001    /*
002     * Copyright 2010-2014 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.jet.codegen.inline;
018    
019    import org.jetbrains.annotations.NotNull;
020    import org.jetbrains.asm4.Type;
021    import org.jetbrains.jet.codegen.context.EnclosedValueDescriptor;
022    
023    public class CapturedParamDesc {
024    
025        private final CapturedParamOwner containingLambda;
026    
027        private final String fieldName;
028    
029        private final Type type;
030    
031        public CapturedParamDesc(@NotNull CapturedParamOwner containingLambda, @NotNull EnclosedValueDescriptor descriptor) {
032            this.containingLambda = containingLambda;
033            this.type = descriptor.getType();
034            this.fieldName = descriptor.getFieldName();
035        }
036    
037        public CapturedParamDesc(@NotNull CapturedParamOwner containingLambda, @NotNull String fieldName, @NotNull Type type) {
038            this.containingLambda = containingLambda;
039            this.fieldName = fieldName;
040            this.type = type;
041        }
042    
043        public CapturedParamOwner getContainingLambda() {
044            return containingLambda;
045        }
046    
047        public String getFieldName() {
048            return fieldName;
049        }
050    
051        public Type getType() {
052            return type;
053        }
054    
055    
056        public static CapturedParamDesc createDesc(CapturedParamOwner containingLambdaInfo, String fieldName, Type type) {
057            return new CapturedParamDesc(containingLambdaInfo, fieldName, type);
058        }
059    }