Make ADT functions be name-decorated correctly, including replaceing some name-decoration iteration over parameters with iterating over parameter types from the function type

This commit is contained in:
Nathan Braswell
2015-11-21 15:28:57 -05:00
parent db29bdb156
commit 624f070c74
2 changed files with 39 additions and 14 deletions

View File

@@ -210,6 +210,16 @@ void ASTTransformation::secondPass(NodeTree<ASTData>* ast, NodeTree<Symbol>* par
addToScope("operator!=", inequalityFunc, adtDef);
addToScope("~enclosing_scope", adtDef, inequalityFunc);
NodeTree<ASTData>* copy_constructFunc = new NodeTree<ASTData>("function", ASTData(function, Symbol("copy_construct", true), new Type(std::vector<Type*>{thisADTType->withIncreasedIndirectionPtr()}, new Type(void_type))));
adtDef->addChild(copy_constructFunc);
addToScope("copy_construct", copy_constructFunc, adtDef);
addToScope("~enclosing_scope", adtDef, copy_constructFunc);
NodeTree<ASTData>* destructFunc = new NodeTree<ASTData>("function", ASTData(function, Symbol("destruct", true), new Type(std::vector<Type*>(), new Type(void_type))));
adtDef->addChild(destructFunc);
addToScope("destruct", destructFunc, adtDef);
addToScope("~enclosing_scope", adtDef, destructFunc);
for (NodeTree<Symbol>* j : getNodes("adt_option", i)) {
std::string ident_name = concatSymbolTree(getNode("identifier", j));
std::cout << "add ing " << ident_name << " to " << name << " for ADT" << std::endl;