aboutsummaryrefslogtreecommitdiff
path: root/src/context.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2023-01-12 18:41:49 +0530
committerAkshay Nair <phenax5@gmail.com>2023-01-12 18:41:49 +0530
commita107048f87828b87b3bd55db1b6217710c40ee84 (patch)
tree2aa04a13f0d2987cc3eb7efe979d77834e2b57ce /src/context.ts
parent3020be98876613b19dcc79f6cc8cade12460ba48 (diff)
downloadts-types-lang-a107048f87828b87b3bd55db1b6217710c40ee84.tar.gz
ts-types-lang-a107048f87828b87b3bd55db1b6217710c40ee84.zip
feat: adds mutable reference effects
Diffstat (limited to '')
-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()),