diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java index 936e0ca3376..d82fa7073c0 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java @@ -147,15 +147,10 @@ public class IntrinsicMethods { declareIntrinsicProperty(Name.identifier("CharSequence"), Name.identifier("length"), new StringLength()); declareIntrinsicProperty(Name.identifier("String"), Name.identifier("length"), new StringLength()); - Name unitName = KotlinBuiltIns.getInstance().getUnit().getName(); - intrinsicsMap.registerIntrinsic( - getClassObjectFqName(unitName), - Name.identifier("VALUE"), -1, new UnitValue()); + registerStaticField(getFQName(KotlinBuiltIns.getInstance().getUnit()).toSafe(), Name.identifier("VALUE")); for (PrimitiveType type : PrimitiveType.NUMBER_TYPES) { - intrinsicsMap.registerIntrinsic( - getClassObjectFqName(type.getRangeTypeName()), - Name.identifier("EMPTY"), -1, new EmptyRange(type)); + registerStaticField(type.getRangeClassName(), Name.identifier("EMPTY")); } for (PrimitiveType type : PrimitiveType.NUMBER_TYPES) { @@ -170,13 +165,13 @@ public class IntrinsicMethods { declareArrayMethods(); } - private void registerRangeOrProgressionProperty(@NotNull FqName ownerClass, @NotNull Name propertyName) { - intrinsicsMap.registerIntrinsic(ownerClass, propertyName, -1, new PropertyOfProgressionOrRange(ownerClass, propertyName)); + private void registerStaticField(@NotNull FqName classFqName, @NotNull Name propertyName) { + FqNameUnsafe classObjectFqName = classFqName.toUnsafe().child(getClassObjectName(classFqName.shortName())); + intrinsicsMap.registerIntrinsic(classObjectFqName, propertyName, -1, new StaticField(classFqName, propertyName)); } - @NotNull - private static FqNameUnsafe getClassObjectFqName(@NotNull Name builtinClassName) { - return KotlinBuiltIns.getInstance().getBuiltInsPackageFqName().child(builtinClassName).toUnsafe().child(getClassObjectName(builtinClassName)); + private void registerRangeOrProgressionProperty(@NotNull FqName ownerClass, @NotNull Name propertyName) { + intrinsicsMap.registerIntrinsic(ownerClass, propertyName, -1, new PropertyOfProgressionOrRange(ownerClass, propertyName)); } private void declareArrayMethods() { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/EmptyRange.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/StaticField.java similarity index 74% rename from compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/EmptyRange.java rename to compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/StaticField.java index ebb066e4598..6339aeaaf21 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/EmptyRange.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/StaticField.java @@ -26,15 +26,19 @@ import org.jetbrains.jet.codegen.StackValue; import org.jetbrains.jet.codegen.state.GenerationState; import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.resolve.java.JvmClassName; -import org.jetbrains.jet.lang.types.lang.PrimitiveType; +import org.jetbrains.jet.lang.resolve.name.FqName; +import org.jetbrains.jet.lang.resolve.name.Name; import java.util.List; -public class EmptyRange implements IntrinsicMethod { - private final PrimitiveType elementType; +public class StaticField implements IntrinsicMethod { + private final FqName ownerClass; + private final Name propertyName; - public EmptyRange(PrimitiveType elementType) { - this.elementType = elementType; + + public StaticField(FqName ownerClass, Name propertyName) { + this.ownerClass = ownerClass; + this.propertyName = propertyName; } @Override @@ -47,8 +51,7 @@ public class EmptyRange implements IntrinsicMethod { StackValue receiver, @NotNull GenerationState state ) { - JvmClassName name = JvmClassName.byFqNameWithoutInnerClasses(elementType.getRangeClassName().getFqName()); - v.getstatic(name.toString(), "EMPTY", "L" + name + ";"); + v.getstatic(JvmClassName.byFqNameWithoutInnerClasses(ownerClass).getInternalName(), propertyName.getName(), expectedType.getDescriptor()); return StackValue.onStack(expectedType); } } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/UnitValue.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/UnitValue.java deleted file mode 100644 index ad3394f0268..00000000000 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/UnitValue.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2010-2013 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.codegen.intrinsics; - -import com.intellij.psi.PsiElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.asm4.Type; -import org.jetbrains.asm4.commons.InstructionAdapter; -import org.jetbrains.jet.codegen.ExpressionCodegen; -import org.jetbrains.jet.codegen.StackValue; -import org.jetbrains.jet.codegen.state.GenerationState; -import org.jetbrains.jet.lang.psi.JetExpression; - -import java.util.List; - -import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.JET_UNIT_TYPE; - -public class UnitValue implements IntrinsicMethod { - - @Override - public StackValue generate( - ExpressionCodegen codegen, - InstructionAdapter v, - @NotNull Type expectedType, - @Nullable PsiElement element, - @Nullable List arguments, - StackValue receiver, - @NotNull GenerationState state - ) { - v.getstatic(JET_UNIT_TYPE.getInternalName(), "VALUE", JET_UNIT_TYPE.getDescriptor()); - return StackValue.onStack(expectedType); - } -}