diff options
| author | gingerBill <ginger.bill.22@gmail.com> | 2016-08-23 11:11:01 +0100 |
|---|---|---|
| committer | gingerBill <ginger.bill.22@gmail.com> | 2016-08-23 11:11:01 +0100 |
| commit | 975705f1fc68af73b25ff135733c57d8cfd62912 (patch) | |
| tree | 97498decafa4cfd5a960ed8b329017f023315bb8 /src/checker/expr.cpp | |
| parent | aaecb18c8f37a7f7feb3400178633819859b642f (diff) | |
Infix and Postfix procedure calls
Diffstat (limited to 'src/checker/expr.cpp')
| -rw-r--r-- | src/checker/expr.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/checker/expr.cpp b/src/checker/expr.cpp index bd317c08d..63a87f3f5 100644 --- a/src/checker/expr.cpp +++ b/src/checker/expr.cpp @@ -1386,7 +1386,6 @@ Entity *lookup_field(Type *type, AstNode *field_node, isize *index = NULL) { } } break; - break; // TODO(bill): Other types and extra "hidden" fields (e.g. introspection stuff) // TODO(bill): Allow for access of field through index? e.g. `x.3` will get member of index 3 // Or is this only suitable if tuples are first-class? @@ -1402,7 +1401,14 @@ void check_selector(Checker *c, Operand *operand, AstNode *node) { AstNode *op_expr = se->expr; AstNode *selector = se->selector; if (selector) { - Entity *entity = lookup_field(operand->type, selector); + Entity *entity = NULL; + if (is_type_enum(operand->type)) { + if (operand->mode == Addressing_Type) { + entity = lookup_field(operand->type, selector); + } + } else { + entity = lookup_field(operand->type, selector); + } if (entity == NULL) { gbString op_str = expr_to_string(op_expr); gbString sel_str = expr_to_string(selector); @@ -2631,6 +2637,15 @@ gbString write_expr_to_string(gbString str, AstNode *node) { str = gb_string_appendc(str, "}"); case_end; + case_ast_node(et, EnumType, node); + str = gb_string_appendc(str, "enum "); + if (et->base_type != NULL) { + str = write_expr_to_string(str, et->base_type); + str = gb_string_appendc(str, " "); + } + str = gb_string_appendc(str, "{"); + str = gb_string_appendc(str, "}"); + case_end; } return str; |