From b2a3dc3b78dd6ce60b7c5e685fbbb40c84434691 Mon Sep 17 00:00:00 2001 From: mryouse Date: Thu, 25 May 2023 01:59:59 +0000 Subject: add nil value --- dbg.d | 2 ++ vm.d | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dbg.d b/dbg.d index 19e92b1..e6ec197 100644 --- a/dbg.d +++ b/dbg.d @@ -82,6 +82,8 @@ string printableValue(Value val) { return printableFunction(val.as.obj); case ValueType.TYPE: return val.as.type; + case ValueType.NIL: + return "nil"; default: return "! unknown value type !"; } diff --git a/vm.d b/vm.d index 6fc6df7..ff2eb1d 100644 --- a/vm.d +++ b/vm.d @@ -223,7 +223,6 @@ class VM { InterpretResult run() { writeln("== VM running =="); - writefln("> > > framecount: %d", this.frameCount); while (true) { if (DEBUG) { writeln(" Stacks:"); @@ -264,6 +263,8 @@ class VM { } Value val = this.popA(); this.globals[asString(name)] = val; + Value nil = { ValueType.NIL }; + this.pushA(nil); break; case OpCode.OP_GET_GLOBAL: Value name = this.current.func.chunk.constants[this.readByte()]; -- cgit v1.2.3