001 /* 002 * Copyright 2010-2015 JetBrains s.r.o. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 package org.jetbrains.kotlin.codegen.inline; 018 019 import org.jetbrains.annotations.NotNull; 020 import org.jetbrains.annotations.Nullable; 021 import org.jetbrains.kotlin.codegen.StackValue; 022 023 public class CapturedParamInfo extends ParameterInfo { 024 public final CapturedParamDesc desc; 025 private final String newFieldName; 026 private final boolean skipInConstructor; 027 028 public CapturedParamInfo(@NotNull CapturedParamDesc desc, @NotNull String newFieldName, boolean skipped, int index, int remapIndex) { 029 super(desc.getType(), skipped, index, remapIndex, index); 030 this.desc = desc; 031 this.newFieldName = newFieldName; 032 this.skipInConstructor = false; 033 } 034 035 public CapturedParamInfo( 036 @NotNull CapturedParamDesc desc, 037 @NotNull String newFieldName, 038 boolean skipped, 039 int index, 040 @Nullable StackValue remapIndex, 041 boolean skipInConstructor 042 ) { 043 super(desc.getType(), skipped, index, remapIndex, index); 044 this.desc = desc; 045 this.newFieldName = newFieldName; 046 this.skipInConstructor = skipInConstructor; 047 } 048 049 @NotNull 050 public String getNewFieldName() { 051 return newFieldName; 052 } 053 054 @NotNull 055 public String getOriginalFieldName() { 056 return desc.getFieldName(); 057 } 058 059 @NotNull 060 public CapturedParamInfo newIndex(int newIndex) { 061 return clone(newIndex, getRemapValue()); 062 } 063 064 @NotNull 065 private CapturedParamInfo clone(int newIndex, @Nullable StackValue newRemapIndex) { 066 CapturedParamInfo result = new CapturedParamInfo(desc, newFieldName, isSkipped, newIndex, newRemapIndex, skipInConstructor); 067 result.setLambda(getLambda()); 068 return result; 069 } 070 071 @NotNull 072 public String getContainingLambdaName() { 073 return desc.getContainingLambdaName(); 074 } 075 076 public boolean isSkipInConstructor() { 077 return skipInConstructor; 078 } 079 }