UNPKG

js-slang

Version:

Javascript-based implementations of Source, written in Typescript

31 lines (30 loc) 1.34 kB
import type es from 'estree'; import { type Context, type Environment, type Node, type Value } from '../types'; import Closure from './closure'; declare class Thunk { exp: Node; env: Environment; value: Value; isMemoized: boolean; constructor(exp: Node, env: Environment); } export declare function actualValue(exp: Node, context: Context): Value; export declare const createBlockEnvironment: (context: Context, name?: string) => Environment; export declare const pushEnvironment: (context: Context, environment: Environment) => void; export type Evaluator<T extends Node> = (node: T, context: Context) => IterableIterator<Value>; /** * WARNING: Do not use object literal shorthands, e.g. * { * *Literal(node: es.Literal, ...) {...}, * *ThisExpression(node: es.ThisExpression, ..._ {...}, * ... * } * They do not minify well, raising uncaught syntax errors in production. * See: https://github.com/webpack/webpack/issues/7566 */ export declare const evaluators: { [nodeType: string]: Evaluator<Node>; }; export declare function evaluateProgram(program: es.Program, context: Context): Generator<any, any, any>; export declare function apply(context: Context, fun: Closure | Value, args: (Thunk | Value)[], node: es.CallExpression, thisContext?: Value): Generator<any, any, any>; export {};