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

work transfer from laptop

master
Felix Brendel 7 лет назад
Родитель
Сommit
3863b96dac
6 измененных файлов: 29 добавлений и 27 удалений
  1. +2
    -4
      src/eval.cpp
  2. +2
    -0
      src/forward_decls.cpp
  3. +10
    -8
      src/io.cpp
  4. +1
    -1
      src/memory.cpp
  5. +13
    -13
      src/slime.h
  6. +1
    -1
      src/testing.cpp

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

@@ -1,5 +1,3 @@
Source_Code_Location* current_source_code_location = nullptr;

proc apply_arguments_to_function(Lisp_Object* arguments, Function* function) -> Lisp_Object* { proc apply_arguments_to_function(Lisp_Object* arguments, Function* function) -> Lisp_Object* {
Environment* new_env = Memory::create_child_environment(function->parent_environment); Environment* new_env = Memory::create_child_environment(function->parent_environment);


@@ -389,7 +387,7 @@ proc eval_expr(Lisp_Object* node, Environment* env) -> Lisp_Object* {
return symbol; return symbol;
} }
case Lisp_Object_Type::Pair: { case Lisp_Object_Type::Pair: {
current_source_code_location = node->sourceCodeLocation;
current_source_code = node;


Lisp_Object* lispOperator; Lisp_Object* lispOperator;
if (node->value.pair.first->type != Lisp_Object_Type::CFunction && if (node->value.pair.first->type != Lisp_Object_Type::CFunction &&
@@ -429,7 +427,7 @@ proc eval_expr(Lisp_Object* node, Environment* env) -> Lisp_Object* {
} }
} }
default: { default: {
create_generic_error("Not a function.");
create_generic_error("%s is not a function.", Lisp_Object_Type_to_string(node->type));
return nullptr; return nullptr;
} }
} }


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

@@ -15,3 +15,5 @@ proc Lisp_Object_Type_to_string(Lisp_Object_Type type) -> const char*;
namespace Memory { namespace Memory {
proc get_or_create_lisp_object_keyword(const char* identifier) -> Lisp_Object*; proc get_or_create_lisp_object_keyword(const char* identifier) -> Lisp_Object*;
} }

Lisp_Object* current_source_code = nullptr;

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

@@ -281,14 +281,16 @@ proc print(Lisp_Object* node, bool print_quotes = false, FILE* file = stdout) ->




proc print_error_location() -> void { proc print_error_location() -> void {
// if (error->location) {
// printf("%s (line %d, position %d)",
// Memory::get_c_str(error->location->file),
// error->location->line,
// error->location->column);
// } else {
// printf("no source code location avaliable");
// }
if (current_source_code) {
printf("%s (line %d, position %d) code:" console_red "\n ",
Memory::get_c_str(
current_source_code->sourceCodeLocation->file),
current_source_code->sourceCodeLocation->line,
current_source_code->sourceCodeLocation->column);
print(current_source_code);
} else {
printf("no source code location avaliable");
}
} }


proc log_error() -> void { proc log_error() -> void {


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

@@ -143,7 +143,7 @@ namespace Memory {
t->type = Lisp_Object_Type::T; t->type = Lisp_Object_Type::T;
} }


proc reset() {
proc reset() -> void {
free_spots_in_object_memory->next_index = 0; free_spots_in_object_memory->next_index = 0;
free_spots_in_string_memory->next_index = 0; free_spots_in_string_memory->next_index = 0;
next_index_in_object_memory = 2; // because t and nil are always there next_index_in_object_memory = 2; // because t and nil are always there


+ 13
- 13
src/slime.h Просмотреть файл

@@ -13,17 +13,17 @@
#undef _CRT_SECURE_NO_WARNINGS #undef _CRT_SECURE_NO_WARNINGS


namespace Slime { namespace Slime {
#include "./defines.cpp"
#include "./structs.cpp"
#include "./forward_decls.cpp"
#include "./memory.cpp"
#include "./lisp_object.cpp"
#include "./error.cpp"
#include "./io.cpp"
#include "./env.cpp"
#include "./parse.cpp"
#include "./eval.cpp"
#include "./built_ins.cpp"
#include "./testing.cpp"
#include "./undefines.cpp"
# include "./defines.cpp"
# include "./structs.cpp"
# include "./forward_decls.cpp"
# include "./memory.cpp"
# include "./lisp_object.cpp"
# include "./error.cpp"
# include "./io.cpp"
# include "./env.cpp"
# include "./parse.cpp"
# include "./eval.cpp"
# include "./built_ins.cpp"
# include "./testing.cpp"
# include "./undefines.cpp"
} }

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

@@ -480,7 +480,7 @@ proc test_singular_t_and_nil() -> testresult {


proc test_file(const char* file) -> testresult { proc test_file(const char* file) -> testresult {
Memory::reset(); Memory::reset();
Environment* env = Memory::create_built_ins_environment();
static Environment* env = Memory::create_built_ins_environment();


Parser::init(env); Parser::init(env);




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