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.context;
018    
019    import org.jetbrains.annotations.NotNull;
020    import org.jetbrains.annotations.Nullable;
021    import org.jetbrains.kotlin.codegen.ExpressionCodegen;
022    import org.jetbrains.kotlin.codegen.StackValue;
023    import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
024    import org.jetbrains.org.objectweb.asm.Type;
025    
026    public final class EnclosedValueDescriptor {
027        private final String fieldName;
028        private final DeclarationDescriptor descriptor;
029        private final StackValue.StackValueWithSimpleReceiver innerValue;
030        private final StackValue instanceValue;
031        private final Type type;
032    
033        public EnclosedValueDescriptor(
034                @NotNull String fieldName,
035                @Nullable DeclarationDescriptor descriptor,
036                @NotNull StackValue.StackValueWithSimpleReceiver innerValue,
037                @NotNull Type type
038        ) {
039            this.fieldName = fieldName;
040            this.descriptor = descriptor;
041            this.innerValue = innerValue;
042            this.instanceValue = innerValue;
043            this.type = type;
044        }
045    
046        public EnclosedValueDescriptor(
047                @NotNull String name,
048                @Nullable DeclarationDescriptor descriptor,
049                @NotNull StackValue.StackValueWithSimpleReceiver innerValue,
050                @NotNull StackValue.Field instanceValue,
051                @NotNull Type type
052        ) {
053            this.fieldName = name;
054            this.descriptor = descriptor;
055            this.innerValue = innerValue;
056            this.instanceValue = instanceValue;
057            this.type = type;
058        }
059    
060        @NotNull
061        public String getFieldName() {
062            return fieldName;
063        }
064    
065        @Nullable
066        public DeclarationDescriptor getDescriptor() {
067            return descriptor;
068        }
069    
070        @NotNull
071        public StackValue.StackValueWithSimpleReceiver getInnerValue() {
072            return innerValue;
073        }
074    
075        @NotNull
076        public StackValue getInstanceValue() {
077            return instanceValue;
078        }
079    
080        @NotNull
081        public Type getType() {
082            return type;
083        }
084    
085        @Override
086        public String toString() {
087            return fieldName + " " + type + " -> " + descriptor;
088        }
089    }