diff options
| author | gingerBill <ginger.bill.22@gmail.com> | 2016-08-14 19:37:47 +0100 |
|---|---|---|
| committer | gingerBill <ginger.bill.22@gmail.com> | 2016-08-14 19:37:47 +0100 |
| commit | 0edae8c8482dd4763737b01deb09a4732a2f35ec (patch) | |
| tree | c15190cd0c55fa1e3db06591af89225d5087bf8e /src/checker/expr.cpp | |
| parent | b44bc99b889bb07dfe4f843ddeefd7483e0fba82 (diff) | |
Vector index works with booleans now.
Diffstat (limited to 'src/checker/expr.cpp')
| -rw-r--r-- | src/checker/expr.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/checker/expr.cpp b/src/checker/expr.cpp index ced7402af..bdae13257 100644 --- a/src/checker/expr.cpp +++ b/src/checker/expr.cpp @@ -610,10 +610,21 @@ void check_is_expressible(Checker *c, Operand *o, Type *type) { } } +b32 check_is_expr_vector_index(Checker *c, AstNode *expr) { + // HACK(bill): Handle this correctly. Maybe with a custom AddressingMode + expr = unparen_expr(expr); + if (expr->kind == AstNode_IndexExpr) { + ast_node(ie, IndexExpr, expr); + Type *t = get_base_type(type_of_expr(&c->info, ie->expr)); + return is_type_vector(t); + } + return false; +} void check_unary_expr(Checker *c, Operand *o, Token op, AstNode *node) { if (op.kind == Token_Pointer) { // Pointer address - if (o->mode != Addressing_Variable) { + if (o->mode != Addressing_Variable || + check_is_expr_vector_index(c, o->expr)) { ast_node(ue, UnaryExpr, node); gbString str = expr_to_string(ue->expr); defer (gb_string_free(str)); |