mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-18 23:21:32 -07:00
eval: lookup rule map building; eval: use general 'set' type-kind to specify custom lookup rule; watch: new table <-> stable-point mappings
This commit is contained in:
@@ -9,14 +9,16 @@
|
||||
////////////////////////////////
|
||||
//~ rjf: Basic Helper Functions
|
||||
|
||||
#if !defined(XXH_IMPLEMENTATION)
|
||||
# define XXH_IMPLEMENTATION
|
||||
# define XXH_STATIC_LINKING_ONLY
|
||||
# include "third_party/xxHash/xxhash.h"
|
||||
#endif
|
||||
|
||||
internal U64
|
||||
e_hash_from_string(U64 seed, String8 string)
|
||||
{
|
||||
U64 result = seed;
|
||||
for(U64 i = 0; i < string.size; i += 1)
|
||||
{
|
||||
result = ((result << 5) + result) + string.str[i];
|
||||
}
|
||||
U64 result = XXH3_64bits_withSeed(string.str, string.size, seed);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+30
-1
@@ -73,6 +73,26 @@ e_select_ir_ctx(E_IRCtx *ctx)
|
||||
////////////////////////////////
|
||||
//~ rjf: Lookups
|
||||
|
||||
internal E_LookupRuleMap
|
||||
e_lookup_rule_map_make(Arena *arena, U64 slots_count)
|
||||
{
|
||||
E_LookupRuleMap map = {0};
|
||||
map.slots_count = slots_count;
|
||||
map.slots = push_array(arena, E_LookupRuleSlot, map.slots_count);
|
||||
return map;
|
||||
}
|
||||
|
||||
internal void
|
||||
e_lookup_rule_map_insert(Arena *arena, E_LookupRuleMap *map, E_LookupRule *rule)
|
||||
{
|
||||
U64 hash = e_hash_from_string(5381, rule->name);
|
||||
U64 slot_idx = hash%map->slots_count;
|
||||
E_LookupRuleNode *n = push_array(arena, E_LookupRuleNode, 1);
|
||||
SLLQueuePush(map->slots[slot_idx].first, map->slots[slot_idx].last, n);
|
||||
MemoryCopyStruct(&n->v, rule);
|
||||
n->v.name = push_str8_copy(arena, n->v.name);
|
||||
}
|
||||
|
||||
internal E_LookupRule *
|
||||
e_lookup_rule_from_string(String8 string)
|
||||
{
|
||||
@@ -703,12 +723,21 @@ e_irtree_and_type_from_expr__space(Arena *arena, E_Space *current_space, E_Expr
|
||||
case E_ExprKind_MemberAccess:
|
||||
case E_ExprKind_ArrayIndex:
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
E_Expr *lhs = expr->first;
|
||||
E_IRTreeAndType lhs_irtree = e_irtree_and_type_from_expr(scratch.arena, lhs);
|
||||
E_Type *lhs_type = e_type_from_key(scratch.arena, lhs_irtree.type_key);
|
||||
String8 lookup_rule_name = expr->string;
|
||||
if(lhs_type->kind == E_TypeKind_Set)
|
||||
{
|
||||
lookup_rule_name = lhs_type->name;
|
||||
}
|
||||
E_Expr *rhs = lhs->next;
|
||||
E_LookupRule *lookup_rule = e_lookup_rule_from_string(expr->string);
|
||||
E_LookupRule *lookup_rule = e_lookup_rule_from_string(lookup_rule_name);
|
||||
E_LookupInfo lookup_info = lookup_rule->lookup_info(arena, lhs);
|
||||
E_Lookup lookup = lookup_rule->lookup(arena, expr->kind, lhs, rhs, lookup_info.user_data);
|
||||
result = lookup.irtree_and_type;
|
||||
scratch_end(scratch);
|
||||
}break;
|
||||
|
||||
//- rjf: dereference
|
||||
|
||||
@@ -152,6 +152,10 @@ internal void e_select_ir_ctx(E_IRCtx *ctx);
|
||||
////////////////////////////////
|
||||
//~ rjf: Lookups
|
||||
|
||||
internal E_LookupRuleMap e_lookup_rule_map_make(Arena *arena, U64 slots_count);
|
||||
internal void e_lookup_rule_map_insert(Arena *arena, E_LookupRuleMap *map, E_LookupRule *rule);
|
||||
#define e_lookup_rule_map_insert_new(arena, map, name_, lookup_info_, lookup_) e_lookup_rule_map_insert((arena), (map), &(E_LookupRule){.name = (name_), .lookup_info = (lookup_info_), .lookup = (lookup_)})
|
||||
|
||||
internal E_LookupRule *e_lookup_rule_from_string(String8 string);
|
||||
E_LOOKUP_INFO_FUNCTION_DEF(default);
|
||||
E_LOOKUP_FUNCTION_DEF(default);
|
||||
|
||||
Reference in New Issue
Block a user