Added a lot to the interpreter, but some odd problem where snprintf seems to print the wrong thing something like a 10th of the time. Debugged it for a while over two days, and I've narrowed it down to the actual snprintf call. It seems to happen under some different circumstances for compiled versions too, so I'm just going to keep it like this for now.

This commit is contained in:
Nathan Braswell
2016-05-18 23:11:00 -07:00
parent 4dcd4f9715
commit ce1afa45f4
4 changed files with 115 additions and 64 deletions

View File

@@ -84,6 +84,15 @@ fun is_dot_style_method_call(node: *ast_node): bool {
is_adt_def(get_ast_scope(node->function_call.func->function_call.parameters[1])->get(string("~enclosing_scope"))[0]))
// should get uglier when we have to figure out if it's just an inside lambda
}
fun method_in_object(method: *ast_node, enclosing_object: *ast_node): bool {
var methods = enclosing_object->type_def.methods
for (var i = 0; i < methods.size; i++;) {
if (methods[i] == method || (is_template(methods[i]) && methods[i]->template.instantiated.contains(method))) {
return true
}
}
return false
}
obj c_generator (Object) {
var id_counter: int
var ast_to_syntax: map<*ast_node, *tree<symbol>>
@@ -789,15 +798,11 @@ obj c_generator (Object) {
}
// handle method call from inside method of same object
if (!dot_style_method_call && enclosing_object) {
var methods = enclosing_object->type_def.methods
for (var i = 0; i < methods.size; i++;) {
if (methods[i] == node->function_call.func || (is_template(methods[i]) && methods[i]->template.instantiated.contains(node->function_call.func))) {
if (enclosing_func && enclosing_func->function.closed_variables.size())
call_string += "(*(closure_data->this))";
else
call_string += "this";
break
}
if (method_in_object(node->function_call.func, enclosing_object)) {
if (enclosing_func && enclosing_func->function.closed_variables.size())
call_string += "(*(closure_data->this))";
else
call_string += "this";
}
}