UNPKG

@neo-one/smart-contract-compiler

Version:

NEO•ONE TypeScript smart contract compiler.

50 lines (48 loc) 1.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CacheStorageHelper = void 0; const constants_1 = require("../../constants"); const Helper_1 = require("../Helper"); class CacheStorageHelper extends Helper_1.Helper { constructor() { super(...arguments); this.needsGlobal = true; this.needsGlobalOut = true; } emitGlobal(sb, node, _options) { sb.emitPushInt(node, constants_1.GlobalProperty.CacheStorage); sb.emitOp(node, 'NEWMAP'); sb.emitOp(node, 'SETITEM'); } emitGlobalOut(sb, node, optionsIn) { const options = sb.pushValueOptions(optionsIn); sb.emitPushInt(node, constants_1.GlobalProperty.CacheStorage); sb.emitOp(node, 'PICKITEM'); sb.emitSysCall(node, 'Neo.Runtime.GetTrigger'); sb.emitPushInt(node, 0x10); sb.emitHelper(node, options, sb.helpers.if({ condition: () => { sb.emitOp(node, 'NUMEQUAL'); }, whenTrue: () => { sb.emitHelper(node, options, sb.helpers.mapForEach({ each: () => { sb.emitSysCall(node, 'Neo.Storage.GetContext'); sb.emitSysCall(node, 'Neo.Storage.Put'); }, })); }, whenFalse: () => { sb.emitOp(node, 'DROP'); }, })); } emit(sb, node, options) { if (!options.pushValue) { return; } sb.emitHelper(node, options, sb.helpers.getGlobalProperty({ property: constants_1.GlobalProperty.CacheStorage })); } } exports.CacheStorageHelper = CacheStorageHelper; //# sourceMappingURL=CacheStorageHelper.js.map