removed ClassName class
This commit is contained in:
@@ -54,7 +54,6 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.PrimitiveType;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.*;
|
||||
@@ -3040,7 +3039,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
assert operationDescriptor != null;
|
||||
if (arrayType.getSort() == Type.ARRAY &&
|
||||
indices.size() == 1 &&
|
||||
PrimitiveType.INT.getClassName().is(operationDescriptor.getValueParameters().get(0).getType())) {
|
||||
operationDescriptor.getValueParameters().get(0).getType().equals(JetStandardLibrary.getInstance().getIntType())) {
|
||||
gen(array, arrayType);
|
||||
for (JetExpression index : indices) {
|
||||
gen(index, Type.INT_TYPE);
|
||||
|
||||
@@ -26,12 +26,12 @@ import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.PrimitiveType;
|
||||
import org.jetbrains.jet.lang.types.ref.ClassName;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.*;
|
||||
@@ -50,8 +50,8 @@ public class KotlinToJavaTypesMap {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private final Map<FqNameUnsafe, Type> asmTypes = Maps.newHashMap();
|
||||
private final Map<FqNameUnsafe, Type> asmNullableTypes = Maps.newHashMap();
|
||||
private final Map<FqName, Type> asmTypes = Maps.newHashMap();
|
||||
private final Map<FqName, Type> asmNullableTypes = Maps.newHashMap();
|
||||
private final Set<String> mappedTypeNames = Sets.newHashSet();
|
||||
|
||||
private KotlinToJavaTypesMap() {
|
||||
@@ -96,7 +96,7 @@ public class KotlinToJavaTypesMap {
|
||||
|
||||
private void initPrimitives() {
|
||||
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
|
||||
ClassName className = jvmPrimitiveType.getPrimitiveType().getClassName();
|
||||
FqName className = jvmPrimitiveType.getPrimitiveType().getClassName();
|
||||
|
||||
register(className, jvmPrimitiveType.getAsmType());
|
||||
registerNullable(className, jvmPrimitiveType.getWrapper().getAsmType());
|
||||
@@ -112,13 +112,15 @@ public class KotlinToJavaTypesMap {
|
||||
ClassifierDescriptor classifier = jetType.getConstructor().getDeclarationDescriptor();
|
||||
assert classifier != null;
|
||||
FqNameUnsafe className = DescriptorUtils.getFQName(classifier);
|
||||
if (!className.isSafe()) return null;
|
||||
FqName fqName = className.toSafe();
|
||||
if (jetType.isNullable()) {
|
||||
Type nullableType = asmNullableTypes.get(className);
|
||||
Type nullableType = asmNullableTypes.get(fqName);
|
||||
if (nullableType != null) {
|
||||
return nullableType;
|
||||
}
|
||||
}
|
||||
return asmTypes.get(className);
|
||||
return asmTypes.get(fqName);
|
||||
}
|
||||
|
||||
private void register(@NotNull ClassDescriptor kotlinDescriptor, @NotNull Class<?> javaClass) {
|
||||
@@ -127,17 +129,17 @@ public class KotlinToJavaTypesMap {
|
||||
|
||||
private void register(@NotNull ClassDescriptor kotlinDescriptor, @NotNull Type javaType) {
|
||||
FqNameUnsafe fqName = DescriptorUtils.getFQName(kotlinDescriptor);
|
||||
ClassName className = new ClassName(fqName.toSafe(), kotlinDescriptor.getDefaultType().getArguments().size());
|
||||
register(className, javaType);
|
||||
assert fqName.isSafe();
|
||||
register(fqName.toSafe(), javaType);
|
||||
}
|
||||
|
||||
private void register(@NotNull ClassName className, @NotNull Type type) {
|
||||
private void register(@NotNull FqName fqName, @NotNull Type type) {
|
||||
mappedTypeNames.add(type.getClassName());
|
||||
asmTypes.put(className.getFqName().toUnsafe(), type);
|
||||
asmTypes.put(fqName, type);
|
||||
}
|
||||
|
||||
private void registerNullable(@NotNull ClassName className, @NotNull Type nullableType) {
|
||||
asmNullableTypes.put(className.getFqName().toUnsafe(), nullableType);
|
||||
private void registerNullable(@NotNull FqName fqName, @NotNull Type nullableType) {
|
||||
asmNullableTypes.put(fqName, nullableType);
|
||||
}
|
||||
|
||||
public boolean isForceReal(@NotNull JvmClassName className) {
|
||||
|
||||
@@ -63,7 +63,8 @@ public class ArrayIterator implements IntrinsicMethod {
|
||||
else {
|
||||
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
|
||||
PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
|
||||
if (primitiveType.getArrayClassName().is(containingDeclaration)) {
|
||||
ClassDescriptor arrayClass = JetStandardLibrary.getInstance().getPrimitiveArrayClassDescriptor(primitiveType);
|
||||
if (containingDeclaration.equals(arrayClass)) {
|
||||
String methodSignature = "([" + jvmPrimitiveType.getJvmLetter() + ")" + jvmPrimitiveType.getIterator().getDescriptor();
|
||||
v.invokestatic("jet/runtime/ArrayIterator", "iterator", methodSignature);
|
||||
return StackValue.onStack(jvmPrimitiveType.getIterator().getAsmType());
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.jetbrains.jet.lang.types.lang;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.ref.ClassName;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
@@ -41,17 +41,17 @@ public enum PrimitiveType {
|
||||
private final Name typeName;
|
||||
private final Name arrayTypeName;
|
||||
private final Name rangeTypeName;
|
||||
private final ClassName className;
|
||||
private final ClassName arrayClassName;
|
||||
private final ClassName rangeClassName;
|
||||
private final FqName className;
|
||||
private final FqName arrayClassName;
|
||||
private final FqName rangeClassName;
|
||||
|
||||
private PrimitiveType(String typeName) {
|
||||
this.typeName = Name.identifier(typeName);
|
||||
this.arrayTypeName = Name.identifier(typeName + "Array");
|
||||
this.rangeTypeName = Name.identifier(typeName + "Range");
|
||||
this.className = new ClassName(JetStandardClasses.STANDARD_CLASSES_FQNAME.child(this.typeName), 0);
|
||||
this.arrayClassName = new ClassName(JetStandardClasses.STANDARD_CLASSES_FQNAME.child(this.arrayTypeName), 0);
|
||||
this.rangeClassName = new ClassName(JetStandardClasses.STANDARD_CLASSES_FQNAME.child(this.rangeTypeName), 0);
|
||||
this.className = JetStandardClasses.STANDARD_CLASSES_FQNAME.child(this.typeName);
|
||||
this.arrayClassName = JetStandardClasses.STANDARD_CLASSES_FQNAME.child(this.arrayTypeName);
|
||||
this.rangeClassName = JetStandardClasses.STANDARD_CLASSES_FQNAME.child(this.rangeTypeName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -70,17 +70,17 @@ public enum PrimitiveType {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassName getClassName() {
|
||||
public FqName getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassName getArrayClassName() {
|
||||
public FqName getArrayClassName() {
|
||||
return arrayClassName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassName getRangeClassName() {
|
||||
public FqName getRangeClassName() {
|
||||
return rangeClassName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.types.ref;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*
|
||||
* @see JetTypeName
|
||||
*/
|
||||
public final class ClassName {
|
||||
|
||||
@NotNull
|
||||
private final FqName fqName;
|
||||
private final int typeParameterCount;
|
||||
|
||||
public ClassName(@NotNull FqName fqName, int typeParameterCount) {
|
||||
this.fqName = fqName;
|
||||
this.typeParameterCount = typeParameterCount;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public FqName getFqName() {
|
||||
return fqName;
|
||||
}
|
||||
|
||||
public int getTypeParameterCount() {
|
||||
return typeParameterCount;
|
||||
}
|
||||
|
||||
|
||||
public boolean is(@NotNull ClassDescriptor clazz) {
|
||||
return DescriptorUtils.getFQName(clazz).equalsTo(fqName);
|
||||
}
|
||||
|
||||
public boolean is(@NotNull JetType type) {
|
||||
ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor();
|
||||
return classifier instanceof ClassDescriptor && is((ClassDescriptor) classifier);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return fqName + "<" + typeParameterCount + ">";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ClassName className = (ClassName) o;
|
||||
|
||||
if (typeParameterCount != className.typeParameterCount) return false;
|
||||
if (!fqName.equals(className.fqName)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = fqName.hashCode();
|
||||
result = 31 * result + typeParameterCount;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,6 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*
|
||||
* @see ClassName
|
||||
*/
|
||||
public class JetTypeName {
|
||||
// generic types one day
|
||||
|
||||
Reference in New Issue
Block a user