diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-05-18 13:30:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-18 13:30:25 -0400 |
| commit | 83a78094788038fcf487e5947945a1f5900d564a (patch) | |
| tree | a8639a11bea5a2fc2b9c5aebf30011f7675f37d7 /src/ir.cpp | |
| parent | 942d384831196acf24868c32ef84409b05441960 (diff) | |
| parent | c38b165db4a16ba6a5c6d13537177db656fc4033 (diff) | |
| download | zig-83a78094788038fcf487e5947945a1f5900d564a.tar.gz zig-83a78094788038fcf487e5947945a1f5900d564a.zip | |
Merge pull request #1019 from zig-lang/pointer-reform
Pointer Reform - change prefix deref syntax to postfix deref syntax
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index cade660651..e2cbba48a7 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -4609,8 +4609,14 @@ static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode } static IrInstruction *ir_gen_prefix_op_id_lval(IrBuilder *irb, Scope *scope, AstNode *node, IrUnOp op_id, LVal lval) { - assert(node->type == NodeTypePrefixOpExpr); - AstNode *expr_node = node->data.prefix_op_expr.primary_expr; + AstNode *expr_node; + if (node->type == NodeTypePrefixOpExpr) { + expr_node = node->data.prefix_op_expr.primary_expr; + } else if (node->type == NodeTypePtrDeref) { + expr_node = node->data.ptr_deref_expr.target; + } else { + zig_unreachable(); + } IrInstruction *value = ir_gen_node_extra(irb, expr_node, scope, lval); if (value == irb->codegen->invalid_instruction) @@ -4751,8 +4757,6 @@ static IrInstruction *ir_gen_prefix_op_expr(IrBuilder *irb, Scope *scope, AstNod return ir_lval_wrap(irb, scope, ir_gen_prefix_op_id(irb, scope, node, IrUnOpNegation), lval); case PrefixOpNegationWrap: return ir_lval_wrap(irb, scope, ir_gen_prefix_op_id(irb, scope, node, IrUnOpNegationWrap), lval); - case PrefixOpDereference: - return ir_gen_prefix_op_id_lval(irb, scope, node, IrUnOpDereference, lval); case PrefixOpMaybe: return ir_lval_wrap(irb, scope, ir_gen_prefix_op_id(irb, scope, node, IrUnOpMaybe), lval); case PrefixOpUnwrapMaybe: @@ -6588,6 +6592,8 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop return ir_build_load_ptr(irb, scope, node, ptr_instruction); } + case NodeTypePtrDeref: + return ir_gen_prefix_op_id_lval(irb, scope, node, IrUnOpDereference, lval); case NodeTypeThisLiteral: return ir_lval_wrap(irb, scope, ir_gen_this_literal(irb, scope, node), lval); case NodeTypeBoolLiteral: |
