UNPKG

js-slang

Version:

Javascript-based implementations of Source, written in Typescript

62 lines (61 loc) 2.28 kB
import * as es from 'estree'; import { Context, Environment } from '../types'; import { Control, Stash, Transformers } from './interpreter'; /** * A dummy function used to detect for the apply function object. * If the interpreter sees this specific function, it applies the function * with the given arguments to apply. * * We need this to be a metaprocedure so that it can properly handle * the arguments passed to it, even if they are continuations. */ export declare class Apply extends Function { private static instance; private constructor(); static get(): Apply; toString(): string; } export declare const apply: Apply; export declare function isApply(value: any): boolean; /** * A dummy function used to detect for the call/cc function object. * If the interpreter sees this specific function, a continuation at the current * point of evaluation is executed instead of a regular function call. */ export declare class Call_cc extends Function { private static instance; private constructor(); static get(): Call_cc; toString(): string; } export declare const call_with_current_continuation: Call_cc; export declare function isCallWithCurrentContinuation(value: any): boolean; /** * An object representing a continuation of the CSE machine. * When instantiated, it copies the control stack, and * current environment at the point of capture. * * Continuations and functions are treated as the same by * the typechecker so that they can be first-class values. */ export declare class Continuation extends Function { private control; private stash; private env; private transformers; /** Unique ID defined for continuation */ readonly id: string; constructor(context: Context, control: Control, stash: Stash, env: Environment[], transformers: Transformers); getControl(): Control; getStash(): Stash; getEnv(): Environment[]; getTransformers(): Transformers; toString(): string; equals(other: Continuation): boolean; } /** * Provides an adequate representation of what calling * call/cc or continuations looks like, to give to the * APPLICATION instruction. */ export declare function makeDummyContCallExpression(callee: string, argument: string): es.CallExpression;