2013-11-01 02:52:18 -04:00
|
|
|
#ifndef CGENERATOR_H
|
|
|
|
|
#define CGENERATOR_H
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <iostream>
|
2014-01-01 17:29:19 -06:00
|
|
|
#include <fstream>
|
2014-12-30 01:22:09 -05:00
|
|
|
#include <utility>
|
2015-05-15 15:19:55 -04:00
|
|
|
#include <stack>
|
2014-12-30 01:22:09 -05:00
|
|
|
#include <sys/stat.h>
|
2013-11-01 02:52:18 -04:00
|
|
|
|
|
|
|
|
#include "NodeTree.h"
|
|
|
|
|
#include "ASTData.h"
|
2013-12-23 01:26:24 -06:00
|
|
|
#include "Type.h"
|
2013-11-01 02:52:18 -04:00
|
|
|
|
2013-12-19 10:39:36 -06:00
|
|
|
#include "util.h"
|
2014-05-21 13:14:16 -04:00
|
|
|
#include "Poset.h"
|
2013-12-19 10:39:36 -06:00
|
|
|
|
2014-12-30 01:22:09 -05:00
|
|
|
// 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.
|
2013-11-01 02:52:18 -04:00
|
|
|
|
|
|
|
|
class CGenerator {
|
|
|
|
|
public:
|
|
|
|
|
CGenerator();
|
|
|
|
|
~CGenerator();
|
2014-01-01 17:29:19 -06:00
|
|
|
void generateCompSet(std::map<std::string, NodeTree<ASTData>*> ASTs, std::string outputName);
|
2014-07-28 01:52:15 -07:00
|
|
|
std::string generateClassStruct(NodeTree<ASTData>* from);
|
2014-12-30 01:22:09 -05:00
|
|
|
bool isUnderTranslationUnit(NodeTree<ASTData>* from, NodeTree<ASTData>* typeDefinition);
|
|
|
|
|
NodeTree<ASTData>* highestScope(NodeTree<ASTData>* node);
|
2015-03-11 01:58:10 -04:00
|
|
|
std::pair<std::string, std::string> generateTranslationUnit(std::string name, std::map<std::string, NodeTree<ASTData>*> ASTs);
|
2015-05-18 04:46:03 -04:00
|
|
|
std::string generate(NodeTree<ASTData>* from, NodeTree<ASTData>* enclosingObject = NULL, bool justFuncName = false);
|
2015-03-11 01:58:10 -04:00
|
|
|
std::string generateAliasChains(std::map<std::string, NodeTree<ASTData>*> ASTs, NodeTree<ASTData>* definition);
|
2015-05-22 22:30:25 -04:00
|
|
|
std::string ValueTypeToCType(Type *type, std::string);
|
|
|
|
|
std::string ValueTypeToCTypeDecoration(Type *type);
|
|
|
|
|
std::string ValueTypeToCTypeThingHelper(Type *type, std::string ptrStr);
|
2014-05-10 19:28:36 -04:00
|
|
|
static std::string CifyName(std::string name);
|
2015-04-04 01:32:40 -04:00
|
|
|
static std::string scopePrefix(NodeTree<ASTData>* from);
|
2014-12-30 01:22:09 -05:00
|
|
|
std::string generateObjectMethod(NodeTree<ASTData>* enclosingObject, NodeTree<ASTData>* from, std::string *functionPrototype);
|
2014-06-10 23:59:39 -07:00
|
|
|
NodeTree<ASTData>* getMethodsObjectType(NodeTree<ASTData>* scope, std::string functionName);
|
2015-05-15 15:19:55 -04:00
|
|
|
std::string tabs();
|
|
|
|
|
|
|
|
|
|
int tabLevel;
|
2013-12-22 01:34:59 -06:00
|
|
|
std::string generatorString;
|
2015-04-10 00:37:31 -04:00
|
|
|
std::string linkerString;
|
2015-05-22 22:30:25 -04:00
|
|
|
std::string functionTypedefString;
|
2015-05-15 15:19:55 -04:00
|
|
|
std::vector<std::vector<NodeTree<ASTData>*>> deferDoubleStack;
|
|
|
|
|
std::stack<int> loopDeferStackDepth;
|
2013-11-01 02:52:18 -04:00
|
|
|
private:
|
|
|
|
|
};
|
2014-06-10 23:59:39 -07:00
|
|
|
#endif
|