UNPKG

@neo-one/smart-contract-compiler

Version:

NEO•ONE TypeScript smart contract compiler.

50 lines (48 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BindFunctionThisHelper = void 0; const Helper_1 = require("../Helper"); class BindFunctionThisHelper extends Helper_1.Helper { constructor(options) { super(); this.overwrite = options.overwrite; } emit(sb, node, options) { if (!options.pushValue) { sb.emitOp(node, 'DROP'); sb.emitOp(node, 'DROP'); return; } let whenTrue; if (this.overwrite) { whenTrue = () => { sb.emitOp(node, 'SWAP'); sb.emitPushInt(node, 2); sb.emitOp(node, 'SETITEM'); }; } else { whenTrue = () => { sb.emitOp(node, 'DROP'); sb.emitOp(node, 'DROP'); }; } sb.emitHelper(node, options, sb.helpers.cloneFunction); sb.emitOp(node, 'TUCK'); sb.emitOp(node, 'DUP'); sb.emitHelper(node, options, sb.helpers.if({ condition: () => { sb.emitOp(node, 'ARRAYSIZE'); sb.emitPushInt(node, 3); sb.emitOp(node, 'NUMEQUAL'); }, whenTrue, whenFalse: () => { sb.emitOp(node, 'SWAP'); sb.emitOp(node, 'APPEND'); }, })); } } exports.BindFunctionThisHelper = BindFunctionThisHelper; //# sourceMappingURL=BindFunctionThisHelper.js.map