From 58e9169c0386b79e7c81b973232f010d221f3a1b Mon Sep 17 00:00:00 2001 From: FelixBrendel Date: Thu, 17 Oct 2019 14:46:52 +0200 Subject: [PATCH] now with generic hashmaps and array lists --- bin/slime.rdbg | Bin 0 -> 71 bytes src/eval.cpp | 6 +++++- src/forward_decls.cpp | 16 ++++++++-------- src/ftb | 2 +- src/slime.h | 12 ++---------- src/structs.cpp | 4 +--- 6 files changed, 17 insertions(+), 23 deletions(-) create mode 100644 bin/slime.rdbg diff --git a/bin/slime.rdbg b/bin/slime.rdbg new file mode 100644 index 0000000000000000000000000000000000000000..e7085e0218191c5950cf72ab3b95280a0fab5a23 GIT binary patch literal 71 zcmWG?adKB@U|?{uigC_QNsV#OEJ;m_35YQ+N{K1X$;?fSNy^NFu=G+ZQh_S50sztZ B599y< literal 0 HcmV?d00001 diff --git a/src/eval.cpp b/src/eval.cpp index 5b20b4f..b54f788 100644 --- a/src/eval.cpp +++ b/src/eval.cpp @@ -252,13 +252,17 @@ proc apply_arguments_to_function(Lisp_Object* arguments, Lisp_Object* function, filling it in */ proc create_arguments_from_lambda_list_and_inject(Lisp_Object* arguments, Lisp_Object* function) -> void { - Arguments* result;; + Arguments* result; if (Memory::get_type(function) == Lisp_Object_Type::CFunction) { result = &function->value.cFunction->args; } else { result = &function->value.function.args; } + ::new ((&(result->positional.symbols))) Array_List; + ::new ((&(result->keyword.keywords))) Array_List; + ::new ((&(result->keyword.values))) Array_List; + // first init the fields // result->positional = create_positional_argument_list(16); // result->keyword = create_keyword_argument_list(16); diff --git a/src/forward_decls.cpp b/src/forward_decls.cpp index ba2e3c7..0344738 100644 --- a/src/forward_decls.cpp +++ b/src/forward_decls.cpp @@ -62,14 +62,6 @@ namespace Globals { Error* error = nullptr; } -bool hm_objects_match(char* a, char* b) { - return strcmp(a, b) == 0; -} - -bool hm_objects_match(void* a, void* b) { - return a == b; -} - unsigned int hm_hash(void* ptr) { return ((unsigned long long)ptr * 2654435761) % 4294967296; } @@ -83,6 +75,14 @@ unsigned int hm_hash(char* str) { 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); } diff --git a/src/ftb b/src/ftb index e782aa7..dd7db5b 160000 --- a/src/ftb +++ b/src/ftb @@ -1 +1 @@ -Subproject commit e782aa70b7ad2a175f11683307e605ad805d5ad3 +Subproject commit dd7db5b3308b839995bfa211fb77ced6aa2f696e diff --git a/src/slime.h b/src/slime.h index 328675a..e9bcbbc 100644 --- a/src/slime.h +++ b/src/slime.h @@ -24,19 +24,11 @@ #include "./ftb/types.hpp" #include "./ftb/macros.hpp" #include "./ftb/profiler.hpp" - -struct Lisp_Object; -u32 hm_hash(Lisp_Object* obj); -unsigned int hm_hash(char* obj); -unsigned int hm_hash(void* obj); -bool hm_objects_match(void* a, void* b); -bool hm_objects_match(char* a, char* b); -bool hm_objects_match(Lisp_Object* a, Lisp_Object* b); - -#include "./ftb/hashmap.hpp" #include "./ftb/arraylist.hpp" namespace Slime { +#include "./ftb/hashmap.hpp" + # include "./defines.cpp" # include "./platform.cpp" # include "./structs.cpp" diff --git a/src/structs.cpp b/src/structs.cpp index 1936d56..b7a6920 100644 --- a/src/structs.cpp +++ b/src/structs.cpp @@ -33,9 +33,7 @@ enum struct Lisp_Object_Type { CFunction, }; -typedef uint64_t u64; - -enum class Lisp_Object_Flags : u64 +enum class Lisp_Object_Flags { // bits 1 to 5 (including) will be reserved for the type Already_Garbage_Collected = 1 << 5,