plug eval2 into watch debug tooltips

This commit is contained in:
Ryan Fleury committed 2026-07-29 12:30:40 -07:00
1 parent 076d41130c
commit 11cb826181
10 files changed
+389 -4

No files matched your search

+48 -1
View File
@@ -199,6 +199,22 @@ e2_msgf(Arena *arena, E2_MsgList *msgs, Rng1U64 src_range, char *fmt, ...)
return msg;
}
internal void
e2_msg_list_concat_in_place(E2_MsgList *dst, E2_MsgList *src)
{
if(dst->last != 0 && src->first != 0)
{
dst->last->next = src->first;
dst->last = src->last;
dst->count += src->count;
}
else if(src->first != 0)
{
MemoryCopyStruct(dst, src);
}
MemoryZeroStruct(src);
}
////////////////////////////////
//~ rjf: Assets
@@ -2594,7 +2610,7 @@ e2_parse_from_string(Arena *arena, E2_ParseState *state, B32 identifier_is_type,
internal E2_Compile
e2_compile_from_expr(Arena *arena, E2_CompileState *state, E2_IRNode *resolve_result, E2_Val compile_time_eval_result, E2_Expr *expr)
{
E2_Compile compile = {E2_CompileStatus_Error};
E2_Compile compile = {E2_CompileStatus_Error, .irtree = &e2_irnode_nil, .params_irtree = &e2_irnode_nil};
{
E2_IRNode *next_resolve_result = resolve_result;
@@ -3720,6 +3736,7 @@ e2_interp_from_bytecode(Arena *arena, E2_InterpState *state, E2_SpaceMap *space_
{
good = 0;
interp.status = E2_InterpStatus_BadRegCode;
e2_msgf(arena, &interp.msgs, r1u64(state->bytecode_off, state->bytecode_off+1), "Bad register code (%i).", base_reg_code);
}
}break;
case RDI_EvalOp_FrameOff: {ctx_flags = E2_CtxFlag_HasFrameBase; ctx_base_addr = state->selected_ctx.frame_base_addr;}goto optional_base_off;
@@ -3735,6 +3752,16 @@ e2_interp_from_bytecode(Arena *arena, E2_InterpState *state, E2_SpaceMap *space_
else
{
good = 0;
String8 missing_msg = {0};
switch(ctx_flags)
{
default:{}break;
case E2_CtxFlag_HasFrameBase: {missing_msg = s("Missing frame base address.");}break;
case E2_CtxFlag_HasModuleBase:{missing_msg = s("Missing module base address.");}break;
case E2_CtxFlag_HasTLSBase: {missing_msg = s("Missing thread-local-storage base address.");}break;
case E2_CtxFlag_HasCFA: {missing_msg = s("Missing canonical frame address.");}break;
}
e2_msg(arena, &interp.msgs, r1u64(state->bytecode_off, state->bytecode_off+1), missing_msg);
interp.status = E2_InterpStatus_MissingCtxFlag;
interp.missing_ctx_flags |= ctx_flags;
}
@@ -3979,6 +4006,7 @@ BinOp(U, u64, u64, symbol);
{
good = 0;
interp.status = E2_InterpStatus_BadOffset;
e2_msgf(arena, &interp.msgs, r1u64(state->bytecode_off, state->bytecode_off+1), "Couldn't read range [0x%I64x, 0x%I64x) (end of range is 0x%I64x).", offset, offset+bytes_to_read, popped_vals[1].string.size);
}
}break;
@@ -4029,6 +4057,25 @@ BinOp(U, u64, u64, symbol);
}break;
}
//- rjf: push generalized failure messages
switch(interp.status)
{
default:{}break;
case E2_InterpStatus_DivideByZero:
{
e2_msgf(arena, &interp.msgs, r1u64(state->bytecode_off, state->bytecode_off+1), "Divide by zero.");
}break;
case E2_InterpStatus_UnsupportedOp:
{
e2_msgf(arena, &interp.msgs, r1u64(state->bytecode_off, state->bytecode_off+1), "Unsupported opcode (%i).", op);
}break;
case E2_InterpStatus_BadOpTypes:
{
String8 opcode_name = rdi_string_from_eval_op(scratch.arena, op);
e2_msgf(arena, &interp.msgs, r1u64(state->bytecode_off, state->bytecode_off+1), "%S opcode cannot be applied to these types.", opcode_name);
}break;
}
//- rjf: if opcode successful -> do stack pops
if(good) for EachIndex(pop_idx, pop_count)
{
+1 -1
View File
@@ -64,7 +64,6 @@ typedef enum E2_CompileStatus
//- rjf: caller-provided info
E2_CompileStatus_MissedIdentifierResolution,
E2_CompileStatus_NewIdentifierDefinition,
E2_CompileStatus_NewCtxID,
E2_CompileStatus_MemberAccess,
E2_CompileStatus_IndexAccess,
E2_CompileStatus_Call,
@@ -559,6 +558,7 @@ internal E2_IRNode *e2_irtree_from_identifier(E2_IdentifierMap *map, String8 nam
internal E2_Msg *e2_msg(Arena *arena, E2_MsgList *msgs, Rng1U64 src_range, String8 string);
internal E2_Msg *e2_msgf(Arena *arena, E2_MsgList *msgs, Rng1U64 src_range, char *fmt, ...);
internal void e2_msg_list_concat_in_place(E2_MsgList *dst, E2_MsgList *src);
////////////////////////////////
//~ rjf: Assets
+6
View File
@@ -65,6 +65,12 @@ E2_ExprKindTable:
COUNT,
}
@data(String8) e2_expr_kind_string_table:
{
`{0}`
@expand(E2_ExprKindTable a) `str8_lit_comp("$(a.name)")`
}
@data(B8) e2_expr_kind_allow_type_operands_table:
{
0,
+52
View File
@@ -4,6 +4,58 @@
//- GENERATED CODE
C_LINKAGE_BEGIN
String8 e2_expr_kind_string_table[48] =
{
{0},
str8_lit_comp("Identifier"),
str8_lit_comp("MacroArg"),
str8_lit_comp("TypeIdentifier"),
str8_lit_comp("Numeric"),
str8_lit_comp("StringLiteral"),
str8_lit_comp("CharLiteral"),
str8_lit_comp("Ptr"),
str8_lit_comp("Array"),
str8_lit_comp("Function"),
str8_lit_comp("Const"),
str8_lit_comp("Volatile"),
str8_lit_comp("Unsigned"),
str8_lit_comp("Signed"),
str8_lit_comp("Dot"),
str8_lit_comp("Index"),
str8_lit_comp("Call"),
str8_lit_comp("DerefAsm"),
str8_lit_comp("SizeOf"),
str8_lit_comp("TypeOf"),
str8_lit_comp("Cast"),
str8_lit_comp("Deref"),
str8_lit_comp("Address"),
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("LtEq"),
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("Define"),
str8_lit_comp("Macro"),
str8_lit_comp("Cond"),
};
B8 e2_expr_kind_allow_type_operands_table[48] =
{
0,
+1
View File
@@ -163,6 +163,7 @@ E2_ExprKindParseInfo *expr_kind_parse_infos;
};
C_LINKAGE_BEGIN
extern String8 e2_expr_kind_string_table[48];
extern B8 e2_expr_kind_allow_type_operands_table[48];
extern B8 e2_expr_kind_is_type_expr_table[48];
extern B8 e2_expr_kind_is_first_operand_type_maybe_table[48];