|
|
|
@@ -44,6 +44,7 @@ namespace Slime { |
|
|
|
|
|
|
|
Lisp_Object* sym, *val; // used as temp storage to use `try` |
|
|
|
Array_List<Lisp_Object*> read_in_keywords; |
|
|
|
read_in_keywords.alloc(); |
|
|
|
int obligatory_keywords_count = 0; |
|
|
|
int read_obligatory_keywords_count = 0; |
|
|
|
|
|
|
|
@@ -73,6 +74,7 @@ namespace Slime { |
|
|
|
}; |
|
|
|
|
|
|
|
proc read_keyword_args = [&] { |
|
|
|
// debug_break(); |
|
|
|
// keyword arguments: use all given ones and keep track of the |
|
|
|
// added ones (array list), if end of parameters in encountered or |
|
|
|
// something that is not a keyword is encountered or a keyword |
|
|
|
@@ -93,7 +95,7 @@ namespace Slime { |
|
|
|
while (Memory::get_type(next_arg) == Lisp_Object_Type::Keyword) { |
|
|
|
// check if this one is even an accepted keyword |
|
|
|
bool accepted = false; |
|
|
|
for (int i = 0; i < arg_spec->keyword.values.next_index; ++i) { |
|
|
|
for (int i = 0; i < arg_spec->keyword.keywords.next_index; ++i) { |
|
|
|
if (next_arg == arg_spec->keyword.keywords.data[i]) |
|
|
|
{ |
|
|
|
accepted = true; |
|
|
|
@@ -146,12 +148,12 @@ namespace Slime { |
|
|
|
try_void sym = Memory::get_symbol(next_arg->value.symbol); |
|
|
|
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) { |
|
|
|
try_void define_symbol(sym, next_arg); |
|
|
|
} else { |
|
|
|
try_void define_symbol( |
|
|
|
sym, |
|
|
|
try_void define_symbol(sym, |
|
|
|
Memory::copy_lisp_object_except_pairs(next_arg)); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -239,7 +241,6 @@ namespace Slime { |
|
|
|
try check_keyword_args(); |
|
|
|
try read_rest_arg(); |
|
|
|
|
|
|
|
// TODO(Felix): fucking destructors |
|
|
|
return new_env; |
|
|
|
} |
|
|
|
proc create_extended_environment_for_function_application( |
|
|
|
@@ -283,6 +284,10 @@ namespace Slime { |
|
|
|
|
|
|
|
Lisp_Object* sym, *val; // used as temp storage to use `try` |
|
|
|
Array_List<Lisp_Object*> read_in_keywords; |
|
|
|
read_in_keywords.alloc(); |
|
|
|
defer { |
|
|
|
read_in_keywords.dealloc(); |
|
|
|
}; |
|
|
|
int obligatory_keywords_count = 0; |
|
|
|
int read_obligatory_keywords_count = 0; |
|
|
|
|
|
|
|
@@ -664,6 +669,11 @@ namespace Slime { |
|
|
|
Array_List<Action> nas; |
|
|
|
Array_List<int> ams; |
|
|
|
|
|
|
|
cs.alloc(); |
|
|
|
pcs.alloc(); |
|
|
|
nas.alloc(); |
|
|
|
ams.alloc(); |
|
|
|
|
|
|
|
proc debug_step = [&] { |
|
|
|
printf("cs:\n "); |
|
|
|
for (auto lo : cs) { |
|
|
|
@@ -1020,20 +1030,17 @@ namespace Slime { |
|
|
|
|
|
|
|
Lisp_Object* parsed, * evaluated; |
|
|
|
while (true) { |
|
|
|
[&] { |
|
|
|
delete_error(); |
|
|
|
fputs("> ", stdout); |
|
|
|
line = read_expression(); |
|
|
|
defer { |
|
|
|
free(line); |
|
|
|
}; |
|
|
|
try_void parsed = Parser::parse_single_expression(line); |
|
|
|
try_void evaluated = nrc_eval(parsed); |
|
|
|
if (evaluated != Memory::nil) { |
|
|
|
print(evaluated); |
|
|
|
fputs("\n", stdout); |
|
|
|
} |
|
|
|
}(); |
|
|
|
delete_error(); |
|
|
|
fputs("> ", stdout); |
|
|
|
line = read_expression(); |
|
|
|
try_void parsed = Parser::parse_single_expression(line); |
|
|
|
free(line); |
|
|
|
try_void evaluated = nrc_eval(parsed); |
|
|
|
// try_void evaluated = eval_expr(parsed); |
|
|
|
if (evaluated != Memory::nil) { |
|
|
|
print(evaluated); |
|
|
|
fputs("\n", stdout); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |