Merge branch 'master' of https://gitlab.lrz.de/FelixBrendel/slime
This commit is contained in:
+23
-4
@@ -170,12 +170,12 @@ proc load_built_ins_into_environment() -> void {
|
||||
); \
|
||||
assert_type(label(params,__LINE__), Lisp_Object_Type::Pair); \
|
||||
assert_type(label(params,__LINE__)->value.pair.first, Lisp_Object_Type::Symbol); \
|
||||
auto label(sym,__LINE__) = label(params,__LINE__)->value.pair.first; \
|
||||
static auto label(sym,__LINE__) = label(params,__LINE__)->value.pair.first; \
|
||||
auto label(sfun,__LINE__) = Memory::create_lisp_object_cfunction(special); \
|
||||
/*NOTE(Felix): for evaluating default args*/ \
|
||||
push_environment(get_root_environment()); \
|
||||
/*push_environment(get_root_environment());*/ \
|
||||
create_arguments_from_lambda_list_and_inject(label(params,__LINE__)->value.pair.rest, label(sfun,__LINE__)); \
|
||||
pop_environment(); \
|
||||
/*pop_environment(); */ \
|
||||
label(sfun,__LINE__)->sourceCodeLocation = new(Source_Code_Location); \
|
||||
label(sfun,__LINE__)->sourceCodeLocation->file = file_name_built_ins; \
|
||||
label(sfun,__LINE__)->sourceCodeLocation->line = __LINE__; \
|
||||
@@ -190,7 +190,13 @@ proc load_built_ins_into_environment() -> void {
|
||||
Globals::Current_Execution::envi_stack.next_index, \
|
||||
Globals::Current_Execution::envi_stack.next_index-1)
|
||||
|
||||
|
||||
define((helper), "") {
|
||||
return Memory::create_lisp_object_number(101);
|
||||
};
|
||||
define((test (:k (helper))), "") {
|
||||
fetch(k);
|
||||
return k;
|
||||
};
|
||||
define((= . args),
|
||||
"Takes 0 or more arguments and returns =t= if all arguments are equal "
|
||||
"and =()= otherwise.")
|
||||
@@ -347,6 +353,19 @@ proc load_built_ins_into_environment() -> void {
|
||||
return Memory::create_lisp_object_number((int)a->value.number %
|
||||
(int)b->value.number);
|
||||
};
|
||||
define((get-random-between a b), "TODO") {
|
||||
fetch(a, b);
|
||||
try assert_type(a, Lisp_Object_Type::Number);
|
||||
try assert_type(b, Lisp_Object_Type::Number);
|
||||
|
||||
double fa = a->value.number;
|
||||
double fb = b->value.number;
|
||||
double x = (double)rand()/(double)(RAND_MAX);
|
||||
x *= (fb - fa);
|
||||
x += fa;
|
||||
|
||||
return Memory::create_lisp_object_number(x);
|
||||
};
|
||||
define((assert test), "TODO") {
|
||||
fetch(test);
|
||||
|
||||
|
||||
@@ -202,6 +202,14 @@ namespace Memory {
|
||||
push_environment(create_built_ins_environment());
|
||||
}
|
||||
|
||||
proc create_lisp_object_pointer(void* ptr) -> Lisp_Object* {
|
||||
Lisp_Object* node;
|
||||
try node = create_lisp_object();
|
||||
set_type(node, Lisp_Object_Type::Pointer);
|
||||
node->value.pointer = ptr;
|
||||
return node;
|
||||
}
|
||||
|
||||
proc create_lisp_object_number(double number) -> Lisp_Object* {
|
||||
Lisp_Object* node;
|
||||
try node = create_lisp_object();
|
||||
|
||||
+2
-1
@@ -24,7 +24,7 @@ enum struct Lisp_Object_Type {
|
||||
Pair,
|
||||
Vector,
|
||||
Continuation,
|
||||
// Pointer,
|
||||
Pointer,
|
||||
// OwningPointer,
|
||||
Function,
|
||||
CFunction,
|
||||
@@ -146,6 +146,7 @@ struct Lisp_Object {
|
||||
Vector vector;
|
||||
Function function;
|
||||
cFunction* cFunction;
|
||||
void* pointer;
|
||||
Continuation continuation;
|
||||
} value;
|
||||
};
|
||||
|
||||
+38
-38
@@ -575,17 +575,17 @@ proc test_singular_t_and_nil() -> testresult {
|
||||
}
|
||||
|
||||
proc test_file(const char* file) -> testresult {
|
||||
Memory::reset();
|
||||
assert_no_error();
|
||||
// Memory::reset();
|
||||
// assert_no_error();
|
||||
|
||||
Environment* root_env = get_root_environment();
|
||||
Environment* user_env = Memory::create_child_environment(root_env);
|
||||
assert_no_error();
|
||||
// Environment* root_env = get_root_environment();
|
||||
// Environment* user_env = Memory::create_child_environment(root_env);
|
||||
// assert_no_error();
|
||||
|
||||
push_environment(user_env);
|
||||
defer {
|
||||
pop_environment();
|
||||
};
|
||||
// push_environment(user_env);
|
||||
// defer {
|
||||
// pop_environment();
|
||||
// };
|
||||
|
||||
built_in_load(Memory::create_string(file));
|
||||
assert_no_error();
|
||||
@@ -605,43 +605,43 @@ proc run_all_tests() -> bool {
|
||||
pop_environment();
|
||||
};
|
||||
|
||||
printf("-- Util --\n");
|
||||
invoke_test(test_array_lists_adding_and_removing);
|
||||
invoke_test(test_array_lists_sorting);
|
||||
invoke_test(test_array_lists_searching);
|
||||
// printf("-- Util --\n");
|
||||
// invoke_test(test_array_lists_adding_and_removing);
|
||||
// invoke_test(test_array_lists_sorting);
|
||||
// invoke_test(test_array_lists_searching);
|
||||
|
||||
printf("\n -- Parsing --\n");
|
||||
invoke_test(test_parse_atom);
|
||||
invoke_test(test_parse_expression);
|
||||
// printf("\n -- Parsing --\n");
|
||||
// invoke_test(test_parse_atom);
|
||||
// invoke_test(test_parse_expression);
|
||||
|
||||
printf("\n-- Basic evaluating --\n");
|
||||
invoke_test(test_eval_operands);
|
||||
// printf("\n-- Basic evaluating --\n");
|
||||
// invoke_test(test_eval_operands);
|
||||
|
||||
printf("\n-- Built ins --\n");
|
||||
invoke_test(test_built_in_add);
|
||||
invoke_test(test_built_in_substract);
|
||||
invoke_test(test_built_in_multiply);
|
||||
invoke_test(test_built_in_divide);
|
||||
invoke_test(test_built_in_if);
|
||||
invoke_test(test_built_in_and);
|
||||
invoke_test(test_built_in_or);
|
||||
invoke_test(test_built_in_not);
|
||||
invoke_test(test_built_in_type);
|
||||
// printf("\n-- Built ins --\n");
|
||||
// invoke_test(test_built_in_add);
|
||||
// invoke_test(test_built_in_substract);
|
||||
// invoke_test(test_built_in_multiply);
|
||||
// invoke_test(test_built_in_divide);
|
||||
// invoke_test(test_built_in_if);
|
||||
// invoke_test(test_built_in_and);
|
||||
// invoke_test(test_built_in_or);
|
||||
// invoke_test(test_built_in_not);
|
||||
// invoke_test(test_built_in_type);
|
||||
|
||||
printf("\n-- Memory management --\n");
|
||||
invoke_test(test_singular_t_and_nil);
|
||||
// printf("\n-- Memory management --\n");
|
||||
// invoke_test(test_singular_t_and_nil);
|
||||
|
||||
printf("\n-- Test Files --\n");
|
||||
|
||||
invoke_test_script("alists");
|
||||
invoke_test_script("case_and_cond");
|
||||
invoke_test_script("evaluation_of_default_args");
|
||||
invoke_test_script("lexical_scope");
|
||||
invoke_test_script("class_macro");
|
||||
invoke_test_script("import_and_load");
|
||||
invoke_test_script("sicp");
|
||||
invoke_test_script("macro_expand");
|
||||
invoke_test_script("automata");
|
||||
// invoke_test_script("alists");
|
||||
// invoke_test_script("case_and_cond");
|
||||
// invoke_test_script("lexical_scope");
|
||||
// invoke_test_script("class_macro");
|
||||
// invoke_test_script("import_and_load");
|
||||
// invoke_test_script("sicp");
|
||||
// invoke_test_script("macro_expand");
|
||||
// invoke_test_script("automata");
|
||||
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user