removed JetStandardLibraryNames
This commit is contained in:
@@ -38,7 +38,6 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
|||||||
import org.jetbrains.jet.lang.types.*;
|
import org.jetbrains.jet.lang.types.*;
|
||||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibraryNames;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -389,7 +388,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (descriptor instanceof ClassDescriptor
|
if (descriptor instanceof ClassDescriptor
|
||||||
&& JetStandardLibraryNames.ARRAY.is((ClassDescriptor) descriptor)
|
&& JetStandardLibrary.getInstance().isArray(jetType)
|
||||||
&& mapBuiltinsToJava) {
|
&& mapBuiltinsToJava) {
|
||||||
if (jetType.getArguments().size() != 1) {
|
if (jetType.getArguments().size() != 1) {
|
||||||
throw new UnsupportedOperationException("arrays must have one type argument");
|
throw new UnsupportedOperationException("arrays must have one type argument");
|
||||||
@@ -970,7 +969,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isGenericsArray(JetType type) {
|
private static boolean isGenericsArray(JetType type) {
|
||||||
return JetStandardLibraryNames.ARRAY.is(type) &&
|
return JetStandardLibrary.getInstance().isArray(type) &&
|
||||||
type.getArguments().get(0).getType().getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor;
|
type.getArguments().get(0).getType().getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.asm4.Type;
|
import org.jetbrains.asm4.Type;
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
||||||
@@ -39,7 +38,6 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.jetbrains.jet.codegen.JetTypeMapper.*;
|
import static org.jetbrains.jet.codegen.JetTypeMapper.*;
|
||||||
import static org.jetbrains.jet.lang.types.lang.JetStandardLibraryNames.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author svtk
|
* @author svtk
|
||||||
@@ -61,7 +59,7 @@ public class KotlinToJavaTypesMap {
|
|||||||
|
|
||||||
private KotlinToJavaTypesMap() {
|
private KotlinToJavaTypesMap() {
|
||||||
init();
|
init();
|
||||||
initPrimitive();
|
initPrimitives();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -97,8 +95,9 @@ public class KotlinToJavaTypesMap {
|
|||||||
asmNullableTypes.put(className.getFqName().toUnsafe(), nullableType);
|
asmNullableTypes.put(className.getFqName().toUnsafe(), nullableType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
private void init() {
|
||||||
JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
|
JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
|
||||||
|
|
||||||
register(JetStandardClasses.getNothing(), JET_NOTHING_TYPE); //todo ?????
|
register(JetStandardClasses.getNothing(), JET_NOTHING_TYPE); //todo ?????
|
||||||
register(JetStandardClasses.getAny(), Object.class);
|
register(JetStandardClasses.getAny(), Object.class);
|
||||||
register(standardLibrary.getNumber(), Number.class);
|
register(standardLibrary.getNumber(), Number.class);
|
||||||
@@ -113,7 +112,7 @@ public class KotlinToJavaTypesMap {
|
|||||||
register(standardLibrary.getMutableIterator(), Iterator.class);
|
register(standardLibrary.getMutableIterator(), Iterator.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initPrimitive() {
|
private void initPrimitives() {
|
||||||
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
|
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
|
||||||
ClassName className = jvmPrimitiveType.getPrimitiveType().getClassName();
|
ClassName className = jvmPrimitiveType.getPrimitiveType().getClassName();
|
||||||
|
|
||||||
@@ -126,7 +125,7 @@ public class KotlinToJavaTypesMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isForceReal(JvmClassName className) {
|
public boolean isForceReal(@NotNull JvmClassName className) {
|
||||||
return JvmPrimitiveType.getByWrapperClass(className) != null
|
return JvmPrimitiveType.getByWrapperClass(className) != null
|
||||||
|| asmTypeNames.contains(className.getFqName().getFqName());
|
|| asmTypeNames.contains(className.getFqName().getFqName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class PropertyCodegen {
|
|||||||
if (!propertyDescriptor.isVar()) {
|
if (!propertyDescriptor.isVar()) {
|
||||||
modifiers |= Opcodes.ACC_FINAL;
|
modifiers |= Opcodes.ACC_FINAL;
|
||||||
}
|
}
|
||||||
if (JetStandardLibrary.isVolatile(propertyDescriptor)) {
|
if (JetStandardLibrary.getInstance().isVolatile(propertyDescriptor)) {
|
||||||
modifiers |= Opcodes.ACC_VOLATILE;
|
modifiers |= Opcodes.ACC_VOLATILE;
|
||||||
}
|
}
|
||||||
Type type = state.getInjector().getJetTypeMapper().mapType(propertyDescriptor.getType(), MapTypeMode.VALUE);
|
Type type = state.getInjector().getJetTypeMapper().mapType(propertyDescriptor.getType(), MapTypeMode.VALUE);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import org.jetbrains.jet.lang.psi.JetExpression;
|
|||||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
||||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibraryNames;
|
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||||
import org.jetbrains.jet.lang.types.lang.PrimitiveType;
|
import org.jetbrains.jet.lang.types.lang.PrimitiveType;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -56,7 +56,7 @@ public class ArrayIterator implements IntrinsicMethod {
|
|||||||
.get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) call.getCalleeExpression());
|
.get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) call.getCalleeExpression());
|
||||||
assert funDescriptor != null;
|
assert funDescriptor != null;
|
||||||
ClassDescriptor containingDeclaration = (ClassDescriptor) funDescriptor.getContainingDeclaration().getOriginal();
|
ClassDescriptor containingDeclaration = (ClassDescriptor) funDescriptor.getContainingDeclaration().getOriginal();
|
||||||
if (JetStandardLibraryNames.ARRAY.is(containingDeclaration)) {
|
if (containingDeclaration.equals(JetStandardLibrary.getInstance().getArray())) {
|
||||||
v.invokestatic("jet/runtime/ArrayIterator", "iterator", "([Ljava/lang/Object;)Ljava/util/Iterator;");
|
v.invokestatic("jet/runtime/ArrayIterator", "iterator", "([Ljava/lang/Object;)Ljava/util/Iterator;");
|
||||||
return StackValue.onStack(JetTypeMapper.JET_ITERATOR_TYPE);
|
return StackValue.onStack(JetTypeMapper.JET_ITERATOR_TYPE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ public class JetStandardLibrary {
|
|||||||
private ClassDescriptor comparableClass;
|
private ClassDescriptor comparableClass;
|
||||||
private ClassDescriptor throwableClass;
|
private ClassDescriptor throwableClass;
|
||||||
private ClassDescriptor enumClass;
|
private ClassDescriptor enumClass;
|
||||||
|
private ClassDescriptor volatileClass;
|
||||||
|
|
||||||
private JetType stringType;
|
private JetType stringType;
|
||||||
|
|
||||||
@@ -169,6 +170,7 @@ public class JetStandardLibrary {
|
|||||||
this.arrayClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Array"));
|
this.arrayClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Array"));
|
||||||
this.throwableClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Throwable"));
|
this.throwableClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Throwable"));
|
||||||
this.enumClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Enum"));
|
this.enumClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Enum"));
|
||||||
|
this.volatileClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("volatile"));
|
||||||
|
|
||||||
this.iterableClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Iterable"));
|
this.iterableClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Iterable"));
|
||||||
this.iteratorClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Iterator"));
|
this.iteratorClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Iterator"));
|
||||||
@@ -458,11 +460,11 @@ public class JetStandardLibrary {
|
|||||||
return primitiveJetTypeToJetArrayType.get(jetType);
|
return primitiveJetTypeToJetArrayType.get(jetType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isVolatile(PropertyDescriptor descriptor) {
|
public boolean isVolatile(@NotNull PropertyDescriptor descriptor) {
|
||||||
List<AnnotationDescriptor> annotations = descriptor.getOriginal().getAnnotations();
|
List<AnnotationDescriptor> annotations = descriptor.getOriginal().getAnnotations();
|
||||||
if (annotations != null) {
|
if (annotations != null) {
|
||||||
for(AnnotationDescriptor d: annotations) {
|
for(AnnotationDescriptor annotation: annotations) {
|
||||||
if (JetStandardLibraryNames.VOLATILE.is(d.getType())) {
|
if (volatileClass.equals(annotation.getType().getConstructor().getDeclarationDescriptor())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -470,6 +472,10 @@ public class JetStandardLibrary {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isArray(@NotNull JetType type) {
|
||||||
|
return getArray().equals(type.getConstructor().getDeclarationDescriptor());
|
||||||
|
}
|
||||||
|
|
||||||
public JetType getTuple0Type() {
|
public JetType getTuple0Type() {
|
||||||
return tuple0Type;
|
return tuple0Type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,41 +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.lang;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
|
||||||
import org.jetbrains.jet.lang.types.ref.ClassName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stepan Koltsov
|
|
||||||
*/
|
|
||||||
public class JetStandardLibraryNames {
|
|
||||||
|
|
||||||
private JetStandardLibraryNames() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private static ClassName classIn(@NotNull String name, int typeParameterCount) {
|
|
||||||
return new ClassName(
|
|
||||||
JetStandardClasses.STANDARD_CLASSES_FQNAME.child(Name.identifier(name)),
|
|
||||||
typeParameterCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final ClassName ARRAY = classIn("Array", 1);
|
|
||||||
public static final ClassName VOLATILE = classIn("volatile", 0);
|
|
||||||
public static final ClassName INT = PrimitiveType.INT.getClassName();
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user