UNPKG

@neo-one/smart-contract-compiler

Version:

NEO•ONE TypeScript smart contract compiler.

27 lines (25 loc) 977 B
import { tsUtils } from '@neo-one/ts-utils'; import ts from 'typescript'; import { NodeCompiler } from '../NodeCompiler'; export class WhileStatementCompiler extends NodeCompiler { constructor() { super(...arguments); this.kind = ts.SyntaxKind.WhileStatement; } visitNode(sb, node, optionsIn) { const options = sb.pushValueOptions(optionsIn); sb.emitHelper(node, sb.noPushValueOptions(options), sb.helpers.forLoop({ condition: () => { const expr = tsUtils.expression.getExpression(node); sb.visit(expr, options); sb.emitHelper(node, options, sb.helpers.toBoolean({ type: sb.context.analysis.getType(expr) })); }, each: (innerOptions) => { sb.visit(tsUtils.statement.getStatement(node), innerOptions); }, cleanup: () => { }, })); } } //# sourceMappingURL=WhileStatementCompiler.js.map