|
|
|
@@ -30,21 +30,41 @@ proc lisp_object_equal(Lisp_Object* n1, Lisp_Object* n2) -> bool { |
|
|
|
} |
|
|
|
|
|
|
|
proc built_in_load(String* file_name, Environment* env) -> Lisp_Object* { |
|
|
|
char* full_file_name = find_slime_file(file_name); |
|
|
|
char* file_content = read_entire_file(full_file_name ); |
|
|
|
if (file_content) { |
|
|
|
Lisp_Object* result = Memory::nil; |
|
|
|
Lisp_Object_Array_List* program; |
|
|
|
try program = Parser::parse_program(file_name, file_content); |
|
|
|
|
|
|
|
for (int i = 0; i < program->next_index; ++i) { |
|
|
|
try result = eval_expr(program->data[i], env); |
|
|
|
// char* full_file_name = find_slime_file(file_name); |
|
|
|
char* file_content; |
|
|
|
file_content = read_entire_file(Memory::get_c_str(file_name)); |
|
|
|
|
|
|
|
if (!file_content) { |
|
|
|
// try slime's bin dir |
|
|
|
// save the current working directory |
|
|
|
|
|
|
|
// get the direction of the exe |
|
|
|
char* exe_path = exe_dir(); |
|
|
|
defer { |
|
|
|
free(exe_path); |
|
|
|
}; |
|
|
|
char fullpath[4096]; |
|
|
|
|
|
|
|
sprintf(fullpath, "%s%s", exe_path, Memory::get_c_str(file_name)); |
|
|
|
// printf("Fullpath: %s\n", fullpath); |
|
|
|
file_content = read_entire_file(fullpath); |
|
|
|
|
|
|
|
if (!file_content) { |
|
|
|
create_generic_error("The file '%s' was not found " |
|
|
|
"(neither in the cwd nor in slime's bin dir)", |
|
|
|
Memory::get_c_str(file_name)); |
|
|
|
return nullptr; |
|
|
|
} |
|
|
|
return result; |
|
|
|
} else { |
|
|
|
create_generic_error("The file '%s' was not found", Memory::get_c_str(file_name)); |
|
|
|
return nullptr; |
|
|
|
} |
|
|
|
|
|
|
|
Lisp_Object* result = Memory::nil; |
|
|
|
Lisp_Object_Array_List* program; |
|
|
|
try program = Parser::parse_program(file_name, file_content); |
|
|
|
|
|
|
|
for (int i = 0; i < program->next_index; ++i) { |
|
|
|
try result = eval_expr(program->data[i], env); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
proc built_in_import(String* file_name, Environment* env) -> Lisp_Object* { |
|
|
|
|