diff options
| author | Ben Winston | 2023-05-21 20:26:59 -0400 |
|---|---|---|
| committer | Ben Winston | 2023-05-21 20:26:59 -0400 |
| commit | 8e1f84b1369909745859777d07a5e8e74b5df334 (patch) | |
| tree | 460f42755407e9ddf1b3e6dfabea6a09b3d1585d /compiler.d | |
| parent | a26bfccdc52ab50a83b8f8d170c9e1a3be0164a5 (diff) | |
move disassembly into compiler, preparing for functions
Diffstat (limited to 'compiler.d')
| -rw-r--r-- | compiler.d | 19 |
1 files changed, 7 insertions, 12 deletions
@@ -7,11 +7,6 @@ import parser; import chunk; import dbg; -enum FunctionType { - FUNCTION, - SCRIPT, -} - struct Local { Symbol sym; int depth; @@ -20,7 +15,6 @@ struct Local { class Compiler { Function func; - FunctionType type; Parser* parser; Local[] locals; int localCount; @@ -369,15 +363,16 @@ class Compiler { Function finish() { this.func.chunk.writeOp(OpCode.OP_RETURN, current.line); + disassembleChunk(func.chunk, to!string(func)); return func; } - this(FunctionType type, Parser* parser) { + this(ObjType type, Parser* parser) { this.parser = parser; - this.func = new Function(); - this.type = type; - localCount = 0; - //locals ~= Local(new Symbol("", -1), 0); - //localCount++; + this.func = new Function(type); + //localCount = 0; + + locals ~= Local(new Symbol("", -1), 0); + localCount++; } } |
