diff --git a/eval4j/src/org/jetbrains/eval4j/interpreter.kt b/eval4j/src/org/jetbrains/eval4j/interpreter.kt index ec8e7418abb..91b270adfe3 100644 --- a/eval4j/src/org/jetbrains/eval4j/interpreter.kt +++ b/eval4j/src/org/jetbrains/eval4j/interpreter.kt @@ -25,25 +25,25 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.Interpreter class UnsupportedByteCodeException(message: String) : RuntimeException(message) -public interface Eval { - public fun loadClass(classType: Type): Value - public fun loadString(str: String): Value - public fun newInstance(classType: Type): Value - public fun isInstanceOf(value: Value, targetType: Type): Boolean +interface Eval { + fun loadClass(classType: Type): Value + fun loadString(str: String): Value + fun newInstance(classType: Type): Value + fun isInstanceOf(value: Value, targetType: Type): Boolean - public fun newArray(arrayType: Type, size: Int): Value - public fun newMultiDimensionalArray(arrayType: Type, dimensionSizes: List): Value - public fun getArrayLength(array: Value): Value - public fun getArrayElement(array: Value, index: Value): Value - public fun setArrayElement(array: Value, index: Value, newValue: Value) + fun newArray(arrayType: Type, size: Int): Value + fun newMultiDimensionalArray(arrayType: Type, dimensionSizes: List): Value + fun getArrayLength(array: Value): Value + fun getArrayElement(array: Value, index: Value): Value + fun setArrayElement(array: Value, index: Value, newValue: Value) - public fun getStaticField(fieldDesc: FieldDescription): Value - public fun setStaticField(fieldDesc: FieldDescription, newValue: Value) - public fun invokeStaticMethod(methodDesc: MethodDescription, arguments: List): Value + fun getStaticField(fieldDesc: FieldDescription): Value + fun setStaticField(fieldDesc: FieldDescription, newValue: Value) + fun invokeStaticMethod(methodDesc: MethodDescription, arguments: List): Value - public fun getField(instance: Value, fieldDesc: FieldDescription): Value - public fun setField(instance: Value, fieldDesc: FieldDescription, newValue: Value) - public fun invokeMethod(instance: Value, methodDesc: MethodDescription, arguments: List, invokespecial: Boolean = false): Value + fun getField(instance: Value, fieldDesc: FieldDescription): Value + fun setField(instance: Value, fieldDesc: FieldDescription, newValue: Value) + fun invokeMethod(instance: Value, methodDesc: MethodDescription, arguments: List, invokespecial: Boolean = false): Value } class SingleInstructionInterpreter(private val eval: Eval) : Interpreter(ASM5) { @@ -203,7 +203,7 @@ class SingleInstructionInterpreter(private val eval: Eval) : Interpreter( } } - public fun checkUnaryCondition(value: Value, opcode: Int): Boolean { + fun checkUnaryCondition(value: Value, opcode: Int): Boolean { return when (opcode) { IFEQ -> value.int == 0 IFNE -> value.int != 0 @@ -312,7 +312,7 @@ class SingleInstructionInterpreter(private val eval: Eval) : Interpreter( } } - public fun checkBinaryCondition(value1: Value, value2: Value, opcode: Int): Boolean { + fun checkBinaryCondition(value1: Value, value2: Value, opcode: Int): Boolean { return when (opcode) { IF_ICMPEQ -> value1.int == value2.int IF_ICMPNE -> value1.int != value2.int diff --git a/eval4j/src/org/jetbrains/eval4j/interpreterLoop.kt b/eval4j/src/org/jetbrains/eval4j/interpreterLoop.kt index 767f1fc273d..8e29e1d7dd1 100644 --- a/eval4j/src/org/jetbrains/eval4j/interpreterLoop.kt +++ b/eval4j/src/org/jetbrains/eval4j/interpreterLoop.kt @@ -24,29 +24,29 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.Frame import org.jetbrains.org.objectweb.asm.util.Printer import java.util.* -public interface InterpreterResult { +interface InterpreterResult { override fun toString(): String } -public class ExceptionThrown(public val exception: ObjectValue, public val kind: ExceptionKind): InterpreterResult { +class ExceptionThrown(val exception: ObjectValue, val kind: ExceptionKind): InterpreterResult { override fun toString(): String = "Thrown $exception: $kind" - public enum class ExceptionKind { + enum class ExceptionKind { FROM_EVALUATED_CODE, FROM_EVALUATOR, BROKEN_CODE } } -public data class ValueReturned(public val result: Value): InterpreterResult { +data class ValueReturned(val result: Value): InterpreterResult { override fun toString(): String = "Returned $result" } -public class AbnormalTermination(public val message: String): InterpreterResult { +class AbnormalTermination(val message: String): InterpreterResult { override fun toString(): String = "Terminated abnormally: $message" } -public interface InterpretationEventHandler { +interface InterpretationEventHandler { object NONE : InterpretationEventHandler { override fun instructionProcessed(insn: AbstractInsnNode): InterpreterResult? = null override fun exceptionThrown(currentState: Frame, currentInsn: AbstractInsnNode, exception: Value): InterpreterResult? = null @@ -71,7 +71,7 @@ class ThrownFromEvaluatedCodeException(val exception: ObjectValue): RuntimeExcep override fun toString(): String = "Thrown from evaluated code: $exception" } -public fun interpreterLoop( +fun interpreterLoop( m: MethodNode, initialState: Frame, eval: Eval, diff --git a/eval4j/src/org/jetbrains/eval4j/jdi/jdiEval.kt b/eval4j/src/org/jetbrains/eval4j/jdi/jdiEval.kt index 06be613793b..5304f15714f 100644 --- a/eval4j/src/org/jetbrains/eval4j/jdi/jdiEval.kt +++ b/eval4j/src/org/jetbrains/eval4j/jdi/jdiEval.kt @@ -28,7 +28,7 @@ val CLASS = Type.getType(Class::class.java) val OBJECT = Type.getType(Any::class.java) val BOOTSTRAP_CLASS_DESCRIPTORS = setOf("Ljava/lang/String;", "Ljava/lang/ClassLoader;", "Ljava/lang/Class;") -public class JDIEval( +class JDIEval( private val vm: VirtualMachine, private val defaultClassLoader: ClassLoaderReference?, private val thread: ThreadReference, @@ -251,7 +251,7 @@ public class JDIEval( mayThrow { obj.setValue(field, jdiValue) } } - public fun unboxType(boxedValue: Value, type: Type): Value { + fun unboxType(boxedValue: Value, type: Type): Value { val method = when (type) { Type.INT_TYPE -> MethodDescription("java/lang/Integer", "intValue", "()I", false) Type.BOOLEAN_TYPE -> MethodDescription("java/lang/Boolean", "booleanValue", "()Z", false) @@ -266,7 +266,7 @@ public class JDIEval( return invokeMethod(boxedValue, method, listOf(), true) } - public fun boxType(value: Value): Value { + fun boxType(value: Value): Value { val method = when (value.asmType) { Type.INT_TYPE -> MethodDescription("java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false) Type.BYTE_TYPE -> MethodDescription("java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false) diff --git a/eval4j/src/org/jetbrains/eval4j/jdi/jdiValues.kt b/eval4j/src/org/jetbrains/eval4j/jdi/jdiValues.kt index bb8a88c89b0..149a79891d3 100644 --- a/eval4j/src/org/jetbrains/eval4j/jdi/jdiValues.kt +++ b/eval4j/src/org/jetbrains/eval4j/jdi/jdiValues.kt @@ -36,7 +36,7 @@ import com.sun.jdi.Type as jdi_Type import com.sun.jdi.Value as jdi_Value import com.sun.jdi.VoidValue as jdi_VoidValue -public fun makeInitialFrame(methodNode: MethodNode, arguments: List): Frame { +fun makeInitialFrame(methodNode: MethodNode, arguments: List): Frame { val isStatic = (methodNode.access and ACC_STATIC) != 0 val params = Type.getArgumentTypes(methodNode.desc) @@ -64,14 +64,14 @@ public fun makeInitialFrame(methodNode: MethodNode, arguments: List): Fra class JDIFailureException(message: String?, cause: Throwable? = null): RuntimeException(message, cause) -public fun jdi_ObjectReference?.asValue(): ObjectValue { +fun jdi_ObjectReference?.asValue(): ObjectValue { return when (this) { null -> NULL_VALUE else -> ObjectValue(this, type().asType()) } } -public fun jdi_Value?.asValue(): Value { +fun jdi_Value?.asValue(): Value { return when (this) { null -> NULL_VALUE is jdi_VoidValue -> VOID_VALUE @@ -96,7 +96,7 @@ val Value.jdiObj: jdi_ObjectReference? val Value.jdiClass: ClassObjectReference? get() = this.jdiObj as ClassObjectReference? -public fun Value.asJdiValue(vm: VirtualMachine, expectedType: Type): jdi_Value? { +fun Value.asJdiValue(vm: VirtualMachine, expectedType: Type): jdi_Value? { return when (this) { NULL_VALUE -> null VOID_VALUE -> vm.mirrorOfVoid() diff --git a/eval4j/src/org/jetbrains/eval4j/members.kt b/eval4j/src/org/jetbrains/eval4j/members.kt index 3892d661949..ff5f18c6bb8 100644 --- a/eval4j/src/org/jetbrains/eval4j/members.kt +++ b/eval4j/src/org/jetbrains/eval4j/members.kt @@ -74,7 +74,7 @@ val MethodDescription.parameterTypes: List get() = Type.getArgumentTypes(desc).toList() -public class FieldDescription( +class FieldDescription( ownerInternalName: String, name: String, desc: String, diff --git a/eval4j/src/org/jetbrains/eval4j/values.kt b/eval4j/src/org/jetbrains/eval4j/values.kt index eaed17cfd51..0f7ca0e2881 100644 --- a/eval4j/src/org/jetbrains/eval4j/values.kt +++ b/eval4j/src/org/jetbrains/eval4j/values.kt @@ -19,9 +19,9 @@ package org.jetbrains.eval4j import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.tree.LabelNode -public interface Value : org.jetbrains.org.objectweb.asm.tree.analysis.Value { - public val asmType: Type - public val valid: Boolean +interface Value : org.jetbrains.org.objectweb.asm.tree.analysis.Value { + val asmType: Type + val valid: Boolean override fun getSize(): Int = asmType.size override fun toString(): String @@ -57,7 +57,7 @@ abstract class AbstractValueBase( override val asmType: Type ) : Value { override val valid = true - public abstract val value: V + abstract val value: V override fun toString() = "$value: $asmType" @@ -81,7 +81,7 @@ class IntValue(value: Int, asmType: Type): AbstractValue(value, asmType) class LongValue(value: Long): AbstractValue(value, Type.LONG_TYPE) class FloatValue(value: Float): AbstractValue(value, Type.FLOAT_TYPE) class DoubleValue(value: Double): AbstractValue(value, Type.DOUBLE_TYPE) -public open class ObjectValue(value: Any?, asmType: Type): AbstractValue(value, asmType) +open class ObjectValue(value: Any?, asmType: Type): AbstractValue(value, asmType) class NewObjectValue(asmType: Type): ObjectValue(null, asmType) { override var value: Any? = null get(): Any? {