args are now stored with their symbols instead of ther string identifiers

This commit is contained in:
FelixBrendel
2019-08-01 19:48:09 +02:00
parent 7cebcd1823
commit 241ac60ced
11 changed files with 141 additions and 15 deletions
+4 -6
View File
@@ -164,14 +164,12 @@ proc apply_arguments_to_function(Lisp_Object* arguments, Function* function) ->
proc read_rest_arg = [&]() -> void {
if (arguments == Memory::nil) {
if (function->rest_argument) {
try_void sym = Memory::get_or_create_lisp_object_symbol(function->rest_argument);
define_symbol(sym, Memory::nil);
define_symbol(function->rest_argument, Memory::nil);
}
} else {
if (function->rest_argument) {
try_void sym = Memory::get_or_create_lisp_object_symbol(function->rest_argument);
define_symbol(
sym,
function->rest_argument,
// NOTE(Felix): arguments will be a list, and I THINK
// we do not need to copy it...
arguments);
@@ -334,7 +332,7 @@ proc parse_argument_list(Lisp_Object* arguments, Function* function) -> void {
create_parsing_error("After the 'rest' marker there must follow a symbol.");
return;
}
function->rest_argument = arguments->value.pair.first->value.symbol.identifier;
function->rest_argument = arguments->value.pair.first;
if (arguments->value.pair.rest != Memory::nil) {
create_parsing_error("The lambda list must end after the rest symbol");
}
@@ -483,6 +481,7 @@ proc eval_expr(Lisp_Object* node) -> Lisp_Object* {
create_generic_error("%s is not a function.", Lisp_Object_Type_to_string(Memory::get_type(node)));
return nullptr;
}
}
}
@@ -557,6 +556,5 @@ proc interprete_stdin() -> void {
print(evaluated);
printf("\n");
}
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
#include "slime.h"
int main(int argc, char* argv[]) {
if (argc > 1) {
if (argc > 1) {
if (Slime::string_equal(argv[1], "--run-tests")) {
return Slime::run_all_tests() ? 0 : 1;
}
+5 -4
View File
@@ -17,8 +17,8 @@ enum struct Lisp_Object_Type {
String,
Pair,
Continuation,
// Pointer,
// OwningPointer,
Pointer,
OwningPointer,
Function,
CFunction,
};
@@ -95,8 +95,9 @@ struct Function {
Function_Type type;
Positional_Arguments* positional_arguments;
Keyword_Arguments* keyword_arguments;
// rest_argument will be nullptr if no rest argument is declared
String* rest_argument;
// NOTE(Felix): rest_argument will be nullptr if no rest argument
// is declared otherwise its a symbol
Lisp_Object* rest_argument;
Lisp_Object* body; // implicit begin
Environment* parent_environment; // we are doing closures now!!
};