From c274fc8d6ddb0959b82adce88f98ab41de031186 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 9 Sep 2014 19:17:21 +0400 Subject: [PATCH] Drop outdated JVM intrinsics EnumValueOf and EnumValues --- .../jet/codegen/intrinsics/EnumValueOf.java | 49 ------------------- .../jet/codegen/intrinsics/EnumValues.java | 46 ----------------- .../codegen/intrinsics/IntrinsicMethods.java | 29 ++--------- 3 files changed, 4 insertions(+), 120 deletions(-) delete mode 100644 compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/EnumValueOf.java delete mode 100644 compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/EnumValues.java diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/EnumValueOf.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/EnumValueOf.java deleted file mode 100644 index 8af7de2759f..00000000000 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/EnumValueOf.java +++ /dev/null @@ -1,49 +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.jet.codegen.ExpressionCodegen; -import org.jetbrains.jet.codegen.StackValue; -import org.jetbrains.jet.lang.psi.JetExpression; -import org.jetbrains.org.objectweb.asm.Type; -import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter; - -import java.util.List; - -import static org.jetbrains.jet.lang.resolve.DescriptorUtils.ENUM_VALUE_OF; -import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.JAVA_STRING_TYPE; - -public class EnumValueOf extends IntrinsicMethod { - @NotNull - @Override - public Type generateImpl( - @NotNull ExpressionCodegen codegen, - @NotNull InstructionAdapter v, - @NotNull Type returnType, - @Nullable PsiElement element, - @Nullable List arguments, - StackValue receiver - ) { - assert arguments != null; - codegen.gen(arguments.get(0), JAVA_STRING_TYPE); - v.invokestatic(returnType.getInternalName(), ENUM_VALUE_OF.asString(), "(Ljava/lang/String;)" + returnType.getDescriptor(), false); - return returnType; - } -} diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/EnumValues.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/EnumValues.java deleted file mode 100644 index 80929155378..00000000000 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/EnumValues.java +++ /dev/null @@ -1,46 +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.jet.codegen.ExpressionCodegen; -import org.jetbrains.jet.codegen.StackValue; -import org.jetbrains.jet.lang.psi.JetExpression; -import org.jetbrains.org.objectweb.asm.Type; -import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter; - -import java.util.List; - -import static org.jetbrains.jet.lang.resolve.DescriptorUtils.ENUM_VALUES; - -public class EnumValues extends IntrinsicMethod { - @NotNull - @Override - public Type generateImpl( - @NotNull ExpressionCodegen codegen, - @NotNull InstructionAdapter v, - @NotNull Type returnType, - @Nullable PsiElement element, - @Nullable List arguments, - StackValue receiver - ) { - v.invokestatic(returnType.getElementType().getInternalName(), ENUM_VALUES.asString(), "()" + returnType, false); - return returnType; - } -} 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 83dd41bde76..5a481ef03bd 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java @@ -19,10 +19,7 @@ package org.jetbrains.jet.codegen.intrinsics; import com.google.common.collect.ImmutableList; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.backend.common.CodegenUtil; import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor; -import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; -import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor; import org.jetbrains.jet.lang.resolve.CompileTimeConstantUtils; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType; @@ -35,8 +32,6 @@ import org.jetbrains.jet.lang.types.lang.PrimitiveType; import java.util.HashMap; import java.util.Map; -import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isClassObject; -import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isEnumClass; import static org.jetbrains.jet.lang.types.lang.KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME; import static org.jetbrains.org.objectweb.asm.Opcodes.*; @@ -58,8 +53,6 @@ public class IntrinsicMethods { private static final ArraySet ARRAY_SET = new ArraySet(); private static final ArrayGet ARRAY_GET = new ArrayGet(); private static final StringPlus STRING_PLUS = new StringPlus(); - private static final EnumValues ENUM_VALUES = new EnumValues(); - private static final EnumValueOf ENUM_VALUE_OF = new EnumValueOf(); private static final ToString TO_STRING = new ToString(); private static final Clone CLONE = new Clone(); @@ -197,25 +190,11 @@ public class IntrinsicMethods { return intrinsicMethod; } - if (descriptor instanceof SimpleFunctionDescriptor) { - SimpleFunctionDescriptor functionDescriptor = (SimpleFunctionDescriptor) descriptor; - - DeclarationDescriptor container = descriptor.getContainingDeclaration(); - //noinspection ConstantConditions - if (isClassObject(container) && isEnumClass(container.getContainingDeclaration())) { - if (CodegenUtil.isEnumValuesMethod(functionDescriptor)) { - return ENUM_VALUES; - } - - if (CodegenUtil.isEnumValueOfMethod(functionDescriptor)) { - return ENUM_VALUE_OF; - } - } + String value = CompileTimeConstantUtils.getIntrinsicAnnotationArgument(descriptor); + if (value != null) { + return namedMethods.get(value); } - String value = CompileTimeConstantUtils.getIntrinsicAnnotationArgument(descriptor); - if (value == null) return null; - - return namedMethods.get(value); + return null; } }