@neo-one/smart-contract-compiler
Version:
NEO•ONE TypeScript smart contract compiler.
28 lines (26 loc) • 1.15 kB
JavaScript
import { tsUtils } from '@neo-one/ts-utils';
import ts from 'typescript';
import { NodeCompiler } from '../NodeCompiler';
export class VariableStatementCompiler extends NodeCompiler {
constructor() {
super(...arguments);
this.kind = ts.SyntaxKind.VariableStatement;
}
visitNode(sb, node, optionsIn) {
sb.visit(tsUtils.variable.getDeclarationList(node), optionsIn);
if (tsUtils.modifier.isNamedExport(node)) {
const options = sb.pushValueOptions(optionsIn);
sb.emitHelper(node, options, sb.helpers.getCurrentModule);
tsUtils.variable.getDeclarations(tsUtils.variable.getDeclarationList(node)).forEach((decl) => {
const name = tsUtils.node.getName(decl);
if (name !== undefined) {
sb.emitOp(node, 'DUP');
sb.scope.get(sb, node, options, name);
sb.emitHelper(node, options, sb.helpers.export({ name: tsUtils.node.getName(decl) }));
}
});
sb.emitOp(node, 'DROP');
}
}
}
//# sourceMappingURL=VariableStatementCompiler.js.map