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 /chunk.d | |
| parent | a26bfccdc52ab50a83b8f8d170c9e1a3be0164a5 (diff) | |
move disassembly into compiler, preparing for functions
Diffstat (limited to 'chunk.d')
| -rw-r--r-- | chunk.d | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -6,6 +6,7 @@ import parser; enum ObjType { FUNCTION, + SCRIPT, } abstract class Obj { @@ -14,19 +15,22 @@ abstract class Obj { class Function : Obj { Chunk chunk; + int arity; string name; + ObjType type; - this() { - this.type = ObjType.FUNCTION; + this(ObjType type) { + this.type = type; this.chunk = new Chunk(); + this.arity = 0; this.name = ""; } override string toString() { - if (name == "") { + if (type == ObjType.SCRIPT) { return "<neb>"; } else { - return name; + return format("<fn %s>", name); } } } |
