work on new eval-viz layer stringification which factors out measurement/limiting/etc., but just walks an eval tree and stringifies each part; start working on new types <-> lookup-rule stuff

This commit is contained in:
Ryan Fleury
2025-04-10 14:29:56 -07:00
parent b1f17b217c
commit 9bfa4f87e3
15 changed files with 278 additions and 72 deletions
+1
View File
@@ -73,6 +73,7 @@ E_TypeKindTable:
{Variadic "variadic" 0 }
{Set "set" 0 }
{Lens "lens" 0 }
{LensSpec "lens_spec" 0 }
}
@table(name op_kind precedence op_pre op_sep op_pos)
+4 -5
View File
@@ -274,11 +274,10 @@ enum
{
E_TypeFlag_Const = (1<<0),
E_TypeFlag_Volatile = (1<<1),
E_TypeFlag_External = (1<<2),
E_TypeFlag_IsPlainText = (1<<3),
E_TypeFlag_IsCodeText = (1<<4),
E_TypeFlag_IsPathText = (1<<5),
E_TypeFlag_EditableChildren = (1<<6),
E_TypeFlag_IsPlainText = (1<<2),
E_TypeFlag_IsCodeText = (1<<3),
E_TypeFlag_IsPathText = (1<<4),
E_TypeFlag_EditableChildren = (1<<5),
};
typedef struct E_Member E_Member;
+13 -2
View File
@@ -98,7 +98,7 @@ e_select_ir_ctx(E_IRCtx *ctx)
for EachElement(idx, builtin_view_rule_names)
{
E_Expr *expr = e_push_expr(e_ir_state->arena, E_ExprKind_LeafOffset, 0);
expr->type_key = e_type_key_cons(.kind = E_TypeKind_Lens, .name = builtin_view_rule_names[idx]);
expr->type_key = e_type_key_cons(.kind = E_TypeKind_LensSpec, .name = builtin_view_rule_names[idx]);
e_string2expr_map_insert(e_ir_state->arena, ctx->macro_map, builtin_view_rule_names[idx], expr);
}
}
@@ -2421,7 +2421,7 @@ E_IRGEN_FUNCTION_DEF(default)
// rjf: calling a lens? -> generate IR for the first argument; wrap the type in
// a lens type, which preserves the name & arguments of the lens call expression
if(lhs_type->kind == E_TypeKind_Lens)
if(lhs_type->kind == E_TypeKind_LensSpec)
{
Temp scratch = scratch_begin(&arena, 1);
@@ -3347,6 +3347,17 @@ e_expr_irext_cast(Arena *arena, E_Expr *rhs, E_IRTreeAndType *rhs_irtree, E_Type
////////////////////////////////
//~ rjf: Expression & IR-Tree => Rules
internal E_LookupRule *
e_lookup_rule_from_type_key(E_TypeKey type_key)
{
E_LookupRule *rule = &e_lookup_rule__default;
// rjf: unpack type
E_Type *type = e_type_from_key__cached(type_key);
return rule;
}
internal E_LookupRuleExprPair
e_lookup_rule_expr_pair_from_expr_irtree(E_Expr *expr, E_IRTreeAndType *irtree)
{
+1
View File
@@ -288,6 +288,7 @@ internal E_Expr *e_expr_irext_cast(Arena *arena, E_Expr *rhs, E_IRTreeAndType *r
////////////////////////////////
//~ rjf: Expression & IR-Tree => Rules
internal E_LookupRule *e_lookup_rule_from_type_key(E_TypeKey type_key);
internal E_LookupRuleExprPair e_lookup_rule_expr_pair_from_expr_irtree(E_Expr *expr, E_IRTreeAndType *irtree);
#if 0 // TODO(rjf): @eval
-1
View File
@@ -483,7 +483,6 @@ e_type_key_cons_base(Type *type)
{
E_TypeKey direct_type = e_type_key_cons_base(type->direct);
E_TypeFlags flags = 0;
if(type->flags & TypeFlag_IsExternal) { flags |= E_TypeFlag_External; }
if(type->flags & TypeFlag_IsPlainText){ flags |= E_TypeFlag_IsPlainText; }
if(type->flags & TypeFlag_IsCodeText) { flags |= E_TypeFlag_IsCodeText; }
if(type->flags & TypeFlag_IsPathText) { flags |= E_TypeFlag_IsPathText; }
+4 -2
View File
@@ -14,7 +14,7 @@ str8_lit_comp("CharLiteral"),
str8_lit_comp("Symbol"),
};
String8 e_type_kind_basic_string_table[57] =
String8 e_type_kind_basic_string_table[58] =
{
str8_lit_comp(""),
str8_lit_comp("void"),
@@ -73,9 +73,10 @@ str8_lit_comp("bitfield"),
str8_lit_comp("variadic"),
str8_lit_comp("set"),
str8_lit_comp("lens"),
str8_lit_comp("lens_spec"),
};
U8 e_type_kind_basic_byte_size_table[57] =
U8 e_type_kind_basic_byte_size_table[58] =
{
0,
0,
@@ -134,6 +135,7 @@ U8 e_type_kind_basic_byte_size_table[57] =
0,
0,
0,
0,
};
String8 e_expr_kind_strings[48] =
+3 -2
View File
@@ -76,6 +76,7 @@ E_TypeKind_Bitfield,
E_TypeKind_Variadic,
E_TypeKind_Set,
E_TypeKind_Lens,
E_TypeKind_LensSpec,
E_TypeKind_COUNT,
E_TypeKind_FirstBasic = E_TypeKind_Void,
E_TypeKind_LastBasic = E_TypeKind_ComplexF128,
@@ -161,8 +162,8 @@ E_InterpretationCode_COUNT,
C_LINKAGE_BEGIN
extern String8 e_token_kind_strings[6];
extern String8 e_type_kind_basic_string_table[57];
extern U8 e_type_kind_basic_byte_size_table[57];
extern String8 e_type_kind_basic_string_table[58];
extern U8 e_type_kind_basic_byte_size_table[58];
extern String8 e_expr_kind_strings[48];
extern E_OpInfo e_expr_kind_op_info_table[48];
extern String8 e_interpretation_code_display_strings[11];