diff options
| author | mryouse | 2023-05-27 01:23:03 +0000 |
|---|---|---|
| committer | mryouse | 2023-05-27 01:23:03 +0000 |
| commit | d21a835072674939527ee327cb34049c072d7e75 (patch) | |
| tree | 1c8eaa0fdd317fb1d18ea51eacad1c0737639bc3 /compiler.d | |
| parent | 21eff156a3094c82ad85f8d3658fc1ac79c63da1 (diff) | |
division
Diffstat (limited to 'compiler.d')
| -rw-r--r-- | compiler.d | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -255,6 +255,19 @@ class Compiler { } } + void compileDivide(Form[] args) { + if (args.length != 2) { + this.error(format("'/': expected [2] arguments, received %d", args.length), -1); + this.advance(); + return; + } + ValueType vt = this.resolve(args[0], ValueType.NUMBER); + this.func.chunk.writeOp(OpCode.OP_TYPE_CHECK_NUMBER, args[0].line); + vt = this.resolve(args[1], ValueType.NUMBER); + this.func.chunk.writeOp(OpCode.OP_TYPE_CHECK_NUMBER, args[1].line); + this.func.chunk.writeOp(OpCode.OP_DIVIDE, args[1].line); + } + //ValueType compileLess(Form[] args, ValueType expected = ValueType.ANY) { ValueType compileLess(Form[] args, ValueType expected) { if (args.length != 2) { @@ -851,6 +864,9 @@ class Compiler { case "*": this.compileMultiply(cons.tail); break; + case "/": + this.compileDivide(cons.tail); + break; // BOOLEAN case "<": |
