Merge branch 'v6'

Conflicts:
	libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java
	libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java
	libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/SymbolType.java
	libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java
	libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java
	libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java
	libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionGraph.java
	libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java
	libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java
	libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/SymbolType.java
	libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java
	libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphSourceItem.java
	libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java
	libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java
	libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java
	src/com/jpexs/decompiler/flash/gui/Main.java
	src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java
This commit is contained in:
Jindra Petřík
2015-07-03 19:06:09 +02:00
150 changed files with 8061 additions and 6047 deletions

View File

@@ -1777,7 +1777,7 @@ public final class SWF implements SWFContainerItem, Timelined {
private static void getVariables(List<MyEntry<DirectValueActionItem, ConstantPool>> variables, List<GraphSourceItem> functions, HashMap<DirectValueActionItem, ConstantPool> strings, HashMap<DirectValueActionItem, String> usageTypes, ActionGraphSource code, int addr, String path) throws InterruptedException {
ActionLocalData localData = new ActionLocalData();
getVariables(null, localData, new TranslateStack(), new ArrayList<GraphTargetItem>(), code, code.adr2pos(addr), variables, functions, strings, new ArrayList<Integer>(), usageTypes, path);
getVariables(null, localData, new TranslateStack(path), new ArrayList<GraphTargetItem>(), code, code.adr2pos(addr), variables, functions, strings, new ArrayList<Integer>(), usageTypes, path);
}
private List<MyEntry<DirectValueActionItem, ConstantPool>> getVariables(List<MyEntry<DirectValueActionItem, ConstantPool>> variables, HashMap<ASMSource, ActionList> actionsMap, List<GraphSourceItem> functions, HashMap<DirectValueActionItem, ConstantPool> strings, HashMap<DirectValueActionItem, String> usageTypes, ASMSource src, String path) throws InterruptedException {

View File

@@ -59,17 +59,21 @@ import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.helpers.utf8.Utf8PrintWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.collections.transformation.SortedList;
public class ABC {
@@ -107,7 +111,7 @@ public class ABC {
public ABCContainerTag parentTag;
/* Map from multiname index of namespace value to namespace name**/
private Map<String, String> namespaceMap;
private Map<String, DottedChain> namespaceMap;
public ABC(ABCContainerTag tag) {
this.parentTag = tag;
@@ -323,7 +327,7 @@ public class ABC {
int mIndex = body.getCode().code.get(ip).operands[0];
if (mIndex > 0) {
Multiname m = constants.getMultiname(mIndex);
if (m.getNameWithNamespace(constants, true).equals("flash.utils.getDefinitionByName")) {
if (m.getNameWithNamespace(constants).equals("flash.utils.getDefinitionByName")) {
if (ip > 0) {
if (body.getCode().code.get(ip - 1).definition instanceof PushStringIns) {
int strIndex = body.getCode().code.get(ip - 1).operands[0];
@@ -812,16 +816,16 @@ public class ABC {
}
}
private Map<String, String> getNamespaceMap() {
private Map<String, DottedChain> getNamespaceMap() {
if (namespaceMap == null) {
Map<String, String> map = new HashMap<>();
Map<String, DottedChain> map = new HashMap<>();
for (ScriptInfo si : script_info) {
for (Trait t : si.traits.traits) {
if (t instanceof TraitSlotConst) {
TraitSlotConst s = ((TraitSlotConst) t);
if (s.isNamespace()) {
String key = constants.getNamespace(s.value_index).getName(constants, true); // assume not null
String val = constants.getMultiname(s.name_index).getNameWithNamespace(constants, true);
DottedChain val = constants.getMultiname(s.name_index).getNameWithNamespace(constants);
map.put(key, val);
}
}
@@ -855,15 +859,15 @@ public class ABC {
return bodyIdxFromMethodIdx;
}
public String nsValueToName(String value) {
public DottedChain nsValueToName(String value) {
if (getNamespaceMap().containsKey(value)) {
return getNamespaceMap().get(value);
} else {
String ns = getDeobfuscation().builtInNs(value);
if (ns == null) {
return "";
return new DottedChain("");
} else {
return ns;
return new DottedChain(ns);
}
}
}
@@ -1037,8 +1041,8 @@ public class ABC {
public int findClassByName(String name) {
for (int c = 0; c < instance_info.size(); c++) {
String s = constants.getMultiname(instance_info.get(c).name_index).getNameWithNamespace(constants, true);
if (name.equals(s)) {
DottedChain s = constants.getMultiname(instance_info.get(c).name_index).getNameWithNamespace(constants);
if (name.equals(s.toString())) {
return c;
}
}
@@ -1229,31 +1233,54 @@ public class ABC {
method_info.remove(index);
}
public void replaceScriptPack(ScriptPack pack, String as) throws AVM2ParseException, CompilationException, IOException, InterruptedException {
public boolean replaceScriptPack(ScriptPack pack, String as) throws AVM2ParseException, CompilationException, IOException, InterruptedException {
String scriptName = pack.getPathScriptName() + ".as";
int oldIndex = pack.scriptIndex;
int newIndex = script_info.size();
String documentClass = getSwf().getDocumentClass();
boolean isDocumentClass = documentClass != null && documentClass.equals(pack.getClassPath().toString());
boolean isSimple = pack.isSimple;
ScriptInfo si = script_info.get(oldIndex);
si.delete(this, true);
int newClassIndex = instance_info.size();
for (Trait t : si.traits.traits) {
if (t instanceof TraitClass) {
TraitClass tc = (TraitClass) t;
newClassIndex = tc.class_info + 1;
if (isSimple) {
si.delete(this, true);
} else {
for (int t : pack.traitIndices) {
si.traits.traits.get(t).delete(this, true);
}
}
int newClassIndex = instance_info.size();
for (int t : pack.traitIndices) {
if (si.traits.traits.get(t) instanceof TraitClass) {
TraitClass tc = (TraitClass) si.traits.traits.get(t);
newClassIndex = tc.class_info + 1;
}
}
List<ABC> otherAbcs = new ArrayList<>(pack.allABCs);
otherAbcs.remove(this);
ActionScript3Parser.compile(as, this, otherAbcs, isDocumentClass, scriptName, newClassIndex);
// Move newly added script to its position
script_info.set(oldIndex, script_info.get(newIndex));
script_info.remove(newIndex);
if (isSimple) {
// Move newly added script to its position
script_info.set(oldIndex, script_info.get(newIndex));
script_info.remove(newIndex);
} else {
script_info.get(newIndex).setModified(true);
//Note: Is deleting traits safe?
List<Integer> todel = new ArrayList<>(new TreeSet<>(pack.traitIndices));
for (int i = todel.size() - 1; i >= 0; i--) {
si.traits.traits.remove((int) todel.get(i));
}
}
script_info.get(oldIndex).setModified(true);
pack(); // removes old classes/methods
((Tag) parentTag).setModified(true);
return !isSimple;
}
public void pack() {

View File

@@ -27,6 +27,7 @@ import com.jpexs.decompiler.graph.ScopeStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
@@ -56,9 +57,10 @@ public class AVM2LocalData extends BaseLocalData {
public ArrayList<ABCException> parsedExceptions;
public ArrayList<Integer> finallyJumps;
public Map<Integer, List<Integer>> finallyJumps;
public ArrayList<Integer> ignoredSwitches;
public Map<Integer, Integer> ignoredSwitches;
public List<Integer> ignoredSwitches2;
public Integer scriptIndex;
@@ -88,6 +90,7 @@ public class AVM2LocalData extends BaseLocalData {
parsedExceptions = localData.parsedExceptions;
finallyJumps = localData.finallyJumps;
ignoredSwitches = localData.ignoredSwitches;
ignoredSwitches2 = localData.ignoredSwitches2;
scriptIndex = localData.scriptIndex;
localRegAssignmentIps = localData.localRegAssignmentIps;
ip = localData.ip;

View File

@@ -61,6 +61,7 @@ public class ScriptPack extends AS3ClassTreeItem {
public final List<Integer> traitIndices;
private final ClassPath path;
public boolean isSimple = false;
@Override
public SWF getSwf() {

View File

@@ -282,6 +282,7 @@ import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateException;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.ExitItem;
import com.jpexs.decompiler.graph.model.ScriptEndItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayInputStream;
@@ -1153,7 +1154,7 @@ public class AVM2Code implements Cloneable {
}
int ret = posCache.indexOf(address);
if (ret == -1) {
throw new ConvertException("Bad jump try conver ofs" + Helper.formatAddress(address) + " ", -1);
throw new ConvertException("Invalid jump to ofs" + Helper.formatAddress(address), -1);
}
return ret;
}
@@ -1247,8 +1248,8 @@ public class AVM2Code implements Cloneable {
if (isKilled(((SetLocalAVM2Item) output.get(i)).regIndex, 0, code.size() - 1)) {
SetLocalAVM2Item lsi = (SetLocalAVM2Item) output.get(i);
if (i + 1 < output.size()) {
if (output.get(i + 1) instanceof ReturnValueAVM2Item) {
ReturnValueAVM2Item rv = (ReturnValueAVM2Item) output.get(i + 1);
if (output.get(i + 1) instanceof ExitItem) {
GraphTargetItem rv = output.get(i + 1);
if (rv.value instanceof LocalRegAVM2Item) {
LocalRegAVM2Item lr = (LocalRegAVM2Item) rv.value;
if (lr.regIndex == lsi.regIndex) {
@@ -1446,7 +1447,7 @@ public class AVM2Code implements Cloneable {
}
}
if (!isKilled(reg, 0, end)) {
GraphTargetItem vx = stack.pop();
GraphTargetItem vx = stack.pop().getThroughDuplicate();
int dupCnt = 1;
for (int i = ip - 1; i >= start; i--) {
if (code.get(i).definition instanceof DupIns) {
@@ -1773,118 +1774,203 @@ public class AVM2Code implements Cloneable {
return list;
}
public void updateOffsets(OffsetUpdater updater, MethodBody body) {
for (int i = 0; i < code.size(); i++) {
AVM2Instruction ins = code.get(i);
if (ins.definition instanceof LookupSwitchIns) {
long target = ins.offset + ins.operands[0];
ins.operands[0] = updater.updateOperandOffset(ins.offset, target, ins.operands[0]);
for (int k = 2; k < ins.operands.length; k++) {
target = ins.offset + ins.operands[k];
ins.operands[k] = updater.updateOperandOffset(ins.offset, target, ins.operands[k]);
}
} else {
/*for (int j = 0; j < ins.definition.operands.length; j++) {
if (ins.definition.operands[j] == AVM2Code.DAT_OFFSET) {
long target = ins.offset + ins.getBytes().length + ins.operands[j];
ins.operands[j] = updater.updateOperandOffset(target, ins.operands[j]);
}
}*/
//Faster, but not so universal
if ((ins.definition instanceof JumpIns) || (ins.definition instanceof IfTypeIns)) {
long target = ins.offset + ins.getBytes().length + ins.operands[0];
ins.operands[0] = updater.updateOperandOffset(ins.offset, target, ins.operands[0]);
}
}
ins.offset = updater.updateInstructionOffset(ins.offset);
}
for (ABCException ex : body.exceptions) {
ex.start = updater.updateOperandOffset(-1, ex.start, ex.start);
ex.end = updater.updateOperandOffset(-1, ex.end, ex.end);
ex.target = updater.updateOperandOffset(-1, ex.target, ex.target);
}
}
private void checkValidOffsets(MethodBody body) {
updateOffsets(new OffsetUpdater() {
@Override
public long updateInstructionOffset(long offset) {
adr2pos(offset);
return offset;
}
@Override
public int updateOperandOffset(long insAddr, long targetAddress, int offset) {
adr2pos(targetAddress);
return offset;
}
}, body);
}
public void removeInstruction(int pos, MethodBody body) {
if ((pos < 0) || (pos >= code.size())) {
throw new IndexOutOfBoundsException();
}
int byteCount = code.get(pos).getBytes().length;
long remOffset = code.get(pos).offset;
for (int i = pos + 1; i < code.size(); i++) {
code.get(i).offset -= byteCount;
}
checkValidOffsets(body);
final long remOffset = code.get(pos).offset;
final int byteCount = code.get(pos).getBytes().length;
updateOffsets(new OffsetUpdater() {
@Override
public long updateInstructionOffset(long address) {
if (address > remOffset) {
return address - byteCount;
}
return address;
}
for (ABCException ex : body.exceptions) {
if (ex.start > remOffset) {
ex.start -= byteCount;
}
if (ex.end > remOffset) {
ex.end -= byteCount;
}
if (ex.target > remOffset) {
ex.target -= byteCount;
}
}
for (int i = 0; i < pos; i++) {
if (code.get(i).definition instanceof LookupSwitchIns) {
long target = code.get(i).offset + code.get(i).operands[0];
if (target > remOffset) {
code.get(i).operands[0] -= byteCount;
}
for (int k = 2; k < code.get(i).operands.length; k++) {
target = code.get(i).offset + code.get(i).operands[k];
if (target > remOffset) {
code.get(i).operands[k] -= byteCount;
}
}
} else {
for (int j = 0; j < code.get(i).definition.operands.length; j++) {
if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) {
long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j];
if (target > remOffset) {
code.get(i).operands[j] -= byteCount;
}
@Override
public int updateOperandOffset(long insAddr, long targetAddress, int offset) {
if (targetAddress > remOffset) {
if (insAddr > remOffset) {
return offset;
}
return offset - byteCount;
}
return offset;
}
}
for (int i = pos + 1; i < code.size(); i++) {
if (code.get(i).definition instanceof LookupSwitchIns) {
long target = code.get(i).offset + code.get(i).operands[0];
if (target < remOffset) {
code.get(i).operands[0] += byteCount;
}
for (int k = 2; k < code.get(i).operands.length; k++) {
target = code.get(i).offset + code.get(i).operands[k];
if (target < remOffset) {
code.get(i).operands[k] += byteCount;
}
}
} else {
for (int j = 0; j < code.get(i).definition.operands.length; j++) {
if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) {
long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j];
if (target < remOffset) {
code.get(i).operands[j] += byteCount;
}
}
}
}
}
}, body);
code.remove(pos);
invalidateCache();
checkValidOffsets(body);
//System.exit(0);
}
public void insertInstruction(int pos, AVM2Instruction instruction) {
/**
* Inserts instuction at specified point. Handles offsets properly. Note: If
* newinstruction is jump, the offset operand must be handled properly by
* caller. All old jump offsets to pos are targeted before new instruction.
*
* @param pos Position in the list
* @param instruction Instruction False means before new instruction
* @param body Method body (used for try handling)
*/
public void insertInstruction(int pos, AVM2Instruction instruction, MethodBody body) {
insertInstruction(pos, instruction, false, body);
}
/**
* Replaces instrunction by another. Properly handles offsets. Note: If
* newinstruction is jump, the offset operand must be handled properly by
* caller.
*
* @param pos
* @param instruction
* @param body
*/
public void replaceInstruction(int pos, AVM2Instruction instruction, MethodBody body) {
if (pos < 0) {
pos = 0;
}
if (pos > code.size()) {
pos = code.size();
}
int byteCount = instruction.getBytes().length;
instruction.offset = code.get(pos).offset;
int oldByteCount = code.get(pos).getBytes().length;
int newByteCount = instruction.getBytes().length;
int byteDelta = newByteCount - oldByteCount;
if (byteDelta != 0) {
updateOffsets(new OffsetUpdater() {
@Override
public long updateInstructionOffset(long addr) {
if (addr > instruction.offset) {
return addr + byteDelta;
}
return addr;
}
@Override
public int updateOperandOffset(long insAddr, long targetAddress, int offset) {
if (targetAddress > instruction.offset && insAddr <= instruction.offset) {
return offset + byteDelta;
}
if (targetAddress <= instruction.offset && insAddr > instruction.offset) {
return offset - byteDelta;
}
return offset;
}
}, body);
}
code.set(pos, instruction);
invalidateCache();
checkValidOffsets(body);
}
/**
* Inserts instuction at specified point. Handles offsets properly. Note: If
* newinstruction is jump, the offset operand must be handled properly by
* caller.
*
* @param pos Position in the list
* @param instruction Instruction
* @param mapOffsetsAfterIns Map all jumps to the pos after new instruction?
* False means before new instruction
* @param body Method body (used for try handling)
*/
public void insertInstruction(int pos, AVM2Instruction instruction, boolean mapOffsetsAfterIns, MethodBody body) {
checkValidOffsets(body);
if (pos < 0) {
pos = 0;
}
if (pos > code.size()) {
pos = code.size();
}
final int byteCount = instruction.getBytes().length;
if (pos == code.size()) {
instruction.offset = code.get(pos - 1).offset + code.get(pos - 1).getBytes().length;
} else {
instruction.offset = code.get(pos).offset;
}
updateOffsets(new OffsetUpdater() {
for (int i = 0; i < pos; i++) {
for (int j = 0; j < code.get(i).definition.operands.length; j++) {
if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) {
long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j];
if (target >= instruction.offset) {
code.get(i).operands[j] += byteCount;
}
@Override
public long updateInstructionOffset(long offset) {
if (offset >= instruction.offset) {
return offset + byteCount;
}
return offset;
}
}
for (int i = pos; i < code.size(); i++) {
for (int j = 0; j < code.get(i).definition.operands.length; j++) {
if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) {
long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j];
if (target < instruction.offset) {
code.get(i).operands[j] -= byteCount;
}
}
}
}
for (int i = pos + 1; i < code.size(); i++) {
code.get(i).offset += byteCount;
}
@Override
public int updateOperandOffset(long insAddr, long targetAddress, int offset) {
//System.err.println("instruction.offset=" + instruction.offset);
if ((targetAddress > instruction.offset) || (mapOffsetsAfterIns && (targetAddress == instruction.offset))) {
if (insAddr >= instruction.offset) {
return offset;
}
return offset + byteCount;
}
return offset;
}
}, body);
code.add(pos, instruction);
invalidateCache();
checkValidOffsets(body);
}
@SuppressWarnings("unchecked")
@@ -1903,6 +1989,7 @@ public class AVM2Code implements Cloneable {
ret.parsedExceptions = localData.parsedExceptions;
ret.finallyJumps = localData.finallyJumps;
ret.ignoredSwitches = localData.ignoredSwitches;
ret.ignoredSwitches2 = localData.ignoredSwitches2;
ret.scriptIndex = localData.scriptIndex;
ret.localRegAssignmentIps = localData.localRegAssignmentIps;
ret.ip = localData.ip;
@@ -1925,8 +2012,9 @@ public class AVM2Code implements Cloneable {
localData.localRegNames = body.getLocalRegNames(abc);
localData.fullyQualifiedNames = new ArrayList<>();
localData.parsedExceptions = new ArrayList<>();
localData.finallyJumps = new ArrayList<>();
localData.ignoredSwitches = new ArrayList<>();
localData.finallyJumps = new HashMap<>();
localData.ignoredSwitches = new HashMap<>();
localData.ignoredSwitches2 = new ArrayList<>();
localData.scriptIndex = scriptIndex;
localData.localRegAssignmentIps = new HashMap<>();
localData.ip = 0;
@@ -2450,36 +2538,38 @@ public class AVM2Code implements Cloneable {
restoreControlFlowPass(constants, trait, info, body, false);
//restoreControlFlowPass(constants, body, true);
}
/*private void removeIgnored(MethodBody body) {
for (int rem = code.size() - 1; rem >= 0; rem--) {
if (code.get(rem).ignored) {
removeInstruction(rem, body);
/*
public void removeIgnored(AVM2ConstantPool constants, Trait trait, MethodInfo info, MethodBody body) throws InterruptedException {
try {
List<Integer> outputMap = new ArrayList<>();
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false);
toASMSource(constants, trait, info, body, outputMap, ScriptExportMode.PCODE, writer);
String src = writer.toString();
AVM2Code acode = ASM3Parser.parse(new StringReader(src), constants, trait, body, info);
for (int i = 0; i < acode.code.size(); i++) {
if (outputMap.size() > i) {
int tpos = outputMap.get(i);
if (tpos == -1) {
} else if (code.get(tpos).mappedOffset >= 0) {
acode.code.get(i).mappedOffset = code.get(tpos).mappedOffset;
} else {
acode.code.get(i).mappedOffset = pos2adr(tpos);
}
}
}
this.code = acode.code;
} catch (IOException | AVM2ParseException ex) {
}
invalidateCache();
}*/
public void removeIgnored(AVM2ConstantPool constants, Trait trait, MethodInfo info, MethodBody body) throws InterruptedException {
try {
List<Integer> outputMap = new ArrayList<>();
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false);
toASMSource(constants, trait, info, body, outputMap, ScriptExportMode.PCODE, writer);
String src = writer.toString();
AVM2Code acode = ASM3Parser.parse(new StringReader(src), constants, trait, body, info);
for (int i = 0; i < acode.code.size(); i++) {
if (outputMap.size() > i) {
int tpos = outputMap.get(i);
if (tpos == -1) {
} else if (code.get(tpos).mappedOffset >= 0) {
acode.code.get(i).mappedOffset = code.get(tpos).mappedOffset;
} else {
acode.code.get(i).mappedOffset = pos2adr(tpos);
}
}
for (int i = 0; i < code.size(); i++) {
if (code.get(i).ignored) {
removeInstruction(i, body);
i--;
}
this.code = acode.code;
} catch (IOException | AVM2ParseException ex) {
}
invalidateCache();
}
public int removeDeadCode(AVM2ConstantPool constants, Trait trait, MethodInfo info, MethodBody body) throws InterruptedException {
@@ -2962,7 +3052,7 @@ public class AVM2Code implements Cloneable {
public static int removeTraps(AVM2ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, AVM2LocalData localData, AVM2GraphSource code, int addr, String path, HashMap<Integer, List<Integer>> refs) throws InterruptedException {
HashMap<AVM2Instruction, AVM2Code.Decision> decisions = new HashMap<>();
removeTraps(refs, false, false, localData, new TranslateStack(), new ArrayList<GraphTargetItem>(), code, code.adr2pos(addr), new HashMap<Integer, Integer>(), new HashMap<Integer, HashMap<Integer, GraphTargetItem>>(), decisions, path, 0);
removeTraps(refs, false, false, localData, new TranslateStack(path), new ArrayList<GraphTargetItem>(), code, code.adr2pos(addr), new HashMap<Integer, Integer>(), new HashMap<Integer, HashMap<Integer, GraphTargetItem>>(), decisions, path, 0);
int cnt = 0;
for (AVM2Instruction src : decisions.keySet()) {
Decision dec = decisions.get(src);

View File

@@ -0,0 +1,59 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
/**
*
* @author JPEXS
*/
public class FixItemCounterTranslateStack extends TranslateStack {
private int fixItemCount = Integer.MAX_VALUE;
public FixItemCounterTranslateStack(String path) {
super(null); //null path => do not add PushItems
}
@Override
public GraphTargetItem pop() {
GraphTargetItem result = super.pop();
int itemCount = size();
if (itemCount < fixItemCount) {
fixItemCount = itemCount;
}
return result;
}
@Override
public synchronized GraphTargetItem remove(int index) {
if (index < fixItemCount) {
fixItemCount = index;
}
return super.remove(index);
}
public boolean allItemsFixed() {
return size() <= fixItemCount;
}
public int getFixItemCount() {
return fixItemCount;
}
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2;
/**
*
* @author JPEXS
*/
public interface OffsetUpdater {
public long updateInstructionOffset(long addr);
public int updateOperandOffset(long jumpAddr, long targetAddress, int offset);
}

View File

@@ -0,0 +1,89 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.deobfuscation;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.action.ActionList;
import java.util.List;
import java.util.Map;
/**
*
* AVM2 Deobfuscator removing single assigned local registers.
*
* Example: var a = true; var b = false; ... if(a){ ...ok }else{ not executed }
*
* @author JPEXS
*/
public class AVM2DeobfuscatorJumps extends AVM2DeobfuscatorSimple {
//private final int executionLimit = 30000;
@Override
public void actionListParsed(ActionList actions, SWF swf) {
}
@Override
public void deobfuscate(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body) throws InterruptedException {
//body.getCode().markMappedOffsets();
//removeUnreachableActions(body.getCode(), cpool, trait, minfo, body);
AVM2Code code = body.getCode();
boolean found;
do {
found = false;
Map<Integer, List<Integer>> refs = body.getCode().visitCode(body);
loopi:
for (int i = 0; i < code.code.size(); i++) {
AVM2Instruction ins = code.code.get(i);
if (ins.definition instanceof JumpIns) {
long targetAddr = ins.offset + ins.operands[0] + ins.getBytes().length;
{
for (int r : refs.get(i)) {
if (r >= 0) { //Not Exception start/end
AVM2Instruction srcIns = code.code.get(r);
if ((srcIns.definition instanceof JumpIns) || ((srcIns.definition instanceof IfTypeIns) && (r != i - 1))) {
{
int oldop = srcIns.operands[0];
srcIns.operands[0] = (int) (targetAddr - (srcIns.offset + srcIns.getBytes().length));
if (srcIns.operands[0] != oldop) {
found = true;
}
}
}
}
}
}
}
}
removeUnreachableActions(body.getCode(), cpool, trait, minfo, body);
} while (found);
}
}

View File

@@ -0,0 +1,245 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.deobfuscation;
import com.jpexs.decompiler.flash.BaseLocalData;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2GraphSource;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.DeobfuscatePopIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocalTypeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocalTypeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnValueIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ThrowIns;
import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.action.ActionList;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphPart;
import com.jpexs.decompiler.graph.GraphSource;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateException;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.ArrayList;
import java.util.EmptyStackException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
*
* AVM2 Deobfuscator removing single assigned local registers.
*
* Example: var a = true; var b = false; ... if(a){ ...ok }else{ not executed }
*
* @author JPEXS
*/
public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
//private final int executionLimit = 30000;
@Override
public void actionListParsed(ActionList actions, SWF swf) {
}
@Override
public void deobfuscate(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body) throws InterruptedException {
body.getCode().markMappedOffsets();
removeUnreachableActions(body.getCode(), cpool, trait, minfo, body);
Map<Integer, GraphTargetItem> singleRegisters = getSingleUseRegisters(classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body);
replaceSingleUseRegisters(singleRegisters, classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body);
super.deobfuscate(path, classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body);
removeUnreachableActions(body.getCode(), cpool, trait, minfo, body);
}
private void replaceSingleUseRegisters(Map<Integer, GraphTargetItem> singleRegisters, int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body) {
AVM2Code code = body.getCode();
for (int i = 0; i < code.code.size(); i++) {
AVM2Instruction ins = code.code.get(i);
if (ins.definition instanceof SetLocalTypeIns) {
SetLocalTypeIns slt = (SetLocalTypeIns) ins.definition;
int regId = slt.getRegisterId(ins);
if (singleRegisters.containsKey(regId)) {
code.replaceInstruction(i, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), new int[]{}), body);
}
}
if (ins.definition instanceof GetLocalTypeIns) {
GetLocalTypeIns glt = (GetLocalTypeIns) ins.definition;
int regId = glt.getRegisterId(ins);
if (singleRegisters.containsKey(regId)) {
code.replaceInstruction(i, makePush(singleRegisters.get(regId).getResult(), cpool), body);
}
}
}
}
private Map<Integer, GraphTargetItem> getSingleUseRegisters(int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body) {
AVM2Code code = body.getCode();
Map<Integer, GraphTargetItem> ret = new HashMap<>();
if (code.code.isEmpty()) {
return ret;
}
ExecutionResult res = new ExecutionResult();
visitCode(new HashSet<>(), new TranslateStack("deo"), classIndex, isStatic, body, scriptIndex, abc, code, 0, code.code.size() - 1, res);
for (int reg : res.assignCount.keySet()) {
if (res.assignCount.get(reg) == 1) {
ret.put(reg, res.lastAssigned.get(reg));
}
}
return ret;
}
private void visitCode(Set<Integer> visited, TranslateStack stack, int classIndex, boolean isStatic, MethodBody body, int scriptIndex, ABC abc, AVM2Code code, int idx, int endIdx, ExecutionResult result) {
List<GraphTargetItem> output = new ArrayList<>();
AVM2LocalData localData = newLocalData(scriptIndex, abc, abc.constants, body, isStatic, classIndex);
localData.localRegs.put(0, new NullAVM2Item(null));//this
int instructionsProcessed = 0;
try {
while (true) {
if (idx > endIdx) {
break;
}
if (visited.contains(idx)) {
break;
}
visited.add(idx);
AVM2Instruction action = code.code.get(idx);
instructionsProcessed++;
action.translate(localData, stack, output, Graph.SOP_USE_STATIC, "");
InstructionDefinition def = action.definition;
if (def instanceof SetLocalTypeIns) {
SetLocalTypeIns slt = (SetLocalTypeIns) def;
int regId = slt.getRegisterId(action);
if (!result.assignCount.containsKey(regId)) {
result.assignCount.put(regId, 0);
}
result.assignCount.put(regId, result.assignCount.get(regId) + 1);
GraphTargetItem regVal = localData.localRegs.get(regId);
if (regVal == null || !regVal.getNotCoerced().isCompileTime()) {
result.assignCount.put(regId, Integer.MAX_VALUE);
} else {
result.lastAssigned.put(regId, regVal.getNotCoerced());
}
//assignCount
}
idx++;
if (action.definition instanceof JumpIns) {
long address = action.offset + action.getBytes().length + action.operands[0];
idx = code.adr2pos(address);//code.indexOf(code.getByAddress(address));
if (idx == -1) {
throw new TranslateException("Jump target not found: " + address);
}
}
if (action.isBranch()) {
List<Integer> branches = action.getBranches(new GraphSource() {
@Override
public int size() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public GraphSourceItem get(int pos) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean isEmpty() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public List<GraphTargetItem> translatePart(GraphPart part, BaseLocalData localData, TranslateStack stack, int start, int end, int staticOperation, String path) throws InterruptedException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public int adr2pos(long adr) {
return code.adr2pos(adr);
}
@Override
public long pos2adr(int pos) {
return code.pos2adr(pos);
}
});
idx = branches.get(0);
for (int n = 1; n < branches.size(); n++) {
visitCode(visited, (TranslateStack) stack.clone(), classIndex, isStatic, body, scriptIndex, abc, code, branches.get(n), endIdx, result);
}
}
/*if (action.definition instanceof IfTypeIns) {
long address = action.offset + action.getBytes().length + action.operands[0];
int newIdx = code.adr2pos(address);
if (newIdx == -1) {
throw new TranslateException("If target not found: " + address);
}
visitCode(visited, (TranslateStack) stack.clone(), classIndex, isStatic, body, scriptIndex, abc, code, newIdx, endIdx, result);
}*/
if (action.definition instanceof ReturnValueIns) {
break;
}
if (action.definition instanceof ThrowIns) {
break;
}
if (action.definition instanceof ReturnVoidIns) {
break;
}
}
} catch (EmptyStackException | TranslateException | InterruptedException ex) {
//ignore
}
}
class ExecutionResult {
public Map<Integer, Integer> assignCount = new HashMap<>();
public Map<Integer, GraphTargetItem> lastAssigned = new HashMap<>();
}
}

View File

@@ -0,0 +1,418 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.deobfuscation;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.FixItemCounterTranslateStack;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.DeobfuscatePopIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.ModuloIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.MultiplyIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.NotIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.SubtractIIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.SubtractIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.BitAndIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.BitOrIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.BitXorIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.LShiftIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.RShiftIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.URShiftIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.EqualsIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.GreaterEqualsIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.GreaterThanIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.LessEqualsIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.LessThanIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.StrictEqualsIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushByteIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushDoubleIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushFalseIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushIntIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushNullIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushShortIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushStringIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushTrueIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushUndefinedIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.SwapIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceOrConvertTypeIns;
import com.jpexs.decompiler.flash.abc.avm2.model.FloatValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.StringAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.UndefinedAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.action.ActionList;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.ecma.Null;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.flash.helpers.SWFDecompilerListener;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateException;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.FalseItem;
import com.jpexs.decompiler.graph.model.PopItem;
import com.jpexs.decompiler.graph.model.TrueItem;
import java.util.ArrayList;
import java.util.EmptyStackException;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class AVM2DeobfuscatorSimple implements SWFDecompilerListener {
private final int executionLimit = 30000;
@Override
public void actionListParsed(ActionList actions, SWF swf) {
}
protected AVM2Instruction makePush(Object ovalue, AVM2ConstantPool cpool) {
if (ovalue instanceof Long) {
long value = (Long) ovalue;
if (value >= -128 && value <= 127) {
return new AVM2Instruction(0, new PushByteIns(), new int[]{(int) (long) value});
} else if (value >= -32768 && value <= 32767) {
return new AVM2Instruction(0, new PushShortIns(), new int[]{((int) (long) value) & 0xffff});
} else {
return new AVM2Instruction(0, new PushIntIns(), new int[]{cpool.getIntId(value, true)});
}
}
if (ovalue instanceof Double) {
return new AVM2Instruction(0, new PushDoubleIns(), new int[]{cpool.getDoubleId((Double) ovalue, true)});
}
if (ovalue instanceof String) {
return new AVM2Instruction(0, new PushStringIns(), new int[]{cpool.getStringId((String) ovalue, true)});
}
if (ovalue instanceof Boolean) {
if ((Boolean) ovalue) {
return new AVM2Instruction(0, new PushTrueIns(), new int[]{});
}
return new AVM2Instruction(0, new PushFalseIns(), new int[]{});
}
if (ovalue instanceof Null) {
return new AVM2Instruction(0, new PushNullIns(), new int[]{});
}
if (ovalue instanceof Undefined) {
return new AVM2Instruction(0, new PushUndefinedIns(), new int[]{});
}
return null;
}
protected AVM2Instruction makePush(AVM2ConstantPool cpool, GraphTargetItem graphTargetItem) {
AVM2Instruction ins = null;
if (graphTargetItem instanceof IntegerValueAVM2Item) {
IntegerValueAVM2Item iv = (IntegerValueAVM2Item) graphTargetItem;
return makePush(iv.value, cpool);
} else if (graphTargetItem instanceof FloatValueAVM2Item) {
FloatValueAVM2Item fv = (FloatValueAVM2Item) graphTargetItem;
return makePush(fv.value, cpool);
} else if (graphTargetItem instanceof StringAVM2Item) {
StringAVM2Item fv = (StringAVM2Item) graphTargetItem;
return makePush(fv.value, cpool);
} else if (graphTargetItem instanceof TrueItem) {
return makePush(Boolean.TRUE, cpool);
} else if (graphTargetItem instanceof FalseItem) {
return makePush(Boolean.FALSE, cpool);
} else if (graphTargetItem instanceof NullAVM2Item) {
return makePush(new Null(), cpool);
} else if (graphTargetItem instanceof UndefinedAVM2Item) {
return makePush(new Undefined(), cpool);
} else {
return null;
}
}
private boolean removeObfuscationIfs(int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body) throws InterruptedException {
AVM2Code code = body.getCode();
if (code.code.size() == 0) {
return false;
}
for (int i = 0; i < code.code.size(); i++) {
ExecutionResult result = new ExecutionResult();
executeActions(classIndex, isStatic, body, scriptIndex, abc, code, i, code.code.size() - 1, result);
/*if (result.idx != -1) {
int newIstructionCount = 1; // jump
if (!result.stack.isEmpty()) {
newIstructionCount += result.stack.size();
}
if (newIstructionCount < result.instructionsProcessed) //if (result.isIf)
{
AVM2Instruction target = code.code.get(result.idx);
AVM2Instruction prevAction = code.code.get(i);
int idelta = 0;
if (result.stack.isEmpty() && prevAction.definition instanceof JumpIns) {
prevAction.operands[0] = ((int) (target.offset - prevAction.offset - prevAction.getBytes().length));
} else {
if (!result.stack.isEmpty()) {
for (GraphTargetItem graphTargetItem : result.stack) {
if (graphTargetItem instanceof PopItem) {
continue;
}
AVM2Instruction ins = makePush(graphTargetItem.getResult(), cpool);
if (ins != null) {
code.insertInstruction(i + (idelta++), ins, body);
//prevAction = ins;
} else {
throw new TranslateException("Cannot push: " + graphTargetItem);
}
}
}
AVM2Instruction jump = new AVM2Instruction(0, new JumpIns(), new int[]{0});
code.insertInstruction(i + (idelta++), jump, body);
jump.operands[0] = ((int) (target.offset - jump.offset - jump.getBytes().length));
}
removeUnreachableActions(code, cpool, trait, minfo, body);
removeZeroJumps(code, body);
i = -1;
}
}*/
}
return false;
}
protected void removeUnreachableActions(AVM2Code code, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body) throws InterruptedException {
code.removeDeadCode(cpool, trait, minfo, body);
}
protected boolean removeZeroJumps(AVM2Code actions, MethodBody body) {
boolean result = false;
for (int i = 0; i < actions.code.size(); i++) {
AVM2Instruction action = actions.code.get(i);
if (action.definition instanceof JumpIns && action.operands[0] == 0) {
actions.removeInstruction(i, body);
i--;
result = true;
}
}
return result;
}
protected AVM2LocalData newLocalData(int scriptIndex, ABC abc, AVM2ConstantPool cpool, MethodBody body, boolean isStatic, int classIndex) {
AVM2LocalData localData = new AVM2LocalData();
localData.isStatic = isStatic;
localData.classIndex = classIndex;
localData.localRegs = new HashMap<>();
localData.scopeStack = new ScopeStack(true);
localData.constants = cpool;
localData.methodInfo = abc.method_info;
localData.methodBody = body;
localData.abc = abc;
localData.localRegNames = new HashMap<>();
localData.fullyQualifiedNames = new ArrayList<>();
localData.parsedExceptions = new ArrayList<>();
localData.finallyJumps = new HashMap<>();
localData.ignoredSwitches = new HashMap<>();
localData.ignoredSwitches2 = new ArrayList<>();
localData.scriptIndex = scriptIndex;
localData.localRegAssignmentIps = new HashMap<>();
localData.ip = 0;
localData.refs = new HashMap<>();
localData.code = body.getCode();
return localData;
}
private void executeActions(int classIndex, boolean isStatic, MethodBody body, int scriptIndex, ABC abc, AVM2Code code, int idx, int endIdx, ExecutionResult result) {
List<GraphTargetItem> output = new ArrayList<>();
AVM2LocalData localData = newLocalData(scriptIndex, abc, abc.constants, body, isStatic, classIndex);
FixItemCounterTranslateStack stack = new FixItemCounterTranslateStack("");
int instructionsProcessed = 0;
try {
while (true) {
if (idx > endIdx) {
break;
}
if (instructionsProcessed > executionLimit) {
break;
}
AVM2Instruction action = code.code.get(idx);
action.translate(localData, stack, output, Graph.SOP_USE_STATIC, "");
InstructionDefinition def = action.definition;
Class allowedDefs[] = new Class[]{
PushByteIns.class,
PushShortIns.class,
PushIntIns.class,
PushDoubleIns.class,
PushStringIns.class,
PushNullIns.class,
PushUndefinedIns.class,
PushFalseIns.class,
PushTrueIns.class,
DupIns.class,
SwapIns.class,
AddIns.class,
AddIIns.class,
SubtractIns.class,
SubtractIIns.class,
ModuloIns.class,
MultiplyIns.class,
BitAndIns.class,
BitXorIns.class,
BitOrIns.class,
LShiftIns.class,
RShiftIns.class,
URShiftIns.class,
EqualsIns.class,
NotIns.class,
IfTypeIns.class,
JumpIns.class,
EqualsIns.class,
LessEqualsIns.class,
GreaterEqualsIns.class,
GreaterThanIns.class,
LessThanIns.class,
StrictEqualsIns.class,
PopIns.class
};
boolean ok = false;
for (Class<?> s : allowedDefs) {
if (s.isAssignableFrom(def.getClass())) {
ok = true;
break;
}
}
if (!ok) {
break;
}
boolean ifed = false;
if (def instanceof JumpIns) {
//ActionJump jump = (ActionJump) action;
long address = action.offset + action.getBytes().length + action.operands[0];
idx = code.adr2pos(address);
if (idx == -1) {
throw new TranslateException("Jump target not found: " + address);
}
} else if (def instanceof IfTypeIns) {
//ActionIf aif = (ActionIf) action;
GraphTargetItem top = stack.pop();
Object res = top.getResult();
long address = action.offset + action.getBytes().length + action.operands[0];
int nidx = code.adr2pos(address);//code.indexOf(code.getByAddress(address));
AVM2Instruction tarIns = code.code.get(nidx);
if (EcmaScript.toBoolean(res)) {
/*if (nidx == -1) {
throw new TranslateException("If target not found: " + address);
}*/
AVM2Instruction jumpIns = new AVM2Instruction(0, new JumpIns(), new int[]{0});
//jumpIns.operands[0] = action.operands[0] /*- action.getBytes().length*/ + jumpIns.getBytes().length;
code.replaceInstruction(idx, jumpIns, body);
jumpIns.operands[0] = (int) (tarIns.offset - jumpIns.offset - jumpIns.getBytes().length);
code.insertInstruction(idx, new AVM2Instruction(action.offset, new DeobfuscatePopIns(), new int[]{}), true, body);
idx = code.adr2pos(jumpIns.offset + jumpIns.getBytes().length + jumpIns.operands[0]);
} else {
code.replaceInstruction(idx, new AVM2Instruction(action.offset, new DeobfuscatePopIns(), new int[]{}), body);
//action.definition = new DeobfuscatePopIns();
idx++;
}
ifed = true;
//break;
} else {
idx++;
}
instructionsProcessed++;
if (stack.allItemsFixed()) {
result.idx = idx == code.code.size() ? idx - 1 : idx;
result.instructionsProcessed = instructionsProcessed;
result.stack.clear();
result.stack.addAll(stack);
}
if (ifed) {
break;
}
}
} catch (EmptyStackException | TranslateException | InterruptedException ex) {
//result.idx = -1;
//result.isIf = false;
//ignore
}
}
@Override
public byte[] proxyFileCatched(byte[] data) {
return null;
}
@Override
public void swfParsed(SWF swf) {
}
@Override
public void abcParsed(ABC abc, SWF swf) {
}
@Override
public void methodBodyParsed(MethodBody body, SWF swf) {
}
public void deobfuscate(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body) throws InterruptedException {
removeUnreachableActions(body.getCode(), cpool, trait, minfo, body);
removeObfuscationIfs(classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body);
removeZeroJumps(body.getCode(), body);
}
class ExecutionResult {
public int idx = -1;
public int instructionsProcessed = -1;
public TranslateStack stack = new TranslateStack("?");
}
}

View File

@@ -36,6 +36,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.HasNextAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.InAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NextNameAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NextValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
@@ -69,6 +70,8 @@ import com.jpexs.decompiler.graph.model.ExitItem;
import com.jpexs.decompiler.graph.model.IfItem;
import com.jpexs.decompiler.graph.model.LoopItem;
import com.jpexs.decompiler.graph.model.NotItem;
import com.jpexs.decompiler.graph.model.PopItem;
import com.jpexs.decompiler.graph.model.PushItem;
import com.jpexs.decompiler.graph.model.SwitchItem;
import com.jpexs.decompiler.graph.model.WhileItem;
import java.util.ArrayList;
@@ -76,6 +79,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
@@ -124,8 +128,9 @@ public class AVM2Graph extends Graph {
localData.localRegNames = localRegNames;
localData.fullyQualifiedNames = fullyQualifiedNames;
localData.parsedExceptions = new ArrayList<>();
localData.finallyJumps = new ArrayList<>();
localData.ignoredSwitches = new ArrayList<>();
localData.finallyJumps = new HashMap<>();
localData.ignoredSwitches = new HashMap<>();
localData.ignoredSwitches2 = new ArrayList<>();
localData.scriptIndex = scriptIndex;
localData.localRegAssignmentIps = new HashMap<>();
localData.ip = 0;
@@ -159,39 +164,21 @@ public class AVM2Graph extends Graph {
}
}
}
/*for(ABCException ex:body.exceptions){
for(GraphPart p:allBlocks){
boolean next_is_ex_start=false;
for(GraphPart n:p.nextParts){
if(n.start==code.adr2pos(ex.start)){
next_is_ex_start = true;
break;
}
}
if(next_is_ex_start){
for(GraphPart q:allBlocks){ //find target part
if(q.start==code.adr2pos(ex.target)){
p.nextParts.add(q);
break;
}
}
}
}
}*/
}
@Override
protected List<GraphTargetItem> check(GraphSource code, BaseLocalData localData, List<GraphPart> allParts, TranslateStack stack, GraphPart parent, GraphPart part, List<GraphPart> stopPart, List<Loop> loops, List<GraphTargetItem> output, Loop currentLoop, int staticOperation, String path) throws InterruptedException {
protected List<GraphTargetItem> check(Map<GraphPart, List<GraphTargetItem>> partCodes, Map<GraphPart, Integer> partCodePos, GraphSource code, BaseLocalData localData, List<GraphPart> allParts, TranslateStack stack, GraphPart parent, GraphPart part, List<GraphPart> stopPart, List<Loop> loops, List<GraphTargetItem> output, Loop currentLoop, int staticOperation, String path) throws InterruptedException {
List<GraphTargetItem> ret = null;
AVM2LocalData aLocalData = (AVM2LocalData) localData;
List<ABCException> parsedExceptions = aLocalData.parsedExceptions;
List<Integer> finallyJumps = aLocalData.finallyJumps;
List<Integer> ignoredSwitches = aLocalData.ignoredSwitches;
Map<Integer, List<Integer>> finallyJumps = aLocalData.finallyJumps;
Map<Integer, Integer> ignoredSwitches = aLocalData.ignoredSwitches;
List<Integer> ignoredSwitches2 = aLocalData.ignoredSwitches2;
int ip = part.start;
int addr = this.avm2code.fixAddrAfterDebugLine(this.avm2code.pos2adr(part.start));
int maxend = -1;
List<Integer> catchedFinallys = new ArrayList<>();
List<ABCException> catchedExceptions = new ArrayList<>();
for (int e = 0; e < body.exceptions.length; e++) {
if (addr == this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].start)) {
@@ -200,11 +187,13 @@ public class AVM2Graph extends Graph {
if (!parsedExceptions.contains(body.exceptions[e])) {
if (((body.exceptions[e].end) > maxend)) {
catchedExceptions.clear();
catchedFinallys.clear();
maxend = this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end);
catchedExceptions.add(body.exceptions[e]);
} else if (this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) {
catchedExceptions.add(body.exceptions[e]);
}
catchedFinallys.add(e);
}
} else if (body.exceptions[e].isFinally()) {
@@ -233,14 +222,16 @@ public class AVM2Graph extends Graph {
List<GraphTargetItem> finallyCommands = new ArrayList<>();
boolean hasFinally = false;
int returnPos = afterCatchPos;
int finStart = -1;
for (int e = 0; e < body.exceptions.length; e++) {
if (body.exceptions[e].isFinally()) {
if (addr == this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].start)) {
if (afterCatchPos + 1 == code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end))) {
catchedFinallys.add(e);
AVM2Instruction jmpIns = this.avm2code.code.get(code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end)));
if (jmpIns.definition instanceof JumpIns) {
int finStart = code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]);
finStart = code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]);
GraphPart fpart = null;
for (GraphPart p : allParts) {
@@ -249,6 +240,8 @@ public class AVM2Graph extends Graph {
break;
}
}
TranslateStack st = (TranslateStack) stack.clone();
st.clear();
int swPos = -1;
for (int f = finStart; f < this.avm2code.code.size(); f++) {
if (this.avm2code.code.get(f).definition instanceof LookupSwitchIns) {
@@ -256,7 +249,7 @@ public class AVM2Graph extends Graph {
if (swins.operands.length >= 3) {
if (swins.operands[0] == swins.getBytes().length) {
if (code.adr2pos(code.pos2adr(f) + swins.operands[2]) < finStart) {
stack.push(new ExceptionAVM2Item(body.exceptions[e]));
//st.push(new ExceptionAVM2Item(body.exceptions[e]));
GraphPart fepart = null;
for (GraphPart p : allParts) {
if (p.start == f + 1) {
@@ -280,13 +273,17 @@ public class AVM2Graph extends Graph {
}
//ignoredSwitches.add(-1);
//int igs_size=ignoredSwitches.size();
List<Integer> oldFinallyJumps = new ArrayList<>(finallyJumps);
Map<Integer, List<Integer>> oldFinallyJumps = new HashMap<>(finallyJumps);
finallyJumps.clear();
ignoredSwitches.add(swPos);
finallyCommands = printGraph(localData, stack, allParts, parent, fpart, null, loops, staticOperation, path);
ignoredSwitches.put(e, swPos);
st.push(new PopItem(null));
finallyCommands = printGraph(partCodes, partCodePos, localData, st, allParts, parent, fpart, null, loops, staticOperation, path);
//ignoredSwitches.remove(igs_size-1);
finallyJumps.addAll(oldFinallyJumps);
finallyJumps.add(finStart);
finallyJumps.putAll(oldFinallyJumps);
if (!finallyJumps.containsKey(e)) {
finallyJumps.put(e, new ArrayList<>());
}
finallyJumps.get(e).add(finStart);
hasFinally = true;
break;
}
@@ -328,7 +325,9 @@ public class AVM2Graph extends Graph {
break;
}
}
stack.add(new ExceptionAVM2Item(catchedExceptions.get(e)));
TranslateStack st2 = (TranslateStack) stack.clone();
st2.clear();
st2.add(new ExceptionAVM2Item(catchedExceptions.get(e)));
AVM2LocalData localData2 = new AVM2LocalData(aLocalData);
localData2.scopeStack = new ScopeStack();
List<GraphPart> stopPart2 = new ArrayList<>(stopPart);
@@ -336,16 +335,18 @@ public class AVM2Graph extends Graph {
if (retPart != null) {
stopPart2.add(retPart);
}
List<GraphTargetItem> ncatchedCommands = printGraph(localData2, stack, allParts, parent, npart, stopPart2, loops, staticOperation, path);
List<GraphTargetItem> ncatchedCommands = printGraph(partCodes, partCodePos, localData2, st2, allParts, parent, npart, stopPart2, loops, staticOperation, path);
if (catchedExceptions.get(e).isFinally() && (catchedExceptions.size() > 1 || hasFinally)) {
catchedExceptions.remove(e);
e--;
} else {
catchedCommands.add(ncatchedCommands);
if (retPart != null && avm2code.code.get(retPart.start).isExit() && !(!ncatchedCommands.isEmpty() && (ncatchedCommands.get(ncatchedCommands.size() - 1) instanceof ExitItem))) {
avm2code.code.get(retPart.start).translate(localData, stack, ncatchedCommands, staticOperation, path);
avm2code.code.get(retPart.start).translate(localData, st2, ncatchedCommands, staticOperation, path);
}
if (catchedExceptions.get(e).isFinally()) {
//endposStartBlock = -1;
if (!ncatchedCommands.isEmpty() && (ncatchedCommands.get(0) instanceof SetLocalAVM2Item)) {
SetLocalAVM2Item sl = (SetLocalAVM2Item) ncatchedCommands.get(0);
if (sl.value.getNotCoerced() instanceof ExceptionAVM2Item) {
@@ -364,19 +365,31 @@ public class AVM2Graph extends Graph {
break;
}
}
List<GraphPart> stopPart2 = new ArrayList<>(stopPart);
stopPart2.add(nepart);
List<GraphPart> stopPart2 = new ArrayList<>();//stopPart);
if (nepart != null) {
stopPart2.add(nepart);
}
stopPart2.addAll(catchParts);
if (retPart != null) {
stopPart2.add(retPart);
}
List<GraphTargetItem> tryCommands = printGraph(localData, stack, allParts, parent, part, stopPart2, loops, staticOperation, path);
TranslateStack st = (TranslateStack) stack.clone();
st.clear();
List<GraphTargetItem> tryCommands = printGraph(partCodes, partCodePos, localData, st, allParts, parent, part, stopPart2, loops, staticOperation, path);
if (retPart != null && avm2code.code.get(retPart.start).isExit() && !(!tryCommands.isEmpty() && (tryCommands.get(tryCommands.size() - 1) instanceof ExitItem))) {
avm2code.code.get(retPart.start).translate(localData, stack, tryCommands, staticOperation, path);
avm2code.code.get(retPart.start).translate(localData, st, tryCommands, staticOperation, path);
}
output.clear();
stack.clear();
output.add(new TryAVM2Item(tryCommands, catchedExceptions, catchedCommands, finallyCommands, finCatchName));
finallyJumps = ((AVM2LocalData) localData).finallyJumps;
for (int fin_e : catchedFinallys) {
if (finallyJumps.containsKey(fin_e)) {
finallyJumps.get(fin_e).clear();
}
//.remove((Integer) finStart);
}
ip = returnPos;
}
@@ -397,7 +410,10 @@ public class AVM2Graph extends Graph {
ret.addAll(output);
GraphTargetItem lop = checkLoop(part, stopPart, loops);
if (lop == null) {
ret.addAll(printGraph(localData, stack, allParts, null, part, stopPart, loops, staticOperation, path));
TranslateStack st = (TranslateStack) stack.clone();
st.clear();
ret.addAll(printGraph(partCodes, partCodePos, localData, st, allParts, null, part, stopPart, loops, staticOperation, path));
} else {
ret.add(lop);
}
@@ -423,7 +439,7 @@ public class AVM2Graph extends Graph {
}
}
}
if ((this.avm2code.code.get(part.end).definition instanceof LookupSwitchIns) && ignoredSwitches.contains(part.end)) {
if ((this.avm2code.code.get(part.end).definition instanceof LookupSwitchIns) && (ignoredSwitches.containsValue(part.end) || ignoredSwitches2.contains(part.end))) {
ret = new ArrayList<>();
ret.addAll(output);
return ret;
@@ -444,9 +460,9 @@ public class AVM2Graph extends Graph {
&& (this.avm2code.code.get(part.nextParts.get(1).nextParts.get(0).end).definition instanceof LookupSwitchIns))) {
if (stack.peek() instanceof StrictEqAVM2Item) {
ignoredSwitches.add(part.nextParts.get(0).nextParts.get(0).end);
ignoredSwitches2.add(part.nextParts.get(0).nextParts.get(0).end);
} else {
ignoredSwitches.add(part.nextParts.get(1).nextParts.get(0).end);
ignoredSwitches2.add(part.nextParts.get(1).nextParts.get(0).end);
}
ret = new ArrayList<>();
ret.addAll(output);
@@ -494,7 +510,7 @@ public class AVM2Graph extends Graph {
}
GraphPart numPart = part.nextParts.get(reversed ? 0 : 1);
AVM2Instruction ins = null;
TranslateStack sstack = new TranslateStack();
TranslateStack sstack = new TranslateStack(path);
do {
for (int n = 0; n < numPart.getHeight(); n++) {
ins = this.avm2code.code.get(numPart.getPosAt(n));
@@ -512,7 +528,7 @@ public class AVM2Graph extends Graph {
GraphTargetItem nt = sstack.peek();
if (!(nt instanceof IntegerValueAVM2Item)) {
throw new RuntimeException("Invalid integer value in Switch");
throw new RuntimeException("Invalid integer value in Switch:" + nt);
}
IntegerValueAVM2Item iv = (IntegerValueAVM2Item) nt;
caseValuesMap.put((int) (long) iv.value, tar);
@@ -535,7 +551,7 @@ public class AVM2Graph extends Graph {
GraphPart numPart = dp;
AVM2Instruction ins = null;
TranslateStack sstack = new TranslateStack();
TranslateStack sstack = new TranslateStack(path);
do {
for (int n = 0; n < numPart.getHeight(); n++) {
ins = this.avm2code.code.get(numPart.getPosAt(n));
@@ -587,7 +603,7 @@ public class AVM2Graph extends Graph {
defaultPart = switchLoc.nextParts.get(switchLoc.nextParts.size() - 1);
List<GraphPart> stopPart2 = new ArrayList<>(stopPart);
stopPart2.add(next);
defaultCommands = printGraph(localData, stack, allParts, switchLoc, defaultPart, stopPart2, loops, staticOperation, path);
defaultCommands = printGraph(partCodes, partCodePos, localData, stack, allParts, switchLoc, defaultPart, stopPart2, loops, staticOperation, path);
if (!defaultCommands.isEmpty()) {
if (defaultCommands.get(defaultCommands.size() - 1) instanceof BreakItem) {
if (((BreakItem) defaultCommands.get(defaultCommands.size() - 1)).loopId == currentLoop.id) {
@@ -614,7 +630,7 @@ public class AVM2Graph extends Graph {
stopPart2.add(defaultPart);
}
cc.addAll(0, printGraph(localData, stack, allParts, switchLoc, caseBodies.get(i), stopPart2, loops, staticOperation, path));
cc.addAll(0, printGraph(partCodes, partCodePos, localData, stack, allParts, switchLoc, caseBodies.get(i), stopPart2, loops, staticOperation, path));
caseCommands.add(cc);
}
@@ -626,7 +642,7 @@ public class AVM2Graph extends Graph {
ret.add(ti);
} else {*/
currentLoop.phase = 2;
ret.addAll(printGraph(localData, stack, allParts, null, next, stopPart, loops, staticOperation, path));
ret.addAll(printGraph(partCodes, partCodePos, localData, stack, allParts, null, next, stopPart, loops, staticOperation, path));
//}
}
}
@@ -636,33 +652,34 @@ public class AVM2Graph extends Graph {
@Override
protected GraphPart checkPart(TranslateStack stack, BaseLocalData localData, GraphPart next, List<GraphPart> allParts) {
AVM2LocalData aLocalData = (AVM2LocalData) localData;
List<Integer> finallyJumps = aLocalData.finallyJumps;
List<Integer> ignoredSwitches = aLocalData.ignoredSwitches;
Map<Integer, List<Integer>> finallyJumps = aLocalData.finallyJumps;
Map<Integer, Integer> ignoredSwitches = aLocalData.ignoredSwitches;
GraphPart ret = next;
for (int f = 0; f < finallyJumps.size(); f++) {
int fip = finallyJumps.get(f);
for (int f : finallyJumps.keySet()) {//int f = 0; f < finallyJumps.size(); f++) {
int swip = ignoredSwitches.get(f);
if (next.start == fip) {
if (stack != null && swip != -1) {
AVM2Instruction swIns = avm2code.code.get(swip);
GraphTargetItem t = stack.pop();
Double dval = EcmaScript.toNumber(t.getResult());
int val = (int) (double) dval;
if (swIns.definition instanceof LookupSwitchIns) {
List<Integer> branches = swIns.getBranches(code);
int nip = branches.get(0);
if (val >= 0 && val < branches.size() - 1) {
nip = branches.get(1 + val);
}
for (GraphPart p : allParts) {
if (avm2code.fixIPAfterDebugLine(p.start) == avm2code.fixIPAfterDebugLine(nip)) {
return p;
for (int fip : finallyJumps.get(f)) {
if (next.start == fip) {
if (stack != null && swip != -1) {
AVM2Instruction swIns = avm2code.code.get(swip);
GraphTargetItem t = stack.pop();
Double dval = EcmaScript.toNumber(t.getResult());
int val = (int) (double) dval;
if (swIns.definition instanceof LookupSwitchIns) {
List<Integer> branches = swIns.getBranches(code);
int nip = branches.get(0);
if (val >= 0 && val < branches.size() - 1) {
nip = branches.get(1 + val);
}
for (GraphPart p : allParts) {
if (avm2code.fixIPAfterDebugLine(p.start) == avm2code.fixIPAfterDebugLine(nip)) {
return p;
}
}
ret = null;
}
ret = null;
}
ret = null;
}
ret = null;
}
}
if (ret != next) {
@@ -678,8 +695,14 @@ public class AVM2Graph extends Graph {
AVM2Instruction jmpIns = this.avm2code.code.get(avm2code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end)));
if (jmpIns.definition instanceof JumpIns) {
int finStart = avm2code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]);
finallyJumps.add(finStart);
ignoredSwitches.add(-1);
if (!finallyJumps.containsKey(e)) {
finallyJumps.put(e, new ArrayList<>());
}
finallyJumps.get(e).add(finStart);
if (!ignoredSwitches.containsKey(e)) {
ignoredSwitches.put(e, -1);
}
//ignoredSwitches.put(e, -1);
break;
}
}
@@ -707,7 +730,11 @@ public class AVM2Graph extends Graph {
}
GraphTargetItem ft = w.commands.get(pos);
if (ft instanceof WithAVM2Item) {
ft = w.commands.get(pos + 1);
pos++;
while (w.commands.get(pos) instanceof SetTypeAVM2Item) {
pos++;
}
ft = w.commands.get(pos);
if (ft instanceof IfItem) {
IfItem ift = (IfItem) ft;
if (ift.onTrue.size() > 0) {
@@ -759,7 +786,7 @@ public class AVM2Graph extends Graph {
@Override
protected void finalProcess(List<GraphTargetItem> list, int level, FinalProcessLocalData localData) {
super.finalProcess(list, level, localData);
if (level == 0) {
if (!list.isEmpty()) {
if (list.get(list.size() - 1) instanceof ReturnVoidAVM2Item) {
@@ -864,6 +891,8 @@ public class AVM2Graph extends Graph {
}
}
}
//Handle for loops at the end:
super.finalProcess(list, level, localData);
}
@Override

View File

@@ -0,0 +1,27 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
/**
*
* @author JPEXS
*/
public interface AlchemyTypeIns {
public static final String ALCHEMY_PACKAGE = "avm2.intrinsics.memory";
}

View File

@@ -1,58 +1,58 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Lf32Ins extends InstructionDefinition {
public Lf32Ins() {
super(0x38, "lf32", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName));
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Lf32Ins extends InstructionDefinition implements AlchemyTypeIns {
public Lf32Ins() {
super(0x38, "lf32", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
stack.push(new AlchemyLoadAVM2Item(ins, ofs, 'f', 32));
}
}

View File

@@ -1,58 +1,58 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Lf64Ins extends InstructionDefinition {
public Lf64Ins() {
super(0x39, "lf64", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName));
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Lf64Ins extends InstructionDefinition implements AlchemyTypeIns {
public Lf64Ins() {
super(0x39, "lf64", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
stack.push(new AlchemyLoadAVM2Item(ins, ofs, 'f', 64));
}
}

View File

@@ -1,58 +1,58 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Li16Ins extends InstructionDefinition {
public Li16Ins() {
super(0x36, "li16", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName));
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Li16Ins extends InstructionDefinition implements AlchemyTypeIns {
public Li16Ins() {
super(0x36, "li16", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
stack.push(new AlchemyLoadAVM2Item(ins, ofs, 'i', 16));
}
}

View File

@@ -1,58 +1,58 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Li32Ins extends InstructionDefinition {
public Li32Ins() {
super(0x37, "li32", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName));
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Li32Ins extends InstructionDefinition implements AlchemyTypeIns {
public Li32Ins() {
super(0x37, "li32", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
stack.push(new AlchemyLoadAVM2Item(ins, ofs, 'i', 32));
}
}

View File

@@ -1,58 +1,58 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Li8Ins extends InstructionDefinition {
public Li8Ins() {
super(0x35, "li8", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName));
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Li8Ins extends InstructionDefinition implements AlchemyTypeIns {
public Li8Ins() {
super(0x35, "li8", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
stack.push(new AlchemyLoadAVM2Item(ins, ofs, 'i', 8));
}
}

View File

@@ -1,59 +1,59 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Sf32Ins extends InstructionDefinition {
public Sf32Ins() {
super(0x3D, "sf32", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
GraphTargetItem value = stack.pop();
stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName));
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Sf32Ins extends InstructionDefinition implements AlchemyTypeIns {
public Sf32Ins() {
super(0x3D, "sf32", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
GraphTargetItem value = stack.pop();
output.add(new AlchemyStoreAVM2Item(ins, value, ofs, 'f', 32));
}
}

View File

@@ -1,59 +1,59 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Sf64Ins extends InstructionDefinition {
public Sf64Ins() {
super(0x3E, "sf64", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
GraphTargetItem value = stack.pop();
stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName));
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Sf64Ins extends InstructionDefinition implements AlchemyTypeIns {
public Sf64Ins() {
super(0x3E, "sf64", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
GraphTargetItem value = stack.pop();
output.add(new AlchemyStoreAVM2Item(ins, value, ofs, 'f', 64));
}
}

View File

@@ -1,59 +1,59 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Si16Ins extends InstructionDefinition {
public Si16Ins() {
super(0x3B, "si16", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
GraphTargetItem value = stack.pop();
stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName));
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Si16Ins extends InstructionDefinition implements AlchemyTypeIns {
public Si16Ins() {
super(0x3B, "si16", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
GraphTargetItem value = stack.pop();
output.add(new AlchemyStoreAVM2Item(ins, value, ofs, 'i', 16));
}
}

View File

@@ -1,59 +1,59 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Si32Ins extends InstructionDefinition {
public Si32Ins() {
super(0x3C, "si32", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
GraphTargetItem value = stack.pop();
stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName));
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Si32Ins extends InstructionDefinition implements AlchemyTypeIns {
public Si32Ins() {
super(0x3C, "si32", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
GraphTargetItem value = stack.pop();
output.add(new AlchemyStoreAVM2Item(ins, value, ofs, 'i', 32));
}
}

View File

@@ -1,59 +1,59 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Si8Ins extends InstructionDefinition {
public Si8Ins() {
super(0x3A, "si8", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
GraphTargetItem value = stack.pop();
stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName));
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Si8Ins extends InstructionDefinition implements AlchemyTypeIns {
public Si8Ins() {
super(0x3A, "si8", new int[]{}, true);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -2;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem ofs = stack.pop();
GraphTargetItem value = stack.pop();
output.add(new AlchemyStoreAVM2Item(ins, value, ofs, 'i', 8));
}
}

View File

@@ -1,58 +1,58 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemySignExtendAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Sxi16Ins extends InstructionDefinition {
public Sxi16Ins() {
super(0x52, "sxi_16", new int[]{}, false);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem value = stack.pop();
stack.push(new AlchemySignExtendAVM2Item(ins, value, instructionName));
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemySignExtendAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Sxi16Ins extends InstructionDefinition implements AlchemyTypeIns {
public Sxi16Ins() {
super(0x52, "sxi16", new int[]{}, false);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem value = stack.pop();
stack.push(new AlchemySignExtendAVM2Item(ins, value, 16));
}
}

View File

@@ -1,58 +1,58 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemySignExtendAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Sxi1Ins extends InstructionDefinition {
public Sxi1Ins() {
super(0x50, "sxi_1", new int[]{}, false);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem value = stack.pop();
stack.push(new AlchemySignExtendAVM2Item(ins, value, instructionName));
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemySignExtendAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Sxi1Ins extends InstructionDefinition implements AlchemyTypeIns {
public Sxi1Ins() {
super(0x50, "sxi1", new int[]{}, false);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem value = stack.pop();
stack.push(new AlchemySignExtendAVM2Item(ins, value, 1));
}
}

View File

@@ -1,58 +1,58 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemySignExtendAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Sxi8Ins extends InstructionDefinition {
public Sxi8Ins() {
super(0x51, "sxi_8", new int[]{}, false);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem value = stack.pop();
stack.push(new AlchemySignExtendAVM2Item(ins, value, instructionName));
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.AlchemySignExtendAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
/**
*
* @author JPEXS
*/
public class Sxi8Ins extends InstructionDefinition implements AlchemyTypeIns {
public Sxi8Ins() {
super(0x51, "sxi8", new int[]{}, false);
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1 - 1;
}
@Override
public int getScopeStackDelta(AVM2Instruction ins, ABC abc) {
return 0;
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem value = stack.pop();
stack.push(new AlchemySignExtendAVM2Item(ins, value, 8));
}
}

View File

@@ -1,49 +1,49 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.NotItem;
import java.util.HashMap;
import java.util.List;
public class NotIns extends InstructionDefinition {
public NotIns() {
super(0x96, "not", new int[]{}, false);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem v = stack.pop();
stack.push(new NotItem(ins, v));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1 + 1;
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.NotItem;
import java.util.HashMap;
import java.util.List;
public class NotIns extends InstructionDefinition {
public NotIns() {
super(0x96, "not", new int[]{}, false);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem v = stack.pop();
stack.push(v.invert(ins));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1 + 1;
}
}

View File

@@ -1,56 +1,57 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.NotItem;
import java.util.HashMap;
import java.util.List;
public class IfFalseIns extends InstructionDefinition implements IfTypeIns {
public IfFalseIns() {
super(0x12, "iffalse", new int[]{AVM2Code.DAT_OFFSET}, false);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem v1 = stack.pop();
stack.push(new NotItem(ins, v1));
}
@Override
public void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins) {
//String v1 = stack.pop().toString();
//stack.push("(" + v1 + ")");
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1;
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.NotItem;
import java.util.HashMap;
import java.util.List;
public class IfFalseIns extends InstructionDefinition implements IfTypeIns {
public IfFalseIns() {
super(0x12, "iffalse", new int[]{AVM2Code.DAT_OFFSET}, false);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
GraphTargetItem v1 = stack.pop();
//stack.push(new NotItem(ins, v1));
stack.push(v1.invert(ins));
}
@Override
public void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins) {
//String v1 = stack.pop().toString();
//stack.push("(" + v1 + ")");
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1;
}
}

View File

@@ -1,56 +1,56 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.NotItem;
import java.util.HashMap;
import java.util.List;
public class IfTrueIns extends InstructionDefinition implements IfTypeIns {
public IfTrueIns() {
super(0x11, "iftrue", new int[]{AVM2Code.DAT_OFFSET}, false);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
//String v1 = stack.pop().toString();
//stack.push("(" + v1 + ")");
}
@Override
public void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins) {
GraphTargetItem v1 = stack.pop();
stack.push(new NotItem(ins, v1));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1;
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.NotItem;
import java.util.HashMap;
import java.util.List;
public class IfTrueIns extends InstructionDefinition implements IfTypeIns {
public IfTrueIns() {
super(0x11, "iftrue", new int[]{AVM2Code.DAT_OFFSET}, false);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
//String v1 = stack.pop().toString();
//stack.push("(" + v1 + ")");
}
@Override
public void translateInverted(HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, AVM2Instruction ins) {
GraphTargetItem v1 = stack.pop();
stack.push(v1.invert(null));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1;
}
}

View File

@@ -1,134 +1,138 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.SetTypeIns;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.DecrementAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.PostDecrementAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.PostIncrementAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreDecrementAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreIncrementAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public abstract class SetLocalTypeIns extends InstructionDefinition implements SetTypeIns {
public SetLocalTypeIns(int instructionCode, String instructionName, int[] operands, boolean canThrow) {
super(instructionCode, instructionName, operands, canThrow);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> regAssignCount, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
int regId = getRegisterId(ins);
GraphTargetItem value = stack.pop();
/*if (localRegs.containsKey(regId)) {
localRegs.put(regId, new NotCompileTimeAVM2Item(ins, value));
} else {
localRegs.put(regId, value);
}*/
localRegs.put(regId, value);
if (!regAssignCount.containsKey(regId)) {
regAssignCount.put(regId, 0);
}
regAssignCount.put(regId, regAssignCount.get(regId) + 1);
//localRegsAssignmentIps.put(regId, ip);
if (value instanceof NewActivationAVM2Item) {
return;
}
if (value instanceof FindPropertyAVM2Item) {
return;
}
if (value.getNotCoerced() instanceof IncrementAVM2Item) {
GraphTargetItem inside = ((IncrementAVM2Item) value.getNotCoerced()).value.getNotCoerced().getThroughDuplicate();
if (inside instanceof LocalRegAVM2Item) {
if (((LocalRegAVM2Item) inside).regIndex == regId) {
if (stack.size() > 0) {
GraphTargetItem top = stack.peek().getNotCoerced().getThroughDuplicate();
if (top == inside) {
stack.pop();
stack.push(new PostIncrementAVM2Item(ins, inside));
} else if ((top instanceof IncrementAVM2Item) && (((IncrementAVM2Item) top).value == inside)) {
stack.pop();
stack.push(new PreIncrementAVM2Item(ins, inside));
} else {
output.add(new PostIncrementAVM2Item(ins, inside));
}
} else {
output.add(new PostIncrementAVM2Item(ins, inside));
}
return;
}
}
}
if (value.getNotCoerced() instanceof DecrementAVM2Item) {
GraphTargetItem inside = ((DecrementAVM2Item) value.getNotCoerced()).value.getNotCoerced().getThroughDuplicate();
if (inside instanceof LocalRegAVM2Item) {
if (((LocalRegAVM2Item) inside).regIndex == regId) {
if (stack.size() > 0) {
GraphTargetItem top = stack.peek().getNotCoerced().getThroughDuplicate();
if (top == inside) {
stack.pop();
stack.push(new PostDecrementAVM2Item(ins, inside));
} else if ((top instanceof DecrementAVM2Item) && (((DecrementAVM2Item) top).value == inside)) {
stack.pop();
stack.push(new PreDecrementAVM2Item(ins, inside));
} else {
output.add(new PostDecrementAVM2Item(ins, inside));
}
} else {
output.add(new PostDecrementAVM2Item(ins, inside));
}
return;
}
}
}
//if(val.startsWith("catchscope ")) return;
//if(val.startsWith("newactivation()")) return;
output.add(new SetLocalAVM2Item(ins, regId, value));
}
@Override
public String getObject(Stack<AVM2Item> stack, ABC abc, AVM2Instruction ins, List<AVM2Item> output, MethodBody body, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return AVM2Item.localRegName(localRegNames, getRegisterId(ins));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1;
}
public abstract int getRegisterId(AVM2Instruction ins);
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.SetTypeIns;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.DecrementAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.PostDecrementAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.PostIncrementAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreDecrementAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreIncrementAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.NotCompileTimeItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.PopItem;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public abstract class SetLocalTypeIns extends InstructionDefinition implements SetTypeIns {
public SetLocalTypeIns(int instructionCode, String instructionName, int[] operands, boolean canThrow) {
super(instructionCode, instructionName, operands, canThrow);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> regAssignCount, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
int regId = getRegisterId(ins);
GraphTargetItem value = stack.pop();
/*if (localRegs.containsKey(regId)) {
localRegs.put(regId, new NotCompileTimeAVM2Item(ins, value));
} else {
localRegs.put(regId, value);
}*/
if (!(value instanceof PopItem)) {
localRegs.put(regId, value);
}
if (!regAssignCount.containsKey(regId)) {
regAssignCount.put(regId, 0);
}
regAssignCount.put(regId, regAssignCount.get(regId) + 1);
//localRegsAssignmentIps.put(regId, ip);
if (value.getThroughDuplicate() instanceof NewActivationAVM2Item) {
return;
}
if (value instanceof FindPropertyAVM2Item) {
return;
}
if (value.getNotCoerced() instanceof IncrementAVM2Item) {
GraphTargetItem inside = ((IncrementAVM2Item) value.getNotCoerced()).value.getNotCoerced().getThroughDuplicate();
if (inside instanceof LocalRegAVM2Item) {
if (((LocalRegAVM2Item) inside).regIndex == regId) {
if (stack.size() > 0) {
GraphTargetItem top = stack.peek().getNotCoerced().getThroughDuplicate();
if (top == inside) {
stack.pop();
stack.push(new PostIncrementAVM2Item(ins, inside));
} else if ((top instanceof IncrementAVM2Item) && (((IncrementAVM2Item) top).value == inside)) {
stack.pop();
stack.push(new PreIncrementAVM2Item(ins, inside));
} else {
output.add(new PostIncrementAVM2Item(ins, inside));
}
} else {
output.add(new PostIncrementAVM2Item(ins, inside));
}
return;
}
}
}
if (value.getNotCoerced() instanceof DecrementAVM2Item) {
GraphTargetItem inside = ((DecrementAVM2Item) value.getNotCoerced()).value.getNotCoerced().getThroughDuplicate();
if (inside instanceof LocalRegAVM2Item) {
if (((LocalRegAVM2Item) inside).regIndex == regId) {
if (stack.size() > 0) {
GraphTargetItem top = stack.peek().getNotCoerced().getThroughDuplicate();
if (top == inside) {
stack.pop();
stack.push(new PostDecrementAVM2Item(ins, inside));
} else if ((top instanceof DecrementAVM2Item) && (((DecrementAVM2Item) top).value == inside)) {
stack.pop();
stack.push(new PreDecrementAVM2Item(ins, inside));
} else {
output.add(new PostDecrementAVM2Item(ins, inside));
}
} else {
output.add(new PostDecrementAVM2Item(ins, inside));
}
return;
}
}
}
//if(val.startsWith("catchscope ")) return;
//if(val.startsWith("newactivation()")) return;
output.add(new SetLocalAVM2Item(ins, regId, value));
}
@Override
public String getObject(Stack<AVM2Item> stack, ABC abc, AVM2Instruction ins, List<AVM2Item> output, MethodBody body, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return AVM2Item.localRegName(localRegNames, getRegisterId(ins));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return -1;
}
public abstract int getRegisterId(AVM2Instruction ins);
}

View File

@@ -156,9 +156,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns {
}
}
}
if (slotname == null) {
System.err.println("SLOT NOT FOUND");
}
output.add(new SetSlotAVM2Item(ins, obj, slotname, value));
}

View File

@@ -45,13 +45,9 @@ public class PopIns extends InstructionDefinition {
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
if (stack.size() > 0) {
GraphTargetItem top = stack.pop();
//Note: Commands like "5;" - numbers are unsupported as it collide with try..finally block decompilation. TODO: allow this somehow
if (/*!(top instanceof IntegerValueAVM2Item) &&*/(!(top instanceof MarkItem))) {
output.add(top);
}
GraphTargetItem top = stack.pop();
if ((!(top instanceof MarkItem))) {
output.add(top);
}
}

View File

@@ -1,54 +1,55 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.stack;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class PushFalseIns extends InstructionDefinition {
public PushFalseIns() {
super(0x27, "pushfalse", new int[]{}, false);
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
lda.operandStack.push(Boolean.FALSE);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
stack.push(new BooleanAVM2Item(ins, Boolean.FALSE));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1;
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.stack;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.FalseItem;
import java.util.HashMap;
import java.util.List;
public class PushFalseIns extends InstructionDefinition {
public PushFalseIns() {
super(0x27, "pushfalse", new int[]{}, false);
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
lda.operandStack.push(Boolean.FALSE);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
stack.push(new FalseItem(ins));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1;
}
}

View File

@@ -1,54 +1,55 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.stack;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
import java.util.List;
public class PushTrueIns extends InstructionDefinition {
public PushTrueIns() {
super(0x26, "pushtrue", new int[]{}, false);
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
lda.operandStack.push(Boolean.TRUE);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
stack.push(new BooleanAVM2Item(ins, Boolean.TRUE));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1;
}
}
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions.stack;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.TrueItem;
import java.util.HashMap;
import java.util.List;
public class PushTrueIns extends InstructionDefinition {
public PushTrueIns() {
super(0x26, "pushtrue", new int[]{}, false);
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
lda.operandStack.push(Boolean.TRUE);
}
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap<Integer, GraphTargetItem> localRegs, TranslateStack stack, ScopeStack scopeStack, AVM2ConstantPool constants, AVM2Instruction ins, List<MethodInfo> method_info, List<GraphTargetItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
stack.push(new TrueItem(ins));
}
@Override
public int getStackDelta(AVM2Instruction ins, ABC abc) {
return 1;
}
}

View File

@@ -16,11 +16,21 @@
*/
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Lf32Ins;
import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Lf64Ins;
import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Li16Ins;
import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Li32Ins;
import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Li8Ins;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
/**
*
@@ -28,25 +38,57 @@ import com.jpexs.decompiler.graph.model.LocalData;
*/
public class AlchemyLoadAVM2Item extends AVM2Item {
private final String name;
private final char type;
private final int size;
private final GraphTargetItem ofs;
public AlchemyLoadAVM2Item(GraphSourceItem instruction, GraphTargetItem ofs, String name) {
public AlchemyLoadAVM2Item(GraphSourceItem instruction, GraphTargetItem ofs, char type, int size) {
super(instruction, PRECEDENCE_PRIMARY);
this.name = name;
this.ofs = ofs;
this.type = type;
this.size = size;
}
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.append("op_" + name + "(");
writer.append("l" + type + size + "(");
ofs.toString(writer, localData);
return writer.append(") /*Alchemy*/");
return writer.append(")");
}
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
String ts = "" + type + size;
InstructionDefinition def = null;
switch (ts) {
case "i8":
def = new Li8Ins();
break;
case "i16":
def = new Li16Ins();
break;
case "i32":
def = new Li32Ins();
break;
case "f":
def = new Lf32Ins();
break;
case "f32":
def = new Lf64Ins();
break;
}
return toSourceMerge(localData, generator, ofs, ins(def));
}
@Override
public GraphTargetItem returnType() {
switch (type) {
case 'i':
return new TypeItem("int");
case 'f':
return new TypeItem("Number");
}
return TypeItem.UNBOUNDED;
}

View File

@@ -12,14 +12,23 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Sxi16Ins;
import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Sxi1Ins;
import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Sxi8Ins;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
/**
*
@@ -27,28 +36,45 @@ import com.jpexs.decompiler.graph.model.LocalData;
*/
public class AlchemySignExtendAVM2Item extends AVM2Item {
private final int size;
public AlchemySignExtendAVM2Item(GraphSourceItem instruction, GraphTargetItem value, int size) {
super(instruction, PRECEDENCE_PRIMARY);
super(instruction, PRECEDENCE_PRIMARY);
this.value = value;
this.size = size;
}
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.append("si" + size + "(");
value.toString(writer, localData);
value.toString(writer, localData);
return writer.append(")");
}
@Override
public GraphTargetItem returnType() {
public GraphTargetItem returnType() {
return new TypeItem("int");
}
@Override
public boolean hasReturnValue() {
return true;
}
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
InstructionDefinition def = null;
switch (size) {
case 1:
def = new Sxi1Ins();
break;
case 8:
def = new Sxi8Ins();
break;
case 16:
def = new Sxi16Ins();
break;
}
return toSourceMerge(localData, generator, value, ins(def));
}
}

View File

@@ -16,11 +16,21 @@
*/
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Sf32Ins;
import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Sf64Ins;
import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Si16Ins;
import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Si32Ins;
import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Si8Ins;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
/**
*
@@ -28,24 +38,26 @@ import com.jpexs.decompiler.graph.model.LocalData;
*/
public class AlchemyStoreAVM2Item extends AVM2Item {
private final String name;
private final char type;
private final int size;
private final GraphTargetItem ofs;
public AlchemyStoreAVM2Item(GraphSourceItem instruction, GraphTargetItem value, GraphTargetItem ofs, String name) {
public AlchemyStoreAVM2Item(GraphSourceItem instruction, GraphTargetItem value, GraphTargetItem ofs, char type, int size) {
super(instruction, PRECEDENCE_PRIMARY);
this.name = name;
this.ofs = ofs;
this.value = value;
this.type = type;
this.size = size;
}
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.append("op_" + name + "(");
writer.append("s" + type + size + "(");
ofs.toString(writer, localData);
writer.append(",");
value.toString(writer, localData);
return writer.append(") /*Alchemy*/");
return writer.append(")");
}
@Override
@@ -57,4 +69,29 @@ public class AlchemyStoreAVM2Item extends AVM2Item {
public boolean hasReturnValue() {
return false;
}
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
String ts = "" + type + size;
InstructionDefinition def = null;
switch (ts) {
case "i8":
def = new Si8Ins();
break;
case "i16":
def = new Si16Ins();
break;
case "i32":
def = new Si32Ins();
break;
case "f32":
def = new Sf32Ins();
break;
case "f64":
def = new Sf64Ins();
break;
}
return toSourceMerge(localData, generator, ofs, ins(def));
}
}

View File

@@ -40,9 +40,9 @@ public class HasNextAVM2Item extends AVM2Item {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
collection.toString(writer, localData);
collection.appendTo(writer, localData);
writer.append(" hasNext ");
return object.toString(writer, localData);
return object.appendTo(writer, localData);
}
@Override

View File

@@ -1,18 +1,19 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -25,6 +26,7 @@ import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SimpleValue;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -47,7 +49,7 @@ public class IntegerValueAVM2Item extends NumberValueAVM2Item {
@Override
public Object getResult() {
public Object getResult() {
return value;//(Double) (double) (long) value;
}
@Override
@@ -78,4 +80,5 @@ public class IntegerValueAVM2Item extends NumberValueAVM2Item {
public boolean hasReturnValue() {
return true;
}
}

View File

@@ -90,7 +90,7 @@ public class LocalRegAVM2Item extends AVM2Item {
@Override
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
return isCT;
return false; //isCT;
}
@Override

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
@@ -32,7 +33,7 @@ public class NewActivationAVM2Item extends AVM2Item {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append("§§activation");
}
@Override

View File

@@ -1,25 +1,32 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.graph.SimpleValue;
public abstract class NumberValueAVM2Item extends AVM2Item implements SimpleValue {
public NumberValueAVM2Item(AVM2Instruction instruction) {
super(instruction, PRECEDENCE_PRIMARY);
}
@Override
public boolean isSimpleValue() {
return true;
}
}

View File

@@ -46,14 +46,14 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
srcData.localName = slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false);
srcData.localName = slotName == null ? "/*UnknownSlot*/" : slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false);
getName(writer, localData);
writer.append(" = ");
return value.toString(writer, localData);
}
public String getNameAsStr(LocalData localData) {
return slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false);
return slotName == null ? "/*UnknownSlot*/" : slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false);
}
public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) {

View File

@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SimpleValue;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -31,7 +32,7 @@ import com.jpexs.helpers.Helper;
import java.util.List;
import java.util.Set;
public class StringAVM2Item extends AVM2Item {
public class StringAVM2Item extends AVM2Item implements SimpleValue {
public String value;
@@ -71,4 +72,9 @@ public class StringAVM2Item extends AVM2Item {
public boolean hasReturnValue() {
return true;
}
@Override
public boolean isSimpleValue() {
return true;
}
}

View File

@@ -85,7 +85,7 @@ public class DeclarationAVM2Item extends AVM2Item {
if (lti.value instanceof ConvertAVM2Item) {
coerType = ((ConvertAVM2Item) lti.value).type;
}
srcData.declaredType = (coerType instanceof TypeItem) ? ((TypeItem) coerType).fullTypeName : "*";
srcData.declaredType = (coerType instanceof TypeItem) ? ((TypeItem) coerType).fullTypeName.toPrintableString() : "*";
writer.append("var ");
writer.append(localName);
writer.append(":");
@@ -97,7 +97,7 @@ public class DeclarationAVM2Item extends AVM2Item {
SetSlotAVM2Item ssti = (SetSlotAVM2Item) assignment;
srcData.localName = ssti.getNameAsStr(localData);
srcData.declaration = true;
srcData.declaredType = (type instanceof TypeItem) ? ((TypeItem) type).fullTypeName : "*";
srcData.declaredType = (type instanceof TypeItem) ? ((TypeItem) type).fullTypeName.toPrintableString() : "*";
writer.append("var ");
ssti.getName(writer, localData);
writer.append(":");

View File

@@ -96,7 +96,7 @@ public class TryAVM2Item extends AVM2Item implements Block {
int eti = catchExceptions.get(e).type_index;
data.declaredType = eti <= 0 ? "*" : localData.constantsAvm2.constant_multiname.get(eti).getNameWithNamespace(localData.constantsAvm2, true);
data.declaredType = eti <= 0 ? "*" : localData.constantsAvm2.constant_multiname.get(eti).getNameWithNamespace(localData.constantsAvm2).toPrintableString();
writer.hilightSpecial(localName, HighlightSpecialType.TRY_NAME, e, data);
writer.append(":");
writer.hilightSpecial(catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames), HighlightSpecialType.TRY_TYPE, e);

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -53,7 +54,7 @@ public class EqAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem neqSrc) {
return new NeqAVM2Item(src, leftSide, rightSide);
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -48,7 +49,7 @@ public class GeAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem neqSrc) {
return new LtAVM2Item(src, leftSide, rightSide);
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -48,7 +49,7 @@ public class GtAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem neqSrc) {
return new LeAVM2Item(src, leftSide, rightSide);
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -48,7 +49,7 @@ public class LeAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem neqSrc) {
return new GtAVM2Item(src, leftSide, rightSide);
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -48,7 +49,7 @@ public class LtAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem neqSrc) {
return new GeAVM2Item(src, leftSide, rightSide);
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -54,7 +55,7 @@ public class NeqAVM2Item extends BinaryOpItem implements LogicalOpItem, IfCondit
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem neqSrc) {
return new EqAVM2Item(src, leftSide, rightSide);
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -56,7 +57,7 @@ public class StrictEqAVM2Item extends BinaryOpItem implements LogicalOpItem, IfC
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem neqSrc) {
return new StrictNeqAVM2Item(src, leftSide, rightSide);
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -49,7 +50,7 @@ public class StrictNeqAVM2Item extends BinaryOpItem implements LogicalOpItem, If
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem neqSrc) {
return new StrictEqAVM2Item(src, leftSide, rightSide);
}

View File

@@ -57,9 +57,11 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopScopeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushByteIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushFalseIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushNullIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushScopeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushStringIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushTrueIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushUndefinedIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushWithIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.SwapIns;
@@ -103,10 +105,10 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitFunction;
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
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.graph.CompilationException;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.Loop;
@@ -118,6 +120,7 @@ import com.jpexs.decompiler.graph.model.CommaExpressionItem;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.DoWhileItem;
import com.jpexs.decompiler.graph.model.DuplicateItem;
import com.jpexs.decompiler.graph.model.FalseItem;
import com.jpexs.decompiler.graph.model.ForItem;
import com.jpexs.decompiler.graph.model.IfItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -125,6 +128,7 @@ import com.jpexs.decompiler.graph.model.NotItem;
import com.jpexs.decompiler.graph.model.OrItem;
import com.jpexs.decompiler.graph.model.SwitchItem;
import com.jpexs.decompiler.graph.model.TernarOpItem;
import com.jpexs.decompiler.graph.model.TrueItem;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import com.jpexs.decompiler.graph.model.WhileItem;
import java.io.ByteArrayOutputStream;
@@ -161,6 +165,16 @@ public class AVM2SourceGenerator implements SourceGenerator {
return new AVM2Instruction(0, def, operands);
}
@Override
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, FalseItem item) throws CompilationException {
return GraphTargetItem.toSourceMerge(localData, this, ins(new PushFalseIns()));
}
@Override
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, TrueItem item) throws CompilationException {
return GraphTargetItem.toSourceMerge(localData, this, ins(new PushTrueIns()));
}
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, GetDescendantsAVM2Item item) throws CompilationException {
int[] nssa = new int[item.openedNamespaces.size()];
for (int i = 0; i < item.openedNamespaces.size(); i++) {
@@ -1181,7 +1195,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
return abc;
}
public void generateClass(List<String> importedClasses, List<AssignableAVM2Item> sinitVariables, boolean staticNeedsActivation, List<GraphTargetItem> staticInit, List<Integer> openedNamespaces, int namespace, int initScope, String pkg, ClassInfo classInfo, InstanceInfo instanceInfo, SourceGeneratorLocalData localData, boolean isInterface, String name, String superName, GraphTargetItem extendsVal, List<GraphTargetItem> implementsStr, GraphTargetItem constructor, List<GraphTargetItem> traitItems, Reference<Integer> class_index) throws AVM2ParseException, CompilationException {
public void generateClass(List<DottedChain> importedClasses, List<AssignableAVM2Item> sinitVariables, boolean staticNeedsActivation, List<GraphTargetItem> staticInit, List<Integer> openedNamespaces, int namespace, int initScope, String pkg, ClassInfo classInfo, InstanceInfo instanceInfo, SourceGeneratorLocalData localData, boolean isInterface, String name, String superName, GraphTargetItem extendsVal, List<GraphTargetItem> implementsStr, GraphTargetItem constructor, List<GraphTargetItem> traitItems, Reference<Integer> class_index) throws AVM2ParseException, CompilationException {
localData.currentClass = name;
localData.pkg = pkg;
List<GraphSourceItem> ret = new ArrayList<>();
@@ -1693,7 +1707,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
TraitSlotConst tsc = (TraitSlotConst) mbody.traits.traits.get(i);
GraphTargetItem type = TypeItem.UNBOUNDED;
if (tsc.type_index > 0) {
type = new TypeItem(abc.constants.constant_multiname.get(tsc.type_index).getNameWithNamespace(abc.constants, true));
type = new TypeItem(abc.constants.constant_multiname.get(tsc.type_index).getNameWithNamespace(abc.constants));
}
NameAVM2Item d = new NameAVM2Item(type, 0, tsc.getName(abc).getName(abc.constants, new ArrayList<>(), true), NameAVM2Item.getDefaultValue("" + type), true, new ArrayList<Integer>());
d.setSlotNumber(tsc.slot_id);
@@ -1854,7 +1868,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
return null;
}
private int genNs(List<String> importedClasses, String pkg, String custom, int namespace, List<Integer> openedNamespaces, SourceGeneratorLocalData localData, int line) throws CompilationException {
private int genNs(List<DottedChain> importedClasses, String pkg, String custom, int namespace, List<Integer> openedNamespaces, SourceGeneratorLocalData localData, int line) throws CompilationException {
if (custom != null) {
PropertyAVM2Item prop = new PropertyAVM2Item(null, custom, abc, allABCs, openedNamespaces, new ArrayList<MethodBody>());
Reference<ValueKind> value = new Reference<>(null);
@@ -1865,11 +1879,9 @@ public class AVM2SourceGenerator implements SourceGenerator {
}
if (!resolved) {
String customPkg = "";
String fullCustom = "";
for (String imp : importedClasses) {
if (imp.endsWith("." + custom)) {
customPkg = imp.substring(0, imp.lastIndexOf('.'));
DottedChain fullCustom = null;
for (DottedChain imp : importedClasses) {
if (imp.getLast().equals(custom)) {
fullCustom = imp;
break;
}
@@ -1882,7 +1894,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
for (ScriptInfo si : a.script_info) {
for (Trait t : si.traits.traits) {
Multiname m = t.getName(a);
if (fullCustom.equals(m.getNameWithNamespace(a.constants, true))) {
if (fullCustom != null && fullCustom.equals(m.getNameWithNamespace(a.constants))) {
if (t instanceof TraitSlotConst) {
if (((TraitSlotConst) t).isNamespace()) {
Namespace ns = a.constants.getNamespace(((TraitSlotConst) t).value_index);
@@ -1901,7 +1913,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
return namespace;
}
public void generateTraitsPhase2(List<String> importedClasses, String pkg, List<GraphTargetItem> items, Trait[] traits, List<Integer> openedNamespaces, SourceGeneratorLocalData localData) throws CompilationException {
public void generateTraitsPhase2(List<DottedChain> importedClasses, String pkg, List<GraphTargetItem> items, Trait[] traits, List<Integer> openedNamespaces, SourceGeneratorLocalData localData) throws CompilationException {
for (int k = 0; k < items.size(); k++) {
GraphTargetItem item = items.get(k);
if (traits[k] == null) {
@@ -2132,7 +2144,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
ScriptInfo si = new ScriptInfo();
localData.currentScript = si;
Trait[] traitArr = generateTraitsPhase1(null, null, true, localData, commands, si.traits, class_index);
generateTraitsPhase2(new ArrayList<>(), null/*FIXME*/, commands, traitArr, new ArrayList<Integer>(), localData);
generateTraitsPhase2(new ArrayList<DottedChain>(), null/*FIXME*/, commands, traitArr, new ArrayList<Integer>(), localData);
MethodInfo mi = new MethodInfo(new int[0], 0, 0, 0, new ValueKind[0], new int[0]);
MethodBody mb = new MethodBody();
mb.method_info = abc.addMethodInfo(mi);
@@ -2444,12 +2456,9 @@ public class AVM2SourceGenerator implements SourceGenerator {
TypeItem type = (TypeItem) typeItem;
String name = type.fullTypeName;
String pkg = "";
if (name.contains(".")) {
pkg = name.substring(0, name.lastIndexOf('.'));
name = name.substring(name.lastIndexOf('.') + 1);
}
DottedChain dname = type.fullTypeName;
String pkg = dname.getWithoutLast().toString();
String name = dname.getLast();
for (InstanceInfo ii : abc.instance_info) {
Multiname mname = abc.constants.constant_multiname.get(ii.name_index);
if (mname != null && name.equals(mname.getName(abc.constants, new ArrayList<>(), true))) {

View File

@@ -86,6 +86,7 @@ import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.Loop;
import com.jpexs.decompiler.graph.TypeItem;
@@ -144,7 +145,7 @@ public class ActionScript3Parser {
return uniqLast;
}
private List<GraphTargetItem> commands(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<String> importedClasses, List<Integer> openedNamespaces, Stack<Loop> loops, Map<Loop, String> loopLabels, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, int forinlevel, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private List<GraphTargetItem> commands(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<Integer> openedNamespaces, Stack<Loop> loops, Map<Loop, String> loopLabels, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, int forinlevel, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
List<GraphTargetItem> ret = new ArrayList<>();
if (debugMode) {
System.out.println("commands:");
@@ -159,7 +160,7 @@ public class ActionScript3Parser {
return ret;
}
private GraphTargetItem type(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<String> importedClasses, List<Integer> openedNamespaces, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private GraphTargetItem type(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<Integer> openedNamespaces, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
ParsedSymbol s = lex();
if (s.type == SymbolType.MULTIPLY) {
return new UnboundedTypeItem();
@@ -174,7 +175,7 @@ public class ActionScript3Parser {
return t;
}
private GraphTargetItem memberOrCall(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<String> importedClasses, List<Integer> openedNamespaces, GraphTargetItem newcmds, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private GraphTargetItem memberOrCall(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<Integer> openedNamespaces, GraphTargetItem newcmds, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
if (debugMode) {
System.out.println("memberOrCall:");
}
@@ -223,7 +224,7 @@ public class ActionScript3Parser {
return ret;
}
private GraphTargetItem applyType(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<String> importedClasses, List<Integer> openedNamespaces, GraphTargetItem obj, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private GraphTargetItem applyType(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<Integer> openedNamespaces, GraphTargetItem obj, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
GraphTargetItem ret = obj;
ParsedSymbol s = lex();
if (s.type == SymbolType.TYPENAME) {
@@ -250,7 +251,7 @@ public class ActionScript3Parser {
return ret;
}
private GraphTargetItem member(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<String> importedClasses, List<Integer> openedNamespaces, GraphTargetItem obj, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private GraphTargetItem member(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<Integer> openedNamespaces, GraphTargetItem obj, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
if (debugMode) {
System.out.println("member:");
}
@@ -286,7 +287,7 @@ public class ActionScript3Parser {
s = lex();
GraphTargetItem ns = null;
if (s.type == SymbolType.NAMESPACE_OP) {
ns = new UnresolvedAVM2Item(new ArrayList<GraphTargetItem>(), importedClasses, false, null, lexer.yyline(), propName, null, openedNamespaces);
ns = new UnresolvedAVM2Item(new ArrayList<GraphTargetItem>(), importedClasses, false, null, lexer.yyline(), new DottedChain(propName), null, openedNamespaces);
variables.add((UnresolvedAVM2Item) ns);
s = lex();
if (s.type == SymbolType.BRACKET_OPEN) {
@@ -317,28 +318,31 @@ public class ActionScript3Parser {
return ret;
}
private GraphTargetItem name(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, boolean typeOnly, List<Integer> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables, List<String> importedClasses) throws IOException, AVM2ParseException {
private GraphTargetItem name(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, boolean typeOnly, List<Integer> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables, List<DottedChain> importedClasses) throws IOException, AVM2ParseException {
ParsedSymbol s = lex();
String name = "";
DottedChain name = new DottedChain();
String name2 = "";
if (s.type == SymbolType.ATTRIBUTE) {
name += "@";
name2 += "@";
s = lex();
}
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.THIS, SymbolType.SUPER, SymbolType.STRING_OP);
name += s.value.toString();
name2 += s.value.toString();
s = lex();
boolean attrBracket = false;
name.parts.add(name2);
while (s.isType(SymbolType.DOT)) {
name += s.value.toString(); //. or ::
//name += s.value.toString(); //. or ::
s = lex();
name2 = "";
if (s.type == SymbolType.ATTRIBUTE) {
name += "@";
name2 += "@";
s = lex();
if (s.type == SymbolType.MULTIPLY) {
name += s.value.toString();
name2 += s.value.toString();
} else if (s.group == SymbolGroup.IDENTIFIER) {
name += s.value.toString();
name2 += s.value.toString();
} else {
if (s.type != SymbolType.BRACKET_OPEN) {
throw new AVM2ParseException("Attribute identifier or bracket expected", lexer.yyline());
@@ -348,19 +352,16 @@ public class ActionScript3Parser {
}
} else {
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.NAMESPACE);
name += s.value.toString();
name2 += s.value.toString();
}
name.parts.add(name2);
s = lex();
}
String nsname = null;
String nsprop = null;
GraphTargetItem nspropItem = null;
if (s.type == SymbolType.NAMESPACE_OP) {
if (name.contains(".")) {
nsname = name.substring(name.lastIndexOf('.') + 1);
} else {
nsname = name;
}
nsname = name.getLast();
s = lex();
if (s.group == SymbolGroup.IDENTIFIER) {
nsprop = s.value.toString();
@@ -368,16 +369,12 @@ public class ActionScript3Parser {
nspropItem = expression(thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables);
expectedType(SymbolType.BRACKET_CLOSE);
}
if (name.contains(".")) {
name = name.substring(0, name.lastIndexOf('.'));
} else {
name = null;
}
name = name.getWithoutLast();
s = lex();
}
GraphTargetItem ret = null;
if (name != null) {
if (!name.parts.isEmpty()) {
UnresolvedAVM2Item unr = new UnresolvedAVM2Item(new ArrayList<GraphTargetItem>(), importedClasses, typeOnly, null, lexer.yyline(), name, null, openedNamespaces);
//unr.setIndex(index);
variables.add(unr);
@@ -388,7 +385,7 @@ public class ActionScript3Parser {
if (attr) {
nsname = nsname.substring(1);
}
UnresolvedAVM2Item ns = new UnresolvedAVM2Item(new ArrayList<GraphTargetItem>(), importedClasses, typeOnly, null, lexer.yyline(), nsname, null, openedNamespaces);
UnresolvedAVM2Item ns = new UnresolvedAVM2Item(new ArrayList<GraphTargetItem>(), importedClasses, typeOnly, null, lexer.yyline(), new DottedChain(nsname), null, openedNamespaces);
variables.add(ns);
ret = new NamespacedAVM2Item(ns, nsprop, nspropItem, ret, attr, openedNamespaces, null);
}
@@ -443,7 +440,7 @@ public class ActionScript3Parser {
return ret;
}
private List<GraphTargetItem> call(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<String> importedClasses, List<Integer> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private List<GraphTargetItem> call(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<Integer> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
List<GraphTargetItem> ret = new ArrayList<>();
//expected(SymbolType.PARENT_OPEN); //MUST BE HANDLED BY CALLER
ParsedSymbol s = lex();
@@ -458,12 +455,12 @@ public class ActionScript3Parser {
return ret;
}
private MethodAVM2Item method(String pkg, boolean isInterface, String customAccess, Reference<Boolean> needsActivation, List<String> importedClasses, boolean override, boolean isFinal, TypeItem thisType, List<Integer> openedNamespaces, boolean isStatic, int namespace, String functionName, boolean isMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private MethodAVM2Item method(String pkg, boolean isInterface, String customAccess, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, boolean override, boolean isFinal, TypeItem thisType, List<Integer> openedNamespaces, boolean isStatic, int namespace, String functionName, boolean isMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
FunctionAVM2Item f = function(pkg, isInterface, needsActivation, importedClasses, namespace, thisType, openedNamespaces, functionName, isMethod, variables);
return new MethodAVM2Item(f.pkg, f.isInterface, customAccess, f.needsActivation, f.hasRest, f.line, override, isFinal, isStatic, f.namespace, functionName, f.paramTypes, f.paramNames, f.paramValues, f.body, f.subvariables, f.retType);
}
private FunctionAVM2Item function(String pkg, boolean isInterface, Reference<Boolean> needsActivation, List<String> importedClasses, int namespace, TypeItem thisType, List<Integer> openedNamespaces, String functionName, boolean isMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private FunctionAVM2Item function(String pkg, boolean isInterface, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, int namespace, TypeItem thisType, List<Integer> openedNamespaces, String functionName, boolean isMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
openedNamespaces = new ArrayList<>(openedNamespaces); //local copy
int line = lexer.yyline();
ParsedSymbol s;
@@ -544,7 +541,7 @@ public class ActionScript3Parser {
return new FunctionAVM2Item(pkg, isInterface, needsActivation2.getVal(), namespace, hasRest, line, functionName, paramTypes, paramNames, paramValues, body, subvariables, retType);
}
private GraphTargetItem traits(String scriptName, boolean scriptTraits, List<AssignableAVM2Item> sinitVariables, Reference<Boolean> sinitNeedsActivation, List<GraphTargetItem> staticInitializer, List<String> importedClasses, int privateNs, int protectedNs, int publicNs, int packageInternalNs, int protectedStaticNs, List<Integer> openedNamespaces, String pkg, String classNameStr, boolean isInterface, List<GraphTargetItem> traits) throws AVM2ParseException, IOException, CompilationException {
private GraphTargetItem traits(String scriptName, boolean scriptTraits, List<AssignableAVM2Item> sinitVariables, Reference<Boolean> sinitNeedsActivation, List<GraphTargetItem> staticInitializer, List<DottedChain> importedClasses, int privateNs, int protectedNs, int publicNs, int packageInternalNs, int protectedStaticNs, List<Integer> openedNamespaces, String pkg, String classNameStr, boolean isInterface, List<GraphTargetItem> traits) throws AVM2ParseException, IOException, CompilationException {
ParsedSymbol s;
GraphTargetItem constr = null;
TypeItem thisType = pkg == null && classNameStr == null ? null : new TypeItem(pkg == null || "".equals(pkg) ? classNameStr : pkg + "." + classNameStr);
@@ -892,7 +889,7 @@ public class ActionScript3Parser {
return constr;
}
private GraphTargetItem classTraits(String scriptName, int gpublicNs, String pkg, List<String> importedClasses, boolean isDynamic, boolean isFinal, List<Integer> openedNamespaces, String packageName, int namespace, boolean isInterface, String nameStr, GraphTargetItem extendsStr, List<GraphTargetItem> implementsStr, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, CompilationException {
private GraphTargetItem classTraits(String scriptName, int gpublicNs, String pkg, List<DottedChain> importedClasses, boolean isDynamic, boolean isFinal, List<Integer> openedNamespaces, String packageName, int namespace, boolean isInterface, String nameStr, GraphTargetItem extendsStr, List<GraphTargetItem> implementsStr, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, CompilationException {
GraphTargetItem ret = null;
@@ -1049,7 +1046,7 @@ public class ActionScript3Parser {
}
}
private List<GraphTargetItem> xmltag(TypeItem thisType, String pkg, Reference<Boolean> usesVars, List<String> openedTags, Reference<Integer> closedVarTags, Reference<Boolean> needsActivation, List<String> importedClasses, List<Integer> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private List<GraphTargetItem> xmltag(TypeItem thisType, String pkg, Reference<Boolean> usesVars, List<String> openedTags, Reference<Integer> closedVarTags, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<Integer> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
ParsedSymbol s = null;
List<GraphTargetItem> rets = new ArrayList<>();
//GraphTargetItem ret = null;
@@ -1178,7 +1175,7 @@ public class ActionScript3Parser {
return rets;
}
private GraphTargetItem xml(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<String> importedClasses, List<Integer> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private GraphTargetItem xml(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<Integer> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
List<String> openedTags = new ArrayList<>();
int closedVarTags = 0;
@@ -1189,7 +1186,7 @@ public class ActionScript3Parser {
return ret;
}
private GraphTargetItem command(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<String> importedClasses, List<Integer> openedNamespaces, Stack<Loop> loops, Map<Loop, String> loopLabels, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, int forinlevel, boolean mustBeCommand, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private GraphTargetItem command(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<Integer> openedNamespaces, Stack<Loop> loops, Map<Loop, String> loopLabels, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, int forinlevel, boolean mustBeCommand, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
LexBufferer buf = new LexBufferer();
lexer.addListener(buf);
GraphTargetItem ret = null;
@@ -1672,7 +1669,7 @@ public class ActionScript3Parser {
}
private GraphTargetItem expression(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<String> importedClasses, List<Integer> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private GraphTargetItem expression(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<Integer> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
return expression(thisType, pkg, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, allowRemainder, variables);
}
@@ -1704,7 +1701,7 @@ public class ActionScript3Parser {
return ret;
}
/*private GraphTargetItem expressionRemainder(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<Integer> openedNamespaces, GraphTargetItem expr, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables, List<String> importedClasses) throws IOException, AVM2ParseException {
/*private GraphTargetItem expressionRemainder(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<Integer> openedNamespaces, GraphTargetItem expr, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables, List<DottedChain> importedClasses) throws IOException, AVM2ParseException {
GraphTargetItem ret = null;
ParsedSymbol s = lex();
@@ -1740,7 +1737,7 @@ public class ActionScript3Parser {
return false;
}
private int brackets(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<String> importedClasses, List<Integer> openedNamespaces, List<GraphTargetItem> ret, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private int brackets(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<Integer> openedNamespaces, List<GraphTargetItem> ret, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
ParsedSymbol s = lex();
int arrCnt = 0;
if (s.type == SymbolType.BRACKET_OPEN) {
@@ -1764,7 +1761,7 @@ public class ActionScript3Parser {
return arrCnt;
}
private GraphTargetItem commaExpression(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<String> importedClasses, List<Integer> openedNamespaces, Stack<Loop> loops, Map<Loop, String> loopLabels, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, int forInLevel, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private GraphTargetItem commaExpression(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<Integer> openedNamespaces, Stack<Loop> loops, Map<Loop, String> loopLabels, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, int forInLevel, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
GraphTargetItem cmd = null;
List<GraphTargetItem> expr = new ArrayList<>();
ParsedSymbol s;
@@ -1786,7 +1783,7 @@ public class ActionScript3Parser {
return new CommaExpressionItem(null, expr);
}
private GraphTargetItem expression(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<String> importedClasses, List<Integer> openedNamespaces, boolean allowEmpty, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private GraphTargetItem expression(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<Integer> openedNamespaces, boolean allowEmpty, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
GraphTargetItem prim = expressionPrimary(thisType, pkg, needsActivation, importedClasses, openedNamespaces, allowEmpty, registerVars, inFunction, inMethod, allowRemainder, variables);
if (prim == null) {
return null;
@@ -1816,7 +1813,7 @@ public class ActionScript3Parser {
return lookahead;
}
private GraphTargetItem expression1(GraphTargetItem lhs, int min_precedence, TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<String> importedClasses, List<Integer> openedNamespaces, boolean allowEmpty, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private GraphTargetItem expression1(GraphTargetItem lhs, int min_precedence, TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<Integer> openedNamespaces, boolean allowEmpty, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
if (debugMode) {
System.out.println("expression1:");
}
@@ -2029,7 +2026,7 @@ public class ActionScript3Parser {
return lhs;
}
private GraphTargetItem expressionPrimary(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<String> importedClasses, List<Integer> openedNamespaces, boolean allowEmpty, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
private GraphTargetItem expressionPrimary(TypeItem thisType, String pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<Integer> openedNamespaces, boolean allowEmpty, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
if (debugMode) {
System.out.println("primary:");
}
@@ -2279,39 +2276,34 @@ public class ActionScript3Parser {
s = lex();
}
List<String> importedClasses = new ArrayList<>();
List<DottedChain> importedClasses = new ArrayList<>();
s = lex();
while (s.type == SymbolType.IMPORT) {
String impPackage = "";
String impName = null;
boolean all = false;
s = lex();
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
impName = s.value.toString();
DottedChain imp = new DottedChain();
imp.parts.add(s.value.toString());
s = lex();
boolean isStar = false;
while (s.type == SymbolType.DOT) {
if (!"".equals(impPackage)) {
impPackage += ".";
}
impPackage += impName;
s = lex();
if (s.type == SymbolType.MULTIPLY) {
impName = null;
isStar = true;
s = lex();
break;
}
expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER);
impName = s.value.toString();
imp.parts.add(s.value.toString());
s = lex();
}
if (impName == null) {
openedNamespaces.add(abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abc.constants.getStringId(impPackage, true)), 0, true));
if (isStar) {
openedNamespaces.add(abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abc.constants.getStringId(imp.toString(), true)), 0, true));
} else {
importedClasses.add(impPackage + "." + impName);
importedClasses.add(imp);
}
expected(s, lexer.yyline(), SymbolType.SEMICOLON);
@@ -2349,7 +2341,7 @@ public class ActionScript3Parser {
openedNamespaces.add(publicNs = abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abc.constants.getStringId("", true)), 0, true));
List<GraphTargetItem> items = new ArrayList<>();
traits(fileName, true, new ArrayList<AssignableAVM2Item>(), new Reference<>(false), new ArrayList<GraphTargetItem>(), new ArrayList<>(), scriptPrivateNs, 0, publicNs, 0, 0, openedNamespaces, null, null, false, items);
traits(fileName, true, new ArrayList<AssignableAVM2Item>(), new Reference<>(false), new ArrayList<GraphTargetItem>(), new ArrayList<DottedChain>(), scriptPrivateNs, 0, publicNs, 0, 0, openedNamespaces, null, null, false, items);
return items;
}

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -54,7 +55,7 @@ public class ClassAVM2Item extends AVM2Item implements Block {
public List<AssignableAVM2Item> sinitVariables;
public List<String> importedClasses;
public List<DottedChain> importedClasses;
public String pkg;
@@ -67,7 +68,7 @@ public class ClassAVM2Item extends AVM2Item implements Block {
return ret;
}
public ClassAVM2Item(List<String> importedClasses, String pkg, List<Integer> openedNamespaces, int protectedNs, boolean isDynamic, boolean isFinal, int namespace, String className, GraphTargetItem extendsOp, List<GraphTargetItem> implementsOp, List<GraphTargetItem> staticInit, boolean staticInitActivation, List<AssignableAVM2Item> sinitVariables, GraphTargetItem constructor, List<GraphTargetItem> traits) {
public ClassAVM2Item(List<DottedChain> importedClasses, String pkg, List<Integer> openedNamespaces, int protectedNs, boolean isDynamic, boolean isFinal, int namespace, String className, GraphTargetItem extendsOp, List<GraphTargetItem> implementsOp, List<GraphTargetItem> staticInit, boolean staticInitActivation, List<AssignableAVM2Item> sinitVariables, GraphTargetItem constructor, List<GraphTargetItem> traits) {
super(null, NOPRECEDENCE);
this.importedClasses = importedClasses;
this.pkg = pkg;

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
@@ -43,9 +44,9 @@ public class InterfaceAVM2Item extends AVM2Item {
public String pkg;
public List<String> importedClasses;
public List<DottedChain> importedClasses;
public InterfaceAVM2Item(List<String> importedClasses, String pkg, List<Integer> openedNamespaces, boolean isFinal, int namespace, String name, List<GraphTargetItem> superInterfaces, List<GraphTargetItem> traits) {
public InterfaceAVM2Item(List<DottedChain> importedClasses, String pkg, List<Integer> openedNamespaces, boolean isFinal, int namespace, String name, List<GraphTargetItem> superInterfaces, List<GraphTargetItem> traits) {
super(null, NOPRECEDENCE);
this.importedClasses = importedClasses;
this.pkg = pkg;

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
@@ -34,11 +35,11 @@ public class PackageAVM2Item extends AVM2Item {
public String packageName;
public List<String> importedClasses = new ArrayList<>();
public List<DottedChain> importedClasses = new ArrayList<>();
public int publicNs = 0;
public PackageAVM2Item(int publicNs, List<String> importedClasses, String packageName, List<GraphTargetItem> items) {
public PackageAVM2Item(int publicNs, List<DottedChain> importedClasses, String packageName, List<GraphTargetItem> items) {
super(null, NOPRECEDENCE);
this.publicNs = publicNs;
this.importedClasses = importedClasses;

View File

@@ -44,6 +44,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
@@ -115,7 +116,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
}
return new ApplyTypeAVM2Item(null, obj, params);
} else {
return new TypeItem(m.getNameWithNamespace(constants, true));
return new TypeItem(m.getNameWithNamespace(constants));
}
}

View File

@@ -1,18 +1,19 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
/**
@@ -32,5 +33,6 @@ public enum SymbolGroup {
TYPENAME,
EOF,
//GLOBALFUNC,
//GLOBALFUNC,
GLOBALCONST,
PREPROCESSOR
}

View File

@@ -205,7 +205,8 @@ public enum SymbolType {
XML_INSTRVARTAG_BEGIN(GraphTargetItem.PRECEDENCE_PRIMARY, false), // <?{
FILTER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
DESCENDANTS(GraphTargetItem.PRECEDENCE_PRIMARY, false),
NATIVE;
NATIVE,
PREPROCESSOR(GraphTargetItem.PRECEDENCE_PRIMARY, false);
private int precedence = GraphTargetItem.NOPRECEDENCE;

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
@@ -48,7 +49,7 @@ import java.util.List;
*/
public class UnresolvedAVM2Item extends AssignableAVM2Item {
private String name;
private DottedChain name;
private int nsKind = -1;
@@ -65,7 +66,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
private final boolean mustBeType;
public List<String> importedClasses;
public List<DottedChain> importedClasses;
public List<GraphTargetItem> scopeStack = new ArrayList<>();
@@ -128,7 +129,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
*/
public void appendName(String name) {
this.name += "." + name;
this.name.parts.add(name);
}
public void setDefinition(boolean definition) {
@@ -150,15 +151,15 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
this.assignedValue = storeValue;
}
public String getVariableName() {
public DottedChain getVariableName() {
return name;
}
public void setVariableName(String name) {
public void setVariableName(DottedChain name) {
this.name = name;
}
public UnresolvedAVM2Item(List<GraphTargetItem> subtypes, List<String> importedClasses, boolean mustBeType, GraphTargetItem type, int line, String name, GraphTargetItem storeValue, List<Integer> openedNamespaces) {
public UnresolvedAVM2Item(List<GraphTargetItem> subtypes, List<DottedChain> importedClasses, boolean mustBeType, GraphTargetItem type, int line, DottedChain name, GraphTargetItem storeValue, List<Integer> openedNamespaces) {
super(storeValue);
this.name = name;
this.assignedValue = storeValue;
@@ -264,7 +265,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
if (resolved != null) {
return resolved.toString();
}
return name;
return name.toString();
}
@Override
@@ -290,14 +291,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
}
public GraphTargetItem resolve(GraphTargetItem thisType, List<GraphTargetItem> paramTypes, List<String> paramNames, ABC abc, List<ABC> otherAbcs, List<MethodBody> callStack, List<AssignableAVM2Item> variables) throws CompilationException {
List<String> parts = new ArrayList<>();
if (name.contains(".")) {
String[] partsArr = name.split("\\.");
parts.addAll(Arrays.asList(partsArr));
} else {
parts.add(name);
}
List<String> parts = name.parts;
if (scopeStack.isEmpty()) { //Everything is multiname property in with command
//search for variable
@@ -326,13 +320,9 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
}
}
//Search for types in imported classes
for (String imp : importedClasses) {
String impName = imp;
String impPkg = "";
if (impName.contains(".")) {
impPkg = impName.substring(0, impName.lastIndexOf('.'));
impName = impName.substring(impName.lastIndexOf('.') + 1);
}
for (DottedChain imp : importedClasses) {
String impName = imp.getLast();
if (impName.equals(parts.get(0))) {
TypeItem ret = new TypeItem(imp);
resolved = ret;
@@ -354,13 +344,13 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
allAbcs.add(abc);
allAbcs.addAll(otherAbcs);
for (int i = 0; i < parts.size(); i++) {
String fname = Helper.joinStrings(parts.subList(0, i + 1), ".");
DottedChain fname = new DottedChain(parts.subList(0, i + 1)); //Helper.joinStrings(parts.subList(0, i + 1), ".");
for (ABC a : allAbcs) {
for (int c = 0; c < a.instance_info.size(); c++) {
if (a.instance_info.get(c).deleted) {
continue;
}
if (a.instance_info.get(c).name_index > 0 && fname.equals(a.instance_info.get(c).getName(a.constants).getNameWithNamespace(a.constants, true))) {
if (a.instance_info.get(c).name_index > 0 && fname.equals(a.instance_info.get(c).getName(a.constants).getNameWithNamespace(a.constants))) {
if (!subtypes.isEmpty() && parts.size() > i + 1) {
continue;
}
@@ -400,7 +390,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
if (!subtypes.isEmpty() && parts.size() > 1) {
continue;
}
TypeItem ret = new TypeItem(a.instance_info.get(c).getName(a.constants).getNameWithNamespace(a.constants, true));
TypeItem ret = new TypeItem(a.instance_info.get(c).getName(a.constants).getNameWithNamespace(a.constants));
/*for (String s : subtypes) {
UnresolvedAVM2Item su = new UnresolvedAVM2Item(new ArrayList<>(), importedClasses, true, null, line, s, null, openedNamespaces);
su.resolve(thisType, paramTypes, paramNames, abc, otherAbcs, callStack, variables);

View File

@@ -97,10 +97,10 @@ public class InstanceInfo {
}
writer.appendNoHilight(modifiers + objType);
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList<>()/* No full names here*/, false), HighlightSpecialType.CLASS_NAME);
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, new ArrayList<String>()/* No full names here*/, false), HighlightSpecialType.CLASS_NAME);
if (super_index > 0) {
String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc.constants, true);
String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc.constants).toPrintableString();
writer.appendNoHilight(" extends ");
writer.hilightSpecial(abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TYPE_NAME, typeName);
}
@@ -114,7 +114,7 @@ public class InstanceInfo {
if (i > 0) {
writer.append(", ");
}
String typeName = abc.constants.getMultiname(interfaces[i]).getNameWithNamespace(abc.constants, true);
String typeName = abc.constants.getMultiname(interfaces[i]).getNameWithNamespace(abc.constants).toPrintableString();
writer.hilightSpecial(abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TYPE_NAME, typeName);
}
}

View File

@@ -20,8 +20,11 @@ import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.ABCInputStream;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorRegisters;
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorSimple;
import com.jpexs.decompiler.flash.abc.avm2.CodeStats;
import com.jpexs.decompiler.flash.abc.avm2.UnknownInstructionCode;
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorJumps;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.configuration.Configuration;
@@ -201,6 +204,7 @@ public final class MethodBody implements Cloneable {
if (exportMode != ScriptExportMode.AS) {
getCode().toASMSource(constants, trait, method_info.get(this.method_info), this, exportMode, writer);
} else {
//if (!path.contains("_addGarbageLineMulti")) {
if (!Configuration.decompile.get()) {
writer.appendNoHilight(Helper.getDecompilationSkippedComment()).newLine();
return;
@@ -244,6 +248,7 @@ public final class MethodBody implements Cloneable {
if (exportMode != ScriptExportMode.AS) {
getCode().toASMSource(constants, trait, method_info.get(this.method_info), this, exportMode, writer);
} else {
//if (!path.contains("_addGarbageLineMulti")) {
if (!Configuration.decompile.get()) {
//writer.startMethod(this.method_info);
writer.appendNoHilight(Helper.getDecompilationSkippedComment()).newLine();
@@ -275,17 +280,22 @@ public final class MethodBody implements Cloneable {
public MethodBody convertMethodBody(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, Trait trait, AVM2ConstantPool constants, List<MethodInfo> method_info, ScopeStack scopeStack, boolean isStaticInitializer, List<String> fullyQualifiedNames, Traits initTraits) throws InterruptedException {
MethodBody b = clone();
AVM2Code deobfuscated = b.getCode();
deobfuscated.markMappedOffsets();
//deobfuscated.inlineJumpExit();
b.getCode().markMappedOffsets();
if (Configuration.autoDeobfuscate.get()) {
try {
deobfuscated.removeTraps(constants, trait, method_info.get(this.method_info), b, abc, scriptIndex, classIndex, isStatic, path);
} catch (StackOverflowError ex) {
logger.log(Level.SEVERE, "Error during remove traps in " + path, ex);
if (Configuration.deobfuscationMode.get() == 0) {
try {
b.getCode().removeTraps(constants, trait, method_info.get(this.method_info), b, abc, scriptIndex, classIndex, isStatic, path);
} catch (Throwable ex) {
logger.log(Level.SEVERE, "Error during old deobfuscation: " + path, ex);
}
} else {
new AVM2DeobfuscatorSimple().deobfuscate(path, classIndex, isStatic, scriptIndex, abc, constants, trait, method_info.get(this.method_info), b);
new AVM2DeobfuscatorRegisters().deobfuscate(path, classIndex, isStatic, scriptIndex, abc, constants, trait, method_info.get(this.method_info), b);
new AVM2DeobfuscatorJumps().deobfuscate(path, classIndex, isStatic, scriptIndex, abc, constants, trait, method_info.get(this.method_info), b);
}
}
//deobfuscated.restoreControlFlow(constants, b);
return b;
}

View File

@@ -49,7 +49,7 @@ public class MethodInfo {
}
}
public int[] param_types;
public int[] param_types = new int[]{};
public int ret_type;
@@ -74,9 +74,9 @@ public class MethodInfo {
public int flags;
public ValueKind[] optional;
public ValueKind[] optional = new ValueKind[0];
public int[] paramNames;
public int[] paramNames = new int[0];
private MethodBody body;
@@ -310,7 +310,7 @@ public class MethodInfo {
}
String ptype = "*";
if (param_types[i] > 0) {
ptype = constants.getMultiname(param_types[i]).getNameWithNamespace(constants, false);
ptype = constants.getMultiname(param_types[i]).getNameWithNamespace(constants).toPrintableString();
}
HighlightData pdata = new HighlightData();

View File

@@ -19,7 +19,9 @@ package com.jpexs.decompiler.flash.abc.types;
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.helpers.Helper;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -288,23 +290,28 @@ public class Multiname {
} else {
String name = constants.getString(name_index);
if (fullyQualifiedNames != null && fullyQualifiedNames.contains(name)) {
return getNameWithNamespace(constants, raw);
DottedChain dc = getNameWithNamespace(constants);
return raw ? dc.toString() : dc.toPrintableString();
}
return (isAttribute() ? "@" : "") + (raw ? name : IdentifiersDeobfuscation.printIdentifier(true, name));
}
}
public String getNameWithNamespace(AVM2ConstantPool constants, boolean raw) {
public DottedChain getNameWithNamespace(AVM2ConstantPool constants) {
StringBuilder ret = new StringBuilder();
Namespace ns = getNamespace(constants);
List<String> chain = new ArrayList<>();
if (ns != null) {
String nsname = ns.getName(constants, raw);
String nsname = ns.getName(constants, true);
if (nsname != null && !nsname.isEmpty()) {
ret.append(nsname).append(".");
String parts[] = nsname.split("\\.");
for (String p : parts) {
chain.add(p);
}
}
}
ret.append(getName(constants, null, raw));
return ret.toString();
chain.add(getName(constants, null, true));
return new DottedChain(chain);
}
public Namespace getNamespace(AVM2ConstantPool constants) {

View File

@@ -88,6 +88,9 @@ public class ScriptInfo {
}
}
}
if (ret.size() == 1) {
ret.get(0).isSimple = true;
}
return ret;
}

View File

@@ -81,7 +81,8 @@ public abstract class Trait implements Serializable {
if (m.namespace_index == -1) {
break;
}
nsname = abcTag.getABC().nsValueToName(abc.constants.getNamespace(m.namespace_index).getName(abc.constants, true));
nsname = abcTag.getABC().nsValueToName(abc.constants.getNamespace(m.namespace_index).getName(abc.constants, true)).toString();
if (nsname == null) {
break;
}
@@ -194,7 +195,7 @@ public abstract class Trait implements Serializable {
Multiname name = getName(abc);
Namespace ns = name.getNamespace(abc.constants);
String packageName = ns.getName(abc.constants, false);
String objectName = name.getName(abc.constants, new ArrayList<>(), false);
String objectName = name.getName(abc.constants, new ArrayList<String>(), false);
return new ClassPath(packageName, objectName); //assume not null name
}
}

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.ClassPath;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.AlchemyTypeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewFunctionIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyStrictIns;
@@ -36,6 +37,7 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.ScopeStack;
import com.jpexs.helpers.Helper;
import java.util.ArrayList;
@@ -89,57 +91,53 @@ public class TraitClass extends Trait implements TraitWithSlot {
return "Class " + abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " slot=" + slot_id + " class_info=" + class_info + " metadata=" + Helper.intArrToString(metadata);
}
private boolean parseUsagesFromNS(ABC abc, List<String> imports, List<String> uses, int namespace_index, String ignorePackage, String name) {
private boolean parseUsagesFromNS(ABC abc, List<DottedChain> imports, List<String> uses, int namespace_index, String ignorePackage, String name) {
Namespace ns = abc.constants.getNamespace(namespace_index);
if (name.isEmpty()) {
name = "*";
}
String newimport = ns.getName(abc.constants, ns.kind == Namespace.KIND_NAMESPACE);
String nsname = ns.getName(abc.constants, ns.kind == Namespace.KIND_NAMESPACE);
DottedChain newimport = nsname == null ? new DottedChain() : new DottedChain(nsname.split("\\."));
/*if ((ns.kind != Namespace.KIND_PACKAGE)
&& (ns.kind != Namespace.KIND_NAMESPACE)
&& (ns.kind != Namespace.KIND_STATIC_PROTECTED)) {
return false;
}*/
/*if (ns.kind == Namespace.KIND_NAMESPACE)*/ {
String oldimport = newimport;
newimport = null;
DottedChain oldimport = newimport;
newimport = new DottedChain();
for (ABCContainerTag abcTag : abc.getAbcTags()) {
String newname = abcTag.getABC().nsValueToName(oldimport);
if (newname.equals("-")) {
DottedChain newname = abcTag.getABC().nsValueToName(oldimport == null ? null : oldimport.toString());
if (newname.toString().equals("-")) {
return true;
}
if (!newname.isEmpty()) {
if (!newname.toString().isEmpty()) {
newimport = newname;
break;
}
}
if (newimport == null) {
if (newimport.parts.isEmpty()) {
newimport = oldimport;
newimport += "." + name;
newimport.parts.add(name);
}
if (newimport != null && newimport.isEmpty()) {
newimport = null;
if (!newimport.parts.isEmpty() && newimport.toString().isEmpty()) {
newimport.parts.clear();
}
if (newimport != null) {
if (newimport.parts.isEmpty()) {
/* if(ns.kind==Namespace.KIND_PACKAGE){
newimport+=".*";
}*/
if (!imports.contains(newimport)) {
if (newimport.contains(":")) {
return true;
}
String pkg = "";
if (newimport.contains(".")) {
pkg = newimport.substring(0, newimport.lastIndexOf('.'));
}
String usname = newimport;
if (usname.contains(".")) {
usname = usname.substring(usname.lastIndexOf('.') + 1);
}
//??
/*if (newimport.contains(":")) {
return true;
}*/
DottedChain pkg = newimport.getWithoutLast();
String usname = newimport.getLast();
if (ns.kind == Namespace.KIND_PACKAGE) {
if (!pkg.equals(ignorePackage)) {
if (!pkg.equals("__AS3__.vec")) { //Automatic import
if (!pkg.toString().equals("__AS3__.vec")) { //Automatic import
imports.add(newimport);
}
}
@@ -161,38 +159,39 @@ public class TraitClass extends Trait implements TraitWithSlot {
return false;
}
private void parseImportsUsagesFromNS(ABC abc, List<String> imports, List<String> uses, int namespace_index, String ignorePackage, String name) {
private void parseImportsUsagesFromNS(ABC abc, List<DottedChain> imports, List<String> uses, int namespace_index, String ignorePackage, String name) {
Namespace ns = abc.constants.getNamespace(namespace_index);
if (name.isEmpty()) {
name = "*";
}
String newimport = ns.getName(abc.constants, false);
String niS = ns.getName(abc.constants, false);
DottedChain newimport = niS == null ? new DottedChain() : new DottedChain(niS.split("\\."));
if (parseUsagesFromNS(abc, imports, uses, namespace_index, ignorePackage, name)) {
return;
} else if ((ns.kind != Namespace.KIND_PACKAGE) && (ns.kind != Namespace.KIND_PACKAGE_INTERNAL)) {
return;
}
if (newimport == null) {
newimport = "";
}
//if (!newimport.equals("")) {
newimport += "." + name;
if (newimport.contains(":")) {
return;
if (newimport.parts.isEmpty()) {
newimport = new DottedChain("");
}
newimport.parts.add(name);
//WUT?
/*if (newimport.contains(":")) {
return;
}*/
if (!imports.contains(newimport)) {
String pkg = newimport.substring(0, newimport.lastIndexOf('.'));
if (pkg.equals("__AS3__.vec")) { //special case - is imported always
DottedChain pkg = newimport.getWithoutLast(); //.substring(0, newimport.lastIndexOf('.'));
if (pkg.toString().equals("__AS3__.vec")) { //special case - is imported always
return;
}
if (!pkg.equals(ignorePackage)) {
if (!pkg.toString().equals(ignorePackage)) {
imports.add(newimport);
}
}
//}
}
private void parseUsagesFromMultiname(ABC abc, List<String> imports, List<String> uses, Multiname m, String ignorePackage, List<String> fullyQualifiedNames) {
private void parseUsagesFromMultiname(ABC abc, List<DottedChain> imports, List<String> uses, Multiname m, String ignorePackage, List<String> fullyQualifiedNames) {
if (m != null) {
if (m.kind == Multiname.TYPENAME) {
if (m.qname_index != 0) {
@@ -223,7 +222,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
}
}
private void parseImportsUsagesFromMultiname(ABC abc, List<String> imports, List<String> uses, Multiname m, String ignorePackage, List<String> fullyQualifiedNames) {
private void parseImportsUsagesFromMultiname(ABC abc, List<DottedChain> imports, List<String> uses, Multiname m, String ignorePackage, List<String> fullyQualifiedNames) {
if (m != null) {
if (m.kind == Multiname.TYPENAME) {
if (m.qname_index != 0) {
@@ -250,7 +249,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
}
}
private void parseImportsUsagesFromMethodInfo(ABC abc, int method_index, List<String> imports, List<String> uses, String ignorePackage, List<String> fullyQualifiedNames, List<Integer> visitedMethods) {
private void parseImportsUsagesFromMethodInfo(ABC abc, int method_index, List<DottedChain> imports, List<String> uses, String ignorePackage, List<String> fullyQualifiedNames, List<Integer> visitedMethods) {
if ((method_index < 0) || (method_index >= abc.method_info.size())) {
return;
}
@@ -270,6 +269,12 @@ public class TraitClass extends Trait implements TraitWithSlot {
parseImportsUsagesFromMultiname(abc, imports, uses, abc.constants.getMultiname(ex.type_index), ignorePackage, fullyQualifiedNames);
}
for (AVM2Instruction ins : body.getCode().code) {
if (ins.definition instanceof AlchemyTypeIns) {
DottedChain nimport = new DottedChain((AlchemyTypeIns.ALCHEMY_PACKAGE + "." + ins.definition.instructionName).split("\\."));
if (!imports.contains(nimport)) {
imports.add(nimport);
}
}
if (ins.definition instanceof NewFunctionIns) {
if (ins.operands[0] != method_index) {
if (!visitedMethods.contains(ins.operands[0])) {
@@ -299,13 +304,13 @@ public class TraitClass extends Trait implements TraitWithSlot {
}
}
private void parseImportsUsagesFromTraits(ABC abc, Traits ts, List<String> imports, List<String> uses, String ignorePackage, List<String> fullyQualifiedNames) {
private void parseImportsUsagesFromTraits(ABC abc, Traits ts, List<DottedChain> imports, List<String> uses, String ignorePackage, List<String> fullyQualifiedNames) {
for (Trait t : ts.traits) {
parseImportsUsagesFromTrait(abc, t, imports, uses, ignorePackage, fullyQualifiedNames);
}
}
private void parseImportsUsagesFromTrait(ABC abc, Trait t, List<String> imports, List<String> uses, String ignorePackage, List<String> fullyQualifiedNames) {
private void parseImportsUsagesFromTrait(ABC abc, Trait t, List<DottedChain> imports, List<String> uses, String ignorePackage, List<String> fullyQualifiedNames) {
if (t instanceof TraitMethodGetterSetter) {
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t;
parseImportsUsagesFromMultiname(abc, imports, uses, abc.constants.getMultiname(tm.name_index), ignorePackage, fullyQualifiedNames);
@@ -321,7 +326,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
}
}
private List<String> getImportsUsages(ABC abc, List<String> imports, List<String> uses, List<String> fullyQualifiedNames) {
private List<DottedChain> getImportsUsages(ABC abc, List<DottedChain> imports, List<String> uses, List<String> fullyQualifiedNames) {
//constructor
String packageName = abc.instance_info.get(class_info).getName(abc.constants).getNamespace(abc.constants).getName(abc.constants, false); //assume not null name
@@ -377,7 +382,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
}
//imports
List<String> imports = new ArrayList<>();
List<DottedChain> imports = new ArrayList<>();
List<String> uses = new ArrayList<>();
getImportsUsages(abc, imports, uses, new ArrayList<>());
@@ -385,20 +390,16 @@ public class TraitClass extends Trait implements TraitWithSlot {
List<String> importnames = new ArrayList<>();
importnames.addAll(namesInThisPackage);
for (String ipath : imports) {
String name = ipath;
String pkg = "";
if (name.contains(".")) {
pkg = name.substring(0, name.lastIndexOf('.'));
name = name.substring(name.lastIndexOf('.') + 1);
}
if (importnames.contains(name) || ((!pkg.isEmpty()) && isBuiltInClass(name))) {
for (DottedChain ipath : imports) {
String name = ipath.getLast();
DottedChain pkg = ipath.getWithoutLast();
if (importnames.contains(name) || ((!pkg.toString().isEmpty()) && isBuiltInClass(name))) {
fullyQualifiedNames.add(name);
} else {
importnames.add(name);
}
}
/*List<String> imports2 = new ArrayList<>();
/*List<DottedChain> imports2 = new ArrayList<String>();
for (String path : imports) {
String name = path;
String pkg = "";
@@ -414,21 +415,23 @@ public class TraitClass extends Trait implements TraitWithSlot {
imports = imports2;*/
for (int i = 0; i < imports.size(); i++) {
String imp = imports.get(i);
String pkg = imp.substring(0, imp.lastIndexOf('.'));
String name = imp.substring(imp.lastIndexOf('.') + 1);
DottedChain imp = imports.get(i);
DottedChain pkg = imp.getWithoutLast(); //imp.substring(0, imp.lastIndexOf('.'));
String name = imp.getLast();//imp.substring(imp.lastIndexOf('.') + 1);
if (name.equals("*")) {
continue;
}
if (imports.contains(pkg + ".*")) {
DottedChain dAll = new DottedChain(pkg.parts);
dAll.parts.add("*");
if (imports.contains(dAll)) {
imports.remove(i);
i--;
}
}
boolean hasImport = false;
for (String imp : imports) {
if (!imp.startsWith(".")) {
for (DottedChain imp : imports) {
if (!imp.parts.get(0).isEmpty()) { //No imports from root package
writer.appendNoHilight("import " + imp + ";").newLine();
hasImport = true;
}

View File

@@ -30,6 +30,6 @@ public class ClassNameMultinameUsage extends InsideClassMultinameUsage implement
@Override
public String toString() {
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants, false);
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants).toPrintableString();
}
}

View File

@@ -36,7 +36,7 @@ public abstract class InsideClassMultinameUsage extends MultinameUsage {
@Override
public String toString() {
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants, false);
return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants).toPrintableString();
}
public int getMultinameIndex() {

View File

@@ -74,8 +74,9 @@ import com.jpexs.decompiler.graph.model.CommentItem;
import com.jpexs.decompiler.graph.model.IfItem;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.NotItem;
import com.jpexs.decompiler.graph.model.ScriptEndItem;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.decompiler.graph.model.PopItem;
import com.jpexs.decompiler.graph.model.ScriptEndItem;
import com.jpexs.helpers.CancellableWorker;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
@@ -996,9 +997,15 @@ public abstract class Action implements GraphSourceItem {
List<GraphTargetItem> tryCommands = ActionGraph.translateViaGraph(registerNames, variables, functions, atry.tryBody, version);
ActionItem catchName;
if (atry.catchInRegisterFlag) {
<<<<<<< HEAD
catchName = new DirectValueActionItem(atry, -1, new RegisterNumber(atry.catchRegister), new ArrayList<>());
} else {
catchName = new DirectValueActionItem(atry, -1, atry.catchName, new ArrayList<>());
=======
catchName = new DirectValueActionItem(atry, -1, new RegisterNumber(atry.catchRegister), new ArrayList<String>());
} else {
catchName = new DirectValueActionItem(atry, -1, atry.catchName, new ArrayList<String>());
>>>>>>> v6
}
List<GraphTargetItem> catchExceptions = new ArrayList<GraphTargetItem>();
catchExceptions.add(catchName);
@@ -1145,9 +1152,8 @@ public abstract class Action implements GraphSourceItem {
className = getWithoutGlobal(nti.value);
if (parts.size() >= 1) {
int ipos = 0;
while ((parts.get(ipos) instanceof IfItem)
&& ((((IfItem) parts.get(ipos)).onTrue.size() == 1) && (((IfItem) parts.get(ipos)).onTrue.get(0) instanceof SetMemberActionItem) && (((SetMemberActionItem) ((IfItem) parts.get(ipos)).onTrue.get(0)).value instanceof NewObjectActionItem))) {
while ((parts.get(ipos) instanceof PopItem) || ((parts.get(ipos) instanceof IfItem) && ((((IfItem) parts.get(ipos)).onTrue.size() == 1) && (((IfItem) parts.get(ipos)).onTrue.get(0) instanceof SetMemberActionItem) && (((SetMemberActionItem) ((IfItem) parts.get(ipos)).onTrue.get(0)).value instanceof NewObjectActionItem)))) {
ipos++;
}
if (parts.get(ipos) instanceof ExtendsActionItem) {
@@ -1256,7 +1262,7 @@ public abstract class Action implements GraphSourceItem {
} else {
ok = false;
}
} else {
} else if (!(t instanceof PopItem)) {
prevCount++;
//ok = false;
}

View File

@@ -47,11 +47,13 @@ import com.jpexs.decompiler.graph.Loop;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.BreakItem;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.PopItem;
import com.jpexs.decompiler.graph.model.SwitchItem;
import com.jpexs.decompiler.graph.model.WhileItem;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
@@ -94,7 +96,6 @@ public class ActionGraph extends Graph {
@Override
protected void finalProcess(List<GraphTargetItem> list, int level, FinalProcessLocalData localData) {
super.finalProcess(list, level, localData);
List<GraphTargetItem> ret = Action.checkClass(list);
if (ret != list) {
list.clear();
@@ -120,7 +121,7 @@ public class ActionGraph extends Graph {
break;
}
} else {
target = new DirectValueActionItem(null, 0, st.target, new ArrayList<>());
target = new DirectValueActionItem(null, 0, st.target, new ArrayList<String>());
targetStart = t;
targetStartItem = it;
}
@@ -157,9 +158,8 @@ public class ActionGraph extends Graph {
again = true;
}
} while (again);
for (int t = 0; t < list.size(); t++) {
for (int t = 1/*not first*/; t < list.size(); t++) {
GraphTargetItem it = list.get(t);
if (it instanceof WhileItem) {
WhileItem wi = (WhileItem) it;
if ((!wi.commands.isEmpty()) && (wi.commands.get(0) instanceof SetTypeActionItem)) {
@@ -169,24 +169,26 @@ public class ActionGraph extends Graph {
if (ne.rightSide instanceof DirectValueActionItem) {
DirectValueActionItem dv = (DirectValueActionItem) ne.rightSide;
if (dv.value instanceof Null) {
GraphTargetItem en = ne.leftSide;
if (en instanceof StoreRegisterActionItem) {
en = ((StoreRegisterActionItem) en).value;
}
GraphTargetItem en = list.get(t - 1);
if (en instanceof EnumerateActionItem) {
EnumerateActionItem eti = (EnumerateActionItem) en;
list.remove(t);
wi.commands.remove(0);
list.add(t, new ForInActionItem(null, wi.loop, sti.getObject(), eti.object, wi.commands));
list.remove(t - 1);
t--;
}
}
}
}
}
}
}
//detectChained(list, temporaryRegisters);
//Handle for loops at the end:
super.finalProcess(list, level, localData);
}
@Override
@@ -247,7 +249,7 @@ public class ActionGraph extends Graph {
}
@Override
protected List<GraphTargetItem> check(GraphSource code, BaseLocalData localData, List<GraphPart> allParts, TranslateStack stack, GraphPart parent, GraphPart part, List<GraphPart> stopPart, List<Loop> loops, List<GraphTargetItem> output, Loop currentLoop, int staticOperation, String path) throws InterruptedException {
protected List<GraphTargetItem> check(Map<GraphPart, List<GraphTargetItem>> partCodes, Map<GraphPart, Integer> partCodePos, GraphSource code, BaseLocalData localData, List<GraphPart> allParts, TranslateStack stack, GraphPart parent, GraphPart part, List<GraphPart> stopPart, List<Loop> loops, List<GraphTargetItem> output, Loop currentLoop, int staticOperation, String path) throws InterruptedException {
if (!output.isEmpty()) {
if (output.get(output.size() - 1) instanceof StoreRegisterActionItem) {
StoreRegisterActionItem str = (StoreRegisterActionItem) output.get(output.size() - 1);
@@ -310,7 +312,7 @@ public class ActionGraph extends Graph {
List<GraphTargetItem> defaultCommands = new ArrayList<>();
List<GraphPart> stopPart2 = new ArrayList<>(stopPart);
stopPart2.add(defaultPart2);
defaultCommands = printGraph(localData, stack, allParts, null, defaultPart, stopPart2, loops, staticOperation, path);
defaultCommands = printGraph(partCodes, partCodePos, localData, stack, allParts, null, defaultPart, stopPart2, loops, staticOperation, path);
List<GraphPart> loopContinues = new ArrayList<>();
for (Loop l : loops) {
@@ -384,7 +386,7 @@ public class ActionGraph extends Graph {
if ((defaultPart != null) && (defaultCommands.isEmpty())) {
List<GraphPart> stopPart2x = new ArrayList<>(stopPart);
stopPart2x.add(next);
defaultCommands = printGraph(localData, stack, allParts, null, defaultPart, stopPart2x, loops, staticOperation, path);
defaultCommands = printGraph(partCodes, partCodePos, localData, stack, allParts, null, defaultPart, stopPart2x, loops, staticOperation, path);
}
if (!defaultCommands.isEmpty()) {
@@ -433,7 +435,7 @@ public class ActionGraph extends Graph {
if (breakPart != null) {
stopPart2x.add(breakPart);
}
cc.addAll(0, printGraph(localData, stack, allParts, null, caseBodies.get(i), stopPart2x, loops, staticOperation, path));
cc.addAll(0, printGraph(partCodes, partCodePos, localData, stack, allParts, null, caseBodies.get(i), stopPart2x, loops, staticOperation, path));
if (cc.size() >= 2) {
if (cc.get(cc.size() - 1) instanceof BreakItem) {
if ((cc.get(cc.size() - 2) instanceof ContinueItem) || (cc.get(cc.size() - 2) instanceof BreakItem)) {
@@ -452,7 +454,7 @@ public class ActionGraph extends Graph {
if (ti != null) {
ret.add(ti);
} else {
ret.addAll(printGraph(localData, stack, allParts, null, next, stopPart, loops, staticOperation, path));
ret.addAll(printGraph(partCodes, partCodePos, localData, stack, allParts, null, next, stopPart, loops, staticOperation, path));
}
}
}

View File

@@ -296,7 +296,7 @@ public class ActionListReader {
new ArrayList<GraphTargetItem>(),
new HashMap<Long, List<GraphSourceItemContainer>>(),
new ActionLocalData(),
new TranslateStack(),
new TranslateStack(path),
new ConstantPool(),
actionMap, ip, retMap, ip, endIp, path,
new HashMap<Integer, Integer>(), false,
@@ -888,10 +888,10 @@ public class ActionListReader {
} else if (!(a instanceof GraphSourceItemContainer)) {
//return in for..in, TODO:Handle this better way
if (((a instanceof ActionEquals) || (a instanceof ActionEquals2)) && (stack.size() == 1) && (stack.peek() instanceof DirectValueActionItem)) {
stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList<>()));
stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList<String>()));
}
if ((a instanceof ActionStoreRegister) && stack.isEmpty()) {
stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList<>()));
stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList<String>()));
}
a.translate(localData, stack, output, Graph.SOP_USE_STATIC/*Graph.SOP_SKIP_STATIC*/, path);
}
@@ -930,7 +930,7 @@ public class ActionListReader {
} else {
localData2 = localData;
}
deobfustaceActionListAtPosRecursive(listeners, output2, containers, localData2, new TranslateStack(), cpool, actions, (int) endAddr, ret, startIp, (int) (endAddr + size), path + (cntName == null ? "" : "/" + cntName), visited, indeterminate, decisionStates, version, recursionLevel + 1, maxRecursionLevel);
deobfustaceActionListAtPosRecursive(listeners, output2, containers, localData2, new TranslateStack(path), cpool, actions, (int) endAddr, ret, startIp, (int) (endAddr + size), path + (cntName == null ? "" : "/" + cntName), visited, indeterminate, decisionStates, version, recursionLevel + 1, maxRecursionLevel);
output2s.add(output2);
endAddr += size;
}

View File

@@ -231,7 +231,7 @@ public class ActionDeobfuscator extends ActionDeobfuscatorSimple {
private void executeActions(ActionList actions, int idx, int endIdx, ActionConstantPool constantPool, ExecutionResult result, Map<String, Object> fakeFunctions) {
List<GraphTargetItem> output = new ArrayList<>();
ActionLocalData localData = new ActionLocalData();
FixItemCounterTranslateStack stack = new FixItemCounterTranslateStack();
FixItemCounterTranslateStack stack = new FixItemCounterTranslateStack("");
int instructionsProcessed = 0;
ActionConstantPool lastConstantPool = null;
@@ -450,7 +450,7 @@ public class ActionDeobfuscator extends ActionDeobfuscatorSimple {
public Set<String> defines = new HashSet<>();
public TranslateStack stack = new TranslateStack();
public TranslateStack stack = new TranslateStack("?");
public Object resultValue;
}

View File

@@ -273,7 +273,7 @@ public class ActionDeobfuscatorSimple implements SWFDecompilerListener {
private void executeActions(ActionList actions, int idx, int endIdx, ExecutionResult result) {
List<GraphTargetItem> output = new ArrayList<>();
ActionLocalData localData = new ActionLocalData();
FixItemCounterTranslateStack stack = new FixItemCounterTranslateStack();
FixItemCounterTranslateStack stack = new FixItemCounterTranslateStack("");
int instructionsProcessed = 0;
try {
@@ -388,7 +388,7 @@ public class ActionDeobfuscatorSimple implements SWFDecompilerListener {
public int instructionsProcessed = -1;
public TranslateStack stack = new TranslateStack();
public TranslateStack stack = new TranslateStack("?");
public Object resultValue;
}

View File

@@ -1,18 +1,19 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.deobfuscation;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -26,6 +27,10 @@ public class FixItemCounterTranslateStack extends TranslateStack {
private int fixItemCount = Integer.MAX_VALUE;
public FixItemCounterTranslateStack(String path) {
super(null); //null path => do not add PushItems
}
@Override
public GraphTargetItem pop() {
GraphTargetItem result = super.pop();

View File

@@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SimpleValue;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.helpers.Helper;
@@ -34,7 +35,7 @@ import java.util.List;
import java.util.Objects;
import java.util.Set;
public class DirectValueActionItem extends ActionItem {
public class DirectValueActionItem extends ActionItem implements SimpleValue {
public Object value;
@@ -91,6 +92,11 @@ public class DirectValueActionItem extends ActionItem {
return value;
}
@Override
public boolean isSimpleValue() {
return !(value instanceof RegisterNumber);
}
@Override
public String toStringNoQuotes(LocalData localData) {
if (value instanceof Double) {

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
@@ -41,8 +42,9 @@ public class EnumerateActionItem extends ActionItem {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
writer.append("enumerate ");
writer.append("§§enumerate(");
object.toString(writer, localData);
return writer.append(")");
}
@Override

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -48,7 +49,7 @@ public class EqActionItem extends BinaryOpItem implements LogicalOpItem {
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem neqSrc) {
return new NeqActionItem(src, leftSide, rightSide, version2);
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -58,7 +59,7 @@ public class GeActionItem extends BinaryOpItem implements LogicalOpItem, Inverte
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new LtActionItem(src, leftSide, rightSide, version2);
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -42,7 +43,7 @@ public class GtActionItem extends BinaryOpItem implements LogicalOpItem {
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem neqSrc) {
return new LeActionItem(src, leftSide, rightSide);
}

View File

@@ -12,9 +12,11 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model.operations;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
/**
@@ -23,5 +25,5 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
*/
public interface Inverted {
public GraphTargetItem invert(GraphSourceItem src);
}

View File

@@ -50,7 +50,7 @@ public class LeActionItem extends BinaryOpItem implements LogicalOpItem, Inverte
return ret;//undefined
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new GtActionItem(src, leftSide, rightSide);
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -50,7 +51,7 @@ public class LtActionItem extends BinaryOpItem implements LogicalOpItem {
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem neqSrc) {
return new GeActionItem(src, leftSide, rightSide, version2);
}

View File

@@ -49,7 +49,7 @@ public class NeqActionItem extends BinaryOpItem implements LogicalOpItem, Invert
}
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new EqActionItem(src, leftSide, rightSide, version2);
}

View File

@@ -42,7 +42,7 @@ public class StrictEqActionItem extends BinaryOpItem implements LogicalOpItem, I
&& EcmaScript.equals(x, y);
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new StrictNeqActionItem(src, leftSide, rightSide);
}

View File

@@ -43,7 +43,7 @@ public class StrictNeqActionItem extends BinaryOpItem implements LogicalOpItem,
|| (!EcmaScript.equals(x, y));
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new StrictEqActionItem(src, leftSide, rightSide);
}

View File

@@ -48,7 +48,7 @@ public class StringEqActionItem extends BinaryOpItem implements Inverted {
return TypeItem.BOOLEAN;
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new StringNeActionItem(src, leftSide, rightSide);
}

View File

@@ -49,7 +49,7 @@ public class StringGeActionItem extends BinaryOpItem implements Inverted {
return TypeItem.BOOLEAN;
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new StringLtActionItem(src, leftSide, rightSide);
}

View File

@@ -54,7 +54,7 @@ public class StringGtActionItem extends BinaryOpItem implements Inverted {
return TypeItem.BOOLEAN;
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new StringLeActionItem(src, leftSide, rightSide);
}

View File

@@ -57,7 +57,7 @@ public class StringLeActionItem extends BinaryOpItem implements Inverted {
return TypeItem.BOOLEAN;
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new StringGtActionItem(src, leftSide, rightSide);
}

View File

@@ -48,7 +48,7 @@ public class StringLtActionItem extends BinaryOpItem implements Inverted {
return TypeItem.BOOLEAN;
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new StringGeActionItem(src, leftSide, rightSide);
}

View File

@@ -49,7 +49,7 @@ public class StringNeActionItem extends BinaryOpItem implements Inverted {
return TypeItem.BOOLEAN;
}
@Override
@Override
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new StringEqActionItem(src, leftSide, rightSide);
}

View File

@@ -56,12 +56,14 @@ import com.jpexs.decompiler.graph.model.CommaExpressionItem;
import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.DoWhileItem;
import com.jpexs.decompiler.graph.model.DuplicateItem;
import com.jpexs.decompiler.graph.model.FalseItem;
import com.jpexs.decompiler.graph.model.ForItem;
import com.jpexs.decompiler.graph.model.IfItem;
import com.jpexs.decompiler.graph.model.NotItem;
import com.jpexs.decompiler.graph.model.OrItem;
import com.jpexs.decompiler.graph.model.SwitchItem;
import com.jpexs.decompiler.graph.model.TernarOpItem;
import com.jpexs.decompiler.graph.model.TrueItem;
import com.jpexs.decompiler.graph.model.WhileItem;
import com.jpexs.helpers.Helper;
import java.util.ArrayList;
@@ -74,6 +76,16 @@ import java.util.List;
*/
public class ActionSourceGenerator implements SourceGenerator {
@Override
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, FalseItem item) throws CompilationException {
return GraphTargetItem.toSourceMerge(localData, this, new ActionPush(Boolean.FALSE));
}
@Override
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, TrueItem item) throws CompilationException {
return GraphTargetItem.toSourceMerge(localData, this, new ActionPush(Boolean.TRUE));
}
@Override
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, AndItem item) throws CompilationException {
List<GraphSourceItem> ret = new ArrayList<>();
@@ -122,7 +134,7 @@ public class ActionSourceGenerator implements SourceGenerator {
private List<GraphSourceItem> generateIf(SourceGeneratorLocalData localData, GraphTargetItem expression, List<GraphTargetItem> onTrueCmds, List<GraphTargetItem> onFalseCmds, boolean ternar) throws CompilationException {
List<GraphSourceItem> ret = new ArrayList<>();
if (expression instanceof Inverted) {
ret.addAll(((Inverted) expression).invert().toSource(localData, this));
ret.addAll(((Inverted) expression).invert(null).toSource(localData, this));
} else {
ret.addAll(expression.toSource(localData, this));
ret.add(new ActionNot());
@@ -400,7 +412,7 @@ public class ActionSourceGenerator implements SourceGenerator {
@Override
public List<GraphSourceItem> generate(SourceGeneratorLocalData localData, NotItem item) throws CompilationException {
if (item.getOriginal() instanceof Inverted) {
GraphTargetItem norig = ((Inverted) item).invert();
GraphTargetItem norig = ((Inverted) item).invert(null);
return norig.toSource(localData, this);
}
List<GraphSourceItem> ret = new ArrayList<>();
@@ -570,7 +582,7 @@ public class ActionSourceGenerator implements SourceGenerator {
} while (item instanceof GetMemberActionItem);
if (item instanceof GetVariableActionItem) {
GetVariableActionItem v = (GetVariableActionItem) item;
item = new GetMemberActionItem(null, new GetVariableActionItem(null, new DirectValueActionItem(null, 0, "_global", new ArrayList<>())), v.name);
item = new GetMemberActionItem(null, new GetVariableActionItem(null, new DirectValueActionItem(null, 0, "_global", new ArrayList<String>())), v.name);
if (mem != null) {
mem.object = item;
}
@@ -670,7 +682,7 @@ public class ActionSourceGenerator implements SourceGenerator {
if (constructor == null) {
List<Action> val = new ArrayList<>();
val.add(new ActionDefineFunction("", new ArrayList<>(), 0, SWF.DEFAULT_VERSION));
val.add(new ActionDefineFunction("", new ArrayList<String>(), 0, SWF.DEFAULT_VERSION));
if (!isInterface) {
val.add(new ActionStoreRegister(1));
}
@@ -722,7 +734,7 @@ public class ActionSourceGenerator implements SourceGenerator {
if (constr.isEmpty()) {
List<Action> val = new ArrayList<>();
val.add(new ActionDefineFunction("", new ArrayList<>(), 0, SWF.DEFAULT_VERSION));
val.add(new ActionDefineFunction("", new ArrayList<String>(), 0, SWF.DEFAULT_VERSION));
if (!isInterface) {
val.add(new ActionStoreRegister(1));
}

View File

@@ -1,18 +1,19 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.parser.script;
/**
@@ -32,5 +33,6 @@ public enum SymbolGroup {
TYPENAME,
EOF,
GLOBALFUNC,
GLOBALFUNC,
GLOBALCONST,
PREPROCESSOR
}

View File

@@ -185,7 +185,8 @@ public enum SymbolType {
PRINTASBITMAPNUM(GraphTargetItem.PRECEDENCE_PRIMARY, false),
UNLOADMOVIE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
UNLOADMOVIENUM(GraphTargetItem.PRECEDENCE_PRIMARY, false),
FSCOMMAND(GraphTargetItem.PRECEDENCE_PRIMARY, false);
FSCOMMAND(GraphTargetItem.PRECEDENCE_PRIMARY, false),
PREPROCESSOR(GraphTargetItem.PRECEDENCE_PRIMARY, false);
private int precedence = GraphTargetItem.NOPRECEDENCE;

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.swf4;
import com.jpexs.decompiler.flash.action.Action;
@@ -36,6 +37,6 @@ public class ActionNot extends Action {
@Override
public void translate(TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
GraphTargetItem a = stack.pop();
GraphTargetItem a = stack.pop();
stack.push(a.invert(this));
}
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.swf4;
import com.jpexs.decompiler.flash.action.Action;
@@ -35,13 +36,7 @@ public class ActionPop extends Action {
@Override
public void translate(TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
public void translate(TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
if (stack.isEmpty()) {
return;
GraphTargetItem val = stack.pop();
GraphTargetItem val = stack.pop();
if (val instanceof DirectValueActionItem) {
return;
output.add(val);
}
}

Some files were not shown because too many files have changed in this diff Show More