meta-expr type operators, for meta-evaluations, to annotate source expression strings of evaluations

This commit is contained in:
Ryan Fleury
2025-04-14 15:21:46 -07:00
parent 8e13f8162a
commit db381db85d
8 changed files with 85 additions and 8 deletions
+1
View File
@@ -74,6 +74,7 @@ E_TypeKindTable:
{Set "set" 0 }
{Lens "lens" 0 }
{LensSpec "lens_spec" 0 }
{MetaExpr "meta_expr" 0 }
}
@table(name op_kind precedence op_pre op_sep op_pos op_chain)
+21 -1
View File
@@ -1338,7 +1338,8 @@ e_type_unwrap(E_TypeKey key)
if((E_TypeKind_FirstIncomplete <= kind && kind <= E_TypeKind_LastIncomplete) ||
kind == E_TypeKind_Modifier ||
kind == E_TypeKind_Alias ||
kind == E_TypeKind_Lens)
kind == E_TypeKind_Lens ||
kind == E_TypeKind_MetaExpr)
{
result = e_type_direct_from_key(result);
}
@@ -1800,6 +1801,12 @@ e_type_lhs_string_from_key(Arena *arena, E_TypeKey key, String8List *out, U32 pr
}
str8_list_push(arena, out, str8_lit("::*"));
}break;
case E_TypeKind_MetaExpr:
{
E_TypeKey direct = e_type_direct_from_key(key);
e_type_lhs_string_from_key(arena, direct, out, prec, skip_return);
}break;
}
}
@@ -1874,6 +1881,12 @@ e_type_rhs_string_from_key(Arena *arena, E_TypeKey key, String8List *out, U32 pr
E_TypeKey direct = e_type_direct_from_key(key);
e_type_rhs_string_from_key(arena, direct, out, 2);
}break;
case E_TypeKind_MetaExpr:
{
E_TypeKey direct = e_type_direct_from_key(key);
e_type_rhs_string_from_key(arena, direct, out, prec);
}break;
}
}
@@ -1947,6 +1960,13 @@ e_default_expansion_type_from_key(E_TypeKey root_key)
done = 0;
}
//- rjf: if we have meta-expression tags in the type chain, defer
// to the next type in the chain.
else if(kind == E_TypeKind_MetaExpr)
{
done = 0;
}
//- rjf: if we've reached a struct-like, then we can use that for
// struct-like expansion.
else if(kind == E_TypeKind_Struct ||
+4 -2
View File
@@ -14,7 +14,7 @@ str8_lit_comp("CharLiteral"),
str8_lit_comp("Symbol"),
};
String8 e_type_kind_basic_string_table[58] =
String8 e_type_kind_basic_string_table[59] =
{
str8_lit_comp(""),
str8_lit_comp("void"),
@@ -74,9 +74,10 @@ str8_lit_comp("variadic"),
str8_lit_comp("set"),
str8_lit_comp("lens"),
str8_lit_comp("lens_spec"),
str8_lit_comp("meta_expr"),
};
U8 e_type_kind_basic_byte_size_table[58] =
U8 e_type_kind_basic_byte_size_table[59] =
{
0,
0,
@@ -136,6 +137,7 @@ U8 e_type_kind_basic_byte_size_table[58] =
0,
0,
0,
0,
};
String8 e_expr_kind_strings[48] =
+3 -2
View File
@@ -77,6 +77,7 @@ E_TypeKind_Variadic,
E_TypeKind_Set,
E_TypeKind_Lens,
E_TypeKind_LensSpec,
E_TypeKind_MetaExpr,
E_TypeKind_COUNT,
E_TypeKind_FirstBasic = E_TypeKind_Void,
E_TypeKind_LastBasic = E_TypeKind_ComplexF128,
@@ -162,8 +163,8 @@ E_InterpretationCode_COUNT,
C_LINKAGE_BEGIN
extern String8 e_token_kind_strings[6];
extern String8 e_type_kind_basic_string_table[58];
extern U8 e_type_kind_basic_byte_size_table[58];
extern String8 e_type_kind_basic_string_table[59];
extern U8 e_type_kind_basic_byte_size_table[59];
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];