UNPKG

@neo-one/smart-contract-compiler

Version:

NEO•ONE TypeScript smart contract compiler.

33 lines (31 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VariableStatementCompiler = void 0; const tslib_1 = require("tslib"); const ts_utils_1 = require("@neo-one/ts-utils"); const typescript_1 = tslib_1.__importDefault(require("typescript")); const NodeCompiler_1 = require("../NodeCompiler"); class VariableStatementCompiler extends NodeCompiler_1.NodeCompiler { constructor() { super(...arguments); this.kind = typescript_1.default.SyntaxKind.VariableStatement; } visitNode(sb, node, optionsIn) { sb.visit(ts_utils_1.tsUtils.variable.getDeclarationList(node), optionsIn); if (ts_utils_1.tsUtils.modifier.isNamedExport(node)) { const options = sb.pushValueOptions(optionsIn); sb.emitHelper(node, options, sb.helpers.getCurrentModule); ts_utils_1.tsUtils.variable.getDeclarations(ts_utils_1.tsUtils.variable.getDeclarationList(node)).forEach((decl) => { const name = ts_utils_1.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: ts_utils_1.tsUtils.node.getName(decl) })); } }); sb.emitOp(node, 'DROP'); } } } exports.VariableStatementCompiler = VariableStatementCompiler; //# sourceMappingURL=VariableStatementCompiler.js.map