Support instance fields and methods

This commit is contained in:
Andrey Breslav
2013-10-13 12:01:00 +04:00
parent 3e26f205b3
commit a5dba2938d
2 changed files with 15 additions and 4 deletions
+14 -3
View File
@@ -124,12 +124,23 @@ class JDIEval(
}
override fun getField(instance: Value, fieldDesc: FieldDescription): Value {
throw UnsupportedOperationException()
val field = findField(fieldDesc)
val obj = instance.jdiObj.checkNull()
return obj.getValue(field).asValue()
}
override fun setField(instance: Value, fieldDesc: FieldDescription, newValue: Value) {
throw UnsupportedOperationException()
val field = findField(fieldDesc)
val obj = instance.jdiObj.checkNull()
return obj.setValue(field, newValue.asJdiValue(vm))
}
override fun invokeMethod(instance: Value, methodDesc: MethodDescription, arguments: List<Value>, invokespecial: Boolean): Value {
throw UnsupportedOperationException()
val method = findMethod(methodDesc)
val obj = instance.jdiObj.checkNull()
return obj.invokeMethod(thread, method, arguments.map { v -> v.asJdiValue(vm) }, 0).asValue()
}
}
+1 -1
View File
@@ -99,7 +99,7 @@ val Value.obj: Any?
return (this as AbstractValue<*>).value
}
fun Any?.checkNull(): Any {
fun <T: Any> T?.checkNull(): T {
if (this == null) {
throwException(NullPointerException())
}