Skip to content

Commit

Permalink
Normative: Add name and length paremeters to CreateBuiltinFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Jul 28, 2020
1 parent 464b597 commit ce0c88c
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -4151,10 +4151,10 @@ <h1>Await</h1>
1. Let _asyncContext_ be the running execution context.
1. Let _promise_ be ? PromiseResolve(%Promise%, _value_).
1. Let _stepsFulfilled_ be the algorithm steps defined in <emu-xref href="#await-fulfilled" title></emu-xref>.
1. Let _onFulfilled_ be ! CreateBuiltinFunction(_stepsFulfilled_, &laquo; [[AsyncContext]] &raquo;).
1. Let _onFulfilled_ be ! CreateBuiltinFunction(_stepsFulfilled_, *""*, *1*, &laquo; [[AsyncContext]] &raquo;).
1. Set _onFulfilled_.[[AsyncContext]] to _asyncContext_.
1. Let _stepsRejected_ be the algorithm steps defined in <emu-xref href="#await-rejected" title></emu-xref>.
1. Let _onRejected_ be ! CreateBuiltinFunction(_stepsRejected_, &laquo; [[AsyncContext]] &raquo;).
1. Let _onRejected_ be ! CreateBuiltinFunction(_stepsRejected_, *""*, *1*, &laquo; [[AsyncContext]] &raquo;).
1. Set _onRejected_.[[AsyncContext]] to _asyncContext_.
1. Perform ! PerformPromiseThen(_promise_, _onFulfilled_, _onRejected_).
1. Remove _asyncContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context.
Expand Down Expand Up @@ -7509,7 +7509,7 @@ <h1>CreateIntrinsics ( _realmRec_ )</h1>
<emu-alg>
1. Let _intrinsics_ be a new Record.
1. Set _realmRec_.[[Intrinsics]] to _intrinsics_.
1. Set fields of _intrinsics_ with the values listed in <emu-xref href="#table-7"></emu-xref>. The field names are the names listed in column one of the table. The value of each field is a new object value fully and recursively populated with property values as defined by the specification of each object in clauses 18-26. All object property values are newly created object values. All values that are built-in function objects are created by performing CreateBuiltinFunction(&lt;steps&gt;, &lt;slots&gt;, _realmRec_, &lt;prototype&gt;) where &lt;steps&gt; is the definition of that function provided by this specification, &lt;slots&gt; is a list of the names, if any, of the function's specified internal slots, and &lt;prototype&gt; is the specified value of the function's [[Prototype]] internal slot. The creation of the intrinsics and their properties must be ordered to avoid any dependencies upon objects that have not yet been created.
1. Set fields of _intrinsics_ with the values listed in <emu-xref href="#table-7"></emu-xref>. The field names are the names listed in column one of the table. The value of each field is a new object value fully and recursively populated with property values as defined by the specification of each object in clauses 18-26. All object property values are newly created object values. All values that are built-in function objects are created by performing CreateBuiltinFunction(&lt;steps&gt;, &lt;name&gt;, &lt;length&gt;, &lt;slots&gt;, _realmRec_, &lt;prototype&gt;) where &lt;steps&gt; is the definition of that function provided by this specification, &lt;slots&gt; is a list of the names, if any, of the function's specified internal slots, and &lt;prototype&gt; is the specified value of the function's [[Prototype]] internal slot. The creation of the intrinsics and their properties must be ordered to avoid any dependencies upon objects that have not yet been created.
1. Perform AddRestrictedFunctionProperties(_intrinsics_.[[%Function.prototype%]], _realmRec_).
1. Return _intrinsics_.
</emu-alg>
Expand Down Expand Up @@ -8871,8 +8871,8 @@ <h1>[[Construct]] ( _argumentsList_, _newTarget_ )</h1>
</emu-clause>

<emu-clause id="sec-createbuiltinfunction" aoid="CreateBuiltinFunction">
<h1>CreateBuiltinFunction ( _steps_ [ , _additionalInternalSlotsList_ [ , _realm_ [ , _prototype_ ] ] ] )</h1>
<p>The abstract operation CreateBuiltinFunction takes arguments _steps_ and optional arguments _additionalInternalSlotsList_ (a List of internal slot names), _realm_, and _prototype_. _additionalInternalSlotsList_ contains the names of additional internal slots that must be defined as part of the object. This operation creates a built-in function object. It performs the following steps when called:</p>
<h1>CreateBuiltinFunction ( _steps_ [ , _name_ [ , _length_ [ , _additionalInternalSlotsList_ [ , _realm_ [ , _prototype_ ] ] ] ] ] )</h1>
<p>The abstract operation CreateBuiltinFunction takes arguments _steps_ and optional arguments _name_, _length_, _additionalInternalSlotsList_ (a List of internal slot names), _realm_, and _prototype_. _additionalInternalSlotsList_ contains the names of additional internal slots that must be defined as part of the object. This operation creates a built-in function object. It performs the following steps when called:</p>
<emu-alg>
1. Assert: _steps_ is either a set of algorithm steps or other definition of a function's behaviour provided in this specification.
1. If _realm_ is not present, set _realm_ to the current Realm Record.
Expand All @@ -8885,6 +8885,10 @@ <h1>CreateBuiltinFunction ( _steps_ [ , _additionalInternalSlotsList_ [ , _realm
1. Set _func_.[[Prototype]] to _prototype_.
1. Set _func_.[[Realm]] to _realm_.
1. Set _func_.[[ScriptOrModule]] to *null*.
1. If _length_ is not present, set _length_ to *+0*.
1. Perform ! SetFunctionLength(_func_, _length_).
1. If _name_ is not present, set _name_ to the empty String.
1. Perform ! SetFunctionName(_func_, _name_).
1. Return _func_.
</emu-alg>
<p>Each built-in function defined in this specification is created by calling the CreateBuiltinFunction abstract operation.</p>
Expand Down Expand Up @@ -9385,7 +9389,7 @@ <h1>MakeArgGetter ( _name_, _env_ )</h1>
<p>The abstract operation MakeArgGetter takes arguments _name_ (a String) and _env_ (an Environment Record). It creates a built-in function object that when executed returns the value bound for _name_ in _env_. It performs the following steps when called:</p>
<emu-alg>
1. Let _steps_ be the steps of an ArgGetter function as specified below.
1. Let _getter_ be ! CreateBuiltinFunction(_steps_, &laquo; [[Name]], [[Env]] &raquo;).
1. Let _getter_ be ! CreateBuiltinFunction(_steps_, *""*, *+0*, &laquo; [[Name]], [[Env]] &raquo;).
1. Set _getter_.[[Name]] to _name_.
1. Set _getter_.[[Env]] to _env_.
1. Return _getter_.
Expand All @@ -9407,7 +9411,7 @@ <h1>MakeArgSetter ( _name_, _env_ )</h1>
<p>The abstract operation MakeArgSetter takes arguments _name_ (a String) and _env_ (an Environment Record). It creates a built-in function object that when executed sets the value bound for _name_ in _env_. It performs the following steps when called:</p>
<emu-alg>
1. Let _steps_ be the steps of an ArgSetter function as specified below.
1. Let _setter_ be ! CreateBuiltinFunction(_steps_, &laquo; [[Name]], [[Env]] &raquo;).
1. Let _setter_ be ! CreateBuiltinFunction(_steps_, *""*, *1*, &laquo; [[Name]], [[Env]] &raquo;).
1. Set _setter_.[[Name]] to _name_.
1. Set _setter_.[[Env]] to _env_.
1. Return _setter_.
Expand Down Expand Up @@ -25980,7 +25984,7 @@ <h1>Object.fromEntries ( _iterable_ )</h1>
1. Let _obj_ be OrdinaryObjectCreate(%Object.prototype%).
1. Assert: _obj_ is an extensible ordinary object with no own properties.
1. Let _stepsDefine_ be the algorithm steps defined in <emu-xref href="#sec-create-data-property-on-object-functions" title></emu-xref>.
1. Let _adder_ be ! CreateBuiltinFunction(_stepsDefine_).
1. Let _adder_ be ! CreateBuiltinFunction(_stepsDefine_, *""*, *2*).
1. Return ? AddEntriesFromIterable(_obj_, _iterable_, _adder_).
</emu-alg>
<emu-note>
Expand Down Expand Up @@ -39226,7 +39230,7 @@ <h1>AsyncFromSyncIteratorContinuation ( _result_, _promiseCapability_ )</h1>
1. Let _valueWrapper_ be PromiseResolve(%Promise%, _value_).
1. IfAbruptRejectPromise(_valueWrapper_, _promiseCapability_).
1. Let _steps_ be the algorithm steps defined in <emu-xref href="#sec-async-from-sync-iterator-value-unwrap-functions" title></emu-xref>.
1. Let _onFulfilled_ be ! CreateBuiltinFunction(_steps_, &laquo; [[Done]] &raquo;).
1. Let _onFulfilled_ be ! CreateBuiltinFunction(_steps_, *""*, *1*, &laquo; [[Done]] &raquo;).
1. Set _onFulfilled_.[[Done]] to _done_.
1. Perform ! PerformPromiseThen(_valueWrapper_, _onFulfilled_, *undefined*, _promiseCapability_).
1. Return _promiseCapability_.[[Promise]].
Expand Down Expand Up @@ -39856,10 +39860,10 @@ <h1>AsyncGeneratorResumeNext ( _generator_ )</h1>
1. Set _generator_.[[AsyncGeneratorState]] to ~awaiting-return~.
1. Let _promise_ be ? PromiseResolve(%Promise%, _completion_.[[Value]]).
1. Let _stepsFulfilled_ be the algorithm steps defined in <emu-xref href="#async-generator-resume-next-return-processor-fulfilled" title></emu-xref>.
1. Let _onFulfilled_ be ! CreateBuiltinFunction(_stepsFulfilled_, &laquo; [[Generator]] &raquo;).
1. Let _onFulfilled_ be ! CreateBuiltinFunction(_stepsFulfilled_, *""*, *1*, &laquo; [[Generator]] &raquo;).
1. Set _onFulfilled_.[[Generator]] to _generator_.
1. Let _stepsRejected_ be the algorithm steps defined in <emu-xref href="#async-generator-resume-next-return-processor-rejected" title></emu-xref>.
1. Let _onRejected_ be ! CreateBuiltinFunction(_stepsRejected_, &laquo; [[Generator]] &raquo;).
1. Let _onRejected_ be ! CreateBuiltinFunction(_stepsRejected_, *""*, *1*, &laquo; [[Generator]] &raquo;).
1. Set _onRejected_.[[Generator]] to _generator_.
1. Perform ! PerformPromiseThen(_promise_, _onFulfilled_, _onRejected_).
1. Return *undefined*.
Expand Down Expand Up @@ -40108,11 +40112,11 @@ <h1>CreateResolvingFunctions ( _promise_ )</h1>
<emu-alg>
1. Let _alreadyResolved_ be the Record { [[Value]]: *false* }.
1. Let _stepsResolve_ be the algorithm steps defined in <emu-xref href="#sec-promise-resolve-functions" title></emu-xref>.
1. Let _resolve_ be ! CreateBuiltinFunction(_stepsResolve_, &laquo; [[Promise]], [[AlreadyResolved]] &raquo;).
1. Let _resolve_ be ! CreateBuiltinFunction(_stepsResolve_, *""*, *1*, &laquo; [[Promise]], [[AlreadyResolved]] &raquo;).
1. Set _resolve_.[[Promise]] to _promise_.
1. Set _resolve_.[[AlreadyResolved]] to _alreadyResolved_.
1. Let _stepsReject_ be the algorithm steps defined in <emu-xref href="#sec-promise-reject-functions" title></emu-xref>.
1. Let _reject_ be ! CreateBuiltinFunction(_stepsReject_, &laquo; [[Promise]], [[AlreadyResolved]] &raquo;).
1. Let _reject_ be ! CreateBuiltinFunction(_stepsReject_, *""*, *1*, &laquo; [[Promise]], [[AlreadyResolved]] &raquo;).
1. Set _reject_.[[Promise]] to _promise_.
1. Set _reject_.[[AlreadyResolved]] to _alreadyResolved_.
1. Return the Record { [[Resolve]]: _resolve_, [[Reject]]: _reject_ }.
Expand Down Expand Up @@ -40186,7 +40190,7 @@ <h1>NewPromiseCapability ( _C_ )</h1>
1. NOTE: _C_ is assumed to be a constructor function that supports the parameter conventions of the Promise constructor (see <emu-xref href="#sec-promise-executor"></emu-xref>).
1. Let _promiseCapability_ be the PromiseCapability Record { [[Promise]]: *undefined*, [[Resolve]]: *undefined*, [[Reject]]: *undefined* }.
1. Let _steps_ be the algorithm steps defined in <emu-xref href="#sec-getcapabilitiesexecutor-functions" title></emu-xref>.
1. Let _executor_ be ! CreateBuiltinFunction(_steps_, &laquo; [[Capability]] &raquo;).
1. Let _executor_ be ! CreateBuiltinFunction(_steps_, *""*, *2*, &laquo; [[Capability]] &raquo;).
1. Set _executor_.[[Capability]] to _promiseCapability_.
1. Let _promise_ be ? Construct(_C_, &laquo; _executor_ &raquo;).
1. If IsCallable(_promiseCapability_.[[Resolve]]) is *false*, throw a *TypeError* exception.
Expand Down Expand Up @@ -40435,7 +40439,7 @@ <h1>Runtime Semantics: PerformPromiseAll ( _iteratorRecord_, _constructor_, _res
1. Append *undefined* to _values_.
1. Let _nextPromise_ be ? Call(_promiseResolve_, _constructor_, &laquo; _nextValue_ &raquo;).
1. Let _steps_ be the algorithm steps defined in <emu-xref href="#sec-promise.all-resolve-element-functions" title></emu-xref>.
1. Let _resolveElement_ be ! CreateBuiltinFunction(_steps_, &laquo; [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] &raquo;).
1. Let _resolveElement_ be ! CreateBuiltinFunction(_steps_, *""*, *1*, &laquo; [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] &raquo;).
1. Set _resolveElement_.[[AlreadyCalled]] to the Record { [[Value]]: *false* }.
1. Set _resolveElement_.[[Index]] to _index_.
1. Set _resolveElement_.[[Values]] to _values_.
Expand Down Expand Up @@ -40517,15 +40521,15 @@ <h1>Runtime Semantics: PerformPromiseAllSettled ( _iteratorRecord_, _constructor
1. Append *undefined* to _values_.
1. Let _nextPromise_ be ? Call(_promiseResolve_, _constructor_, &laquo; _nextValue_ &raquo;).
1. Let _steps_ be the algorithm steps defined in <emu-xref href="#sec-promise.allsettled-resolve-element-functions" title></emu-xref>.
1. Let _resolveElement_ be ! CreateBuiltinFunction(_steps_, &laquo; [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] &raquo;).
1. Let _resolveElement_ be ! CreateBuiltinFunction(_steps_, *""*, *1*, &laquo; [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] &raquo;).
1. Let _alreadyCalled_ be the Record { [[Value]]: *false* }.
1. Set _resolveElement_.[[AlreadyCalled]] to _alreadyCalled_.
1. Set _resolveElement_.[[Index]] to _index_.
1. Set _resolveElement_.[[Values]] to _values_.
1. Set _resolveElement_.[[Capability]] to _resultCapability_.
1. Set _resolveElement_.[[RemainingElements]] to _remainingElementsCount_.
1. Let _rejectSteps_ be the algorithm steps defined in <emu-xref href="#sec-promise.allsettled-reject-element-functions" title></emu-xref>.
1. Let _rejectElement_ be ! CreateBuiltinFunction(_rejectSteps_, &laquo; [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] &raquo;).
1. Let _rejectElement_ be ! CreateBuiltinFunction(_rejectSteps_, *""*, *1*, &laquo; [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] &raquo;).
1. Set _rejectElement_.[[AlreadyCalled]] to _alreadyCalled_.
1. Set _rejectElement_.[[Index]] to _index_.
1. Set _rejectElement_.[[Values]] to _values_.
Expand Down Expand Up @@ -40637,7 +40641,7 @@ <h1>Runtime Semantics: PerformPromiseAny ( _iteratorRecord_, _constructor_, _res
1. Append *undefined* to _errors_.
1. Let _nextPromise_ be ? Call(_promiseResolve_, _constructor_, &laquo; _nextValue_ &raquo;).
1. Let _steps_ be the algorithm steps defined in <emu-xref href="#sec-promise.any-reject-element-functions" title></emu-xref>.
1. Let _rejectElement_ be ! CreateBuiltinFunction(_steps_, &laquo; [[AlreadyCalled]], [[Index]], [[Errors]], [[Capability]], [[RemainingElements]] &raquo;).
1. Let _rejectElement_ be ! CreateBuiltinFunction(_steps_, *""*, *1*, &laquo; [[AlreadyCalled]], [[Index]], [[Errors]], [[Capability]], [[RemainingElements]] &raquo;).
1. Set _rejectElement_.[[AlreadyCalled]] to the Record { [[Value]]: *false* }.
1. Set _rejectElement_.[[Index]] to _index_.
1. Set _rejectElement_.[[Errors]] to _errors_.
Expand Down Expand Up @@ -40818,11 +40822,11 @@ <h1>Promise.prototype.finally ( _onFinally_ )</h1>
1. Let _catchFinally_ be _onFinally_.
1. Else,
1. Let _stepsThenFinally_ be the algorithm steps defined in <emu-xref href="#sec-thenfinallyfunctions" title></emu-xref>.
1. Let _thenFinally_ be ! CreateBuiltinFunction(_stepsThenFinally_, &laquo; [[Constructor]], [[OnFinally]] &raquo;).
1. Let _thenFinally_ be ! CreateBuiltinFunction(_stepsThenFinally_, *""*, *1*, &laquo; [[Constructor]], [[OnFinally]] &raquo;).
1. Set _thenFinally_.[[Constructor]] to _C_.
1. Set _thenFinally_.[[OnFinally]] to _onFinally_.
1. Let _stepsCatchFinally_ be the algorithm steps defined in <emu-xref href="#sec-catchfinallyfunctions" title></emu-xref>.
1. Let _catchFinally_ be ! CreateBuiltinFunction(_stepsCatchFinally_, &laquo; [[Constructor]], [[OnFinally]] &raquo;).
1. Let _catchFinally_ be ! CreateBuiltinFunction(_stepsCatchFinally_, *""*, *1*, &laquo; [[Constructor]], [[OnFinally]] &raquo;).
1. Set _catchFinally_.[[Constructor]] to _C_.
1. Set _catchFinally_.[[OnFinally]] to _onFinally_.
1. Return ? Invoke(_promise_, *"then"*, &laquo; _thenFinally_, _catchFinally_ &raquo;).
Expand Down Expand Up @@ -41305,7 +41309,7 @@ <h1>Proxy.revocable ( _target_, _handler_ )</h1>
<emu-alg>
1. Let _p_ be ? ProxyCreate(_target_, _handler_).
1. Let _steps_ be the algorithm steps defined in <emu-xref href="#sec-proxy-revocation-functions" title></emu-xref>.
1. Let _revoker_ be ! CreateBuiltinFunction(_steps_, &laquo; [[RevocableProxy]] &raquo;).
1. Let _revoker_ be ! CreateBuiltinFunction(_steps_, *""*, *+0*, &laquo; [[RevocableProxy]] &raquo;).
1. Set _revoker_.[[RevocableProxy]] to _p_.
1. Let _result_ be OrdinaryObjectCreate(%Object.prototype%).
1. Perform ! CreateDataPropertyOrThrow(_result_, *"proxy"*, _p_).
Expand Down

0 comments on commit ce0c88c

Please sign in to comment.