001/* 002 * Copyright 2010-2013 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 017package org.jetbrains.jet.codegen; 018 019import org.jetbrains.annotations.NotNull; 020import org.jetbrains.jet.codegen.signature.JvmMethodParameterKind; 021import org.jetbrains.jet.codegen.signature.JvmMethodParameterSignature; 022import org.jetbrains.jet.codegen.signature.JvmMethodSignature; 023 024import java.util.List; 025 026import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE; 027 028public class ConstructorFrameMap extends FrameMap { 029 private int myOuterThisIndex = -1; 030 031 public ConstructorFrameMap(@NotNull JvmMethodSignature signature) { 032 enterTemp(OBJECT_TYPE); // this 033 034 List<JvmMethodParameterSignature> parameterTypes = signature.getKotlinParameterTypes(); 035 if (parameterTypes != null) { 036 for (JvmMethodParameterSignature parameterType : parameterTypes) { 037 if (parameterType.getKind() == JvmMethodParameterKind.OUTER) { 038 myOuterThisIndex = enterTemp(OBJECT_TYPE); // this0 039 } 040 else if (parameterType.getKind() != JvmMethodParameterKind.VALUE) { 041 enterTemp(parameterType.getAsmType()); 042 } 043 else { 044 break; 045 } 046 } 047 } 048 } 049 050 public int getOuterThisIndex() { 051 return myOuterThisIndex; 052 } 053}