mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-19 14:31:30 +00:00
line expressions in eval lang; begin getting off of entities for breakpoints/watch-pins/etc., move -> cfg
This commit is contained in:
@@ -132,6 +132,8 @@ E_ExprKindTable:
|
||||
{ Array Null 0 "array" "" "" "" }
|
||||
{ Func Null 0 "function" "" "" "" }
|
||||
|
||||
{ Line Binary 1 ":" "" ":" "" }
|
||||
|
||||
{ Define Binary 13 "=" "" "=" "" }
|
||||
}
|
||||
|
||||
|
||||
@@ -1337,6 +1337,51 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr)
|
||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, expr->location, "Type expression not expected.");
|
||||
}break;
|
||||
|
||||
//- rjf: textual line slicing
|
||||
case E_ExprKind_Line:
|
||||
{
|
||||
E_Expr *lhs = expr->first;
|
||||
E_Expr *rhs = expr->last;
|
||||
E_IRTreeAndType lhs_irtree = e_irtree_and_type_from_expr(arena, lhs);
|
||||
E_Space space = lhs_irtree.space;
|
||||
U64 line_num = rhs->value.u64;
|
||||
B32 space_is_good = 1;
|
||||
if(lhs_irtree.root->op != E_IRExtKind_SetSpace)
|
||||
{
|
||||
space_is_good = 0;
|
||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, lhs->location, "Cannot take a line from a non-file.");
|
||||
}
|
||||
B32 line_num_is_good = 1;
|
||||
if(rhs->kind != E_ExprKind_LeafU64)
|
||||
{
|
||||
line_num_is_good = 0;
|
||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, rhs->location, "Line number must be specified as a constant number.");
|
||||
}
|
||||
if(space_is_good && line_num_is_good)
|
||||
{
|
||||
TXT_Scope *txt_scope = txt_scope_open();
|
||||
U128 key = space.u128;
|
||||
U128 hash = {0};
|
||||
TXT_TextInfo text_info = txt_text_info_from_key_lang(txt_scope, key, TXT_LangKind_Null, &hash);
|
||||
if(1 <= line_num && line_num <= text_info.lines_count)
|
||||
{
|
||||
Rng1U64 line_range = text_info.lines_ranges[line_num-1];
|
||||
U64 line_size = dim_1u64(line_range);
|
||||
E_IRNode *line_offset = e_irtree_const_u(arena, line_range.min);
|
||||
E_IRNode *set_space = e_irtree_set_space(arena, space, line_offset);
|
||||
result.root = set_space;
|
||||
result.type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), line_size);
|
||||
result.mode = E_Mode_Offset;
|
||||
result.space = space;
|
||||
}
|
||||
else
|
||||
{
|
||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, rhs->location, "Line %I64u is out of bounds.", line_num);
|
||||
}
|
||||
txt_scope_close(txt_scope);
|
||||
}
|
||||
}break;
|
||||
|
||||
//- rjf: definitions
|
||||
case E_ExprKind_Define:
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ str8_lit_comp("CharLiteral"),
|
||||
str8_lit_comp("Symbol"),
|
||||
};
|
||||
|
||||
String8 e_expr_kind_strings[48] =
|
||||
String8 e_expr_kind_strings[49] =
|
||||
{
|
||||
str8_lit_comp("Nil"),
|
||||
str8_lit_comp("Ref"),
|
||||
@@ -63,6 +63,7 @@ str8_lit_comp("TypeIdent"),
|
||||
str8_lit_comp("Ptr"),
|
||||
str8_lit_comp("Array"),
|
||||
str8_lit_comp("Func"),
|
||||
str8_lit_comp("Line"),
|
||||
str8_lit_comp("Define"),
|
||||
};
|
||||
|
||||
@@ -81,7 +82,7 @@ str8_lit_comp("Insufficient evaluation machine stack space."),
|
||||
str8_lit_comp("Malformed bytecode."),
|
||||
};
|
||||
|
||||
E_OpInfo e_expr_kind_op_info_table[48] =
|
||||
E_OpInfo e_expr_kind_op_info_table[49] =
|
||||
{
|
||||
{ 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("") },
|
||||
@@ -130,6 +131,7 @@ E_OpInfo e_expr_kind_op_info_table[48] =
|
||||
{ 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, 1, str8_lit_comp(""), str8_lit_comp(":"), str8_lit_comp("") },
|
||||
{ E_OpKind_Binary, 13, str8_lit_comp(""), str8_lit_comp("="), str8_lit_comp("") },
|
||||
};
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ E_ExprKind_TypeIdent,
|
||||
E_ExprKind_Ptr,
|
||||
E_ExprKind_Array,
|
||||
E_ExprKind_Func,
|
||||
E_ExprKind_Line,
|
||||
E_ExprKind_Define,
|
||||
E_ExprKind_COUNT,
|
||||
} E_ExprKindEnum;
|
||||
@@ -160,9 +161,9 @@ E_InterpretationCode_COUNT,
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
extern String8 e_token_kind_strings[6];
|
||||
extern String8 e_expr_kind_strings[48];
|
||||
extern String8 e_expr_kind_strings[49];
|
||||
extern String8 e_interpretation_code_display_strings[11];
|
||||
extern E_OpInfo e_expr_kind_op_info_table[48];
|
||||
extern E_OpInfo e_expr_kind_op_info_table[49];
|
||||
extern U8 e_kind_basic_byte_size_table[56];
|
||||
extern String8 e_kind_basic_string_table[56];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user