mathjslab
Version:
MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.
69 lines (68 loc) • 2.5 kB
TypeScript
import type { ClassMethodDefinition as ClassMethodDefinitionBase } from './ClassMember';
import type { ClassInstance } from './ClassInstance';
import type { ClassDefinition } from './ClassDefinition';
import type { RuntimeDisplay } from './RuntimeDisplay';
type ClassMethodDefinition = ClassMethodDefinitionBase<ClassDefinition>;
/**
* Runtime value representing an instance method already bound to an object.
*/
declare class ClassBoundMethod {
/** Runtime type tag used by interpreter predicates. */
static readonly CLASS_BOUND_METHOD = 8;
/** Runtime type tag stored on the bound method. */
readonly type = 8;
/** Optional AST-style parent pointer used by generic value handling. */
parent?: unknown;
/** Object instance that will be supplied as the receiver. */
readonly instance: ClassInstance;
/** Method metadata selected from the receiver class. */
readonly method: ClassMethodDefinition;
/**
* Test whether a value is a bound class method.
*
* @param obj Value to test.
* @returns `true` when `obj` is a `ClassBoundMethod`.
*/
static readonly isInstanceOf: (obj: unknown) => obj is ClassBoundMethod;
/**
* Create a bound method value.
*
* @param instance Receiver instance.
* @param method Method metadata.
*/
constructor(instance: ClassInstance, method: ClassMethodDefinition);
/**
* Bind a method to a receiver instance.
*
* @param instance Receiver instance.
* @param method Method metadata.
* @returns Bound method value.
*/
static readonly bind: (instance: ClassInstance, method: ClassMethodDefinition) => ClassBoundMethod;
/**
* Copy a bound method value.
*
* @param boundMethod Bound method to copy.
* @returns New bound method wrapper.
*/
static readonly copy: (boundMethod: ClassBoundMethod) => ClassBoundMethod;
/**
* Render a compact method summary.
*
* @param boundMethod Bound method to render.
* @param _interpreter Interpreter requesting unparse.
* @returns Human-readable method summary.
*/
static readonly unparse: (boundMethod: ClassBoundMethod, _interpreter: RuntimeDisplay) => string;
/**
* Copy this bound method value.
*
* @returns New bound method wrapper.
*/
copy(): ClassBoundMethod;
}
export { ClassBoundMethod };
declare const _default: {
ClassBoundMethod: typeof ClassBoundMethod;
};
export default _default;