diff options
| author | gingerBill <bill@gingerbill.org> | 2018-09-02 15:56:36 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-09-02 15:56:36 +0100 |
| commit | 220485a2d2cd180e7ff2a15bab66c867c06b05d7 (patch) | |
| tree | 4b3df1aae33e7b2af9375b1f8e11d8c2b2b88a15 /src/check_expr.cpp | |
| parent | eb274cf31600814b2f808c80d43376b0e9e959f1 (diff) | |
`typeid` as keyword (ready to implement polymorphic name parameters)
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 93f2f5fe9..f26e487b8 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -3200,10 +3200,8 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 add_type_info_type(c, t); t = base_type(t); - if (is_operand_value(o) && are_types_identical(t, t_type_info_ptr)) { - add_package_dependency(c, "runtime", "__typeid_of"); - } else if (o.mode != Addressing_Type) { - error(expr, "Expected a type or type info for 'typeid_of'"); + if (o.mode != Addressing_Type) { + error(expr, "Expected a type for 'typeid_of'"); return false; } @@ -6069,6 +6067,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type } case_end; + case Ast_TypeidType: case Ast_TypeType: case Ast_PolyType: case Ast_ProcType: @@ -6077,7 +6076,6 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type case Ast_DynamicArrayType: case Ast_StructType: case Ast_UnionType: - // case Ast_RawUnionType: case Ast_EnumType: case Ast_MapType: o->mode = Addressing_Type; @@ -6512,6 +6510,14 @@ gbString write_expr_to_string(gbString str, Ast *node) { } case_end; + case_ast_node(tt, TypeidType, node); + str = gb_string_appendc(str, "typeid"); + if (tt->specialization) { + str = gb_string_appendc(str, "/"); + str = write_expr_to_string(str, tt->specialization); + } + case_end; + case_ast_node(pt, ProcType, node); str = gb_string_appendc(str, "proc("); str = write_expr_to_string(str, pt->params); |