From 9d9d73268af42d23976cde076e31a7ac6bdc38dc Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 12 Feb 2014 21:17:07 +0400 Subject: [PATCH] Move and rename jet.runtime.SharedVar -> kotlin.jvm.internal.Ref --- .../jet/codegen/ExpressionCodegen.java | 4 +- .../org/jetbrains/jet/codegen/StackValue.java | 35 +++++------- .../lang/resolve/java/AsmTypeConstants.java | 10 +--- .../src/jet/runtime/SharedVar.java | 55 ------------------ .../src/kotlin/jvm/internal/Ref.java | 57 +++++++++++++++++++ .../OnlyScopedClassesWithoutExplicit.kt | 2 +- 6 files changed, 74 insertions(+), 89 deletions(-) delete mode 100644 core/runtime.jvm/src/jet/runtime/SharedVar.java create mode 100644 core/runtime.jvm/src/kotlin/jvm/internal/Ref.java diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 0576f62348f..f1a73813439 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -3230,8 +3230,8 @@ public class ExpressionCodegen extends JetVisitor implem else { v.load(index, OBJECT_TYPE); generateInitializer.fun(variableDescriptor); - v.putfield(sharedVarType.getInternalName(), "ref", - sharedVarType == JET_SHARED_VAR_TYPE ? "Ljava/lang/Object;" : varType.getDescriptor()); + v.putfield(sharedVarType.getInternalName(), "element", + sharedVarType.equals(OBJECT_REF_TYPE) ? "Ljava/lang/Object;" : varType.getDescriptor()); } } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java index a7df78b5aea..6758f921fe8 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java @@ -934,7 +934,7 @@ public abstract class StackValue { v.load(index, OBJECT_TYPE); Type refType = refType(this.type); Type sharedType = sharedTypeForType(this.type); - v.visitFieldInsn(GETFIELD, sharedType.getInternalName(), "ref", refType.getDescriptor()); + v.visitFieldInsn(GETFIELD, sharedType.getInternalName(), "element", refType.getDescriptor()); coerceFrom(refType, v); coerceTo(type, v); if (isReleaseOnPut) { @@ -950,7 +950,7 @@ public abstract class StackValue { AsmUtil.swap(v, sharedTypeForType(this.type), topOfStackType); Type refType = refType(this.type); Type sharedType = sharedTypeForType(this.type); - v.visitFieldInsn(PUTFIELD, sharedType.getInternalName(), "ref", refType.getDescriptor()); + v.visitFieldInsn(PUTFIELD, sharedType.getInternalName(), "element", refType.getDescriptor()); } } @@ -958,32 +958,23 @@ public abstract class StackValue { switch (type.getSort()) { case Type.OBJECT: case Type.ARRAY: - return JET_SHARED_VAR_TYPE; - + return OBJECT_REF_TYPE; case Type.BYTE: - return JET_SHARED_BYTE_TYPE; - + return Type.getObjectType("kotlin/jvm/internal/Ref$ByteRef"); case Type.SHORT: - return JET_SHARED_SHORT_TYPE; - + return Type.getObjectType("kotlin/jvm/internal/Ref$ShortRef"); case Type.CHAR: - return JET_SHARED_CHAR_TYPE; - + return Type.getObjectType("kotlin/jvm/internal/Ref$CharRef"); case Type.INT: - return JET_SHARED_INT_TYPE; - + return Type.getObjectType("kotlin/jvm/internal/Ref$IntRef"); case Type.LONG: - return JET_SHARED_LONG_TYPE; - + return Type.getObjectType("kotlin/jvm/internal/Ref$LongRef"); case Type.BOOLEAN: - return JET_SHARED_BOOLEAN_TYPE; - + return Type.getObjectType("kotlin/jvm/internal/Ref$BooleanRef"); case Type.FLOAT: - return JET_SHARED_FLOAT_TYPE; - + return Type.getObjectType("kotlin/jvm/internal/Ref$FloatRef"); case Type.DOUBLE: - return JET_SHARED_DOUBLE_TYPE; - + return Type.getObjectType("kotlin/jvm/internal/Ref$DoubleRef"); default: throw new UnsupportedOperationException(); } @@ -1011,7 +1002,7 @@ public abstract class StackValue { public void put(Type type, InstructionAdapter v) { Type sharedType = sharedTypeForType(this.type); Type refType = refType(this.type); - v.visitFieldInsn(GETFIELD, sharedType.getInternalName(), "ref", refType.getDescriptor()); + v.visitFieldInsn(GETFIELD, sharedType.getInternalName(), "element", refType.getDescriptor()); coerceFrom(refType, v); coerceTo(type, v); } @@ -1019,7 +1010,7 @@ public abstract class StackValue { @Override public void store(Type topOfStackType, InstructionAdapter v) { coerceFrom(topOfStackType, v); - v.visitFieldInsn(PUTFIELD, sharedTypeForType(type).getInternalName(), "ref", refType(type).getDescriptor()); + v.visitFieldInsn(PUTFIELD, sharedTypeForType(type).getInternalName(), "element", refType(type).getDescriptor()); } } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AsmTypeConstants.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AsmTypeConstants.java index f673729c050..bb6b9af84ba 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AsmTypeConstants.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AsmTypeConstants.java @@ -33,16 +33,8 @@ public class AsmTypeConstants { public static final Type JET_FUNCTION0_TYPE = Type.getObjectType("jet/Function0"); public static final Type JET_FUNCTION1_TYPE = Type.getObjectType("jet/Function1"); public static final Type JET_INT_RANGE_TYPE = Type.getObjectType("jet/IntRange"); - public static final Type JET_SHARED_VAR_TYPE = Type.getObjectType("jet/runtime/SharedVar$Object"); - public static final Type JET_SHARED_INT_TYPE = Type.getObjectType("jet/runtime/SharedVar$Int"); - public static final Type JET_SHARED_DOUBLE_TYPE = Type.getObjectType("jet/runtime/SharedVar$Double"); - public static final Type JET_SHARED_FLOAT_TYPE = Type.getObjectType("jet/runtime/SharedVar$Float"); - public static final Type JET_SHARED_BYTE_TYPE = Type.getObjectType("jet/runtime/SharedVar$Byte"); - public static final Type JET_SHARED_SHORT_TYPE = Type.getObjectType("jet/runtime/SharedVar$Short"); - public static final Type JET_SHARED_CHAR_TYPE = Type.getObjectType("jet/runtime/SharedVar$Char"); - public static final Type JET_SHARED_LONG_TYPE = Type.getObjectType("jet/runtime/SharedVar$Long"); - public static final Type JET_SHARED_BOOLEAN_TYPE = Type.getObjectType("jet/runtime/SharedVar$Boolean"); + public static final Type OBJECT_REF_TYPE = Type.getObjectType("kotlin/jvm/internal/Ref$ObjectRef"); public static Type getType(@NotNull Class javaClass) { Type type = TYPES_MAP.get(javaClass); diff --git a/core/runtime.jvm/src/jet/runtime/SharedVar.java b/core/runtime.jvm/src/jet/runtime/SharedVar.java deleted file mode 100644 index 41e537acd7e..00000000000 --- a/core/runtime.jvm/src/jet/runtime/SharedVar.java +++ /dev/null @@ -1,55 +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 jet.runtime; - -public final class SharedVar { - public static final class Object { - public T ref; - } - - public static final class Byte { - public byte ref; - } - - public static final class Short { - public short ref; - } - - public static final class Int { - public int ref; - } - - public static final class Long { - public long ref; - } - - public static final class Float { - public float ref; - } - - public static final class Double { - public double ref; - } - - public static final class Char { - public char ref; - } - - public static final class Boolean { - public boolean ref; - } -} diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/Ref.java b/core/runtime.jvm/src/kotlin/jvm/internal/Ref.java new file mode 100644 index 00000000000..970920db091 --- /dev/null +++ b/core/runtime.jvm/src/kotlin/jvm/internal/Ref.java @@ -0,0 +1,57 @@ +/* + * 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 kotlin.jvm.internal; + +public class Ref { + private Ref() {} + + public static final class ObjectRef { + public T element; + } + + public static final class ByteRef { + public byte element; + } + + public static final class ShortRef { + public short element; + } + + public static final class IntRef { + public int element; + } + + public static final class LongRef { + public long element; + } + + public static final class FloatRef { + public float element; + } + + public static final class DoubleRef { + public double element; + } + + public static final class CharRef { + public char element; + } + + public static final class BooleanRef { + public boolean element; + } +} diff --git a/idea/testData/completion/basic/common/OnlyScopedClassesWithoutExplicit.kt b/idea/testData/completion/basic/common/OnlyScopedClassesWithoutExplicit.kt index 3d7fff8f7a7..f2d77a4dcd6 100644 --- a/idea/testData/completion/basic/common/OnlyScopedClassesWithoutExplicit.kt +++ b/idea/testData/completion/basic/common/OnlyScopedClassesWithoutExplicit.kt @@ -6,4 +6,4 @@ fun firstFun() { // INVOCATION_COUNT: 0 // EXIST: { lookupString:"Int", tailText:" (jet)" } -// ABSENT: { lookupString:"Int", tailText:" (jet.runtime.SharedVar)" } \ No newline at end of file +// ABSENT: { lookupString:"IntRef", tailText:" (kotlin.internal.Ref)" }