Closures work\!

This commit is contained in:
Nathan Braswell
2015-06-26 13:29:37 -04:00
parent 542821dd81
commit 1e76bf2772
8 changed files with 102 additions and 73 deletions

View File

@@ -42,8 +42,6 @@ class ASTTransformation: public NodeTransformation<Symbol,ASTData> {
virtual NodeTree<ASTData>* transform(NodeTree<Symbol>* from);
NodeTree<ASTData>* transform(NodeTree<Symbol>* from, NodeTree<ASTData>* scope, std::vector<Type> types, bool limitToFunction, std::map<std::string, Type*> templateTypeReplacements);
std::vector<NodeTree<ASTData>*> transformChildren(std::vector<NodeTree<Symbol>*> children, std::set<int> skipChildren, NodeTree<ASTData>* scope, std::vector<Type> types, bool limitToFunction, std::map<std::string, Type*> templateTypeReplacements);
std::vector<Type> mapNodesToTypes(std::vector<NodeTree<ASTData>*> nodes);
std::vector<Type*> mapNodesToTypePointers(std::vector<NodeTree<ASTData>*> nodes);
std::string concatSymbolTree(NodeTree<Symbol>* root);
NodeTree<ASTData>* doFunction(NodeTree<ASTData>* scope, std::string lookup, std::vector<NodeTree<ASTData>*> nodes, std::map<std::string, Type*> templateTypeReplacements);
@@ -73,4 +71,7 @@ class ASTTransformation: public NodeTransformation<Symbol,ASTData> {
int lambdaID = 0;
};
std::vector<Type> mapNodesToTypes(std::vector<NodeTree<ASTData>*> nodes);
std::vector<Type*> mapNodesToTypePointers(std::vector<NodeTree<ASTData>*> nodes);
#endif

View File

@@ -12,6 +12,8 @@
#include "NodeTree.h"
#include "ASTData.h"
#include "Type.h"
// for mapNodesToTypes
#include "ASTTransformation.h"
#include "util.h"
#include "Poset.h"
@@ -31,6 +33,8 @@ class CGenerator {
std::pair<std::string, std::string> generateTranslationUnit(std::string name, std::map<std::string, NodeTree<ASTData>*> ASTs);
CCodeTriple generate(NodeTree<ASTData>* from, NodeTree<ASTData>* enclosingObject = NULL, bool justFuncName = false, NodeTree<ASTData>* enclosingFunction = NULL);
std::string generateAliasChains(std::map<std::string, NodeTree<ASTData>*> ASTs, NodeTree<ASTData>* definition);
std::string closureStructType(std::set<NodeTree<ASTData>*> closedVariables);
std::string ValueTypeToCType(Type *type, std::string, ClosureTypeSpecialType closureSpecial = ClosureTypeRegularNone);
std::string ValueTypeToCTypeDecoration(Type *type, ClosureTypeSpecialType closureSpecial = ClosureTypeRegularNone);
std::string ValueTypeToCTypeThingHelper(Type *type, std::string ptrStr, ClosureTypeSpecialType closureSpecial);
@@ -52,6 +56,7 @@ class CGenerator {
std::string linkerString;
std::string functionTypedefString;
std::map<Type, std::pair<std::string, std::string>> functionTypedefMap;
std::map<std::set<NodeTree<ASTData>*>, std::string> closureStructMap;
std::vector<std::vector<NodeTree<ASTData>*>> distructDoubleStack;
std::stack<int> loopDistructStackDepth;
std::vector<std::vector<NodeTree<ASTData>*>> deferDoubleStack;