removed JetStandardLibraryNames

This commit is contained in:
Svetlana Isakova
2012-08-24 21:30:23 +04:00
parent 35c276be18
commit 12aea75b02
6 changed files with 19 additions and 56 deletions
@@ -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.lang.JetStandardClasses;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.lang.types.lang.JetStandardLibraryNames;
import javax.inject.Inject;
import java.util.ArrayList;
@@ -389,7 +388,7 @@ public class JetTypeMapper {
}
if (descriptor instanceof ClassDescriptor
&& JetStandardLibraryNames.ARRAY.is((ClassDescriptor) descriptor)
&& JetStandardLibrary.getInstance().isArray(jetType)
&& mapBuiltinsToJava) {
if (jetType.getArguments().size() != 1) {
throw new UnsupportedOperationException("arrays must have one type argument");
@@ -970,7 +969,7 @@ public class JetTypeMapper {
}
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;
}
@@ -23,7 +23,6 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.asm4.Type;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
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.java.JvmClassName;
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
@@ -39,7 +38,6 @@ import java.util.Map;
import java.util.Set;
import static org.jetbrains.jet.codegen.JetTypeMapper.*;
import static org.jetbrains.jet.lang.types.lang.JetStandardLibraryNames.*;
/**
* @author svtk
@@ -61,7 +59,7 @@ public class KotlinToJavaTypesMap {
private KotlinToJavaTypesMap() {
init();
initPrimitive();
initPrimitives();
}
@Nullable
@@ -97,8 +95,9 @@ public class KotlinToJavaTypesMap {
asmNullableTypes.put(className.getFqName().toUnsafe(), nullableType);
}
public void init() {
private void init() {
JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
register(JetStandardClasses.getNothing(), JET_NOTHING_TYPE); //todo ?????
register(JetStandardClasses.getAny(), Object.class);
register(standardLibrary.getNumber(), Number.class);
@@ -113,7 +112,7 @@ public class KotlinToJavaTypesMap {
register(standardLibrary.getMutableIterator(), Iterator.class);
}
public void initPrimitive() {
private void initPrimitives() {
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
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
|| asmTypeNames.contains(className.getFqName().getFqName());
}
@@ -103,7 +103,7 @@ public class PropertyCodegen {
if (!propertyDescriptor.isVar()) {
modifiers |= Opcodes.ACC_FINAL;
}
if (JetStandardLibrary.isVolatile(propertyDescriptor)) {
if (JetStandardLibrary.getInstance().isVolatile(propertyDescriptor)) {
modifiers |= Opcodes.ACC_VOLATILE;
}
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.resolve.BindingContext;
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 java.util.List;
@@ -56,7 +56,7 @@ public class ArrayIterator implements IntrinsicMethod {
.get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) call.getCalleeExpression());
assert funDescriptor != null;
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;");
return StackValue.onStack(JetTypeMapper.JET_ITERATOR_TYPE);
}
@@ -99,6 +99,7 @@ public class JetStandardLibrary {
private ClassDescriptor comparableClass;
private ClassDescriptor throwableClass;
private ClassDescriptor enumClass;
private ClassDescriptor volatileClass;
private JetType stringType;
@@ -169,6 +170,7 @@ public class JetStandardLibrary {
this.arrayClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Array"));
this.throwableClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Throwable"));
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.iteratorClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Iterator"));
@@ -458,11 +460,11 @@ public class JetStandardLibrary {
return primitiveJetTypeToJetArrayType.get(jetType);
}
public static boolean isVolatile(PropertyDescriptor descriptor) {
public boolean isVolatile(@NotNull PropertyDescriptor descriptor) {
List<AnnotationDescriptor> annotations = descriptor.getOriginal().getAnnotations();
if (annotations != null) {
for(AnnotationDescriptor d: annotations) {
if (JetStandardLibraryNames.VOLATILE.is(d.getType())) {
for(AnnotationDescriptor annotation: annotations) {
if (volatileClass.equals(annotation.getType().getConstructor().getDeclarationDescriptor())) {
return true;
}
}
@@ -470,6 +472,10 @@ public class JetStandardLibrary {
return false;
}
public boolean isArray(@NotNull JetType type) {
return getArray().equals(type.getConstructor().getDeclarationDescriptor());
}
public JetType getTuple0Type() {
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();
}