Skip to content

Commit

Permalink
Add missing if statement in GetSource()
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Jan 12, 2024
1 parent 479ad90 commit 7ce691a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3363,7 +3363,7 @@ <h1><span class="secnum">1.5.6</span> FormatMarkupPart ( <var>ctx</var>, <var>ma
<h1><span class="secnum">1.5.7</span> GetSource ( <var>ctx</var>, <var>value</var> )</h1>
<p>The abstract operation GetSource takes arguments <var>ctx</var> (a <emu-xref href="#messageformatcontext-record" id="_ref_49"><a href="#messageformatcontext-record">MessageFormatContext Record</a></emu-xref>) and <var>value</var> (an Object) and returns a String. Determines the "source" value for a data model Object. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>type</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"type"</emu-val>).</li><li>If <var>type</var> is <emu-val>"literal"</emu-val>, then<ol><li>Let <var>strValue</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"value"</emu-val>).</li><li>Modify <var>strValue</var> such that all <emu-val>"\"</emu-val> characters are replaced with <emu-val>"\"</emu-val>.</li><li>Modify <var>strValue</var> such that all <emu-val>"|"</emu-val> characters are replaced with <emu-val>"|"</emu-val>.</li><li>Return the string-concatenation of <emu-val>"|"</emu-val>, <var>strValue</var>, and <emu-val>"|"</emu-val>.</li></ol></li><li>If <var>type</var> is <emu-val>"variable"</emu-val>, then<ol><li>Let <var>name</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"name"</emu-val>).</li><li>Let <var>local</var> be !&nbsp;Get(<var>ctx</var>.<var class="field">[[LocalVariables]]</var>, <var>name</var>).</li><li>If <var>local</var> has an <var class="field">[[UnresolvedDeclaration]]</var> internal slot, then<ol><li>Let <var>decl</var> be <var>local</var>.<var class="field">[[UnresolvedDeclaration]]</var>.</li><li>If ?&nbsp;Get(<var>decl</var>, <emu-val>"type"</emu-val>) is <emu-val>"local"</emu-val>, then<ol><li>Let <var>declValue</var> be ?&nbsp;Get(<var>decl</var>, <emu-val>"value"</emu-val>).</li><li>Return ?&nbsp;<emu-xref aoid="GetSource" id="_ref_50"><a href="#sec-getsource">GetSource</a></emu-xref>(<var>ctx</var>, <var>declValue</var>).</li></ol></li></ol></li><li>Else if <var>local</var> has a <var class="field">[[MessageValue]]</var> internal slot, then<ol><li>Return <emu-xref aoid="MessageValueSource" id="_ref_51"><a href="#sec-messagevaluesource">MessageValueSource</a></emu-xref>(<var>local</var>.<var class="field">[[MessageValue]]</var>).</li></ol></li><li>Else,<ol><li>Assert: <var>local</var> has a <var class="field">[[ResolvedName]]</var> internal slot.</li><li>Assert: <var>local</var> has a <var class="field">[[ResolvedValue]]</var> internal slot.</li><li>Set <var>name</var> to <var>local</var>.<var class="field">[[ResolvedName]]</var>.</li></ol></li><li>Return the string-concatenation of <emu-val>"$"</emu-val> and <var>name</var>.</li></ol></li><li>If <var>type</var> is <emu-val>"markup"</emu-val>, then<ol><li>Let <var>kind</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"kind"</emu-val>).</li><li>Let <var>name</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"name"</emu-val>).</li><li>If <var>kind</var> is <emu-val>"open"</emu-val>, return the string-concatenation of <emu-val>"#"</emu-val> and <var>name</var>.</li><li>If <var>kind</var> is <emu-val>"standalone"</emu-val>, return the string-concatenation of <emu-val>"#"</emu-val>, <var>name</var>, and <emu-val>"/"</emu-val>.</li><li>If <var>kind</var> is <emu-val>"close"</emu-val>, return the string-concatenation of <emu-val>"/"</emu-val> and <var>name</var>.</li></ol></li><li>If <var>type</var> is <emu-val>"function"</emu-val>, then<ol><li>Let <var>name</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"name"</emu-val>).</li><li>Return the string-concatenation of <emu-val>":"</emu-val> and <var>name</var>.</li></ol></li><li>If <var>type</var> is <emu-val>"unsupported-annotation"</emu-val>, then<ol><li>Return ?&nbsp;Get(<var>value</var>, <emu-val>"sigil"</emu-val>).</li></ol></li><li>If <var>type</var> is <emu-val>"expression"</emu-val>, then<ol><li>Let <var>arg</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"arg"</emu-val>).</li><li>If <var>arg</var> is not <emu-val>undefined</emu-val>, return ?&nbsp;<emu-xref aoid="GetSource" id="_ref_52"><a href="#sec-getsource">GetSource</a></emu-xref>(<var>ctx</var>, <var>arg</var>).</li><li>Let <var>annotation</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"annotation"</emu-val>).</li><li>If <var>annotation</var> is not <emu-val>undefined</emu-val>, return ?&nbsp;<emu-xref aoid="GetSource" id="_ref_53"><a href="#sec-getsource">GetSource</a></emu-xref>(<var>ctx</var>, <var>annotation</var>).</li></ol></li><li>Return <emu-val>"\uFFFD"</emu-val>.</li></ol></emu-alg>
<emu-alg><ol><li>Let <var>type</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"type"</emu-val>).</li><li>If <var>type</var> is <emu-val>"literal"</emu-val>, then<ol><li>Let <var>strValue</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"value"</emu-val>).</li><li>Modify <var>strValue</var> such that all <emu-val>"\"</emu-val> characters are replaced with <emu-val>"\"</emu-val>.</li><li>Modify <var>strValue</var> such that all <emu-val>"|"</emu-val> characters are replaced with <emu-val>"|"</emu-val>.</li><li>Return the string-concatenation of <emu-val>"|"</emu-val>, <var>strValue</var>, and <emu-val>"|"</emu-val>.</li></ol></li><li>If <var>type</var> is <emu-val>"variable"</emu-val>, then<ol><li>Let <var>name</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"name"</emu-val>).</li><li>Let <var>local</var> be !&nbsp;Get(<var>ctx</var>.<var class="field">[[LocalVariables]]</var>, <var>name</var>).</li><li>If <var>local</var> is an Object, then<ol><li>If <var>local</var> has an <var class="field">[[UnresolvedDeclaration]]</var> internal slot, then<ol><li>Let <var>decl</var> be <var>local</var>.<var class="field">[[UnresolvedDeclaration]]</var>.</li><li>If ?&nbsp;Get(<var>decl</var>, <emu-val>"type"</emu-val>) is <emu-val>"local"</emu-val>, then<ol><li>Let <var>declValue</var> be ?&nbsp;Get(<var>decl</var>, <emu-val>"value"</emu-val>).</li><li>Return ?&nbsp;<emu-xref aoid="GetSource" id="_ref_50"><a href="#sec-getsource">GetSource</a></emu-xref>(<var>ctx</var>, <var>declValue</var>).</li></ol></li></ol></li><li>Else if <var>local</var> has a <var class="field">[[MessageValue]]</var> internal slot, then<ol><li>Return <emu-xref aoid="MessageValueSource" id="_ref_51"><a href="#sec-messagevaluesource">MessageValueSource</a></emu-xref>(<var>local</var>.<var class="field">[[MessageValue]]</var>).</li></ol></li><li>Else,<ol><li>Assert: <var>local</var> has a <var class="field">[[ResolvedName]]</var> internal slot.</li><li>Assert: <var>local</var> has a <var class="field">[[ResolvedValue]]</var> internal slot.</li><li>Set <var>name</var> to <var>local</var>.<var class="field">[[ResolvedName]]</var>.</li></ol></li></ol></li><li>Return the string-concatenation of <emu-val>"$"</emu-val> and <var>name</var>.</li></ol></li><li>If <var>type</var> is <emu-val>"markup"</emu-val>, then<ol><li>Let <var>kind</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"kind"</emu-val>).</li><li>Let <var>name</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"name"</emu-val>).</li><li>If <var>kind</var> is <emu-val>"open"</emu-val>, return the string-concatenation of <emu-val>"#"</emu-val> and <var>name</var>.</li><li>If <var>kind</var> is <emu-val>"standalone"</emu-val>, return the string-concatenation of <emu-val>"#"</emu-val>, <var>name</var>, and <emu-val>"/"</emu-val>.</li><li>If <var>kind</var> is <emu-val>"close"</emu-val>, return the string-concatenation of <emu-val>"/"</emu-val> and <var>name</var>.</li></ol></li><li>If <var>type</var> is <emu-val>"function"</emu-val>, then<ol><li>Let <var>name</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"name"</emu-val>).</li><li>Return the string-concatenation of <emu-val>":"</emu-val> and <var>name</var>.</li></ol></li><li>If <var>type</var> is <emu-val>"unsupported-annotation"</emu-val>, then<ol><li>Return ?&nbsp;Get(<var>value</var>, <emu-val>"sigil"</emu-val>).</li></ol></li><li>If <var>type</var> is <emu-val>"expression"</emu-val>, then<ol><li>Let <var>arg</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"arg"</emu-val>).</li><li>If <var>arg</var> is not <emu-val>undefined</emu-val>, return ?&nbsp;<emu-xref aoid="GetSource" id="_ref_52"><a href="#sec-getsource">GetSource</a></emu-xref>(<var>ctx</var>, <var>arg</var>).</li><li>Let <var>annotation</var> be ?&nbsp;Get(<var>value</var>, <emu-val>"annotation"</emu-val>).</li><li>If <var>annotation</var> is not <emu-val>undefined</emu-val>, return ?&nbsp;<emu-xref aoid="GetSource" id="_ref_53"><a href="#sec-getsource">GetSource</a></emu-xref>(<var>ctx</var>, <var>annotation</var>).</li></ol></li><li>Return <emu-val>"\uFFFD"</emu-val>.</li></ol></emu-alg>
<emu-clause id="sec-messagevaluesource" type="abstract operation" aoid="MessageValueSource">
<h1><span class="secnum">1.5.7.1</span> MessageValueSource ( <var>mv</var> )</h1>
Expand Down
23 changes: 12 additions & 11 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -868,17 +868,18 @@ contributors: Eemeli Aro
1. If _type_ is *"variable"*, then
1. Let _name_ be ? Get(_value_, *"name"*).
1. Let _local_ be ! Get(_ctx_.[[LocalVariables]], _name_).
1. If _local_ has an [[UnresolvedDeclaration]] internal slot, then
1. Let _decl_ be _local_.[[UnresolvedDeclaration]].
1. If ? Get(_decl_, *"type"*) is *"local"*, then
1. Let _declValue_ be ? Get(_decl_, *"value"*).
1. Return ? GetSource(_ctx_, _declValue_).
1. Else if _local_ has a [[MessageValue]] internal slot, then
1. Return MessageValueSource(_local_.[[MessageValue]]).
1. Else,
1. Assert: _local_ has a [[ResolvedName]] internal slot.
1. Assert: _local_ has a [[ResolvedValue]] internal slot.
1. Set _name_ to _local_.[[ResolvedName]].
1. If _local_ is an Object, then
1. If _local_ has an [[UnresolvedDeclaration]] internal slot, then
1. Let _decl_ be _local_.[[UnresolvedDeclaration]].
1. If ? Get(_decl_, *"type"*) is *"local"*, then
1. Let _declValue_ be ? Get(_decl_, *"value"*).
1. Return ? GetSource(_ctx_, _declValue_).
1. Else if _local_ has a [[MessageValue]] internal slot, then
1. Return MessageValueSource(_local_.[[MessageValue]]).
1. Else,
1. Assert: _local_ has a [[ResolvedName]] internal slot.
1. Assert: _local_ has a [[ResolvedValue]] internal slot.
1. Set _name_ to _local_.[[ResolvedName]].
1. Return the string-concatenation of *"$"* and _name_.
1. If _type_ is *"markup"*, then
1. Let _kind_ be ? Get(_value_, *"kind"*).
Expand Down

0 comments on commit 7ce691a

Please sign in to comment.