UNPKG

@neo-one/smart-contract-compiler

Version:

NEO•ONE TypeScript smart contract compiler.

35 lines (33 loc) 1.44 kB
import { StructuredStorageBaseHelper } from './StructuredStorageBaseHelper'; export class ForEachStructuredStorageHelper extends StructuredStorageBaseHelper { constructor({ each, ...rest }) { super(rest); this.each = each; } emit(sb, node, optionsIn) { const options = sb.pushValueOptions(optionsIn); const size = sb.scope.addUnique(); sb.emitOp(node, 'DUP'); sb.emitHelper(node, options, sb.helpers.getStructuredStorageSize({ type: this.type })); sb.scope.set(sb, node, options, size); sb.emitHelper(node, optionsIn, sb.helpers.forEachStructuredStorageBase({ type: this.type, each: (innerOptions) => { sb.scope.get(sb, node, innerOptions, size); sb.emitHelper(node, sb.pushValueOptions(innerOptions), sb.helpers.if({ condition: () => { sb.emitHelper(node, sb.pushValueOptions(innerOptions), sb.helpers.handleValueStructuredStorage); }, whenTrue: () => { this.each(sb.noPushValueOptions(innerOptions)); }, whenFalse: () => { sb.emitOp(node, 'DROP'); sb.emitOp(node, 'DROP'); }, })); }, })); } } //# sourceMappingURL=ForEachStructuredStorageHelper.js.map