UNPKG

@neo-one/smart-contract-compiler

Version:

NEO•ONE TypeScript smart contract compiler.

33 lines (31 loc) 1.04 kB
import { tsUtils } from '@neo-one/ts-utils'; import { BuiltinInstanceMemberCall } from '../BuiltinInstanceMemberCall'; export class ArrayPush extends BuiltinInstanceMemberCall { constructor() { super(...arguments); this.isReadonly = false; } canCall(_sb, _func, _node) { return true; } emitCall(sb, func, node, optionsIn, visited) { const options = sb.pushValueOptions(optionsIn); if (!visited) { sb.visit(tsUtils.expression.getExpression(func), options); } sb.emitHelper(node, options, sb.helpers.unwrapArray); tsUtils.argumented.getArguments(node).forEach((arg) => { sb.emitOp(node, 'DUP'); sb.visit(arg, options); sb.emitOp(node, 'APPEND'); }); sb.emitOp(node, 'ARRAYSIZE'); if (optionsIn.pushValue) { sb.emitHelper(node, options, sb.helpers.wrapNumber); } else { sb.emitOp(node, 'DROP'); } } } //# sourceMappingURL=push.js.map