Scanning on Demand 16

This commit is contained in:
nazrin 2025-06-03 22:57:02 +00:00
parent aba643a88e
commit 8fb449825d
6 changed files with 209 additions and 32 deletions

View file

@ -6,6 +6,7 @@ import clox.chunk;
import clox.value;
import clox.dbg;
import clox.util;
import clox.compiler;
enum stackMax = 256;
@ -13,10 +14,14 @@ struct VM{
const(ubyte)* ip;
Stack!(Value, stackMax) stack;
Chunk* chunk;
enum InterpretResult{ Ok, CompileError, RunetimeError }
enum InterpretResult{ Ok, CompileError, RuntimeError }
this(int _) @nogc nothrow {
stack = typeof(stack)(0);
}
InterpretResult interpret(string source) @nogc nothrow {
compile(source);
return InterpretResult.Ok;
}
InterpretResult interpret(Chunk* chunk) @nogc nothrow {
this.chunk = chunk;
ip = &chunk.code[0];