| 1 | module scheme |
| 2 | |
| 3 | import reader |
| 4 | |
| 5 | fn (mut b Builder) guarded_sequence(name string, nodes []reader.NodeId, tail bool, origin reader.NodeId) ! { |
| 6 | check_arity(name, nodes.len - 1, 2, -1)! |
| 7 | b.expression(nodes[1], false) |
| 8 | branch := b.emit(.jump_false, 0, 0, origin) |
| 9 | if name == 'when' { |
| 10 | b.sequence(nodes[2..], tail) |
| 11 | } else { |
| 12 | b.constant(unspecified(), origin) |
| 13 | } |
| 14 | finish := b.emit(.jump, 0, 0, origin) |
| 15 | b.patch(branch, b.function.instructions.len) |
| 16 | if name == 'unless' { |
| 17 | b.sequence(nodes[2..], tail) |
| 18 | } else { |
| 19 | b.constant(unspecified(), origin) |
| 20 | } |
| 21 | b.patch(finish, b.function.instructions.len) |
| 22 | } |
| 23 | |