#ifndef CGENERATOR_H #define CGENERATOR_H #include #include #include #include #include #include #include "CCodeTriple.h" #include "NodeTree.h" #include "ASTData.h" #include "Type.h" #include "util.h" #include "Poset.h" // Note the use of std::pair to hold two strings - the running string for the header file and the running string for the c file. class CGenerator { public: CGenerator(); ~CGenerator(); void generateCompSet(std::map*> ASTs, std::string outputName); std::string generateClassStruct(NodeTree* from); bool isUnderTranslationUnit(NodeTree* from, NodeTree* typeDefinition); NodeTree* highestScope(NodeTree* node); std::pair generateTranslationUnit(std::string name, std::map*> ASTs); CCodeTriple generate(NodeTree* from, NodeTree* enclosingObject = NULL, bool justFuncName = false); std::string generateAliasChains(std::map*> ASTs, NodeTree* definition); std::string ValueTypeToCType(Type *type, std::string); std::string ValueTypeToCTypeDecoration(Type *type); std::string ValueTypeToCTypeThingHelper(Type *type, std::string ptrStr); static std::string CifyName(std::string name); static std::string scopePrefix(NodeTree* from); std::string generateObjectMethod(NodeTree* enclosingObject, NodeTree* from, std::string *functionPrototype); NodeTree* getMethodsObjectType(NodeTree* scope, std::string functionName); NodeTree* getMethod(Type* type, std::string method); bool methodExists(Type* type, std::string method); std::string generateMethodIfExists(Type* type, std::string method, std::string parameter); std::string emitDestructors(std::vector*> possibleDeclarations, NodeTree* enclosingObject); std::string tabs(); std::string getID(); int tabLevel; int id; std::string generatorString; std::string linkerString; std::string functionTypedefString; std::vector*>> distructDoubleStack; std::stack loopDistructStackDepth; std::vector*>> deferDoubleStack; std::stack loopDeferStackDepth; private: }; #endif