@neo-one/smart-contract-compiler
Version:
NEO•ONE TypeScript smart contract compiler.
27 lines (25 loc) • 1.1 kB
JavaScript
import { tsUtils } from '@neo-one/ts-utils';
import { BuiltinInstanceMemberCall } from '../BuiltinInstanceMemberCall';
export class SetForEach extends BuiltinInstanceMemberCall {
canCall(_sb, _func, node) {
return tsUtils.argumented.getArguments(node).length === 1;
}
emitCall(sb, func, node, optionsIn, visited) {
const options = sb.pushValueOptions(optionsIn);
if (!visited) {
sb.visit(tsUtils.expression.getExpression(func), options);
}
if (tsUtils.argumented.getArguments(node).length < 1) {
return;
}
sb.emitHelper(node, options, sb.helpers.unwrapMap);
sb.emitSysCall(node, 'Neo.Iterator.Create');
sb.emitSysCall(node, 'Neo.Iterator.Keys');
sb.visit(tsUtils.argumented.getArguments(node)[0], options);
sb.emitHelper(node, sb.noPushValueOptions(options), sb.helpers.rawEnumeratorForEachFunc({ deserializeKey: true }));
if (optionsIn.pushValue) {
sb.emitHelper(node, options, sb.helpers.wrapUndefined);
}
}
}
//# sourceMappingURL=forEach.js.map