no valueFunctions
This commit is contained in:
parent
59fe509889
commit
c8362e106d
6
bin/repl
6
bin/repl
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bun
|
#!/usr/bin/env bun
|
||||||
|
|
||||||
import { Compiler } from '../src/compiler/compiler'
|
import { Compiler } from '../src/compiler/compiler'
|
||||||
import { colors, formatValue, nativeFunctions, valueFunctions } from '../src/prelude'
|
import { colors, formatValue, nativeFunctions } from '../src/prelude'
|
||||||
import { VM, Scope, bytecodeToString } from 'reefvm'
|
import { VM, Scope, bytecodeToString } from 'reefvm'
|
||||||
import * as readline from 'readline'
|
import * as readline from 'readline'
|
||||||
import { readFileSync, writeFileSync } from 'fs'
|
import { readFileSync, writeFileSync } from 'fs'
|
||||||
|
|
@ -48,7 +48,7 @@ async function repl() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
vm ||= new VM({ instructions: [], constants: [] }, nativeFunctions, valueFunctions)
|
vm ||= new VM({ instructions: [], constants: [] }, nativeFunctions)
|
||||||
|
|
||||||
if (['/exit', 'exit', '/quit', 'quit'].includes(trimmed)) {
|
if (['/exit', 'exit', '/quit', 'quit'].includes(trimmed)) {
|
||||||
console.log(`\n${colors.yellow}Goodbye!${colors.reset}`)
|
console.log(`\n${colors.yellow}Goodbye!${colors.reset}`)
|
||||||
|
|
@ -211,7 +211,7 @@ async function loadFile(filePath: string): Promise<{ vm: VM; codeHistory: string
|
||||||
|
|
||||||
console.log(`${colors.dim}Loading ${basename(filePath)}...${colors.reset}`)
|
console.log(`${colors.dim}Loading ${basename(filePath)}...${colors.reset}`)
|
||||||
|
|
||||||
const vm = new VM({ instructions: [], constants: [] }, nativeFunctions, valueFunctions)
|
const vm = new VM({ instructions: [], constants: [] }, nativeFunctions)
|
||||||
await vm.run()
|
await vm.run()
|
||||||
|
|
||||||
const codeHistory: string[] = []
|
const codeHistory: string[] = []
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bun
|
#!/usr/bin/env bun
|
||||||
|
|
||||||
import { Compiler } from '../src/compiler/compiler'
|
import { Compiler } from '../src/compiler/compiler'
|
||||||
import { colors, nativeFunctions, valueFunctions } from '../src/prelude'
|
import { colors, nativeFunctions } from '../src/prelude'
|
||||||
import { VM, fromValue, bytecodeToString } from 'reefvm'
|
import { VM, fromValue, bytecodeToString } from 'reefvm'
|
||||||
import { readFileSync, writeFileSync, mkdirSync } from 'fs'
|
import { readFileSync, writeFileSync, mkdirSync } from 'fs'
|
||||||
import { randomUUID } from "crypto"
|
import { randomUUID } from "crypto"
|
||||||
|
|
@ -12,7 +12,7 @@ async function runFile(filePath: string) {
|
||||||
try {
|
try {
|
||||||
const code = readFileSync(filePath, 'utf-8')
|
const code = readFileSync(filePath, 'utf-8')
|
||||||
const compiler = new Compiler(code)
|
const compiler = new Compiler(code)
|
||||||
const vm = new VM(compiler.bytecode, nativeFunctions, valueFunctions)
|
const vm = new VM(compiler.bytecode, nativeFunctions)
|
||||||
await vm.run()
|
await vm.run()
|
||||||
return vm.stack.length ? fromValue(vm.stack[vm.stack.length - 1]) : null
|
return vm.stack.length ? fromValue(vm.stack[vm.stack.length - 1]) : null
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user