Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/implementation/c/code/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@ import { Update } from './update';

export * from './base';

class Match extends External<frontend.code.External> {}
class Span extends External<frontend.code.Span> {}
class Value extends External<frontend.code.Value> {}

export default {
And,
IsEqual,
Load,
Match: class Match extends External<frontend.code.External> {},
Match,
MulAdd,
Or,
Span: class Span extends External<frontend.code.Span> {},
Span,
Store,
Test,
Update,
Value: class Value extends External<frontend.code.Value> {},
Value,
};
2 changes: 1 addition & 1 deletion src/implementation/c/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class CCompiler {
const posField = ctx.spanPosField(span.index);
let callback: string;
if (span.callbacks.length === 1) {
callback = ctx.buildCode(ctx.unwrapCode(span.callbacks[0]));
callback = ctx.buildCode(ctx.unwrapCode(span.callbacks[0]!));
} else {
callback = `(${info.prefix}__span_cb) ` + ctx.spanCbField(span.index);
callback = `(${callback})`;
Expand Down
4 changes: 3 additions & 1 deletion src/implementation/c/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import { TableLookup } from './table-lookup';

export { Node } from './base';

class Error extends ErrorNode<frontend.node.Error> {}

export default {
Consume,
Empty,
Error: class Error extends ErrorNode<frontend.node.Error> {},
Error,
Invoke,
Pause,
Sequence,
Expand Down
8 changes: 5 additions & 3 deletions src/implementation/c/node/table-lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ export class TableLookup extends Node<frontend.node.TableLookup> {
const current = transform.build(ctx, `*${ctx.posArg()}`);
out.push(`switch (${table.name}[(uint8_t) ${current}]) {`);

for (const [ index ] of this.ref.edges.entries()) {
for (const [ index, edge ] of this.ref.edges.entries()) {
out.push(` case ${index + 1}: {`);

const tmp: string[] = [];
const edge = this.ref.edges[index];
this.tailTo(tmp, {
noAdvance: edge.noAdvance,
node: edge.node,
Expand Down Expand Up @@ -77,7 +76,10 @@ export class TableLookup extends Node<frontend.node.TableLookup> {
}

const edge = this.ref.edges[0];
if (edge.node.ref !== this.ref) {
if (
!edge ||
edge.node.ref !== this.ref
) {
return false;
}

Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"declaration": true,
"pretty": true,
"sourceMap": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true
},
"include": [
Expand Down