added Compiler class to pass to Node::process() instead of a FILE *

git-svn-id: svn://anubis/jtlc/trunk@22 f5bc74b8-7b62-4e90-9214-7121d538519f
This commit is contained in:
josh committed 2010-01-14 20:27:01 +00:00
1 parent b686d15705
commit 7b8436acb4
7 files changed
+46 -10

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
#include "Compiler.h"
#include <string>
using namespace std;
Compiler::Compiler(FILE * output_file)
{
m_outfile = output_file;
}
void Compiler::write(const string & str)
{
fputs(str.c_str(), m_outfile);
}
+18
View File
@@ -0,0 +1,18 @@
#ifndef COMPILER_H
#define COMPILER_H
#include <stdio.h>
#include <string>
class Compiler
{
public:
Compiler(FILE * output_file);
void write(const std::string & str);
protected:
FILE * m_outfile;
};
#endif
+2 -1
View File
@@ -53,7 +53,8 @@ string compile(const char * filename)
string obj_filename = string(filename) + ".o";
FILE * out = fopen(out_filename.c_str(), "w");
refptr<Node> tree = parse(filename);
tree->process(out);
refptr<Compiler> compiler = new Compiler(out);
tree->process(compiler);
fclose(out);
ccompile(out_filename.c_str(), obj_filename.c_str());
// unlink(out_filename.c_str());