JetStandardLibrary -> KotlinBuiltIns
This commit is contained in:
@@ -37,7 +37,7 @@ import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.List;
|
||||
@@ -55,13 +55,13 @@ import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.JAVA_STRING_T
|
||||
*/
|
||||
public class AsmUtil {
|
||||
private static final Set<ClassDescriptor> PRIMITIVE_NUMBER_CLASSES = Sets.newHashSet(
|
||||
JetStandardLibrary.getInstance().getByte(),
|
||||
JetStandardLibrary.getInstance().getShort(),
|
||||
JetStandardLibrary.getInstance().getInt(),
|
||||
JetStandardLibrary.getInstance().getLong(),
|
||||
JetStandardLibrary.getInstance().getFloat(),
|
||||
JetStandardLibrary.getInstance().getDouble(),
|
||||
JetStandardLibrary.getInstance().getChar()
|
||||
KotlinBuiltIns.getInstance().getByte(),
|
||||
KotlinBuiltIns.getInstance().getShort(),
|
||||
KotlinBuiltIns.getInstance().getInt(),
|
||||
KotlinBuiltIns.getInstance().getLong(),
|
||||
KotlinBuiltIns.getInstance().getFloat(),
|
||||
KotlinBuiltIns.getInstance().getDouble(),
|
||||
KotlinBuiltIns.getInstance().getChar()
|
||||
);
|
||||
|
||||
private static final int NO_FLAG_LOCAL = 0;
|
||||
|
||||
@@ -55,7 +55,6 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.*;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
@@ -79,7 +78,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
private static final String CLASS_NO_PATTERN_MATCHED_EXCEPTION = "jet/NoPatternMatchedException";
|
||||
private static final String CLASS_TYPE_CAST_EXCEPTION = "jet/TypeCastException";
|
||||
public static final Set<DeclarationDescriptor> INTEGRAL_RANGES = JetStandardLibrary.getInstance().getIntegralRanges();
|
||||
public static final Set<DeclarationDescriptor> INTEGRAL_RANGES = KotlinBuiltIns.getInstance().getIntegralRanges();
|
||||
|
||||
private int myLastLineNumber = -1;
|
||||
|
||||
@@ -651,7 +650,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
invokeFunction(fakeCall, StackValue.local(iteratorVarIndex, asmTypeForIterator), hasNextCall);
|
||||
|
||||
JetType type = hasNextCall.getResultingDescriptor().getReturnType();
|
||||
assert type != null && JetTypeChecker.INSTANCE.isSubtypeOf(type, JetStandardLibrary.getInstance().getBooleanType());
|
||||
assert type != null && JetTypeChecker.INSTANCE.isSubtypeOf(type, KotlinBuiltIns.getInstance().getBooleanType());
|
||||
|
||||
Type asmType = asmType(type);
|
||||
StackValue.coerce(asmType, Type.BOOLEAN_TYPE, v);
|
||||
@@ -723,7 +722,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
protected void assignToLoopParameter(int parameterIndex) {
|
||||
Type arrayElParamType;
|
||||
Type asmElementType = asmType(elementType);
|
||||
if (JetStandardLibrary.getInstance().isArray(loopRangeType)) {
|
||||
if (KotlinBuiltIns.getInstance().isArray(loopRangeType)) {
|
||||
arrayElParamType = boxType(asmElementType);
|
||||
}
|
||||
else {
|
||||
@@ -2873,7 +2872,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
args.addAll(expression.getFunctionLiteralArguments());
|
||||
|
||||
boolean isArray = JetStandardLibrary.getInstance().isArray(arrayType);
|
||||
boolean isArray = KotlinBuiltIns.getInstance().isArray(arrayType);
|
||||
if (isArray) {
|
||||
// if (args.size() != 2 && !arrayType.getArguments().get(0).getType().isNullable()) {
|
||||
// throw new CompilationException("array constructor of non-nullable type requires two arguments");
|
||||
@@ -2943,13 +2942,13 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
assert operationDescriptor != null;
|
||||
if (arrayType.getSort() == Type.ARRAY &&
|
||||
indices.size() == 1 &&
|
||||
operationDescriptor.getValueParameters().get(0).getType().equals(JetStandardLibrary.getInstance().getIntType())) {
|
||||
operationDescriptor.getValueParameters().get(0).getType().equals(KotlinBuiltIns.getInstance().getIntType())) {
|
||||
gen(array, arrayType);
|
||||
for (JetExpression index : indices) {
|
||||
gen(index, Type.INT_TYPE);
|
||||
}
|
||||
assert type != null;
|
||||
if (JetStandardLibrary.getInstance().isArray(type)) {
|
||||
if (KotlinBuiltIns.getInstance().isArray(type)) {
|
||||
JetType elementType = type.getArguments().get(0).getType();
|
||||
Type notBoxed = asmType(elementType);
|
||||
return StackValue.arrayElement(notBoxed, true);
|
||||
|
||||
@@ -53,7 +53,6 @@ import org.jetbrains.jet.lang.resolve.java.kt.DescriptorKindUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.*;
|
||||
@@ -361,7 +360,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
if (superClassType == null) {
|
||||
if (descriptor.getKind() == ClassKind.ENUM_CLASS) {
|
||||
superClassType = JetStandardLibrary.getInstance().getEnumType(descriptor.getDefaultType());
|
||||
superClassType = KotlinBuiltIns.getInstance().getEnumType(descriptor.getDefaultType());
|
||||
superClassAsmType = typeMapper.mapType(superClassType);
|
||||
}
|
||||
if (descriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
||||
@@ -413,7 +412,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
private void generateFunctionsForDataClasses() {
|
||||
if (!JetStandardLibrary.isData(descriptor)) return;
|
||||
if (!KotlinBuiltIns.getInstance().isData(descriptor)) return;
|
||||
|
||||
generateComponentFunctionsForDataClasses();
|
||||
|
||||
@@ -426,21 +425,21 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
private void generateDataClassToStringIfNeeded(List<PropertyDescriptor> properties) {
|
||||
ClassDescriptor stringClass = JetStandardLibrary.getInstance().getString();
|
||||
ClassDescriptor stringClass = KotlinBuiltIns.getInstance().getString();
|
||||
if (getDeclaredFunctionByRawSignature(descriptor, Name.identifier("toString"), stringClass) == null) {
|
||||
generateDataClassToStringMethod(properties);
|
||||
}
|
||||
}
|
||||
|
||||
private void generateDataClassHashCodeIfNeeded(List<PropertyDescriptor> properties) {
|
||||
ClassDescriptor intClass = JetStandardLibrary.getInstance().getInt();
|
||||
ClassDescriptor intClass = KotlinBuiltIns.getInstance().getInt();
|
||||
if (getDeclaredFunctionByRawSignature(descriptor, Name.identifier("hashCode"), intClass) == null) {
|
||||
generateDataClassHashCodeMethod(properties);
|
||||
}
|
||||
}
|
||||
|
||||
private void generateDataClassEqualsIfNeeded(List<PropertyDescriptor> properties) {
|
||||
ClassDescriptor booleanClass = JetStandardLibrary.getInstance().getBoolean();
|
||||
ClassDescriptor booleanClass = KotlinBuiltIns.getInstance().getBoolean();
|
||||
ClassDescriptor anyClass = KotlinBuiltIns.getInstance().getAny();
|
||||
FunctionDescriptor equalsFunction = getDeclaredFunctionByRawSignature(descriptor, Name.identifier("equals"), booleanClass, anyClass);
|
||||
if (equalsFunction == null) {
|
||||
@@ -605,7 +604,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
private void generateComponentFunctionsForDataClasses() {
|
||||
if (!myClass.hasPrimaryConstructor() || !JetStandardLibrary.isData(descriptor)) return;
|
||||
if (!myClass.hasPrimaryConstructor() || !KotlinBuiltIns.getInstance().isData(descriptor)) return;
|
||||
|
||||
ConstructorDescriptor constructor = descriptor.getConstructors().iterator().next();
|
||||
|
||||
@@ -646,7 +645,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (myEnumConstants.size() > 0) {
|
||||
{
|
||||
Type type =
|
||||
typeMapper.mapType(JetStandardLibrary.getInstance().getArrayType(descriptor.getDefaultType()),
|
||||
typeMapper.mapType(KotlinBuiltIns.getInstance().getArrayType(descriptor.getDefaultType()),
|
||||
JetTypeMapperMode.IMPL);
|
||||
|
||||
MethodVisitor mv =
|
||||
@@ -1398,7 +1397,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
Type myAsmType = typeMapper.mapType(myType, JetTypeMapperMode.IMPL);
|
||||
|
||||
assert myEnumConstants.size() > 0;
|
||||
JetType arrayType = JetStandardLibrary.getInstance().getArrayType(myType);
|
||||
JetType arrayType = KotlinBuiltIns.getInstance().getArrayType(myType);
|
||||
Type arrayAsmType = typeMapper.mapType(arrayType, JetTypeMapperMode.IMPL);
|
||||
v.newField(myClass, ACC_PRIVATE | ACC_STATIC | ACC_FINAL | ACC_SYNTHETIC, "$VALUES", arrayAsmType.getDescriptor(), null, null);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.lang.resolve.java.kt.DescriptorKindUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.*;
|
||||
@@ -115,7 +115,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
modifiers |= ACC_FINAL;
|
||||
}
|
||||
modifiers |= getDeprecatedAccessFlag(propertyDescriptor);
|
||||
if (JetStandardLibrary.getInstance().isVolatile(propertyDescriptor)) {
|
||||
if (KotlinBuiltIns.getInstance().isVolatile(propertyDescriptor)) {
|
||||
modifiers |= ACC_VOLATILE;
|
||||
}
|
||||
Type type = typeMapper.mapType(propertyDescriptor);
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -34,20 +34,20 @@ import static org.jetbrains.jet.codegen.AsmUtil.isPrimitiveNumberClassDescriptor
|
||||
*/
|
||||
public class RangeCodegenUtil {
|
||||
private static final ImmutableMap<String, JetType> RANGE_TO_ELEMENT_TYPE = ImmutableMap.<String, JetType>builder()
|
||||
.put("ByteRange", JetStandardLibrary.getInstance().getByteType())
|
||||
.put("ShortRange", JetStandardLibrary.getInstance().getShortType())
|
||||
.put("IntRange", JetStandardLibrary.getInstance().getIntType())
|
||||
.put("LongRange", JetStandardLibrary.getInstance().getLongType())
|
||||
.put("FloatRange", JetStandardLibrary.getInstance().getFloatType())
|
||||
.put("DoubleRange", JetStandardLibrary.getInstance().getDoubleType())
|
||||
.put("CharRange", JetStandardLibrary.getInstance().getCharType())
|
||||
.put("ByteRange", KotlinBuiltIns.getInstance().getByteType())
|
||||
.put("ShortRange", KotlinBuiltIns.getInstance().getShortType())
|
||||
.put("IntRange", KotlinBuiltIns.getInstance().getIntType())
|
||||
.put("LongRange", KotlinBuiltIns.getInstance().getLongType())
|
||||
.put("FloatRange", KotlinBuiltIns.getInstance().getFloatType())
|
||||
.put("DoubleRange", KotlinBuiltIns.getInstance().getDoubleType())
|
||||
.put("CharRange", KotlinBuiltIns.getInstance().getCharType())
|
||||
.build();
|
||||
|
||||
private RangeCodegenUtil() {}
|
||||
|
||||
public static boolean isIntRange(JetType rangeType) {
|
||||
return !rangeType.isNullable()
|
||||
&& JetStandardLibrary.getInstance().getIntType().equals(getPrimitiveRangeElementType(rangeType));
|
||||
&& KotlinBuiltIns.getInstance().getIntType().equals(getPrimitiveRangeElementType(rangeType));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -84,7 +84,7 @@ public class RangeCodegenUtil {
|
||||
public static JetType getPrimitiveRangeElementType(JetType rangeType) {
|
||||
ClassifierDescriptor declarationDescriptor = rangeType.getConstructor().getDeclarationDescriptor();
|
||||
assert declarationDescriptor != null;
|
||||
if (declarationDescriptor != JetStandardLibrary.getInstance().getLibraryScope().getClassifier(declarationDescriptor.getName())) {
|
||||
if (declarationDescriptor != KotlinBuiltIns.getInstance().getBuiltInsScope().getClassifier(declarationDescriptor.getName())) {
|
||||
// Must be a standard library class
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -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.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.PrimitiveType;
|
||||
|
||||
import java.util.List;
|
||||
@@ -56,14 +56,14 @@ public class ArrayIterator implements IntrinsicMethod {
|
||||
.get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) call.getCalleeExpression());
|
||||
assert funDescriptor != null;
|
||||
ClassDescriptor containingDeclaration = (ClassDescriptor) funDescriptor.getContainingDeclaration().getOriginal();
|
||||
if (containingDeclaration.equals(JetStandardLibrary.getInstance().getArray())) {
|
||||
if (containingDeclaration.equals(KotlinBuiltIns.getInstance().getArray())) {
|
||||
v.invokestatic("jet/runtime/ArrayIterator", "iterator", "([Ljava/lang/Object;)Ljava/util/Iterator;");
|
||||
return StackValue.onStack(AsmTypeConstants.JET_ITERATOR_TYPE);
|
||||
}
|
||||
else {
|
||||
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
|
||||
PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
|
||||
ClassDescriptor arrayClass = JetStandardLibrary.getInstance().getPrimitiveArrayClassDescriptor(primitiveType);
|
||||
ClassDescriptor arrayClass = KotlinBuiltIns.getInstance().getPrimitiveArrayClassDescriptor(primitiveType);
|
||||
if (containingDeclaration.equals(arrayClass)) {
|
||||
String methodSignature = "([" + jvmPrimitiveType.getJvmLetter() + ")" + jvmPrimitiveType.getIterator().getDescriptor();
|
||||
v.invokestatic("jet/runtime/ArrayIterator", "iterator", methodSignature);
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -269,7 +268,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
return asmType;
|
||||
}
|
||||
|
||||
if (mapBuiltinsToJava && descriptor instanceof ClassDescriptor && JetStandardLibrary.getInstance().isArray(jetType)) {
|
||||
if (mapBuiltinsToJava && descriptor instanceof ClassDescriptor && KotlinBuiltIns.getInstance().isArray(jetType)) {
|
||||
if (jetType.getArguments().size() != 1) {
|
||||
throw new UnsupportedOperationException("arrays must have one type argument");
|
||||
}
|
||||
@@ -768,10 +767,10 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
if (containingDeclaration.getKind() == ClassKind.ENUM_CLASS || containingDeclaration.getKind() == ClassKind.ENUM_ENTRY) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.ENUM_NAME);
|
||||
mapType(JetStandardLibrary.getInstance().getStringType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
mapType(KotlinBuiltIns.getInstance().getStringType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.ENUM_ORDINAL);
|
||||
mapType(JetStandardLibrary.getInstance().getIntType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
mapType(KotlinBuiltIns.getInstance().getIntType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
@@ -870,7 +869,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
|
||||
private static boolean isGenericsArray(JetType type) {
|
||||
return JetStandardLibrary.getInstance().isArray(type) &&
|
||||
return KotlinBuiltIns.getInstance().isArray(type) &&
|
||||
type.getArguments().get(0).getType().getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user