Skip to content

Commit 6c093fa

Browse files
function implementation hiding
1 parent 9c8d03c commit 6c093fa

File tree

1 file changed

+131
-5
lines changed

1 file changed

+131
-5
lines changed

spec.html

Lines changed: 131 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8353,6 +8353,28 @@ <h1>ECMAScript Function Objects</h1>
83538353
*true* if this is a strict function, *false* if this is a non-strict function.
83548354
</td>
83558355
</tr>
8356+
<tr>
8357+
<td>
8358+
[[PresentInStackTraces]]
8359+
</td>
8360+
<td>
8361+
Boolean
8362+
</td>
8363+
<td>
8364+
When *false*, this function must not have a corresponding entry in stack traces.
8365+
</td>
8366+
</tr>
8367+
<tr>
8368+
<td>
8369+
[[HasSourceTextAvailable]]
8370+
</td>
8371+
<td>
8372+
Boolean
8373+
</td>
8374+
<td>
8375+
When *false*, this function will be rendered as a |NativeFunction| by `Function.prototype.toString` (<emu-xref href="#sec-function.prototype.tostring"></emu-xref>) and corresponding stack trace entries will have no attribution or position information.
8376+
</td>
8377+
</tr>
83568378
<tr>
83578379
<td>
83588380
[[HomeObject]]
@@ -8505,6 +8527,20 @@ <h1>OrdinaryFunctionCreate ( _functionPrototype_, _ParameterList_, _Body_, _this
85058527
1. Set _F_.[[FormalParameters]] to _ParameterList_.
85068528
1. Set _F_.[[ECMAScriptCode]] to _Body_.
85078529
1. If the source text matching _Body_ is strict mode code, let _Strict_ be *true*; else let _Strict_ be *false*.
8530+
1. Set _F_.[[PresentInStackTraces]] to PresentInStackTraces of _Body_.
8531+
1. Set _F_.[[HasSourceTextAvailable]] to HasSourceTextAvailable of _Body_.
8532+
1. Let _ec_ be the running execution context.
8533+
1. If _ec_ is not *null*,
8534+
1. Let _runningFunc_ be _ec_'s Function.
8535+
1. If _runningFunc_ is not *null*,
8536+
1. If _F_.[[PresentInStackTraces]] is *true*, set _F_.[[PresentInStackTraces]] to _runningFunc_.[[PresentInStackTraces]].
8537+
1. If _F_.[[HasSourceTextAvailable]] is *true*, set _F_.[[HasSourceTextAvailable]] to _runningFunc_.[[HasSourceTextAvailable]].
8538+
1. Let _scriptOrModule_ be _ec_'s ScriptOrModule.
8539+
1. If _scriptOrModule_ is not *null*,
8540+
1. If _F_.[[PresentInStackTraces]] is *true*, set _F_.[[PresentInStackTraces]] to PresentInStackTraces of _scriptOrModule_.[[ECMAScriptCode]].
8541+
1. If _F_.[[HasSourceTextAvailable]] is *true*, set _F_.[[HasSourceTextAvailable]] to HasSourceTextAvailable of _scriptOrModule_.[[ECMAScriptCode]].
8542+
1. Set _F_.[[Strict]] to _Strict_.
8543+
1. Set _F_.[[Environment]] to _Scope_.
85088544
1. Set _F_.[[Strict]] to _Strict_.
85098545
1. If _thisMode_ is ~lexical-this~, set _F_.[[ThisMode]] to ~lexical~.
85108546
1. Else if _Strict_ is *true*, set _F_.[[ThisMode]] to ~strict~.
@@ -18967,12 +19003,15 @@ <h2>Syntax</h2>
1896719003
</emu-grammar>
1896819004

1896919005
<emu-clause id="sec-directive-prologues-and-the-use-strict-directive">
18970-
<h1>Directive Prologues and the Use Strict Directive</h1>
19006+
<h1>Directive Prologues</h1>
1897119007
<p>A <dfn id="directive-prologue">Directive Prologue</dfn> is the longest sequence of |ExpressionStatement|s occurring as the initial |StatementListItem|s or |ModuleItem|s of a |FunctionBody|, a |ScriptBody|, or a |ModuleBody| and where each |ExpressionStatement| in the sequence consists entirely of a |StringLiteral| token followed by a semicolon. The semicolon may appear explicitly or may be inserted by automatic semicolon insertion. A Directive Prologue may be an empty sequence.</p>
1897219008
<p>A <dfn id="use-strict-directive">Use Strict Directive</dfn> is an |ExpressionStatement| in a Directive Prologue whose |StringLiteral| is either of the exact code point sequences `"use strict"` or `'use strict'`. A Use Strict Directive may not contain an |EscapeSequence| or |LineContinuation|.</p>
18973-
<p>A Directive Prologue may contain more than one Use Strict Directive. However, an implementation may issue a warning if this occurs.</p>
19009+
<p>A <dfn id="sensitive-directive">Sensitive Directive</dfn> is an |ExpressionStatement| in a Directive Prologue whose |StringLiteral| is either of the exact code point sequences `"sensitive"` or `'sensitive'`. A Sensitive Directive may not contain an |EscapeSequence| or |LineContinuation|.</p>
19010+
<p>A <dfn id="hidden-implementation-directive">Hidden Implementation Directive</dfn> is an |ExpressionStatement| in a Directive Prologue whose |StringLiteral| is either of the exact code point sequences `"hide implementation"` or `'hide implementation'`. A Hidden Implementation Directive may not contain an |EscapeSequence| or |LineContinuation|.</p>
19011+
<p>A <dfn id="built-in-directive">Built-in Directive</dfn> is an |ExpressionStatement| in a Directive Prologue that is either a Use Strict Directive, a Sensitive Directive, or a Hidden Implementation Directive.</p>
19012+
<p>A Directive Prologue may contain duplicate Built-in Directives. However, an implementation may issue a warning if this occurs.</p>
1897419013
<emu-note>
18975-
<p>The |ExpressionStatement|s of a Directive Prologue are evaluated normally during evaluation of the containing production. Implementations may define implementation specific meanings for |ExpressionStatement|s which are not a Use Strict Directive and which occur in a Directive Prologue. If an appropriate notification mechanism exists, an implementation should issue a warning if it encounters in a Directive Prologue an |ExpressionStatement| that is not a Use Strict Directive and which does not have a meaning defined by the implementation.</p>
19014+
<p>The |ExpressionStatement|s of a Directive Prologue are evaluated normally during evaluation of the containing production. Implementations may define implementation-specific meanings for |ExpressionStatement|s in a Directive Prologue which are not a Built-in Directive. If an appropriate notification mechanism exists, an implementation should issue a warning if it encounters in a Directive Prologue an |ExpressionStatement| that is not a Built-in Directive and which does not have a meaning defined by the implementation.</p>
1897619015
</emu-note>
1897719016
</emu-clause>
1897819017

@@ -19128,6 +19167,24 @@ <h1>Static Semantics: ContainsUseStrict</h1>
1912819167
</emu-alg>
1912919168
</emu-clause>
1913019169

19170+
<emu-clause id="sec-function-definitions-static-semantics-presentinstacktraces">
19171+
<h1>Static Semantics: PresentInStackTraces</h1>
19172+
<emu-see-also-para op="PresentInStackTraces"></emu-see-also-para>
19173+
<emu-grammar>FunctionBody : FunctionStatementList</emu-grammar>
19174+
<emu-alg>
19175+
1. If the Directive Prologue of |FunctionBody| contains a Sensitive Directive, return *false*; otherwise, return *true*.
19176+
</emu-alg>
19177+
</emu-clause>
19178+
19179+
<emu-clause id="sec-function-definitions-static-semantics-hassourcetextavailable">
19180+
<h1>Static Semantics: HasSourceTextAvailable</h1>
19181+
<emu-see-also-para op="HasSourceTextAvailable"></emu-see-also-para>
19182+
<emu-grammar>FunctionBody : FunctionStatementList</emu-grammar>
19183+
<emu-alg>
19184+
1. If the Directive Prologue of |FunctionBody| contains a Sensitive Directive or a Hidden Implementation Directive, return *false*; otherwise, return *true*.
19185+
</emu-alg>
19186+
</emu-clause>
19187+
1913119188
<emu-clause id="sec-function-definitions-static-semantics-expectedargumentcount">
1913219189
<h1>Static Semantics: ExpectedArgumentCount</h1>
1913319190
<emu-see-also-para op="ExpectedArgumentCount"></emu-see-also-para>
@@ -19541,6 +19598,24 @@ <h1>Static Semantics: ContainsUseStrict</h1>
1954119598
</emu-alg>
1954219599
</emu-clause>
1954319600

19601+
<emu-clause id="sec-arrow-function-definitions-static-semantics-presentinstacktraces">
19602+
<h1>Static Semantics: PresentInStackTraces</h1>
19603+
<emu-see-also-para op="PresentInStackTraces"></emu-see-also-para>
19604+
<emu-grammar>ConciseBody : AssignmentExpression</emu-grammar>
19605+
<emu-alg>
19606+
1. Return *true*.
19607+
</emu-alg>
19608+
</emu-clause>
19609+
19610+
<emu-clause id="sec-arrow-function-definitions-static-semantics-hassourcetextavailable">
19611+
<h1>Static Semantics: HasSourceTextAvailable</h1>
19612+
<emu-see-also-para op="HasSourceTextAvailable"></emu-see-also-para>
19613+
<emu-grammar>ConciseBody : AssignmentExpression</emu-grammar>
19614+
<emu-alg>
19615+
1. Return *true*.
19616+
</emu-alg>
19617+
</emu-clause>
19618+
1954419619
<emu-clause id="sec-arrow-function-definitions-static-semantics-expectedargumentcount">
1954519620
<h1>Static Semantics: ExpectedArgumentCount</h1>
1954619621
<emu-see-also-para op="ExpectedArgumentCount"></emu-see-also-para>
@@ -21275,6 +21350,24 @@ <h1>Static Semantics: ContainsUseStrict</h1>
2127521350
</emu-alg>
2127621351
</emu-clause>
2127721352

21353+
<emu-clause id="sec-async-arrow-function-definitions-static-semantics-presentinstacktraces">
21354+
<h1>Static Semantics: PresentInStackTraces</h1>
21355+
<emu-see-also-para op="PresentInStackTraces"></emu-see-also-para>
21356+
<emu-grammar>AsyncConciseBody : AssignmentExpression</emu-grammar>
21357+
<emu-alg>
21358+
1. Return *true*.
21359+
</emu-alg>
21360+
</emu-clause>
21361+
21362+
<emu-clause id="sec-async-arrow-function-definitions-static-semantics-hassourcetextavailable">
21363+
<h1>Static Semantics: HasSourceTextAvailable</h1>
21364+
<emu-see-also-para op="HasSourceTextAvailable"></emu-see-also-para>
21365+
<emu-grammar>AsyncConciseBody : AssignmentExpression</emu-grammar>
21366+
<emu-alg>
21367+
1. Return *true*.
21368+
</emu-alg>
21369+
</emu-clause>
21370+
2127821371
<emu-clause id="sec-async-arrow-function-definitions-static-semantics-ExpectedArgumentCount">
2127921372
<h1>Static Semantics: ExpectedArgumentCount</h1>
2128021373
<emu-grammar>
@@ -21812,6 +21905,22 @@ <h1>Static Semantics: IsStrict</h1>
2181221905
</emu-alg>
2181321906
</emu-clause>
2181421907

21908+
<emu-clause id="sec-static-semantics-presentinstacktraces">
21909+
<h1>Static Semantics: PresentInStackTraces</h1>
21910+
<emu-grammar>Script : ScriptBody?</emu-grammar>
21911+
<emu-alg>
21912+
1. If |ScriptBody| is present and the Directive Prologue of |ScriptBody| contains a Sensitive Directive, return *false*; otherwise, return *true*.
21913+
</emu-alg>
21914+
</emu-clause>
21915+
21916+
<emu-clause id="sec-static-semantics-hassourcetextavailable">
21917+
<h1>Static Semantics: HasSourceTextAvailable</h1>
21918+
<emu-grammar>Script : ScriptBody?</emu-grammar>
21919+
<emu-alg>
21920+
1. If |ScriptBody| is present and the Directive Prologue of |ScriptBody| contains a Sensitive Directive or a Hidden Implementation Directive, return *false*; otherwise, return *true*.
21921+
</emu-alg>
21922+
</emu-clause>
21923+
2181521924
<emu-clause id="sec-scripts-static-semantics-lexicallydeclarednames">
2181621925
<h1>Static Semantics: LexicallyDeclaredNames</h1>
2181721926
<emu-see-also-para op="LexicallyDeclaredNames"></emu-see-also-para>
@@ -22115,6 +22224,22 @@ <h1>Static Semantics: Early Errors</h1>
2211522224
</emu-note>
2211622225
</emu-clause>
2211722226

22227+
<emu-clause id="sec-module-semantics-static-semantics-presentinstacktraces">
22228+
<h1>Static Semantics: PresentInStackTraces</h1>
22229+
<emu-grammar>Module : ModuleBody?</emu-grammar>
22230+
<emu-alg>
22231+
1. If |ModuleBody| is present and the Directive Prologue of |ModuleBody| contains a Sensitive Directive, return *false*; otherwise, return *true*.
22232+
</emu-alg>
22233+
</emu-clause>
22234+
22235+
<emu-clause id="sec-module-semantics-static-semantics-hassourcetextavailable">
22236+
<h1>Static Semantics: HasSourceTextAvailable</h1>
22237+
<emu-grammar>Module : ModuleBody?</emu-grammar>
22238+
<emu-alg>
22239+
1. If |ModuleBody| is present and the Directive Prologue of |ModuleBody| contains a Sensitive Directive or a Hidden Implementation Directive, return *false*; otherwise, return *true*.
22240+
</emu-alg>
22241+
</emu-clause>
22242+
2211822243
<emu-clause id="sec-module-semantics-static-semantics-containsduplicatelabels">
2211922244
<h1>Static Semantics: ContainsDuplicateLabels</h1>
2212022245
<p>With parameter _labelSet_.</p>
@@ -24459,7 +24584,7 @@ <h1>Runtime Semantics: PerformEval ( _x_, _callerRealm_, _strictCaller_, _direct
2445924584
1. If _strictEval_ is *true*, set _varEnv_ to _lexEnv_.
2446024585
1. If _runningContext_ is not already suspended, suspend _runningContext_.
2446124586
1. Let _evalContext_ be a new ECMAScript code execution context.
24462-
1. Set _evalContext_'s Function to *null*.
24587+
1. Set _evalContext_'s Function to _ctx_'s Function.
2446324588
1. Set _evalContext_'s Realm to _evalRealm_.
2446424589
1. Set _evalContext_'s ScriptOrModule to _runningContext_'s ScriptOrModule.
2446524590
1. Set _evalContext_'s VariableEnvironment to _varEnv_.
@@ -25920,7 +26045,7 @@ <h1>Function.prototype.toString ( )</h1>
2592026045
<p>When the `toString` method is called, the following steps are taken:</p>
2592126046
<emu-alg>
2592226047
1. Let _func_ be the *this* value.
25923-
1. If _func_ is a <emu-xref href="#sec-bound-function-exotic-objects">Bound Function exotic object</emu-xref> or a <emu-xref href="#sec-built-in-function-objects">built-in function object</emu-xref>, then return an implementation-dependent String source code representation of _func_. The representation must have the syntax of a |NativeFunction|. Additionally, if _func_ is a <emu-xref href="#sec-well-known-intrinsic-objects">Well-known Intrinsic Object</emu-xref> and is not identified as an anonymous function, the portion of the returned String that would be matched by |PropertyName| must be the initial value of the *"name"* property of _func_.
26048+
1. If _func_ is a <emu-xref href="#sec-bound-function-exotic-objects">Bound Function exotic object</emu-xref> or a <emu-xref href="#sec-built-in-function-objects">built-in function object</emu-xref> or has a [[HasSourceTextAvailable]] slot with the value *false*, then return an implementation-dependent String source code representation of _func_. The representation must have the syntax of a |NativeFunction|. Additionally, if _func_ is a <emu-xref href="#sec-well-known-intrinsic-objects">Well-known Intrinsic Object</emu-xref> and is not identified as an anonymous function, the portion of the returned String that would be matched by |PropertyName| must be the initial value of the `"name"` property of _func_.
2592426049
1. If Type(_func_) is Object and _func_ has a [[SourceText]] internal slot and Type(_func_.[[SourceText]]) is String and ! HostHasSourceTextAvailable(_func_) is *true*, then return _func_.[[SourceText]].
2592526050
1. If Type(_func_) is Object and IsCallable(_func_) is *true*, then return an implementation-dependent String source code representation of _func_. The representation must have the syntax of a |NativeFunction|.
2592626051
1. Throw a *TypeError* exception.
@@ -26357,6 +26482,7 @@ <h1>Properties of Symbol Instances</h1>
2635726482
<emu-clause id="sec-error-objects">
2635826483
<h1>Error Objects</h1>
2635926484
<p>Instances of Error objects are thrown as exceptions when runtime errors occur. The Error objects may also serve as base objects for user-defined exception classes.</p>
26485+
<p>Stack trace information exposed to the running program through implementation-defined accessors such as the de facto `Error.prototype.stack` must not indicate the presence of functions whose [[PresentInStackTraces]] slot has a value of *false*. Additionally, stack frames from these accessors which refer to functions whose [[HasSourceTextAvailable]] slot has a value of *false* must not include any attribution or position information related to the function.</p>
2636026486

2636126487
<emu-clause id="sec-error-constructor">
2636226488
<h1>The Error Constructor</h1>

0 commit comments

Comments
 (0)