|
|
|
@@ -1,7 +1,9 @@ |
|
|
|
namespace Slime { |
|
|
|
|
|
|
|
proc create_extended_environment_for_function_application_nrc( |
|
|
|
Array_List<Lisp_Object*> cs, |
|
|
|
// TODO(Felix): pass cs as value as soon as we got rid of |
|
|
|
// destructors, to prevent destroying it on scope exit |
|
|
|
Array_List<Lisp_Object*>* cs, |
|
|
|
Lisp_Object* function, |
|
|
|
int arg_start, |
|
|
|
int arg_count) -> Environment* |
|
|
|
@@ -45,7 +47,7 @@ namespace Slime { |
|
|
|
int obligatory_keywords_count = 0; |
|
|
|
int read_obligatory_keywords_count = 0; |
|
|
|
|
|
|
|
Lisp_Object* next_arg = cs.data[arg_start]; |
|
|
|
Lisp_Object* next_arg = cs->data[arg_start]; |
|
|
|
|
|
|
|
proc read_positional_args = [&] { |
|
|
|
for (int i = 0; i < arg_spec->positional.symbols.next_index; ++i) { |
|
|
|
@@ -65,7 +67,7 @@ namespace Slime { |
|
|
|
sym, |
|
|
|
Memory::copy_lisp_object_except_pairs(next_arg)); |
|
|
|
} |
|
|
|
next_arg = cs[++arg_start]; |
|
|
|
next_arg = cs->data[++arg_start]; |
|
|
|
--arg_count; |
|
|
|
} |
|
|
|
}; |
|
|
|
@@ -142,7 +144,7 @@ namespace Slime { |
|
|
|
|
|
|
|
// if not set it and then add it to the array list |
|
|
|
try_void sym = Memory::get_symbol(next_arg->value.symbol); |
|
|
|
next_arg = cs[++arg_start]; |
|
|
|
next_arg = cs->data[++arg_start]; |
|
|
|
--arg_count; |
|
|
|
// NOTE(Felix): It seems we do not need to evaluate the argument here... |
|
|
|
if (is_c_function) { |
|
|
|
@@ -157,7 +159,7 @@ namespace Slime { |
|
|
|
++read_obligatory_keywords_count; |
|
|
|
|
|
|
|
// overstep both for next one |
|
|
|
next_arg = cs[++arg_start]; |
|
|
|
next_arg = cs->data[++arg_start]; |
|
|
|
--arg_count; |
|
|
|
|
|
|
|
if (arg_count == 0) { |
|
|
|
@@ -213,12 +215,12 @@ namespace Slime { |
|
|
|
Lisp_Object* list; |
|
|
|
try_void list = Memory::create_list(next_arg); |
|
|
|
Lisp_Object* head = list; |
|
|
|
next_arg = cs[++arg_start]; |
|
|
|
next_arg = cs->data[++arg_start]; |
|
|
|
--arg_count; |
|
|
|
while (arg_count > 0) { |
|
|
|
try_void head->value.pair.rest = Memory::create_list(next_arg); |
|
|
|
head = head->value.pair.rest; |
|
|
|
next_arg = cs[++arg_start]; |
|
|
|
next_arg = cs->data[++arg_start]; |
|
|
|
--arg_count; |
|
|
|
} |
|
|
|
define_symbol(arg_spec->rest, list); |
|
|
|
@@ -238,7 +240,6 @@ namespace Slime { |
|
|
|
try read_rest_arg(); |
|
|
|
|
|
|
|
// TODO(Felix): fucking destructors |
|
|
|
cs.data = nullptr; |
|
|
|
return new_env; |
|
|
|
} |
|
|
|
proc create_extended_environment_for_function_application( |
|
|
|
@@ -781,7 +782,6 @@ namespace Slime { |
|
|
|
Lisp_Object* args = pcs[--pcs.next_index]; |
|
|
|
int length = list_length(args); |
|
|
|
cs.reserve(length); |
|
|
|
printf("aaaaaa\n\n"); |
|
|
|
for_lisp_list(args) { |
|
|
|
cs.data[cs.next_index - 1 + (length - it_index)] = it; |
|
|
|
nas.append(Action::Eval); |
|
|
|
@@ -798,7 +798,7 @@ namespace Slime { |
|
|
|
Action current_action; |
|
|
|
Lisp_Object* pc; |
|
|
|
while (nas.next_index > 0) { |
|
|
|
debug_step(); |
|
|
|
// debug_step(); |
|
|
|
|
|
|
|
current_action = nas.data[--nas.next_index]; |
|
|
|
switch (current_action) { |
|
|
|
@@ -871,7 +871,7 @@ namespace Slime { |
|
|
|
Lisp_Object_Type type = Memory::get_type(function); |
|
|
|
Environment* extended_env = |
|
|
|
create_extended_environment_for_function_application_nrc( |
|
|
|
cs, function, am+1, cs.next_index-am-1); |
|
|
|
&cs, function, am+1, cs.next_index-am-1); |
|
|
|
cs.next_index = am; |
|
|
|
push_environment(extended_env); |
|
|
|
if (type == Lisp_Object_Type::CFunction) { |
|
|
|
@@ -914,12 +914,13 @@ namespace Slime { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
debug_step(); |
|
|
|
// debug_step(); |
|
|
|
|
|
|
|
return cs.data[--cs.next_index]; |
|
|
|
} |
|
|
|
|
|
|
|
proc eval_expr(Lisp_Object* node) -> Lisp_Object* { |
|
|
|
return nrc_eval(node); |
|
|
|
profile_this(); |
|
|
|
|
|
|
|
using namespace Globals::Current_Execution; |
|
|
|
@@ -1020,12 +1021,12 @@ namespace Slime { |
|
|
|
Lisp_Object* parsed, * evaluated; |
|
|
|
while (true) { |
|
|
|
[&] { |
|
|
|
// delete_error(); |
|
|
|
delete_error(); |
|
|
|
fputs("> ", stdout); |
|
|
|
line = read_expression(); |
|
|
|
// defer { |
|
|
|
// free(line); |
|
|
|
// }; |
|
|
|
defer { |
|
|
|
free(line); |
|
|
|
}; |
|
|
|
try_void parsed = Parser::parse_single_expression(line); |
|
|
|
try_void evaluated = nrc_eval(parsed); |
|
|
|
if (evaluated != Memory::nil) { |
|
|
|
|