mathjslab
Version:
MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.
44 lines (43 loc) • 1.89 kB
TypeScript
import type { NodeExpr } from './AST';
import type { Callable } from './Callable';
import type { Scope } from './Scope';
/**
* Represents one interpreter call-frame.
*
* Frames are pushed for built-ins, user-defined functions, anonymous function
* handles, and temporary `eval` execution. They provide:
*
* - the active workspace for lookup and assignment,
* - the callable currently being executed,
* - metadata used by `nargin`, `nargout`, `inputname`, and stack traces,
* - a linked `parentFrame` chain for MATLAB/Octave-like caller lookup.
*
* `InterpreterError` remains in `Interpreter.ts`; this class is intentionally a
* small data holder so stack-management helpers can use it without depending on
* the full interpreter implementation.
*/
declare class CallFrame {
scope: Scope;
func?: Callable | undefined;
callSite?: NodeExpr | undefined;
name?: string | undefined;
nargin: number;
nargout: number;
inputArgs: NodeExpr[];
parentFrame?: CallFrame | undefined;
/**
* Create a call frame.
*
* @param scope Workspace associated with this frame.
* @param func Callable being executed, when the frame represents a call.
* @param callSite AST node that originated the call, used for diagnostics.
* @param name Display name used by stack traces and introspection.
* @param nargin Number of input arguments supplied by the caller.
* @param nargout Number of output values requested by the caller.
* @param inputArgs Original unevaluated argument nodes, used by `inputname`.
* @param parentFrame Caller frame.
*/
constructor(scope: Scope, func?: Callable | undefined, callSite?: NodeExpr | undefined, name?: string | undefined, nargin?: number, nargout?: number, inputArgs?: NodeExpr[], parentFrame?: CallFrame | undefined);
}
export { CallFrame };
export default CallFrame;