Skip to content

Commit

Permalink
Fix varies NPE's in handling abstract methods in the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Oct 14, 2024
1 parent 429b822 commit 1c687a6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javafx.util.Duration;
import me.darknet.assembler.ast.ASTElement;
import me.darknet.assembler.ast.primitive.ASTArray;
import me.darknet.assembler.ast.primitive.ASTCode;
import me.darknet.assembler.ast.primitive.ASTInstruction;
import me.darknet.assembler.ast.primitive.ASTLabel;
import me.darknet.assembler.ast.primitive.ASTObject;
Expand Down Expand Up @@ -199,7 +200,10 @@ private void updateModel() {
Consumer<ASTMethod> methodConsumer = astMethod -> {
if (currentMethod != null && !Objects.equals(currentMethod.getName(), astMethod.getName().literal()))
return;
for (ASTInstruction instruction : astMethod.code().instructions()) {
ASTCode code = astMethod.code();
if (code == null)
return;
for (ASTInstruction instruction : code.instructions()) {
if (instruction instanceof ASTLabel label) {
readUpdater.accept(label.identifier().content(), label);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import me.darknet.assembler.ast.ASTElement;
import me.darknet.assembler.ast.primitive.ASTCode;
import me.darknet.assembler.ast.primitive.ASTEmpty;
import me.darknet.assembler.ast.primitive.ASTInstruction;
import me.darknet.assembler.ast.specific.ASTClass;
Expand Down Expand Up @@ -185,7 +186,10 @@ private int getSelectedInsnIndexOfMethod(@Nonnull ASTMethod method) {
int pos = editor.getCodeArea().getCaretPosition();
if (!method.range().within(pos))
return -1;
List<ASTInstruction> instructions = method.code().instructions();
ASTCode code = method.code();
if (code == null)
return -1;
List<ASTInstruction> instructions = code.instructions();
int paragraph = editor.getCodeArea().getCurrentParagraph();
int result = Collections.binarySearch(instructions, new ASTEmpty(new Token(
new Range(pos, pos + 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import me.darknet.assembler.ast.ASTElement;
import me.darknet.assembler.ast.primitive.ASTCode;
import me.darknet.assembler.ast.primitive.ASTIdentifier;
import me.darknet.assembler.ast.primitive.ASTInstruction;
import me.darknet.assembler.ast.specific.ASTClass;
Expand Down Expand Up @@ -220,7 +221,10 @@ private void updateTable() {
String literalName = parameter.literal();
variableUsages.putIfAbsent(literalName, emptyUsage);
}
for (ASTInstruction instruction : astMethod.code().instructions()) {
ASTCode code = astMethod.code();
if (code == null)
return;
for (ASTInstruction instruction : code.instructions()) {
String insnName = instruction.identifier().content();
boolean isLoad = insnName.endsWith("load");
if (((isLoad || insnName.endsWith("store")) && insnName.charAt(1) != 'a') || insnName.equals("iinc")) {
Expand Down

0 comments on commit 1c687a6

Please sign in to comment.