mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-13 07:32:23 -07:00
pipe through parent expression string info through expr -> string generation path, so we can correctly generate standalone expression strings in the presence of $ (parent shortcuts)
This commit is contained in:
+4
-4
@@ -2620,7 +2620,7 @@ e_expr_irext_member_access(Arena *arena, E_Expr *lhs, E_IRTreeAndType *lhs_irtre
|
||||
E_Expr *root = e_push_expr(arena, E_ExprKind_MemberAccess, 0);
|
||||
E_Expr *lhs_bytecode = e_push_expr(arena, E_ExprKind_LeafBytecode, lhs->location);
|
||||
E_OpList lhs_oplist = e_oplist_from_irtree(arena, lhs_irtree->root);
|
||||
lhs_bytecode->string = e_string_from_expr(arena, lhs);
|
||||
lhs_bytecode->string = e_string_from_expr(arena, lhs, str8_zero());
|
||||
lhs_bytecode->qualifier = lhs->qualifier;
|
||||
lhs_bytecode->space = lhs->space;
|
||||
lhs_bytecode->mode = lhs_irtree->mode;
|
||||
@@ -2639,7 +2639,7 @@ e_expr_irext_array_index(Arena *arena, E_Expr *lhs, E_IRTreeAndType *lhs_irtree,
|
||||
E_Expr *root = e_push_expr(arena, E_ExprKind_ArrayIndex, 0);
|
||||
E_Expr *lhs_bytecode = e_push_expr(arena, E_ExprKind_LeafBytecode, lhs->location);
|
||||
E_OpList lhs_oplist = e_oplist_from_irtree(arena, lhs_irtree->root);
|
||||
lhs_bytecode->string = e_string_from_expr(arena, lhs);
|
||||
lhs_bytecode->string = e_string_from_expr(arena, lhs, str8_zero());
|
||||
lhs_bytecode->qualifier = lhs->qualifier;
|
||||
lhs_bytecode->space = lhs->space;
|
||||
lhs_bytecode->mode = lhs_irtree->mode;
|
||||
@@ -2658,7 +2658,7 @@ e_expr_irext_deref(Arena *arena, E_Expr *rhs, E_IRTreeAndType *rhs_irtree)
|
||||
E_Expr *root = e_push_expr(arena, E_ExprKind_Deref, 0);
|
||||
E_Expr *rhs_bytecode = e_push_expr(arena, E_ExprKind_LeafBytecode, rhs->location);
|
||||
E_OpList rhs_oplist = e_oplist_from_irtree(arena, rhs_irtree->root);
|
||||
rhs_bytecode->string = e_string_from_expr(arena, rhs);
|
||||
rhs_bytecode->string = e_string_from_expr(arena, rhs, str8_zero());
|
||||
rhs_bytecode->space = rhs->space;
|
||||
rhs_bytecode->mode = rhs_irtree->mode;
|
||||
rhs_bytecode->type_key = rhs_irtree->type_key;
|
||||
@@ -2673,7 +2673,7 @@ e_expr_irext_cast(Arena *arena, E_Expr *rhs, E_IRTreeAndType *rhs_irtree, E_Type
|
||||
E_Expr *root = e_push_expr(arena, E_ExprKind_Cast, 0);
|
||||
E_Expr *rhs_bytecode = e_push_expr(arena, E_ExprKind_LeafBytecode, rhs->location);
|
||||
E_OpList rhs_oplist = e_oplist_from_irtree(arena, rhs_irtree->root);
|
||||
rhs_bytecode->string = e_string_from_expr(arena, rhs);
|
||||
rhs_bytecode->string = e_string_from_expr(arena, rhs, str8_zero());
|
||||
rhs_bytecode->space = rhs->space;
|
||||
rhs_bytecode->mode = rhs_irtree->mode;
|
||||
rhs_bytecode->type_key = rhs_irtree->type_key;
|
||||
|
||||
+13
-6
@@ -483,7 +483,7 @@ e_expr_list_push(Arena *arena, E_ExprList *list, E_Expr *expr)
|
||||
//~ rjf: Expression Tree -> String Conversions
|
||||
|
||||
internal void
|
||||
e_append_strings_from_expr(Arena *arena, E_Expr *expr, String8List *out)
|
||||
e_append_strings_from_expr(Arena *arena, E_Expr *expr, String8 parent_expr_string, String8List *out)
|
||||
{
|
||||
switch(expr->kind)
|
||||
{
|
||||
@@ -518,7 +518,7 @@ e_append_strings_from_expr(Arena *arena, E_Expr *expr, String8List *out)
|
||||
{
|
||||
str8_list_pushf(arena, out, "(");
|
||||
}
|
||||
e_append_strings_from_expr(arena, child, out);
|
||||
e_append_strings_from_expr(arena, child, parent_expr_string, out);
|
||||
if(need_parens)
|
||||
{
|
||||
str8_list_pushf(arena, out, ")");
|
||||
@@ -528,7 +528,14 @@ e_append_strings_from_expr(Arena *arena, E_Expr *expr, String8List *out)
|
||||
case E_ExprKind_LeafBytecode:
|
||||
case E_ExprKind_LeafIdentifier:
|
||||
{
|
||||
str8_list_push(arena, out, expr->string);
|
||||
if(str8_match(expr->string, str8_lit("$"), 0) && parent_expr_string.size != 0)
|
||||
{
|
||||
str8_list_push(arena, out, parent_expr_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
str8_list_push(arena, out, expr->string);
|
||||
}
|
||||
}break;
|
||||
case E_ExprKind_LeafStringLiteral:
|
||||
{
|
||||
@@ -561,16 +568,16 @@ e_append_strings_from_expr(Arena *arena, E_Expr *expr, String8List *out)
|
||||
}break;
|
||||
case E_ExprKind_Ref:
|
||||
{
|
||||
e_append_strings_from_expr(arena, expr->ref, out);
|
||||
e_append_strings_from_expr(arena, expr->ref, parent_expr_string, out);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
internal String8
|
||||
e_string_from_expr(Arena *arena, E_Expr *expr)
|
||||
e_string_from_expr(Arena *arena, E_Expr *expr, String8 parent_expr_string)
|
||||
{
|
||||
String8List strings = {0};
|
||||
e_append_strings_from_expr(arena, expr, &strings);
|
||||
e_append_strings_from_expr(arena, expr, parent_expr_string, &strings);
|
||||
String8 result = str8_list_join(arena, &strings, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@ internal void e_expr_list_push(Arena *arena, E_ExprList *list, E_Expr *expr);
|
||||
////////////////////////////////
|
||||
//~ rjf: Expression Tree -> String Conversions
|
||||
|
||||
internal void e_append_strings_from_expr(Arena *arena, E_Expr *expr, String8List *out);
|
||||
internal String8 e_string_from_expr(Arena *arena, E_Expr *expr);
|
||||
internal void e_append_strings_from_expr(Arena *arena, E_Expr *expr, String8 parent_expr_string, String8List *out);
|
||||
internal String8 e_string_from_expr(Arena *arena, E_Expr *expr, String8 parent_expr_string);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Parsing Functions
|
||||
|
||||
@@ -1741,7 +1741,7 @@ e_type_lhs_string_from_key(Arena *arena, E_TypeKey key, String8List *out, U32 pr
|
||||
str8_list_push(arena, out, direct_string);
|
||||
for EachIndex(idx, type->count)
|
||||
{
|
||||
String8 string = e_string_from_expr(arena, type->args[idx]);
|
||||
String8 string = e_string_from_expr(arena, type->args[idx], str8_zero());
|
||||
str8_list_pushf(arena, out, ", ");
|
||||
str8_list_push(arena, out, string);
|
||||
}
|
||||
|
||||
@@ -2183,7 +2183,7 @@ rd_view_from_eval(RD_Cfg *parent, E_Eval eval)
|
||||
args_count = type->count;
|
||||
}
|
||||
RD_Cfg *expr_root = rd_cfg_child_from_string_or_alloc(view, str8_lit("expression"));
|
||||
rd_cfg_new_replace(expr_root, e_string_from_expr(scratch.arena, primary_expr));
|
||||
rd_cfg_new_replace(expr_root, e_string_from_expr(scratch.arena, primary_expr, str8_zero()));
|
||||
{
|
||||
U64 unnamed_order_idx = 0;
|
||||
for EachIndex(arg_idx, args_count)
|
||||
@@ -2216,7 +2216,7 @@ rd_view_from_eval(RD_Cfg *parent, E_Eval eval)
|
||||
unnamed_order_idx += 1;
|
||||
}
|
||||
RD_Cfg *arg_root = rd_cfg_child_from_string_or_alloc(view, param_name);
|
||||
rd_cfg_new_replace(arg_root, e_string_from_expr(scratch.arena, arg_expr));
|
||||
rd_cfg_new_replace(arg_root, e_string_from_expr(scratch.arena, arg_expr, str8_zero()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4495,7 +4495,7 @@ rd_view_ui(Rng2F32 rect)
|
||||
cell->eval.space.kind == E_SpaceKind_File ||
|
||||
cell->eval.space.kind == E_SpaceKind_Null)
|
||||
{
|
||||
RD_RegsScope(.expr = e_string_from_expr(scratch.arena, cell->eval.expr))
|
||||
RD_RegsScope(.expr = e_string_from_expr(scratch.arena, cell->eval.expr, e_string_from_expr(scratch.arena, row->eval.expr, str8_zero())))
|
||||
rd_drag_begin(RD_RegSlot_Expr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1615,13 +1615,13 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
|
||||
// rjf: default case -> just walk the expression tree & generate a string
|
||||
default:
|
||||
{
|
||||
expr_string = e_string_from_expr(arena, notable_expr);
|
||||
expr_string = e_string_from_expr(arena, notable_expr, str8_zero());
|
||||
}break;
|
||||
|
||||
// rjf: array indices -> fast path to [index]
|
||||
case E_ExprKind_ArrayIndex:
|
||||
{
|
||||
expr_string = push_str8f(arena, "[%S]", e_string_from_expr(arena, notable_expr->last));
|
||||
expr_string = push_str8f(arena, "[%S]", e_string_from_expr(arena, notable_expr->last, str8_zero()));
|
||||
}break;
|
||||
|
||||
// rjf: member accesses -> fast-path to .name
|
||||
|
||||
Reference in New Issue
Block a user