@neo-one/smart-contract-compiler
Version:
NEO•ONE TypeScript smart contract compiler.
26 lines (24 loc) • 735 B
JavaScript
import { Helper } from '../Helper';
export class CaseHelper extends Helper {
constructor(cases, defaultCase) {
super();
this.cases = cases;
this.defaultCase = defaultCase;
}
emit(sb, node, options) {
this.addCase(sb, node, options);
}
addCase(sb, node, options, idx = 0) {
if (idx >= this.cases.length) {
this.defaultCase();
}
else {
sb.emitHelper(node, options, sb.helpers.if({
condition: this.cases[idx].condition,
whenTrue: this.cases[idx].whenTrue,
whenFalse: () => this.addCase(sb, node, options, idx + 1),
}));
}
}
}
//# sourceMappingURL=CaseHelper.js.map