|
|
@@ -46,6 +46,7 @@ proc add_to_load_path(const char* path) -> void { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
proc built_in_load(String* file_name) -> Lisp_Object* { |
|
|
proc built_in_load(String* file_name) -> Lisp_Object* { |
|
|
|
|
|
profile_this(); |
|
|
char* file_content; |
|
|
char* file_content; |
|
|
char fullpath[4096]; |
|
|
char fullpath[4096]; |
|
|
sprintf(fullpath, "%s", Memory::get_c_str(file_name)); |
|
|
sprintf(fullpath, "%s", Memory::get_c_str(file_name)); |
|
|
@@ -89,6 +90,7 @@ proc built_in_load(String* file_name) -> Lisp_Object* { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
proc built_in_import(String* file_name) -> Lisp_Object* { |
|
|
proc built_in_import(String* file_name) -> Lisp_Object* { |
|
|
|
|
|
profile_this(); |
|
|
Environment* new_env; |
|
|
Environment* new_env; |
|
|
|
|
|
|
|
|
new_env = Memory::file_to_env_map.get_object(Memory::get_c_str(file_name)); |
|
|
new_env = Memory::file_to_env_map.get_object(Memory::get_c_str(file_name)); |
|
|
@@ -114,12 +116,15 @@ proc built_in_import(String* file_name) -> Lisp_Object* { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
proc load_built_ins_into_environment() -> void* { |
|
|
proc load_built_ins_into_environment() -> void* { |
|
|
|
|
|
profile_this(); |
|
|
String* file_name_built_ins = Memory::create_string(__FILE__); |
|
|
String* file_name_built_ins = Memory::create_string(__FILE__); |
|
|
|
|
|
|
|
|
define((helper), "") { |
|
|
define((helper), "") { |
|
|
|
|
|
profile_with_name("(helper)"); |
|
|
return Memory::create_lisp_object_number(101); |
|
|
return Memory::create_lisp_object_number(101); |
|
|
}; |
|
|
}; |
|
|
define((test (:k (helper))), "") { |
|
|
define((test (:k (helper))), "") { |
|
|
|
|
|
profile_with_name("(test)"); |
|
|
fetch(k); |
|
|
fetch(k); |
|
|
return k; |
|
|
return k; |
|
|
}; |
|
|
}; |
|
|
@@ -127,6 +132,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
"Takes 0 or more arguments and returns =t= if all arguments are equal " |
|
|
"Takes 0 or more arguments and returns =t= if all arguments are equal " |
|
|
"and =()= otherwise.") |
|
|
"and =()= otherwise.") |
|
|
{ |
|
|
{ |
|
|
|
|
|
profile_with_name("(=)"); |
|
|
fetch(args); |
|
|
fetch(args); |
|
|
|
|
|
|
|
|
if (args == Memory::nil) |
|
|
if (args == Memory::nil) |
|
|
@@ -143,6 +149,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
}; |
|
|
}; |
|
|
define((> . args), "TODO") |
|
|
define((> . args), "TODO") |
|
|
{ |
|
|
{ |
|
|
|
|
|
profile_with_name("(>)"); |
|
|
fetch(args); |
|
|
fetch(args); |
|
|
double last_number = strtod("Inf", NULL); |
|
|
double last_number = strtod("Inf", NULL); |
|
|
|
|
|
|
|
|
@@ -157,6 +164,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
}; |
|
|
}; |
|
|
define((>= . args), "TODO") |
|
|
define((>= . args), "TODO") |
|
|
{ |
|
|
{ |
|
|
|
|
|
profile_with_name("(>=)"); |
|
|
fetch(args); |
|
|
fetch(args); |
|
|
double last_number = strtod("Inf", NULL); |
|
|
double last_number = strtod("Inf", NULL); |
|
|
|
|
|
|
|
|
@@ -171,6 +179,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
}; |
|
|
}; |
|
|
define((< . args), "TODO") |
|
|
define((< . args), "TODO") |
|
|
{ |
|
|
{ |
|
|
|
|
|
profile_with_name("(<)"); |
|
|
fetch(args); |
|
|
fetch(args); |
|
|
double last_number = strtod("-Inf", NULL); |
|
|
double last_number = strtod("-Inf", NULL); |
|
|
|
|
|
|
|
|
@@ -185,6 +194,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
}; |
|
|
}; |
|
|
define((<= . args), "TODO") |
|
|
define((<= . args), "TODO") |
|
|
{ |
|
|
{ |
|
|
|
|
|
profile_with_name("(<=)"); |
|
|
fetch(args); |
|
|
fetch(args); |
|
|
double last_number = strtod("-Inf", NULL); |
|
|
double last_number = strtod("-Inf", NULL); |
|
|
|
|
|
|
|
|
@@ -199,6 +209,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
}; |
|
|
}; |
|
|
define((+ . args), "TODO") |
|
|
define((+ . args), "TODO") |
|
|
{ |
|
|
{ |
|
|
|
|
|
profile_with_name("(+)"); |
|
|
fetch(args); |
|
|
fetch(args); |
|
|
double sum = 0; |
|
|
double sum = 0; |
|
|
|
|
|
|
|
|
@@ -211,6 +222,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
}; |
|
|
}; |
|
|
define((- . args), "TODO") |
|
|
define((- . args), "TODO") |
|
|
{ |
|
|
{ |
|
|
|
|
|
profile_with_name("(-)"); |
|
|
fetch(args); |
|
|
fetch(args); |
|
|
if (args == Memory::nil) |
|
|
if (args == Memory::nil) |
|
|
return Memory::create_lisp_object_number(0); |
|
|
return Memory::create_lisp_object_number(0); |
|
|
@@ -232,6 +244,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
}; |
|
|
}; |
|
|
define((* . args), "TODO") |
|
|
define((* . args), "TODO") |
|
|
{ |
|
|
{ |
|
|
|
|
|
profile_with_name("(*)"); |
|
|
fetch(args); |
|
|
fetch(args); |
|
|
if (args == Memory::nil) { |
|
|
if (args == Memory::nil) { |
|
|
return Memory::create_lisp_object_number(1); |
|
|
return Memory::create_lisp_object_number(1); |
|
|
@@ -248,6 +261,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
}; |
|
|
}; |
|
|
define((/ . args), "TODO") |
|
|
define((/ . args), "TODO") |
|
|
{ |
|
|
{ |
|
|
|
|
|
profile_with_name("(/)"); |
|
|
fetch(args); |
|
|
fetch(args); |
|
|
|
|
|
|
|
|
if (args == Memory::nil) { |
|
|
if (args == Memory::nil) { |
|
|
@@ -266,6 +280,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return Memory::create_lisp_object_number(quotient); |
|
|
return Memory::create_lisp_object_number(quotient); |
|
|
}; |
|
|
}; |
|
|
define((** a b), "TODO") { |
|
|
define((** a b), "TODO") { |
|
|
|
|
|
profile_with_name("(**)"); |
|
|
fetch(a, b); |
|
|
fetch(a, b); |
|
|
try assert_type(a, Lisp_Object_Type::Number); |
|
|
try assert_type(a, Lisp_Object_Type::Number); |
|
|
try assert_type(b, Lisp_Object_Type::Number); |
|
|
try assert_type(b, Lisp_Object_Type::Number); |
|
|
@@ -273,6 +288,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
b->value.number)); |
|
|
b->value.number)); |
|
|
}; |
|
|
}; |
|
|
define((% a b), "TODO") { |
|
|
define((% a b), "TODO") { |
|
|
|
|
|
profile_with_name("(%)"); |
|
|
fetch(a, b); |
|
|
fetch(a, b); |
|
|
try assert_type(a, Lisp_Object_Type::Number); |
|
|
try assert_type(a, Lisp_Object_Type::Number); |
|
|
try assert_type(b, Lisp_Object_Type::Number); |
|
|
try assert_type(b, Lisp_Object_Type::Number); |
|
|
@@ -280,6 +296,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
(int)b->value.number); |
|
|
(int)b->value.number); |
|
|
}; |
|
|
}; |
|
|
define((get-random-between a b), "TODO") { |
|
|
define((get-random-between a b), "TODO") { |
|
|
|
|
|
profile_with_name("(get-random-between)"); |
|
|
fetch(a, b); |
|
|
fetch(a, b); |
|
|
try assert_type(a, Lisp_Object_Type::Number); |
|
|
try assert_type(a, Lisp_Object_Type::Number); |
|
|
try assert_type(b, Lisp_Object_Type::Number); |
|
|
try assert_type(b, Lisp_Object_Type::Number); |
|
|
@@ -293,6 +310,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return Memory::create_lisp_object_number(x); |
|
|
return Memory::create_lisp_object_number(x); |
|
|
}; |
|
|
}; |
|
|
define_special((bound? var), "TODO") { |
|
|
define_special((bound? var), "TODO") { |
|
|
|
|
|
profile_with_name("(bound?)"); |
|
|
fetch(var); |
|
|
fetch(var); |
|
|
try assert_type(var, Lisp_Object_Type::Symbol); |
|
|
try assert_type(var, Lisp_Object_Type::Symbol); |
|
|
|
|
|
|
|
|
@@ -305,6 +323,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return Memory::nil; |
|
|
return Memory::nil; |
|
|
}; |
|
|
}; |
|
|
define((assert test), "TODO") { |
|
|
define((assert test), "TODO") { |
|
|
|
|
|
profile_with_name("(assert)"); |
|
|
fetch(test); |
|
|
fetch(test); |
|
|
|
|
|
|
|
|
if (is_truthy(test)) |
|
|
if (is_truthy(test)) |
|
|
@@ -314,6 +333,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return nullptr; |
|
|
return nullptr; |
|
|
}; |
|
|
}; |
|
|
define_special((define-syntax form (:doc "") . body), "TODO") { |
|
|
define_special((define-syntax form (:doc "") . body), "TODO") { |
|
|
|
|
|
profile_with_name("(define-syntax)"); |
|
|
fetch(form, doc, body); |
|
|
fetch(form, doc, body); |
|
|
|
|
|
|
|
|
try assert_type(doc, Lisp_Object_Type::String); |
|
|
try assert_type(doc, Lisp_Object_Type::String); |
|
|
@@ -350,6 +370,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return Memory::nil; |
|
|
return Memory::nil; |
|
|
}; |
|
|
}; |
|
|
define_special((define definee (:doc "") . body), "TODO") { |
|
|
define_special((define definee (:doc "") . body), "TODO") { |
|
|
|
|
|
profile_with_name("(define)"); |
|
|
fetch(definee, doc, body); |
|
|
fetch(definee, doc, body); |
|
|
|
|
|
|
|
|
// print_hm(get_current_environment()->hm); |
|
|
// print_hm(get_current_environment()->hm); |
|
|
@@ -405,6 +426,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return Memory::nil; |
|
|
return Memory::nil; |
|
|
}; |
|
|
}; |
|
|
define((mutate target source), "TODO") { |
|
|
define((mutate target source), "TODO") { |
|
|
|
|
|
profile_with_name("(mutate)"); |
|
|
fetch(target, source); |
|
|
fetch(target, source); |
|
|
|
|
|
|
|
|
if (target == Memory::nil || |
|
|
if (target == Memory::nil || |
|
|
@@ -427,11 +449,13 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return target; |
|
|
return target; |
|
|
}; |
|
|
}; |
|
|
define((vector-length v), "TODO") { |
|
|
define((vector-length v), "TODO") { |
|
|
|
|
|
profile_with_name("(vector-length)"); |
|
|
fetch(v); |
|
|
fetch(v); |
|
|
try assert_type(v, Lisp_Object_Type::Vector); |
|
|
try assert_type(v, Lisp_Object_Type::Vector); |
|
|
return Memory::create_lisp_object_number((double)v->value.vector.length); |
|
|
return Memory::create_lisp_object_number((double)v->value.vector.length); |
|
|
}; |
|
|
}; |
|
|
define((vector-ref vec idx), "TODO") { |
|
|
define((vector-ref vec idx), "TODO") { |
|
|
|
|
|
profile_with_name("(vector-ref)"); |
|
|
fetch(vec, idx); |
|
|
fetch(vec, idx); |
|
|
|
|
|
|
|
|
try assert_type(vec, Lisp_Object_Type::Vector); |
|
|
try assert_type(vec, Lisp_Object_Type::Vector); |
|
|
@@ -445,6 +469,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return vec->value.vector.data+int_idx; |
|
|
return vec->value.vector.data+int_idx; |
|
|
}; |
|
|
}; |
|
|
define((vector-set! vec idx val), "TODO") { |
|
|
define((vector-set! vec idx val), "TODO") { |
|
|
|
|
|
profile_with_name("(vector-set!)"); |
|
|
fetch(vec, idx, val); |
|
|
fetch(vec, idx, val); |
|
|
|
|
|
|
|
|
try assert_type(vec, Lisp_Object_Type::Vector); |
|
|
try assert_type(vec, Lisp_Object_Type::Vector); |
|
|
@@ -460,6 +485,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return val; |
|
|
return val; |
|
|
}; |
|
|
}; |
|
|
define_special((set! sym val), "TODO") { |
|
|
define_special((set! sym val), "TODO") { |
|
|
|
|
|
profile_with_name("(set!)"); |
|
|
fetch(sym, val); |
|
|
fetch(sym, val); |
|
|
|
|
|
|
|
|
try assert_type(sym, Lisp_Object_Type::Symbol); |
|
|
try assert_type(sym, Lisp_Object_Type::Symbol); |
|
|
@@ -473,14 +499,13 @@ proc load_built_ins_into_environment() -> void* { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
push_environment(target_env); |
|
|
push_environment(target_env); |
|
|
{ |
|
|
|
|
|
define_symbol(sym, val); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
define_symbol(sym, val); |
|
|
pop_environment(); |
|
|
pop_environment(); |
|
|
|
|
|
|
|
|
return val; |
|
|
return val; |
|
|
}; |
|
|
}; |
|
|
define((set-car! target source), "TODO") { |
|
|
define((set-car! target source), "TODO") { |
|
|
|
|
|
profile_with_name("(set-car!)"); |
|
|
fetch(target, source); |
|
|
fetch(target, source); |
|
|
|
|
|
|
|
|
try assert_type(target, Lisp_Object_Type::Pair); |
|
|
try assert_type(target, Lisp_Object_Type::Pair); |
|
|
@@ -489,6 +514,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return source; |
|
|
return source; |
|
|
}; |
|
|
}; |
|
|
define((set-cdr! target source), "TODO") { |
|
|
define((set-cdr! target source), "TODO") { |
|
|
|
|
|
profile_with_name("(set-cdr!)"); |
|
|
fetch(target, source); |
|
|
fetch(target, source); |
|
|
|
|
|
|
|
|
try assert_type(target, Lisp_Object_Type::Pair); |
|
|
try assert_type(target, Lisp_Object_Type::Pair); |
|
|
@@ -497,6 +523,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return source; |
|
|
return source; |
|
|
}; |
|
|
}; |
|
|
define_special((if test then_part else_part), "TODO") { |
|
|
define_special((if test then_part else_part), "TODO") { |
|
|
|
|
|
profile_with_name("(if)"); |
|
|
fetch(test, then_part, else_part); |
|
|
fetch(test, then_part, else_part); |
|
|
|
|
|
|
|
|
bool truthy; |
|
|
bool truthy; |
|
|
@@ -511,10 +538,12 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return result; |
|
|
return result; |
|
|
}; |
|
|
}; |
|
|
define_special((quote datum), "TODO") { |
|
|
define_special((quote datum), "TODO") { |
|
|
|
|
|
profile_with_name("(quote)"); |
|
|
fetch(datum); |
|
|
fetch(datum); |
|
|
return datum; |
|
|
return datum; |
|
|
}; |
|
|
}; |
|
|
define_special((quasiquote expr), "TODO") { |
|
|
define_special((quasiquote expr), "TODO") { |
|
|
|
|
|
profile_with_name("(quasiquote)"); |
|
|
fetch(expr); |
|
|
fetch(expr); |
|
|
Lisp_Object* quasiquote_sym = Memory::get_or_create_lisp_object_symbol("quasiquote"); |
|
|
Lisp_Object* quasiquote_sym = Memory::get_or_create_lisp_object_symbol("quasiquote"); |
|
|
Lisp_Object* unquote_sym = Memory::get_or_create_lisp_object_symbol("unquote"); |
|
|
Lisp_Object* unquote_sym = Memory::get_or_create_lisp_object_symbol("unquote"); |
|
|
@@ -615,6 +644,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return expr; |
|
|
return expr; |
|
|
}; |
|
|
}; |
|
|
define_special((and . args), "TODO") { |
|
|
define_special((and . args), "TODO") { |
|
|
|
|
|
profile_with_name("(and)"); |
|
|
fetch(args); |
|
|
fetch(args); |
|
|
bool result = true; |
|
|
bool result = true; |
|
|
in_caller_env { |
|
|
in_caller_env { |
|
|
@@ -627,6 +657,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return Memory::t; |
|
|
return Memory::t; |
|
|
}; |
|
|
}; |
|
|
define_special((or . args), "TODO") { |
|
|
define_special((or . args), "TODO") { |
|
|
|
|
|
profile_with_name("(or)"); |
|
|
fetch(args); |
|
|
fetch(args); |
|
|
bool result = false; |
|
|
bool result = false; |
|
|
in_caller_env { |
|
|
in_caller_env { |
|
|
@@ -639,6 +670,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return Memory::nil; |
|
|
return Memory::nil; |
|
|
}; |
|
|
}; |
|
|
define_special((not test), "TODO") { |
|
|
define_special((not test), "TODO") { |
|
|
|
|
|
profile_with_name("(not)"); |
|
|
fetch(test); |
|
|
fetch(test); |
|
|
bool truthy; |
|
|
bool truthy; |
|
|
in_caller_env { |
|
|
in_caller_env { |
|
|
@@ -673,6 +705,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
|
|
|
|
|
|
// // }); |
|
|
// // }); |
|
|
define_special((lambda args . body), "TODO") { |
|
|
define_special((lambda args . body), "TODO") { |
|
|
|
|
|
profile_with_name("(lambda)"); |
|
|
fetch(args, body); |
|
|
fetch(args, body); |
|
|
|
|
|
|
|
|
// creating new lisp object and setting type |
|
|
// creating new lisp object and setting type |
|
|
@@ -688,6 +721,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return func; |
|
|
return func; |
|
|
}; |
|
|
}; |
|
|
define((apply fun args), "TODO") { |
|
|
define((apply fun args), "TODO") { |
|
|
|
|
|
profile_with_name("(apply)"); |
|
|
fetch(fun, args); |
|
|
fetch(fun, args); |
|
|
Lisp_Object* result; |
|
|
Lisp_Object* result; |
|
|
|
|
|
|
|
|
@@ -696,6 +730,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return result; |
|
|
return result; |
|
|
}; |
|
|
}; |
|
|
define((eval expr), "TODO") { |
|
|
define((eval expr), "TODO") { |
|
|
|
|
|
profile_with_name("(eval)"); |
|
|
fetch(expr); |
|
|
fetch(expr); |
|
|
Lisp_Object* result; |
|
|
Lisp_Object* result; |
|
|
|
|
|
|
|
|
@@ -706,6 +741,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return result; |
|
|
return result; |
|
|
}; |
|
|
}; |
|
|
define_special((begin . args), "TODO") { |
|
|
define_special((begin . args), "TODO") { |
|
|
|
|
|
profile_with_name("(begin)"); |
|
|
fetch(args); |
|
|
fetch(args); |
|
|
Lisp_Object* result = Memory::nil; |
|
|
Lisp_Object* result = Memory::nil; |
|
|
in_caller_env { |
|
|
in_caller_env { |
|
|
@@ -716,10 +752,12 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return result; |
|
|
return result; |
|
|
}; |
|
|
}; |
|
|
define((list . args), "TODO") { |
|
|
define((list . args), "TODO") { |
|
|
|
|
|
profile_with_name("(list)"); |
|
|
fetch(args); |
|
|
fetch(args); |
|
|
return args; |
|
|
return args; |
|
|
}; |
|
|
}; |
|
|
define((hash-map . args), "TODO") { |
|
|
define((hash-map . args), "TODO") { |
|
|
|
|
|
profile_with_name("(hash-map)"); |
|
|
fetch(args); |
|
|
fetch(args); |
|
|
Lisp_Object* ret; |
|
|
Lisp_Object* ret; |
|
|
try ret = Memory::create_lisp_object_hash_map(); |
|
|
try ret = Memory::create_lisp_object_hash_map(); |
|
|
@@ -732,6 +770,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return ret; |
|
|
return ret; |
|
|
}; |
|
|
}; |
|
|
define((hash-map-get hm key), "TODO") { |
|
|
define((hash-map-get hm key), "TODO") { |
|
|
|
|
|
profile_with_name("(hash-map-get)"); |
|
|
fetch(hm, key); |
|
|
fetch(hm, key); |
|
|
try assert_type(hm, Lisp_Object_Type::HashMap); |
|
|
try assert_type(hm, Lisp_Object_Type::HashMap); |
|
|
|
|
|
|
|
|
@@ -742,18 +781,21 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return ret; |
|
|
return ret; |
|
|
}; |
|
|
}; |
|
|
define((hash-map-set! hm key value), "TODO") { |
|
|
define((hash-map-set! hm key value), "TODO") { |
|
|
|
|
|
profile_with_name("(hash-map-set!)"); |
|
|
fetch(hm, key, value); |
|
|
fetch(hm, key, value); |
|
|
try assert_type(hm, Lisp_Object_Type::HashMap); |
|
|
try assert_type(hm, Lisp_Object_Type::HashMap); |
|
|
hm->value.hashMap->set_object(key, value); |
|
|
hm->value.hashMap->set_object(key, value); |
|
|
return Memory::nil; |
|
|
return Memory::nil; |
|
|
}; |
|
|
}; |
|
|
define((hash-map-delete! hm key), "TODO") { |
|
|
define((hash-map-delete! hm key), "TODO") { |
|
|
|
|
|
profile_with_name("(hash-map-delete!)"); |
|
|
fetch(hm, key); |
|
|
fetch(hm, key); |
|
|
try assert_type(hm, Lisp_Object_Type::HashMap); |
|
|
try assert_type(hm, Lisp_Object_Type::HashMap); |
|
|
hm->value.hashMap->delete_object(key); |
|
|
hm->value.hashMap->delete_object(key); |
|
|
return Memory::nil; |
|
|
return Memory::nil; |
|
|
}; |
|
|
}; |
|
|
define((vector . args), "TODO") { |
|
|
define((vector . args), "TODO") { |
|
|
|
|
|
profile_with_name("(vector)"); |
|
|
fetch(args); |
|
|
fetch(args); |
|
|
Lisp_Object* ret; |
|
|
Lisp_Object* ret; |
|
|
int length = list_length(args); |
|
|
int length = list_length(args); |
|
|
@@ -761,6 +803,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return ret; |
|
|
return ret; |
|
|
}; |
|
|
}; |
|
|
define((pair car cdr), "TODO") { |
|
|
define((pair car cdr), "TODO") { |
|
|
|
|
|
profile_with_name("(pair)"); |
|
|
fetch(car, cdr); |
|
|
fetch(car, cdr); |
|
|
|
|
|
|
|
|
Lisp_Object* ret; |
|
|
Lisp_Object* ret; |
|
|
@@ -768,6 +811,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return ret; |
|
|
return ret; |
|
|
}; |
|
|
}; |
|
|
define((first seq), "TODO") { |
|
|
define((first seq), "TODO") { |
|
|
|
|
|
profile_with_name("(first)"); |
|
|
fetch(seq); |
|
|
fetch(seq); |
|
|
if (seq == Memory::nil) |
|
|
if (seq == Memory::nil) |
|
|
return Memory::nil; |
|
|
return Memory::nil; |
|
|
@@ -775,6 +819,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return seq->value.pair.first; |
|
|
return seq->value.pair.first; |
|
|
}; |
|
|
}; |
|
|
define((rest seq), "TODO") { |
|
|
define((rest seq), "TODO") { |
|
|
|
|
|
profile_with_name("(rest)"); |
|
|
fetch(seq); |
|
|
fetch(seq); |
|
|
if (seq == Memory::nil) |
|
|
if (seq == Memory::nil) |
|
|
return Memory::nil; |
|
|
return Memory::nil; |
|
|
@@ -782,17 +827,20 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return seq->value.pair.rest; |
|
|
return seq->value.pair.rest; |
|
|
}; |
|
|
}; |
|
|
define((set-type! node new_type), "TODO") { |
|
|
define((set-type! node new_type), "TODO") { |
|
|
|
|
|
profile_with_name("(set-type!)"); |
|
|
fetch(node, new_type); |
|
|
fetch(node, new_type); |
|
|
try assert_type(new_type, Lisp_Object_Type::Keyword); |
|
|
try assert_type(new_type, Lisp_Object_Type::Keyword); |
|
|
node->userType = new_type; |
|
|
node->userType = new_type; |
|
|
return node; |
|
|
return node; |
|
|
}; |
|
|
}; |
|
|
define((delete-type! n), "TODO") { |
|
|
define((delete-type! n), "TODO") { |
|
|
|
|
|
profile_with_name("(delete-type!)"); |
|
|
fetch(n); |
|
|
fetch(n); |
|
|
n->userType = nullptr; |
|
|
n->userType = nullptr; |
|
|
return Memory::t; |
|
|
return Memory::t; |
|
|
}; |
|
|
}; |
|
|
define((type n), "TODO") { |
|
|
define((type n), "TODO") { |
|
|
|
|
|
profile_with_name("(type)"); |
|
|
fetch(n); |
|
|
fetch(n); |
|
|
|
|
|
|
|
|
if (n->userType) { |
|
|
if (n->userType) { |
|
|
@@ -828,6 +876,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return Memory::get_or_create_lisp_object_keyword("unknown"); |
|
|
return Memory::get_or_create_lisp_object_keyword("unknown"); |
|
|
}; |
|
|
}; |
|
|
define((mem-reset), "TODO") { |
|
|
define((mem-reset), "TODO") { |
|
|
|
|
|
profile_with_name("(mem-reset)"); |
|
|
Memory::reset(); |
|
|
Memory::reset(); |
|
|
return Memory::nil; |
|
|
return Memory::nil; |
|
|
}; |
|
|
}; |
|
|
@@ -837,6 +886,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
// object. Otherwise (define k :doc "hallo" :keyword) would modify |
|
|
// object. Otherwise (define k :doc "hallo" :keyword) would modify |
|
|
// the global keyword |
|
|
// the global keyword |
|
|
define_special((info n), "TODO") { |
|
|
define_special((info n), "TODO") { |
|
|
|
|
|
profile_with_name("(info)"); |
|
|
fetch(n); |
|
|
fetch(n); |
|
|
|
|
|
|
|
|
print(n); |
|
|
print(n); |
|
|
@@ -908,6 +958,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return Memory::nil; |
|
|
return Memory::nil; |
|
|
}; |
|
|
}; |
|
|
define((show n), "TODO") { |
|
|
define((show n), "TODO") { |
|
|
|
|
|
profile_with_name("(show)"); |
|
|
fetch(n); |
|
|
fetch(n); |
|
|
try assert_type(n, Lisp_Object_Type::Function); |
|
|
try assert_type(n, Lisp_Object_Type::Function); |
|
|
|
|
|
|
|
|
@@ -920,11 +971,13 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return Memory::nil; |
|
|
return Memory::nil; |
|
|
}; |
|
|
}; |
|
|
define((addr-of var), "TODO") { |
|
|
define((addr-of var), "TODO") { |
|
|
|
|
|
profile_with_name("(addr-of-var)"); |
|
|
fetch(var); |
|
|
fetch(var); |
|
|
return Memory::create_lisp_object_number( |
|
|
return Memory::create_lisp_object_number( |
|
|
(float)((u64)&(var))); |
|
|
(float)((u64)&(var))); |
|
|
}; |
|
|
}; |
|
|
define((generate-docs file_name), "TODO") { |
|
|
define((generate-docs file_name), "TODO") { |
|
|
|
|
|
profile_with_name("(generate-docs)"); |
|
|
fetch(file_name); |
|
|
fetch(file_name); |
|
|
try assert_type(file_name, Lisp_Object_Type::String); |
|
|
try assert_type(file_name, Lisp_Object_Type::String); |
|
|
in_caller_env { |
|
|
in_caller_env { |
|
|
@@ -933,6 +986,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return Memory::t; |
|
|
return Memory::t; |
|
|
}; |
|
|
}; |
|
|
define((print (:sep " ") (:end "\n") . things), "TODO") { |
|
|
define((print (:sep " ") (:end "\n") . things), "TODO") { |
|
|
|
|
|
profile_with_name("(print)"); |
|
|
fetch(sep, end, things); |
|
|
fetch(sep, end, things); |
|
|
|
|
|
|
|
|
if (things != Memory::nil) { |
|
|
if (things != Memory::nil) { |
|
|
@@ -948,6 +1002,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return Memory::nil; |
|
|
return Memory::nil; |
|
|
}; |
|
|
}; |
|
|
define((read (:prompt ">")), "TODO") { |
|
|
define((read (:prompt ">")), "TODO") { |
|
|
|
|
|
profile_with_name("(read)"); |
|
|
fetch(prompt); |
|
|
fetch(prompt); |
|
|
print(prompt); |
|
|
print(prompt); |
|
|
|
|
|
|
|
|
@@ -960,21 +1015,25 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return Memory::create_lisp_object_string(strLine); |
|
|
return Memory::create_lisp_object_string(strLine); |
|
|
}; |
|
|
}; |
|
|
define((exit (:code 0)), "TODO") { |
|
|
define((exit (:code 0)), "TODO") { |
|
|
|
|
|
profile_with_name("(exit)"); |
|
|
fetch(code); |
|
|
fetch(code); |
|
|
try assert_type(code, Lisp_Object_Type::Number); |
|
|
try assert_type(code, Lisp_Object_Type::Number); |
|
|
exit((int)code->value.number); |
|
|
exit((int)code->value.number); |
|
|
}; |
|
|
}; |
|
|
define((break), "TODO") { |
|
|
define((break), "TODO") { |
|
|
|
|
|
profile_with_name("(break)"); |
|
|
in_caller_env { |
|
|
in_caller_env { |
|
|
print_environment(get_current_environment()); |
|
|
print_environment(get_current_environment()); |
|
|
} |
|
|
} |
|
|
return Memory::nil; |
|
|
return Memory::nil; |
|
|
}; |
|
|
}; |
|
|
define((memstat), "TODO") { |
|
|
define((memstat), "TODO") { |
|
|
|
|
|
profile_with_name("(memstat)"); |
|
|
Memory::print_status(); |
|
|
Memory::print_status(); |
|
|
return Memory::nil; |
|
|
return Memory::nil; |
|
|
}; |
|
|
}; |
|
|
define_special((mytry try_part catch_part), "TODO") { |
|
|
define_special((mytry try_part catch_part), "TODO") { |
|
|
|
|
|
profile_with_name("(mytry)"); |
|
|
fetch(try_part, catch_part); |
|
|
fetch(try_part, catch_part); |
|
|
|
|
|
|
|
|
Lisp_Object* result; |
|
|
Lisp_Object* result; |
|
|
@@ -993,6 +1052,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return result; |
|
|
return result; |
|
|
}; |
|
|
}; |
|
|
define((load file), "TODO") { |
|
|
define((load file), "TODO") { |
|
|
|
|
|
profile_with_name("(load)"); |
|
|
fetch(file); |
|
|
fetch(file); |
|
|
try assert_type(file, Lisp_Object_Type::String); |
|
|
try assert_type(file, Lisp_Object_Type::String); |
|
|
|
|
|
|
|
|
@@ -1003,6 +1063,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return result; |
|
|
return result; |
|
|
}; |
|
|
}; |
|
|
define((import f), "TODO") { |
|
|
define((import f), "TODO") { |
|
|
|
|
|
profile_with_name("(import)"); |
|
|
fetch(f); |
|
|
fetch(f); |
|
|
try assert_type(f, Lisp_Object_Type::String); |
|
|
try assert_type(f, Lisp_Object_Type::String); |
|
|
|
|
|
|
|
|
@@ -1014,12 +1075,14 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return Memory::t; |
|
|
return Memory::t; |
|
|
}; |
|
|
}; |
|
|
define((copy obj), "TODO") { |
|
|
define((copy obj), "TODO") { |
|
|
|
|
|
profile_with_name("(copy)"); |
|
|
fetch(obj); |
|
|
fetch(obj); |
|
|
// TODO(Felix): if we are copying string nodes, then |
|
|
// TODO(Felix): if we are copying string nodes, then |
|
|
// shouldn't the string itself also get copied?? |
|
|
// shouldn't the string itself also get copied?? |
|
|
return Memory::copy_lisp_object(obj); |
|
|
return Memory::copy_lisp_object(obj); |
|
|
}; |
|
|
}; |
|
|
define((error type message), "TODO") { |
|
|
define((error type message), "TODO") { |
|
|
|
|
|
profile_with_name("(error)"); |
|
|
fetch(type, message); |
|
|
fetch(type, message); |
|
|
// TODO(Felix): make the error function useful |
|
|
// TODO(Felix): make the error function useful |
|
|
try assert_type(type, Lisp_Object_Type::Keyword); |
|
|
try assert_type(type, Lisp_Object_Type::Keyword); |
|
|
@@ -1034,11 +1097,13 @@ proc load_built_ins_into_environment() -> void* { |
|
|
return nullptr; |
|
|
return nullptr; |
|
|
}; |
|
|
}; |
|
|
define((symbol->keyword sym), "TODO") { |
|
|
define((symbol->keyword sym), "TODO") { |
|
|
|
|
|
profile_with_name("(symbol->keyword)"); |
|
|
fetch(sym); |
|
|
fetch(sym); |
|
|
try assert_type(sym, Lisp_Object_Type::Symbol); |
|
|
try assert_type(sym, Lisp_Object_Type::Symbol); |
|
|
return Memory::get_or_create_lisp_object_keyword(sym->value.symbol); |
|
|
return Memory::get_or_create_lisp_object_keyword(sym->value.symbol); |
|
|
}; |
|
|
}; |
|
|
define((string->symbol str), "TODO") { |
|
|
define((string->symbol str), "TODO") { |
|
|
|
|
|
profile_with_name("(string->symbol)"); |
|
|
fetch(str); |
|
|
fetch(str); |
|
|
// TODO(Felix): do some sanity checks on the string. For |
|
|
// TODO(Felix): do some sanity checks on the string. For |
|
|
// example, numbers are not valid symbols. |
|
|
// example, numbers are not valid symbols. |
|
|
@@ -1048,6 +1113,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
Memory::duplicate_string(str->value.string)); |
|
|
Memory::duplicate_string(str->value.string)); |
|
|
}; |
|
|
}; |
|
|
define((symbol->string sym), "TODO") { |
|
|
define((symbol->string sym), "TODO") { |
|
|
|
|
|
profile_with_name("(symbol->string)"); |
|
|
fetch(sym); |
|
|
fetch(sym); |
|
|
|
|
|
|
|
|
try assert_type(sym, Lisp_Object_Type::Symbol); |
|
|
try assert_type(sym, Lisp_Object_Type::Symbol); |
|
|
@@ -1055,6 +1121,7 @@ proc load_built_ins_into_environment() -> void* { |
|
|
Memory::duplicate_string(sym->value.symbol)); |
|
|
Memory::duplicate_string(sym->value.symbol)); |
|
|
}; |
|
|
}; |
|
|
define((concat-strings . strings), "TODO") { |
|
|
define((concat-strings . strings), "TODO") { |
|
|
|
|
|
profile_with_name("(concat-strings)"); |
|
|
fetch(strings); |
|
|
fetch(strings); |
|
|
|
|
|
|
|
|
int resulting_string_len = 0; |
|
|
int resulting_string_len = 0; |
|
|
@@ -1076,3 +1143,4 @@ proc load_built_ins_into_environment() -> void* { |
|
|
}; |
|
|
}; |
|
|
return nullptr; |
|
|
return nullptr; |
|
|
} |
|
|
} |
|
|
|
|
|
|