environments are now hashmaps

This commit is contained in:
FelixBrendel
2019-09-30 08:27:23 +02:00
parent beb4e18efc
commit 2882f81e13
9 changed files with 120 additions and 113 deletions
+14 -7
View File
@@ -1055,13 +1055,20 @@ proc load_built_ins_into_environment() -> void {
// shouldn't the string itself also get copied??
return Memory::copy_lisp_object(obj);
};
// // defun("error", "TODO", __LINE__, cLambda {
// // // TODO(Felix): make the error function useful
// // try evaluated_arguments = eval_arguments(arguments, &arguments_length);
// // try assert_arguments_length(0, arguments_length);
// // create_generic_error("Userlanderror");
// // return nullptr;
// // });
define((error type message), "TODO") {
fetch(type, message);
// TODO(Felix): make the error function useful
try assert_type(type, Lisp_Object_Type::Keyword);
try assert_type(message, Lisp_Object_Type::String);
using Globals::error;
error = new(Error);
error->type = type;
error->message = message->value.string;
create_generic_error("Userlanderror");
return nullptr;
};
define((symbol->keyword sym), "TODO") {
fetch(sym);
try assert_type(sym, Lisp_Object_Type::Symbol);
+17 -17
View File
@@ -90,25 +90,25 @@ proc print_indent(int indent) -> void {
}
proc print_environment_indent(Environment* env, int indent) -> void {
if(env == get_root_environment()) {
// if(env == get_root_environment()) {
// print_indent(indent);
// printf("[built-ins]-Environment (%lld)\n", (long long)env);
// return;
// }
for_str_hash_map (env->hm) {
print_indent(indent);
printf("[built-ins]-Environment (%lld)\n", (long long)env);
return;
printf("-> %s :: ", key);
print((Lisp_Object*)value);
printf(" (%lld)", (unsigned long long)value);
puts("");
}
for (int i = 0; i < env->parents.next_index; ++i) {
print_indent(indent);
printf("parent (%lld)", (long long)env->parents.data[i]);
puts(":");
print_environment_indent(env->parents.data[i], indent+4);
}
printf("TODO\n");
// for (int i = 0; i < env->next_index; ++i) {
// print_indent(indent);
// printf("-> %s :: ", env->keys[i]);
// print(env->values[i]);
// printf(" (%lld)", (long long)env->values[i]);
// puts("");
// }
// for (int i = 0; i < env->parents.next_index; ++i) {
// print_indent(indent);
// printf("parent (%lld)", (long long)env->parents.data[i]);
// puts(":");
// print_environment_indent(env->parents.data[i], indent+4);
// }
}
proc print_environment(Environment* env) -> void {
+1 -1
Submodule src/ftb updated: b9de82c0d8...854593273f
+29 -29
View File
@@ -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("evaluation_of_default_args");
// 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");
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;