diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-03-26 18:26:39 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-03-26 18:26:39 -0700 |
| commit | a72bfd00cf07da50a94a024d6f74167aa41382c5 (patch) | |
| tree | 8fe496f8fc343f58f8dc315dad4d5638ab303a8c /src | |
| parent | a217ad59c770eb3915f5b98f177a012181b7f48e (diff) | |
| download | zig-a72bfd00cf07da50a94a024d6f74167aa41382c5.tar.gz zig-a72bfd00cf07da50a94a024d6f74167aa41382c5.zip | |
astgen: fix continue expressions
Diffstat (limited to 'src')
| -rw-r--r-- | src/astgen.zig | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/astgen.zig b/src/astgen.zig index 664a37c9d1..d01bc46515 100644 --- a/src/astgen.zig +++ b/src/astgen.zig @@ -766,11 +766,9 @@ fn breakExpr(mod: *Module, parent_scope: *Scope, node: ast.Node.Index) InnerErro } fn continueExpr(mod: *Module, parent_scope: *Scope, node: ast.Node.Index) InnerError!zir.Inst.Ref { - if (true) @panic("TODO update for zir-memory-layout"); - const tree = parent_scope.tree(); + const parent_gz = parent_scope.getGenZir(); + const tree = parent_gz.tree(); const node_datas = tree.nodes.items(.data); - const main_tokens = tree.nodes.items(.main_token); - const break_label = node_datas[node].lhs; // Look for the label in the scope. @@ -779,10 +777,11 @@ fn continueExpr(mod: *Module, parent_scope: *Scope, node: ast.Node.Index) InnerE switch (scope.tag) { .gen_zir => { const gen_zir = scope.cast(Scope.GenZir).?; - const continue_block = gen_zir.continue_block orelse { + const continue_block = gen_zir.continue_block; + if (continue_block == 0) { scope = gen_zir.parent; continue; - }; + } if (break_label != 0) blk: { if (gen_zir.label) |*label| { if (try tokenIdentEql(mod, parent_scope, label.token, break_label)) { @@ -795,9 +794,8 @@ fn continueExpr(mod: *Module, parent_scope: *Scope, node: ast.Node.Index) InnerE continue; } - _ = try addZirInstTag(mod, parent_scope, src, .break_void, .{ - .block = continue_block, - }); + // TODO emit a break_inline if the loop being continued is inline + _ = try parent_gz.addBreak(.@"break", continue_block, .void_value); return zir.Inst.Ref.unreachable_value; }, .local_val => scope = scope.cast(Scope.LocalVal).?.parent, @@ -806,7 +804,7 @@ fn continueExpr(mod: *Module, parent_scope: *Scope, node: ast.Node.Index) InnerE const label_name = try mod.identifierTokenString(parent_scope, break_label); return mod.failTok(parent_scope, break_label, "label not found: '{s}'", .{label_name}); } else { - return mod.failTok(parent_scope, src, "continue expression outside loop", .{}); + return mod.failNode(parent_scope, node, "continue expression outside loop", .{}); }, } } |
