aboutsummaryrefslogtreecommitdiff
path: root/compiler.d
diff options
context:
space:
mode:
Diffstat (limited to 'compiler.d')
-rw-r--r--compiler.d19
1 files changed, 7 insertions, 12 deletions
diff --git a/compiler.d b/compiler.d
index 6482f50..ae4cb4a 100644
--- a/compiler.d
+++ b/compiler.d
@@ -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++;
}
}