From a107048f87828b87b3bd55db1b6217710c40ee84 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Thu, 12 Jan 2023 18:41:49 +0530 Subject: feat: adds mutable reference effects --- src/context.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/context.ts') diff --git a/src/context.ts b/src/context.ts index bdae0d3..6b7875c 100644 --- a/src/context.ts +++ b/src/context.ts @@ -65,6 +65,13 @@ export const createContext = (options: CtxOptions): Ctx => { } } + const refMap: Map = new Map + const createRef = (ty: string): string => { + const key = uuid() + refMap.set(key, ty) + return key + } + const ctx: Ctx = { sourceFile, typeChecker, @@ -72,6 +79,11 @@ export const createContext = (options: CtxOptions): Ctx => { typeToString, getTypeValue, + createRef, + getRef: (k: string) => refMap.get(k), + setRef: (k: string, ty: string) => refMap.set(k, ty), + deleteRef: (k: string) => refMap.delete(k), + createResult, getResultExpr, printResultNode: () => console.log(resultTypeNode?.print()), -- cgit v1.3.1