aboutsummaryrefslogtreecommitdiff
path: root/chunk.d
diff options
context:
space:
mode:
authorBen Winston2023-05-21 20:26:59 -0400
committerBen Winston2023-05-21 20:26:59 -0400
commit8e1f84b1369909745859777d07a5e8e74b5df334 (patch)
tree460f42755407e9ddf1b3e6dfabea6a09b3d1585d /chunk.d
parenta26bfccdc52ab50a83b8f8d170c9e1a3be0164a5 (diff)
move disassembly into compiler, preparing for functions
Diffstat (limited to 'chunk.d')
-rw-r--r--chunk.d12
1 files changed, 8 insertions, 4 deletions
diff --git a/chunk.d b/chunk.d
index 87c9fb6..c512f14 100644
--- a/chunk.d
+++ b/chunk.d
@@ -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);
}
}
}