mirror of
https://github.com/revanced/smali.git
synced 2025-05-19 23:47:06 +02:00
Fix DebugItems in the new builder stuff
This commit is contained in:
parent
edd961477e
commit
84be16bf51
@ -33,14 +33,12 @@ package org.jf.dexlib2.builder;
|
||||
|
||||
import org.jf.dexlib2.iface.debug.DebugItem;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class BuilderDebugItem implements DebugItem {
|
||||
@Nullable MethodLocation location;
|
||||
|
||||
public BuilderDebugItem(@Nonnull MethodLocation location) {
|
||||
this.location = location;
|
||||
public BuilderDebugItem() {
|
||||
}
|
||||
|
||||
@Override public int getCodeAddress() {
|
||||
|
@ -183,31 +183,31 @@ public class MethodLocation {
|
||||
}
|
||||
|
||||
public void addLineNumber(int lineNumber) {
|
||||
debugItems.add(new BuilderLineNumber(this, lineNumber));
|
||||
getDebugItems().add(new BuilderLineNumber(lineNumber));
|
||||
}
|
||||
|
||||
public void addStartLocal(int registerNumber, @Nullable StringReference name, @Nullable TypeReference type,
|
||||
@Nullable StringReference signature) {
|
||||
debugItems.add(new BuilderStartLocal(this, registerNumber, name, type, signature));
|
||||
getDebugItems().add(new BuilderStartLocal(registerNumber, name, type, signature));
|
||||
}
|
||||
|
||||
public void addEndLocal(int registerNumber) {
|
||||
debugItems.add(new BuilderEndLocal(this, registerNumber));
|
||||
getDebugItems().add(new BuilderEndLocal(registerNumber));
|
||||
}
|
||||
|
||||
public void addRestartLocal(int registerNumber) {
|
||||
debugItems.add(new BuilderRestartLocal(this, registerNumber));
|
||||
getDebugItems().add(new BuilderRestartLocal(registerNumber));
|
||||
}
|
||||
|
||||
public void addPrologue() {
|
||||
debugItems.add(new BuilderPrologueEnd(this));
|
||||
getDebugItems().add(new BuilderPrologueEnd());
|
||||
}
|
||||
|
||||
public void addEpilogue() {
|
||||
debugItems.add(new BuilderEpilogueBegin(this));
|
||||
getDebugItems().add(new BuilderEpilogueBegin());
|
||||
}
|
||||
|
||||
public void addSetSourceFile(@Nullable BuilderStringReference sourceFile) {
|
||||
debugItems.add(new BuilderSetSourceFile(this, sourceFile));
|
||||
getDebugItems().add(new BuilderSetSourceFile(sourceFile));
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public class MutableMethodImplementation implements MethodImplementation {
|
||||
int debugCodeAddress = debugItem.getCodeAddress();
|
||||
int locationIndex = mapCodeAddressToIndex(codeAddressToIndex, debugCodeAddress);
|
||||
MethodLocation debugLocation = instructionList.get(locationIndex);
|
||||
BuilderDebugItem builderDebugItem = convertDebugItem(debugLocation, debugItem);
|
||||
BuilderDebugItem builderDebugItem = convertDebugItem(debugItem);
|
||||
debugLocation.getDebugItems().add(builderDebugItem);
|
||||
builderDebugItem.location = debugLocation;
|
||||
}
|
||||
@ -909,32 +909,32 @@ public class MutableMethodImplementation implements MethodImplementation {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private BuilderDebugItem convertDebugItem(@Nonnull MethodLocation location, @Nonnull DebugItem debugItem) {
|
||||
private BuilderDebugItem convertDebugItem(@Nonnull DebugItem debugItem) {
|
||||
switch (debugItem.getDebugItemType()) {
|
||||
case DebugItemType.START_LOCAL: {
|
||||
StartLocal startLocal = (StartLocal)debugItem;
|
||||
return new BuilderStartLocal(location, startLocal.getRegister(), startLocal.getNameReference(),
|
||||
return new BuilderStartLocal(startLocal.getRegister(), startLocal.getNameReference(),
|
||||
startLocal.getTypeReference(), startLocal.getSignatureReference());
|
||||
}
|
||||
case DebugItemType.END_LOCAL: {
|
||||
EndLocal endLocal = (EndLocal)debugItem;
|
||||
return new BuilderEndLocal(location, endLocal.getRegister());
|
||||
return new BuilderEndLocal(endLocal.getRegister());
|
||||
}
|
||||
case DebugItemType.RESTART_LOCAL: {
|
||||
RestartLocal restartLocal = (RestartLocal)debugItem;
|
||||
return new BuilderRestartLocal(location, restartLocal.getRegister());
|
||||
return new BuilderRestartLocal(restartLocal.getRegister());
|
||||
}
|
||||
case DebugItemType.PROLOGUE_END:
|
||||
return new BuilderPrologueEnd(location);
|
||||
return new BuilderPrologueEnd();
|
||||
case DebugItemType.EPILOGUE_BEGIN:
|
||||
return new BuilderEpilogueBegin(location);
|
||||
return new BuilderEpilogueBegin();
|
||||
case DebugItemType.LINE_NUMBER: {
|
||||
LineNumber lineNumber = (LineNumber)debugItem;
|
||||
return new BuilderLineNumber(location, lineNumber.getLineNumber());
|
||||
return new BuilderLineNumber(lineNumber.getLineNumber());
|
||||
}
|
||||
case DebugItemType.SET_SOURCE_FILE: {
|
||||
SetSourceFile setSourceFile = (SetSourceFile)debugItem;
|
||||
return new BuilderSetSourceFile(location, setSourceFile.getSourceFileReference());
|
||||
return new BuilderSetSourceFile(setSourceFile.getSourceFileReference());
|
||||
}
|
||||
default:
|
||||
throw new ExceptionWithContext("Invalid debug item type: " + debugItem.getDebugItemType());
|
||||
|
@ -33,18 +33,14 @@ package org.jf.dexlib2.builder.debug;
|
||||
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.builder.BuilderDebugItem;
|
||||
import org.jf.dexlib2.builder.MethodLocation;
|
||||
import org.jf.dexlib2.iface.debug.EndLocal;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BuilderEndLocal extends BuilderDebugItem implements EndLocal {
|
||||
private final int register;
|
||||
|
||||
public BuilderEndLocal(@Nonnull MethodLocation location,
|
||||
int register) {
|
||||
super(location);
|
||||
public BuilderEndLocal(int register) {
|
||||
this.register = register;
|
||||
}
|
||||
|
||||
|
@ -33,14 +33,10 @@ package org.jf.dexlib2.builder.debug;
|
||||
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.builder.BuilderDebugItem;
|
||||
import org.jf.dexlib2.builder.MethodLocation;
|
||||
import org.jf.dexlib2.iface.debug.EpilogueBegin;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BuilderEpilogueBegin extends BuilderDebugItem implements EpilogueBegin {
|
||||
public BuilderEpilogueBegin(@Nonnull MethodLocation location) {
|
||||
super(location);
|
||||
public BuilderEpilogueBegin() {
|
||||
}
|
||||
|
||||
@Override public int getDebugItemType() { return DebugItemType.EPILOGUE_BEGIN; }
|
||||
|
@ -33,17 +33,12 @@ package org.jf.dexlib2.builder.debug;
|
||||
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.builder.BuilderDebugItem;
|
||||
import org.jf.dexlib2.builder.MethodLocation;
|
||||
import org.jf.dexlib2.iface.debug.LineNumber;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BuilderLineNumber extends BuilderDebugItem implements LineNumber {
|
||||
private final int lineNumber;
|
||||
|
||||
public BuilderLineNumber(@Nonnull MethodLocation location,
|
||||
int lineNumber) {
|
||||
super(location);
|
||||
public BuilderLineNumber(int lineNumber) {
|
||||
this.lineNumber = lineNumber;
|
||||
}
|
||||
|
||||
|
@ -33,14 +33,10 @@ package org.jf.dexlib2.builder.debug;
|
||||
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.builder.BuilderDebugItem;
|
||||
import org.jf.dexlib2.builder.MethodLocation;
|
||||
import org.jf.dexlib2.iface.debug.PrologueEnd;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BuilderPrologueEnd extends BuilderDebugItem implements PrologueEnd {
|
||||
public BuilderPrologueEnd(@Nonnull MethodLocation location) {
|
||||
super(location);
|
||||
public BuilderPrologueEnd() {
|
||||
}
|
||||
|
||||
@Override public int getDebugItemType() { return DebugItemType.PROLOGUE_END; }
|
||||
|
@ -33,18 +33,14 @@ package org.jf.dexlib2.builder.debug;
|
||||
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.builder.BuilderDebugItem;
|
||||
import org.jf.dexlib2.builder.MethodLocation;
|
||||
import org.jf.dexlib2.iface.debug.RestartLocal;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BuilderRestartLocal extends BuilderDebugItem implements RestartLocal {
|
||||
private final int register;
|
||||
|
||||
public BuilderRestartLocal(@Nonnull MethodLocation location,
|
||||
int register) {
|
||||
super(location);
|
||||
public BuilderRestartLocal(int register) {
|
||||
this.register = register;
|
||||
}
|
||||
|
||||
|
@ -33,20 +33,16 @@ package org.jf.dexlib2.builder.debug;
|
||||
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.builder.BuilderDebugItem;
|
||||
import org.jf.dexlib2.builder.MethodLocation;
|
||||
import org.jf.dexlib2.iface.debug.SetSourceFile;
|
||||
import org.jf.dexlib2.iface.reference.StringReference;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BuilderSetSourceFile extends BuilderDebugItem implements SetSourceFile {
|
||||
@Nullable
|
||||
private final StringReference sourceFile;
|
||||
|
||||
public BuilderSetSourceFile(@Nonnull MethodLocation location,
|
||||
@Nullable StringReference sourceFile) {
|
||||
super(location);
|
||||
public BuilderSetSourceFile(@Nullable StringReference sourceFile) {
|
||||
this.sourceFile = sourceFile;
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,10 @@ package org.jf.dexlib2.builder.debug;
|
||||
|
||||
import org.jf.dexlib2.DebugItemType;
|
||||
import org.jf.dexlib2.builder.BuilderDebugItem;
|
||||
import org.jf.dexlib2.builder.MethodLocation;
|
||||
import org.jf.dexlib2.iface.debug.StartLocal;
|
||||
import org.jf.dexlib2.iface.reference.StringReference;
|
||||
import org.jf.dexlib2.iface.reference.TypeReference;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BuilderStartLocal extends BuilderDebugItem implements StartLocal {
|
||||
@ -47,12 +45,10 @@ public class BuilderStartLocal extends BuilderDebugItem implements StartLocal {
|
||||
@Nullable private final TypeReference type;
|
||||
@Nullable private final StringReference signature;
|
||||
|
||||
public BuilderStartLocal(@Nonnull MethodLocation location,
|
||||
int register,
|
||||
public BuilderStartLocal(int register,
|
||||
@Nullable StringReference name,
|
||||
@Nullable TypeReference type,
|
||||
@Nullable StringReference signature) {
|
||||
super(location);
|
||||
this.register = register;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
|
Loading…
x
Reference in New Issue
Block a user