UNPKG

@neo-one/smart-contract-compiler-esnext-esm

Version:

NEO•ONE TypeScript smart contract compiler.

32 lines (30 loc) 1.19 kB
import { tsUtils } from '@neo-one/ts-utils-esnext-esm'; import { Helper } from '../Helper'; export class IsIterableHelper extends Helper { emit(sb, node, options) { if (!options.pushValue) { sb.emitOp(node, 'DROP'); return; } const pushTrue = () => { sb.emitPushBoolean(node, true); }; const pushFalse = () => { sb.emitPushBoolean(node, false); }; sb.emitHelper(node, options, sb.helpers.forIterableType({ array: pushTrue, map: pushTrue, set: pushTrue, arrayStorage: pushTrue, mapStorage: pushTrue, setStorage: pushTrue, iterableIterator: pushTrue, defaultCase: pushFalse, })); } } export const hasIterable = (context, node, type) => tsUtils.type_.hasType(type, (tpe) => isIterable(context, node, tpe)); export const isOnlyIterable = (context, node, type) => tsUtils.type_.isOnlyType(type, (tpe) => isIterable(context, node, tpe)); export const isIterable = (context, node, type) => context.builtins.isInterface(node, type, 'Iterable'); //# sourceMappingURL=iterable.js.map