-
-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathspan-start.ts
More file actions
25 lines (19 loc) · 718 Bytes
/
span-start.ts
File metadata and controls
25 lines (19 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import * as frontend from 'llparse-frontend';
import { Node } from './base';
export class SpanStart extends Node<frontend.node.SpanStart> {
public doBuild(out: string[]): void {
// Prevent spurious empty spans
this.prologue(out);
const ctx = this.compilation;
const field = this.ref.field;
const posField = ctx.spanPosField(field.index);
out.push(`${posField} = (void*) ${ctx.posArg()};`);
if (field.callbacks.length > 1) {
const cbField = ctx.spanCbField(field.index);
const callback = ctx.unwrapCode(this.ref.callback);
out.push(`${cbField} = ${ctx.buildCode(callback)};`);
}
const otherwise = this.ref.otherwise!;
this.tailTo(out, otherwise);
}
}