From aa8ecb7cf66765d9f6383d591d5b15bbfff84117 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Sat, 25 Oct 2025 19:00:12 -0700 Subject: [PATCH] VM constructor also accepts valueFunctions --- src/vm.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/vm.ts b/src/vm.ts index aa3c948..b116f7d 100644 --- a/src/vm.ts +++ b/src/vm.ts @@ -19,15 +19,19 @@ export class VM { labels: Map = new Map() nativeFunctions: Map = new Map() - constructor(bytecode: Bytecode, functions?: Record) { + constructor(bytecode: Bytecode, nativeFunctions?: Record, valueFunctions?: Record) { this.instructions = bytecode.instructions this.constants = bytecode.constants this.labels = bytecode.labels || new Map() this.scope = new Scope() - if (functions) - for (const name of Object.keys(functions)) - this.registerFunction(name, functions[name]!) + if (nativeFunctions) + for (const name of Object.keys(nativeFunctions)) + this.registerFunction(name, nativeFunctions[name]!) + + if (valueFunctions) + for (const name of Object.keys(valueFunctions)) + this.registerValueFunction(name, valueFunctions[name]!) } async call(name: string, ...args: any) {