better errors and cleanp
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
#define __create_error(keyword, ...) \
|
||||
create_error( \
|
||||
__FILE__, __LINE__, \
|
||||
__func__, __FILE__, __LINE__, \
|
||||
Memory::get_or_create_lisp_object_keyword(keyword), \
|
||||
__VA_ARGS__)
|
||||
|
||||
|
||||
+7
-8
@@ -14,6 +14,11 @@ proc lisp_object_equal(Lisp_Object* n1, Lisp_Object* n2) -> bool {
|
||||
|
||||
switch (Memory::get_type(n1)) {
|
||||
|
||||
case Lisp_Object_Type::T: // code for t and nil should never be
|
||||
// reached since they are memory unique
|
||||
case Lisp_Object_Type::Nil:
|
||||
case Lisp_Object_Type::Symbol:
|
||||
case Lisp_Object_Type::Keyword:
|
||||
case Lisp_Object_Type::CFunction: // if they have the same
|
||||
// pointer, true is returned a
|
||||
// few lines above
|
||||
@@ -21,9 +26,6 @@ proc lisp_object_equal(Lisp_Object* n1, Lisp_Object* n2) -> bool {
|
||||
case Lisp_Object_Type::Pointer: // TODO(Felix): should a pointer
|
||||
// object compare the pointer?
|
||||
case Lisp_Object_Type::Continuation: return false;
|
||||
case Lisp_Object_Type::T: // code for t and nil should never be
|
||||
// reached since they are memory unique
|
||||
case Lisp_Object_Type::Nil: return true;
|
||||
case Lisp_Object_Type::Number: return n1->value.number == n2->value.number;
|
||||
case Lisp_Object_Type::String: return string_equal(n1->value.string, n2->value.string);
|
||||
case Lisp_Object_Type::Pair: {
|
||||
@@ -33,9 +35,6 @@ proc lisp_object_equal(Lisp_Object* n1, Lisp_Object* n2) -> bool {
|
||||
case Lisp_Object_Type::HashMap:
|
||||
case Lisp_Object_Type::Vector:
|
||||
create_not_yet_implemented_error();
|
||||
case Lisp_Object_Type::Symbol:
|
||||
case Lisp_Object_Type::Keyword:
|
||||
return false;
|
||||
}
|
||||
|
||||
// we should never reach here
|
||||
@@ -373,7 +372,7 @@ proc load_built_ins_into_environment() -> void {
|
||||
}
|
||||
auto value = body->value.pair.first;
|
||||
in_caller_env {
|
||||
value = eval_expr(value);
|
||||
try value = eval_expr(value);
|
||||
define_symbol(definee, value);
|
||||
}
|
||||
} else if (Memory::get_type(definee) == Lisp_Object_Type::Pair) {
|
||||
@@ -548,7 +547,7 @@ proc load_built_ins_into_environment() -> void {
|
||||
|
||||
Lisp_Object* ret;
|
||||
in_caller_env {
|
||||
ret = eval_expr(expr->value.pair.rest->value.pair.first);
|
||||
try ret = eval_expr(expr->value.pair.rest->value.pair.first);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
+35
-19
@@ -1,20 +1,38 @@
|
||||
#define concat_( a, b) a##b
|
||||
#define label(prefix, lnum) concat_(prefix,lnum)
|
||||
|
||||
#define try_or_else_return(val) \
|
||||
if (1) \
|
||||
goto label(body,__LINE__); \
|
||||
else \
|
||||
while (1) \
|
||||
if (1) { \
|
||||
if (Globals::error) { \
|
||||
if (Globals::log_level == Log_Level::Debug) { \
|
||||
printf("in %s:%d\n", __FILE__, __LINE__); \
|
||||
} \
|
||||
return val; \
|
||||
} \
|
||||
break; \
|
||||
} \
|
||||
#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", __func__); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define if_error_log_location_and_return() \
|
||||
do { \
|
||||
if (Globals::error) { \
|
||||
log_location(); \
|
||||
return; \
|
||||
} \
|
||||
} 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; \
|
||||
} \
|
||||
else label(body,__LINE__):
|
||||
;
|
||||
|
||||
@@ -87,16 +105,14 @@
|
||||
// in the code
|
||||
#define _define_helper(def, docs, special) \
|
||||
auto label(params,__LINE__) = Parser::parse_single_expression( \
|
||||
Memory::get_c_str(Memory::create_string(#def)) \
|
||||
); \
|
||||
Memory::get_c_str(Memory::create_string(#def))); \
|
||||
if_error_log_location_and_return(); \
|
||||
assert_type(label(params,__LINE__), Lisp_Object_Type::Pair); \
|
||||
assert_type(label(params,__LINE__)->value.pair.first, Lisp_Object_Type::Symbol); \
|
||||
auto label(sym,__LINE__) = label(params,__LINE__)->value.pair.first; \
|
||||
auto label(sfun,__LINE__) = Memory::create_lisp_object_cfunction(special); \
|
||||
/*NOTE(Felix): for evaluating default args*/ \
|
||||
/*push_environment(get_root_environment());*/ \
|
||||
create_arguments_from_lambda_list_and_inject(label(params,__LINE__)->value.pair.rest, label(sfun,__LINE__)); \
|
||||
/*pop_environment(); */ \
|
||||
if_error_log_location_and_return(); \
|
||||
label(sfun,__LINE__)->sourceCodeLocation = new(Source_Code_Location); \
|
||||
label(sfun,__LINE__)->sourceCodeLocation->file = file_name_built_ins; \
|
||||
label(sfun,__LINE__)->sourceCodeLocation->line = __LINE__; \
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#define new(type) new type
|
||||
#define proc auto
|
||||
|
||||
#ifdef _DEBUG
|
||||
@@ -7,7 +6,6 @@
|
||||
# define if_debug if constexpr (false)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define debug_break() if_debug __debugbreak()
|
||||
# define if_windows if constexpr (true)
|
||||
@@ -18,15 +16,6 @@
|
||||
# define if_linux if constexpr (true)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* iterate over array lists
|
||||
*/
|
||||
// #define for_array_list(l) \
|
||||
// if (int it_index = 0); else \
|
||||
// for (auto it = (l).data[0]; \
|
||||
// it_index < (l).next_index; \
|
||||
// it=(l).data[++it_index])
|
||||
|
||||
/*
|
||||
* iterate over lisp vectors
|
||||
*/
|
||||
|
||||
+5
-5
@@ -1,10 +1,10 @@
|
||||
proc define_symbol(Lisp_Object* symbol, Lisp_Object* value) -> void {
|
||||
Environment* env = get_current_environment();
|
||||
env->hm.set_object(symbol, value);
|
||||
env->hm.set_object((void*)symbol, value);
|
||||
}
|
||||
|
||||
inline proc lookup_symbol_in_this_envt(Lisp_Object* sym, Environment* env) -> Lisp_Object* {
|
||||
return (Lisp_Object*)env->hm.get_object(sym);
|
||||
return (Lisp_Object*)env->hm.get_object((void*)sym);
|
||||
}
|
||||
|
||||
proc environment_binds_symbol(Lisp_Object* sym, Environment* env) -> bool {
|
||||
@@ -70,7 +70,6 @@ inline proc get_current_environment() -> Environment* {
|
||||
|
||||
proc lookup_symbol(Lisp_Object* node, Environment* env) -> Lisp_Object* {
|
||||
// print(node);
|
||||
// printf("\n");
|
||||
assert_type(node, Lisp_Object_Type::Symbol);
|
||||
|
||||
Lisp_Object* result = try_lookup_symbol(node, env);
|
||||
@@ -79,8 +78,9 @@ proc lookup_symbol(Lisp_Object* node, Environment* env) -> Lisp_Object* {
|
||||
return result;
|
||||
|
||||
String* identifier = node->value.symbol.identifier;
|
||||
create_symbol_undefined_error("The symbol '%s' is not defined.", &identifier->data);
|
||||
print_environment(env);
|
||||
printf("\n");
|
||||
create_symbol_undefined_error("The symbol '%s' is not defined.", &identifier->data);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ proc print_environment_indent(Environment* env, int indent) -> void {
|
||||
// return;
|
||||
// }
|
||||
|
||||
for_LO_to_LO_hash_map (env->hm) {
|
||||
for_hash_map (env->hm) {
|
||||
print_indent(indent);
|
||||
printf("-> %s :: ", &(((Lisp_Object*)key)->value.symbol.identifier->data));
|
||||
print((Lisp_Object*)value);
|
||||
|
||||
+16
-9
@@ -7,11 +7,19 @@ proc delete_error() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
proc create_error(const char* c_file_name, int c_file_line, Lisp_Object* type, String* message) -> void {
|
||||
|
||||
proc create_error(const char* c_func_name,const char* c_file_name, int c_file_line, Lisp_Object* type, String* message) -> void {
|
||||
if (Globals::log_level > Log_Level::None) {
|
||||
printf("Error created in:\n %s:%d\n", c_file_name, c_file_line);
|
||||
printf(" -> %s\n", Memory::get_c_str(message));
|
||||
for (int i = 0; i < 10+strlen(Memory::get_c_str(message));++i)
|
||||
printf("-");
|
||||
printf("\n Error - %s\n", Memory::get_c_str(message));
|
||||
for (int i = 0; i < 10+strlen(Memory::get_c_str(message));++i)
|
||||
printf("-");
|
||||
|
||||
printf("\nin");
|
||||
for (int i = 0; i < 30-(strlen(c_file_name) - (int)log10(c_file_line)); ++i)
|
||||
printf(" ");
|
||||
printf("%s (%d) ", c_file_name, c_file_line);
|
||||
printf("-> %s\n", c_func_name);
|
||||
}
|
||||
|
||||
delete_error();
|
||||
@@ -19,19 +27,18 @@ proc create_error(const char* c_file_name, int c_file_line, Lisp_Object* type, S
|
||||
debug_break();
|
||||
}
|
||||
// visualize_lisp_machine();
|
||||
|
||||
using Globals::error;
|
||||
|
||||
error = new(Error);
|
||||
error->type = type;
|
||||
error->message = message;
|
||||
|
||||
}
|
||||
|
||||
|
||||
proc create_error(const char* c_file_name, int c_file_line, Lisp_Object* type, const char* format, ...) -> void {
|
||||
proc create_error(const char* c_func_name, const char* c_file_name, int c_file_line, Lisp_Object* type, const char* format, ...) -> void {
|
||||
// HACK(Felix): the length of all error strings is 200!!!!!!!!!!
|
||||
using Globals::error;
|
||||
|
||||
|
||||
int length = 200;
|
||||
String* formatted_string = Memory::create_string("", length);
|
||||
if (error) {
|
||||
@@ -46,7 +53,7 @@ proc create_error(const char* c_file_name, int c_file_line, Lisp_Object* type, c
|
||||
|
||||
formatted_string->length = written_length;
|
||||
|
||||
create_error(c_file_name, c_file_line, type, formatted_string);
|
||||
create_error(c_func_name, c_file_name, c_file_line, type, formatted_string);
|
||||
}
|
||||
|
||||
// proc Error_Type_to_string(Error_Type type) -> const char* {
|
||||
|
||||
+6
-6
@@ -259,9 +259,9 @@ proc create_arguments_from_lambda_list_and_inject(Lisp_Object* arguments, Lisp_O
|
||||
result = &function->value.function.args;
|
||||
}
|
||||
|
||||
::new ((&(result->positional.symbols))) Array_List<Lisp_Object*>;
|
||||
::new ((&(result->keyword.keywords))) Array_List<Lisp_Object*>;
|
||||
::new ((&(result->keyword.values))) Array_List<Lisp_Object*>;
|
||||
::new (&(result->positional.symbols)) Array_List<Lisp_Object*>;
|
||||
::new (&(result->keyword.keywords)) Array_List<Lisp_Object*>;
|
||||
::new (&(result->keyword.values)) Array_List<Lisp_Object*>;
|
||||
|
||||
// first init the fields
|
||||
// result->positional = create_positional_argument_list(16);
|
||||
@@ -315,7 +315,7 @@ proc create_arguments_from_lambda_list_and_inject(Lisp_Object* arguments, Lisp_O
|
||||
create_parsing_error("Default args must be a list of 2.");
|
||||
}
|
||||
auto value = arguments->value.pair.first->value.pair.rest->value.pair.first;
|
||||
value = eval_expr(value);
|
||||
try_void value = eval_expr(value);
|
||||
if (arguments->value.pair.first->value.pair.rest->value.pair.rest != Memory::nil) {
|
||||
create_parsing_error("Default args must be a list of 2.");
|
||||
}
|
||||
@@ -486,7 +486,7 @@ proc is_truthy(Lisp_Object* expression) -> bool {
|
||||
}
|
||||
|
||||
proc interprete_file (char* file_name) -> Lisp_Object* {
|
||||
Memory::init(4096 * 256, 1024, 4096 * 256);
|
||||
try Memory::init(4096 * 256, 1024, 4096 * 256);
|
||||
Environment* root_env = get_root_environment();
|
||||
Environment* user_env;
|
||||
try user_env = Memory::create_child_environment(root_env);
|
||||
@@ -506,7 +506,7 @@ proc interprete_file (char* file_name) -> Lisp_Object* {
|
||||
}
|
||||
|
||||
proc interprete_stdin() -> void {
|
||||
Memory::init(4096 * 256, 1024, 4096 * 256);
|
||||
try_void Memory::init(4096 * 256, 1024, 4096 * 256);
|
||||
Environment* root_env = get_root_environment();
|
||||
Environment* user_env = Memory::create_child_environment(root_env);
|
||||
push_environment(user_env);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// proc assert_type(Lisp_Object*, Lisp_Object_Type) -> void;
|
||||
void add_to_load_path(const char*);
|
||||
bool lisp_object_equal(Lisp_Object*,Lisp_Object*);
|
||||
Lisp_Object* built_in_load(String*);
|
||||
Lisp_Object* built_in_import(String*);
|
||||
void delete_error();
|
||||
void create_error(const char* c_file_name, int c_file_line, Lisp_Object* type, String* message);
|
||||
void create_error(const char* c_file_name, int c_file_line, Lisp_Object* type, const char* format, ...);
|
||||
void create_error(const char* c_func_name, const char* c_file_name, int c_file_line, Lisp_Object* type, const char* format, ...);
|
||||
void create_error(const char* c_func_name, const char* c_file_name, int c_file_line, Lisp_Object* type, String* message);
|
||||
void create_error(Lisp_Object* type, const char* message, const char* c_file_name, int c_file_line);
|
||||
Lisp_Object* eval_arguments(Lisp_Object*);
|
||||
Lisp_Object* eval_expr(Lisp_Object*);
|
||||
@@ -17,8 +16,10 @@ void create_arguments_from_lambda_list_and_inject(Lisp_Object* formal_arguments,
|
||||
Lisp_Object* lookup_symbol(Lisp_Object* symbol, Environment*);
|
||||
void define_symbol(Lisp_Object* symbol, Lisp_Object* value);
|
||||
void print(Lisp_Object* node, bool print_repr = false, FILE* file = stdout);
|
||||
|
||||
void print_environment(Environment*);
|
||||
|
||||
bool run_all_tests();
|
||||
|
||||
inline Environment* get_root_environment();
|
||||
inline Environment* get_current_environment();
|
||||
inline void push_environment(Environment*);
|
||||
@@ -72,7 +73,6 @@ namespace Globals {
|
||||
extern Array_List<Lisp_Object*> call_stack;
|
||||
extern Array_List<Environment*> envi_stack;
|
||||
}
|
||||
|
||||
extern Error* error;
|
||||
extern bool breaking_on_errors;
|
||||
}
|
||||
|
||||
-1
Submodule src/ftb deleted from dd7db5b330
@@ -15,61 +15,3 @@ namespace Globals {
|
||||
bool breaking_on_errors = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned int hm_hash(void* ptr) {
|
||||
return ((unsigned long long)ptr * 2654435761) % 4294967296;
|
||||
}
|
||||
|
||||
unsigned int hm_hash(char* str) {
|
||||
unsigned int value = str[0] << 7;
|
||||
int i = 0;
|
||||
while (str[i]) {
|
||||
value = (10000003 * value) ^ str[i++];
|
||||
}
|
||||
return value ^ i;
|
||||
}
|
||||
|
||||
bool hm_objects_match(char* a, char* b) {
|
||||
return strcmp(a, b) == 0;
|
||||
}
|
||||
|
||||
bool hm_objects_match(void* a, void* b) {
|
||||
return a == b;
|
||||
}
|
||||
|
||||
bool hm_objects_match(Lisp_Object* a, Lisp_Object* b) {
|
||||
return lisp_object_equal(a, b);
|
||||
}
|
||||
|
||||
u32 hm_hash(Lisp_Object* obj) {
|
||||
switch (Memory::get_type(obj)) {
|
||||
// hash from adress: if two objects of these types have
|
||||
// different addresses, they are different
|
||||
case Lisp_Object_Type::CFunction:
|
||||
case Lisp_Object_Type::Function:
|
||||
case Lisp_Object_Type::Symbol:
|
||||
case Lisp_Object_Type::Keyword:
|
||||
case Lisp_Object_Type::Continuation:
|
||||
case Lisp_Object_Type::Nil:
|
||||
case Lisp_Object_Type::T:
|
||||
return hm_hash((void*) obj);
|
||||
// hash from contents: even if objects are themselved
|
||||
// different, they cauld be equivalent:
|
||||
case Lisp_Object_Type::Pointer: return hm_hash((void*) obj->value.pointer);
|
||||
case Lisp_Object_Type::Number: return hm_hash((void*) (unsigned long long)obj->value.number); // HACK(Felix): yes
|
||||
case Lisp_Object_Type::String: return hm_hash((char*) &obj->value.string->data);
|
||||
case Lisp_Object_Type::Pair: {
|
||||
u32 hash = 1;
|
||||
for_lisp_list (obj) {
|
||||
hash <<= 1;
|
||||
hash += hm_hash(it);
|
||||
}
|
||||
return hash;
|
||||
} break;
|
||||
case Lisp_Object_Type::Vector:
|
||||
case Lisp_Object_Type::HashMap:
|
||||
default:
|
||||
create_not_yet_implemented_error();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -302,7 +302,6 @@ char* wchar_to_char(const wchar_t* pwchar) {
|
||||
}
|
||||
|
||||
proc print(Lisp_Object* node, bool print_repr, FILE* file) -> void {
|
||||
|
||||
switch (Memory::get_type(node)) {
|
||||
case (Lisp_Object_Type::Nil): fputs("()", file); break;
|
||||
case (Lisp_Object_Type::T): fputs("t", file); break;
|
||||
@@ -318,7 +317,7 @@ proc print(Lisp_Object* node, bool print_repr, FILE* file) -> void {
|
||||
case (Lisp_Object_Type::CFunction): fputs("[C-function]", file); break;
|
||||
case (Lisp_Object_Type::Pointer): fputs("[pointer]", file); break;
|
||||
case (Lisp_Object_Type::HashMap): {
|
||||
for_LO_to_LO_hash_map (node->value.hashMap) {
|
||||
for_hash_map (node->value.hashMap) {
|
||||
fputs(" ", file);
|
||||
print(key, true, file);
|
||||
fputs(" -> ", file);
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <cmath>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <functional>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include <direct.h>
|
||||
# include <windows.h>
|
||||
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <signal.h>
|
||||
#endif
|
||||
|
||||
#include "ftb/types.hpp"
|
||||
#include "ftb/arraylist.hpp"
|
||||
#include "ftb/macros.hpp"
|
||||
#include "ftb/profiler.hpp"
|
||||
|
||||
namespace Slime {
|
||||
struct Lisp_Object;
|
||||
}
|
||||
|
||||
bool hm_objects_match(char* a, char* b);
|
||||
bool hm_objects_match(void* a, void* b);
|
||||
bool hm_objects_match(Slime::Lisp_Object* a, Slime::Lisp_Object* b);
|
||||
unsigned int hm_hash(char* str);
|
||||
unsigned int hm_hash(void* ptr);
|
||||
unsigned int hm_hash(Slime::Lisp_Object* obj);
|
||||
#include "ftb/hashmap.hpp"
|
||||
|
||||
namespace Slime {
|
||||
# include "defines.cpp"
|
||||
# include "assert.hpp"
|
||||
# include "define_macros.hpp"
|
||||
# include "platform.cpp"
|
||||
# include "structs.cpp"
|
||||
# include "forward_decls.cpp"
|
||||
}
|
||||
|
||||
bool hm_objects_match(char* a, char* b) {
|
||||
return strcmp(a, b) == 0;
|
||||
}
|
||||
|
||||
bool hm_objects_match(void* a, void* b) {
|
||||
return a == b;
|
||||
}
|
||||
|
||||
bool hm_objects_match(Slime::Lisp_Object* a, Slime::Lisp_Object* b) {
|
||||
return Slime::lisp_object_equal(a, b);
|
||||
}
|
||||
|
||||
unsigned int hm_hash(char* str) {
|
||||
unsigned int value = str[0] << 7;
|
||||
int i = 0;
|
||||
while (str[i]) {
|
||||
value = (10000003 * value) ^ str[i++];
|
||||
}
|
||||
return value ^ i;
|
||||
}
|
||||
|
||||
unsigned int hm_hash(void* ptr) {
|
||||
return ((unsigned long long)ptr * 2654435761) % 4294967296;
|
||||
}
|
||||
|
||||
unsigned int hm_hash(Slime::Lisp_Object* obj) {
|
||||
using namespace Slime;
|
||||
switch (Memory::get_type(obj)) {
|
||||
// hash from adress: if two objects of these types have
|
||||
// different addresses, they are different
|
||||
case Lisp_Object_Type::CFunction:
|
||||
case Lisp_Object_Type::Function:
|
||||
case Lisp_Object_Type::Symbol:
|
||||
case Lisp_Object_Type::Keyword:
|
||||
case Lisp_Object_Type::Continuation:
|
||||
case Lisp_Object_Type::Nil:
|
||||
case Lisp_Object_Type::T:
|
||||
return hm_hash((void*) obj);
|
||||
// hash from contents: even if objects are themselved
|
||||
// different, they cauld be equivalent:
|
||||
case Lisp_Object_Type::Pointer: return hm_hash((void*) obj->value.pointer);
|
||||
case Lisp_Object_Type::Number: return hm_hash((void*) (unsigned long long)obj->value.number); // HACK(Felix): yes
|
||||
case Lisp_Object_Type::String: return hm_hash((char*) &obj->value.string->data);
|
||||
case Lisp_Object_Type::Pair: {
|
||||
u32 hash = 1;
|
||||
for_lisp_list (obj) {
|
||||
hash <<= 1;
|
||||
hash += hm_hash(it);
|
||||
}
|
||||
return hash;
|
||||
} break;
|
||||
case Lisp_Object_Type::Vector:
|
||||
case Lisp_Object_Type::HashMap:
|
||||
default:
|
||||
create_not_yet_implemented_error();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#include "ftb/hashmap.hpp"
|
||||
|
||||
namespace Slime {
|
||||
# include "globals.cpp"
|
||||
# include "memory.cpp"
|
||||
# include "gc.cpp"
|
||||
# include "lisp_object.cpp"
|
||||
# include "error.cpp"
|
||||
# include "io.cpp"
|
||||
# include "env.cpp"
|
||||
# include "parse.cpp"
|
||||
# include "eval.cpp"
|
||||
# include "visualization.cpp"
|
||||
# include "docgeneration.cpp"
|
||||
# include "built_ins.cpp"
|
||||
# include "testing.cpp"
|
||||
// # include "undefines.cpp"
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#include "slime.h"
|
||||
#include "libslime.cpp"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc > 1) {
|
||||
|
||||
+8
-5
@@ -203,8 +203,9 @@ namespace Memory {
|
||||
try_void Parser::standard_in = create_string("stdin");
|
||||
|
||||
Globals::Current_Execution::envi_stack.next_index = 0;
|
||||
push_environment(create_built_ins_environment());
|
||||
|
||||
Environment* env;
|
||||
try_void env = create_built_ins_environment();
|
||||
push_environment(env);
|
||||
}
|
||||
|
||||
proc reset() -> void {
|
||||
@@ -224,7 +225,9 @@ namespace Memory {
|
||||
next_free_spot_in_string_memory = string_memory;
|
||||
|
||||
Globals::Current_Execution::envi_stack.next_index = 0;
|
||||
push_environment(create_built_ins_environment());
|
||||
Environment* env;
|
||||
try_void env = create_built_ins_environment();
|
||||
push_environment(env);
|
||||
}
|
||||
|
||||
proc create_lisp_object_pointer(void* ptr) -> Lisp_Object* {
|
||||
@@ -437,7 +440,7 @@ namespace Memory {
|
||||
if (parent)
|
||||
env->parents.append(parent);
|
||||
|
||||
::new((&env->hm)) Hash_Map<Lisp_Object*, Lisp_Object*>;
|
||||
::new((&env->hm)) Hash_Map<void*, Lisp_Object*>;
|
||||
|
||||
return env;
|
||||
}
|
||||
@@ -456,7 +459,7 @@ namespace Memory {
|
||||
pop_environment();
|
||||
};
|
||||
|
||||
load_built_ins_into_environment();
|
||||
try load_built_ins_into_environment();
|
||||
|
||||
// save the current working directory
|
||||
//char* cwd = get_cwd();
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <cmath>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <functional>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include <direct.h>
|
||||
# include <windows.h>
|
||||
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <signal.h>
|
||||
#endif
|
||||
|
||||
#include "./ftb/arraylist.hpp"
|
||||
#include "./ftb/macros.hpp"
|
||||
#include "./ftb/profiler.hpp"
|
||||
|
||||
namespace Slime {
|
||||
#include "./ftb/hashmap.hpp"
|
||||
# include "./defines.cpp"
|
||||
# include "./assert.hpp"
|
||||
# include "./define_macros.hpp"
|
||||
# include "./platform.cpp"
|
||||
# include "./structs.cpp"
|
||||
# include "./forward_decls.cpp"
|
||||
# include "./globals.cpp"
|
||||
# include "./memory.cpp"
|
||||
# include "./gc.cpp"
|
||||
# include "./lisp_object.cpp"
|
||||
# include "./error.cpp"
|
||||
# include "./io.cpp"
|
||||
# include "./env.cpp"
|
||||
# include "./parse.cpp"
|
||||
# include "./eval.cpp"
|
||||
# include "./visualization.cpp"
|
||||
# include "./docgeneration.cpp"
|
||||
# include "./built_ins.cpp"
|
||||
# include "./testing.cpp"
|
||||
# include "./undefines.cpp"
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <cmath>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <functional>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include <direct.h>
|
||||
# include <windows.h>
|
||||
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <signal.h>
|
||||
#endif
|
||||
|
||||
#include "./ftb/types.hpp"
|
||||
#include "./ftb/macros.hpp"
|
||||
#include "./ftb/profiler.hpp"
|
||||
#include "./ftb/arraylist.hpp"
|
||||
|
||||
namespace Slime {
|
||||
# include "./ftb/hashmap.hpp"
|
||||
|
||||
# include "./defines.cpp"
|
||||
# include "./assert.hpp"
|
||||
# include "./define_macros.hpp"
|
||||
# include "./platform.cpp"
|
||||
# include "./structs.cpp"
|
||||
# include "./forward_decls.cpp"
|
||||
# include "./globals.cpp"
|
||||
# include "./memory.cpp"
|
||||
# include "./gc.cpp"
|
||||
# include "./lisp_object.cpp"
|
||||
# include "./error.cpp"
|
||||
# include "./io.cpp"
|
||||
# include "./env.cpp"
|
||||
# include "./parse.cpp"
|
||||
# include "./eval.cpp"
|
||||
# include "./visualization.cpp"
|
||||
# include "./docgeneration.cpp"
|
||||
# include "./built_ins.cpp"
|
||||
# include "./testing.cpp"
|
||||
# include "./undefines.cpp"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
#include <functional>
|
||||
|
||||
namespace Slime {
|
||||
# include "./ftb/hashmap.hpp"
|
||||
# include "./ftb/arraylist.hpp"
|
||||
# include "./assert.hpp"
|
||||
# include "./structs.cpp"
|
||||
# include "./forward_decls.cpp"
|
||||
}
|
||||
+1
-11
@@ -2,15 +2,6 @@ struct Lisp_Object;
|
||||
struct String;
|
||||
struct Environment;
|
||||
|
||||
// HASH MAPS
|
||||
// define_hash_map(char*, String);
|
||||
// define_hash_map(Lisp_Object*, Lisp_Obj);
|
||||
// define_hash_map(void*, Void_Ptr);
|
||||
#define for_str_to_LO_hash_map(hm) __for_hm_generator(char*, Lisp_Object*, hm)
|
||||
// #define for_ptr_hash_map(hm) __for_hm_generator(void*, hm)
|
||||
#define for_LO_to_LO_hash_map(hm) __for_hm_generator(Lisp_Object*, Lisp_Object*, hm)
|
||||
|
||||
// STRUCTS
|
||||
enum struct Thread_Type {
|
||||
Main,
|
||||
GarbageCollection
|
||||
@@ -42,7 +33,6 @@ enum class Lisp_Object_Flags
|
||||
|
||||
enum struct Function_Type {
|
||||
Lambda,
|
||||
// Special_Lambda,
|
||||
Macro
|
||||
};
|
||||
|
||||
@@ -112,7 +102,7 @@ struct Arguments {
|
||||
|
||||
struct Environment {
|
||||
Array_List<Environment*> parents;
|
||||
Hash_Map<Lisp_Object*, Lisp_Object*> hm;
|
||||
Hash_Map<void*, Lisp_Object*> hm;
|
||||
};
|
||||
|
||||
struct Function {
|
||||
|
||||
+1
-1
@@ -606,7 +606,7 @@ proc run_all_tests() -> bool {
|
||||
|
||||
bool result = true;
|
||||
|
||||
Memory::init(200000, 102400, 409600);
|
||||
try Memory::init(200000, 102400, 409600);
|
||||
Environment* root_env = get_root_environment();
|
||||
Environment* user_env = Memory::create_child_environment(root_env);
|
||||
push_environment(user_env);
|
||||
|
||||
Reference in New Issue
Block a user