Skip to content

Commit f15b006

Browse files
committed
Make OriginalScopeStart production context-free
1 parent 0e191ce commit f15b006

File tree

1 file changed

+50
-28
lines changed

1 file changed

+50
-28
lines changed

spec.emu

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@
13741374
UnknownItem
13751375

13761376
OriginalScopeStart :
1377-
`B` ScopeFlags ScopeLine ScopeColumn ScopeName? ScopeKind?
1377+
`B` ScopeFlags ScopeLine ScopeColumn ScopeNameOrKind? ScopeKind?
13781378

13791379
OriginalScopeEnd :
13801380
`C` ScopeLine ScopeColumn
@@ -1395,7 +1395,7 @@
13951395
ScopeColumn :
13961396
Vlq
13971397

1398-
ScopeName :
1398+
ScopeNameOrKind :
13991399
Vlq
14001400

14011401
ScopeKind :
@@ -1404,7 +1404,7 @@
14041404
ScopeVariable :
14051405
Vlq
14061406
</emu-grammar>
1407-
<p>The VLQUnsignedValue of |ScopeFlags| encodes the presence of |ScopeName| and |ScopeKind| and marks the scope as a function:</p>
1407+
<p>The VLQUnsignedValue of |ScopeFlags| encodes the presence of |ScopeNameOrKind| and |ScopeKind| and marks the scope as a function:</p>
14081408
<emu-table id="table-scope-flags" caption="|ScopeFlags| bits">
14091409
<table>
14101410
<thead>
@@ -1415,11 +1415,11 @@
14151415
</thead>
14161416
<tr>
14171417
<td>0x1</td>
1418-
<td>Set if |ScopeName| is present.</td>
1418+
<td>|ScopeNameOrKind| is present and contains the scope's name.</td>
14191419
</tr>
14201420
<tr>
14211421
<td>0x2</td>
1422-
<td>Set if |ScopeKind| is present.</td>
1422+
<td>If 0x1 is also set, |ScopeKind| is present and contains the scope's kind. If 0x1 is not set, then |ScopeNameOrKind| is present and contains the scope's kind.</td>
14231423
</tr>
14241424
<tr>
14251425
<td>0x4</td>
@@ -1628,12 +1628,12 @@
16281628
<tr>
16291629
<td>[[ScopeNameIndex]]</td>
16301630
<td>a non-negative Number</td>
1631-
<td>|ScopeName|</td>
1631+
<td>|ScopeNameOrKind|</td>
16321632
</tr>
16331633
<tr>
16341634
<td>[[ScopeKindIndex]]</td>
16351635
<td>a non-negative Number</td>
1636-
<td>|ScopeKind|</td>
1636+
<td>|ScopeNameOrKind| and |ScopeKind|</td>
16371637
</tr>
16381638
<tr>
16391639
<td>[[ScopeVariableIndex]]</td>
@@ -1792,18 +1792,24 @@
17921792
</emu-alg>
17931793
<emu-grammar>
17941794
OriginalScopeStart :
1795-
`B` ScopeFlags ScopeLine ScopeColumn ScopeName? ScopeKind?
1795+
`B` ScopeFlags ScopeLine ScopeColumn ScopeNameOrKind? ScopeKind?
17961796
</emu-grammar>
17971797
<emu-alg>
17981798
1. Perform DecodeOriginalScopeItem of |ScopeLine| with arguments _scope_, _state_ and _names_.
17991799
1. Set _scope_.[[Start]].[[Line]] to _state_.[[ScopeLine]].
18001800
1. Perform DecodeOriginalScopeItem of |ScopeColumn| with arguments _scope_, _state_ and _names_.
18011801
1. Set _scope_.[[Start]].[[Column]] to _state_.[[ScopeColumn]].
18021802
1. Let _flags_ be the VLQUnsignedValue of |ScopeFlags|.
1803-
1. Assert: |ScopeName| is present if and only if, _flags_ & 0x1 = 0x1.
1804-
1. If |ScopeName| is present, perform DecodeOriginalScopeItem of |ScopeName| with arguments _scope_, _state_ and _names_.
1805-
1. Assert: |ScopeKind| is present if and only if, _flags_ & 0x2 = 0x2.
1806-
1. If |ScopeKind| is present, perform DecodeOriginalScopeItem of |ScopeKind| with arguments _scope_, _state_ and _names_.
1803+
1. If _flags_ & 0x3 = 0x1, then
1804+
1. Assert: |ScopeNameOrKind| is present and |ScopeKind| is not present.
1805+
1. DecodeOriginalScopeName(|ScopeNameOrKind|, _scope_, _state_, _names_).
1806+
1. Else if _flags_ & 0x3 = 0x2, then
1807+
1. Assert: |ScopeNameOrKind| is present and |ScopeKind| is not present.
1808+
1. DecodeOriginalScopeKind(|ScopeNameOrKind|, _scope_, _state_, _names_).
1809+
1. Else if _flags_ & 0x3 = 0x3, then
1810+
1. Assert: |ScopeNameOrKind| is present and |ScopeKind| is present.
1811+
1. DecodeOriginalScopeName(|ScopeNameOrKind|, _scope_, _state_, _names_).
1812+
1. DecodeOriginalScopeKind(|ScopeKind|, _scope_, _state_, _names_).
18071813
1. If _flags_ & 0x4 = 0x4, set _scope_.[[IsStackFrame]] to *true*.
18081814
</emu-alg>
18091815
<emu-grammar>
@@ -1861,32 +1867,48 @@
18611867
1. Set _state_.[[ScopeColumn]] to _state_.[[ScopeColumn]] + _relativeColumn_.
18621868
</emu-alg>
18631869
<emu-grammar>
1864-
ScopeName :
1870+
ScopeVariable :
18651871
Vlq
18661872
</emu-grammar>
18671873
<emu-alg>
1868-
1. Let _relativeName_ be the VLQSignedValue of |Vlq|.
1874+
1. Let _relativeVariable_ be the VLQSignedValue of |Vlq|.
1875+
1. Set _state_.[[ScopeVariableIndex]] to _state_.[[ScopeVariableIndex]] + _relativeVariable_.
1876+
1. Append _names_[_state_.[[ScopeVariableIndex]]] to _scope_.[[Variables]].
1877+
</emu-alg>
1878+
</emu-clause>
1879+
1880+
<emu-clause id="sec-DecodeOriginalScopeName" type="abstract operation">
1881+
<h1>
1882+
DecodeOriginalScopeName (
1883+
_name_: a |Vlq| Parse Node,
1884+
_scope_: a Original Scope Record,
1885+
_state_: a Decode Scope State Record,
1886+
_names_: a List of Strings,
1887+
)
1888+
</h1>
1889+
<dl class="header"></dl>
1890+
<emu-alg>
1891+
1. Let _relativeName_ be the VLQSignedValue of _name_.
18691892
1. Set _state_.[[ScopeNameIndex]] to _state_.[[ScopeNameIndex]] + _relativeName_.
18701893
1. Set _scope_.[[Name]] to _names_[_state_.[[ScopeNameIndex]]].
18711894
</emu-alg>
1872-
<emu-grammar>
1873-
ScopeKind :
1874-
Vlq
1875-
</emu-grammar>
1895+
</emu-clause>
1896+
1897+
<emu-clause id="sec-DecodeOriginalScopeKind" type="abstract operation">
1898+
<h1>
1899+
DecodeOriginalScopeKind (
1900+
_kind_: a |Vlq| Parse Node,
1901+
_scope_: a Original Scope Record,
1902+
_state_: a Decode Scope State Record,
1903+
_names_: a List of Strings,
1904+
)
1905+
</h1>
1906+
<dl class="header"></dl>
18761907
<emu-alg>
1877-
1. Let _relativeKind_ be the VLQSignedValue of |Vlq|.
1908+
1. Let _relativeKind_ be the VLQSignedValue of _kind_.
18781909
1. Set _state_.[[ScopeKindIndex]] to _state_.[[ScopeKindIndex]] + _relativeKind_.
18791910
1. Set _scope_.[[Kind]] to _names_[_state_.[[ScopeKindIndex]]].
18801911
</emu-alg>
1881-
<emu-grammar>
1882-
ScopeVariable :
1883-
Vlq
1884-
</emu-grammar>
1885-
<emu-alg>
1886-
1. Let _relativeVariable_ be the VLQSignedValue of |Vlq|.
1887-
1. Set _state_.[[ScopeVariableIndex]] to _state_.[[ScopeVariableIndex]] + _relativeVariable_.
1888-
1. Append _names_[_state_.[[ScopeVariableIndex]]] to _scope_.[[Variables]].
1889-
</emu-alg>
18901912
</emu-clause>
18911913
</emu-clause>
18921914

0 commit comments

Comments
 (0)