9.2.1.1 PrepareForOrdinaryCall ( F, newTarget )
当使用函数对象 F 和 ECMAScript 语言值 newTarget 调用抽象操作 PrepareForOrdinaryCall 时,将执行以下步骤:
- Assert: Type(newTarget) is Undefined or Object.
- Let callerContext be the running execution context.
- Let _calleeContext _be a new ECMAScript code execution context.
- Set the Function of calleeContext _to _F.
- Let calleeRealm _be _F.[[Realm]].
- Set the Realm of calleeContext _to _calleeRealm.
- Set the ScriptOrModule of calleeContext _to _F.[[ScriptOrModule]]
- Let localEnv _be NewFunctionEnvironment(_F, newTarget).
- Set the LexicalEnvironment of calleeContext _to _localEnv
- Set the VariableEnvironment of calleeContext _to _localEnv.
- If callerContext _is not already suspended, suspend _callerContext.
- Push _calleeContext _onto the execution context stack; _calleeContext _is now the running execution context.
- NOTE Any exception objects produced after this point are associated with calleeRealm.
- Return calleeContext.
原文地址:https://tc39.github.io/ecma262/#sec-prepareforordinarycall