Skip to content

Commit

Permalink
Normative: fix spec bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed Mar 26, 2024
1 parent 29eacc4 commit ac67644
Show file tree
Hide file tree
Showing 4 changed files with 397 additions and 482 deletions.
106 changes: 21 additions & 85 deletions assets/ecmarkup.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ body {
word-wrap: break-word;
font-size: 18px;
line-height: 1.5;
font-family:
IBM Plex Serif,
serif;
font-family: IBM Plex Serif, serif;
font-variant-numeric: slashed-zero;
padding: 0;
margin: 0;
Expand All @@ -110,8 +108,6 @@ body {

#spec-container {
padding: 0 20px;
max-width: 80rem;
margin: 0 auto;
flex-grow: 1;
flex-basis: 66%;
box-sizing: border-box;
Expand Down Expand Up @@ -157,9 +153,7 @@ span.e-user-code::before {
line-height: normal;
vertical-align: middle;
text-transform: uppercase;
font-family:
IBM Plex Sans,
sans-serif;
font-family: IBM Plex Sans, sans-serif;
font-weight: 900;
font-size: x-small;
}
Expand All @@ -182,10 +176,7 @@ span.e-user-code::before {

code {
font-weight: bold;
font-family:
Comic Code,
IBM Plex Mono,
monospace;
font-family: Comic Code, IBM Plex Mono, monospace;
white-space: pre;
}

Expand Down Expand Up @@ -250,9 +241,7 @@ var.referenced6 {
}

emu-const {
font-family:
IBM Plex Sans,
sans-serif;
font-family: IBM Plex Sans, sans-serif;
font-variant: small-caps;
text-transform: uppercase;
}
Expand Down Expand Up @@ -321,7 +310,6 @@ emu-note {
border-left: 5px solid #52e052;
background: #e9fbe9;
padding: 10px 10px 10px 0;
overflow-x: auto;
}

emu-note > span.note {
Expand Down Expand Up @@ -452,9 +440,7 @@ emu-rhs emu-nt {

emu-t {
display: inline-block;
font-family:
IBM Plex Mono,
monospace;
font-family: IBM Plex Mono, monospace;
font-weight: bold;
white-space: nowrap;
text-indent: 0;
Expand Down Expand Up @@ -489,9 +475,7 @@ emu-mods {
emu-params,
emu-opt {
margin-right: 1ex;
font-family:
IBM Plex Mono,
monospace;
font-family: IBM Plex Mono, monospace;
}

emu-params,
Expand All @@ -505,9 +489,7 @@ emu-opt {

emu-gprose {
font-size: 0.9em;
font-family:
IBM Plex Sans,
sans-serif;
font-family: IBM Plex Sans, sans-serif;
}

emu-production emu-gprose {
Expand Down Expand Up @@ -731,8 +713,7 @@ emu-annex emu-annex emu-annex emu-annex emu-annex emu-annex {
/* Figures and tables */
figure {
display: block;
overflow-x: auto;
margin: 1.5em 0;
margin: 1em 0 3em 0;
}
figure object {
display: block;
Expand Down Expand Up @@ -795,7 +776,7 @@ table.lightweight-table th {
background-color: rgba(249, 241, 172, 1);
}
100% {
background-color: rgba(249, 241, 172, 0);
background-color: rgba(249, 241, 172, 0)
}
}
#spec-container :target:not(emu-annex, emu-clause, emu-intro, emu-note, body) {
Expand Down Expand Up @@ -913,68 +894,26 @@ tr.del > td {
display: block;
}

#menu-pins .unpin-all {
border: none;
background: #ccc;
border-radius: 4px;
height: 18px;
font-size: 12px;
margin: 0 5px 0 10px;
font-family: IBM Plex Sans;
}
#menu-pins .unpin-all:hover {
background: #ddd;
}

#menu-pins-list {
margin: 0;
padding: 0;
counter-reset: pins-counter;
}

#menu-pins-list > li {
display: flex;
align-items: stretch;
gap: 4px;
margin: 3px 1px;
border-radius: 4px;
}

#menu-pins-list > li > a {
flex-grow: 1;
align-self: center;
}

#menu-pins-list > li:before,
#menu-pins-list > li > .unpin {
flex-shrink: 0;
flex-grow: 0;
text-align: center;
padding: 1px 3px;
border-radius: 4px;
background: none;
border: none;
}
#menu-pins-list > li:before,
#menu-pins-list > li > .unpin:hover {
background: #ccc;
}

#menu-pins-list > li > .unpin,
#menu-pins .unpin-all {
cursor: pointer;
}
#menu-pins-list > li > .unpin:hover,
#menu-pins .unpin-all:hover {
color: #bb1212;
}

#menu-pins-list > li:before {
content: counter(pins-counter);
counter-increment: pins-counter;
font-size: 16px;
display: inline-block;
width: 25px;
text-align: center;
border: 1px solid #bbb;
padding: 2px;
margin: 4px;
box-sizing: border-box;
line-height: 1em;
background-color: #ccc;
border-radius: 4px;
}

#menu-toc > ol {
padding: 0;
flex-grow: 1;
Expand Down Expand Up @@ -1071,6 +1010,7 @@ tr.del > td {
flex-grow: 0;
flex-shrink: 0;
font-size: 80%;
cursor: row-resize;
user-select: none;
}

Expand Down Expand Up @@ -1345,16 +1285,12 @@ li.menu-search-result-term:before {
flex-direction: column;
}

#references-pane > .menu-pane-header {
cursor: row-resize;
}

#references-pane-container.active {
display: flex;
}

#references-pane-close:after {
content: '\2716';
content: '';
float: right;
cursor: pointer;
}
Expand Down
58 changes: 17 additions & 41 deletions assets/ecmarkup.js

Large diffs are not rendered by default.

652 changes: 325 additions & 327 deletions index.html

Large diffs are not rendered by default.

63 changes: 34 additions & 29 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -2428,7 +2428,8 @@ contributors:
1. Let _resultArray_ be CreateArrayFromList(_result_).
1. NOTE: "The following steps will not trigger any user code" ends here.
1. If |RegularExpressionPattern| is <emu-grammar>RegularExpressionPattern : RegularExpressionLiteral `(` MatchList `)`</emu-grammar>, then
1. Return ? ListPatternMatches of |MatchList| with arguments _resultArray_ and _cacheGroup_.
1. Let _iterator_ be ? GetIteratorCached(_resultArray_, _cacheGroup_).
1. Return ? ListPatternMatches of |MatchList| with arguments _iterator_ and _cacheGroup_.
1. Return *true*.
</emu-alg>
<emu-note type="editor" class="show-ao-annotations">
Expand Down Expand Up @@ -2526,11 +2527,12 @@ contributors:
1. Let _value_ be ? GetValue(_ref_).
1. If _ref_ is a Reference Record and IsPropertyReference(_ref_) is *true*, let _receiver_ be GetThisValue(_ref_).
1. Else, let _receiver_ be *null*.
1. Let _listSubject_ be ? InvokeCustomMatcher(_value_, _subject_, _cacheGroup_, ~list~, _receiver_).
1. Assert: _listSubject_ is an Object.
1. Let _listMatchResult_ be ? InvokeCustomMatcher(_value_, _subject_, _cacheGroup_, ~list~, _receiver_).
1. If _listMatchResult_ is *false*, return *false*.
1. Assert: _listMatchResult_ is an Iterator Record.
1. If |MatchList| is not present, then
1. Return ? FinishListMatch(_listSubject_, _cacheGroup_, 0).
1. Return ? ListPatternMatches of |MatchList| with arguments _listSubject_ and _cacheGroup_.
1. Return ? FinishListMatch(_listMatchResult_, _cacheGroup_, 0).
1. Return ? ListPatternMatches of |MatchList| with arguments _listMatchResult_ and _cacheGroup_.
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -2696,7 +2698,7 @@ contributors:
<emu-clause id="sec-list-pattern-matches" type="sdo">
<h1>
Runtime Semantics: ListPatternMatches (
_subject_: an Iterator Record,
_iterator_: an Iterator Record,
_cacheGroup_: a %Map%,
): either a normal completion containing a Boolean or an abrupt completion
</h1>
Expand All @@ -2708,34 +2710,34 @@ contributors:
<emu-alg>
1. Let _visitedCount_ be 0.
1. If |Elision| is present, then
1. If ? GetIteratorNthValueCached(_subject_, _cacheGroup_, 0) is ~not-matched~, return *false*.
1. If ? GetIteratorNthValueCached(_iterator_, _cacheGroup_, 0) is ~not-matched~, return *false*.
1. Set _visitedCount_ to 1.
1. If |MatchRestElement| is present, then
1. Let _matches_ be ? ListPatternInnerMatches of |MatchRestElement| with arguments _subject_, _cacheGroup_ and _visitedCount_.
1. Return ? FinishListMatch(_subject_, _cacheGroup_, _matches_).
1. Return ? FinishListMatch(_subject_, _cacheGroup_, _visitedCount_).
1. Let _matches_ be ? ListPatternInnerMatches of |MatchRestElement| with arguments _iterator_, _cacheGroup_ and _visitedCount_.
1. Return ? FinishListMatch(_iterator_, _cacheGroup_, _matches_).
1. Return ? FinishListMatch(_iterator_, _cacheGroup_, _visitedCount_).
</emu-alg>
<emu-grammar>
MatchList : MatchElementList
</emu-grammar>
<emu-alg>
1. Let _matches_ be ? ListPatternInnerMatches of |MatchElementList| with arguments _subject_, _cacheGroup_ and 0.
1. Return ? FinishListMatch(_subject_, _cacheGroup_, _matches_).
1. Let _matches_ be ? ListPatternInnerMatches of |MatchElementList| with arguments _iterator_, _cacheGroup_ and 0.
1. Return ? FinishListMatch(_iterator_, _cacheGroup_, _matches_).
</emu-alg>
<emu-grammar>
MatchList : MatchElementList `,` Elision? MatchRestElement?
</emu-grammar>
<emu-alg>
1. Let _visitedCount_ be ? ListPatternInnerMatches of |MatchElementList| with arguments _subject_, _cacheGroup_ and 0.
1. Let _visitedCount_ be ? ListPatternInnerMatches of |MatchElementList| with arguments _iterator_, _cacheGroup_ and 0.
1. If _visitedCount_ is ~not-matched~, return *false*.
1. Assert: _visitedCount_ is a non-negative integer.
1. If |Elision| is present, then
1. If ? GetIteratorNthValueCached(_subject_, _cacheGroup_, _visitedCount_) is ~not-matched~, return *false*.
1. If ? GetIteratorNthValueCached(_iterator_, _cacheGroup_, _visitedCount_) is ~not-matched~, return *false*.
1. Set _visitedCount_ to _visitedCount_ + 1.
1. If |MatchRestElement| is present, then
1. Let _matches_ be ? ListPatternInnerMatches of |MatchRestElement| with arguments _subject_, _cacheGroup_ and _visitedCount_.
1. Return ? FinishListMatch(_subject_, _cacheGroup_, _matches_).
1. Return ? FinishListMatch(_subject_, _cacheGroup_, _visitedCount_).
1. Let _matches_ be ? ListPatternInnerMatches of |MatchRestElement| with arguments _iterator_, _cacheGroup_ and _visitedCount_.
1. Return ? FinishListMatch(_iterator_, _cacheGroup_, _matches_).
1. Return ? FinishListMatch(_iterator_, _cacheGroup_, _visitedCount_).
</emu-alg>
<emu-note>
It is possible to use array-like object or IsArray semantics rather than iterator protocol if there is performance issue reported from the engine.
Expand All @@ -2745,7 +2747,7 @@ contributors:
<emu-clause id="sec-list-pattern-inner-matches" type="sdo">
<h1>
Runtime Semantics: ListPatternInnerMatches (
_subject_: an Iterator Record,
_iterator_: an Iterator Record,
_cacheGroup_: a %Map%,
_startIndex_: a non-negative integer,
): either a normal completion containing either a non-negative integer, ~unlimited~ or ~not-matched~, or an abrupt completion
Expand All @@ -2756,16 +2758,16 @@ contributors:
MatchElementList : MatchElisionElement
</emu-grammar>
<emu-alg>
1. Return ? ListPatternInnerMatches of |MatchElisionElement| with arguments _subject_, _cacheGroup_ and _startIndex_.
1. Return ? ListPatternInnerMatches of |MatchElisionElement| with arguments _iterator_, _cacheGroup_ and _startIndex_.
</emu-alg>
<emu-grammar>
MatchElementList : MatchElementList `,` MatchElisionElement
</emu-grammar>
<emu-alg>
1. Let _visitedCount_ be ? ListPatternInnerMatches of |MatchElementList| with arguments _subject_, _cacheGroup_ and _startIndex_.
1. Let _visitedCount_ be ? ListPatternInnerMatches of |MatchElementList| with arguments _iterator_, _cacheGroup_ and _startIndex_.
1. If _visitedCount_ is ~not-matched~, return ~not-matched~.
1. Assert: _visitedCount_ is a non-negative integer.
1. Let _matches_ be ? ListPatternInnerMatches of |MatchElisionElement| with arguments _subject_, _cacheGroup_ and _startIndex_ + _visitedCount_.
1. Let _matches_ be ? ListPatternInnerMatches of |MatchElisionElement| with arguments _iterator_, _cacheGroup_ and _startIndex_ + _visitedCount_.
1. If _matches_ is ~not-matched~, return ~not-matched~.
1. Assert: _matches_ is a non-negative integer.
1. Return _visitedCount_ + _matches_.
Expand All @@ -2776,9 +2778,9 @@ contributors:
<emu-alg>
1. Let _visitedCount_ be 0.
1. If |Elision| is present, then
1. If ? GetIteratorNthValueCached(_subject_, _cacheGroup_, _startIndex_) is ~not-matched~, return ~not-matched~.
1. If ? GetIteratorNthValueCached(_iterator_, _cacheGroup_, _startIndex_) is ~not-matched~, return ~not-matched~.
1. Set _visitedCount_ to _visitedCount_ + 1.
1. Let _matches_ be ? ListPatternInnerMatches of |MatchElement| with arguments _subject_, _cacheGroup_ and _startIndex_ + _visitedCount_.
1. Let _matches_ be ? ListPatternInnerMatches of |MatchElement| with arguments _iterator_, _cacheGroup_ and _startIndex_ + _visitedCount_.
1. If _matches_ is ~not-matched~, return ~not-matched~.
1. Assert: _matches_ is a non-negative integer.
1. Return _visitedCount_ + _matches_.
Expand All @@ -2787,7 +2789,7 @@ contributors:
MatchElement : MatchPattern `?`?
</emu-grammar>
<emu-alg>
1. Let _value_ be ? GetIteratorNthValueCached(_subject_, _cacheGroup_, _startIndex_).
1. Let _value_ be ? GetIteratorNthValueCached(_iterator_, _cacheGroup_, _startIndex_).
1. If _value_ is ~not-matched~, then
1. If `?` is present, return 1.
1. Return ~not-matched~.
Expand All @@ -2809,7 +2811,7 @@ contributors:
1. Let _i_ be _startIndex_.
1. Let _next_ be ~unused~.
1. Repeat, while _next_ is not ~not-matched~,
1. Set _next_ to ? GetIteratorNthValueCached(_subject_, _cacheGroup_, _i_).
1. Set _next_ to ? GetIteratorNthValueCached(_iterator_, _cacheGroup_, _i_).
1. If _next_ is not ~not-matched~, append _next_ to _elements_.
1. Set _i_ to _i_ + 1.
1. Let _rest_ be CreateArrayFromList(_elements_).
Expand Down Expand Up @@ -3183,9 +3185,13 @@ contributors:
<dl class="header">
</dl>
<emu-alg>
1. If _matcher_ is not an Object, return SameValueZero(_matcher_, _subject_).
1. If _matcher_ is not an Object, then
1. If _kind_ is ~boolean~, return SameValueZero(_matcher_, _subject_).
1. Throw a *TypeError* exception.
1. Let _f_ be ? Get(_matcher_, @@customMatcher).
1. If _f_ is *undefined*, return SameValueNonNumber(_matcher_, _subject_).
1. If _f_ is *undefined*, then
1. If _kind_ is ~boolean~, return SameValueNonNumber(_matcher_, _subject_).
1. Throw a *TypeError* exception.
1. If _kind_ is ~boolean~, let _hint_ be *"boolean"*.
1. Else, let _hint_ be *"list"*.
1. Let _result_ be ? Call(_f_, _matcher_, « _subject_, _hint_, _receiver_ »).
Expand Down Expand Up @@ -3407,7 +3413,7 @@ contributors:
<emu-clause id="sec-finish-list-match" type="abstract operation">
<h1>
FinishListMatch (
_subject_: an ECMAScript language value,
_iterator_: an Iterator Record,
_cacheGroup_: a %Map%,
_expectedLength_: either a non-negative integer, ~not-matched~ or ~unlimited~,
): either a normal completion containing a Boolean or an abrupt completion
Expand All @@ -3417,7 +3423,6 @@ contributors:
<emu-alg>
1. If _expectedLength_ is ~not-matched~, return *false*.
1. If _expectedLength_ is ~unlimited~, return *true*.
1. Let _iterator_ be ? GetIteratorCached(_subject_, _cacheGroup_).
1. Let _cache_ be GetMatchCache(_iterator_, _cacheGroup_).
1. Let _cachedLength_ be ! LengthOfArrayLike(! Get(_cache_, *"IteratedValues"*)).
1. If _cachedLength_ &gt; _expectedLength_, return *false*.
Expand Down

0 comments on commit ac67644

Please sign in to comment.