Ejemplo n.º 1
0
  private void putCapturedInLocal(
      @NotNull Type type,
      @Nullable StackValue stackValue,
      @Nullable ValueParameterDescriptor valueParameterDescriptor,
      int capturedParamIndex) {
    if (!asFunctionInline && Type.VOID_TYPE != type) {
      // TODO remap only inlinable closure => otherwise we could get a lot of problem
      boolean couldBeRemapped = !shouldPutValue(type, stackValue, valueParameterDescriptor);
      StackValue remappedIndex = couldBeRemapped ? stackValue : null;

      ParameterInfo info;
      if (capturedParamIndex >= 0) {
        CapturedParamDesc capturedParamInfoInLambda =
            activeLambda.getCapturedVars().get(capturedParamIndex);
        info =
            invocationParamBuilder.addCapturedParam(
                capturedParamInfoInLambda, capturedParamInfoInLambda.getFieldName());
        info.setRemapValue(remappedIndex);
      } else {
        info = invocationParamBuilder.addNextParameter(type, false, remappedIndex);
      }

      putParameterOnStack(info);
    }
  }
Ejemplo n.º 2
0
  @NotNull
  public Parameters addAllParameters(@NotNull FieldRemapper remapper) {
    Method asmMethod = typeMapper.mapAsmMethod(getFunctionDescriptor());
    ParametersBuilder builder =
        ParametersBuilder.initializeBuilderFrom(
            AsmTypes.OBJECT_TYPE, asmMethod.getDescriptor(), this);

    for (CapturedParamDesc info : getCapturedVars()) {
      CapturedParamInfo field =
          remapper.findField(
              new FieldInsnNode(0, info.getContainingLambdaName(), info.getFieldName(), ""));
      assert field != null
          : "Captured field not found: "
              + info.getContainingLambdaName()
              + "."
              + info.getFieldName();
      builder.addCapturedParam(field, info.getFieldName());
    }

    return builder.buildParameters();
  }