From ac8493d7f364d7a20f479d0ca72d1dec2ed3be6a Mon Sep 17 00:00:00 2001 From: Nathan Braswell Date: Thu, 10 Mar 2016 16:07:12 -0500 Subject: [PATCH] 62 tests passing - the two Kalypso misses that Cephalapod doesn't is string because of taking the address of a literal (which I want to fix in a broader way that will also make Kalypso pass the other tests that Cephelapod is failing because of reference of literal) and ADT, which is the last (or perhaps second to last) thing to implement. --- stdlib/c_generator.krak | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/stdlib/c_generator.krak b/stdlib/c_generator.krak index 7407d3b..588ac74 100644 --- a/stdlib/c_generator.krak +++ b/stdlib/c_generator.krak @@ -639,9 +639,12 @@ obj c_generator (Object) { if (func_return_type->is_object() && func_return_type->indirection == 0 && has_method(func_return_type->type_def, "destruct", vector<*type>())) call_string.post += generate_statement(ast_statement_ptr(make_method_call(temp_ident, "destruct", vector<*ast_node>())), enclosing_object, enclosing_func, null>>>()).one_string() } - var ref_pre = code_triple() - if (func_return_type->is_ref) - ref_pre += "*" + var ref_pre = string() + var ref_post = string() + if (func_return_type->is_ref) { + ref_pre += "(*" + ref_post += ")" + } if (!is_function(node->function_call.func) || node->function_call.func->function.closed_variables.size()) { // not function, so we must be an identifier or function call return or something if (!dot_style_method_call) { @@ -675,7 +678,8 @@ obj c_generator (Object) { call_string.pre += string("else ") + pre_call + " = ((" + type_to_c(func_type) + "_without_data) " + func_name+".func)(" + call_string.value + ");\n" call_string.value = pre_call } - return ref_pre + call_string + call_string.value = ref_pre + call_string.value + ref_post + return call_string } } if (pre_call != "") { @@ -684,7 +688,8 @@ obj c_generator (Object) { } else { call_string.value = func_name + "(" + call_string.value + ")" } - return ref_pre + call_string + call_string.value = ref_pre + call_string.value + ref_post + return call_string } // for now, anyway