Esempio 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);
    }
  }
Esempio n. 2
0
  public void rememberClosure(JetExpression expression, Type type) {
    JetExpression lambda = JetPsiUtil.deparenthesize(expression);
    assert isInlinableParameterExpression(lambda)
        : "Couldn't find inline expression in " + expression.getText();

    LambdaInfo info = new LambdaInfo(lambda, typeMapper);

    ParameterInfo closureInfo = invocationParamBuilder.addNextParameter(type, true, null);
    closureInfo.setLambda(info);
    expressionMap.put(closureInfo.getIndex(), info);
  }
Esempio n. 3
0
 public void leaveTemps() {
   FrameMap frameMap = codegen.getFrameMap();
   List<ParameterInfo> infos = invocationParamBuilder.listAllParams();
   for (ListIterator<? extends ParameterInfo> iterator = infos.listIterator(infos.size());
       iterator.hasPrevious(); ) {
     ParameterInfo param = iterator.previous();
     if (!param.isSkippedOrRemapped()) {
       frameMap.leaveTemp(param.type);
     }
   }
 }
Esempio n. 4
0
  private void putParameterOnStack(ParameterInfo... infos) {
    int[] index = new int[infos.length];
    for (int i = 0; i < infos.length; i++) {
      ParameterInfo info = infos[i];
      if (!info.isSkippedOrRemapped()) {
        index[i] = codegen.getFrameMap().enterTemp(info.getType());
      } else {
        index[i] = -1;
      }
    }

    for (int i = infos.length - 1; i >= 0; i--) {
      ParameterInfo info = infos[i];
      if (!info.isSkippedOrRemapped()) {
        Type type = info.type;
        StackValue.local(index[i], type).store(StackValue.onStack(type), codegen.v);
      }
    }
  }