Added mem::safe_recursive_clone, and while it works for regex, it's actually slower then remaking it. Hmmmm, maybe because some of the stdlib is inefficent
This commit is contained in:
@@ -692,21 +692,23 @@ NodeTree<ASTData>* ASTTransformation::transform(NodeTree<Symbol>* from, NodeTree
|
||||
return newNode;
|
||||
}
|
||||
|
||||
auto boolExp = getNode("boolean_expression", children);
|
||||
NodeTree<ASTData>* toAssign = boolExp ? transform(boolExp, scope, types, limitToFunction, templateTypeReplacements) : nullptr;
|
||||
// for type inferencing
|
||||
if (!identifierType) {
|
||||
if (toAssign)
|
||||
identifierType = toAssign->getDataRef()->valueType;
|
||||
else
|
||||
throw "have to inference but no expression";
|
||||
}
|
||||
|
||||
NodeTree<ASTData>* newIdentifier = new NodeTree<ASTData>("identifier", ASTData(identifier, Symbol(newIdentifierStr, true), identifierType));
|
||||
addToScope(newIdentifierStr, newIdentifier, scope);
|
||||
addToScope("~enclosing_scope", scope, newNode);
|
||||
addToScope("~enclosing_scope", newNode, newIdentifier);
|
||||
|
||||
auto boolExp = getNode("boolean_expression", children);
|
||||
NodeTree<ASTData>* toAssign = boolExp ? transform(boolExp, scope, types, limitToFunction, templateTypeReplacements) : nullptr;
|
||||
// for type inferencing
|
||||
if (!identifierType) {
|
||||
if (toAssign) {
|
||||
identifierType = toAssign->getDataRef()->valueType;
|
||||
newIdentifier->getDataRef()->valueType = identifierType;
|
||||
} else
|
||||
throw "have to inference but no expression";
|
||||
}
|
||||
|
||||
|
||||
newNode->addChild(newIdentifier);
|
||||
if (toAssign)
|
||||
newNode->addChild(toAssign);
|
||||
@@ -791,7 +793,7 @@ NodeTree<ASTData>* ASTTransformation::transform(NodeTree<Symbol>* from, NodeTree
|
||||
throw "Ambigious parse!";
|
||||
} else {
|
||||
// Should get rid of this eventually. Right now it handles cases like sign, alpha, a comma, etc
|
||||
std::cout << "Unhandled syntax node: " << name << std::endl;
|
||||
//std::cout << "Unhandled syntax node: " << name << std::endl;
|
||||
return new NodeTree<ASTData>();
|
||||
}
|
||||
|
||||
|
||||
@@ -566,7 +566,11 @@ CCodeTriple CGenerator::generate(NodeTree<ASTData>* from, NodeTree<ASTData>* enc
|
||||
output.value += toAssign.postValue;
|
||||
return output;
|
||||
} else {
|
||||
return ValueTypeToCType(children[0]->getData().valueType, generate(children[0], enclosingObject, justFuncName, enclosingFunction).oneString()) + " = " + generate(children[1], enclosingObject, true, enclosingFunction) + ";";
|
||||
// we might use this address in the right hand side (recursive closures), so split it up
|
||||
std::string assignTo = generate(children[0], enclosingObject, justFuncName, enclosingFunction).oneString();
|
||||
output.preValue = ValueTypeToCType(children[0]->getData().valueType, assignTo) + ";\n";
|
||||
output += assignTo + " = " + generate(children[1], enclosingObject, true, enclosingFunction) + ";";
|
||||
return output;
|
||||
}
|
||||
}
|
||||
case if_comp:
|
||||
|
||||
Reference in New Issue
Block a user