aboutsummaryrefslogtreecommitdiff
path: root/src/context.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/context.ts')
-rw-r--r--src/context.ts12
1 files changed, 12 insertions, 0 deletions
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<string, string> = 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()),