Ver a proveniência

updated to use type-extensible hashmaps

master
FelixBrendel há 6 anos
ascendente
cometimento
2cc076fa43
5 ficheiros alterados com 34 adições e 4 eliminações
  1. +1
    -0
      src/built_ins.cpp
  2. +1
    -1
      src/error.cpp
  3. +1
    -1
      src/ftb
  4. +1
    -1
      src/memory.cpp
  5. +30
    -1
      src/structs.cpp

+ 1
- 0
src/built_ins.cpp Ver ficheiro

@@ -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
src/error.cpp Ver ficheiro

@@ -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
src/ftb

@@ -1 +1 @@
Subproject commit 854593273fdf8039d8ac1ac7150527fca47818ef
Subproject commit 2f6954b520f0175e801a78dbfb00ab026f75c1bf

+ 1
- 1
src/memory.cpp Ver ficheiro

@@ -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
src/structs.cpp Ver ficheiro

@@ -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;



Carregando…
Cancelar
Guardar