Skip to content

Commit

Permalink
merging PR #84: ECMA-402 v1 legacy constructor semantics compromise
Browse files Browse the repository at this point in the history
  • Loading branch information
caridy committed Feb 2, 2017
2 parents 2a77f67 + 8775fdc commit c84e3f0
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 6 deletions.
4 changes: 4 additions & 0 deletions spec/conventions.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ <h1>Notational Conventions</h1>
For ECMAScript objects, this standard may use variable-named internal slots: The notation "[[&lt;_name_&gt;]]" denotes an internal slot whose name is given by the variable name, which must have a String value. For example, if a variable _s_ has the value *"a"*, then [[&lt;_s_&gt;]] denotes the [[&lt;_a_&gt;]] internal slot.
</p>

<p>
This specification uses blocks demarcated as <span class="normative-optional">Normative Optional</span> to denote the sense of <a href="https://tc39.github.io/ecma262/#sec-additional-ecmascript-features-for-web-browsers">Annex B</a> in ECMA 262. That is, normative optional sections are required when the ECMAScript host is a web browser. The content of the section is normative but optional if the ECMAScript host is not a web browser.
</p>

<emu-clause id="sec-402-well-known-intrinsic-objects">
<h1>Well-Known Intrinsic Objects</h1>

Expand Down
39 changes: 36 additions & 3 deletions spec/datetimeformat.html
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,28 @@ <h1>ToLocalTime ( _date_, _calendar_, _timeZone_ )</h1>
It is recommended that implementations use the time zone information of the IANA Time Zone Database.
</emu-note>
</emu-clause>

<emu-clause id="sec-unwrapdatetimeformat" aoid="UnwrapDateTimeFormat">
<h1>UnwrapDateTimeFormat( _dtf_ )</h1>
<p>
The UnwrapDateTimeFormat abstract operation gets the underlying DateTimeFormat operation
for various methods which implement ECMA-402 v1 semantics for supporting initializing
existing Intl objects.
</p>
<emu-normative-optional><span class="normative-optional">Normative Optional</span><div class="normative-optional-contents">
<emu-alg>
1. If _dtf_ does not have an [[InitializedDateTimeFormat]] internal slot and ? InstanceofOperator(_dtf_, %DateTimeFormat%) is equal *true*, then
1. Let _obj_ be Get(_dtf_, Intl.[[FallbackSymbol]]).
1. Let _dtf_ be ? RequireObjectCoercible(_obj_).
</emu-alg>
</div></emu-normative-optional>
<emu-alg>
2. If _dtf_ does not have an [[InitializedDateTimeFormat]] internal slot,
1. Throw a *TypeError* exception.
1. Return _dtf_.
</emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>

<emu-clause id="sec-intl-datetimeformat-constructor">
Expand All @@ -389,7 +411,18 @@ <h1>Intl.DateTimeFormat ( [ _locales_ [ , _options_ ] ] )</h1>
<emu-alg>
1. If NewTarget is *undefined*, let _newTarget_ be the active function object, else let _newTarget_ be NewTarget.
1. Let _dateTimeFormat_ be ? OrdinaryCreateFromConstructor(_newTarget_, `"%DateTimeFormatPrototype%"`, &laquo; [[InitializedIntlObject]], [[InitializedDateTimeFormat]], [[Locale]], [[Calendar]], [[NumberingSystem]], [[TimeZone]], [[Weekday]], [[Era]], [[Year]], [[Month]], [[Day]], [[Hour]], [[Minute]], [[Second]], [[TimeZoneName]], [[Hour12]], [[HourNo0]], [[Pattern]], [[BoundFormat]] &raquo;).
1. Return ? InitializeDateTimeFormat(_dateTimeFormat_, _locales_, _options_).
1. Perform ? InitializeDateTimeFormat(_dateTimeFormat_, _locales_, _options_).
</emu-alg>
<emu-normative-optional><span class="normative-optional">Normative Optional</span><div class="normative-optional-contents">
<emu-alg>
4. Let _this_ be the *this* value.
1. If NewTarget is *undefined* and ? InstanceofOperator(_this_, %NumberFormat%),
1. Perform ? DefineOwnPropertyOrThrow(_this_, Intl.[[FallbackSymbol]], { [[Value]]: _dateTimeFormat_, [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }).
1. Return _this_.
</emu-alg>
</div></emu-normative-optional>
<emu-alg>
6. Return _dateTimeFormat_.
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -522,7 +555,7 @@ <h1>get Intl.DateTimeFormat.prototype.format</h1>
<emu-alg>
1. Let _dtf_ be *this* value.
1. If Type(_dtf_) is not Object, throw a *TypeError* exception.
1. If _dtf_ does not have an [[InitializedDateTimeFormat]] internal slot, throw a *TypeError* exception.
1. Let _dtf_ be ? UnwrapDateTimeFormat(_dtf_).
1. If _dtf_.[[BoundFormat]] is *undefined*, then
1. Let _F_ be a new built-in function object as defined in DateTime Format Functions (<emu-xref href="#sec-datetime-format-functions"></emu-xref>).
1. Let _bf_ be BoundFunctionCreate(_F_, _dft_, &laquo; &raquo;).
Expand Down Expand Up @@ -555,7 +588,7 @@ <h1>Intl.DateTimeFormat.prototype.formatToParts ( [ _date_ ] )</h1>
<h1>Intl.DateTimeFormat.prototype.resolvedOptions ()</h1>

<p>
This function provides access to the locale and formatting options computed during initialization of the object.
This function provides access to the locale and formatting options computed during initialization of the object. This function initially invokes the internal algorithm UnwrapDateTimeFormat to get the %DateTimeFormat% object on which to operate.
</p>

<p>
Expand Down
14 changes: 14 additions & 0 deletions spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@
margin-bottom: 10px;
padding-left: 10px;
}

emu-normative-optional {
margin: 1em 0;
border-left: 5px solid #ff6600;
display: block;
background: #ffeedd;
}

span.normative-optional {
padding-left: 5px;
text-transform: uppercase;
color: #884400;
}

</style>
<img src="img/ecma-logo.jpg">
<pre class=metadata>
Expand Down
4 changes: 4 additions & 0 deletions spec/intl.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ <h1>The Intl Object</h1>
The Intl object is not a function object. It does not have a [[Construct]] internal method; it is not possible to use the Intl object as a constructor with the *new* operator. The Intl object does not have a [[Call]] internal method; it is not possible to invoke the Intl object as a function.
</p>

<p>
The Intl object has an internal slot, [[FallbackSymbol]], which is a new %Symbol% in the current realm.
</p>

<emu-clause id="sec-constructor-properties-of-the-intl-object">
<h1>Constructor Properties of the Intl Object</h1>

Expand Down
38 changes: 35 additions & 3 deletions spec/numberformat.html
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,27 @@ <h1>ToRawFixed( _x_, _minInteger_, _minFraction_, _maxFraction_ )</h1>
1. Return _m_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-unwrapnumberformat" aoid="UnwrapNumberFormat">
<h1>UnwrapNumberFormat( _nf_ )</h1>
<p>
The UnwrapNumberFormat abstract operation gets the underlying NumberFormat operation
for various methods which implement ECMA-402 v1 semantics for supporting initializing
existing Intl objects.
</p>
<emu-normative-optional><span class="normative-optional">Normative Optional</span><div class="normative-optional-contents">
<emu-alg>
1. If _nf_ does not have an [[InitializedNumberFormat]] internal slot and ? InstanceofOperator(_nf_, %NumberFormat%)is equal *true*, then
1. Let _obj_ be Get(_nf_, Intl.[[FallbackSymbol]]).
1. Let _nf_ be ? RequireObjectCoercible(_obj_).
</emu-alg>
</div></emu-normative-optional>
<emu-alg>
2. If _nf_ does not have an [[InitializedNumberFormat]] internal slot, then
1. Throw a *TypeError* exception.
1. Return _nf_.
</emu-alg>
</emu-clause>
</emu-clause>

<emu-clause id="sec-intl-numberformat-constructor">
Expand All @@ -467,7 +488,18 @@ <h1>Intl.NumberFormat ( [ _locales_ [ , _options_ ] ] )</h1>
<emu-alg>
1. If NewTarget is *undefined*, let _newTarget_ be the active function object, else let _newTarget_ be NewTarget.
1. Let _numberFormat_ be ? OrdinaryCreateFromConstructor(_newTarget_, `"%NumberFormatPrototype%"`, &laquo; [[InitializedIntlObject]], [[InitializedNumberFormat]], [[Locale]], [[NumberingSystem]], [[Style]], [[Currency]], [[CurrencyDisplay]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[UseGrouping]], [[PositivePattern]], [[NegativePattern]], [[BoundFormat]] &raquo;).
1. Return ? InitializeNumberFormat(_numberFormat_, _locales_, _options_).
1. Perform ? InitializeNumberFormat(_numberFormat_, _locales_, _options_).
</emu-alg>
<emu-normative-optional><span class="normative-optional">Normative Optional</span><div class="normative-optional-contents">
<emu-alg>
4. Let _this_ be the *this* value.
1. If NewTarget is *undefined* and ? InstanceofOperator(_this_, %NumberFormat%),
1. Perform ? DefineOwnPropertyOrThrow(_this_, Intl.[[FallbackSymbol]], { [[Value]]: _numberFormat_, [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }).
1. Return _this_.
</emu-alg>
</div></emu-normative-optional>
<emu-alg>
6. Return _numberFormat_.
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -577,7 +609,7 @@ <h1>get Intl.NumberFormat.prototype.format</h1>
<emu-alg>
1. Let _nf_ be *this* value.
1. If Type(_nf_) is not Object, throw a *TypeError* exception.
1. If _nf_.[[InitializedNumberFormat]] is *true*, throw a *TypeError* exception.
1. Let _nf_ be ? UnwrapNumberFormat(_nf_);
1. If _nf_.[[BoundFormat]] is *undefined*, then
1. Let _F_ be a new built-in function object as defined in Number Format Functions (<emu-xref href="#sec-number-format-functions"></emu-xref>).
1. Let _bf_ be BoundFunctionCreate(_F_, _nf_, &laquo; &raquo;).
Expand All @@ -591,7 +623,7 @@ <h1>get Intl.NumberFormat.prototype.format</h1>
<h1>Intl.NumberFormat.prototype.resolvedOptions ()</h1>

<p>
This function provides access to the locale and formatting options computed during initialization of the object.
This function provides access to the locale and formatting options computed during initialization of the object. This function initially invokes the internal algorithm UnwrapNumberFormat to get the %NumberFormat% object on which to operate.
</p>
<p>
The function returns a new object whose properties and attributes are set as if constructed by an object literal assigning to each of the following properties the value of the corresponding internal slot of this NumberFormat object (see <emu-xref href="#sec-properties-of-intl-numberformat-instances"></emu-xref>): locale, numberingSystem, style, currency, currencyDisplay, minimumIntegerDigits, minimumFractionDigits, maximumFractionDigits, minimumSignificantDigits, maximumSignificantDigits, and useGrouping. Properties whose corresponding internal slots have the value *undefined* are not assigned.
Expand Down

0 comments on commit c84e3f0

Please sign in to comment.