lib exports
This commit is contained in:
parent
000eb7ad92
commit
d057bf4b10
|
|
@ -1,6 +1,4 @@
|
|||
import { toBytecode } from "#bytecode"
|
||||
import { VM } from "#vm"
|
||||
import { type Value, toString, toValue } from "#value"
|
||||
import { VM, toBytecode, type Value, toString, toNull } from "#reef"
|
||||
|
||||
const bytecode = toBytecode(`
|
||||
PUSH 5
|
||||
|
|
@ -13,7 +11,7 @@ const vm = new VM(bytecode)
|
|||
|
||||
vm.registerFunction('print', (...args: Value[]): Value => {
|
||||
console.log(...args.map(toString))
|
||||
return toValue(null)
|
||||
return toNull()
|
||||
})
|
||||
|
||||
console.write('5 + 10 = ')
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
import type { Bytecode } from "./bytecode"
|
||||
import type { Value } from "./value"
|
||||
import { type Value } from "./value"
|
||||
import { VM } from "./vm"
|
||||
|
||||
export async function run(bytecode: Bytecode): Promise<Value> {
|
||||
const vm = new VM(bytecode)
|
||||
return await vm.run()
|
||||
}
|
||||
|
||||
export { type Bytecode, toBytecode } from "./bytecode"
|
||||
export { type Value, toValue, toString, toNumber, toJs, toNull } from "./value"
|
||||
export { VM } from "./vm"
|
||||
|
|
@ -132,3 +132,7 @@ export function toJs(v: Value): any {
|
|||
case 'function': return '<function>'
|
||||
}
|
||||
}
|
||||
|
||||
export function toNull(): Value {
|
||||
return toValue(null)
|
||||
}
|
||||
|
|
@ -28,6 +28,9 @@
|
|||
"paths": {
|
||||
"#*": [
|
||||
"./src/*"
|
||||
],
|
||||
"#reef": [
|
||||
"./src/index.ts"
|
||||
]
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user