diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-07-19 17:35:14 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-07-20 12:19:17 -0700 |
| commit | ea902ffe8f5f337b04f25b4efc69599db74d99ce (patch) | |
| tree | 7c0f184759b9ca8ebf9db49aa04ac91042eff705 /src/Air.zig | |
| parent | caa0de545e2f45a96ac3136178f478dab1c89ebd (diff) | |
| download | zig-ea902ffe8f5f337b04f25b4efc69599db74d99ce.tar.gz zig-ea902ffe8f5f337b04f25b4efc69599db74d99ce.zip | |
Sema: reimplement runtime switch
Now supports multiple items pointing to the same body. This is a common
pattern even when using a jump table, with multiple cases pointing to
the same block of code.
In the case of a range specified, the items are moved to branches in the
else body. A future improvement may make it possible to have jump table
items as well as ranges pointing to the same block of code.
Diffstat (limited to 'src/Air.zig')
| -rw-r--r-- | src/Air.zig | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Air.zig b/src/Air.zig index 0e19202244..718123818b 100644 --- a/src/Air.zig +++ b/src/Air.zig @@ -352,9 +352,10 @@ pub const SwitchBr = struct { else_body_len: u32, /// Trailing: + /// * item: Inst.Ref // for each `items_len`. /// * instruction index for each `body_len`. pub const Case = struct { - item: Inst.Ref, + items_len: u32, body_len: u32, }; }; |
