diff options
Diffstat (limited to 'src/eval.ts')
| -rw-r--r-- | src/eval.ts | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/eval.ts b/src/eval.ts index 12997b1..8b53982 100644 --- a/src/eval.ts +++ b/src/eval.ts @@ -4,7 +4,6 @@ import readline from 'readline' import { match } from './util' import { Ctx } from './types' -import { assert } from 'console' const rl = readline.createInterface({ input: process.stdin, @@ -39,6 +38,32 @@ export const evaluateType = async ( return [] }, + CreateRef: async () => { + const val = ctx.typeToString(args[0]) + const refKey = ctx.createRef(val) + const [resultKey, _] = ctx.createResult(JSON.stringify(refKey)) + return [resultKey] + }, + + GetRef: async () => { + const refKey = ctx.getTypeValue(args[0]) + const val = ctx.getRef(refKey) + if (!val) throw new Error('Ref has been deleted') + const [resultKey, _] = ctx.createResult(val) + return [resultKey] + }, + + SetRef: async () => { + const [ keyTy, valTyp ] = args + ctx.setRef(ctx.getTypeValue(keyTy), ctx.typeToString(valTyp)) + return [] + }, + + DeleteRef: async () => { + ctx.deleteRef(ctx.getTypeValue(args[0])) + return [] + }, + Pure: async () => { const [valTyp] = args const [resultKey, _] = ctx.createResult(ctx.typeToString(valTyp)) |
