UNPKG

@neo-one/smart-contract-compiler

Version:

NEO•ONE TypeScript smart contract compiler.

73 lines (71 loc) 2.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ArrayConcat = void 0; const ts_utils_1 = require("@neo-one/ts-utils"); const BuiltinInstanceMemberCall_1 = require("../BuiltinInstanceMemberCall"); class ArrayConcat extends BuiltinInstanceMemberCall_1.BuiltinInstanceMemberCall { canCall() { return true; } emitCall(sb, func, node, optionsIn, visited) { const options = sb.pushValueOptions(optionsIn); if (!visited) { sb.visit(ts_utils_1.tsUtils.expression.getExpression(func), options); } const handleArray = (innerOptions) => { sb.emitHelper(node, innerOptions, sb.helpers.unwrapArray); }; const handleOther = () => { sb.emitPushInt(node, 0); sb.emitOp(node, 'NEWARRAY'); sb.emitOp(node, 'TUCK'); sb.emitOp(node, 'SWAP'); sb.emitOp(node, 'APPEND'); }; sb.emitHelper(node, options, sb.helpers.unwrapArray); sb.emitHelper(node, options, sb.helpers.cloneArray); ts_utils_1.tsUtils.argumented.getArguments(node).forEach((arg) => { sb.visit(arg, options); sb.emitHelper(node, options, sb.helpers.forBuiltinType({ type: sb.context.analysis.getType(arg), array: handleArray, arrayStorage: handleOther, boolean: handleOther, buffer: handleOther, null: handleOther, number: handleOther, object: handleOther, string: handleOther, symbol: handleOther, undefined: handleOther, map: handleOther, mapStorage: handleOther, set: handleOther, setStorage: handleOther, error: handleOther, forwardValue: handleOther, iteratorResult: handleOther, iterable: handleOther, iterableIterator: handleOther, transaction: handleOther, output: handleOther, attribute: handleOther, input: handleOther, account: handleOther, asset: handleOther, contract: handleOther, header: handleOther, block: handleOther, })); sb.emitHelper(node, options, sb.helpers.arrConcat); }); if (optionsIn.pushValue) { sb.emitHelper(node, options, sb.helpers.wrapArray); } else { sb.emitOp(node, 'DROP'); } } } exports.ArrayConcat = ArrayConcat; //# sourceMappingURL=concat.js.map