summaryrefslogtreecommitdiff
path: root/src/chillASTs.cc
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2016-10-05 17:33:25 -0600
committerTuowen Zhao <ztuowen@gmail.com>2016-10-05 17:33:25 -0600
commit64915c9dd543c847d7b54cdad5f83c12b579c233 (patch)
tree10551e451bf73d28ed788fae2d6c477e80c1b6f2 /src/chillASTs.cc
parent342af96cd123860b3fbe0fe9b0669627cefca1cc (diff)
downloadchill-64915c9dd543c847d7b54cdad5f83c12b579c233.tar.gz
chill-64915c9dd543c847d7b54cdad5f83c12b579c233.tar.bz2
chill-64915c9dd543c847d7b54cdad5f83c12b579c233.zip
working clang frontend
Diffstat (limited to 'src/chillASTs.cc')
-rw-r--r--src/chillASTs.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/chillASTs.cc b/src/chillASTs.cc
index a632441..5324ef2 100644
--- a/src/chillASTs.cc
+++ b/src/chillASTs.cc
@@ -3,6 +3,7 @@
#include <chilldebug.h>
#include <stack>
+#include <fstream>
#include "chillAST.h"
#include "printer/dump.h"
#include "printer/cfamily.h"
@@ -218,13 +219,13 @@ void chillAST_SourceFile::printToFile(char *filename) {
}
} else strcpy(fn, filename);
- FILE *fp = fopen(fn, "w");
- if (!fp) {
- fprintf(stderr, "can't open file '%s' for writing\n", fn);
+ std::ofstream fo(fn);
+ if (fo.fail()) {
+ CHILL_ERROR("can't open file '%s' for writing\n", fn);
exit(-1);
}
- fprintf(fp, "\n\n");
- print(0, fp);
+ chill::printer::CFamily cp;
+ cp.print("",this,fo);
}