Skip to content

Commit

Permalink
Propagate the effect from emu-meta steps to AOs
Browse files Browse the repository at this point in the history
  • Loading branch information
syg committed Dec 10, 2021
1 parent f9ee8b6 commit 236ce06
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
17 changes: 16 additions & 1 deletion src/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,25 @@ import type { Context } from './Context';

import Builder from './Builder';

import { validateEffects } from './utils';

export default class Meta extends Builder {
static elements = ['EMU-META'];

static async enter({ spec, node }: Context) {
static async enter({ spec, node, clauseStack }: Context) {
const parent = clauseStack[clauseStack.length - 1] || null;
if (node.hasAttribute('effects') && parent !== null) {
const effects = validateEffects(spec, node.getAttribute('effects')!.split(',').map(c => c.trim()), node);
for (const effect of effects) {
if (!parent.effects.includes(effect)) {
parent.effects.push(effect);
if (!spec._effectWorklist.has(effect)) {
spec._effectWorklist.set(effect, []);
}
spec._effectWorklist.get(effect)!.push(parent);
}
}
}
spec._emuMetasToRender.add(node);
}

Expand Down
2 changes: 1 addition & 1 deletion test/baselines/generated-reference/effect-user-code.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<emu-clause id="sec-user-code" type="abstract operation" aoid="UserCode">
<h1><span class="secnum">1</span> UserCode ( )</h1>
<p>The abstract operation UserCode takes no arguments. It performs the following steps when called:</p>
<emu-alg><ol><li>Call user code.</li></ol></emu-alg>
<emu-alg><ol><li><span class="e-user-code">Call user code</span>.</li></ol></emu-alg>
</emu-clause>

<emu-clause id="sec-nop" type="abstract operation" aoid="Nop">
Expand Down
4 changes: 1 addition & 3 deletions test/baselines/sources/effect-user-code.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
<emu-clause id="sec-user-code" type="abstract operation">
<h1>UserCode ( )</h1>
<dl class="header">
<dt>effects</dt>
<dd>user-code</dd>
</dl>
<emu-alg>
1. Call user code.
1. <emu-meta effects="user-code">Call user code</emu-meta>.
</emu-alg>
</emu-clause>

Expand Down

0 comments on commit 236ce06

Please sign in to comment.