Zen
A cross-platform functional programming language

/home/renji/Data/projects/zenlang/sources/zbl/CppGen.hpp

00001 #pragma once
00002 #include "Ast.hpp"
00003 #include "Project.hpp"
00004 
00005 namespace zbl {
00007 
00009     class CppGen {
00010     public:
00012 
00019         static void writeMain(const Build::Project& project, z::stream& src, const Ast::ContinuationImplItem* mainCntn);
00020 
00026         static void writePch(const Build::Project& project);
00027 
00028     public:
00031 
00036         class OutFile {
00037         public:
00040             inline OutFile() {}
00041 
00044             inline ~OutFile() {
00045                 if(_file.isOpen())
00046                     close();
00047             }
00048 
00049         public:
00056             void open(const Build::Project& project, const z::string& dir, const z::string& filename, const z::string& ext);
00057 
00060             void close();
00061 
00064             inline z::string getFilename() const { return z::string(_file.getFileName());}
00065 
00068             inline z::stream& operator()() { return _stream;}
00069 
00070         private:
00072             z::file _file;
00073 
00075             z::filestream _stream;
00076         };
00077 
00078     public:
00082         inline CppGen(const Build::Project& project) : _project(project) {}
00083 
00084     public:
00087         inline z::string getImportFileName() const {return z::string(_imp.getFilename());}
00088 
00091         inline z::string getHeaderFileName() const {return z::string(_hdr.getFilename());}
00092 
00095         inline z::string getSourceFileName() const {return z::string(_src.getFilename());}
00096 
00097     public:
00101         void generate(const Ast::Unit& unit);
00102 
00103     private:
00107         inline void open(const z::fileinfo& fi);
00108 
00111         inline void close();
00112 
00113     private:
00115         const Build::Project& _project;
00116 
00117     private:
00119         OutFile _imp;
00120 
00122         OutFile _hdr;
00123 
00125         OutFile _src;
00126 
00127     private:
00129         z::stringlist _hdrList;
00130 
00132         z::stringlist _srcList;
00133     };
00134 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines