blob: 445da679f47513502ad5f05a81e231092891fb90 (
plain)
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
26
|
import * as frontend from 'llparse-frontend';
import { Compilation } from '../compilation';
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);
}
}
|