avoid throwing EmptyStackExceptions in as2 deobfuscation

This commit is contained in:
2015-08-26 20:50:22 +02:00
parent 5465043ec0
commit 696ee04cb4
104 changed files with 1451 additions and 469 deletions
@@ -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) {