updated to use type-extensible hashmaps
This commit is contained in:
@@ -426,6 +426,7 @@ proc load_built_ins_into_environment() -> void {
|
||||
define_special((define definee (:doc "") . body), "TODO") {
|
||||
fetch(definee, doc, body);
|
||||
|
||||
// print_hm(get_current_environment()->hm);
|
||||
try assert_type(doc, Lisp_Object_Type::String);
|
||||
|
||||
// if no doc string, we dont have to store it
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ proc create_error(const char* c_file_name, int c_file_line, Lisp_Object* type, S
|
||||
|
||||
delete_error();
|
||||
if (Globals::breaking_on_errors) {
|
||||
// debug_break();
|
||||
debug_break();
|
||||
}
|
||||
// visualize_lisp_machine();
|
||||
|
||||
|
||||
+1
-1
Submodule src/ftb updated: 854593273f...2f6954b520
+1
-1
@@ -387,7 +387,7 @@ namespace Memory {
|
||||
if (parent)
|
||||
append_to_array_list(&env->parents, parent);
|
||||
|
||||
env->hm = create_hashmap();
|
||||
env->hm = create_String_hashmap();
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
+30
-1
@@ -2,12 +2,41 @@ struct Lisp_Object;
|
||||
struct String;
|
||||
struct Environment;
|
||||
|
||||
// ARRAY LISTS
|
||||
define_array_list(Lisp_Object*, Lisp_Object);
|
||||
define_array_list(Environment*, Environment);
|
||||
define_array_list(String*, String);
|
||||
define_array_list(int, Int);
|
||||
define_array_list(void*, Void_Ptr);
|
||||
|
||||
// HASH MAPS
|
||||
inline bool hm_objects_match(char* a, char* b) {
|
||||
return strcmp(a, b) == 0;
|
||||
}
|
||||
|
||||
inline bool hm_objects_match(void* a, void* b) {
|
||||
return a == b;
|
||||
}
|
||||
|
||||
u32 hm_hash(void* ptr) {
|
||||
return ((unsigned long long)ptr * 2654435761) % 4294967296;
|
||||
}
|
||||
|
||||
u32 hm_hash(char* str) {
|
||||
u32 value = str[0] << 7;
|
||||
int i = 0;
|
||||
while (str[i]) {
|
||||
value = (10000003 * value) ^ str[i++];
|
||||
}
|
||||
return value ^ i;
|
||||
}
|
||||
|
||||
define_hash_map(char*, String);
|
||||
define_hash_map(void*, Void_Ptr);
|
||||
#define for_str_hash_map(hm) __for_hm_generator(char*, hm)
|
||||
#define for_ptr_hash_map(hm) __for_hm_generator(void*, hm)
|
||||
|
||||
// STRUCTS
|
||||
enum struct Thread_Type {
|
||||
Main,
|
||||
GarbageCollection
|
||||
@@ -111,7 +140,7 @@ struct Arguments {
|
||||
|
||||
struct Environment {
|
||||
Environment_Array_List parents;
|
||||
StringHashMap* hm;
|
||||
String_Hash_Map* hm;
|
||||
// int capacity;
|
||||
// int next_index;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user