mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 10:41:06 +00:00
avoid throwing EmptyStackExceptions in as2 deobfuscation
This commit is contained in:
@@ -25,6 +25,10 @@ public interface GraphSourceItem extends Serializable, Cloneable {
|
||||
|
||||
public void translate(BaseLocalData localData, TranslateStack stack, List<GraphTargetItem> output, int staticOperation, String path) throws InterruptedException;
|
||||
|
||||
public int getStackPopCount(BaseLocalData localData, TranslateStack stack);
|
||||
|
||||
public int getStackPushCount(BaseLocalData localData, TranslateStack stack);
|
||||
|
||||
public boolean isJump();
|
||||
|
||||
public boolean isBranch();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.graph;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
|
||||
@@ -375,4 +376,15 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
|
||||
writer.endBlock();
|
||||
return writer;
|
||||
}
|
||||
|
||||
public long getAsLong() {
|
||||
if (this instanceof DirectValueActionItem) {
|
||||
DirectValueActionItem dvai = (DirectValueActionItem) this;
|
||||
if (dvai.value instanceof Long) {
|
||||
return (long) (Long) dvai.value;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,16 @@ public class TranslateStack extends Stack<GraphTargetItem> {
|
||||
return super.peek();
|
||||
}
|
||||
|
||||
public synchronized GraphTargetItem peek(int index) {
|
||||
if (path != null) {
|
||||
if (index > this.size()) {
|
||||
Logger.getLogger(TranslateStack.class.getName()).log(Level.FINE, "{0}: Attemp to Peek item from stack", path);
|
||||
return getPop();
|
||||
}
|
||||
}
|
||||
return super.get(size() - index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized GraphTargetItem pop() {
|
||||
if (path != null) {
|
||||
|
||||
Reference in New Issue
Block a user