Added copy_constructing when returning
This commit is contained in:
@@ -351,17 +351,17 @@ fun make_method_call(object_ident: *ast_node, method: *ast_node, parameters: vec
|
||||
var method_access = ast_function_call_ptr(get_builtin_function(string("."), vector(get_ast_type(object_ident), get_ast_type(method))), vector(object_ident, method))
|
||||
return ast_function_call_ptr(method_access, parameters)
|
||||
}
|
||||
fun make_operator_call(left: *ast_node, func: *char, right: *ast_node): *ast_node return make_operator_call(left, string(func), right);
|
||||
fun make_operator_call(left: *ast_node, func: string, right: *ast_node): *ast_node {
|
||||
return ast_function_call_ptr(get_builtin_function(func, vector(get_ast_type(left), get_ast_type(right))), vector(left, right))
|
||||
fun make_operator_call(func: *char, params: vector<*ast_node>): *ast_node return make_operator_call(string(func), params);
|
||||
fun make_operator_call(func: string, params: vector<*ast_node>): *ast_node {
|
||||
return ast_function_call_ptr(get_builtin_function(func, params.map(fun(p:*ast_node): *type return get_ast_type(p);)), params)
|
||||
}
|
||||
fun transform_assignment_statement(node: *tree<symbol>, scope: *ast_node): *ast_node {
|
||||
var assign_to = transform(get_node("factor", node), scope)
|
||||
var to_assign = transform(get_node("boolean_expression", node), scope)
|
||||
if (get_node("\"\\+=\"", node)) to_assign = make_operator_call(assign_to, "+", to_assign)
|
||||
else if (get_node("\"-=\"", node)) to_assign = make_operator_call(assign_to, "-", to_assign)
|
||||
else if (get_node("\"\\*=\"", node)) to_assign = make_operator_call(assign_to, "*", to_assign)
|
||||
else if (get_node("\"/=\"", node)) to_assign = make_operator_call(assign_to, "/", to_assign)
|
||||
if (get_node("\"\\+=\"", node)) to_assign = make_operator_call("+", vector(to_assign, to_assign))
|
||||
else if (get_node("\"-=\"", node)) to_assign = make_operator_call("-", vector(to_assign, to_assign))
|
||||
else if (get_node("\"\\*=\"", node)) to_assign = make_operator_call("*", vector(to_assign, to_assign))
|
||||
else if (get_node("\"/=\"", node)) to_assign = make_operator_call("/", vector(to_assign, to_assign))
|
||||
var assignment = ast_assignment_statement_ptr(assign_to, to_assign)
|
||||
return assignment
|
||||
}
|
||||
@@ -451,6 +451,10 @@ fun transform_expression(node: *tree<symbol>, scope: *ast_node, searching_for: s
|
||||
fun get_builtin_function(name: string, param_types: vector<*type>): *ast_node {
|
||||
if (name == "." || name == "->")
|
||||
return ast_function_ptr(name, type_ptr(param_types, param_types[1]), vector<*ast_node>())
|
||||
if (name == "&")
|
||||
return ast_function_ptr(name, type_ptr(param_types, param_types[0]->clone_with_increased_indirection()), vector<*ast_node>())
|
||||
if (name == "\\*")
|
||||
return ast_function_ptr(name, type_ptr(param_types, param_types[0]->clone_with_decreased_indirection()), vector<*ast_node>())
|
||||
return ast_function_ptr(name, type_ptr(param_types, param_types[0]), vector<*ast_node>())
|
||||
}
|
||||
fun function_lookup(name: string, scope: *ast_node, param_types: vector<*type>): *ast_node {
|
||||
|
||||
Reference in New Issue
Block a user