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
017 package org.jetbrains.jet.codegen.signature;
018
019 import org.jetbrains.annotations.NotNull;
020 import org.jetbrains.annotations.Nullable;
021 import org.jetbrains.asm4.Type;
022 import org.jetbrains.asm4.commons.Method;
023
024 import java.util.ArrayList;
025 import java.util.List;
026
027 public class JvmMethodSignature {
028
029 @NotNull
030 private final Method asmMethod;
031 /**
032 * Null when we don't care about type parameters
033 */
034 private final String genericsSignature;
035 @NotNull
036 private final List<JvmMethodParameterSignature> kotlinParameterTypes;
037
038 protected JvmMethodSignature(
039 @NotNull Method asmMethod,
040 @Nullable String genericsSignature,
041 @NotNull List<JvmMethodParameterSignature> kotlinParameterTypes
042 ) {
043 this.asmMethod = asmMethod;
044 this.genericsSignature = genericsSignature;
045 this.kotlinParameterTypes = kotlinParameterTypes;
046 }
047
048 @NotNull
049 public Method getAsmMethod() {
050 return asmMethod;
051 }
052
053 public String getGenericsSignature() {
054 return genericsSignature;
055 }
056
057 @NotNull
058 public List<JvmMethodParameterSignature> getKotlinParameterTypes() {
059 return kotlinParameterTypes;
060 }
061
062 public List<Type> getValueParameterTypes() {
063 List<Type> r = new ArrayList<Type>(kotlinParameterTypes.size());
064 for (JvmMethodParameterSignature p : kotlinParameterTypes) {
065 if (p.getKind() == JvmMethodParameterKind.VALUE) {
066 r.add(p.getAsmType());
067 }
068 }
069 return r;
070 }
071
072 @NotNull
073 public String getName() {
074 return asmMethod.getName();
075 }
076
077 @Override
078 public String toString() {
079 return asmMethod.toString();
080 }
081 }