From 8ba316461d2dc0a1372af16836ce14ceabc2bf4f Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 13 Jan 2023 19:21:41 +0530 Subject: feat: adds test to stdlib + refactors runtime environment --- src/context.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/context.ts') diff --git a/src/context.ts b/src/context.ts index 6b7875c..485083a 100644 --- a/src/context.ts +++ b/src/context.ts @@ -2,6 +2,7 @@ import { Project, ScriptTarget, Type, Node, SyntaxKind } from 'ts-morph' import path from 'path' import { v4 as uuid } from 'uuid' import { Ctx } from './types' +import { evaluateType } from './eval' const RESULT_TYPE_NAME = '__$result' @@ -72,6 +73,9 @@ export const createContext = (options: CtxOptions): Ctx => { return key } + let currentEnv = 'node' + const setEnv = (e: string) => (currentEnv = e) + const ctx: Ctx = { sourceFile, typeChecker, @@ -79,6 +83,9 @@ export const createContext = (options: CtxOptions): Ctx => { typeToString, getTypeValue, + get currentEnv() { return currentEnv }, + setEnv, + createRef, getRef: (k: string) => refMap.get(k), setRef: (k: string, ty: string) => refMap.set(k, ty), @@ -101,6 +108,8 @@ export const createContext = (options: CtxOptions): Ctx => { return [] }, hasCustomEffect: (name) => customEffects[name] !== undefined, + + evaluateType, } return ctx -- cgit v1.3.1