mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-26 22:00:45 +00:00
AS1/2 and AS3 now share common decompiling method
This commit is contained in:
@@ -16,68 +16,30 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.action.treemodel;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.IgnoredPair;
|
||||
import com.jpexs.decompiler.flash.helpers.Highlighting;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class TreeItem {
|
||||
public abstract class TreeItem extends GraphTargetItem {
|
||||
|
||||
public static final int PRECEDENCE_PRIMARY = 0;
|
||||
public static final int PRECEDENCE_POSTFIX = 1;
|
||||
public static final int PRECEDENCE_UNARY = 2;
|
||||
public static final int PRECEDENCE_MULTIPLICATIVE = 3;
|
||||
public static final int PRECEDENCE_ADDITIVE = 4;
|
||||
public static final int PRECEDENCE_BITWISESHIFT = 5;
|
||||
public static final int PRECEDENCE_RELATIONAL = 6;
|
||||
public static final int PRECEDENCE_EQUALITY = 7;
|
||||
public static final int PRECEDENCE_BITWISEAND = 8;
|
||||
public static final int PRECEDENCE_BITWISEXOR = 9;
|
||||
public static final int PRECEDENCE_BITWISEOR = 10;
|
||||
public static final int PRECEDENCE_LOGICALAND = 11;
|
||||
public static final int PRECEDENCE_LOGICALOR = 12;
|
||||
public static final int PRECEDENCE_CONDITIONAL = 13;
|
||||
public static final int PRECEDENCE_ASSIGMENT = 14;
|
||||
public static final int PRECEDENCE_COMMA = 15;
|
||||
public static final int NOPRECEDENCE = 16;
|
||||
public int precedence = NOPRECEDENCE;
|
||||
public Action instruction;
|
||||
public int instructionPos = 0;
|
||||
public List<IgnoredPair> moreInstructions = new ArrayList<IgnoredPair>();
|
||||
public List<GraphSourceItemPos> moreInstructions = new ArrayList<GraphSourceItemPos>();
|
||||
|
||||
public TreeItem(Action instruction, int precedence) {
|
||||
this.instruction = instruction;
|
||||
this.precedence = precedence;
|
||||
public TreeItem(GraphSourceItem instruction, int precedence) {
|
||||
super(instruction, precedence);
|
||||
}
|
||||
|
||||
public abstract String toString(ConstantPool constants);
|
||||
|
||||
public String toStringNoQuotes(ConstantPool constants) {
|
||||
return toString(constants);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toString(null);
|
||||
ConstantPool c = null;
|
||||
return toString(c);
|
||||
}
|
||||
|
||||
protected String hilight(String str) {
|
||||
if (instruction == null) {
|
||||
return str;
|
||||
}
|
||||
return Highlighting.hilighOffset(str, instruction.getAddress());
|
||||
}
|
||||
|
||||
public boolean isFalse() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isTrue() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isEmptyString(TreeItem target) {
|
||||
protected boolean isEmptyString(GraphTargetItem target) {
|
||||
if (target instanceof DirectValueTreeItem) {
|
||||
if (((DirectValueTreeItem) target).value instanceof String) {
|
||||
|
||||
@@ -89,7 +51,7 @@ public abstract class TreeItem {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected String stripQuotes(TreeItem target) {
|
||||
protected String stripQuotes(GraphTargetItem target) {
|
||||
if (target instanceof DirectValueTreeItem) {
|
||||
if (((DirectValueTreeItem) target).value instanceof String) {
|
||||
return (String) ((DirectValueTreeItem) target).hilight((String) ((DirectValueTreeItem) target).value);
|
||||
@@ -102,24 +64,17 @@ public abstract class TreeItem {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCompileTime() {
|
||||
return false;
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
return getNeededSources();
|
||||
}
|
||||
|
||||
public double toNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean toBoolean() {
|
||||
return Double.compare(toNumber(), 0.0) != 0;
|
||||
}
|
||||
|
||||
public List<com.jpexs.decompiler.flash.action.IgnoredPair> getNeededActions() {
|
||||
List<com.jpexs.decompiler.flash.action.IgnoredPair> ret = new ArrayList<com.jpexs.decompiler.flash.action.IgnoredPair>();
|
||||
if (instruction != null) {
|
||||
ret.add(new IgnoredPair(instruction, instructionPos));
|
||||
@Override
|
||||
public String toString(List localData) {
|
||||
if (localData.isEmpty()) {
|
||||
ConstantPool c = null;
|
||||
return toString(c);
|
||||
}
|
||||
ret.addAll(moreInstructions);
|
||||
return ret;
|
||||
return toString((ConstantPool) localData.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user