UNPKG

@neo-one/smart-contract-compiler

Version:

NEO•ONE TypeScript smart contract compiler.

31 lines (29 loc) 1.17 kB
import { tsUtils } from '@neo-one/ts-utils'; import { BuiltinInstanceMemberCall } from '../BuiltinInstanceMemberCall'; export class ArrayJoin extends BuiltinInstanceMemberCall { canCall(_sb, _func, node) { return tsUtils.argumented.getArguments(node).length <= 1; } emitCall(sb, func, node, optionsIn, visited) { const options = sb.pushValueOptions(optionsIn); const expr = tsUtils.expression.getExpression(func); if (!visited) { sb.visit(expr, options); } sb.emitHelper(node, options, sb.helpers.unwrapArray); const args = tsUtils.argumented.getArguments(node); const hasJoinString = args.length > 0; if (hasJoinString) { sb.visit(args[0], options); sb.emitHelper(node, options, sb.helpers.unwrapString); } sb.emitHelper(node, options, sb.helpers.arrToString({ type: sb.context.analysis.getType(expr), hasJoinString })); if (optionsIn.pushValue) { sb.emitHelper(node, options, sb.helpers.wrapString); } else { sb.emitOp(node, 'DROP'); } } } //# sourceMappingURL=join.js.map