mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-28 18:10:43 +00:00
Stack handling improved - no more StackEmptyException
And/Or handling improved Preprocessor instructions introduced - §§pop,§§push...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,487 +1,487 @@
|
||||
/*
|
||||
* 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.action;
|
||||
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.FinalProcessLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.EnumerateActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.FunctionActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.SetTarget2ActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.SetTargetActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.SetTypeActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.clauses.ForInActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.clauses.TellTargetActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.NeqActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.StrictEqActionItem;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionEquals;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionIf;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionNot;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionEquals2;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
|
||||
import com.jpexs.decompiler.flash.action.swf6.ActionStrictEquals;
|
||||
import com.jpexs.decompiler.flash.ecma.Null;
|
||||
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.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.SwitchItem;
|
||||
import com.jpexs.decompiler.graph.model.WhileItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ActionGraph extends Graph {
|
||||
|
||||
public ActionGraph(List<Action> code, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int version) {
|
||||
super(new ActionGraphSource(code, version, registerNames, variables, functions), new ArrayList<Integer>());
|
||||
//this.version = version;
|
||||
/*heads = makeGraph(code, new ArrayList<GraphPart>());
|
||||
for (GraphPart head : heads) {
|
||||
fixGraph(head);
|
||||
makeMulti(head, new ArrayList<GraphPart>());
|
||||
}*/
|
||||
}
|
||||
|
||||
public static List<GraphTargetItem> translateViaGraph(HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, List<Action> code, int version, int staticOperation, String path) throws InterruptedException {
|
||||
|
||||
ActionGraph g = new ActionGraph(code, registerNames, variables, functions, version);
|
||||
ActionLocalData localData = new ActionLocalData(registerNames);
|
||||
g.init(localData);
|
||||
return g.translate(localData, staticOperation, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalProcessStack(TranslateStack stack, List<GraphTargetItem> output) {
|
||||
if (stack.size() > 0) {
|
||||
for (int i = stack.size() - 1; i >= 0; i--) {
|
||||
//System.err.println(stack.get(i));
|
||||
if (stack.get(i) instanceof FunctionActionItem) {
|
||||
FunctionActionItem f = (FunctionActionItem) stack.remove(i);
|
||||
if (!output.contains(f)) {
|
||||
output.add(0, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
list.addAll(ret);
|
||||
}
|
||||
int targetStart;
|
||||
int targetEnd;
|
||||
|
||||
boolean again;
|
||||
do {
|
||||
again = false;
|
||||
targetStart = -1;
|
||||
targetEnd = -1;
|
||||
GraphTargetItem targetStartItem = null;
|
||||
GraphTargetItem target = null;
|
||||
for (int t = 0; t < list.size(); t++) {
|
||||
GraphTargetItem it = list.get(t);
|
||||
if (it instanceof SetTargetActionItem) {
|
||||
SetTargetActionItem st = (SetTargetActionItem) it;
|
||||
if (st.target.isEmpty()) {
|
||||
if (targetStart > -1) {
|
||||
targetEnd = t;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
target = new DirectValueActionItem(null, 0, st.target, new ArrayList<>());
|
||||
targetStart = t;
|
||||
targetStartItem = it;
|
||||
}
|
||||
}
|
||||
if (it instanceof SetTarget2ActionItem) {
|
||||
SetTarget2ActionItem st = (SetTarget2ActionItem) it;
|
||||
if ((st.target instanceof DirectValueActionItem) && st.target.getResult().equals("")) {
|
||||
if (targetStart > -1) {
|
||||
targetEnd = t;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
targetStart = t;
|
||||
target = st.target;
|
||||
targetStartItem = it;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((targetStart > -1) && (targetEnd > -1)) {
|
||||
List<GraphTargetItem> newlist = new ArrayList<>();
|
||||
for (int i = 0; i < targetStart; i++) {
|
||||
newlist.add(list.get(i));
|
||||
}
|
||||
List<GraphTargetItem> tellist = new ArrayList<>();
|
||||
for (int i = targetStart + 1; i < targetEnd; i++) {
|
||||
tellist.add(list.get(i));
|
||||
}
|
||||
newlist.add(new TellTargetActionItem(targetStartItem.src, target, tellist));
|
||||
for (int i = targetEnd + 1; i < list.size(); i++) {
|
||||
newlist.add(list.get(i));
|
||||
}
|
||||
list.clear();
|
||||
list.addAll(newlist);
|
||||
again = true;
|
||||
}
|
||||
} while (again);
|
||||
for (int t = 0; 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)) {
|
||||
SetTypeActionItem sti = (SetTypeActionItem) wi.commands.get(0);
|
||||
if (wi.expression.get(wi.expression.size() - 1) instanceof NeqActionItem) {
|
||||
NeqActionItem ne = (NeqActionItem) wi.expression.get(wi.expression.size() - 1);
|
||||
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;
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//detectChained(list, temporaryRegisters);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<GraphPart> checkPrecoNextParts(GraphPart part) {
|
||||
List<GraphSourceItem> items = getPartItems(part);
|
||||
part = makeMultiPart(part);
|
||||
if (items.size() > 1) {
|
||||
if (items.get(items.size() - 1) instanceof ActionIf) {
|
||||
if (items.get(items.size() - 2) instanceof ActionStrictEquals) {
|
||||
List<Integer> storeRegisters = new ArrayList<>();
|
||||
for (GraphSourceItem s : items) {
|
||||
if (s instanceof ActionStoreRegister) {
|
||||
ActionStoreRegister sr = (ActionStoreRegister) s;
|
||||
storeRegisters.add(sr.registerNumber);
|
||||
}
|
||||
}
|
||||
if (!storeRegisters.isEmpty()) {
|
||||
List<GraphPart> caseBodies = new ArrayList<>();
|
||||
boolean proceed = false;
|
||||
do {
|
||||
proceed = false;
|
||||
caseBodies.add(part.nextParts.get(0)); //jump
|
||||
part = part.nextParts.get(1); //nojump
|
||||
items = getPartItems(part);
|
||||
part = makeMultiPart(part);
|
||||
if (!items.isEmpty()) {
|
||||
if (items.get(0) instanceof ActionPush) {
|
||||
ActionPush pu = (ActionPush) items.get(0);
|
||||
if (!pu.values.isEmpty()) {
|
||||
if (pu.values.get(0) instanceof RegisterNumber) {
|
||||
RegisterNumber rn = (RegisterNumber) pu.values.get(0);
|
||||
if (storeRegisters.contains(rn.number)) {
|
||||
storeRegisters.clear();
|
||||
storeRegisters.add(rn.number);
|
||||
if (items.get(items.size() - 1) instanceof ActionIf) {
|
||||
if (items.size() > 1) {
|
||||
if (items.get(items.size() - 2) instanceof ActionStrictEquals) {
|
||||
proceed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (proceed);
|
||||
|
||||
if (caseBodies.size() > 1) {
|
||||
caseBodies.add(part); //TODO: properly detect default clause (?)
|
||||
return caseBodies;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@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 {
|
||||
if (!output.isEmpty()) {
|
||||
if (output.get(output.size() - 1) instanceof StoreRegisterActionItem) {
|
||||
StoreRegisterActionItem str = (StoreRegisterActionItem) output.get(output.size() - 1);
|
||||
if (str.value instanceof EnumerateActionItem) {
|
||||
output.remove(output.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<GraphTargetItem> ret = null;
|
||||
if ((part.nextParts.size() == 2) && (!stack.isEmpty()) && (stack.peek() instanceof StrictEqActionItem)) {
|
||||
|
||||
GraphTargetItem switchedObject = null;
|
||||
if (!output.isEmpty()) {
|
||||
if (output.get(output.size() - 1) instanceof StoreRegisterActionItem) {
|
||||
switchedObject = ((StoreRegisterActionItem) output.get(output.size() - 1)).value;
|
||||
}
|
||||
}
|
||||
if (switchedObject == null) {
|
||||
switchedObject = new DirectValueActionItem(null, -1, new Null(), null);
|
||||
}
|
||||
HashMap<Integer, GraphTargetItem> caseValuesMap = new HashMap<>();
|
||||
|
||||
int pos = 0;
|
||||
StrictEqActionItem set = (StrictEqActionItem) stack.pop();
|
||||
caseValuesMap.put(pos, set.rightSide);
|
||||
if (set.leftSide instanceof StoreRegisterActionItem) {
|
||||
switchedObject = ((StoreRegisterActionItem) set.leftSide).value;
|
||||
}
|
||||
//GraphPart switchLoc = part.nextParts.get(1).nextParts.get(0);
|
||||
List<GraphPart> caseBodyParts = new ArrayList<>();
|
||||
caseBodyParts.add(part.nextParts.get(0));
|
||||
GraphTargetItem top = null;
|
||||
int cnt = 1;
|
||||
while (part.nextParts.size() > 1
|
||||
&& part.nextParts.get(1).getHeight() > 1
|
||||
&& code.get(part.nextParts.get(1).end >= code.size() ? code.size() - 1 : part.nextParts.get(1).end) instanceof ActionIf
|
||||
&& ((top = translatePartGetStack(localData, part.nextParts.get(1), stack, staticOperation)) instanceof StrictEqActionItem)) {
|
||||
cnt++;
|
||||
part = part.nextParts.get(1);
|
||||
pos++;
|
||||
caseBodyParts.add(part.nextParts.get(0));
|
||||
|
||||
set = (StrictEqActionItem) top;
|
||||
caseValuesMap.put(pos, set.rightSide);
|
||||
}
|
||||
if (cnt == 1) {
|
||||
stack.push(set);
|
||||
} else {
|
||||
part = part.nextParts.get(1);
|
||||
|
||||
GraphPart defaultPart = part; //21-21
|
||||
//caseBodyParts.add(defaultPart);
|
||||
|
||||
List<GraphPart> defaultAndLastPart = new ArrayList<>();
|
||||
defaultAndLastPart.add(defaultPart);
|
||||
defaultAndLastPart.add(caseBodyParts.get(caseBodyParts.size() - 1));
|
||||
|
||||
GraphPart defaultPart2 = getCommonPart(localData, defaultAndLastPart, loops);//34-37
|
||||
|
||||
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);
|
||||
|
||||
List<GraphPart> loopContinues = new ArrayList<>();
|
||||
for (Loop l : loops) {
|
||||
if (l.loopContinue != null) {
|
||||
loopContinues.add(l.loopContinue);
|
||||
}
|
||||
}
|
||||
|
||||
List<GraphPart> breakParts = new ArrayList<>();
|
||||
/*for (int g = 0; g < caseBodyParts.size(); g++) {
|
||||
if (g < caseBodyParts.size() - 1) {
|
||||
if (caseBodyParts.get(g).leadsTo(code, caseBodyParts.get(g + 1), loops)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
GraphPart nsp = caseBodyParts.get(g).getNextSuperPartPath(loopContinues);
|
||||
if (nsp != null) {
|
||||
breakParts.add(nsp);
|
||||
}
|
||||
}
|
||||
Collections.sort(breakParts, new Comparator<GraphPart>() {
|
||||
@Override
|
||||
public int compare(GraphPart o1, GraphPart o2) {
|
||||
return o2.path.length() - o1.path.length();
|
||||
}
|
||||
});*/
|
||||
|
||||
//GraphPart breakPart = breakParts.isEmpty() ? null : breakParts.get(0);
|
||||
List<GraphPart> mcp = new ArrayList<>();
|
||||
mcp.addAll(caseBodyParts);
|
||||
if (defaultPart2 != null) {
|
||||
mcp.add(defaultPart2);
|
||||
}
|
||||
GraphPart breakPart = getMostCommonPart(localData, mcp, loops);
|
||||
if ((defaultPart2 != breakPart) && (defaultCommands.isEmpty())) {
|
||||
defaultPart = defaultPart2;
|
||||
}
|
||||
|
||||
List<GraphTargetItem> caseValues = new ArrayList<>();
|
||||
for (int i = 0; i < caseBodyParts.size(); i++) {
|
||||
if (caseValuesMap.containsKey(i)) {
|
||||
caseValues.add(caseValuesMap.get(i));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
List<List<GraphTargetItem>> caseCommands = new ArrayList<>();
|
||||
GraphPart next = null;
|
||||
|
||||
next = breakPart;
|
||||
|
||||
GraphTargetItem ti = checkLoop(next, stopPart, loops);
|
||||
currentLoop = new Loop(loops.size(), null, next);
|
||||
currentLoop.phase = 1;
|
||||
loops.add(currentLoop);
|
||||
//switchLoc.getNextPartPath(new ArrayList<GraphPart>());
|
||||
List<Integer> valuesMapping = new ArrayList<>();
|
||||
List<GraphPart> caseBodies = new ArrayList<>();
|
||||
for (int i = 0; i < caseValues.size(); i++) {
|
||||
GraphPart cur = caseBodyParts.get(i);
|
||||
if (!caseBodies.contains(cur)) {
|
||||
caseBodies.add(cur);
|
||||
}
|
||||
valuesMapping.add(caseBodies.indexOf(cur));
|
||||
}
|
||||
|
||||
if (defaultPart == breakPart) {
|
||||
defaultPart = null;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
if (!defaultCommands.isEmpty()) {
|
||||
if (defaultCommands.get(defaultCommands.size() - 1) instanceof BreakItem) {
|
||||
BreakItem bi = (BreakItem) defaultCommands.get(defaultCommands.size() - 1);
|
||||
if (bi.loopId == currentLoop.id) {
|
||||
defaultCommands.remove(defaultCommands.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<GraphPart> ignored = new ArrayList<>();
|
||||
for (Loop l : loops) {
|
||||
ignored.add(l.loopContinue);
|
||||
}
|
||||
|
||||
for (int i = 0; i < caseBodies.size(); i++) {
|
||||
List<GraphTargetItem> cc = new ArrayList<>();
|
||||
GraphPart nextCase = null;
|
||||
nextCase = next;
|
||||
if (next != null) {
|
||||
if (i < caseBodies.size() - 1) {
|
||||
if (!caseBodies.get(i).leadsTo(localData, this, code, caseBodies.get(i + 1), loops)) {
|
||||
cc.add(new BreakItem(null, currentLoop.id));
|
||||
} else {
|
||||
nextCase = caseBodies.get(i + 1);
|
||||
}
|
||||
} else if (!defaultCommands.isEmpty()) {
|
||||
if (!caseBodies.get(i).leadsTo(localData, this, code, defaultPart, loops)) {
|
||||
cc.add(new BreakItem(null, currentLoop.id));
|
||||
} else {
|
||||
nextCase = defaultPart;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<GraphPart> stopPart2x = new ArrayList<>(stopPart);
|
||||
//stopPart2.add(nextCase);
|
||||
for (GraphPart b : caseBodies) {
|
||||
if (b != caseBodies.get(i)) {
|
||||
stopPart2x.add(b);
|
||||
}
|
||||
}
|
||||
if (defaultPart != null) {
|
||||
stopPart2x.add(defaultPart);
|
||||
}
|
||||
if (breakPart != null) {
|
||||
stopPart2x.add(breakPart);
|
||||
}
|
||||
cc.addAll(0, printGraph(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)) {
|
||||
cc.remove(cc.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
caseCommands.add(cc);
|
||||
}
|
||||
ret = new ArrayList<>();
|
||||
ret.addAll(output);
|
||||
SwitchItem sti = new SwitchItem(null, currentLoop, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping);
|
||||
ret.add(sti);
|
||||
currentLoop.phase = 2;
|
||||
if (next != null) {
|
||||
if (ti != null) {
|
||||
ret.add(ti);
|
||||
} else {
|
||||
ret.addAll(printGraph(localData, stack, allParts, null, next, stopPart, loops, staticOperation, path));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int checkIp(int ip) {
|
||||
int oldIp = ip;
|
||||
//return in for..in
|
||||
GraphSourceItem action = code.get(ip);
|
||||
if ((action instanceof ActionPush) && (((ActionPush) action).values.size() == 1) && (((ActionPush) action).values.get(0) instanceof Null)) {
|
||||
if (ip + 3 < code.size()) {
|
||||
if ((code.get(ip + 1) instanceof ActionEquals) || (code.get(ip + 1) instanceof ActionEquals2)) {
|
||||
if (code.get(ip + 2) instanceof ActionNot) {
|
||||
if (code.get(ip + 3) instanceof ActionIf) {
|
||||
ActionIf aif = (ActionIf) code.get(ip + 3);
|
||||
if (code.adr2pos(code.pos2adr(ip + 4) + aif.getJumpOffset()) == ip) {
|
||||
ip += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (oldIp != ip) {
|
||||
return checkIp(ip);
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.action;
|
||||
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.FinalProcessLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.EnumerateActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.FunctionActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.SetTarget2ActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.SetTargetActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.SetTypeActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.clauses.ForInActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.clauses.TellTargetActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.NeqActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.StrictEqActionItem;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionEquals;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionIf;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionNot;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionEquals2;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
|
||||
import com.jpexs.decompiler.flash.action.swf6.ActionStrictEquals;
|
||||
import com.jpexs.decompiler.flash.ecma.Null;
|
||||
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.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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ActionGraph extends Graph {
|
||||
|
||||
public ActionGraph(List<Action> code, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int version) {
|
||||
super(new ActionGraphSource(code, version, registerNames, variables, functions), new ArrayList<Integer>());
|
||||
//this.version = version;
|
||||
/*heads = makeGraph(code, new ArrayList<GraphPart>());
|
||||
for (GraphPart head : heads) {
|
||||
fixGraph(head);
|
||||
makeMulti(head, new ArrayList<GraphPart>());
|
||||
}*/
|
||||
}
|
||||
|
||||
public static List<GraphTargetItem> translateViaGraph(HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, List<Action> code, int version, int staticOperation, String path) throws InterruptedException {
|
||||
|
||||
ActionGraph g = new ActionGraph(code, registerNames, variables, functions, version);
|
||||
ActionLocalData localData = new ActionLocalData(registerNames);
|
||||
g.init(localData);
|
||||
return g.translate(localData, staticOperation, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalProcessStack(TranslateStack stack, List<GraphTargetItem> output) {
|
||||
if (stack.size() > 0) {
|
||||
for (int i = stack.size() - 1; i >= 0; i--) {
|
||||
//System.err.println(stack.get(i));
|
||||
if (stack.get(i) instanceof FunctionActionItem) {
|
||||
FunctionActionItem f = (FunctionActionItem) stack.remove(i);
|
||||
if (!output.contains(f)) {
|
||||
output.add(0, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalProcess(List<GraphTargetItem> list, int level, FinalProcessLocalData localData) {
|
||||
List<GraphTargetItem> ret = Action.checkClass(list);
|
||||
if (ret != list) {
|
||||
list.clear();
|
||||
list.addAll(ret);
|
||||
}
|
||||
int targetStart;
|
||||
int targetEnd;
|
||||
|
||||
boolean again;
|
||||
do {
|
||||
again = false;
|
||||
targetStart = -1;
|
||||
targetEnd = -1;
|
||||
GraphTargetItem targetStartItem = null;
|
||||
GraphTargetItem target = null;
|
||||
for (int t = 0; t < list.size(); t++) {
|
||||
GraphTargetItem it = list.get(t);
|
||||
if (it instanceof SetTargetActionItem) {
|
||||
SetTargetActionItem st = (SetTargetActionItem) it;
|
||||
if (st.target.isEmpty()) {
|
||||
if (targetStart > -1) {
|
||||
targetEnd = t;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
target = new DirectValueActionItem(null, 0, st.target, new ArrayList<String>());
|
||||
targetStart = t;
|
||||
targetStartItem = it;
|
||||
}
|
||||
}
|
||||
if (it instanceof SetTarget2ActionItem) {
|
||||
SetTarget2ActionItem st = (SetTarget2ActionItem) it;
|
||||
if ((st.target instanceof DirectValueActionItem) && st.target.getResult().equals("")) {
|
||||
if (targetStart > -1) {
|
||||
targetEnd = t;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
targetStart = t;
|
||||
target = st.target;
|
||||
targetStartItem = it;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((targetStart > -1) && (targetEnd > -1)) {
|
||||
List<GraphTargetItem> newlist = new ArrayList<>();
|
||||
for (int i = 0; i < targetStart; i++) {
|
||||
newlist.add(list.get(i));
|
||||
}
|
||||
List<GraphTargetItem> tellist = new ArrayList<>();
|
||||
for (int i = targetStart + 1; i < targetEnd; i++) {
|
||||
tellist.add(list.get(i));
|
||||
}
|
||||
newlist.add(new TellTargetActionItem(targetStartItem.src, target, tellist));
|
||||
for (int i = targetEnd + 1; i < list.size(); i++) {
|
||||
newlist.add(list.get(i));
|
||||
}
|
||||
list.clear();
|
||||
list.addAll(newlist);
|
||||
again = true;
|
||||
}
|
||||
} while (again);
|
||||
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)) {
|
||||
SetTypeActionItem sti = (SetTypeActionItem) wi.commands.get(0);
|
||||
if (wi.expression.get(wi.expression.size() - 1) instanceof NeqActionItem) {
|
||||
NeqActionItem ne = (NeqActionItem) wi.expression.get(wi.expression.size() - 1);
|
||||
if (ne.rightSide instanceof DirectValueActionItem) {
|
||||
DirectValueActionItem dv = (DirectValueActionItem) ne.rightSide;
|
||||
if (dv.value instanceof Null) {
|
||||
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--;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//Handle for loops at the end:
|
||||
super.finalProcess(list, level, localData);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<GraphPart> checkPrecoNextParts(GraphPart part) {
|
||||
List<GraphSourceItem> items = getPartItems(part);
|
||||
part = makeMultiPart(part);
|
||||
if (items.size() > 1) {
|
||||
if (items.get(items.size() - 1) instanceof ActionIf) {
|
||||
if (items.get(items.size() - 2) instanceof ActionStrictEquals) {
|
||||
List<Integer> storeRegisters = new ArrayList<>();
|
||||
for (GraphSourceItem s : items) {
|
||||
if (s instanceof ActionStoreRegister) {
|
||||
ActionStoreRegister sr = (ActionStoreRegister) s;
|
||||
storeRegisters.add(sr.registerNumber);
|
||||
}
|
||||
}
|
||||
if (!storeRegisters.isEmpty()) {
|
||||
List<GraphPart> caseBodies = new ArrayList<>();
|
||||
boolean proceed = false;
|
||||
do {
|
||||
proceed = false;
|
||||
caseBodies.add(part.nextParts.get(0)); //jump
|
||||
part = part.nextParts.get(1); //nojump
|
||||
items = getPartItems(part);
|
||||
part = makeMultiPart(part);
|
||||
if (!items.isEmpty()) {
|
||||
if (items.get(0) instanceof ActionPush) {
|
||||
ActionPush pu = (ActionPush) items.get(0);
|
||||
if (!pu.values.isEmpty()) {
|
||||
if (pu.values.get(0) instanceof RegisterNumber) {
|
||||
RegisterNumber rn = (RegisterNumber) pu.values.get(0);
|
||||
if (storeRegisters.contains(rn.number)) {
|
||||
storeRegisters.clear();
|
||||
storeRegisters.add(rn.number);
|
||||
if (items.get(items.size() - 1) instanceof ActionIf) {
|
||||
if (items.size() > 1) {
|
||||
if (items.get(items.size() - 2) instanceof ActionStrictEquals) {
|
||||
proceed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (proceed);
|
||||
|
||||
if (caseBodies.size() > 1) {
|
||||
caseBodies.add(part); //TODO: properly detect default clause (?)
|
||||
return caseBodies;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@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 {
|
||||
if (!output.isEmpty()) {
|
||||
if (output.get(output.size() - 1) instanceof StoreRegisterActionItem) {
|
||||
StoreRegisterActionItem str = (StoreRegisterActionItem) output.get(output.size() - 1);
|
||||
if (str.value instanceof EnumerateActionItem) {
|
||||
output.remove(output.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<GraphTargetItem> ret = null;
|
||||
if ((part.nextParts.size() == 2) && (!stack.isEmpty()) && (stack.peek() instanceof StrictEqActionItem)) {
|
||||
|
||||
GraphTargetItem switchedObject = null;
|
||||
if (!output.isEmpty()) {
|
||||
if (output.get(output.size() - 1) instanceof StoreRegisterActionItem) {
|
||||
switchedObject = ((StoreRegisterActionItem) output.get(output.size() - 1)).value;
|
||||
}
|
||||
}
|
||||
if (switchedObject == null) {
|
||||
switchedObject = new DirectValueActionItem(null, -1, new Null(), null);
|
||||
}
|
||||
HashMap<Integer, GraphTargetItem> caseValuesMap = new HashMap<>();
|
||||
|
||||
int pos = 0;
|
||||
StrictEqActionItem set = (StrictEqActionItem) stack.pop();
|
||||
caseValuesMap.put(pos, set.rightSide);
|
||||
if (set.leftSide instanceof StoreRegisterActionItem) {
|
||||
switchedObject = ((StoreRegisterActionItem) set.leftSide).value;
|
||||
}
|
||||
//GraphPart switchLoc = part.nextParts.get(1).nextParts.get(0);
|
||||
List<GraphPart> caseBodyParts = new ArrayList<>();
|
||||
caseBodyParts.add(part.nextParts.get(0));
|
||||
GraphTargetItem top = null;
|
||||
int cnt = 1;
|
||||
while (part.nextParts.size() > 1
|
||||
&& part.nextParts.get(1).getHeight() > 1
|
||||
&& code.get(part.nextParts.get(1).end >= code.size() ? code.size() - 1 : part.nextParts.get(1).end) instanceof ActionIf
|
||||
&& ((top = translatePartGetStack(localData, part.nextParts.get(1), stack, staticOperation)) instanceof StrictEqActionItem)) {
|
||||
cnt++;
|
||||
part = part.nextParts.get(1);
|
||||
pos++;
|
||||
caseBodyParts.add(part.nextParts.get(0));
|
||||
|
||||
set = (StrictEqActionItem) top;
|
||||
caseValuesMap.put(pos, set.rightSide);
|
||||
}
|
||||
if (cnt == 1) {
|
||||
stack.push(set);
|
||||
} else {
|
||||
part = part.nextParts.get(1);
|
||||
|
||||
GraphPart defaultPart = part; //21-21
|
||||
//caseBodyParts.add(defaultPart);
|
||||
|
||||
List<GraphPart> defaultAndLastPart = new ArrayList<>();
|
||||
defaultAndLastPart.add(defaultPart);
|
||||
defaultAndLastPart.add(caseBodyParts.get(caseBodyParts.size() - 1));
|
||||
|
||||
GraphPart defaultPart2 = getCommonPart(localData, defaultAndLastPart, loops);//34-37
|
||||
|
||||
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);
|
||||
|
||||
List<GraphPart> loopContinues = new ArrayList<>();
|
||||
for (Loop l : loops) {
|
||||
if (l.loopContinue != null) {
|
||||
loopContinues.add(l.loopContinue);
|
||||
}
|
||||
}
|
||||
|
||||
List<GraphPart> breakParts = new ArrayList<>();
|
||||
/*for (int g = 0; g < caseBodyParts.size(); g++) {
|
||||
if (g < caseBodyParts.size() - 1) {
|
||||
if (caseBodyParts.get(g).leadsTo(code, caseBodyParts.get(g + 1), loops)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
GraphPart nsp = caseBodyParts.get(g).getNextSuperPartPath(loopContinues);
|
||||
if (nsp != null) {
|
||||
breakParts.add(nsp);
|
||||
}
|
||||
}
|
||||
Collections.sort(breakParts, new Comparator<GraphPart>() {
|
||||
@Override
|
||||
public int compare(GraphPart o1, GraphPart o2) {
|
||||
return o2.path.length() - o1.path.length();
|
||||
}
|
||||
});*/
|
||||
|
||||
//GraphPart breakPart = breakParts.isEmpty() ? null : breakParts.get(0);
|
||||
List<GraphPart> mcp = new ArrayList<>();
|
||||
mcp.addAll(caseBodyParts);
|
||||
if (defaultPart2 != null) {
|
||||
mcp.add(defaultPart2);
|
||||
}
|
||||
GraphPart breakPart = getMostCommonPart(localData, mcp, loops);
|
||||
if ((defaultPart2 != breakPart) && (defaultCommands.isEmpty())) {
|
||||
defaultPart = defaultPart2;
|
||||
}
|
||||
|
||||
List<GraphTargetItem> caseValues = new ArrayList<>();
|
||||
for (int i = 0; i < caseBodyParts.size(); i++) {
|
||||
if (caseValuesMap.containsKey(i)) {
|
||||
caseValues.add(caseValuesMap.get(i));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
List<List<GraphTargetItem>> caseCommands = new ArrayList<>();
|
||||
GraphPart next = null;
|
||||
|
||||
next = breakPart;
|
||||
|
||||
GraphTargetItem ti = checkLoop(next, stopPart, loops);
|
||||
currentLoop = new Loop(loops.size(), null, next);
|
||||
currentLoop.phase = 1;
|
||||
loops.add(currentLoop);
|
||||
//switchLoc.getNextPartPath(new ArrayList<GraphPart>());
|
||||
List<Integer> valuesMapping = new ArrayList<>();
|
||||
List<GraphPart> caseBodies = new ArrayList<>();
|
||||
for (int i = 0; i < caseValues.size(); i++) {
|
||||
GraphPart cur = caseBodyParts.get(i);
|
||||
if (!caseBodies.contains(cur)) {
|
||||
caseBodies.add(cur);
|
||||
}
|
||||
valuesMapping.add(caseBodies.indexOf(cur));
|
||||
}
|
||||
|
||||
if (defaultPart == breakPart) {
|
||||
defaultPart = null;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
if (!defaultCommands.isEmpty()) {
|
||||
if (defaultCommands.get(defaultCommands.size() - 1) instanceof BreakItem) {
|
||||
BreakItem bi = (BreakItem) defaultCommands.get(defaultCommands.size() - 1);
|
||||
if (bi.loopId == currentLoop.id) {
|
||||
defaultCommands.remove(defaultCommands.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<GraphPart> ignored = new ArrayList<>();
|
||||
for (Loop l : loops) {
|
||||
ignored.add(l.loopContinue);
|
||||
}
|
||||
|
||||
for (int i = 0; i < caseBodies.size(); i++) {
|
||||
List<GraphTargetItem> cc = new ArrayList<>();
|
||||
GraphPart nextCase = null;
|
||||
nextCase = next;
|
||||
if (next != null) {
|
||||
if (i < caseBodies.size() - 1) {
|
||||
if (!caseBodies.get(i).leadsTo(localData, this, code, caseBodies.get(i + 1), loops)) {
|
||||
cc.add(new BreakItem(null, currentLoop.id));
|
||||
} else {
|
||||
nextCase = caseBodies.get(i + 1);
|
||||
}
|
||||
} else if (!defaultCommands.isEmpty()) {
|
||||
if (!caseBodies.get(i).leadsTo(localData, this, code, defaultPart, loops)) {
|
||||
cc.add(new BreakItem(null, currentLoop.id));
|
||||
} else {
|
||||
nextCase = defaultPart;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<GraphPart> stopPart2x = new ArrayList<>(stopPart);
|
||||
//stopPart2.add(nextCase);
|
||||
for (GraphPart b : caseBodies) {
|
||||
if (b != caseBodies.get(i)) {
|
||||
stopPart2x.add(b);
|
||||
}
|
||||
}
|
||||
if (defaultPart != null) {
|
||||
stopPart2x.add(defaultPart);
|
||||
}
|
||||
if (breakPart != null) {
|
||||
stopPart2x.add(breakPart);
|
||||
}
|
||||
cc.addAll(0, printGraph(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)) {
|
||||
cc.remove(cc.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
caseCommands.add(cc);
|
||||
}
|
||||
ret = new ArrayList<>();
|
||||
ret.addAll(output);
|
||||
SwitchItem sti = new SwitchItem(null, currentLoop, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping);
|
||||
ret.add(sti);
|
||||
currentLoop.phase = 2;
|
||||
if (next != null) {
|
||||
if (ti != null) {
|
||||
ret.add(ti);
|
||||
} else {
|
||||
ret.addAll(printGraph(localData, stack, allParts, null, next, stopPart, loops, staticOperation, path));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int checkIp(int ip) {
|
||||
int oldIp = ip;
|
||||
//return in for..in
|
||||
GraphSourceItem action = code.get(ip);
|
||||
if ((action instanceof ActionPush) && (((ActionPush) action).values.size() == 1) && (((ActionPush) action).values.get(0) instanceof Null)) {
|
||||
if (ip + 3 < code.size()) {
|
||||
if ((code.get(ip + 1) instanceof ActionEquals) || (code.get(ip + 1) instanceof ActionEquals2)) {
|
||||
if (code.get(ip + 2) instanceof ActionNot) {
|
||||
if (code.get(ip + 3) instanceof ActionIf) {
|
||||
ActionIf aif = (ActionIf) code.get(ip + 3);
|
||||
if (code.adr2pos(code.pos2adr(ip + 4) + aif.getJumpOffset()) == ip) {
|
||||
ip += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (oldIp != ip) {
|
||||
return checkIp(ip);
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -223,7 +223,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;
|
||||
|
||||
@@ -442,7 +442,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;
|
||||
}
|
||||
|
||||
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
+9
-4
@@ -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();
|
||||
|
||||
+7
-1
@@ -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) {
|
||||
|
||||
+5
-3
@@ -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 {
|
||||
writer.append("enumerate ");
|
||||
return object.toString(writer, localData);
|
||||
writer.append("§§enumerate(");
|
||||
object.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-2
@@ -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
|
||||
public GraphTargetItem invert() {
|
||||
public GraphTargetItem invert(GraphSourceItem neqSrc) {
|
||||
return new NeqActionItem(src, leftSide, rightSide, version2);
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -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
|
||||
public GraphTargetItem invert() {
|
||||
public GraphTargetItem invert(GraphSourceItem negSrc) {
|
||||
return new LtActionItem(src, leftSide, rightSide, version2);
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -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
|
||||
public GraphTargetItem invert() {
|
||||
public GraphTargetItem invert(GraphSourceItem neqSrc) {
|
||||
return new LeActionItem(src, leftSide, rightSide);
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -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();
|
||||
public GraphTargetItem invert(GraphSourceItem src);
|
||||
}
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ public class LeActionItem extends BinaryOpItem implements LogicalOpItem, Inverte
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem invert() {
|
||||
public GraphTargetItem invert(GraphSourceItem negSrc) {
|
||||
return new GtActionItem(src, leftSide, rightSide);
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -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
|
||||
public GraphTargetItem invert() {
|
||||
public GraphTargetItem invert(GraphSourceItem neqSrc) {
|
||||
return new GeActionItem(src, leftSide, rightSide, version2);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public class NeqActionItem extends BinaryOpItem implements LogicalOpItem, Invert
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem invert() {
|
||||
public GraphTargetItem invert(GraphSourceItem negSrc) {
|
||||
return new EqActionItem(src, leftSide, rightSide, version2);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public class StrictEqActionItem extends BinaryOpItem implements LogicalOpItem, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem invert() {
|
||||
public GraphTargetItem invert(GraphSourceItem negSrc) {
|
||||
return new StrictNeqActionItem(src, leftSide, rightSide);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class StrictNeqActionItem extends BinaryOpItem implements LogicalOpItem,
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem invert() {
|
||||
public GraphTargetItem invert(GraphSourceItem negSrc) {
|
||||
return new StrictEqActionItem(src, leftSide, rightSide);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public class StringEqActionItem extends BinaryOpItem implements Inverted {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem invert() {
|
||||
public GraphTargetItem invert(GraphSourceItem negSrc) {
|
||||
return new StringNeActionItem(src, leftSide, rightSide);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public class StringGeActionItem extends BinaryOpItem implements Inverted {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem invert() {
|
||||
public GraphTargetItem invert(GraphSourceItem negSrc) {
|
||||
return new StringLtActionItem(src, leftSide, rightSide);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class StringGtActionItem extends BinaryOpItem implements Inverted {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem invert() {
|
||||
public GraphTargetItem invert(GraphSourceItem negSrc) {
|
||||
return new StringLeActionItem(src, leftSide, rightSide);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class StringLeActionItem extends BinaryOpItem implements Inverted {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem invert() {
|
||||
public GraphTargetItem invert(GraphSourceItem negSrc) {
|
||||
return new StringGtActionItem(src, leftSide, rightSide);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public class StringLtActionItem extends BinaryOpItem implements Inverted {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem invert() {
|
||||
public GraphTargetItem invert(GraphSourceItem negSrc) {
|
||||
return new StringGeActionItem(src, leftSide, rightSide);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public class StringNeActionItem extends BinaryOpItem implements Inverted {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem invert() {
|
||||
public GraphTargetItem invert(GraphSourceItem negSrc) {
|
||||
return new StringEqActionItem(src, leftSide, rightSide);
|
||||
}
|
||||
}
|
||||
|
||||
+2219
-2452
File diff suppressed because it is too large
Load Diff
+806
-794
File diff suppressed because it is too large
Load Diff
+7
-5
@@ -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,
|
||||
GLOBALCONST
|
||||
GLOBALCONST,
|
||||
PREPROCESSOR
|
||||
}
|
||||
|
||||
+223
-222
@@ -1,222 +1,223 @@
|
||||
/*
|
||||
* 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.action.parser.script;
|
||||
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public enum SymbolType {
|
||||
//Keywords
|
||||
|
||||
BREAK,
|
||||
CASE,
|
||||
CONTINUE,
|
||||
DEFAULT,
|
||||
DO,
|
||||
WHILE,
|
||||
ELSE,
|
||||
FOR,
|
||||
EACH,
|
||||
IN(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
IF,
|
||||
RETURN,
|
||||
SUPER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
SWITCH,
|
||||
THROW,
|
||||
TRY,
|
||||
CATCH,
|
||||
FINALLY,
|
||||
WITH,
|
||||
DYNAMIC,
|
||||
INTERNAL,
|
||||
OVERRIDE,
|
||||
PRIVATE,
|
||||
PROTECTED,
|
||||
PUBLIC,
|
||||
STATIC,
|
||||
CLASS,
|
||||
CONST,
|
||||
EXTENDS,
|
||||
FUNCTION(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
GET,
|
||||
IMPLEMENTS,
|
||||
INTERFACE,
|
||||
NAMESPACE,
|
||||
PACKAGE,
|
||||
SET,
|
||||
VAR,
|
||||
IMPORT,
|
||||
USE,
|
||||
FALSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
NULL(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
THIS(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
TRUE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
//Operators
|
||||
PARENT_OPEN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
PARENT_CLOSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
CURLY_OPEN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
CURLY_CLOSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
BRACKET_OPEN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
BRACKET_CLOSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
SEMICOLON,
|
||||
COMMA(GraphTargetItem.PRECEDENCE_COMMA, false),
|
||||
REST,
|
||||
DOT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
ASSIGN(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
GREATER_THAN(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
LOWER_THAN(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
NOT(GraphTargetItem.PRECEDENCE_UNARY, false),
|
||||
NEGATE(GraphTargetItem.PRECEDENCE_UNARY, false),
|
||||
TERNAR(GraphTargetItem.PRECEDENCE_CONDITIONAL, true, true), /*!! ternar !!!*/
|
||||
COLON(GraphTargetItem.PRECEDENCE_CONDITIONAL, false),/*!! ternar !!!*/
|
||||
EQUALS(GraphTargetItem.PRECEDENCE_EQUALITY, true),
|
||||
STRICT_EQUALS(GraphTargetItem.PRECEDENCE_EQUALITY, true),
|
||||
LOWER_EQUAL(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
GREATER_EQUAL(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
NOT_EQUAL(GraphTargetItem.PRECEDENCE_EQUALITY, true),
|
||||
STRICT_NOT_EQUAL(GraphTargetItem.PRECEDENCE_EQUALITY, true),
|
||||
AND(GraphTargetItem.PRECEDENCE_LOGICALAND, true),
|
||||
OR(GraphTargetItem.PRECEDENCE_LOGICALOR, true),
|
||||
FULLAND(GraphTargetItem.PRECEDENCE_LOGICALAND, true),
|
||||
FULLOR(GraphTargetItem.PRECEDENCE_LOGICALOR, true),
|
||||
INCREMENT(GraphTargetItem.PRECEDENCE_POSTFIX, false),//OR Unary
|
||||
DECREMENT(GraphTargetItem.PRECEDENCE_POSTFIX, false), //OR Unary
|
||||
PLUS(GraphTargetItem.PRECEDENCE_ADDITIVE, true),
|
||||
MINUS(GraphTargetItem.PRECEDENCE_ADDITIVE, true), //OR Unary
|
||||
MULTIPLY(GraphTargetItem.PRECEDENCE_MULTIPLICATIVE, true),
|
||||
DIVIDE(GraphTargetItem.PRECEDENCE_MULTIPLICATIVE, true),
|
||||
BITAND(GraphTargetItem.PRECEDENCE_BITWISEAND, true),
|
||||
BITOR(GraphTargetItem.PRECEDENCE_BITWISEOR, true),
|
||||
XOR(GraphTargetItem.PRECEDENCE_BITWISEXOR, true),
|
||||
MODULO(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
|
||||
SHIFT_LEFT(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
|
||||
SHIFT_RIGHT(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
|
||||
USHIFT_RIGHT(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
|
||||
ASSIGN_PLUS(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_MINUS(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_MULTIPLY(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_DIVIDE(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_BITAND(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_BITOR(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_XOR(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_MODULO(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_SHIFT_LEFT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_SHIFT_RIGHT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_USHIFT_RIGHT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
AS(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
DELETE(GraphTargetItem.PRECEDENCE_UNARY, false),
|
||||
INSTANCEOF(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
IS(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
NAMESPACE_OP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
NEW(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
TYPEOF(GraphTargetItem.PRECEDENCE_UNARY, false),
|
||||
VOID,
|
||||
ATTRIBUTE,
|
||||
//Other
|
||||
STRING(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
COMMENT,
|
||||
XML,
|
||||
IDENTIFIER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
INTEGER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
DOUBLE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
TYPENAME(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
EOF,
|
||||
TRACE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
GETURL(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
GOTOANDSTOP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
NEXTFRAME(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
PLAY(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
PREVFRAME(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
TELLTARGET(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
STOP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
STOPALLSOUNDS(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
TOGGLEHIGHQUALITY(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
ORD(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
CHR(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
DUPLICATEMOVIECLIP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
STOPDRAG(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
GETTIMER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
LOADVARIABLES(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
LOADMOVIE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
GOTOANDPLAY(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
MBORD(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
MBCHR(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
MBLENGTH(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
MBSUBSTRING(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
RANDOM(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
REMOVEMOVIECLIP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
STARTDRAG(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
SUBSTR(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
LENGTH(GraphTargetItem.PRECEDENCE_PRIMARY, false), //string.length
|
||||
INT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
TARGETPATH(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
NUMBER_OP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
STRING_OP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
IFFRAMELOADED,
|
||||
INFINITY(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
EVAL(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
UNDEFINED(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
NEWLINE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
NAN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
GETVERSION(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
CALL(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
LOADMOVIENUM(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
LOADVARIABLESNUM(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
PRINT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
PRINTNUM(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
PRINTASBITMAP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
PRINTASBITMAPNUM(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
UNLOADMOVIE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
UNLOADMOVIENUM(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
FSCOMMAND(GraphTargetItem.PRECEDENCE_PRIMARY, false);
|
||||
|
||||
private int precedence = GraphTargetItem.NOPRECEDENCE;
|
||||
|
||||
private boolean binary = false;
|
||||
|
||||
private boolean rightAssociative = false;
|
||||
|
||||
public boolean isBinary() {
|
||||
return binary;
|
||||
}
|
||||
|
||||
public boolean isRightAssociative() {
|
||||
return rightAssociative;
|
||||
}
|
||||
|
||||
public int getPrecedence() {
|
||||
return precedence;
|
||||
}
|
||||
|
||||
private SymbolType(int precedence, boolean binary) {
|
||||
this.precedence = precedence;
|
||||
this.binary = binary;
|
||||
}
|
||||
|
||||
private SymbolType(int precedence, boolean binary, boolean rightAssociative) {
|
||||
this.precedence = precedence;
|
||||
this.binary = binary;
|
||||
this.rightAssociative = rightAssociative;
|
||||
}
|
||||
|
||||
private SymbolType() {
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.action.parser.script;
|
||||
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public enum SymbolType {
|
||||
//Keywords
|
||||
|
||||
BREAK,
|
||||
CASE,
|
||||
CONTINUE,
|
||||
DEFAULT,
|
||||
DO,
|
||||
WHILE,
|
||||
ELSE,
|
||||
FOR,
|
||||
EACH,
|
||||
IN(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
IF,
|
||||
RETURN,
|
||||
SUPER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
SWITCH,
|
||||
THROW,
|
||||
TRY,
|
||||
CATCH,
|
||||
FINALLY,
|
||||
WITH,
|
||||
DYNAMIC,
|
||||
INTERNAL,
|
||||
OVERRIDE,
|
||||
PRIVATE,
|
||||
PROTECTED,
|
||||
PUBLIC,
|
||||
STATIC,
|
||||
CLASS,
|
||||
CONST,
|
||||
EXTENDS,
|
||||
FUNCTION(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
GET,
|
||||
IMPLEMENTS,
|
||||
INTERFACE,
|
||||
NAMESPACE,
|
||||
PACKAGE,
|
||||
SET,
|
||||
VAR,
|
||||
IMPORT,
|
||||
USE,
|
||||
FALSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
NULL(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
THIS(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
TRUE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
//Operators
|
||||
PARENT_OPEN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
PARENT_CLOSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
CURLY_OPEN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
CURLY_CLOSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
BRACKET_OPEN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
BRACKET_CLOSE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
SEMICOLON,
|
||||
COMMA(GraphTargetItem.PRECEDENCE_COMMA, false),
|
||||
REST,
|
||||
DOT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
ASSIGN(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
GREATER_THAN(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
LOWER_THAN(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
NOT(GraphTargetItem.PRECEDENCE_UNARY, false),
|
||||
NEGATE(GraphTargetItem.PRECEDENCE_UNARY, false),
|
||||
TERNAR(GraphTargetItem.PRECEDENCE_CONDITIONAL, true, true), /*!! ternar !!!*/
|
||||
COLON(GraphTargetItem.PRECEDENCE_CONDITIONAL, false),/*!! ternar !!!*/
|
||||
EQUALS(GraphTargetItem.PRECEDENCE_EQUALITY, true),
|
||||
STRICT_EQUALS(GraphTargetItem.PRECEDENCE_EQUALITY, true),
|
||||
LOWER_EQUAL(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
GREATER_EQUAL(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
NOT_EQUAL(GraphTargetItem.PRECEDENCE_EQUALITY, true),
|
||||
STRICT_NOT_EQUAL(GraphTargetItem.PRECEDENCE_EQUALITY, true),
|
||||
AND(GraphTargetItem.PRECEDENCE_LOGICALAND, true),
|
||||
OR(GraphTargetItem.PRECEDENCE_LOGICALOR, true),
|
||||
FULLAND(GraphTargetItem.PRECEDENCE_LOGICALAND, true),
|
||||
FULLOR(GraphTargetItem.PRECEDENCE_LOGICALOR, true),
|
||||
INCREMENT(GraphTargetItem.PRECEDENCE_POSTFIX, false),//OR Unary
|
||||
DECREMENT(GraphTargetItem.PRECEDENCE_POSTFIX, false), //OR Unary
|
||||
PLUS(GraphTargetItem.PRECEDENCE_ADDITIVE, true),
|
||||
MINUS(GraphTargetItem.PRECEDENCE_ADDITIVE, true), //OR Unary
|
||||
MULTIPLY(GraphTargetItem.PRECEDENCE_MULTIPLICATIVE, true),
|
||||
DIVIDE(GraphTargetItem.PRECEDENCE_MULTIPLICATIVE, true),
|
||||
BITAND(GraphTargetItem.PRECEDENCE_BITWISEAND, true),
|
||||
BITOR(GraphTargetItem.PRECEDENCE_BITWISEOR, true),
|
||||
XOR(GraphTargetItem.PRECEDENCE_BITWISEXOR, true),
|
||||
MODULO(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
|
||||
SHIFT_LEFT(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
|
||||
SHIFT_RIGHT(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
|
||||
USHIFT_RIGHT(GraphTargetItem.PRECEDENCE_BITWISESHIFT, true),
|
||||
ASSIGN_PLUS(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_MINUS(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_MULTIPLY(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_DIVIDE(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_BITAND(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_BITOR(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_XOR(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_MODULO(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_SHIFT_LEFT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_SHIFT_RIGHT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
ASSIGN_USHIFT_RIGHT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
|
||||
AS(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
DELETE(GraphTargetItem.PRECEDENCE_UNARY, false),
|
||||
INSTANCEOF(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
IS(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
|
||||
NAMESPACE_OP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
NEW(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
TYPEOF(GraphTargetItem.PRECEDENCE_UNARY, false),
|
||||
VOID,
|
||||
ATTRIBUTE,
|
||||
//Other
|
||||
STRING(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
COMMENT,
|
||||
XML,
|
||||
IDENTIFIER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
INTEGER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
DOUBLE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
TYPENAME(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
EOF,
|
||||
TRACE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
GETURL(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
GOTOANDSTOP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
NEXTFRAME(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
PLAY(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
PREVFRAME(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
TELLTARGET(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
STOP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
STOPALLSOUNDS(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
TOGGLEHIGHQUALITY(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
ORD(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
CHR(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
DUPLICATEMOVIECLIP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
STOPDRAG(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
GETTIMER(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
LOADVARIABLES(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
LOADMOVIE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
GOTOANDPLAY(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
MBORD(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
MBCHR(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
MBLENGTH(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
MBSUBSTRING(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
RANDOM(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
REMOVEMOVIECLIP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
STARTDRAG(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
SUBSTR(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
LENGTH(GraphTargetItem.PRECEDENCE_PRIMARY, false), //string.length
|
||||
INT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
TARGETPATH(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
NUMBER_OP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
STRING_OP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
IFFRAMELOADED,
|
||||
INFINITY(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
EVAL(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
UNDEFINED(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
NEWLINE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
NAN(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
GETVERSION(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
CALL(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
LOADMOVIENUM(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
LOADVARIABLESNUM(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
PRINT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
PRINTNUM(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
PRINTASBITMAP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
PRINTASBITMAPNUM(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
UNLOADMOVIE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
UNLOADMOVIENUM(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
FSCOMMAND(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
PREPROCESSOR(GraphTargetItem.PRECEDENCE_PRIMARY, false);
|
||||
|
||||
private int precedence = GraphTargetItem.NOPRECEDENCE;
|
||||
|
||||
private boolean binary = false;
|
||||
|
||||
private boolean rightAssociative = false;
|
||||
|
||||
public boolean isBinary() {
|
||||
return binary;
|
||||
}
|
||||
|
||||
public boolean isRightAssociative() {
|
||||
return rightAssociative;
|
||||
}
|
||||
|
||||
public int getPrecedence() {
|
||||
return precedence;
|
||||
}
|
||||
|
||||
private SymbolType(int precedence, boolean binary) {
|
||||
this.precedence = precedence;
|
||||
this.binary = binary;
|
||||
}
|
||||
|
||||
private SymbolType(int precedence, boolean binary, boolean rightAssociative) {
|
||||
this.precedence = precedence;
|
||||
this.binary = binary;
|
||||
this.rightAssociative = rightAssociative;
|
||||
}
|
||||
|
||||
private SymbolType() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
stack.push(new NotItem(this, a));
|
||||
stack.push(a.invert(this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
if (stack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
GraphTargetItem val = stack.pop();
|
||||
if (val instanceof DirectValueActionItem) {
|
||||
return;
|
||||
}
|
||||
output.add(val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.FalseItem;
|
||||
import com.jpexs.decompiler.graph.model.TrueItem;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -360,18 +362,27 @@ public class ActionPush extends Action {
|
||||
}
|
||||
}
|
||||
}*/
|
||||
DirectValueActionItem dvt = new DirectValueActionItem(this, pos, o, constantPool);
|
||||
|
||||
if (o instanceof RegisterNumber) {//TemporaryRegister
|
||||
dvt.computedRegValue = variables.get("__register" + ((RegisterNumber) o).number);
|
||||
if (regNames.containsKey(((RegisterNumber) o).number)) {
|
||||
((RegisterNumber) o).name = regNames.get(((RegisterNumber) o).number);
|
||||
if (o instanceof Boolean) {
|
||||
Boolean b = (Boolean) o;
|
||||
if (b) {
|
||||
stack.push(new TrueItem(this));
|
||||
} else {
|
||||
stack.push(new FalseItem(this));
|
||||
}
|
||||
}
|
||||
if (dvt.computedRegValue instanceof TemporaryRegister) {
|
||||
stack.push(new TemporaryRegister(((RegisterNumber) o).number, ((TemporaryRegister) dvt.computedRegValue).value));
|
||||
} else {
|
||||
stack.push(dvt);
|
||||
DirectValueActionItem dvt = new DirectValueActionItem(this, pos, o, constantPool);
|
||||
|
||||
if (o instanceof RegisterNumber) {//TemporaryRegister
|
||||
dvt.computedRegValue = variables.get("__register" + ((RegisterNumber) o).number);
|
||||
if (regNames.containsKey(((RegisterNumber) o).number)) {
|
||||
((RegisterNumber) o).name = regNames.get(((RegisterNumber) o).number);
|
||||
}
|
||||
}
|
||||
if (dvt.computedRegValue instanceof TemporaryRegister) {
|
||||
stack.push(new TemporaryRegister(((RegisterNumber) o).number, ((TemporaryRegister) dvt.computedRegValue).value));
|
||||
} else {
|
||||
stack.push(dvt);
|
||||
}
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
|
||||
@@ -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.swf5;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
@@ -39,7 +40,7 @@ public class ActionEnumerate 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 object = stack.pop();
|
||||
stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList<>()));
|
||||
stack.push(new EnumerateActionItem(this, object));
|
||||
//stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList<String>()));
|
||||
output.add(new EnumerateActionItem(this, object));
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -12,13 +12,15 @@
|
||||
* 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.swf5;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.DuplicateItem;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,7 +38,7 @@ public class ActionPushDuplicate 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 value = stack.peek();
|
||||
stack.push(value);
|
||||
stack.push(new DuplicateItem(this, value));
|
||||
value.moreSrc.add(new GraphSourceItemPos(this, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
/*
|
||||
* 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.action.swf6;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.model.EnumerateActionItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ActionEnumerate2 extends Action {
|
||||
|
||||
public ActionEnumerate2() {
|
||||
super(0x55, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Enumerate2";
|
||||
}
|
||||
|
||||
@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 object = stack.pop();
|
||||
stack.push(new EnumerateActionItem(this, object));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.action.swf6;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.model.EnumerateActionItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ActionEnumerate2 extends Action {
|
||||
|
||||
public ActionEnumerate2() {
|
||||
super(0x55, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Enumerate2";
|
||||
}
|
||||
|
||||
@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 object = stack.pop();
|
||||
output.add(new EnumerateActionItem(this, object));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user