UNPKG

js-slang

Version:

Javascript-based implementations of Source, written in Typescript

41 lines (40 loc) 1.47 kB
import * as es from 'estree'; import { Environment } from '../types'; import { Control, Stash } from './interpreter'; /** * 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; constructor(control: Control, stash: Stash, env: Environment[]); getControl(): Control; getStash(): Stash; getEnv(): Environment[]; toString(): string; } /** * 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;