import { ExecutionContext } from '../execution-context/ExecutionContext.mts'; import { ObjectValue, UndefinedValue, Value, PrivateName, type Arguments, BooleanValue, type PropertyKeyValue, NullValue, JSStringValue, type NativeSteps } from '../value.mts'; import { NormalCompletion, type PlainCompletion, ThrowCompletion } from '../completion.mts'; import { ClassFieldDefinitionRecord, PrivateElementRecord } from '../runtime-semantics/all.mts'; import { type Mutable } from '../utils/language.mts'; import type { ParseNode } from '../parser/ParseNode.mts'; import type { PlainEvaluator, ValueEvaluator } from '../evaluator.mts'; import { type BoundFunctionObject } from '../intrinsics/FunctionPrototype.mts'; import { type OrdinaryObject } from './all.mts'; import { Realm, EnvironmentRecord, ClassElementDefinitionRecord, type AbstractModuleRecord, type CanBeNativeSteps, type DefaultConstructorBuiltinFunction, type PrivateEnvironmentRecord, type ScriptRecord } from '#self'; export interface BaseFunctionObject extends OrdinaryObject { readonly Realm: Realm; InitialName: JSStringValue | NullValue; readonly Async: boolean; readonly IsClassConstructor: BooleanValue; Call(thisValue: Value, args: Arguments): ValueEvaluator; Construct(args: Arguments, newTarget: FunctionObject | UndefinedValue): ValueEvaluator; } export type Body = ParseNode.AsyncGeneratorBody | ParseNode.GeneratorBody | ParseNode.AsyncBody | ParseNode.FunctionBody | ParseNode.AsyncConciseBodyLike | ParseNode.ConciseBodyLike | ParseNode.ClassStaticBlockBody | ParseNode.AssignmentExpressionOrHigher; export interface ECMAScriptFunctionObject extends BaseFunctionObject { readonly Environment: EnvironmentRecord; readonly PrivateEnvironment: PrivateEnvironmentRecord | NullValue; readonly FormalParameters: ParseNode.FormalParameters; readonly ECMAScriptCode: Body | null; readonly ConstructorKind: 'base' | 'derived'; readonly ScriptOrModule: ScriptRecord | AbstractModuleRecord; readonly scriptId?: string; readonly ThisMode: 'lexical' | 'strict' | 'global'; readonly Strict: boolean; readonly HomeObject: ObjectValue | UndefinedValue; readonly SourceText: string; readonly Fields: readonly ClassFieldDefinitionRecord[]; readonly PrivateMethods: readonly PrivateElementRecord[]; readonly Elements: readonly ClassElementDefinitionRecord[]; readonly Initializers: readonly FunctionObject[]; readonly ClassFieldInitializerName: undefined | PropertyKeyValue | PrivateName; /** * Note: this is different than InitialName, which is used and observable in Function.prototype.toString. * This is only used in the inspector. */ HostInitialName: PropertyKeyValue | PrivateName; } export interface BuiltinFunctionObject extends BaseFunctionObject { readonly nativeFunction: NativeSteps; HostCapturedValues?: readonly Value[]; } export type FunctionObject = ECMAScriptFunctionObject | BuiltinFunctionObject | BoundFunctionObject; /** https://tc39.es/ecma262/#sec-ecmascript-function-objects */ /** https://tc39.es/ecma262/#sec-built-in-function-objects */ /** https://tc39.es/ecma262/#sec-tail-position-calls */ export declare function hasSourceTextInternalSlot(O: undefined | null | Value): O is FunctionObject & { readonly SourceText: string; }; export declare function isECMAScriptFunctionObject(O: undefined | null | Value): O is ECMAScriptFunctionObject; export declare function isBuiltinFunctionObject(O: undefined | null | Value): O is BuiltinFunctionObject; export declare function isFunctionObject(O: Value): O is FunctionObject; /** https://tc39.es/ecma262/#sec-prepareforordinarycall */ export declare function PrepareForOrdinaryCall(F: ECMAScriptFunctionObject, newTarget: ObjectValue | UndefinedValue): ExecutionContext; /** https://tc39.es/ecma262/#sec-ordinarycallbindthis */ export declare function OrdinaryCallBindThis(F: ECMAScriptFunctionObject, calleeContext: ExecutionContext, thisArgument: Value): PlainCompletion; /** https://tc39.es/ecma262/#sec-ordinarycallevaluatebody */ export declare function OrdinaryCallEvaluateBody(F: ECMAScriptFunctionObject, argumentsList: Arguments): Generator | NormalCompletion | { readonly Type: 'return'; readonly Value: Value; readonly Target: undefined; mark(m: import("#self").GCMarker): void; } | ThrowCompletion, import("#self").EvaluatorNextType>; /** https://tc39.es/ecma262/#sec-definefield */ export declare function DefineField(receiver: ObjectValue, fieldRecord: ClassFieldDefinitionRecord): PlainEvaluator; /** https://tc39.es/ecma262/#sec-initializeinstanceelements */ /** https://arai-a.github.io/ecma262-compare/snapshot.html?pr=2417#sec-initializeinstanceelements */ export declare function InitializeInstanceElements(O: ObjectValue, constructor: ECMAScriptFunctionObject | DefaultConstructorBuiltinFunction): PlainEvaluator; /** https://arai-a.github.io/ecma262-compare/snapshot.html?pr=2417#sec-initializefieldoraccessor */ export declare function InitializeFieldOrAccessor(receiver: ObjectValue, elementRecord: ClassElementDefinitionRecord): PlainEvaluator; /** https://tc39.es/ecma262/#sec-functionallocate */ export declare function OrdinaryFunctionCreate(functionPrototype: ObjectValue, sourceText: string, ParameterList: ParseNode.FormalParameters, Body: Body, thisMode: 'lexical-this' | 'non-lexical-this', Scope: EnvironmentRecord, PrivateEnv: PrivateEnvironmentRecord | NullValue): Mutable; /** https://tc39.es/ecma262/#sec-makeconstructor */ export declare function MakeConstructor(F: Mutable | BuiltinFunctionObject, writablePrototype?: BooleanValue, prototype?: ObjectValue): void; /** https://tc39.es/ecma262/#sec-makeclassconstructor */ export declare function MakeClassConstructor(F: Mutable): void; /** https://tc39.es/ecma262/#sec-makemethod */ export declare function MakeMethod(F: Mutable, homeObject: ObjectValue): void; /** https://arai-a.github.io/ecma262-compare/snapshot.html?pr=2417#sec-definemethodproperty */ export declare function DefineMethodProperty(homeObject: ObjectValue, methodDefinition: ClassElementDefinitionRecord, enumerable: boolean): PlainEvaluator; /** https://tc39.es/ecma262/#sec-setfunctionname */ export declare function SetFunctionName(func: FunctionObject, name: PropertyKeyValue | PrivateName, prefix?: JSStringValue): void; /** https://tc39.es/ecma262/#sec-setfunctionlength */ export declare function SetFunctionLength(F: FunctionObject, length: number): void; /** https://tc39.es/ecma262/#sec-createbuiltinfunction */ export declare function CreateBuiltinFunction(behaviour: NativeSteps, length: number, name: string | PropertyKeyValue | PrivateName, additionalInternalSlotsList: readonly string[], realm?: Realm, prototype?: ObjectValue | NullValue, prefix?: JSStringValue, async?: boolean): BuiltinFunctionObject; export declare namespace CreateBuiltinFunction { var from: (steps: CanBeNativeSteps, name?: string, async?: boolean) => BuiltinFunctionObject; } export declare function markBuiltinFunctionAsConstructor(steps: NativeSteps): NativeSteps; /** https://tc39.es/ecma262/#sec-preparefortailcall */ export declare function PrepareForTailCall(): void; /** https://tc39.es/proposal-shadowrealm/#sec-copynameandlength */ export declare function CopyNameAndLength(F: FunctionObject, Target: FunctionObject, prefix?: string, argCount?: number): PlainEvaluator; /** NON-SPEC */ export declare function IntrinsicsFunctionToString(F: FunctionObject): string; //# sourceMappingURL=function-operations.d.mts.map