Add a new method call operator, and more.

The '.' operator now represents method calls. A function f: (a, b)->c
can be called as a.f(b), which is equivalent to f(a, b). Besides
this change, all reserved operators now have a negative precedence
(it's relative, remember?), and some function names were changed.
This commit is contained in:
2018-09-13 17:05:39 -07:00
parent 4425b27b52
commit ca6075e8d5
7 changed files with 103 additions and 13 deletions

View File

@@ -1297,7 +1297,7 @@ libab_result libab_interpreter_run(libab_interpreter* intr, libab_tree* tree,
return result;
}
libab_result libab_interpreter_run_function(libab_interpreter* intr,
libab_result libab_interpreter_call_function(libab_interpreter* intr,
libab_ref* scope,
const char* function,
libab_ref_vec* params,
@@ -1322,6 +1322,21 @@ libab_result libab_interpreter_run_function(libab_interpreter* intr,
return result;
}
libab_result libab_interpreter_call_value(libab_interpreter* intr,
libab_ref* scope,
libab_ref* function,
libab_ref_vec* params,
libab_ref* into) {
struct interpreter_state state;
libab_result result = LIBAB_SUCCESS;
_interpreter_init(&state, intr, scope);
result = _interpreter_try_call(&state, function, params, into);
_interpreter_free(&state);
return result;
}
void libab_interpreter_unit_value(libab_interpreter* intr, libab_ref* into) {
libab_ref_copy(&intr->value_unit, into);
}