new shorthand syntax for simple_passthrough if assigning to same name simple_passthrough(i=i, j=j : j = j:) becomes simple_passthrough(i,j : j :)
This commit is contained in:
@@ -43,7 +43,7 @@ in_passthrough_params = opt_param_assign_list ;
|
||||
out_passthrough_params = opt_param_assign_list ;
|
||||
opt_param_assign_list = param_assign_list | ;
|
||||
param_assign_list = param_assign WS "," WS param_assign_list | param_assign ;
|
||||
param_assign = identifier WS "=" WS identifier ;
|
||||
param_assign = identifier WS "=" WS identifier | identifier ;
|
||||
opt_string = string | ;
|
||||
|
||||
triple_quoted_string = "\"\"\"((\"\"(`|1|2|3|4|5|6|7|8|9|0|-|=| |q|w|e|r|t|y|u|i|o|p|[|]|\\|a|s|d|f|g|h|j|k|l|;|'|
|
||||
|
||||
@@ -512,9 +512,15 @@ CCodeTriple CGenerator::generate(NodeTree<ASTData>* from, NodeTree<ASTData>* enc
|
||||
for (auto assign : in_or_out->getChildren()) {
|
||||
auto assignChildren = assign->getChildren();
|
||||
if (in_or_out->getDataRef()->type == in_passthrough_params)
|
||||
pre_passthrough += ValueTypeToCType(assignChildren[0]->getDataRef()->valueType, assignChildren[1]->getDataRef()->symbol.getName()) + " = " + generate(assignChildren[0], enclosingObject).oneString() + ";\n";
|
||||
if (assignChildren.size() == 2)
|
||||
pre_passthrough += ValueTypeToCType(assignChildren[0]->getDataRef()->valueType, assignChildren[1]->getDataRef()->symbol.getName()) + " = " + generate(assignChildren[0], enclosingObject).oneString() + ";\n";
|
||||
else
|
||||
pre_passthrough += ValueTypeToCType(assignChildren[0]->getDataRef()->valueType, assignChildren[0]->getDataRef()->symbol.getName()) + " = " + generate(assignChildren[0], enclosingObject).oneString() + ";\n";
|
||||
else if (in_or_out->getDataRef()->type == out_passthrough_params)
|
||||
post_passthrough += generate(assignChildren[0], enclosingObject, justFuncName).oneString() + " = " + assignChildren[1]->getDataRef()->symbol.getName() + ";\n";
|
||||
if (assignChildren.size() == 2)
|
||||
post_passthrough += generate(assignChildren[0], enclosingObject, justFuncName).oneString() + " = " + assignChildren[1]->getDataRef()->symbol.getName() + ";\n";
|
||||
else
|
||||
post_passthrough += generate(assignChildren[0], enclosingObject, justFuncName).oneString() + " = " + assignChildren[0]->getDataRef()->symbol.getName() + ";\n";
|
||||
else
|
||||
linkerString += " " + strSlice(generate(in_or_out, enclosingObject, justFuncName).oneString(), 1, -2) + " ";
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
same_file: 5
|
||||
diff_file: 7
|
||||
diff_file: 13
|
||||
diff_file: 1337
|
||||
|
||||
@@ -19,6 +19,14 @@ fun main(): int {
|
||||
j = i + j;
|
||||
"""
|
||||
c_passthrough_diff::print_it(j)
|
||||
|
||||
// test new shorthand for same name assignments
|
||||
var r: int = 1000;
|
||||
var s: int = 337;
|
||||
__if_comp__ __C__ simple_passthrough(r, s : s:) """
|
||||
s = r + s;
|
||||
"""
|
||||
c_passthrough_diff::print_it(s)
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user