diff --git a/src/built_ins.cpp b/src/built_ins.cpp index f353f54..d2dfa93 100644 --- a/src/built_ins.cpp +++ b/src/built_ins.cpp @@ -171,9 +171,6 @@ namespace Slime { proc load_built_ins_into_environment() -> void* { profile_this(); - String file_name_built_ins = Memory::create_string(__FILE__); - defer_free(file_name_built_ins.data); - define_macro((call/cc fun), "TODO") { profile_with_name("(call/cc)"); diff --git a/src/define_macros.hpp b/src/define_macros.hpp index 23a3746..d91fd8b 100644 --- a/src/define_macros.hpp +++ b/src/define_macros.hpp @@ -109,7 +109,7 @@ // because the parser relys on being able to temporaily put in markers // in the code and also it will fill out the source code location #define _define_helper(def, docstring, type, ending) \ - Parser::parser_file = file_name_built_ins; \ + Parser::parser_file = Memory::create_string_no_alloc((char*)__FILE__); \ Parser::parser_line = __LINE__; \ Parser::parser_col = 0; \ auto label(params,__LINE__) = Parser::parse_single_expression(#def); \ @@ -129,7 +129,7 @@ #define define_special(def, docs) _define_helper(def, docs, Slime::C_Function_Type::cSpecial, c_body = []() -> Lisp_Object*) #define define_macro(def, docs) _define_helper(def, docs, Slime::C_Function_Type::cMacro, c_macro_body = []() -> void) -#define in_caller_env fluid_let( \ +#define in_caller_env fluid_let( \ Globals::Current_Execution.envi_stack.next_index, \ Globals::Current_Execution.envi_stack.next_index-1) diff --git a/src/forward_decls.cpp b/src/forward_decls.cpp index 29e49f1..d17e031 100644 --- a/src/forward_decls.cpp +++ b/src/forward_decls.cpp @@ -49,6 +49,7 @@ namespace Slime { char* get_c_str(String); void free_everything(); String create_string(const char*); + String create_string_no_alloc(const char*); Lisp_Object* get_symbol(String identifier); Lisp_Object* get_symbol(const char*); Lisp_Object* get_keyword(String identifier); diff --git a/src/memory.cpp b/src/memory.cpp index 115d384..4b1a4f9 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -74,6 +74,14 @@ namespace Slime::Memory { } + proc create_string_no_alloc(char* str) -> String { + String s = { + (u32)strlen(str), + str + }; + return s; + } + proc create_string(const char* str, u32 len) -> String { String s = { len,