and the porgam would jsut essentially print spaced forevermaster
| @@ -1,15 +1,17 @@ | |||||
| #define concat_( a, b) a##b | #define concat_( a, b) a##b | ||||
| #define label(prefix, lnum) concat_(prefix,lnum) | #define label(prefix, lnum) concat_(prefix,lnum) | ||||
| #define log_location() \ | |||||
| do { \ | |||||
| if (Globals::log_level == Log_Level::Debug) { \ | |||||
| printf("in"); \ | |||||
| for (int i = 0; i < 30-strlen(__FILE__);++i) \ | |||||
| printf(" "); \ | |||||
| printf("%s (%d) ", __FILE__, __LINE__); \ | |||||
| printf("-> %s\n",__FUNCTION__); \ | |||||
| } \ | |||||
| #define log_location() \ | |||||
| do { \ | |||||
| if (Globals::log_level == Log_Level::Debug) { \ | |||||
| printf("in"); \ | |||||
| int spacing = 30-(int)strlen(__FILE__); \ | |||||
| if (spacing < 1) spacing = 1; \ | |||||
| for (int i = 0; i < spacing;++i) \ | |||||
| printf(" "); \ | |||||
| printf("%s (%d) ", __FILE__, __LINE__); \ | |||||
| printf("-> %s\n",__FUNCTION__); \ | |||||
| } \ | |||||
| } while(0) | } while(0) | ||||
| #define if_error_log_location_and_return() \ | #define if_error_log_location_and_return() \ | ||||
| @@ -21,18 +23,18 @@ | |||||
| } while(0) | } while(0) | ||||
| #define try_or_else_return(val) \ | |||||
| if (1) \ | |||||
| goto label(body,__LINE__); \ | |||||
| else \ | |||||
| while (1) \ | |||||
| if (1) { \ | |||||
| if (Globals::error) { \ | |||||
| log_location(); \ | |||||
| return val; \ | |||||
| } \ | |||||
| break; \ | |||||
| } \ | |||||
| #define try_or_else_return(val) \ | |||||
| if (1) \ | |||||
| goto label(body,__LINE__); \ | |||||
| else \ | |||||
| while (1) \ | |||||
| if (1) { \ | |||||
| if (Globals::error) { \ | |||||
| log_location(); \ | |||||
| return val; \ | |||||
| } \ | |||||
| break; \ | |||||
| } \ | |||||
| else label(body,__LINE__): | else label(body,__LINE__): | ||||
| ; | ; | ||||
| @@ -149,6 +149,8 @@ namespace Slime { | |||||
| String* message; | String* message; | ||||
| }; | }; | ||||
| const wchar_t* char_to_wchar(const char* c); | |||||
| char* read_entire_file(char* filename); | |||||
| void add_to_load_path(const char*); | void add_to_load_path(const char*); | ||||
| bool lisp_object_equal(Lisp_Object*,Lisp_Object*); | bool lisp_object_equal(Lisp_Object*,Lisp_Object*); | ||||
| Lisp_Object* built_in_load(String*); | Lisp_Object* built_in_load(String*); | ||||
| @@ -182,6 +184,9 @@ namespace Slime { | |||||
| void generate_docs(String* path); | void generate_docs(String* path); | ||||
| namespace Memory { | namespace Memory { | ||||
| extern Lisp_Object* nil; | |||||
| extern Lisp_Object* t; | |||||
| Environment* create_built_ins_environment(); | Environment* create_built_ins_environment(); | ||||
| Lisp_Object* create_lisp_object_cfunction(bool is_special); | Lisp_Object* create_lisp_object_cfunction(bool is_special); | ||||
| Lisp_Object* get_or_create_lisp_object_keyword(const char* identifier); | Lisp_Object* get_or_create_lisp_object_keyword(const char* identifier); | ||||
| @@ -1,15 +1,17 @@ | |||||
| #define concat_( a, b) a##b | #define concat_( a, b) a##b | ||||
| #define label(prefix, lnum) concat_(prefix,lnum) | #define label(prefix, lnum) concat_(prefix,lnum) | ||||
| #define log_location() \ | |||||
| do { \ | |||||
| if (Globals::log_level == Log_Level::Debug) { \ | |||||
| printf("in"); \ | |||||
| for (int i = 0; i < 30-strlen(__FILE__);++i) \ | |||||
| printf(" "); \ | |||||
| printf("%s (%d) ", __FILE__, __LINE__); \ | |||||
| printf("-> %s\n",__FUNCTION__); \ | |||||
| } \ | |||||
| #define log_location() \ | |||||
| do { \ | |||||
| if (Globals::log_level == Log_Level::Debug) { \ | |||||
| printf("in"); \ | |||||
| int spacing = 30-(int)strlen(__FILE__); \ | |||||
| if (spacing < 1) spacing = 1; \ | |||||
| for (int i = 0; i < spacing;++i) \ | |||||
| printf(" "); \ | |||||
| printf("%s (%d) ", __FILE__, __LINE__); \ | |||||
| printf("-> %s\n",__FUNCTION__); \ | |||||
| } \ | |||||
| } while(0) | } while(0) | ||||
| #define if_error_log_location_and_return() \ | #define if_error_log_location_and_return() \ | ||||
| @@ -16,7 +16,9 @@ proc create_error(const char* c_func_name,const char* c_file_name, int c_file_li | |||||
| printf("-"); | printf("-"); | ||||
| printf("\nin"); | printf("\nin"); | ||||
| for (int i = 0; i < 30-(strlen(c_file_name) - (int)log10(c_file_line)); ++i) | |||||
| int spacing = 30-((int)strlen(c_file_name) - (int)log10(c_file_line)); | |||||
| if (spacing < 1) spacing = 1; | |||||
| for (int i = 0; i < spacing; ++i) | |||||
| printf(" "); | printf(" "); | ||||
| printf("%s (%d) ", c_file_name, c_file_line); | printf("%s (%d) ", c_file_name, c_file_line); | ||||
| printf("-> %s\n", c_func_name); | printf("-> %s\n", c_func_name); | ||||
| @@ -301,6 +301,13 @@ char* wchar_to_char(const wchar_t* pwchar) { | |||||
| return filePathC; | return filePathC; | ||||
| } | } | ||||
| const wchar_t* char_to_wchar(const char* c) { | |||||
| const size_t cSize = strlen(c)+1; | |||||
| wchar_t* wc = new wchar_t[cSize]; | |||||
| mbstowcs (wc, c, cSize); | |||||
| return wc; | |||||
| } | |||||
| proc print(Lisp_Object* node, bool print_repr, FILE* file) -> void { | proc print(Lisp_Object* node, bool print_repr, FILE* file) -> void { | ||||
| switch (Memory::get_type(node)) { | switch (Memory::get_type(node)) { | ||||
| case (Lisp_Object_Type::Nil): fputs("()", file); break; | case (Lisp_Object_Type::Nil): fputs("()", file); break; | ||||
| @@ -339,10 +346,10 @@ proc print(Lisp_Object* node, bool print_repr, FILE* file) -> void { | |||||
| case (Lisp_Object_Type::Vector): { | case (Lisp_Object_Type::Vector): { | ||||
| fputs("[", file); | fputs("[", file); | ||||
| if (node->value.vector.length > 0) | if (node->value.vector.length > 0) | ||||
| print(node->value.vector.data); | |||||
| print(node->value.vector.data, print_repr, file); | |||||
| for (int i = 1; i < node->value.vector.length; ++i) { | for (int i = 1; i < node->value.vector.length; ++i) { | ||||
| fputs(" ", file); | fputs(" ", file); | ||||
| print(node->value.vector.data+i); | |||||
| print(node->value.vector.data+i, print_repr, file); | |||||
| } | } | ||||
| fputs("]", file); | fputs("]", file); | ||||
| } break; | } break; | ||||