mirror of
https://github.com/revanced/smali.git
synced 2025-05-09 10:54:29 +02:00
Fix up and improve how parameters are mapped to registers, for local info
This additionally adds the local info for the "this" parameter
This commit is contained in:
parent
269c15688b
commit
8582095cfb
@ -106,34 +106,38 @@ public abstract class DebugInfo implements Iterable<DebugItem> {
|
|||||||
VariableSizeList<? extends MethodParameter> parameters = getParametersWithNames();
|
VariableSizeList<? extends MethodParameter> parameters = getParametersWithNames();
|
||||||
final VariableSizeList<? extends MethodParameter>.Iterator parameterIterator = parameters.listIterator();
|
final VariableSizeList<? extends MethodParameter>.Iterator parameterIterator = parameters.listIterator();
|
||||||
|
|
||||||
{ // local scope for i
|
// first, we grab all the parameters and temporarily store them at the beginning of locals,
|
||||||
int i=0;
|
// disregarding any wide types
|
||||||
while (parameterIterator.hasNext()) {
|
int parameterIndex = 0;
|
||||||
locals[i++] = parameterIterator.next();
|
if (!AccessFlags.STATIC.isSet(methodImpl.method.getAccessFlags())) {
|
||||||
}
|
// add the local info for the "this" parameter
|
||||||
|
locals[parameterIndex++] = new LocalInfo() {
|
||||||
|
@Override public String getName() { return "this"; }
|
||||||
|
@Override public String getType() { return methodImpl.method.classDef.getName(); }
|
||||||
|
@Override public String getSignature() { return null; }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
while (parameterIterator.hasNext()) {
|
||||||
|
locals[parameterIndex++] = parameterIterator.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters.size() < registerCount) {
|
if (parameterIndex < registerCount) {
|
||||||
// we need to push the parameter locals back to their appropriate register
|
// now, we push the parameter locals back to their appropriate register, starting from the end
|
||||||
int localIndex = registerCount-1;
|
int localIndex = registerCount-1;
|
||||||
for (int i=parameters.size()-1; i>-1; i--) {
|
while(--parameterIndex > -1) {
|
||||||
LocalInfo currentLocal = locals[i];
|
LocalInfo currentLocal = locals[parameterIndex];
|
||||||
String type = currentLocal.getType();
|
String type = currentLocal.getType();
|
||||||
if (type != null && (type.equals("J") || type.equals("D"))) {
|
if (type != null && (type.equals("J") || type.equals("D"))) {
|
||||||
localIndex--;
|
localIndex--;
|
||||||
|
if (localIndex == parameterIndex) {
|
||||||
|
// there's no more room to push, the remaining registers are already in the correct place
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
locals[localIndex] = currentLocal;
|
locals[localIndex] = currentLocal;
|
||||||
locals[i] = EMPTY_LOCAL_INFO;
|
locals[parameterIndex] = EMPTY_LOCAL_INFO;
|
||||||
localIndex--;
|
localIndex--;
|
||||||
}
|
}
|
||||||
if (!AccessFlags.STATIC.isSet(methodImpl.method.getAccessFlags())) {
|
|
||||||
// add the local info for the "this" parameter
|
|
||||||
locals[localIndex] = new LocalInfo() {
|
|
||||||
@Override public String getName() { return "this"; }
|
|
||||||
@Override public String getType() { return methodImpl.method.classDef.getName(); }
|
|
||||||
@Override public String getSignature() { return null; }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Iterator<DebugItem>() {
|
return new Iterator<DebugItem>() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user