From 999eca5e29cac852873ecdc401d35d8a632afd32 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Mon, 31 Mar 2025 15:41:10 -0700 Subject: [PATCH] more old eval trimming --- src/eval/eval.mdesk | 146 +++++----- src/eval/eval_core.h | 474 +++++++++++++++++++++++++++++++++ src/eval/eval_interpret.h | 2 - src/eval/eval_ir.h | 185 ------------- src/eval/eval_parse.h | 149 ----------- src/eval/eval_types.c | 12 +- src/eval/eval_types.h | 137 ---------- src/eval/generated/eval.meta.c | 372 +++++++++++++------------- src/eval/generated/eval.meta.h | 6 +- src/scratch/eval_scratch.c | 2 +- 10 files changed, 740 insertions(+), 745 deletions(-) diff --git a/src/eval/eval.mdesk b/src/eval/eval.mdesk index 82bc175a..ec41dfa9 100644 --- a/src/eval/eval.mdesk +++ b/src/eval/eval.mdesk @@ -74,70 +74,70 @@ E_TypeKindTable: {Set "set" 0 } } -@table(name op_kind precedence string op_pre op_sep op_pos) +@table(name op_kind precedence op_pre op_sep op_pos) E_ExprKindTable: { - { Nil Null 0 "" "" "" "" } - { Ref Null 0 "" "" "" "" } + { Nil Null 0 "" "" "" } + { Ref Null 0 "" "" "" } - { ArrayIndex Null 0 "[]" "" "[" "]"} - { MemberAccess Null 0 "." "" "." "" } - { Deref UnaryPrefix 2 "*" "*" "" "" } - { Address UnaryPrefix 2 "&" "&" "" "" } + { ArrayIndex Null 0 "" "[" "]"} + { MemberAccess Null 0 "" "." "" } + { Deref UnaryPrefix 2 "*" "" "" } + { Address UnaryPrefix 2 "&" "" "" } - { Cast Null 1 "cast" "(" ")" "" } - { Sizeof UnaryPrefix 1 "sizeof" "sizeof" "(" ")"} - { Typeof UnaryPrefix 1 "typeof" "typeof" "(" ")"} - { ByteSwap UnaryPrefix 1 "bswap" "bswap" "(" ")"} + { Cast Null 1 "(" ")" "" } + { Sizeof UnaryPrefix 1 "sizeof" "(" ")"} + { Typeof UnaryPrefix 1 "typeof" "(" ")"} + { ByteSwap UnaryPrefix 1 "bswap" "(" ")"} - { Pos UnaryPrefix 2 "+" "+" "" "" } - { Neg UnaryPrefix 2 "-" "-" "" "" } - { LogNot UnaryPrefix 2 "!" "!" "" "" } - { BitNot UnaryPrefix 2 "~" "~" "" "" } - { Mul Binary 3 "*" "" "*" "" } - { Div Binary 3 "/" "" "/" "" } - { Mod Binary 3 "%" "" "%" "" } - { Add Binary 4 "+" "" "+" "" } - { Sub Binary 4 "-" "" "-" "" } - { LShift Binary 5 "<<" "" "<<" "" } - { RShift Binary 5 ">>" "" ">>" "" } - { Less Binary 6 "<" "" "<" "" } - { LsEq Binary 6 "<=" "" "<=" "" } - { Grtr Binary 6 ">" "" ">" "" } - { GrEq Binary 6 ">=" "" ">=" "" } - { EqEq Binary 7 "==" "" "==" "" } - { NtEq Binary 7 "!=" "" "!=" "" } + { Pos UnaryPrefix 2 "+" "" "" } + { Neg UnaryPrefix 2 "-" "" "" } + { LogNot UnaryPrefix 2 "!" "" "" } + { BitNot UnaryPrefix 2 "~" "" "" } + { Mul Binary 3 "" "*" "" } + { Div Binary 3 "" "/" "" } + { Mod Binary 3 "" "%" "" } + { Add Binary 4 "" "+" "" } + { Sub Binary 4 "" "-" "" } + { LShift Binary 5 "" "<<" "" } + { RShift Binary 5 "" ">>" "" } + { Less Binary 6 "" "<" "" } + { LsEq Binary 6 "" "<=" "" } + { Grtr Binary 6 "" ">" "" } + { GrEq Binary 6 "" ">=" "" } + { EqEq Binary 7 "" "==" "" } + { NtEq Binary 7 "" "!=" "" } - { BitAnd Binary 8 "&" "" "&" "" } - { BitXor Binary 9 "^" "" "^" "" } - { BitOr Binary 10 "|" "" "|" "" } - { LogAnd Binary 11 "&&" "" "&&" "" } - { LogOr Binary 12 "||" "" "||" "" } + { BitAnd Binary 8 "" "&" "" } + { BitXor Binary 9 "" "^" "" } + { BitOr Binary 10 "" "|" "" } + { LogAnd Binary 11 "" "&&" "" } + { LogOr Binary 12 "" "||" "" } - { Ternary Null 0 "? " "" "?" ":"} + { Ternary Null 0 "" "?" ":"} - { Call Null 0 "()" "(" "," ")"} + { Call Null 0 "(" "," ")"} - { LeafBytecode Null 0 "bytecode" "" "" "" } - { LeafMember Null 0 "member" "" "" "" } - { LeafStringLiteral Null 0 "string_literal" "" "" "" } - { LeafBool Null 0 "B32" "" "" "" } - { LeafU64 Null 0 "U64" "" "" "" } - { LeafF64 Null 0 "F64" "" "" "" } - { LeafF32 Null 0 "F32" "" "" "" } - { LeafIdentifier Null 0 "leaf_identifier" "" "" "" } - { LeafOffset Null 0 "leaf_offset" "" "" "" } - { LeafValue Null 0 "leaf_value" "" "" "" } - { LeafFilePath Null 0 "leaf_filepath" "" "" "" } + { LeafBytecode Null 0 "" "" "" } + { LeafMember Null 0 "" "" "" } + { LeafStringLiteral Null 0 "" "" "" } + { LeafBool Null 0 "" "" "" } + { LeafU64 Null 0 "" "" "" } + { LeafF64 Null 0 "" "" "" } + { LeafF32 Null 0 "" "" "" } + { LeafIdentifier Null 0 "" "" "" } + { LeafOffset Null 0 "" "" "" } + { LeafValue Null 0 "" "" "" } + { LeafFilePath Null 0 "" "" "" } - { TypeIdent Null 0 "type_ident" "" "" "" } - { Ptr Null 0 "ptr" "" "" "" } - { Array Null 0 "array" "" "" "" } - { Func Null 0 "function" "" "" "" } + { TypeIdent Null 0 "" "" "" } + { Ptr Null 0 "" "" "" } + { Array Null 0 "" "" "" } + { Func Null 0 "" "" "" } - { Define Binary 13 "=" "" "=" "" } + { Define Binary 13 "" "=" "" } - { Tag Null 0 "=>" "=>" "," "" } + { Tag Null 0 "=>" "," "" } } @table(name display_string) @@ -162,6 +162,12 @@ E_InterpretationCodeTable: COUNT, } +@data(String8) +e_token_kind_strings: +{ + @expand(E_TokenKindTable a) `str8_lit_comp("$(a.name)")` +} + @enum E_TypeKind: { @expand(E_TypeKindTable a) `$(a.name)`, @@ -178,46 +184,40 @@ E_InterpretationCodeTable: `LastIncomplete = E_TypeKind_IncompleteEnum`, } +@data(String8) e_type_kind_basic_string_table: +{ + @expand(E_TypeKindTable a) `str8_lit_comp("$(a.basic_string)")`; +} + +@data(U8) e_type_kind_basic_byte_size_table: +{ + @expand(E_TypeKindTable a) `$(a.basic_byte_size)`; +} + @enum(U32) E_ExprKind: { @expand(E_ExprKindTable a) `$(a.name)`, COUNT, } -@enum E_InterpretationCode: -{ - @expand(E_InterpretationCodeTable a) `$(a.name)`, - COUNT, -} - -@data(String8) -e_token_kind_strings: -{ - @expand(E_TokenKindTable a) `str8_lit_comp("$(a.name)")` -} - @data(String8) e_expr_kind_strings: { @expand(E_ExprKindTable a) `str8_lit_comp("$(a.name)")` } -@data(String8) e_interpretation_code_display_strings: -{ - @expand(E_InterpretationCodeTable a) `str8_lit_comp("$(a.display_string)")` -} - @data(E_OpInfo) e_expr_kind_op_info_table: { @expand(E_ExprKindTable a) `{ E_OpKind_$(a.op_kind), $(a.precedence), str8_lit_comp("$(a.op_pre)"), str8_lit_comp("$(a.op_sep)"), str8_lit_comp("$(a.op_pos)") }` } -@data(U8) e_kind_basic_byte_size_table: +@enum E_InterpretationCode: { - @expand(E_TypeKindTable a) `$(a.basic_byte_size)`; + @expand(E_InterpretationCodeTable a) `$(a.name)`, + COUNT, } -@data(String8) e_kind_basic_string_table: +@data(String8) e_interpretation_code_display_strings: { - @expand(E_TypeKindTable a) `str8_lit_comp("$(a.basic_string)")`; + @expand(E_InterpretationCodeTable a) `str8_lit_comp("$(a.display_string)")` } diff --git a/src/eval/eval_core.h b/src/eval/eval_core.h index df697586..7bcd86a1 100644 --- a/src/eval/eval_core.h +++ b/src/eval/eval_core.h @@ -114,6 +114,147 @@ struct E_Space }; }; +//////////////////////////////// +//~ rjf: Implicit Type Graph Key Types + +typedef enum E_TypeKeyKind +{ + E_TypeKeyKind_Null, + E_TypeKeyKind_Basic, + E_TypeKeyKind_Ext, + E_TypeKeyKind_Cons, + E_TypeKeyKind_Reg, + E_TypeKeyKind_RegAlias, +} +E_TypeKeyKind; + +typedef struct E_TypeKey E_TypeKey; +struct E_TypeKey +{ + E_TypeKeyKind kind; + U32 u32[3]; + // [0] -> E_TypeKind (Basic, Cons, Ext); Arch (Reg, RegAlias) + // [1] -> Type Index In RDI (Ext); Code (Reg, RegAlias); Type Index In Constructed (Cons) + // [2] -> RDI Index (Ext) +}; + +typedef struct E_TypeKeyNode E_TypeKeyNode; +struct E_TypeKeyNode +{ + E_TypeKeyNode *next; + E_TypeKey v; +}; + +typedef struct E_TypeKeyList E_TypeKeyList; +struct E_TypeKeyList +{ + E_TypeKeyNode *first; + E_TypeKeyNode *last; + U64 count; +}; + +//////////////////////////////// +//~ rjf: Generated Code + +#include "generated/eval.meta.h" + +//////////////////////////////// +//~ rjf: Full Extracted Type Information Types + +typedef enum E_MemberKind +{ + E_MemberKind_Null, + E_MemberKind_DataField, + E_MemberKind_StaticData, + E_MemberKind_Method, + E_MemberKind_StaticMethod, + E_MemberKind_VirtualMethod, + E_MemberKind_VTablePtr, + E_MemberKind_Base, + E_MemberKind_VirtualBase, + E_MemberKind_NestedType, + E_MemberKind_Padding, + E_MemberKind_Query, + E_MemberKind_COUNT +} +E_MemberKind; + +typedef U32 E_TypeFlags; +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), +}; + +typedef struct E_Member E_Member; +struct E_Member +{ + E_MemberKind kind; + E_TypeKey type_key; + String8 name; + U64 off; + E_TypeKeyList inheritance_key_chain; +}; + +typedef struct E_MemberNode E_MemberNode; +struct E_MemberNode +{ + E_MemberNode *next; + E_Member v; +}; + +typedef struct E_MemberList E_MemberList; +struct E_MemberList +{ + E_MemberNode *first; + E_MemberNode *last; + U64 count; +}; + +typedef struct E_MemberArray E_MemberArray; +struct E_MemberArray +{ + E_Member *v; + U64 count; +}; + +typedef struct E_EnumVal E_EnumVal; +struct E_EnumVal +{ + String8 name; + U64 val; +}; + +typedef struct E_EnumValArray E_EnumValArray; +struct E_EnumValArray +{ + E_EnumVal *v; + U64 count; +}; + +typedef struct E_Type E_Type; +struct E_Type +{ + E_TypeKind kind; + E_TypeFlags flags; + String8 name; + U64 byte_size; + U64 count; + U64 depth; + U32 off; + Arch arch; + E_TypeKey direct_type_key; + E_TypeKey owner_type_key; + E_TypeKey *param_type_keys; + E_Member *members; + E_EnumVal *enum_vals; +}; + //////////////////////////////// //~ rjf: Evaluation Modes @@ -137,6 +278,339 @@ struct E_Module E_Space space; }; +//////////////////////////////// +//~ rjf: Token Types + +typedef struct E_Token E_Token; +struct E_Token +{ + E_TokenKind kind; + Rng1U64 range; +}; + +typedef struct E_TokenChunkNode E_TokenChunkNode; +struct E_TokenChunkNode +{ + E_TokenChunkNode *next; + E_Token *v; + U64 count; + U64 cap; +}; + +typedef struct E_TokenChunkList E_TokenChunkList; +struct E_TokenChunkList +{ + E_TokenChunkNode *first; + E_TokenChunkNode *last; + U64 node_count; + U64 total_count; +}; + +typedef struct E_TokenArray E_TokenArray; +struct E_TokenArray +{ + E_Token *v; + U64 count; +}; + +//////////////////////////////// +//~ rjf: Expression Tree Types + +typedef struct E_Expr E_Expr; +struct E_Expr +{ + E_Expr *first; + E_Expr *last; + E_Expr *first_tag; + E_Expr *last_tag; + E_Expr *next; + E_Expr *prev; + E_Expr *ref; + void *location; + E_ExprKind kind; + E_Mode mode; + E_Space space; + E_TypeKey type_key; + E_Value value; + String8 string; + String8 qualifier; + String8 bytecode; +}; + +typedef struct E_ExprChain E_ExprChain; +struct E_ExprChain +{ + E_Expr *first; + E_Expr *last; +}; + +typedef struct E_ExprNode E_ExprNode; +struct E_ExprNode +{ + E_ExprNode *next; + E_Expr *v; +}; + +typedef struct E_ExprList E_ExprList; +struct E_ExprList +{ + E_ExprNode *first; + E_ExprNode *last; + U64 count; +}; + +//////////////////////////////// +//~ rjf: IR Tree Types + +typedef struct E_IRNode E_IRNode; +struct E_IRNode +{ + E_IRNode *first; + E_IRNode *last; + E_IRNode *next; + RDI_EvalOp op; + E_Space space; + String8 string; + E_Value value; +}; + +typedef struct E_IRTreeAndType E_IRTreeAndType; +struct E_IRTreeAndType +{ + E_IRNode *root; + E_TypeKey type_key; + E_Member member; + E_Mode mode; + E_MsgList msgs; +}; + +//////////////////////////////// +//~ rjf: String -> Num + +typedef struct E_String2NumMapNode E_String2NumMapNode; +struct E_String2NumMapNode +{ + E_String2NumMapNode *order_next; + E_String2NumMapNode *hash_next; + String8 string; + U64 num; +}; + +typedef struct E_String2NumMapNodeArray E_String2NumMapNodeArray; +struct E_String2NumMapNodeArray +{ + E_String2NumMapNode **v; + U64 count; +}; + +typedef struct E_String2NumMapSlot E_String2NumMapSlot; +struct E_String2NumMapSlot +{ + E_String2NumMapNode *first; + E_String2NumMapNode *last; +}; + +typedef struct E_String2NumMap E_String2NumMap; +struct E_String2NumMap +{ + U64 slots_count; + U64 node_count; + E_String2NumMapSlot *slots; + E_String2NumMapNode *first; + E_String2NumMapNode *last; +}; + +//////////////////////////////// +//~ rjf: String -> Expr + +typedef struct E_String2ExprMapNode E_String2ExprMapNode; +struct E_String2ExprMapNode +{ + E_String2ExprMapNode *hash_next; + String8 string; + E_Expr *expr; + U64 poison_count; +}; + +typedef struct E_String2ExprMapSlot E_String2ExprMapSlot; +struct E_String2ExprMapSlot +{ + E_String2ExprMapNode *first; + E_String2ExprMapNode *last; +}; + +typedef struct E_String2ExprMap E_String2ExprMap; +struct E_String2ExprMap +{ + U64 slots_count; + E_String2ExprMapSlot *slots; +}; + +//////////////////////////////// +//~ rjf: Member/Index Lookup Hooks + +typedef struct E_LookupInfo E_LookupInfo; +struct E_LookupInfo +{ + void *user_data; + U64 named_expr_count; + U64 idxed_expr_count; +}; + +typedef struct E_LookupAccess E_LookupAccess; +struct E_LookupAccess +{ + E_IRTreeAndType irtree_and_type; +}; + +#define E_LOOKUP_INFO_FUNCTION_SIG(name) E_LookupInfo name(Arena *arena, E_IRTreeAndType *lhs, E_Expr *tag, String8 filter) +#define E_LOOKUP_INFO_FUNCTION_NAME(name) e_lookup_info_##name +#define E_LOOKUP_INFO_FUNCTION_DEF(name) internal E_LOOKUP_INFO_FUNCTION_SIG(E_LOOKUP_INFO_FUNCTION_NAME(name)) +typedef E_LOOKUP_INFO_FUNCTION_SIG(E_LookupInfoFunctionType); +E_LOOKUP_INFO_FUNCTION_DEF(default); + +#define E_LOOKUP_ACCESS_FUNCTION_SIG(name) E_LookupAccess name(Arena *arena, E_ExprKind kind, E_Expr *lhs, E_Expr *rhs, E_Expr *tag, void *user_data) +#define E_LOOKUP_ACCESS_FUNCTION_NAME(name) e_lookup_access_##name +#define E_LOOKUP_ACCESS_FUNCTION_DEF(name) internal E_LOOKUP_ACCESS_FUNCTION_SIG(E_LOOKUP_ACCESS_FUNCTION_NAME(name)) +typedef E_LOOKUP_ACCESS_FUNCTION_SIG(E_LookupAccessFunctionType); +E_LOOKUP_ACCESS_FUNCTION_DEF(default); + +#define E_LOOKUP_RANGE_FUNCTION_SIG(name) void name(Arena *arena, E_Expr *lhs, E_Expr *tag, String8 filter, Rng1U64 idx_range, E_Expr **exprs, String8 *exprs_strings, void *user_data) +#define E_LOOKUP_RANGE_FUNCTION_NAME(name) e_lookup_range_##name +#define E_LOOKUP_RANGE_FUNCTION_DEF(name) internal E_LOOKUP_RANGE_FUNCTION_SIG(E_LOOKUP_RANGE_FUNCTION_NAME(name)) +typedef E_LOOKUP_RANGE_FUNCTION_SIG(E_LookupRangeFunctionType); +E_LOOKUP_RANGE_FUNCTION_DEF(default); + +#define E_LOOKUP_ID_FROM_NUM_FUNCTION_SIG(name) U64 name(U64 num, void *user_data) +#define E_LOOKUP_ID_FROM_NUM_FUNCTION_NAME(name) e_lookup_id_from_num_##name +#define E_LOOKUP_ID_FROM_NUM_FUNCTION_DEF(name) internal E_LOOKUP_ID_FROM_NUM_FUNCTION_SIG(E_LOOKUP_ID_FROM_NUM_FUNCTION_NAME(name)) +typedef E_LOOKUP_ID_FROM_NUM_FUNCTION_SIG(E_LookupIDFromNumFunctionType); +E_LOOKUP_ID_FROM_NUM_FUNCTION_DEF(default); + +#define E_LOOKUP_NUM_FROM_ID_FUNCTION_SIG(name) U64 name(U64 id, void *user_data) +#define E_LOOKUP_NUM_FROM_ID_FUNCTION_NAME(name) e_lookup_num_from_id_##name +#define E_LOOKUP_NUM_FROM_ID_FUNCTION_DEF(name) internal E_LOOKUP_NUM_FROM_ID_FUNCTION_SIG(E_LOOKUP_NUM_FROM_ID_FUNCTION_NAME(name)) +typedef E_LOOKUP_NUM_FROM_ID_FUNCTION_SIG(E_LookupNumFromIDFunctionType); +E_LOOKUP_NUM_FROM_ID_FUNCTION_DEF(default); + +typedef struct E_LookupRule E_LookupRule; +struct E_LookupRule +{ + String8 name; + E_LookupInfoFunctionType *info; + E_LookupAccessFunctionType *access; + E_LookupRangeFunctionType *range; + E_LookupIDFromNumFunctionType *id_from_num; + E_LookupNumFromIDFunctionType *num_from_id; +}; + +typedef struct E_LookupRuleNode E_LookupRuleNode; +struct E_LookupRuleNode +{ + E_LookupRuleNode *next; + E_LookupRule v; +}; + +typedef struct E_LookupRuleSlot E_LookupRuleSlot; +struct E_LookupRuleSlot +{ + E_LookupRuleNode *first; + E_LookupRuleNode *last; +}; + +typedef struct E_LookupRuleMap E_LookupRuleMap; +struct E_LookupRuleMap +{ + E_LookupRuleSlot *slots; + U64 slots_count; +}; + +typedef struct E_LookupRuleTagPair E_LookupRuleTagPair; +struct E_LookupRuleTagPair +{ + E_LookupRule *rule; + E_Expr *tag; +}; + +//////////////////////////////// +//~ rjf: IR Generation Hooks + +#define E_IRGEN_FUNCTION_SIG(name) E_IRTreeAndType name(Arena *arena, E_Expr *expr, E_Expr *tag) +#define E_IRGEN_FUNCTION_NAME(name) e_irgen_##name +#define E_IRGEN_FUNCTION_DEF(name) internal E_IRGEN_FUNCTION_SIG(E_IRGEN_FUNCTION_NAME(name)) +typedef E_IRGEN_FUNCTION_SIG(E_IRGenFunctionType); +E_IRGEN_FUNCTION_DEF(default); + +typedef struct E_IRGenRule E_IRGenRule; +struct E_IRGenRule +{ + String8 name; + E_IRGenFunctionType *irgen; +}; + +typedef struct E_IRGenRuleNode E_IRGenRuleNode; +struct E_IRGenRuleNode +{ + E_IRGenRuleNode *next; + E_IRGenRule v; +}; + +typedef struct E_IRGenRuleSlot E_IRGenRuleSlot; +struct E_IRGenRuleSlot +{ + E_IRGenRuleNode *first; + E_IRGenRuleNode *last; +}; + +typedef struct E_IRGenRuleMap E_IRGenRuleMap; +struct E_IRGenRuleMap +{ + U64 slots_count; + E_IRGenRuleSlot *slots; +}; + +//////////////////////////////// +//~ rjf: Type Pattern -> Hook Key Data Structure (Auto View Rules) + +typedef struct E_AutoHookNode E_AutoHookNode; +struct E_AutoHookNode +{ + E_AutoHookNode *hash_next; + E_AutoHookNode *pattern_order_next; + String8 type_string; + String8List type_pattern_parts; + E_ExprChain tag_exprs; +}; + +typedef struct E_AutoHookSlot E_AutoHookSlot; +struct E_AutoHookSlot +{ + E_AutoHookNode *first; + E_AutoHookNode *last; +}; + +typedef struct E_AutoHookMap E_AutoHookMap; +struct E_AutoHookMap +{ + U64 slots_count; + E_AutoHookSlot *slots; + E_AutoHookNode *first_pattern; + E_AutoHookNode *last_pattern; +}; + +typedef struct E_AutoHookParams E_AutoHookParams; +struct E_AutoHookParams +{ + E_TypeKey type_key; + String8 type_pattern; + String8 tag_expr_string; +}; + +//////////////////////////////// +//~ rjf: Contextual & Implicit Evaluation Parameters + +typedef B32 E_SpaceRWFunction(void *user_data, E_Space space, void *out, Rng1U64 offset_range); + //////////////////////////////// //~ rjf: Generated Code diff --git a/src/eval/eval_interpret.h b/src/eval/eval_interpret.h index 8d1c1449..cfebe221 100644 --- a/src/eval/eval_interpret.h +++ b/src/eval/eval_interpret.h @@ -18,8 +18,6 @@ struct E_Interpretation //////////////////////////////// //~ rjf: Interpretation Context -typedef B32 E_SpaceRWFunction(void *user_data, E_Space space, void *out, Rng1U64 offset_range); - typedef struct E_InterpretCtx E_InterpretCtx; struct E_InterpretCtx { diff --git a/src/eval/eval_ir.h b/src/eval/eval_ir.h index a11f7e87..b23023bc 100644 --- a/src/eval/eval_ir.h +++ b/src/eval/eval_ir.h @@ -32,191 +32,6 @@ struct E_OpList U64 encoded_size; }; -//////////////////////////////// -//~ rjf: IR Tree Types - -typedef struct E_IRNode E_IRNode; -struct E_IRNode -{ - E_IRNode *first; - E_IRNode *last; - E_IRNode *next; - RDI_EvalOp op; - E_Space space; - String8 string; - E_Value value; -}; - -typedef struct E_IRTreeAndType E_IRTreeAndType; -struct E_IRTreeAndType -{ - E_IRNode *root; - E_TypeKey type_key; - E_Member member; - E_Mode mode; - E_MsgList msgs; -}; - -//////////////////////////////// -//~ rjf: Member/Index Lookup Hooks - -typedef struct E_LookupInfo E_LookupInfo; -struct E_LookupInfo -{ - void *user_data; - U64 named_expr_count; - U64 idxed_expr_count; -}; - -typedef struct E_LookupAccess E_LookupAccess; -struct E_LookupAccess -{ - E_IRTreeAndType irtree_and_type; -}; - -#define E_LOOKUP_INFO_FUNCTION_SIG(name) E_LookupInfo name(Arena *arena, E_IRTreeAndType *lhs, E_Expr *tag, String8 filter) -#define E_LOOKUP_INFO_FUNCTION_NAME(name) e_lookup_info_##name -#define E_LOOKUP_INFO_FUNCTION_DEF(name) internal E_LOOKUP_INFO_FUNCTION_SIG(E_LOOKUP_INFO_FUNCTION_NAME(name)) -typedef E_LOOKUP_INFO_FUNCTION_SIG(E_LookupInfoFunctionType); -E_LOOKUP_INFO_FUNCTION_DEF(default); - -#define E_LOOKUP_ACCESS_FUNCTION_SIG(name) E_LookupAccess name(Arena *arena, E_ExprKind kind, E_Expr *lhs, E_Expr *rhs, E_Expr *tag, void *user_data) -#define E_LOOKUP_ACCESS_FUNCTION_NAME(name) e_lookup_access_##name -#define E_LOOKUP_ACCESS_FUNCTION_DEF(name) internal E_LOOKUP_ACCESS_FUNCTION_SIG(E_LOOKUP_ACCESS_FUNCTION_NAME(name)) -typedef E_LOOKUP_ACCESS_FUNCTION_SIG(E_LookupAccessFunctionType); -E_LOOKUP_ACCESS_FUNCTION_DEF(default); - -#define E_LOOKUP_RANGE_FUNCTION_SIG(name) void name(Arena *arena, E_Expr *lhs, E_Expr *tag, String8 filter, Rng1U64 idx_range, E_Expr **exprs, String8 *exprs_strings, void *user_data) -#define E_LOOKUP_RANGE_FUNCTION_NAME(name) e_lookup_range_##name -#define E_LOOKUP_RANGE_FUNCTION_DEF(name) internal E_LOOKUP_RANGE_FUNCTION_SIG(E_LOOKUP_RANGE_FUNCTION_NAME(name)) -typedef E_LOOKUP_RANGE_FUNCTION_SIG(E_LookupRangeFunctionType); -E_LOOKUP_RANGE_FUNCTION_DEF(default); - -#define E_LOOKUP_ID_FROM_NUM_FUNCTION_SIG(name) U64 name(U64 num, void *user_data) -#define E_LOOKUP_ID_FROM_NUM_FUNCTION_NAME(name) e_lookup_id_from_num_##name -#define E_LOOKUP_ID_FROM_NUM_FUNCTION_DEF(name) internal E_LOOKUP_ID_FROM_NUM_FUNCTION_SIG(E_LOOKUP_ID_FROM_NUM_FUNCTION_NAME(name)) -typedef E_LOOKUP_ID_FROM_NUM_FUNCTION_SIG(E_LookupIDFromNumFunctionType); -E_LOOKUP_ID_FROM_NUM_FUNCTION_DEF(default); - -#define E_LOOKUP_NUM_FROM_ID_FUNCTION_SIG(name) U64 name(U64 id, void *user_data) -#define E_LOOKUP_NUM_FROM_ID_FUNCTION_NAME(name) e_lookup_num_from_id_##name -#define E_LOOKUP_NUM_FROM_ID_FUNCTION_DEF(name) internal E_LOOKUP_NUM_FROM_ID_FUNCTION_SIG(E_LOOKUP_NUM_FROM_ID_FUNCTION_NAME(name)) -typedef E_LOOKUP_NUM_FROM_ID_FUNCTION_SIG(E_LookupNumFromIDFunctionType); -E_LOOKUP_NUM_FROM_ID_FUNCTION_DEF(default); - -typedef struct E_LookupRule E_LookupRule; -struct E_LookupRule -{ - String8 name; - E_LookupInfoFunctionType *info; - E_LookupAccessFunctionType *access; - E_LookupRangeFunctionType *range; - E_LookupIDFromNumFunctionType *id_from_num; - E_LookupNumFromIDFunctionType *num_from_id; -}; - -typedef struct E_LookupRuleNode E_LookupRuleNode; -struct E_LookupRuleNode -{ - E_LookupRuleNode *next; - E_LookupRule v; -}; - -typedef struct E_LookupRuleSlot E_LookupRuleSlot; -struct E_LookupRuleSlot -{ - E_LookupRuleNode *first; - E_LookupRuleNode *last; -}; - -typedef struct E_LookupRuleMap E_LookupRuleMap; -struct E_LookupRuleMap -{ - E_LookupRuleSlot *slots; - U64 slots_count; -}; - -typedef struct E_LookupRuleTagPair E_LookupRuleTagPair; -struct E_LookupRuleTagPair -{ - E_LookupRule *rule; - E_Expr *tag; -}; - -//////////////////////////////// -//~ rjf: IR Generation Hooks - -#define E_IRGEN_FUNCTION_SIG(name) E_IRTreeAndType name(Arena *arena, E_Expr *expr, E_Expr *tag) -#define E_IRGEN_FUNCTION_NAME(name) e_irgen_##name -#define E_IRGEN_FUNCTION_DEF(name) internal E_IRGEN_FUNCTION_SIG(E_IRGEN_FUNCTION_NAME(name)) -typedef E_IRGEN_FUNCTION_SIG(E_IRGenFunctionType); -E_IRGEN_FUNCTION_DEF(default); - -typedef struct E_IRGenRule E_IRGenRule; -struct E_IRGenRule -{ - String8 name; - E_IRGenFunctionType *irgen; -}; - -typedef struct E_IRGenRuleNode E_IRGenRuleNode; -struct E_IRGenRuleNode -{ - E_IRGenRuleNode *next; - E_IRGenRule v; -}; - -typedef struct E_IRGenRuleSlot E_IRGenRuleSlot; -struct E_IRGenRuleSlot -{ - E_IRGenRuleNode *first; - E_IRGenRuleNode *last; -}; - -typedef struct E_IRGenRuleMap E_IRGenRuleMap; -struct E_IRGenRuleMap -{ - U64 slots_count; - E_IRGenRuleSlot *slots; -}; - -//////////////////////////////// -//~ rjf: Type Pattern -> Hook Key Data Structure (Auto View Rules) - -typedef struct E_AutoHookNode E_AutoHookNode; -struct E_AutoHookNode -{ - E_AutoHookNode *hash_next; - E_AutoHookNode *pattern_order_next; - String8 type_string; - String8List type_pattern_parts; - E_ExprChain tag_exprs; -}; - -typedef struct E_AutoHookSlot E_AutoHookSlot; -struct E_AutoHookSlot -{ - E_AutoHookNode *first; - E_AutoHookNode *last; -}; - -typedef struct E_AutoHookMap E_AutoHookMap; -struct E_AutoHookMap -{ - U64 slots_count; - E_AutoHookSlot *slots; - E_AutoHookNode *first_pattern; - E_AutoHookNode *last_pattern; -}; - -typedef struct E_AutoHookParams E_AutoHookParams; -struct E_AutoHookParams -{ - E_TypeKey type_key; - String8 type_pattern; - String8 tag_expr_string; -}; - //////////////////////////////// //~ rjf: Used Tag Map Data Structure diff --git a/src/eval/eval_parse.h b/src/eval/eval_parse.h index 39e9c716..cd34d618 100644 --- a/src/eval/eval_parse.h +++ b/src/eval/eval_parse.h @@ -4,155 +4,6 @@ #ifndef EVAL_PARSE_H #define EVAL_PARSE_H -//////////////////////////////// -//~ rjf: Generated Code - -#include "generated/eval.meta.h" - -//////////////////////////////// -//~ rjf: Token Types - -typedef struct E_Token E_Token; -struct E_Token -{ - E_TokenKind kind; - Rng1U64 range; -}; - -typedef struct E_TokenChunkNode E_TokenChunkNode; -struct E_TokenChunkNode -{ - E_TokenChunkNode *next; - E_Token *v; - U64 count; - U64 cap; -}; - -typedef struct E_TokenChunkList E_TokenChunkList; -struct E_TokenChunkList -{ - E_TokenChunkNode *first; - E_TokenChunkNode *last; - U64 node_count; - U64 total_count; -}; - -typedef struct E_TokenArray E_TokenArray; -struct E_TokenArray -{ - E_Token *v; - U64 count; -}; - -//////////////////////////////// -//~ rjf: Expression Tree Types - -typedef struct E_Expr E_Expr; -struct E_Expr -{ - E_Expr *first; - E_Expr *last; - E_Expr *first_tag; - E_Expr *last_tag; - E_Expr *next; - E_Expr *prev; - E_Expr *ref; - void *location; - E_ExprKind kind; - E_Mode mode; - E_Space space; - E_TypeKey type_key; - E_Value value; - String8 string; - String8 qualifier; - String8 bytecode; -}; - -typedef struct E_ExprChain E_ExprChain; -struct E_ExprChain -{ - E_Expr *first; - E_Expr *last; -}; - -typedef struct E_ExprNode E_ExprNode; -struct E_ExprNode -{ - E_ExprNode *next; - E_Expr *v; -}; - -typedef struct E_ExprList E_ExprList; -struct E_ExprList -{ - E_ExprNode *first; - E_ExprNode *last; - U64 count; -}; - -//////////////////////////////// -//~ rjf: Map Types - -//- rjf: string -> num - -typedef struct E_String2NumMapNode E_String2NumMapNode; -struct E_String2NumMapNode -{ - E_String2NumMapNode *order_next; - E_String2NumMapNode *hash_next; - String8 string; - U64 num; -}; - -typedef struct E_String2NumMapNodeArray E_String2NumMapNodeArray; -struct E_String2NumMapNodeArray -{ - E_String2NumMapNode **v; - U64 count; -}; - -typedef struct E_String2NumMapSlot E_String2NumMapSlot; -struct E_String2NumMapSlot -{ - E_String2NumMapNode *first; - E_String2NumMapNode *last; -}; - -typedef struct E_String2NumMap E_String2NumMap; -struct E_String2NumMap -{ - U64 slots_count; - U64 node_count; - E_String2NumMapSlot *slots; - E_String2NumMapNode *first; - E_String2NumMapNode *last; -}; - -//- rjf: string -> expr - -typedef struct E_String2ExprMapNode E_String2ExprMapNode; -struct E_String2ExprMapNode -{ - E_String2ExprMapNode *hash_next; - String8 string; - E_Expr *expr; - U64 poison_count; -}; - -typedef struct E_String2ExprMapSlot E_String2ExprMapSlot; -struct E_String2ExprMapSlot -{ - E_String2ExprMapNode *first; - E_String2ExprMapNode *last; -}; - -typedef struct E_String2ExprMap E_String2ExprMap; -struct E_String2ExprMap -{ - U64 slots_count; - E_String2ExprMapSlot *slots; -}; - //////////////////////////////// //~ rjf: Parse Results diff --git a/src/eval/eval_types.c b/src/eval/eval_types.c index c2822449..0565f4c7 100644 --- a/src/eval/eval_types.c +++ b/src/eval/eval_types.c @@ -225,12 +225,6 @@ e_member_array_from_list(Arena *arena, E_MemberList *list) //////////////////////////////// //~ rjf: Context Selection Functions (Selection Required For All Subsequent APIs) -internal E_TypeCtx * -e_selected_type_ctx(void) -{ - return e_type_state->ctx; -} - internal void e_select_type_ctx(E_TypeCtx *ctx) { @@ -605,8 +599,8 @@ e_type_from_key(Arena *arena, E_TypeKey key) { type = push_array(arena, E_Type, 1); type->kind = kind; - type->name = e_kind_basic_string_table[kind]; - type->byte_size = e_kind_basic_byte_size_table[kind]; + type->name = e_type_kind_basic_string_table[kind]; + type->byte_size = e_type_kind_basic_byte_size_table[kind]; } }break; @@ -1159,7 +1153,7 @@ e_type_byte_size_from_key(E_TypeKey key) case E_TypeKeyKind_Basic: { E_TypeKind kind = (E_TypeKind)key.u32[0]; - result = e_kind_basic_byte_size_table[kind]; + result = e_type_kind_basic_byte_size_table[kind]; }break; case E_TypeKeyKind_Ext: { diff --git a/src/eval/eval_types.h b/src/eval/eval_types.h index e106fd52..1801164b 100644 --- a/src/eval/eval_types.h +++ b/src/eval/eval_types.h @@ -4,142 +4,6 @@ #ifndef EVAL_TYPES_H #define EVAL_TYPES_H -//////////////////////////////// -//~ rjf: Implicit Type Graph Key Types - -typedef enum E_TypeKeyKind -{ - E_TypeKeyKind_Null, - E_TypeKeyKind_Basic, - E_TypeKeyKind_Ext, - E_TypeKeyKind_Cons, - E_TypeKeyKind_Reg, - E_TypeKeyKind_RegAlias, -} -E_TypeKeyKind; - -typedef struct E_TypeKey E_TypeKey; -struct E_TypeKey -{ - E_TypeKeyKind kind; - U32 u32[3]; - // [0] -> E_TypeKind (Basic, Cons, Ext); Arch (Reg, RegAlias) - // [1] -> Type Index In RDI (Ext); Code (Reg, RegAlias); Type Index In Constructed (Cons) - // [2] -> RDI Index (Ext) -}; - -typedef struct E_TypeKeyNode E_TypeKeyNode; -struct E_TypeKeyNode -{ - E_TypeKeyNode *next; - E_TypeKey v; -}; - -typedef struct E_TypeKeyList E_TypeKeyList; -struct E_TypeKeyList -{ - E_TypeKeyNode *first; - E_TypeKeyNode *last; - U64 count; -}; - -//////////////////////////////// -//~ rjf: Full Extracted Type Information Types - -typedef enum E_MemberKind -{ - E_MemberKind_Null, - E_MemberKind_DataField, - E_MemberKind_StaticData, - E_MemberKind_Method, - E_MemberKind_StaticMethod, - E_MemberKind_VirtualMethod, - E_MemberKind_VTablePtr, - E_MemberKind_Base, - E_MemberKind_VirtualBase, - E_MemberKind_NestedType, - E_MemberKind_Padding, - E_MemberKind_Query, - E_MemberKind_COUNT -} -E_MemberKind; - -typedef U32 E_TypeFlags; -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), -}; - -typedef struct E_Member E_Member; -struct E_Member -{ - E_MemberKind kind; - E_TypeKey type_key; - String8 name; - U64 off; - E_TypeKeyList inheritance_key_chain; -}; - -typedef struct E_MemberNode E_MemberNode; -struct E_MemberNode -{ - E_MemberNode *next; - E_Member v; -}; - -typedef struct E_MemberList E_MemberList; -struct E_MemberList -{ - E_MemberNode *first; - E_MemberNode *last; - U64 count; -}; - -typedef struct E_MemberArray E_MemberArray; -struct E_MemberArray -{ - E_Member *v; - U64 count; -}; - -typedef struct E_EnumVal E_EnumVal; -struct E_EnumVal -{ - String8 name; - U64 val; -}; - -typedef struct E_EnumValArray E_EnumValArray; -struct E_EnumValArray -{ - E_EnumVal *v; - U64 count; -}; - -typedef struct E_Type E_Type; -struct E_Type -{ - E_TypeKind kind; - E_TypeFlags flags; - String8 name; - U64 byte_size; - U64 count; - U64 depth; - U32 off; - Arch arch; - E_TypeKey direct_type_key; - E_TypeKey owner_type_key; - E_TypeKey *param_type_keys; - E_Member *members; - E_EnumVal *enum_vals; -}; - //////////////////////////////// //~ rjf: String -> Type Key Map Data Structure @@ -339,7 +203,6 @@ internal E_MemberArray e_member_array_from_list(Arena *arena, E_MemberList *list //////////////////////////////// //~ rjf: Context Selection Functions (Selection Required For All Subsequent APIs) -internal E_TypeCtx *e_selected_type_ctx(void); internal void e_select_type_ctx(E_TypeCtx *ctx); //////////////////////////////// diff --git a/src/eval/generated/eval.meta.c b/src/eval/generated/eval.meta.c index 48dd90f6..50b115ba 100644 --- a/src/eval/generated/eval.meta.c +++ b/src/eval/generated/eval.meta.c @@ -14,192 +14,7 @@ str8_lit_comp("CharLiteral"), str8_lit_comp("Symbol"), }; -String8 e_expr_kind_strings[51] = -{ -str8_lit_comp("Nil"), -str8_lit_comp("Ref"), -str8_lit_comp("ArrayIndex"), -str8_lit_comp("MemberAccess"), -str8_lit_comp("Deref"), -str8_lit_comp("Address"), -str8_lit_comp("Cast"), -str8_lit_comp("Sizeof"), -str8_lit_comp("Typeof"), -str8_lit_comp("ByteSwap"), -str8_lit_comp("Pos"), -str8_lit_comp("Neg"), -str8_lit_comp("LogNot"), -str8_lit_comp("BitNot"), -str8_lit_comp("Mul"), -str8_lit_comp("Div"), -str8_lit_comp("Mod"), -str8_lit_comp("Add"), -str8_lit_comp("Sub"), -str8_lit_comp("LShift"), -str8_lit_comp("RShift"), -str8_lit_comp("Less"), -str8_lit_comp("LsEq"), -str8_lit_comp("Grtr"), -str8_lit_comp("GrEq"), -str8_lit_comp("EqEq"), -str8_lit_comp("NtEq"), -str8_lit_comp("BitAnd"), -str8_lit_comp("BitXor"), -str8_lit_comp("BitOr"), -str8_lit_comp("LogAnd"), -str8_lit_comp("LogOr"), -str8_lit_comp("Ternary"), -str8_lit_comp("Call"), -str8_lit_comp("LeafBytecode"), -str8_lit_comp("LeafMember"), -str8_lit_comp("LeafStringLiteral"), -str8_lit_comp("LeafBool"), -str8_lit_comp("LeafU64"), -str8_lit_comp("LeafF64"), -str8_lit_comp("LeafF32"), -str8_lit_comp("LeafIdentifier"), -str8_lit_comp("LeafOffset"), -str8_lit_comp("LeafValue"), -str8_lit_comp("LeafFilePath"), -str8_lit_comp("TypeIdent"), -str8_lit_comp("Ptr"), -str8_lit_comp("Array"), -str8_lit_comp("Func"), -str8_lit_comp("Define"), -str8_lit_comp("Tag"), -}; - -String8 e_interpretation_code_display_strings[11] = -{ -str8_lit_comp(""), -str8_lit_comp("Cannot divide by zero."), -str8_lit_comp("Invalid operation."), -str8_lit_comp("Invalid operation types."), -str8_lit_comp("Failed memory read."), -str8_lit_comp("Failed register read."), -str8_lit_comp("Invalid frame base address."), -str8_lit_comp("Invalid module base address."), -str8_lit_comp("Invalid thread-local storage base address."), -str8_lit_comp("Insufficient evaluation machine stack space."), -str8_lit_comp("Malformed bytecode."), -}; - -E_OpInfo e_expr_kind_op_info_table[51] = -{ -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp("["), str8_lit_comp("]") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp("."), str8_lit_comp("") }, -{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("*"), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("&"), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 1, str8_lit_comp("("), str8_lit_comp(")"), str8_lit_comp("") }, -{ E_OpKind_UnaryPrefix, 1, str8_lit_comp("sizeof"), str8_lit_comp("("), str8_lit_comp(")") }, -{ E_OpKind_UnaryPrefix, 1, str8_lit_comp("typeof"), str8_lit_comp("("), str8_lit_comp(")") }, -{ E_OpKind_UnaryPrefix, 1, str8_lit_comp("bswap"), str8_lit_comp("("), str8_lit_comp(")") }, -{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("+"), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("-"), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("!"), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("~"), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Binary, 3, str8_lit_comp(""), str8_lit_comp("*"), str8_lit_comp("") }, -{ E_OpKind_Binary, 3, str8_lit_comp(""), str8_lit_comp("/"), str8_lit_comp("") }, -{ E_OpKind_Binary, 3, str8_lit_comp(""), str8_lit_comp("%"), str8_lit_comp("") }, -{ E_OpKind_Binary, 4, str8_lit_comp(""), str8_lit_comp("+"), str8_lit_comp("") }, -{ E_OpKind_Binary, 4, str8_lit_comp(""), str8_lit_comp("-"), str8_lit_comp("") }, -{ E_OpKind_Binary, 5, str8_lit_comp(""), str8_lit_comp("<<"), str8_lit_comp("") }, -{ E_OpKind_Binary, 5, str8_lit_comp(""), str8_lit_comp(">>"), str8_lit_comp("") }, -{ E_OpKind_Binary, 6, str8_lit_comp(""), str8_lit_comp("<"), str8_lit_comp("") }, -{ E_OpKind_Binary, 6, str8_lit_comp(""), str8_lit_comp("<="), str8_lit_comp("") }, -{ E_OpKind_Binary, 6, str8_lit_comp(""), str8_lit_comp(">"), str8_lit_comp("") }, -{ E_OpKind_Binary, 6, str8_lit_comp(""), str8_lit_comp(">="), str8_lit_comp("") }, -{ E_OpKind_Binary, 7, str8_lit_comp(""), str8_lit_comp("=="), str8_lit_comp("") }, -{ E_OpKind_Binary, 7, str8_lit_comp(""), str8_lit_comp("!="), str8_lit_comp("") }, -{ E_OpKind_Binary, 8, str8_lit_comp(""), str8_lit_comp("&"), str8_lit_comp("") }, -{ E_OpKind_Binary, 9, str8_lit_comp(""), str8_lit_comp("^"), str8_lit_comp("") }, -{ E_OpKind_Binary, 10, str8_lit_comp(""), str8_lit_comp("|"), str8_lit_comp("") }, -{ E_OpKind_Binary, 11, str8_lit_comp(""), str8_lit_comp("&&"), str8_lit_comp("") }, -{ E_OpKind_Binary, 12, str8_lit_comp(""), str8_lit_comp("||"), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp("?"), str8_lit_comp(":") }, -{ E_OpKind_Null, 0, str8_lit_comp("("), str8_lit_comp(","), str8_lit_comp(")") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, -{ E_OpKind_Binary, 13, str8_lit_comp(""), str8_lit_comp("="), str8_lit_comp("") }, -{ E_OpKind_Null, 0, str8_lit_comp("=>"), str8_lit_comp(","), str8_lit_comp("") }, -}; - -U8 e_kind_basic_byte_size_table[56] = -{ -0, -0, -0xFF, -4, -1, -2, -4, -1, -2, -4, -1, -2, -4, -8, -16, -32, -64, -1, -2, -4, -8, -16, -32, -64, -1, -2, -4, -4, -6, -8, -10, -16, -8, -16, -20, -32, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -}; - -String8 e_kind_basic_string_table[56] = +String8 e_type_kind_basic_string_table[56] = { str8_lit_comp(""), str8_lit_comp("void"), @@ -259,5 +74,190 @@ str8_lit_comp("variadic"), str8_lit_comp("set"), }; +U8 e_type_kind_basic_byte_size_table[56] = +{ +0, +0, +0xFF, +4, +1, +2, +4, +1, +2, +4, +1, +2, +4, +8, +16, +32, +64, +1, +2, +4, +8, +16, +32, +64, +1, +2, +4, +4, +6, +8, +10, +16, +8, +16, +20, +32, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +}; + +String8 e_expr_kind_strings[51] = +{ +str8_lit_comp("Nil"), +str8_lit_comp("Ref"), +str8_lit_comp("ArrayIndex"), +str8_lit_comp("MemberAccess"), +str8_lit_comp("Deref"), +str8_lit_comp("Address"), +str8_lit_comp("Cast"), +str8_lit_comp("Sizeof"), +str8_lit_comp("Typeof"), +str8_lit_comp("ByteSwap"), +str8_lit_comp("Pos"), +str8_lit_comp("Neg"), +str8_lit_comp("LogNot"), +str8_lit_comp("BitNot"), +str8_lit_comp("Mul"), +str8_lit_comp("Div"), +str8_lit_comp("Mod"), +str8_lit_comp("Add"), +str8_lit_comp("Sub"), +str8_lit_comp("LShift"), +str8_lit_comp("RShift"), +str8_lit_comp("Less"), +str8_lit_comp("LsEq"), +str8_lit_comp("Grtr"), +str8_lit_comp("GrEq"), +str8_lit_comp("EqEq"), +str8_lit_comp("NtEq"), +str8_lit_comp("BitAnd"), +str8_lit_comp("BitXor"), +str8_lit_comp("BitOr"), +str8_lit_comp("LogAnd"), +str8_lit_comp("LogOr"), +str8_lit_comp("Ternary"), +str8_lit_comp("Call"), +str8_lit_comp("LeafBytecode"), +str8_lit_comp("LeafMember"), +str8_lit_comp("LeafStringLiteral"), +str8_lit_comp("LeafBool"), +str8_lit_comp("LeafU64"), +str8_lit_comp("LeafF64"), +str8_lit_comp("LeafF32"), +str8_lit_comp("LeafIdentifier"), +str8_lit_comp("LeafOffset"), +str8_lit_comp("LeafValue"), +str8_lit_comp("LeafFilePath"), +str8_lit_comp("TypeIdent"), +str8_lit_comp("Ptr"), +str8_lit_comp("Array"), +str8_lit_comp("Func"), +str8_lit_comp("Define"), +str8_lit_comp("Tag"), +}; + +E_OpInfo e_expr_kind_op_info_table[51] = +{ +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp("["), str8_lit_comp("]") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp("."), str8_lit_comp("") }, +{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("*"), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("&"), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 1, str8_lit_comp("("), str8_lit_comp(")"), str8_lit_comp("") }, +{ E_OpKind_UnaryPrefix, 1, str8_lit_comp("sizeof"), str8_lit_comp("("), str8_lit_comp(")") }, +{ E_OpKind_UnaryPrefix, 1, str8_lit_comp("typeof"), str8_lit_comp("("), str8_lit_comp(")") }, +{ E_OpKind_UnaryPrefix, 1, str8_lit_comp("bswap"), str8_lit_comp("("), str8_lit_comp(")") }, +{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("+"), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("-"), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("!"), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("~"), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Binary, 3, str8_lit_comp(""), str8_lit_comp("*"), str8_lit_comp("") }, +{ E_OpKind_Binary, 3, str8_lit_comp(""), str8_lit_comp("/"), str8_lit_comp("") }, +{ E_OpKind_Binary, 3, str8_lit_comp(""), str8_lit_comp("%"), str8_lit_comp("") }, +{ E_OpKind_Binary, 4, str8_lit_comp(""), str8_lit_comp("+"), str8_lit_comp("") }, +{ E_OpKind_Binary, 4, str8_lit_comp(""), str8_lit_comp("-"), str8_lit_comp("") }, +{ E_OpKind_Binary, 5, str8_lit_comp(""), str8_lit_comp("<<"), str8_lit_comp("") }, +{ E_OpKind_Binary, 5, str8_lit_comp(""), str8_lit_comp(">>"), str8_lit_comp("") }, +{ E_OpKind_Binary, 6, str8_lit_comp(""), str8_lit_comp("<"), str8_lit_comp("") }, +{ E_OpKind_Binary, 6, str8_lit_comp(""), str8_lit_comp("<="), str8_lit_comp("") }, +{ E_OpKind_Binary, 6, str8_lit_comp(""), str8_lit_comp(">"), str8_lit_comp("") }, +{ E_OpKind_Binary, 6, str8_lit_comp(""), str8_lit_comp(">="), str8_lit_comp("") }, +{ E_OpKind_Binary, 7, str8_lit_comp(""), str8_lit_comp("=="), str8_lit_comp("") }, +{ E_OpKind_Binary, 7, str8_lit_comp(""), str8_lit_comp("!="), str8_lit_comp("") }, +{ E_OpKind_Binary, 8, str8_lit_comp(""), str8_lit_comp("&"), str8_lit_comp("") }, +{ E_OpKind_Binary, 9, str8_lit_comp(""), str8_lit_comp("^"), str8_lit_comp("") }, +{ E_OpKind_Binary, 10, str8_lit_comp(""), str8_lit_comp("|"), str8_lit_comp("") }, +{ E_OpKind_Binary, 11, str8_lit_comp(""), str8_lit_comp("&&"), str8_lit_comp("") }, +{ E_OpKind_Binary, 12, str8_lit_comp(""), str8_lit_comp("||"), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp("?"), str8_lit_comp(":") }, +{ E_OpKind_Null, 0, str8_lit_comp("("), str8_lit_comp(","), str8_lit_comp(")") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") }, +{ E_OpKind_Binary, 13, str8_lit_comp(""), str8_lit_comp("="), str8_lit_comp("") }, +{ E_OpKind_Null, 0, str8_lit_comp("=>"), str8_lit_comp(","), str8_lit_comp("") }, +}; + +String8 e_interpretation_code_display_strings[11] = +{ +str8_lit_comp(""), +str8_lit_comp("Cannot divide by zero."), +str8_lit_comp("Invalid operation."), +str8_lit_comp("Invalid operation types."), +str8_lit_comp("Failed memory read."), +str8_lit_comp("Failed register read."), +str8_lit_comp("Invalid frame base address."), +str8_lit_comp("Invalid module base address."), +str8_lit_comp("Invalid thread-local storage base address."), +str8_lit_comp("Insufficient evaluation machine stack space."), +str8_lit_comp("Malformed bytecode."), +}; + C_LINKAGE_END diff --git a/src/eval/generated/eval.meta.h b/src/eval/generated/eval.meta.h index 2bbf680a..5bb4994c 100644 --- a/src/eval/generated/eval.meta.h +++ b/src/eval/generated/eval.meta.h @@ -163,11 +163,11 @@ E_InterpretationCode_COUNT, C_LINKAGE_BEGIN extern String8 e_token_kind_strings[6]; +extern String8 e_type_kind_basic_string_table[56]; +extern U8 e_type_kind_basic_byte_size_table[56]; extern String8 e_expr_kind_strings[51]; -extern String8 e_interpretation_code_display_strings[11]; extern E_OpInfo e_expr_kind_op_info_table[51]; -extern U8 e_kind_basic_byte_size_table[56]; -extern String8 e_kind_basic_string_table[56]; +extern String8 e_interpretation_code_display_strings[11]; C_LINKAGE_END diff --git a/src/scratch/eval_scratch.c b/src/scratch/eval_scratch.c index a0b8895e..b83d0d1c 100644 --- a/src/scratch/eval_scratch.c +++ b/src/scratch/eval_scratch.c @@ -113,7 +113,7 @@ entry_point(CmdLine *cmdline) indent += 1) { E_Type *type = e_type_from_key(arena, type_key); - raddbg_log("%.*s%S\n", (int)indent*4, indent_spaces, e_kind_basic_string_table[type->kind]); + raddbg_log("%.*s%S\n", (int)indent*4, indent_spaces, e_type_kind_basic_string_table[type->kind]); } }