mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-15 00:22:23 -07:00
fix some edge cases in new casting compilation, fix some old usage of cast expr trees
This commit is contained in:
+2
-20
@@ -1275,13 +1275,13 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_overridden,
|
||||
case E_ExprKind_Call:
|
||||
{
|
||||
E_Expr *lhs = expr->first;
|
||||
E_IRTreeAndType lhs_irtree = e_push_irtree_and_type_from_expr(arena, overridden, disallow_autohooks, disallow_chained_fastpaths, 1, lhs);
|
||||
E_IRTreeAndType lhs_irtree = e_push_irtree_and_type_from_expr(arena, overridden, disallow_autohooks, 1, 1, lhs);
|
||||
e_msg_list_concat_in_place(&result.msgs, &lhs_irtree.msgs);
|
||||
E_TypeKey lhs_type_key = lhs_irtree.type_key;
|
||||
E_Type *lhs_type = e_type_from_key__cached(lhs_type_key);
|
||||
|
||||
// rjf: calling a type? -> treat as a cast of that type
|
||||
if(lhs_irtree.mode == E_Mode_Null)
|
||||
if(lhs_irtree.mode == E_Mode_Null && lhs_type != &e_type_nil)
|
||||
{
|
||||
E_IRTreeAndType casted_tree = e_push_irtree_and_type_from_expr(arena, overridden, disallow_autohooks, 1, disallow_chained_casts, expr->first->next);
|
||||
e_msg_list_concat_in_place(&result.msgs, &casted_tree.msgs);
|
||||
@@ -2543,21 +2543,3 @@ e_expr_irext_deref(Arena *arena, E_Expr *rhs, E_IRTreeAndType *rhs_irtree)
|
||||
e_expr_push_child(root, rhs_bytecode);
|
||||
return root;
|
||||
}
|
||||
|
||||
internal E_Expr *
|
||||
e_expr_irext_cast(Arena *arena, E_Expr *rhs, E_IRTreeAndType *rhs_irtree, E_TypeKey type_key)
|
||||
{
|
||||
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, str8_zero());
|
||||
rhs_bytecode->space = rhs->space;
|
||||
rhs_bytecode->mode = rhs_irtree->mode;
|
||||
rhs_bytecode->type_key = rhs_irtree->type_key;
|
||||
rhs_bytecode->bytecode = e_bytecode_from_oplist(arena, &rhs_oplist);
|
||||
E_Expr *lhs = e_push_expr(arena, E_ExprKind_TypeIdent, 0);
|
||||
lhs->type_key = type_key;
|
||||
e_expr_push_child(root, lhs);
|
||||
e_expr_push_child(root, rhs_bytecode);
|
||||
return root;
|
||||
}
|
||||
|
||||
@@ -99,6 +99,5 @@ internal String8 e_bytecode_from_oplist(Arena *arena, E_OpList *oplist);
|
||||
internal E_Expr *e_expr_irext_member_access(Arena *arena, E_Expr *lhs, E_IRTreeAndType *lhs_irtree, String8 member_name);
|
||||
internal E_Expr *e_expr_irext_array_index(Arena *arena, E_Expr *lhs, E_IRTreeAndType *lhs_irtree, U64 index);
|
||||
internal E_Expr *e_expr_irext_deref(Arena *arena, E_Expr *rhs, E_IRTreeAndType *rhs_irtree);
|
||||
internal E_Expr *e_expr_irext_cast(Arena *arena, E_Expr *rhs, E_IRTreeAndType *rhs_irtree, E_TypeKey type_key);
|
||||
|
||||
#endif // EVAL_IR_H
|
||||
|
||||
+1
-13
@@ -334,18 +334,6 @@ e_expr_ref(Arena *arena, E_Expr *ref)
|
||||
return expr;
|
||||
}
|
||||
|
||||
internal E_Expr *
|
||||
e_expr_ref_cast(Arena *arena, E_TypeKey type_key, E_Expr *rhs)
|
||||
{
|
||||
E_Expr *root = e_push_expr(arena, E_ExprKind_Cast, 0);
|
||||
E_Expr *lhs = e_push_expr(arena, E_ExprKind_TypeIdent, 0);
|
||||
lhs->type_key = type_key;
|
||||
E_Expr *rhs_ref = e_expr_ref(arena, rhs);
|
||||
e_expr_push_child(root, lhs);
|
||||
e_expr_push_child(root, rhs_ref);
|
||||
return root;
|
||||
}
|
||||
|
||||
internal E_Expr *
|
||||
e_expr_copy(Arena *arena, E_Expr *src)
|
||||
{
|
||||
@@ -1195,7 +1183,7 @@ e_push_parse_from_string_tokens__prec(Arena *arena, String8 text, E_TokenArray t
|
||||
// rjf: no identifier after `.`? -> error
|
||||
else
|
||||
{
|
||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, token_string.str, "Missing identifier after `.`.");
|
||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, token_string.str, "Missing member name after `%S`.", token_string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ internal void e_expr_insert_child(E_Expr *parent, E_Expr *prev, E_Expr *child);
|
||||
internal void e_expr_push_child(E_Expr *parent, E_Expr *child);
|
||||
internal void e_expr_remove_child(E_Expr *parent, E_Expr *child);
|
||||
internal E_Expr *e_expr_ref(Arena *arena, E_Expr *ref);
|
||||
internal E_Expr *e_expr_ref_cast(Arena *arena, E_TypeKey type_key, E_Expr *rhs);
|
||||
internal E_Expr *e_expr_copy(Arena *arena, E_Expr *src);
|
||||
internal void e_expr_list_push(Arena *arena, E_ExprList *list, E_Expr *expr);
|
||||
|
||||
|
||||
@@ -2120,9 +2120,7 @@ rd_commit_eval_value_string(E_Eval dst_eval, String8 string)
|
||||
type_kind == E_TypeKind_Enum))
|
||||
{
|
||||
got_commit_data = 1;
|
||||
E_Expr *src_expr = e_parse_from_string(string).expr;
|
||||
E_Expr *src_expr__casted = e_expr_ref_cast(scratch.arena, type_key, src_expr);
|
||||
E_Eval src_eval = e_eval_from_expr(src_expr__casted);
|
||||
E_Eval src_eval = e_eval_from_stringf("(%S)(%S)", e_type_string_from_key(scratch.arena, type_key), string);
|
||||
commit_data = push_str8_copy(scratch.arena, str8_struct(&src_eval.value));
|
||||
commit_data.size = Min(commit_data.size, e_type_byte_size_from_key(type_key));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user