Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: GetFunctionRealm may throw on revoked proxies #356

Merged
merged 2 commits into from
Jun 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 45 additions & 5 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,35 @@ <h1>
<dt>for</dt>
<dd>a wrapped function exotic object _F_</dd>
</dl>
<emu-alg>
1. Let _callerContext_ be the running execution context.
1. Let _calleeContext_ be PrepareForWrappedFunctionCall(_F_).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, initially I had something similar to this, and after some back and forward with @syg, we decided that this was not necessary. I will try to dig that discussing out from some of the earlier PRs.

1. Assert: _calleeContext_ is now the running execution context.
1. Let result be OrdinaryWrappedFunctionCall(_F_, _thisArgument_, _argumentsList_).
1. Remove _calleeContext_ from the execution context stack and restore _callerContext_ as the running execution context.
1. If result.[[Type]] is return, return result.[[Value]].
1. ReturnIfAbrupt(result).
1. Return *undefined*.
</emu-alg>
<emu-note type=editor>
In the case of an abrupt ~throw~ completion, the type of error to be created should match the type of the abrupt throw completion record. This could be revisited when merging into the main specification. Additionally, in the case of a ~break~ or ~continue~ completion, since those are not supported, a TypeError is expected.
</emu-note>
</emu-clause>

<emu-clause id="sec-ordinary-wrapped-function-call" type="abstract operation">
<h1>
OrdinaryWrappedFunctionCall (
_F_: a wrapped function exotic object,
_thisArgument_: an ECMAScript language value,
_argumentsList_: a List of ECMAScript language values,
)
</h1>
<emu-alg>
1. Let _target_ be _F_.[[WrappedTargetFunction]].
1. Assert: IsCallable(_target_) is *true*.
1. Let _targetRealm_ be ? GetFunctionRealm(_target_).
1. Let _callerRealm_ be ? GetFunctionRealm(_F_).
1. Let _callerRealm_ be _F_.[[Realm]].
1. NOTE: Any exception objects produced after this point are associated with _callerRealm_.
1. Let _targetRealm_ be ? GetFunctionRealm(_target_).
caridy marked this conversation as resolved.
Show resolved Hide resolved
1. Let _wrappedArgs_ be a new empty List.
1. For each element _arg_ of _argumentsList_, do
1. Let _wrappedValue_ be ? GetWrappedValue(_targetRealm_, _arg_).
Expand All @@ -124,9 +147,26 @@ <h1>
1. Else,
1. Throw a *TypeError* exception.
</emu-alg>
<emu-note type=editor>
In the case of an abrupt ~throw~ completion, the type of error to be created should match the type of the abrupt throw completion record. This could be revisited when merging into the main specification. Additionally, in the case of a ~break~ or ~continue~ completion, since those are not supported, a TypeError is expected.
</emu-note>
</emu-clause>

<emu-clause id="sec-prepare-for-wrapped-function-call" type="abstract operation">
<h1>
PrepareForWrappedFunctionCall (
_F_: a wrapped function exotic object,
)
</h1>
<emu-alg>
1. Let callerContext be the running execution context.
1. Let calleeContext be a new execution context.
1. Set the Function of calleeContext to F.
1. Let calleeRealm be F.[[Realm]].
1. Set the Realm of calleeContext to calleeRealm.
1. Set the ScriptOrModule of calleeContext to *null*.
1. If callerContext is not already suspended, suspend callerContext.
1. Push calleeContext onto the execution context stack; calleeContext is now the running execution context.
1. NOTE: Any exception objects produced after this point are associated with calleeRealm.
1. Return calleeContext.
</emu-alg>
</emu-clause>
</emu-clause>

Expand Down