Просмотр исходного кода

Fixed importing not working in the test file

master
Felix Brendel 7 лет назад
Родитель
Сommit
346d2f8f3f
6 измененных файлов: 1806 добавлений и 1751 удалений
  1. +1784
    -1731
      bin/visualization.svg
  2. +1
    -0
      src/env.cpp
  3. +9
    -14
      src/eval.cpp
  4. +10
    -4
      src/memory.cpp
  5. +1
    -1
      src/testing.cpp
  6. +1
    -1
      src/visualization.cpp

+ 1784
- 1731
bin/visualization.svg
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 1
- 0
src/env.cpp Просмотреть файл

@@ -55,6 +55,7 @@ proc lookup_symbol(Lisp_Object* node, Environment* env) -> Lisp_Object* {

String* identifier = node->value.identifier;
create_symbol_undefined_error("The symbol '%s' is not defined.", &identifier->data);
print_environment(env);
return nullptr;
}



+ 9
- 14
src/eval.cpp Просмотреть файл

@@ -432,23 +432,18 @@ proc interprete_file (char* file_name) -> Lisp_Object* {
Environment* user_env = Memory::create_child_environment(root_env);
Parser::environment_for_macros = user_env;

char* file_content;
try file_content = read_entire_file(file_name);
// char* file_content;
// try file_content = read_entire_file(file_name);

built_in_load(Memory::create_string("pre.slime"), root_env);

Lisp_Object_Array_List* program;
program = Parser::parse_program(Memory::create_string(file_name), file_content);
built_in_import(Memory::create_string("pre.slime"), user_env);

Lisp_Object* result = Memory::nil;
for (int i = 0; i < program->next_index; ++i) {
result = eval_expr(program->data[i], user_env);
Lisp_Object* result;
result = built_in_load(Memory::create_string(file_name), user_env);

if (Globals::error) {
log_error();
delete_error();
return nullptr;
}
if (Globals::error) {
log_error();
delete_error();
return nullptr;
}

return result;


+ 10
- 4
src/memory.cpp Просмотреть файл

@@ -1,13 +1,21 @@
namespace Memory {

// ------------------
// lisp_object
// lisp_objects
// ------------------
int object_memory_size;
Int_Array_List* free_spots_in_object_memory;
Lisp_Object* object_memory;
int next_index_in_object_memory = 0;

// ------------------
// environments
// ------------------
int environment_memory_size;
Int_Array_List* free_spots_in_environment_memory;
Lisp_Object* environment_memory;
int next_index_in_environment_memory = 0;

// ------------------
// strings
// ------------------
@@ -19,7 +27,6 @@ namespace Memory {
String* string_memory;
String* next_free_spot_in_string_memory;


// ------------------
// immutables
// ------------------
@@ -168,8 +175,7 @@ namespace Memory {
next_index_in_object_memory = 2; // because t and nil are always there
next_free_spot_in_string_memory = string_memory;

Globals::root_environment->next_index = 0;
Globals::root_environment->parents->next_index = 0;
Globals::root_environment = create_built_ins_environment();
}

proc create_lisp_object_number(double number) -> Lisp_Object* {


+ 1
- 1
src/testing.cpp Просмотреть файл

@@ -570,7 +570,7 @@ proc test_file(const char* file) -> testresult {
Environment* user_env = Memory::create_child_environment(root_env);
assert_no_error();

Parser::environment_for_macros = root_env;
Parser::environment_for_macros = user_env;

built_in_import(Memory::create_string("pre.slime"), user_env);
assert_no_error();


+ 1
- 1
src/visualization.cpp Просмотреть файл

@@ -414,7 +414,7 @@ proc visualize_lisp_machine() -> void {
}

remove_doubles_from_lisp_object_array_list(pairs_to_filter);
fprintf(stderr, "removing %d pairs\n", pairs_to_filter->next_index);
// fprintf(stderr, "removing %d pairs\n", pairs_to_filter->next_index);
// okay, so pairs_to_filter now only the pairs once each that
// we want to filter from the pairs list
for (int i = 0; i < pairs->next_index; ++i) {


Загрузка…
Отмена
Сохранить