mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-14 08:02:23 -07:00
multi-module eval: type graph; eval parser
This commit is contained in:
+2932
File diff suppressed because it is too large
Load Diff
+259
-11
@@ -4,6 +4,43 @@
|
||||
#ifndef EVAL_H
|
||||
#define EVAL_H
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Generated Code
|
||||
|
||||
#include "generated/eval2.meta.h"
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Messages
|
||||
|
||||
typedef enum E_MsgKind
|
||||
{
|
||||
E_MsgKind_Null,
|
||||
E_MsgKind_MalformedInput,
|
||||
E_MsgKind_MissingInfo,
|
||||
E_MsgKind_ResolutionFailure,
|
||||
E_MsgKind_InterpretationError,
|
||||
E_MsgKind_COUNT
|
||||
}
|
||||
E_MsgKind;
|
||||
|
||||
typedef struct E_Msg E_Msg;
|
||||
struct E_Msg
|
||||
{
|
||||
E_Msg *next;
|
||||
E_MsgKind kind;
|
||||
void *location;
|
||||
String8 text;
|
||||
};
|
||||
|
||||
typedef struct E_MsgList E_MsgList;
|
||||
struct E_MsgList
|
||||
{
|
||||
E_Msg *first;
|
||||
E_Msg *last;
|
||||
E_MsgKind max_kind;
|
||||
U64 count;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Token Types
|
||||
|
||||
@@ -75,6 +112,21 @@ struct E_TypeKey
|
||||
// [2] -> RDI Index (Cons, 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
|
||||
|
||||
@@ -179,13 +231,13 @@ E_Mode;
|
||||
typedef struct E_Expr E_Expr;
|
||||
struct E_Expr
|
||||
{
|
||||
E_ExprKind kind;
|
||||
E_Mode mode;
|
||||
void *location;
|
||||
E_TypeKey type_key;
|
||||
E_Expr *first;
|
||||
E_Expr *last;
|
||||
E_Expr *next;
|
||||
void *location;
|
||||
E_ExprKind kind;
|
||||
E_Mode mode;
|
||||
E_TypeKey type_key;
|
||||
U32 u32;
|
||||
F32 f32;
|
||||
U64 u64;
|
||||
@@ -199,12 +251,12 @@ struct E_Expr
|
||||
typedef struct E_IRNode E_IRNode;
|
||||
struct E_IRNode
|
||||
{
|
||||
RDI_EvalOp op;
|
||||
String8 bytecode;
|
||||
U64 u64;
|
||||
E_IRNode *first;
|
||||
E_IRNode *last;
|
||||
E_IRNode *next;
|
||||
RDI_EvalOp op;
|
||||
String8 bytecode;
|
||||
U64 u64;
|
||||
};
|
||||
|
||||
typedef struct E_IRTreeAndType E_IRTreeAndType;
|
||||
@@ -213,6 +265,58 @@ struct E_IRTreeAndType
|
||||
E_IRNode *root;
|
||||
E_TypeKey type_key;
|
||||
E_Mode mode;
|
||||
E_MsgList msgs;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Bytecode Operation Types
|
||||
|
||||
enum
|
||||
{
|
||||
E_IRExtKind_Bytecode = RDI_EvalOp_COUNT,
|
||||
E_IRExtKind_COUNT
|
||||
};
|
||||
|
||||
typedef struct E_Op E_Op;
|
||||
struct E_Op
|
||||
{
|
||||
E_Op *next;
|
||||
RDI_EvalOp opcode;
|
||||
union
|
||||
{
|
||||
U64 p;
|
||||
String8 bytecode;
|
||||
};
|
||||
};
|
||||
|
||||
typedef struct E_OpList E_OpList;
|
||||
struct E_OpList
|
||||
{
|
||||
E_Op *first;
|
||||
E_Op *last;
|
||||
U64 op_count;
|
||||
U64 encoded_size;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Evaluation Types
|
||||
|
||||
typedef union E_Value E_Value;
|
||||
union E_Value
|
||||
{
|
||||
U64 u256[4];
|
||||
U64 u128[2];
|
||||
U64 u64;
|
||||
S64 s64;
|
||||
F64 f64;
|
||||
F32 f32;
|
||||
};
|
||||
|
||||
typedef struct E_Result E_Result;
|
||||
struct E_Result
|
||||
{
|
||||
E_Value value;
|
||||
E_ResultCode code;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
@@ -298,25 +402,27 @@ struct E_ConsTypeSlot
|
||||
E_ConsTypeNode *last;
|
||||
};
|
||||
|
||||
typedef B32 E_MemoryReadFunction(void *user_data, void *out, Rng1U64 vaddr_range);
|
||||
|
||||
typedef struct E_Ctx E_Ctx;
|
||||
struct E_Ctx
|
||||
{
|
||||
// rjf: architecture
|
||||
Architecture arch;
|
||||
|
||||
// rjf: evaluation instruction pointer address (selects from `rdis`, and within them)
|
||||
// rjf: instruction pointer info
|
||||
U64 ip_vaddr;
|
||||
U64 ip_voff; // (within module, which uses `rdis[0]` for debug info)
|
||||
|
||||
// rjf: debug info
|
||||
RDI_Parsed **rdis;
|
||||
Rng1U64 *rdis_vaddr_ranges;
|
||||
U64 rdis_count;
|
||||
|
||||
// rjf: identifier resolution maps
|
||||
E_String2NumMap *regs_map;
|
||||
E_String2NumMap *reg_alias_map;
|
||||
E_String2NumMap *locals_map;
|
||||
E_String2NumMap *member_map;
|
||||
E_String2NumMap *locals_map; // (within `rdis[0]`)
|
||||
E_String2NumMap *member_map; // (within `rdis[0]`)
|
||||
E_String2ExprMap *macro_map;
|
||||
|
||||
// rjf: JIT-constructed types
|
||||
@@ -325,6 +431,148 @@ struct E_Ctx
|
||||
U64 cons_key_slots_count;
|
||||
E_ConsTypeSlot *cons_content_slots;
|
||||
E_ConsTypeSlot *cons_key_slots;
|
||||
|
||||
// rjf: interpretation environment info
|
||||
void *memory_read_user_data;
|
||||
E_MemoryReadFunction *memory_read;
|
||||
void *reg_data;
|
||||
U64 reg_size;
|
||||
U64 *module_base;
|
||||
U64 *frame_base;
|
||||
U64 *tls_base;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Parse Results
|
||||
|
||||
typedef struct E_Parse E_Parse;
|
||||
struct E_Parse
|
||||
{
|
||||
E_Token *last_token;
|
||||
E_Expr *expr;
|
||||
E_MsgList msgs;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Globals
|
||||
|
||||
global read_only E_Expr e_expr_nil = {&e_expr_nil, &e_expr_nil, &e_expr_nil};
|
||||
global read_only E_Type e_type_nil = {E_TypeKind_Null};
|
||||
global read_only E_IRNode e_irnode_nil = {&e_irnode_nil, &e_irnode_nil, &e_irnode_nil};
|
||||
thread_static E_Ctx *e_ctx = 0;
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Basic Helper Functions
|
||||
|
||||
internal U64 e_hash_from_string(String8 string);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Type Kind Enum Functions
|
||||
|
||||
internal E_TypeKind e_type_kind_from_rdi(RDI_TypeKind kind);
|
||||
internal E_MemberKind e_member_kind_from_rdi(RDI_MemberKind kind);
|
||||
internal RDI_EvalTypeGroup e_type_group_from_kind(E_TypeKind kind);
|
||||
internal B32 e_type_kind_is_integer(E_TypeKind kind);
|
||||
internal B32 e_type_kind_is_signed(E_TypeKind kind);
|
||||
internal B32 e_type_kind_is_basic_or_enum(E_TypeKind kind);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Message Functions
|
||||
|
||||
internal void e_msg(Arena *arena, E_MsgList *msgs, E_MsgKind kind, void *location, String8 text);
|
||||
internal void e_msgf(Arena *arena, E_MsgList *msgs, E_MsgKind kind, void *location, char *fmt, ...);
|
||||
internal void e_msg_list_concat_in_place(E_MsgList *dst, E_MsgList *to_push);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Basic Map Functions
|
||||
|
||||
//- rjf: string -> num
|
||||
internal E_String2NumMap e_string2num_map_make(Arena *arena, U64 slot_count);
|
||||
internal void e_string2num_map_insert(Arena *arena, E_String2NumMap *map, String8 string, U64 num);
|
||||
internal U64 e_num_from_string(E_String2NumMap *map, String8 string);
|
||||
internal E_String2NumMapNodeArray e_string2num_map_node_array_from_map(Arena *arena, E_String2NumMap *map);
|
||||
internal int e_string2num_map_node_qsort_compare__num_ascending(E_String2NumMapNode **a, E_String2NumMapNode **b);
|
||||
internal void e_string2num_map_node_array_sort__in_place(E_String2NumMapNodeArray *array);
|
||||
|
||||
//- rjf: string -> expr
|
||||
internal E_String2ExprMap e_string2expr_map_make(Arena *arena, U64 slot_count);
|
||||
internal void e_string2expr_map_insert(Arena *arena, E_String2ExprMap *map, String8 string, E_Expr *expr);
|
||||
internal void e_string2expr_map_inc_poison(E_String2ExprMap *map, String8 string);
|
||||
internal void e_string2expr_map_dec_poison(E_String2ExprMap *map, String8 string);
|
||||
internal E_Expr *e_expr_from_string(E_String2ExprMap *map, String8 string);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Debug-Info-Driven Map Building Functions
|
||||
|
||||
internal E_String2NumMap *e_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff);
|
||||
internal E_String2NumMap *e_push_member_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Context Selection Functions (Required For All Subsequent APIs)
|
||||
|
||||
internal void e_select_ctx(E_Ctx *ctx);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Tokenization Functions
|
||||
|
||||
#define e_token_at_it(it, arr) (((it) < (arr)->v+(arr)->count) ? (*(it)) : e_token_zero())
|
||||
internal E_Token e_token_zero(void);
|
||||
internal void e_token_chunk_list_push(Arena *arena, E_TokenChunkList *list, U64 chunk_size, E_Token *token);
|
||||
internal E_TokenArray e_token_array_from_chunk_list(Arena *arena, E_TokenChunkList *list);
|
||||
internal E_TokenArray e_token_array_from_text(Arena *arena, String8 text);
|
||||
internal E_TokenArray e_token_array_make_first_opl(E_Token *first, E_Token *opl);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Expression Tree Building Functions
|
||||
|
||||
internal E_Expr *e_push_expr(Arena *arena, E_ExprKind kind, void *location);
|
||||
internal void e_expr_push_child(E_Expr *parent, E_Expr *child);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Type Operation Functions
|
||||
|
||||
//- rjf: key constructors
|
||||
internal E_TypeKey e_type_key_zero(void);
|
||||
internal E_TypeKey e_type_key_basic(E_TypeKind kind);
|
||||
internal E_TypeKey e_type_key_ext(TG_Kind kind, U32 type_idx, U32 rdi_idx);
|
||||
internal E_TypeKey e_type_key_reg(Architecture arch, REGS_RegCode code);
|
||||
internal E_TypeKey e_type_key_reg_alias(Architecture arch, REGS_AliasCode code);
|
||||
internal E_TypeKey e_type_key_cons(E_TypeKind kind, E_TypeKey direct_key, U64 u64);
|
||||
|
||||
//- rjf: basic type key functions
|
||||
internal B32 e_type_key_match(E_TypeKey l, E_TypeKey r);
|
||||
|
||||
//- rjf: key -> info extraction
|
||||
internal E_TypeKind e_type_kind_from_key(E_TypeKey key);
|
||||
internal U64 e_type_byte_size_from_key(E_TypeKey key);
|
||||
internal E_Type *e_type_from_key(Arena *arena, E_TypeKey key);
|
||||
internal E_TypeKey e_type_direct_from_key(E_TypeKey key);
|
||||
internal E_TypeKey e_type_owner_from_key(E_TypeKey key);
|
||||
internal E_TypeKey e_type_unwrap_enum(E_TypeKey key);
|
||||
internal E_TypeKey e_type_unwrap(E_TypeKey key);
|
||||
internal E_TypeKey e_type_promote(E_TypeKey key);
|
||||
internal B32 e_type_match(E_TypeKey l, E_TypeKey r);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Parsing Functions
|
||||
|
||||
internal E_TypeKey e_leaf_type_from_name(String8 name);
|
||||
internal E_Parse e_parse_type_from_text_tokens(Arena *arena, String8 text, E_TokenArray *tokens);
|
||||
internal E_Parse e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *tokens, S64 max_precedence);
|
||||
internal E_Parse e_parse_expr_from_text_tokens(Arena *arena, String8 text, E_TokenArray *tokens);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: IR-ization Functions
|
||||
|
||||
internal void e_oplist_push(Arena *arena, E_OpList *list, RDI_EvalOp opcode, U64 p);
|
||||
internal E_IRTreeAndType e_irtree_and_type_from_expr(Arena *arena, EVAL_Expr *expr);
|
||||
internal E_OpList e_oplist_from_irtree(Arena *arena, E_IRNode *root);
|
||||
internal void e_append_oplist_from_irtree(Arena *arena, E_IRNode *root, E_OpList *out);
|
||||
internal String8 e_bytecode_from_oplist(Arena *arena, E_OpList *oplist);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Interpretation Functions
|
||||
|
||||
internal E_Result e_interpret(String8 bytecode);
|
||||
|
||||
#endif // EVAL_H
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
@table(name basic_string basic_byte_size)
|
||||
// NOTE(rjf): basic_byte_size == 0xFF? => address sized
|
||||
E_TypeKindTable:
|
||||
{
|
||||
{Null "" 0 }
|
||||
{Void "void" 0 }
|
||||
{Handle "HANDLE" 0xFF }
|
||||
{Char8 "char8" 1 }
|
||||
{Char16 "char16" 2 }
|
||||
{Char32 "char32" 4 }
|
||||
{UChar8 "uchar8" 1 }
|
||||
{UChar16 "uchar16" 2 }
|
||||
{UChar32 "uchar32" 4 }
|
||||
{U8 "U8" 1 }
|
||||
{U16 "U16" 2 }
|
||||
{U32 "U32" 4 }
|
||||
{U64 "U64" 8 }
|
||||
{U128 "U128" 16 }
|
||||
{U256 "U256" 32 }
|
||||
{U512 "U512" 64 }
|
||||
{S8 "S8" 1 }
|
||||
{S16 "S16" 2 }
|
||||
{S32 "S32" 4 }
|
||||
{S64 "S64" 8 }
|
||||
{S128 "S128" 16 }
|
||||
{S256 "S256" 32 }
|
||||
{S512 "S512" 64 }
|
||||
{Bool "bool" 1 }
|
||||
{F16 "F16" 2 }
|
||||
{F32 "F32" 4 }
|
||||
{F32PP "F32PP" 4 }
|
||||
{F48 "F48" 6 }
|
||||
{F64 "F64" 8 }
|
||||
{F80 "F80" 10 }
|
||||
{F128 "F128" 16 }
|
||||
{ComplexF32 "ComplexF32" 8 }
|
||||
{ComplexF64 "ComplexF64" 16 }
|
||||
{ComplexF80 "ComplexF80" 20 }
|
||||
{ComplexF128 "ComplexF128" 32 }
|
||||
{Modifier "" 0 }
|
||||
{Ptr "" 0 }
|
||||
{LRef "" 0 }
|
||||
{RRef "" 0 }
|
||||
{Array "" 0 }
|
||||
{Function "" 0 }
|
||||
{Method "" 0 }
|
||||
{MemberPtr "" 0 }
|
||||
{Struct "struct" 0 }
|
||||
{Class "class" 0 }
|
||||
{Union "union" 0 }
|
||||
{Enum "enum" 0 }
|
||||
{Alias "typedef" 0 }
|
||||
{IncompleteStruct "struct" 0 }
|
||||
{IncompleteUnion "union" 0 }
|
||||
{IncompleteClass "class" 0 }
|
||||
{IncompleteEnum "enum" 0 }
|
||||
{Bitfield "" 0 }
|
||||
{Variadic "" 0 }
|
||||
}
|
||||
|
||||
@table(name op_string)
|
||||
E_ExprKindTable:
|
||||
{
|
||||
{ Nil "" }
|
||||
|
||||
{ ArrayIndex "[]" }
|
||||
{ MemberAccess "." }
|
||||
{ Deref "*" }
|
||||
{ Address "&" }
|
||||
|
||||
{ Cast "cast" }
|
||||
{ Sizeof "sizeof" }
|
||||
|
||||
{ Neg "-" }
|
||||
{ LogNot "!" }
|
||||
{ BitNot "~" }
|
||||
{ Mul "*" }
|
||||
{ Div "/" }
|
||||
{ Mod "%" }
|
||||
{ Add "+" }
|
||||
{ Sub "-" }
|
||||
{ LShift "<<" }
|
||||
{ RShift ">>" }
|
||||
{ Less "<" }
|
||||
{ LsEq "<=" }
|
||||
{ Grtr ">" }
|
||||
{ GrEq ">=" }
|
||||
{ EqEq "==" }
|
||||
{ NtEq "!=" }
|
||||
|
||||
{ BitAnd "&" }
|
||||
{ BitXor "^" }
|
||||
{ BitOr "|" }
|
||||
{ LogAnd "&&" }
|
||||
{ LogOr "||" }
|
||||
|
||||
{ Ternary "? " }
|
||||
|
||||
{ LeafBytecode "bytecode" }
|
||||
{ LeafMember "member" }
|
||||
{ LeafU64 "U64" }
|
||||
{ LeafF64 "F64" }
|
||||
{ LeafF32 "F32" }
|
||||
|
||||
{ TypeIdent "type_ident" }
|
||||
{ Ptr "ptr" }
|
||||
{ Array "array" }
|
||||
{ Func "function" }
|
||||
|
||||
{ Define "=" }
|
||||
{ LeafIdent "leaf_ident" }
|
||||
}
|
||||
|
||||
@table(name display_string)
|
||||
E_ResultCodeTable:
|
||||
{
|
||||
{ Good "" }
|
||||
{ DivideByZero "Cannot divide by zero." }
|
||||
{ BadOp "Invalid operation." }
|
||||
{ BadOpTypes "Invalid operation types." }
|
||||
{ BadMemRead "Failed memory read." }
|
||||
{ BadRegRead "Failed register read." }
|
||||
{ BadFrameBase "Invalid frame base address." }
|
||||
{ BadModuleBase "Invalid module base address." }
|
||||
{ BadTLSBase "Invalid thread-local storage base address." }
|
||||
{ InsufficientStackSpace "Insufficient evaluation machine stack space." }
|
||||
{ MalformedBytecode "Malformed bytecode." }
|
||||
}
|
||||
|
||||
@enum E_TypeKind:
|
||||
{
|
||||
@expand(E_TypeKindTable a) `$(a.name)`,
|
||||
COUNT,
|
||||
`FirstBasic = E_TypeKind_Void`,
|
||||
`LastBasic = E_TypeKind_ComplexF128`,
|
||||
`FirstInteger = E_TypeKind_Char8`,
|
||||
`LastInteger = E_TypeKind_S512`,
|
||||
`FirstSigned1 = E_TypeKind_Char8`,
|
||||
`LastSigned1 = E_TypeKind_Char32`,
|
||||
`FirstSigned2 = E_TypeKind_S8`,
|
||||
`LastSigned2 = E_TypeKind_S512`,
|
||||
`FirstIncomplete = E_TypeKind_IncompleteStruct`,
|
||||
`LastIncomplete = E_TypeKind_IncompleteEnum`,
|
||||
}
|
||||
|
||||
@enum(U32) E_ExprKind:
|
||||
{
|
||||
@expand(E_ExprKindTable a) `$(a.name)`,
|
||||
COUNT,
|
||||
}
|
||||
|
||||
@enum E_ResultCode:
|
||||
{
|
||||
@expand(E_ResultCodeTable a) `$(a.name)`,
|
||||
COUNT,
|
||||
}
|
||||
|
||||
@data(String8)
|
||||
e_expr_kind_strings:
|
||||
{
|
||||
@expand(E_ExprKindTable a) `str8_lit_comp("$(a.name)")`
|
||||
}
|
||||
|
||||
@data(String8) e_result_code_display_strings:
|
||||
{
|
||||
@expand(E_ResultCodeTable a) `str8_lit_comp("$(a.display_string)")`
|
||||
}
|
||||
|
||||
@data(String8) e_expr_op_strings:
|
||||
{
|
||||
@expand(E_ExprKindTable a) `str8_lit_comp("$(a.op_string)")`
|
||||
}
|
||||
|
||||
@data(U8) e_kind_basic_byte_size_table:
|
||||
{
|
||||
@expand(E_TypeKindTable a) `$(a.basic_byte_size)`;
|
||||
}
|
||||
|
||||
@data(String8) e_kind_basic_string_table:
|
||||
{
|
||||
@expand(E_TypeKindTable a) `str8_lit_comp("$(a.basic_string)")`;
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
String8 e_expr_kind_strings[40] =
|
||||
{
|
||||
str8_lit_comp("Nil"),
|
||||
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("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("LeafBytecode"),
|
||||
str8_lit_comp("LeafMember"),
|
||||
str8_lit_comp("LeafU64"),
|
||||
str8_lit_comp("LeafF64"),
|
||||
str8_lit_comp("LeafF32"),
|
||||
str8_lit_comp("TypeIdent"),
|
||||
str8_lit_comp("Ptr"),
|
||||
str8_lit_comp("Array"),
|
||||
str8_lit_comp("Func"),
|
||||
str8_lit_comp("Define"),
|
||||
str8_lit_comp("LeafIdent"),
|
||||
};
|
||||
|
||||
String8 e_result_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."),
|
||||
};
|
||||
|
||||
String8 e_expr_op_strings[40] =
|
||||
{
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp("[]"),
|
||||
str8_lit_comp("."),
|
||||
str8_lit_comp("*"),
|
||||
str8_lit_comp("&"),
|
||||
str8_lit_comp("cast"),
|
||||
str8_lit_comp("sizeof"),
|
||||
str8_lit_comp("-"),
|
||||
str8_lit_comp("!"),
|
||||
str8_lit_comp("~"),
|
||||
str8_lit_comp("*"),
|
||||
str8_lit_comp("/"),
|
||||
str8_lit_comp("%"),
|
||||
str8_lit_comp("+"),
|
||||
str8_lit_comp("-"),
|
||||
str8_lit_comp("<<"),
|
||||
str8_lit_comp(">>"),
|
||||
str8_lit_comp("<"),
|
||||
str8_lit_comp("<="),
|
||||
str8_lit_comp(">"),
|
||||
str8_lit_comp(">="),
|
||||
str8_lit_comp("=="),
|
||||
str8_lit_comp("!="),
|
||||
str8_lit_comp("&"),
|
||||
str8_lit_comp("^"),
|
||||
str8_lit_comp("|"),
|
||||
str8_lit_comp("&&"),
|
||||
str8_lit_comp("||"),
|
||||
str8_lit_comp("? "),
|
||||
str8_lit_comp("bytecode"),
|
||||
str8_lit_comp("member"),
|
||||
str8_lit_comp("U64"),
|
||||
str8_lit_comp("F64"),
|
||||
str8_lit_comp("F32"),
|
||||
str8_lit_comp("type_ident"),
|
||||
str8_lit_comp("ptr"),
|
||||
str8_lit_comp("array"),
|
||||
str8_lit_comp("function"),
|
||||
str8_lit_comp("="),
|
||||
str8_lit_comp("leaf_ident"),
|
||||
};
|
||||
|
||||
U8 e_kind_basic_byte_size_table[54] =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
0xFF,
|
||||
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,
|
||||
};
|
||||
|
||||
String8 e_kind_basic_string_table[54] =
|
||||
{
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp("void"),
|
||||
str8_lit_comp("HANDLE"),
|
||||
str8_lit_comp("char8"),
|
||||
str8_lit_comp("char16"),
|
||||
str8_lit_comp("char32"),
|
||||
str8_lit_comp("uchar8"),
|
||||
str8_lit_comp("uchar16"),
|
||||
str8_lit_comp("uchar32"),
|
||||
str8_lit_comp("U8"),
|
||||
str8_lit_comp("U16"),
|
||||
str8_lit_comp("U32"),
|
||||
str8_lit_comp("U64"),
|
||||
str8_lit_comp("U128"),
|
||||
str8_lit_comp("U256"),
|
||||
str8_lit_comp("U512"),
|
||||
str8_lit_comp("S8"),
|
||||
str8_lit_comp("S16"),
|
||||
str8_lit_comp("S32"),
|
||||
str8_lit_comp("S64"),
|
||||
str8_lit_comp("S128"),
|
||||
str8_lit_comp("S256"),
|
||||
str8_lit_comp("S512"),
|
||||
str8_lit_comp("bool"),
|
||||
str8_lit_comp("F16"),
|
||||
str8_lit_comp("F32"),
|
||||
str8_lit_comp("F32PP"),
|
||||
str8_lit_comp("F48"),
|
||||
str8_lit_comp("F64"),
|
||||
str8_lit_comp("F80"),
|
||||
str8_lit_comp("F128"),
|
||||
str8_lit_comp("ComplexF32"),
|
||||
str8_lit_comp("ComplexF64"),
|
||||
str8_lit_comp("ComplexF80"),
|
||||
str8_lit_comp("ComplexF128"),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp("struct"),
|
||||
str8_lit_comp("class"),
|
||||
str8_lit_comp("union"),
|
||||
str8_lit_comp("enum"),
|
||||
str8_lit_comp("typedef"),
|
||||
str8_lit_comp("struct"),
|
||||
str8_lit_comp("union"),
|
||||
str8_lit_comp("class"),
|
||||
str8_lit_comp("enum"),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
};
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
#ifndef EVAL2_META_H
|
||||
#define EVAL2_META_H
|
||||
|
||||
typedef enum E_TypeKind
|
||||
{
|
||||
E_TypeKind_Null,
|
||||
E_TypeKind_Void,
|
||||
E_TypeKind_Handle,
|
||||
E_TypeKind_Char8,
|
||||
E_TypeKind_Char16,
|
||||
E_TypeKind_Char32,
|
||||
E_TypeKind_UChar8,
|
||||
E_TypeKind_UChar16,
|
||||
E_TypeKind_UChar32,
|
||||
E_TypeKind_U8,
|
||||
E_TypeKind_U16,
|
||||
E_TypeKind_U32,
|
||||
E_TypeKind_U64,
|
||||
E_TypeKind_U128,
|
||||
E_TypeKind_U256,
|
||||
E_TypeKind_U512,
|
||||
E_TypeKind_S8,
|
||||
E_TypeKind_S16,
|
||||
E_TypeKind_S32,
|
||||
E_TypeKind_S64,
|
||||
E_TypeKind_S128,
|
||||
E_TypeKind_S256,
|
||||
E_TypeKind_S512,
|
||||
E_TypeKind_Bool,
|
||||
E_TypeKind_F16,
|
||||
E_TypeKind_F32,
|
||||
E_TypeKind_F32PP,
|
||||
E_TypeKind_F48,
|
||||
E_TypeKind_F64,
|
||||
E_TypeKind_F80,
|
||||
E_TypeKind_F128,
|
||||
E_TypeKind_ComplexF32,
|
||||
E_TypeKind_ComplexF64,
|
||||
E_TypeKind_ComplexF80,
|
||||
E_TypeKind_ComplexF128,
|
||||
E_TypeKind_Modifier,
|
||||
E_TypeKind_Ptr,
|
||||
E_TypeKind_LRef,
|
||||
E_TypeKind_RRef,
|
||||
E_TypeKind_Array,
|
||||
E_TypeKind_Function,
|
||||
E_TypeKind_Method,
|
||||
E_TypeKind_MemberPtr,
|
||||
E_TypeKind_Struct,
|
||||
E_TypeKind_Class,
|
||||
E_TypeKind_Union,
|
||||
E_TypeKind_Enum,
|
||||
E_TypeKind_Alias,
|
||||
E_TypeKind_IncompleteStruct,
|
||||
E_TypeKind_IncompleteUnion,
|
||||
E_TypeKind_IncompleteClass,
|
||||
E_TypeKind_IncompleteEnum,
|
||||
E_TypeKind_Bitfield,
|
||||
E_TypeKind_Variadic,
|
||||
E_TypeKind_COUNT,
|
||||
E_TypeKind_FirstBasic = E_TypeKind_Void,
|
||||
E_TypeKind_LastBasic = E_TypeKind_ComplexF128,
|
||||
E_TypeKind_FirstInteger = E_TypeKind_Char8,
|
||||
E_TypeKind_LastInteger = E_TypeKind_S512,
|
||||
E_TypeKind_FirstSigned1 = E_TypeKind_Char8,
|
||||
E_TypeKind_LastSigned1 = E_TypeKind_Char32,
|
||||
E_TypeKind_FirstSigned2 = E_TypeKind_S8,
|
||||
E_TypeKind_LastSigned2 = E_TypeKind_S512,
|
||||
E_TypeKind_FirstIncomplete = E_TypeKind_IncompleteStruct,
|
||||
E_TypeKind_LastIncomplete = E_TypeKind_IncompleteEnum,
|
||||
} E_TypeKind;
|
||||
|
||||
typedef U32 E_ExprKind;
|
||||
typedef enum E_ExprKindEnum
|
||||
{
|
||||
E_ExprKind_Nil,
|
||||
E_ExprKind_ArrayIndex,
|
||||
E_ExprKind_MemberAccess,
|
||||
E_ExprKind_Deref,
|
||||
E_ExprKind_Address,
|
||||
E_ExprKind_Cast,
|
||||
E_ExprKind_Sizeof,
|
||||
E_ExprKind_Neg,
|
||||
E_ExprKind_LogNot,
|
||||
E_ExprKind_BitNot,
|
||||
E_ExprKind_Mul,
|
||||
E_ExprKind_Div,
|
||||
E_ExprKind_Mod,
|
||||
E_ExprKind_Add,
|
||||
E_ExprKind_Sub,
|
||||
E_ExprKind_LShift,
|
||||
E_ExprKind_RShift,
|
||||
E_ExprKind_Less,
|
||||
E_ExprKind_LsEq,
|
||||
E_ExprKind_Grtr,
|
||||
E_ExprKind_GrEq,
|
||||
E_ExprKind_EqEq,
|
||||
E_ExprKind_NtEq,
|
||||
E_ExprKind_BitAnd,
|
||||
E_ExprKind_BitXor,
|
||||
E_ExprKind_BitOr,
|
||||
E_ExprKind_LogAnd,
|
||||
E_ExprKind_LogOr,
|
||||
E_ExprKind_Ternary,
|
||||
E_ExprKind_LeafBytecode,
|
||||
E_ExprKind_LeafMember,
|
||||
E_ExprKind_LeafU64,
|
||||
E_ExprKind_LeafF64,
|
||||
E_ExprKind_LeafF32,
|
||||
E_ExprKind_TypeIdent,
|
||||
E_ExprKind_Ptr,
|
||||
E_ExprKind_Array,
|
||||
E_ExprKind_Func,
|
||||
E_ExprKind_Define,
|
||||
E_ExprKind_LeafIdent,
|
||||
E_ExprKind_COUNT,
|
||||
} E_ExprKindEnum;
|
||||
|
||||
typedef enum E_ResultCode
|
||||
{
|
||||
E_ResultCode_Good,
|
||||
E_ResultCode_DivideByZero,
|
||||
E_ResultCode_BadOp,
|
||||
E_ResultCode_BadOpTypes,
|
||||
E_ResultCode_BadMemRead,
|
||||
E_ResultCode_BadRegRead,
|
||||
E_ResultCode_BadFrameBase,
|
||||
E_ResultCode_BadModuleBase,
|
||||
E_ResultCode_BadTLSBase,
|
||||
E_ResultCode_InsufficientStackSpace,
|
||||
E_ResultCode_MalformedBytecode,
|
||||
E_ResultCode_COUNT,
|
||||
} E_ResultCode;
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
extern String8 e_expr_kind_strings[40];
|
||||
extern String8 e_result_code_display_strings[11];
|
||||
extern String8 e_expr_op_strings[40];
|
||||
extern U8 e_kind_basic_byte_size_table[54];
|
||||
extern String8 e_kind_basic_string_table[54];
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
#endif // EVAL2_META_H
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "fuzzy_search/fuzzy_search.h"
|
||||
#include "demon/demon_inc.h"
|
||||
#include "eval/eval_inc.h"
|
||||
#include "eval2/eval2.h"
|
||||
#include "ctrl/ctrl_inc.h"
|
||||
#include "font_provider/font_provider_inc.h"
|
||||
#include "render/render_inc.h"
|
||||
@@ -96,6 +97,7 @@
|
||||
#include "fuzzy_search/fuzzy_search.c"
|
||||
#include "demon/demon_inc.c"
|
||||
#include "eval/eval_inc.c"
|
||||
#include "eval2/eval2.c"
|
||||
#include "ctrl/ctrl_inc.c"
|
||||
#include "font_provider/font_provider_inc.c"
|
||||
#include "render/render_inc.c"
|
||||
|
||||
Reference in New Issue
Block a user