UNPKG

@neo-one/smart-contract-compiler

Version:

NEO•ONE TypeScript smart contract compiler.

46 lines (44 loc) 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FunctionLikeHelper = void 0; const ts_utils_1 = require("@neo-one/ts-utils"); const constants_1 = require("../../constants"); const Helper_1 = require("../Helper"); class FunctionLikeHelper extends Helper_1.Helper { emit(sb, node, optionsIn) { if (!ts_utils_1.tsUtils.overload.isImplementation(node)) { return; } if (sb.context.analysis.isSmartContractMixinFunction(node)) { return; } const func = node; const options = sb.pushValueOptions(optionsIn); let name; const nodeName = ts_utils_1.tsUtils.node.getName(node); if (nodeName !== undefined) { name = sb.scope.add(ts_utils_1.tsUtils.node.getNameOrThrow(node)); } sb.emitHelper(func, options, sb.helpers.createCallArray); sb.emitHelper(func, options, sb.helpers.createFunctionObject({ property: constants_1.InternalObjectProperty.Call, })); if (ts_utils_1.tsUtils.modifier.isNamedExport(node) || ts_utils_1.tsUtils.modifier.isDefaultExport(node)) { sb.emitOp(node, 'DUP'); sb.emitHelper(node, options, sb.helpers.exportSingle({ name: ts_utils_1.tsUtils.modifier.isNamedExport(node) ? ts_utils_1.tsUtils.node.getNameOrThrow(node) : undefined, defaultExport: ts_utils_1.tsUtils.modifier.isDefaultExport(node), })); } if (!optionsIn.pushValue) { if (name === undefined) { sb.emitOp(node, 'DROP'); } else { sb.scope.set(sb, node, options, name); } } } } exports.FunctionLikeHelper = FunctionLikeHelper; //# sourceMappingURL=FunctionLikeHelper.js.map