Now allow one-line functions without codeblocks\! (espically nice for lambdas) fun a():void println(4), or fun():void println(7)

This commit is contained in:
Nathan Braswell
2015-05-27 12:27:50 -04:00
parent 85834789e4
commit b71bb84070
5 changed files with 39 additions and 7 deletions

View File

@@ -474,7 +474,7 @@ NodeTree<ASTData>* ASTTransformation::transform(NodeTree<Symbol>* from, NodeTree
newNode->addChildren(parameters);
// update type with actual type
newNode->getDataRef()->valueType = new Type(mapNodesToTypePointers(parameters), newNode->getDataRef()->valueType);
newNode->addChild(transform(getNode("code_block", children), scope, types, templateTypeReplacements));
newNode->addChild(transform(getNode("statement", children), scope, types, templateTypeReplacements));
std::cout << "finished function" << functionName << std::endl;
return newNode;
@@ -1545,7 +1545,7 @@ NodeTree<ASTData>* ASTTransformation::findOrInstantiateFunctionTemplate(std::vec
instantiatedFunction->addChildren(parameters);
// update type with actual type
instantiatedFunction->getDataRef()->valueType = new Type(mapNodesToTypePointers(parameters), instantiatedFunction->getDataRef()->valueType);
instantiatedFunction->addChild(transform(getNode("code_block", templateSyntaxTree->getChildren()), instantiatedFunction, std::vector<Type>(), newTemplateTypeReplacement));
instantiatedFunction->addChild(transform(getNode("statement", templateSyntaxTree->getChildren()), instantiatedFunction, std::vector<Type>(), newTemplateTypeReplacement));
std::cout << "Fully Instantiated function " << functionName << " to " << fullyInstantiatedName << std::endl;
return instantiatedFunction;