pass over help menu; typeof in eval

This commit is contained in:
Ryan Fleury
2024-10-10 07:44:26 -07:00
parent 848b26bbd9
commit 9c5d9caa32
10 changed files with 79 additions and 39 deletions
+12 -11
View File
@@ -52,14 +52,14 @@ E_TypeKindTable:
{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 }
{Modifier "modifier" 0 }
{Ptr "ptr" 0 }
{LRef "lref" 0 }
{RRef "rref" 0 }
{Array "array" 0 }
{Function "function" 0 }
{Method "method" 0 }
{MemberPtr "member_ptr" 0 }
{Struct "struct" 0 }
{Class "class" 0 }
{Union "union" 0 }
@@ -69,9 +69,9 @@ E_TypeKindTable:
{IncompleteUnion "union" 0 }
{IncompleteClass "class" 0 }
{IncompleteEnum "enum" 0 }
{Bitfield "" 0 }
{Variadic "" 0 }
{Collection "" 0 }
{Bitfield "bitfield" 0 }
{Variadic "variadic" 0 }
{Collection "collection" 0 }
}
@table(name op_kind precedence string op_pre op_sep op_pos)
@@ -87,6 +87,7 @@ E_ExprKindTable:
{ Cast Null 1 "cast" "(" ")" "" }
{ Sizeof UnaryPrefix 1 "sizeof" "sizeof" "" "" }
{ Typeof UnaryPrefix 1 "typeof" "typeof" "" "" }
{ ByteSwap UnaryPrefix 1 "bswap" "bswap" "(" ")"}
{ Neg UnaryPrefix 2 "-" "-" "" "" }
+15
View File
@@ -806,6 +806,21 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr)
}
}break;
//- rjf: typeof
case E_ExprKind_Typeof:
{
// rjf: evaluate operand tree
E_Expr *r_expr = expr->first;
E_IRTreeAndType r_tree = e_irtree_and_type_from_expr(arena, r_expr);
e_msg_list_concat_in_place(&result.msgs, &r_tree.msgs);
// rjf: fill output
result.root = &e_irnode_nil;
result.type_key = r_tree.type_key;
result.mode = E_Mode_Null;
result.space = r_tree.space;
}break;
//- rjf: byteswap
case E_ExprKind_ByteSwap:
{
+15 -13
View File
@@ -14,7 +14,7 @@ str8_lit_comp("CharLiteral"),
str8_lit_comp("Symbol"),
};
String8 e_expr_kind_strings[46] =
String8 e_expr_kind_strings[47] =
{
str8_lit_comp("Nil"),
str8_lit_comp("Ref"),
@@ -24,6 +24,7 @@ str8_lit_comp("Deref"),
str8_lit_comp("Address"),
str8_lit_comp("Cast"),
str8_lit_comp("Sizeof"),
str8_lit_comp("Typeof"),
str8_lit_comp("ByteSwap"),
str8_lit_comp("Neg"),
str8_lit_comp("LogNot"),
@@ -79,7 +80,7 @@ str8_lit_comp("Insufficient evaluation machine stack space."),
str8_lit_comp("Malformed bytecode."),
};
E_OpInfo e_expr_kind_op_info_table[46] =
E_OpInfo e_expr_kind_op_info_table[47] =
{
{ 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("") },
@@ -89,6 +90,7 @@ E_OpInfo e_expr_kind_op_info_table[46] =
{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("&"), str8_lit_comp(""), str8_lit_comp("") },
{ E_OpKind_Null, 1, str8_lit_comp("("), str8_lit_comp(")"), str8_lit_comp("") },
{ E_OpKind_UnaryPrefix, 1, str8_lit_comp("sizeof"), str8_lit_comp(""), str8_lit_comp("") },
{ E_OpKind_UnaryPrefix, 1, str8_lit_comp("typeof"), str8_lit_comp(""), str8_lit_comp("") },
{ E_OpKind_UnaryPrefix, 1, str8_lit_comp("bswap"), str8_lit_comp("("), str8_lit_comp(")") },
{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("-"), str8_lit_comp(""), str8_lit_comp("") },
{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("!"), str8_lit_comp(""), str8_lit_comp("") },
@@ -227,14 +229,14 @@ 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("modifier"),
str8_lit_comp("ptr"),
str8_lit_comp("lref"),
str8_lit_comp("rref"),
str8_lit_comp("array"),
str8_lit_comp("function"),
str8_lit_comp("method"),
str8_lit_comp("member_ptr"),
str8_lit_comp("struct"),
str8_lit_comp("class"),
str8_lit_comp("union"),
@@ -244,9 +246,9 @@ str8_lit_comp("struct"),
str8_lit_comp("union"),
str8_lit_comp("class"),
str8_lit_comp("enum"),
str8_lit_comp(""),
str8_lit_comp(""),
str8_lit_comp(""),
str8_lit_comp("bitfield"),
str8_lit_comp("variadic"),
str8_lit_comp("collection"),
};
C_LINKAGE_END
+3 -2
View File
@@ -99,6 +99,7 @@ E_ExprKind_Deref,
E_ExprKind_Address,
E_ExprKind_Cast,
E_ExprKind_Sizeof,
E_ExprKind_Typeof,
E_ExprKind_ByteSwap,
E_ExprKind_Neg,
E_ExprKind_LogNot,
@@ -158,9 +159,9 @@ E_InterpretationCode_COUNT,
C_LINKAGE_BEGIN
extern String8 e_token_kind_strings[6];
extern String8 e_expr_kind_strings[46];
extern String8 e_expr_kind_strings[47];
extern String8 e_interpretation_code_display_strings[11];
extern E_OpInfo e_expr_kind_op_info_table[46];
extern E_OpInfo e_expr_kind_op_info_table[47];
extern U8 e_kind_basic_byte_size_table[56];
extern String8 e_kind_basic_string_table[56];