563 int collectorArity = collectorType.parameterCount(); |
563 int collectorArity = collectorType.parameterCount(); |
564 boolean dropResult = (collectorType.returnType() == void.class); |
564 boolean dropResult = (collectorType.returnType() == void.class); |
565 if (collectorArity == 1 && !dropResult) { |
565 if (collectorArity == 1 && !dropResult) { |
566 return filterArgumentForm(pos, basicType(collectorType.parameterType(0))); |
566 return filterArgumentForm(pos, basicType(collectorType.parameterType(0))); |
567 } |
567 } |
568 BasicType[] newTypes = BasicType.basicTypes(collectorType.parameterList()); |
568 byte[] newTypes = BasicType.basicTypesOrd(collectorType.parameterArray()); |
569 Transform.Kind kind = (dropResult |
569 Transform.Kind kind = (dropResult |
570 ? Transform.Kind.COLLECT_ARGS_TO_VOID |
570 ? Transform.Kind.COLLECT_ARGS_TO_VOID |
571 : Transform.Kind.COLLECT_ARGS); |
571 : Transform.Kind.COLLECT_ARGS); |
572 if (dropResult && collectorArity == 0) pos = 1; // pure side effect |
572 if (dropResult && collectorArity == 0) pos = 1; // pure side effect |
573 Transform key = Transform.of(kind, pos, collectorArity, BasicType.basicTypesOrd(newTypes)); |
573 Transform key = Transform.of(kind, pos, collectorArity, newTypes); |
574 LambdaForm form = getInCache(key); |
574 LambdaForm form = getInCache(key); |
575 if (form != null) { |
575 if (form != null) { |
576 assert(form.arity == lambdaForm.arity - (dropResult ? 0 : 1) + collectorArity); |
576 assert(form.arity == lambdaForm.arity - (dropResult ? 0 : 1) + collectorArity); |
577 return form; |
577 return form; |
578 } |
578 } |
678 newParams = new Name[0]; |
678 newParams = new Name[0]; |
679 System.arraycopy(lambdaForm.names, pos + resultArity, |
679 System.arraycopy(lambdaForm.names, pos + resultArity, |
680 combinerArgs, 1, combinerArity); |
680 combinerArgs, 1, combinerArity); |
681 } else { |
681 } else { |
682 newParams = new Name[combinerArity]; |
682 newParams = new Name[combinerArity]; |
683 BasicType[] newTypes = basicTypes(combinerType.parameterList()); |
683 for (int i = 0; i < newParams.length; i++) { |
684 for (int i = 0; i < newTypes.length; i++) { |
684 newParams[i] = new Name(pos + i, basicType(combinerType.parameterType(i))); |
685 newParams[i] = new Name(pos + i, newTypes[i]); |
|
686 } |
685 } |
687 System.arraycopy(newParams, 0, |
686 System.arraycopy(newParams, 0, |
688 combinerArgs, 1, combinerArity); |
687 combinerArgs, 1, combinerArity); |
689 } |
688 } |
690 Name callCombiner = new Name(combinerType, combinerArgs); |
689 Name callCombiner = new Name(combinerType, combinerArgs); |