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:
1 parent
b686d15705
commit
7b8436acb4
7 files changed
+46
-10
No files matched your search
@@ -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);
|
||||
}
|
||||
@@ -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
@@ -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());
|
||||
|
||||
Reference in new issue
Block a user