[JVM] Unify initLocals method in Fast...Analyzer classes
This commit is contained in:
+5
-7
@@ -110,20 +110,18 @@ open class FastMethodAnalyzer<V : Value>
|
||||
var local = 0
|
||||
val isInstanceMethod = (method.access and Opcodes.ACC_STATIC) == 0
|
||||
if (isInstanceMethod) {
|
||||
current.setLocal(local, interpreter.newParameterValue(true, local, Type.getObjectType(owner)))
|
||||
val ctype = Type.getObjectType(owner)
|
||||
current.setLocal(local, interpreter.newParameterValue(true, local, ctype))
|
||||
local++
|
||||
}
|
||||
for (arg in args) {
|
||||
current.setLocal(local, interpreter.newParameterValue(isInstanceMethod, local, arg))
|
||||
local++
|
||||
current.setLocal(local++, interpreter.newValue(arg))
|
||||
if (arg.size == 2) {
|
||||
current.setLocal(local, interpreter.newEmptyValue(local))
|
||||
local++
|
||||
current.setLocal(local++, interpreter.newValue(null))
|
||||
}
|
||||
}
|
||||
while (local < method.maxLocals) {
|
||||
current.setLocal(local, interpreter.newEmptyValue(local))
|
||||
local++
|
||||
current.setLocal(local++, interpreter.newValue(null))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -53,6 +53,10 @@ abstract class BasicTypeInterpreter<V : Value> : Interpreter<V>(API_VERSION) {
|
||||
else -> throw AssertionError("Unexpected type: $type")
|
||||
}
|
||||
|
||||
override fun newEmptyValue(local: Int): V {
|
||||
return uninitializedValue()
|
||||
}
|
||||
|
||||
override fun newOperation(insn: AbstractInsnNode): V? =
|
||||
when (insn.opcode) {
|
||||
ACONST_NULL ->
|
||||
|
||||
+10
-5
@@ -141,18 +141,23 @@ internal open class FastStackAnalyzer<V : Value>(
|
||||
current.setReturn(interpreter.newValue(Type.getReturnType(method.desc)))
|
||||
val args = Type.getArgumentTypes(method.desc)
|
||||
var local = 0
|
||||
if ((method.access and Opcodes.ACC_STATIC) == 0) {
|
||||
val isInstanceMethod = (method.access and Opcodes.ACC_STATIC) == 0
|
||||
if (isInstanceMethod) {
|
||||
val ctype = Type.getObjectType(owner)
|
||||
current.setLocal(local++, interpreter.newValue(ctype))
|
||||
current.setLocal(local, interpreter.newParameterValue(true, local, ctype))
|
||||
local++
|
||||
}
|
||||
for (arg in args) {
|
||||
current.setLocal(local++, interpreter.newValue(arg))
|
||||
current.setLocal(local, interpreter.newParameterValue(isInstanceMethod, local, arg))
|
||||
local++
|
||||
if (arg.size == 2) {
|
||||
current.setLocal(local++, interpreter.newValue(null))
|
||||
current.setLocal(local, interpreter.newEmptyValue(local))
|
||||
local++
|
||||
}
|
||||
}
|
||||
while (local < method.maxLocals) {
|
||||
current.setLocal(local++, interpreter.newValue(null))
|
||||
current.setLocal(local, interpreter.newEmptyValue(local))
|
||||
local++
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-5
@@ -189,23 +189,25 @@ class FastStoreLoadAnalyzer<V : StoreLoadValue>(
|
||||
}
|
||||
|
||||
override fun initLocals(current: StoreLoadFrame<V>) {
|
||||
current.setReturn(interpreter.newReturnTypeValue(Type.getReturnType(method.desc)))
|
||||
val args = Type.getArgumentTypes(method.desc)
|
||||
var local = 0
|
||||
if ((method.access and Opcodes.ACC_STATIC) == 0) {
|
||||
val isInstanceMethod = (method.access and Opcodes.ACC_STATIC) == 0
|
||||
if (isInstanceMethod) {
|
||||
val ctype = Type.getObjectType(owner)
|
||||
current.setLocal(local, interpreter.newValue(ctype))
|
||||
current.setLocal(local, interpreter.newParameterValue(true, local, ctype))
|
||||
local++
|
||||
}
|
||||
for (arg in args) {
|
||||
current.setLocal(local, interpreter.newValue(arg))
|
||||
current.setLocal(local, interpreter.newParameterValue(isInstanceMethod, local, arg))
|
||||
local++
|
||||
if (arg.size == 2) {
|
||||
current.setLocal(local, interpreter.uninitialized())
|
||||
current.setLocal(local, interpreter.newEmptyValue(local))
|
||||
local++
|
||||
}
|
||||
}
|
||||
while (local < method.maxLocals) {
|
||||
current.setLocal(local, interpreter.uninitialized())
|
||||
current.setLocal(local, interpreter.newEmptyValue(local))
|
||||
local++
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user