diff options
Diffstat (limited to 'compiler.d')
| -rw-r--r-- | compiler.d | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -242,6 +242,26 @@ class Compiler { } } + void compileOr(Form form) { + Or or_ = cast(Or)form; + + resolve(or_.clauses[0]); + int[] jumps; + jumps ~= jump(OpCode.OP_JUMP_IF_TRUE); + int count = 1; + while (count < or_.clauses.length) { + this.func.chunk.writeOp(OpCode.OP_POP, or_.line); + resolve(or_.clauses[count]); + jumps ~= jump(OpCode.OP_JUMP_IF_TRUE); + count++; + } + + // patch all the jumps + foreach (int jmp; jumps) { + patchJump(jmp); + } + } + void compileBlock(Form form) { Block block = cast(Block)form; beginScope(); @@ -327,6 +347,9 @@ class Compiler { case FormType.AND: this.compileAnd(form); break; + case FormType.OR: + this.compileOr(form); + break; default: write("not sure how to resolve: "); printForm(form); |
