Skip to content

Commit

Permalink
function implementation hiding
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed Nov 26, 2019
1 parent 9c8d03c commit 6c093fa
Showing 1 changed file with 131 additions and 5 deletions.
136 changes: 131 additions & 5 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -8353,6 +8353,28 @@ <h1>ECMAScript Function Objects</h1>
*true* if this is a strict function, *false* if this is a non-strict function.
</td>
</tr>
<tr>
<td>
[[PresentInStackTraces]]
</td>
<td>
Boolean
</td>
<td>
When *false*, this function must not have a corresponding entry in stack traces.
</td>
</tr>
<tr>
<td>
[[HasSourceTextAvailable]]
</td>
<td>
Boolean
</td>
<td>
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.
</td>
</tr>
<tr>
<td>
[[HomeObject]]
Expand Down Expand Up @@ -8505,6 +8527,20 @@ <h1>OrdinaryFunctionCreate ( _functionPrototype_, _ParameterList_, _Body_, _this
1. Set _F_.[[FormalParameters]] to _ParameterList_.
1. Set _F_.[[ECMAScriptCode]] to _Body_.
1. If the source text matching _Body_ is strict mode code, let _Strict_ be *true*; else let _Strict_ be *false*.
1. Set _F_.[[PresentInStackTraces]] to PresentInStackTraces of _Body_.
1. Set _F_.[[HasSourceTextAvailable]] to HasSourceTextAvailable of _Body_.
1. Let _ec_ be the running execution context.
1. If _ec_ is not *null*,
1. Let _runningFunc_ be _ec_'s Function.
1. If _runningFunc_ is not *null*,
1. If _F_.[[PresentInStackTraces]] is *true*, set _F_.[[PresentInStackTraces]] to _runningFunc_.[[PresentInStackTraces]].
1. If _F_.[[HasSourceTextAvailable]] is *true*, set _F_.[[HasSourceTextAvailable]] to _runningFunc_.[[HasSourceTextAvailable]].
1. Let _scriptOrModule_ be _ec_'s ScriptOrModule.
1. If _scriptOrModule_ is not *null*,
1. If _F_.[[PresentInStackTraces]] is *true*, set _F_.[[PresentInStackTraces]] to PresentInStackTraces of _scriptOrModule_.[[ECMAScriptCode]].
1. If _F_.[[HasSourceTextAvailable]] is *true*, set _F_.[[HasSourceTextAvailable]] to HasSourceTextAvailable of _scriptOrModule_.[[ECMAScriptCode]].
1. Set _F_.[[Strict]] to _Strict_.
1. Set _F_.[[Environment]] to _Scope_.
1. Set _F_.[[Strict]] to _Strict_.
1. If _thisMode_ is ~lexical-this~, set _F_.[[ThisMode]] to ~lexical~.
1. Else if _Strict_ is *true*, set _F_.[[ThisMode]] to ~strict~.
Expand Down Expand Up @@ -18967,12 +19003,15 @@ <h2>Syntax</h2>
</emu-grammar>

<emu-clause id="sec-directive-prologues-and-the-use-strict-directive">
<h1>Directive Prologues and the Use Strict Directive</h1>
<h1>Directive Prologues</h1>
<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>
<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>
<p>A Directive Prologue may contain more than one Use Strict Directive. However, an implementation may issue a warning if this occurs.</p>
<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>
<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>
<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>
<p>A Directive Prologue may contain duplicate Built-in Directives. However, an implementation may issue a warning if this occurs.</p>
<emu-note>
<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>
<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>
</emu-note>
</emu-clause>

Expand Down Expand Up @@ -19128,6 +19167,24 @@ <h1>Static Semantics: ContainsUseStrict</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-function-definitions-static-semantics-presentinstacktraces">
<h1>Static Semantics: PresentInStackTraces</h1>
<emu-see-also-para op="PresentInStackTraces"></emu-see-also-para>
<emu-grammar>FunctionBody : FunctionStatementList</emu-grammar>
<emu-alg>
1. If the Directive Prologue of |FunctionBody| contains a Sensitive Directive, return *false*; otherwise, return *true*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-function-definitions-static-semantics-hassourcetextavailable">
<h1>Static Semantics: HasSourceTextAvailable</h1>
<emu-see-also-para op="HasSourceTextAvailable"></emu-see-also-para>
<emu-grammar>FunctionBody : FunctionStatementList</emu-grammar>
<emu-alg>
1. If the Directive Prologue of |FunctionBody| contains a Sensitive Directive or a Hidden Implementation Directive, return *false*; otherwise, return *true*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-function-definitions-static-semantics-expectedargumentcount">
<h1>Static Semantics: ExpectedArgumentCount</h1>
<emu-see-also-para op="ExpectedArgumentCount"></emu-see-also-para>
Expand Down Expand Up @@ -19541,6 +19598,24 @@ <h1>Static Semantics: ContainsUseStrict</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-arrow-function-definitions-static-semantics-presentinstacktraces">
<h1>Static Semantics: PresentInStackTraces</h1>
<emu-see-also-para op="PresentInStackTraces"></emu-see-also-para>
<emu-grammar>ConciseBody : AssignmentExpression</emu-grammar>
<emu-alg>
1. Return *true*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-arrow-function-definitions-static-semantics-hassourcetextavailable">
<h1>Static Semantics: HasSourceTextAvailable</h1>
<emu-see-also-para op="HasSourceTextAvailable"></emu-see-also-para>
<emu-grammar>ConciseBody : AssignmentExpression</emu-grammar>
<emu-alg>
1. Return *true*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-arrow-function-definitions-static-semantics-expectedargumentcount">
<h1>Static Semantics: ExpectedArgumentCount</h1>
<emu-see-also-para op="ExpectedArgumentCount"></emu-see-also-para>
Expand Down Expand Up @@ -21275,6 +21350,24 @@ <h1>Static Semantics: ContainsUseStrict</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-async-arrow-function-definitions-static-semantics-presentinstacktraces">
<h1>Static Semantics: PresentInStackTraces</h1>
<emu-see-also-para op="PresentInStackTraces"></emu-see-also-para>
<emu-grammar>AsyncConciseBody : AssignmentExpression</emu-grammar>
<emu-alg>
1. Return *true*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-async-arrow-function-definitions-static-semantics-hassourcetextavailable">
<h1>Static Semantics: HasSourceTextAvailable</h1>
<emu-see-also-para op="HasSourceTextAvailable"></emu-see-also-para>
<emu-grammar>AsyncConciseBody : AssignmentExpression</emu-grammar>
<emu-alg>
1. Return *true*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-async-arrow-function-definitions-static-semantics-ExpectedArgumentCount">
<h1>Static Semantics: ExpectedArgumentCount</h1>
<emu-grammar>
Expand Down Expand Up @@ -21812,6 +21905,22 @@ <h1>Static Semantics: IsStrict</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-static-semantics-presentinstacktraces">
<h1>Static Semantics: PresentInStackTraces</h1>
<emu-grammar>Script : ScriptBody?</emu-grammar>
<emu-alg>
1. If |ScriptBody| is present and the Directive Prologue of |ScriptBody| contains a Sensitive Directive, return *false*; otherwise, return *true*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-static-semantics-hassourcetextavailable">
<h1>Static Semantics: HasSourceTextAvailable</h1>
<emu-grammar>Script : ScriptBody?</emu-grammar>
<emu-alg>
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*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-scripts-static-semantics-lexicallydeclarednames">
<h1>Static Semantics: LexicallyDeclaredNames</h1>
<emu-see-also-para op="LexicallyDeclaredNames"></emu-see-also-para>
Expand Down Expand Up @@ -22115,6 +22224,22 @@ <h1>Static Semantics: Early Errors</h1>
</emu-note>
</emu-clause>

<emu-clause id="sec-module-semantics-static-semantics-presentinstacktraces">
<h1>Static Semantics: PresentInStackTraces</h1>
<emu-grammar>Module : ModuleBody?</emu-grammar>
<emu-alg>
1. If |ModuleBody| is present and the Directive Prologue of |ModuleBody| contains a Sensitive Directive, return *false*; otherwise, return *true*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-module-semantics-static-semantics-hassourcetextavailable">
<h1>Static Semantics: HasSourceTextAvailable</h1>
<emu-grammar>Module : ModuleBody?</emu-grammar>
<emu-alg>
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*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-module-semantics-static-semantics-containsduplicatelabels">
<h1>Static Semantics: ContainsDuplicateLabels</h1>
<p>With parameter _labelSet_.</p>
Expand Down Expand Up @@ -24459,7 +24584,7 @@ <h1>Runtime Semantics: PerformEval ( _x_, _callerRealm_, _strictCaller_, _direct
1. If _strictEval_ is *true*, set _varEnv_ to _lexEnv_.
1. If _runningContext_ is not already suspended, suspend _runningContext_.
1. Let _evalContext_ be a new ECMAScript code execution context.
1. Set _evalContext_'s Function to *null*.
1. Set _evalContext_'s Function to _ctx_'s Function.
1. Set _evalContext_'s Realm to _evalRealm_.
1. Set _evalContext_'s ScriptOrModule to _runningContext_'s ScriptOrModule.
1. Set _evalContext_'s VariableEnvironment to _varEnv_.
Expand Down Expand Up @@ -25920,7 +26045,7 @@ <h1>Function.prototype.toString ( )</h1>
<p>When the `toString` method is called, the following steps are taken:</p>
<emu-alg>
1. Let _func_ be the *this* value.
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_.
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_.
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]].
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|.
1. Throw a *TypeError* exception.
Expand Down Expand Up @@ -26357,6 +26482,7 @@ <h1>Properties of Symbol Instances</h1>
<emu-clause id="sec-error-objects">
<h1>Error Objects</h1>
<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>
<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>

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

0 comments on commit 6c093fa

Please sign in to comment.