mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-28 14:00:52 +00:00
Separated FFDec core library and the rest (GUI).
FFDec Library is now LGPLv3, others stay GPLv3. Version changed to 3.0.0 for FFDec, 1.0.0 for FFDec Library.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,486 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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) {
|
||||
|
||||
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 = 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.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.TranslateStack;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ActionGraphSource extends GraphSource {
|
||||
|
||||
private final List<Action> actions;
|
||||
public int version;
|
||||
private final HashMap<Integer, String> registerNames;
|
||||
private final HashMap<String, GraphTargetItem> variables;
|
||||
private final HashMap<String, GraphTargetItem> functions;
|
||||
|
||||
public List<Action> getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public ActionGraphSource(List<Action> actions, int version, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
|
||||
this.actions = actions;
|
||||
this.version = version;
|
||||
this.registerNames = registerNames;
|
||||
this.variables = variables;
|
||||
this.functions = functions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return actions.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphSourceItem get(int pos) {
|
||||
return actions.get(pos);
|
||||
}
|
||||
|
||||
public void set(int pos, Action t) {
|
||||
actions.set(pos, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return actions.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> translatePart(GraphPart part, BaseLocalData localData, TranslateStack stack, int start, int end, int staticOperation, String path) throws InterruptedException {
|
||||
return (Action.actionsPartToTree(registerNames, variables, functions, stack, actions, start, end, version, staticOperation, path));
|
||||
}
|
||||
private List<Long> posCache = null;
|
||||
|
||||
private void rebuildCache() {
|
||||
posCache = new ArrayList<>();
|
||||
for (int i = 0; i < size(); i++) {
|
||||
posCache.add(pos2adr(i));
|
||||
}
|
||||
}
|
||||
|
||||
/* public int adr2posInside(long addr){
|
||||
long lastAddr=0;
|
||||
if(addr==0){
|
||||
return 0;
|
||||
}
|
||||
for(int i=0;i<size();i++){
|
||||
long curAdr=pos2adr(i);
|
||||
if(curAdr==addr){
|
||||
return i;
|
||||
}
|
||||
if(curAdr>addr){
|
||||
System.err.println("lastAddr="+lastAddr+" addr="+addr+" curAddr="+curAdr);
|
||||
int contPos=adr2pos(lastAddr);
|
||||
System.err.println("/insadr2po");
|
||||
GraphSourceItem src=get(contPos);
|
||||
if(src instanceof ActionContainer){
|
||||
ActionContainer cnt=(ActionContainer)src;
|
||||
return new ActionGraphSource(cnt.getActions(), version, registerNames, variables, functions).adr2pos(addr);
|
||||
}else{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
lastAddr=curAdr;
|
||||
}
|
||||
return -1;
|
||||
}*/
|
||||
@Override
|
||||
public int adr2pos(long adr) {
|
||||
if (posCache == null) {
|
||||
rebuildCache();
|
||||
}
|
||||
if (adr == 0) {
|
||||
return 0;
|
||||
}
|
||||
int ret = posCache.indexOf((Long) adr);
|
||||
if (ret == -1) {
|
||||
if (!posCache.isEmpty() && (adr > posCache.get(posCache.size() - 1))) {
|
||||
return size();
|
||||
}
|
||||
//ret = adr2posInside(adr);
|
||||
if (ret == -1) {
|
||||
Logger.getLogger(ActionGraphSource.class.getName()).log(Level.SEVERE, "Address loc" + Helper.formatAddress(adr) + " not found");
|
||||
/*System.err.println("Addr loc"+Helper.formatAddress(adr)+" not found");
|
||||
int pos=0;
|
||||
for(long l:posCache){
|
||||
System.err.println("ip "+pos+" action "+get(pos).toString()+" loc"+Helper.formatAddress(l));
|
||||
pos++;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
/*int pos = 0;
|
||||
long lastAddr = 0;
|
||||
for (Action a : actions) {
|
||||
lastAddr = a.getAddress();
|
||||
System.err.println("ip "+pos+" addr "+Helper.formatAddress(lastAddr));
|
||||
if (lastAddr == adr) {
|
||||
return pos;
|
||||
}
|
||||
|
||||
pos++;
|
||||
}
|
||||
if (adr > lastAddr) {
|
||||
return actions.size();
|
||||
}
|
||||
if (adr == 0) {
|
||||
return 0;
|
||||
}
|
||||
//throw new RuntimeException("Address "+Helper.formatAddress(adr)+" not found");
|
||||
return -1;*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public long pos2adr(int pos) {
|
||||
GraphSourceItem si = actions.get(pos);
|
||||
if (si instanceof Action) {
|
||||
return ((Action) si).getAddress();//Action.ip2adr(actions, pos, version);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.DisassemblyListener;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.action.special.ActionNop;
|
||||
import com.jpexs.decompiler.flash.action.special.ActionStore;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionIf;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionJump;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.helpers.EmptySWFDecompilerListener;
|
||||
import com.jpexs.decompiler.flash.helpers.FileTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ActionList extends ArrayList<Action> {
|
||||
|
||||
public ActionList() {
|
||||
}
|
||||
|
||||
public ActionList(Collection<Action> actions) {
|
||||
super(actions);
|
||||
}
|
||||
|
||||
public void setActions(List<Action> list) {
|
||||
clear();
|
||||
addAll(list);
|
||||
}
|
||||
|
||||
public void removeAction(int index) {
|
||||
ActionListReader.removeAction(this, index, SWF.DEFAULT_VERSION, true);
|
||||
}
|
||||
|
||||
public void removeAction(int index, int count) {
|
||||
if (size() <= index + count - 1) {
|
||||
// Can't remove count elements, only size - index is available
|
||||
count = size() - index;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
ActionListReader.removeAction(this, index, SWF.DEFAULT_VERSION, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void addAction(int index, Action action) {
|
||||
ActionListReader.addAction(this, index, action, SWF.DEFAULT_VERSION, false, false);
|
||||
}
|
||||
|
||||
public void fixActionList() {
|
||||
ActionListReader.fixActionList(this, null, SWF.DEFAULT_VERSION);
|
||||
}
|
||||
|
||||
public List<Action> getContainerLastActions(Action action) {
|
||||
return ActionListReader.getContainerLastActions(this, action);
|
||||
}
|
||||
|
||||
public Iterator<Action> getReferencesFor(final Action target) {
|
||||
final ActionList diz = this;
|
||||
return new Iterator<Action>() {
|
||||
|
||||
private final Iterator<Action> iterator = diz.iterator();
|
||||
|
||||
private Action action = getNext();
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return action != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action next() {
|
||||
Action a = action;
|
||||
action = getNext();
|
||||
return a;
|
||||
}
|
||||
|
||||
private Action getNext() {
|
||||
while (iterator.hasNext()) {
|
||||
Action a = iterator.next();
|
||||
if (a instanceof ActionJump) {
|
||||
ActionJump aJump = (ActionJump) a;
|
||||
long ref = aJump.getAddress() + aJump.getTotalActionLength() + aJump.getJumpOffset();
|
||||
if (target.getAddress() == ref) {
|
||||
return aJump;
|
||||
}
|
||||
} else if (a instanceof ActionIf) {
|
||||
ActionIf aIf = (ActionIf) a;
|
||||
long ref = aIf.getAddress() + aIf.getTotalActionLength() + aIf.getJumpOffset();
|
||||
if (target.getAddress() == ref) {
|
||||
return aIf;
|
||||
}
|
||||
} else if (a instanceof ActionStore) {
|
||||
ActionStore aStore = (ActionStore) a;
|
||||
int storeSize = aStore.getStoreSize();
|
||||
int idx = indexOf(a);
|
||||
int idx2 = indexOf(target);
|
||||
if (idx != -1 && idx2 == idx + storeSize) {
|
||||
return a;
|
||||
}
|
||||
} else if (a instanceof GraphSourceItemContainer) {
|
||||
GraphSourceItemContainer container = (GraphSourceItemContainer) a;
|
||||
long ref = a.getAddress() + a.getTotalActionLength();
|
||||
for (Long size : container.getContainerSizes()) {
|
||||
ref += size;
|
||||
if (target.getAddress() == ref) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void removeNops() {
|
||||
for (int i = 0; i < size(); i++) {
|
||||
if (get(i) instanceof ActionNop) {
|
||||
removeAction(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Action getByAddress(long address) {
|
||||
int idx = getIndexByAddress(address);
|
||||
return idx == -1 ? null : get(idx);
|
||||
}
|
||||
|
||||
public int getIndexByAddress(long address) {
|
||||
int min = 0;
|
||||
int max = size() - 1;
|
||||
|
||||
while (max >= min) {
|
||||
int mid = (min + max) / 2;
|
||||
long midValue = get(mid).getAddress();
|
||||
if (midValue == address) {
|
||||
return mid;
|
||||
} else if (midValue < address) {
|
||||
min = mid + 1;
|
||||
} else {
|
||||
max = mid - 1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void saveToFile(String fileName) {
|
||||
File file = new File(fileName);
|
||||
try (FileTextWriter writer = new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(file))) {
|
||||
Action.actionsToString(new ArrayList<DisassemblyListener>(), 0, this, SWF.DEFAULT_VERSION, ScriptExportMode.PCODE, writer);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(EmptySWFDecompilerListener.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.graph.GraphTargetItem;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ActionLocalData extends BaseLocalData {
|
||||
|
||||
public final HashMap<Integer, String> regNames;
|
||||
public final HashMap<String, GraphTargetItem> variables;
|
||||
public final HashMap<String, GraphTargetItem> functions;
|
||||
|
||||
public ActionLocalData() {
|
||||
regNames = new HashMap<>();
|
||||
variables = new HashMap<>();
|
||||
functions = new HashMap<>();
|
||||
}
|
||||
|
||||
public ActionLocalData(HashMap<Integer, String> regNames) {
|
||||
this.regNames = regNames;
|
||||
variables = new HashMap<>();
|
||||
functions = new HashMap<>();
|
||||
}
|
||||
|
||||
public ActionLocalData(HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
|
||||
this.regNames = regNames;
|
||||
this.variables = variables;
|
||||
this.functions = functions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.abc.RenameType;
|
||||
import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Deobfuscation {
|
||||
|
||||
private final Random rnd = new Random();
|
||||
private final int DEFAULT_FOO_SIZE = 10;
|
||||
public HashSet<String> allVariableNamesStr = new HashSet<>();
|
||||
private final HashMap<String, Integer> typeCounts = new HashMap<>();
|
||||
|
||||
public static final String VALID_FIRST_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
|
||||
public static final String VALID_NEXT_CHARACTERS = VALID_FIRST_CHARACTERS + "0123456789";
|
||||
public static final String FOO_CHARACTERS = "bcdfghjklmnpqrstvwz";
|
||||
public static final String FOO_JOIN_CHARACTERS = "aeiouy";
|
||||
|
||||
private String fooString(HashMap<String, String> deobfuscated, String orig, boolean firstUppercase, int rndSize) {
|
||||
boolean exists;
|
||||
String ret;
|
||||
loopfoo:
|
||||
do {
|
||||
exists = false;
|
||||
int len = 3 + rnd.nextInt(rndSize - 3);
|
||||
ret = "";
|
||||
for (int i = 0; i < len; i++) {
|
||||
String c = "";
|
||||
if ((i % 2) == 0) {
|
||||
c = "" + FOO_CHARACTERS.charAt(rnd.nextInt(FOO_CHARACTERS.length()));
|
||||
} else {
|
||||
c = "" + FOO_JOIN_CHARACTERS.charAt(rnd.nextInt(FOO_JOIN_CHARACTERS.length()));
|
||||
}
|
||||
if (i == 0 && firstUppercase) {
|
||||
c = c.toUpperCase(Locale.ENGLISH);
|
||||
}
|
||||
ret += c;
|
||||
}
|
||||
if (allVariableNamesStr.contains(ret)) {
|
||||
exists = true;
|
||||
rndSize += 1;
|
||||
continue loopfoo;
|
||||
}
|
||||
if (Action.isReservedWord(ret)) {
|
||||
exists = true;
|
||||
rndSize += 1;
|
||||
continue;
|
||||
}
|
||||
if (deobfuscated.containsValue(ret)) {
|
||||
exists = true;
|
||||
rndSize += 1;
|
||||
continue;
|
||||
}
|
||||
} while (exists);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void deobfuscateInstanceNames(HashMap<String, String> namesMap, RenameType renameType, List<Tag> tags, Map<String, String> selected) {
|
||||
for (Tag t : tags) {
|
||||
if (t instanceof DefineSpriteTag) {
|
||||
deobfuscateInstanceNames(namesMap, renameType, ((DefineSpriteTag) t).subTags, selected);
|
||||
}
|
||||
if (t instanceof PlaceObjectTypeTag) {
|
||||
PlaceObjectTypeTag po = (PlaceObjectTypeTag) t;
|
||||
String name = po.getInstanceName();
|
||||
if (name != null) {
|
||||
String changedName = deobfuscateName(name, false, "instance", namesMap, renameType, selected);
|
||||
if (changedName != null) {
|
||||
po.setInstanceName(changedName);
|
||||
((Tag) po).setModified(true);
|
||||
}
|
||||
}
|
||||
String className = po.getClassName();
|
||||
if (className != null) {
|
||||
String changedClassName = deobfuscateNameWithPackage(className, namesMap, renameType, selected);
|
||||
if (changedClassName != null) {
|
||||
po.setClassName(changedClassName);
|
||||
((Tag) po).setModified(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String deobfuscatePackage(String pkg, HashMap<String, String> namesMap, RenameType renameType, Map<String, String> selected) {
|
||||
if (namesMap.containsKey(pkg)) {
|
||||
return namesMap.get(pkg);
|
||||
}
|
||||
String[] parts = null;
|
||||
if (pkg.contains(".")) {
|
||||
parts = pkg.split("\\.");
|
||||
} else {
|
||||
parts = new String[]{pkg};
|
||||
}
|
||||
String ret = "";
|
||||
boolean isChanged = false;
|
||||
for (int p = 0; p < parts.length; p++) {
|
||||
if (p > 0) {
|
||||
ret += ".";
|
||||
}
|
||||
String partChanged = deobfuscateName(parts[p], false, "package", namesMap, renameType, selected);
|
||||
if (partChanged != null) {
|
||||
ret += partChanged;
|
||||
isChanged = true;
|
||||
} else {
|
||||
ret += parts[p];
|
||||
}
|
||||
}
|
||||
if (isChanged) {
|
||||
namesMap.put(pkg, ret);
|
||||
return ret;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String deobfuscateNameWithPackage(String n, HashMap<String, String> namesMap, RenameType renameType, Map<String, String> selected) {
|
||||
String pkg = null;
|
||||
String name = "";
|
||||
if (n.contains(".")) {
|
||||
pkg = n.substring(0, n.lastIndexOf('.'));
|
||||
name = n.substring(n.lastIndexOf('.') + 1);
|
||||
} else {
|
||||
name = n;
|
||||
}
|
||||
boolean changed = false;
|
||||
if ((pkg != null) && (!pkg.isEmpty())) {
|
||||
String changedPkg = deobfuscatePackage(pkg, namesMap, renameType, selected);
|
||||
if (changedPkg != null) {
|
||||
changed = true;
|
||||
pkg = changedPkg;
|
||||
}
|
||||
}
|
||||
String changedName = deobfuscateName(name, true, "class", namesMap, renameType, selected);
|
||||
if (changedName != null) {
|
||||
changed = true;
|
||||
name = changedName;
|
||||
}
|
||||
if (changed) {
|
||||
String newClassName = "";
|
||||
if (pkg == null) {
|
||||
newClassName = name;
|
||||
} else {
|
||||
newClassName = pkg + "." + name;
|
||||
}
|
||||
return newClassName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isValidName(String s,String ...exceptions) {
|
||||
boolean isValid = true;
|
||||
|
||||
for(String e:exceptions){
|
||||
if(e.equals(s)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Action.isReservedWord(s)) {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (isValid) {
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (s.charAt(i) > 127) {
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isValid) {
|
||||
Pattern pat = Pattern.compile("^[" + Pattern.quote(VALID_FIRST_CHARACTERS) + "]" + "[" + Pattern.quote(VALID_FIRST_CHARACTERS + VALID_NEXT_CHARACTERS) + "]*$");
|
||||
if (!pat.matcher(s).matches()) {
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
public String deobfuscateName(String s, boolean firstUppercase, String usageType, HashMap<String, String> namesMap, RenameType renameType, Map<String, String> selected) {
|
||||
boolean isValid = true;
|
||||
if (usageType == null) {
|
||||
usageType = "name";
|
||||
}
|
||||
|
||||
if (selected != null) {
|
||||
if (selected.containsKey(s)) {
|
||||
return selected.get(s);
|
||||
}
|
||||
}
|
||||
|
||||
isValid = isValidName(s);
|
||||
if (!isValid) {
|
||||
if (namesMap.containsKey(s)) {
|
||||
return namesMap.get(s);
|
||||
} else {
|
||||
Integer cnt = typeCounts.get(usageType);
|
||||
if (cnt == null) {
|
||||
cnt = 0;
|
||||
}
|
||||
|
||||
String ret = null;
|
||||
if (renameType == RenameType.TYPENUMBER) {
|
||||
|
||||
boolean found;
|
||||
do {
|
||||
found = false;
|
||||
cnt++;
|
||||
ret = usageType + "_" + cnt;
|
||||
found = allVariableNamesStr.contains(ret);
|
||||
} while (found);
|
||||
typeCounts.put(usageType, cnt);
|
||||
} else if (renameType == RenameType.RANDOMWORD) {
|
||||
ret = fooString(namesMap, s, firstUppercase, DEFAULT_FOO_SIZE);
|
||||
}
|
||||
namesMap.put(s, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String makeObfuscatedIdentifier(String s){
|
||||
return "§"+escapeOIdentifier(s)+"§";
|
||||
}
|
||||
|
||||
|
||||
public static String escapeOIdentifier(String s) {
|
||||
StringBuilder ret = new StringBuilder(s.length());
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
if (c == '\n') {
|
||||
ret.append("\\n");
|
||||
} else if (c == '\r') {
|
||||
ret.append("\\r");
|
||||
} else if (c == '\t') {
|
||||
ret.append("\\t");
|
||||
} else if (c == '\b') {
|
||||
ret.append("\\b");
|
||||
} else if (c == '\t') {
|
||||
ret.append("\\t");
|
||||
} else if (c == '\f') {
|
||||
ret.append("\\f");
|
||||
} else if (c == '\\') {
|
||||
ret.append("\\\\");
|
||||
} else if (c == '\u00A7') {
|
||||
ret.append("\\\\u00A7");
|
||||
} else {
|
||||
ret.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
return ret.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.action.model.ConstantPool;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface StoreTypeAction {
|
||||
|
||||
public String getVariableName(TranslateStack stack, ConstantPool cpool);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class UnknownActionException extends RuntimeException {
|
||||
|
||||
public int opCode;
|
||||
|
||||
public UnknownActionException(int opCode) {
|
||||
super("Unknown opCode: 0x" + Integer.toHexString(opCode));
|
||||
this.opCode = opCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.action.model.ActionItem;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
* Raised when actual address has been referenced with an unknown jump
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class UnknownJumpException extends RuntimeException {
|
||||
|
||||
/**
|
||||
* Actual stack
|
||||
*/
|
||||
public Stack stack;
|
||||
/**
|
||||
* Actual address
|
||||
*/
|
||||
public long addr;
|
||||
/**
|
||||
* Output of the method before raising the exception
|
||||
*/
|
||||
public List<ActionItem> output;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param stack Actual stack
|
||||
* @param addr Actual address
|
||||
* @param output Output of the method before raising the exception
|
||||
*/
|
||||
public UnknownJumpException(Stack stack, long addr, List<ActionItem> output) {
|
||||
this.stack = stack;
|
||||
this.addr = addr;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the object
|
||||
*
|
||||
* @return a string representation of the object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Unknown jump to " + addr;
|
||||
}
|
||||
}
|
||||
+482
@@ -0,0 +1,482 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.deobfuscation;
|
||||
|
||||
import com.jpexs.decompiler.flash.DisassemblyListener;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionList;
|
||||
import com.jpexs.decompiler.flash.action.ActionListReader;
|
||||
import com.jpexs.decompiler.flash.action.ActionLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.ReturnActionItem;
|
||||
import com.jpexs.decompiler.flash.action.special.ActionEnd;
|
||||
import com.jpexs.decompiler.flash.action.special.ActionStore;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionAdd;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionEquals;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionIf;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionJump;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionMultiply;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionNot;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionSetVariable;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionSubtract;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ConstantIndex;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionAdd2;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitAnd;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitLShift;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitOr;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitRShift;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitXor;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionCallFunction;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionConstantPool;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionModulo;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionPushDuplicate;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionReturn;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.helpers.SWFDecompilerListener;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemContainer;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateException;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.io.IOException;
|
||||
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;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ActionDeobfuscator implements SWFDecompilerListener {
|
||||
|
||||
private final int executionLimit = 30000;
|
||||
|
||||
@Override
|
||||
public void actionListParsed(ActionList actions, SWF swf) {
|
||||
combinePushs(actions);
|
||||
Map<String, Object> fakeFunctions = getFakeFunctionResults(actions);
|
||||
removeUnreachableActions(actions);
|
||||
removeObfuscationIfs(actions, fakeFunctions);
|
||||
removeUnreachableActions(actions);
|
||||
removeZeroJumps(actions);
|
||||
rereadActionList(actions, swf); // this call will fix the contant pool assigments
|
||||
}
|
||||
|
||||
private void combinePushs(ActionList actions) {
|
||||
for (int i = 0; i < actions.size() - 1; i++) {
|
||||
Action action = actions.get(i);
|
||||
Action action2 = actions.get(i + 1);
|
||||
if (action instanceof ActionPush && action2 instanceof ActionPush) {
|
||||
if (!actions.getReferencesFor(action2).hasNext()) {
|
||||
ActionPush push = (ActionPush) action;
|
||||
ActionPush push2 = (ActionPush) action2;
|
||||
if (!(push.constantPool != null && push2.constantPool != null && push.constantPool != push.constantPool)) {
|
||||
ActionPush newPush = new ActionPush(0);
|
||||
newPush.constantPool = push.constantPool == null ? push2.constantPool : push.constantPool;
|
||||
newPush.values.clear();
|
||||
newPush.values.addAll(push.values);
|
||||
newPush.values.addAll(push2.values);
|
||||
actions.addAction(i + 1, newPush);
|
||||
actions.removeAction(i + 2);
|
||||
actions.removeAction(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean rereadActionList(ActionList actions, SWF swf) {
|
||||
byte[] actionBytes = Action.actionsToBytes(actions, true, SWF.DEFAULT_VERSION);
|
||||
try {
|
||||
SWFInputStream rri = new SWFInputStream(swf, actionBytes);
|
||||
ActionList newActions = ActionListReader.readActionList(new ArrayList<DisassemblyListener>(), rri, SWF.DEFAULT_VERSION, 0, actionBytes.length, "", -1);
|
||||
actions.setActions(newActions);
|
||||
} catch (IOException | InterruptedException ex) {
|
||||
Logger.getLogger(ActionDeobfuscator.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean removeUnreachableActions(ActionList actions) {
|
||||
Set<Action> reachableActions = new HashSet<>();
|
||||
Set<Action> processedActions = new HashSet<>();
|
||||
reachableActions.add(actions.get(0));
|
||||
boolean modified = true;
|
||||
while (modified) {
|
||||
modified = false;
|
||||
for (int i = 0; i < actions.size(); i++) {
|
||||
Action action = actions.get(i);
|
||||
if (reachableActions.contains(action) && !processedActions.contains(action)) {
|
||||
if (!action.isExit() && !(action instanceof ActionJump) && i != actions.size() - 1) {
|
||||
Action next = actions.get(i + 1);
|
||||
if (!reachableActions.contains(next)) {
|
||||
reachableActions.add(next);
|
||||
}
|
||||
}
|
||||
|
||||
if (action instanceof ActionJump) {
|
||||
ActionJump aJump = (ActionJump) action;
|
||||
long ref = aJump.getAddress() + aJump.getTotalActionLength() + aJump.getJumpOffset();
|
||||
Action target = actions.getByAddress(ref);
|
||||
if (target != null && !reachableActions.contains(target)) {
|
||||
reachableActions.add(target);
|
||||
}
|
||||
} else if (action instanceof ActionIf) {
|
||||
ActionIf aIf = (ActionIf) action;
|
||||
long ref = aIf.getAddress() + aIf.getTotalActionLength() + aIf.getJumpOffset();
|
||||
Action target = actions.getByAddress(ref);
|
||||
if (target != null && !reachableActions.contains(target)) {
|
||||
reachableActions.add(target);
|
||||
}
|
||||
} else if (action instanceof ActionStore) {
|
||||
ActionStore aStore = (ActionStore) action;
|
||||
int storeSize = aStore.getStoreSize();
|
||||
if (actions.size() > i + storeSize) {
|
||||
Action target = actions.get(i + storeSize);
|
||||
if (!reachableActions.contains(target)) {
|
||||
reachableActions.add(target);
|
||||
}
|
||||
}
|
||||
} else if (action instanceof GraphSourceItemContainer) {
|
||||
GraphSourceItemContainer container = (GraphSourceItemContainer) action;
|
||||
long ref = action.getAddress() + action.getTotalActionLength();
|
||||
for (Long size : container.getContainerSizes()) {
|
||||
ref += size;
|
||||
Action target = actions.getByAddress(ref);
|
||||
if (target != null && !reachableActions.contains(target)) {
|
||||
reachableActions.add(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processedActions.add(action);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean result = false;
|
||||
for (int i = 0; i < actions.size(); i++) {
|
||||
if (!reachableActions.contains(actions.get(i))) {
|
||||
actions.removeAction(i);
|
||||
i--;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean removeZeroJumps(ActionList actions) {
|
||||
boolean result = false;
|
||||
for (int i = 0; i < actions.size(); i++) {
|
||||
Action action = actions.get(i);
|
||||
if (action instanceof ActionJump && ((ActionJump) action).getJumpOffset() == 0) {
|
||||
actions.removeAction(i);
|
||||
i--;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean removeObfuscationIfs(ActionList actions, Map<String, Object> fakeFunctions) {
|
||||
if (actions.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < actions.size(); i++) {
|
||||
ExecutionResult result = new ExecutionResult();
|
||||
executeActions(actions, i, actions.size() - 1, result, fakeFunctions);
|
||||
|
||||
if (result.idx != -1) {
|
||||
int newIstructionCount = 1; // jump
|
||||
if (result.constantPool != null) {
|
||||
newIstructionCount++;
|
||||
}
|
||||
if (!result.stack.isEmpty()) {
|
||||
newIstructionCount++;
|
||||
}
|
||||
newIstructionCount += 2 * result.variables.size();
|
||||
|
||||
if (newIstructionCount * 2 < result.instructionsProcessed) {
|
||||
Action target = actions.get(result.idx);
|
||||
Action prevAction = actions.get(i);
|
||||
|
||||
if (result.constantPool != null) {
|
||||
ActionConstantPool constantPool2 = new ActionConstantPool(new ArrayList<>(result.constantPool.constantPool));
|
||||
actions.addAction(i++, constantPool2);
|
||||
prevAction = constantPool2;
|
||||
}
|
||||
|
||||
for (String variableName : result.variables.keySet()) {
|
||||
Object value = result.variables.get(variableName);
|
||||
ActionPush push = new ActionPush(variableName);
|
||||
push.values.add(value);
|
||||
push.setAddress(prevAction.getAddress());
|
||||
actions.addAction(i++, push);
|
||||
prevAction = push;
|
||||
|
||||
if (result.defines.contains(variableName)) {
|
||||
ActionDefineLocal defineLocal = new ActionDefineLocal();
|
||||
defineLocal.setAddress(prevAction.getAddress());
|
||||
actions.addAction(i++, defineLocal);
|
||||
prevAction = defineLocal;
|
||||
} else {
|
||||
ActionSetVariable setVariable = new ActionSetVariable();
|
||||
setVariable.setAddress(prevAction.getAddress());
|
||||
actions.addAction(i++, setVariable);
|
||||
prevAction = setVariable;
|
||||
}
|
||||
}
|
||||
|
||||
if (!result.stack.isEmpty()) {
|
||||
ActionPush push = new ActionPush(0);
|
||||
push.values.clear();
|
||||
for (GraphTargetItem graphTargetItem : result.stack) {
|
||||
DirectValueActionItem dv = (DirectValueActionItem) graphTargetItem;
|
||||
push.values.add(dv.value);
|
||||
}
|
||||
push.setAddress(prevAction.getAddress());
|
||||
actions.addAction(i++, push);
|
||||
prevAction = push;
|
||||
}
|
||||
|
||||
ActionJump jump = new ActionJump(0);
|
||||
jump.setAddress(prevAction.getAddress());
|
||||
jump.setJumpOffset((int) (target.getAddress() - jump.getAddress() - jump.getTotalActionLength()));
|
||||
actions.addAction(i++, jump);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void executeActions(ActionList actions, int idx, int endIdx, ExecutionResult result, Map<String, Object> fakeFunctions) {
|
||||
List<GraphTargetItem> output = new ArrayList<>();
|
||||
ActionLocalData localData = new ActionLocalData();
|
||||
FixItemCounterTranslateStack stack = new FixItemCounterTranslateStack();
|
||||
int instructionsProcessed = 0;
|
||||
ActionConstantPool constantPool = null;
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
if (idx > endIdx) {
|
||||
break;
|
||||
}
|
||||
|
||||
Action action = actions.get(idx);
|
||||
instructionsProcessed++;
|
||||
|
||||
if (instructionsProcessed > executionLimit) {
|
||||
break;
|
||||
}
|
||||
|
||||
/*System.out.print(action.getASMSource(actions, new ArrayList<Long>(), ScriptExportMode.PCODE));
|
||||
for (int j = 0; j < stack.size(); j++) {
|
||||
System.out.print(" '" + stack.get(j).getResult() + "'");
|
||||
}
|
||||
System.out.println();*/
|
||||
if (action instanceof ActionConstantPool) {
|
||||
constantPool = (ActionConstantPool) action;
|
||||
}
|
||||
|
||||
if (action instanceof ActionDefineLocal) {
|
||||
GraphTargetItem top = stack.pop();
|
||||
String variableName = stack.peek().getResult().toString();
|
||||
result.defines.add(variableName);
|
||||
stack.push(top);
|
||||
}
|
||||
|
||||
if (action instanceof ActionGetVariable) {
|
||||
String variableName = stack.peek().getResult().toString();
|
||||
if (!localData.variables.containsKey(variableName)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (action instanceof ActionCallFunction) {
|
||||
String functionName = stack.pop().getResult().toString();
|
||||
long numArgs = EcmaScript.toUint32(stack.pop().getResult());
|
||||
if (numArgs == 0) {
|
||||
if (fakeFunctions != null && fakeFunctions.containsKey(functionName)) {
|
||||
stack.push(new DirectValueActionItem(fakeFunctions.get(functionName)));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
action.translate(localData, stack, output, Graph.SOP_USE_STATIC, "");
|
||||
}
|
||||
|
||||
if (!(action instanceof ActionPush
|
||||
|| action instanceof ActionPushDuplicate
|
||||
|| action instanceof ActionAdd
|
||||
|| action instanceof ActionAdd2
|
||||
|| action instanceof ActionSubtract
|
||||
|| action instanceof ActionModulo
|
||||
|| action instanceof ActionMultiply
|
||||
|| action instanceof ActionBitXor
|
||||
|| action instanceof ActionBitAnd
|
||||
|| action instanceof ActionBitOr
|
||||
|| action instanceof ActionBitLShift
|
||||
|| action instanceof ActionBitRShift
|
||||
|| action instanceof ActionDefineLocal
|
||||
|| action instanceof ActionJump
|
||||
|| action instanceof ActionGetVariable
|
||||
|| action instanceof ActionSetVariable
|
||||
|| action instanceof ActionEquals
|
||||
|| action instanceof ActionNot
|
||||
|| action instanceof ActionIf
|
||||
|| action instanceof ActionConstantPool
|
||||
|| action instanceof ActionCallFunction
|
||||
|| action instanceof ActionReturn
|
||||
|| action instanceof ActionEnd)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (action instanceof ActionPush) {
|
||||
ActionPush push = (ActionPush) action;
|
||||
boolean ok = true;
|
||||
for (Object value : push.values) {
|
||||
if (value instanceof ConstantIndex || value instanceof RegisterNumber) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!ok) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*for (String variable : localData.variables.keySet()) {
|
||||
System.out.println(Helper.byteArrToString(variable.getBytes()));
|
||||
}*/
|
||||
idx++;
|
||||
|
||||
if (action instanceof ActionJump) {
|
||||
ActionJump jump = (ActionJump) action;
|
||||
long address = jump.getAddress() + jump.getTotalActionLength() + jump.getJumpOffset();
|
||||
idx = actions.indexOf(actions.getByAddress(address));
|
||||
if (idx == -1) {
|
||||
throw new TranslateException("Jump target not found: " + address);
|
||||
}
|
||||
}
|
||||
|
||||
if (action instanceof ActionIf) {
|
||||
ActionIf aif = (ActionIf) action;
|
||||
if (EcmaScript.toBoolean(stack.pop().getResult())) {
|
||||
long address = aif.getAddress() + aif.getTotalActionLength() + aif.getJumpOffset();
|
||||
idx = actions.indexOf(actions.getByAddress(address));
|
||||
if (idx == -1) {
|
||||
throw new TranslateException("If target not found: " + address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (action instanceof ActionDefineFunction) {
|
||||
List<Action> lastActions = actions.getContainerLastActions(action);
|
||||
int lastActionIdx = actions.indexOf(lastActions.get(0));
|
||||
idx = lastActionIdx != -1 ? lastActionIdx + 1 : -1;
|
||||
}
|
||||
|
||||
if (/*localData.variables.size() == 1 && */stack.allItemsFixed() || action instanceof ActionEnd) {
|
||||
result.idx = idx == actions.size() ? idx - 1 : idx;
|
||||
result.instructionsProcessed = instructionsProcessed;
|
||||
result.constantPool = constantPool;
|
||||
result.variables.clear();
|
||||
for (String variableName : localData.variables.keySet()) {
|
||||
Object value = localData.variables.get(variableName).getResult();
|
||||
result.variables.put(variableName, value);
|
||||
}
|
||||
result.stack.clear();
|
||||
result.stack.addAll(stack);
|
||||
}
|
||||
|
||||
if (action instanceof ActionReturn) {
|
||||
if (output.size() > 0) {
|
||||
ReturnActionItem ret = (ReturnActionItem) output.get(output.size() - 1);
|
||||
result.resultValue = ret.value.getResult();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (EmptyStackException | TranslateException | InterruptedException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> getFakeFunctionResults(ActionList actions) {
|
||||
/*
|
||||
DefineFunction "fakeName" 0 {
|
||||
Push 1777
|
||||
Return
|
||||
}
|
||||
*/
|
||||
|
||||
Map<String, Object> results = new HashMap<>();
|
||||
|
||||
for (int i = 0; i < actions.size(); i++) {
|
||||
Action action = actions.get(i);
|
||||
if (action instanceof ActionDefineFunction) {
|
||||
ActionDefineFunction def = (ActionDefineFunction) action;
|
||||
if (def.paramNames.isEmpty()) {
|
||||
ExecutionResult result = new ExecutionResult();
|
||||
List<Action> lastActions = actions.getContainerLastActions(action);
|
||||
int lastActionIdx = actions.indexOf(lastActions.get(0));
|
||||
executeActions(actions, i + 1, lastActionIdx, result, null);
|
||||
if (result.resultValue != null) {
|
||||
results.put(def.functionName, result.resultValue);
|
||||
for (int j = i; j <= lastActionIdx; j++) {
|
||||
actions.removeAction(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
class ExecutionResult {
|
||||
|
||||
public int idx = -1;
|
||||
public int instructionsProcessed = -1;
|
||||
public ActionConstantPool constantPool;
|
||||
public Map<String, Object> variables = new HashMap<>();
|
||||
public Set<String> defines = new HashSet<>();
|
||||
public TranslateStack stack = new TranslateStack();
|
||||
public Object resultValue;
|
||||
}
|
||||
}
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.deobfuscation;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionList;
|
||||
import com.jpexs.decompiler.flash.action.ActionLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionAdd;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionEquals;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionIf;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionJump;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionMultiply;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionNot;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionSubtract;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ConstantIndex;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionAdd2;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitAnd;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitLShift;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitOr;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitRShift;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitXor;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionModulo;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionPushDuplicate;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.helpers.SWFDecompilerListener;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
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.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ActionDeobfuscatorSimple implements SWFDecompilerListener {
|
||||
|
||||
private final int executionLimit = 30000;
|
||||
|
||||
@Override
|
||||
public void actionListParsed(ActionList actions, SWF swf) {
|
||||
removeObfuscationIfs(actions);
|
||||
}
|
||||
|
||||
private boolean removeObfuscationIfs(ActionList actions) {
|
||||
if (actions.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < actions.size(); i++) {
|
||||
ExecutionResult result = new ExecutionResult();
|
||||
executeActions(actions, i, actions.size() - 1, result);
|
||||
|
||||
if (result.idx != -1) {
|
||||
int newIstructionCount = 1; // jump
|
||||
if (!result.stack.isEmpty()) {
|
||||
newIstructionCount++;
|
||||
}
|
||||
|
||||
if (newIstructionCount * 2 < result.instructionsProcessed) {
|
||||
Action target = actions.get(result.idx);
|
||||
Action prevAction = actions.get(i);
|
||||
|
||||
if (!result.stack.isEmpty()) {
|
||||
ActionPush push = new ActionPush(0);
|
||||
push.values.clear();
|
||||
for (GraphTargetItem graphTargetItem : result.stack) {
|
||||
DirectValueActionItem dv = (DirectValueActionItem) graphTargetItem;
|
||||
push.values.add(dv.value);
|
||||
}
|
||||
push.setAddress(prevAction.getAddress());
|
||||
actions.addAction(i++, push);
|
||||
prevAction = push;
|
||||
}
|
||||
|
||||
ActionJump jump = new ActionJump(0);
|
||||
jump.setAddress(prevAction.getAddress());
|
||||
jump.setJumpOffset((int) (target.getAddress() - jump.getAddress() - jump.getTotalActionLength()));
|
||||
actions.addAction(i++, jump);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void executeActions(ActionList actions, int idx, int endIdx, ExecutionResult result) {
|
||||
List<GraphTargetItem> output = new ArrayList<>();
|
||||
ActionLocalData localData = new ActionLocalData();
|
||||
FixItemCounterTranslateStack stack = new FixItemCounterTranslateStack();
|
||||
int instructionsProcessed = 0;
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
if (idx > endIdx) {
|
||||
break;
|
||||
}
|
||||
|
||||
Action action = actions.get(idx);
|
||||
instructionsProcessed++;
|
||||
|
||||
if (instructionsProcessed > executionLimit) {
|
||||
break;
|
||||
}
|
||||
|
||||
/*System.out.print(action.getASMSource(actions, new ArrayList<Long>(), ScriptExportMode.PCODE));
|
||||
for (int j = 0; j < stack.size(); j++) {
|
||||
System.out.print(" '" + stack.get(j).getResult() + "'");
|
||||
}
|
||||
System.out.println();*/
|
||||
action.translate(localData, stack, output, Graph.SOP_USE_STATIC, "");
|
||||
|
||||
if (!(action instanceof ActionPush
|
||||
|| action instanceof ActionPushDuplicate
|
||||
|| action instanceof ActionAdd
|
||||
|| action instanceof ActionAdd2
|
||||
|| action instanceof ActionSubtract
|
||||
|| action instanceof ActionModulo
|
||||
|| action instanceof ActionMultiply
|
||||
|| action instanceof ActionBitXor
|
||||
|| action instanceof ActionBitAnd
|
||||
|| action instanceof ActionBitOr
|
||||
|| action instanceof ActionBitLShift
|
||||
|| action instanceof ActionBitRShift
|
||||
|| action instanceof ActionEquals
|
||||
|| action instanceof ActionNot
|
||||
|| action instanceof ActionIf)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (action instanceof ActionPush) {
|
||||
ActionPush push = (ActionPush) action;
|
||||
boolean ok = true;
|
||||
for (Object value : push.values) {
|
||||
if (value instanceof ConstantIndex || value instanceof RegisterNumber) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!ok) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
idx++;
|
||||
|
||||
if (action instanceof ActionIf) {
|
||||
ActionIf aif = (ActionIf) action;
|
||||
if (EcmaScript.toBoolean(stack.pop().getResult())) {
|
||||
long address = aif.getAddress() + aif.getTotalActionLength() + aif.getJumpOffset();
|
||||
idx = actions.indexOf(actions.getByAddress(address));
|
||||
if (idx == -1) {
|
||||
throw new TranslateException("If target not found: " + address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.allItemsFixed()) {
|
||||
result.idx = idx == actions.size() ? idx - 1 : idx;
|
||||
result.instructionsProcessed = instructionsProcessed;
|
||||
result.stack.clear();
|
||||
result.stack.addAll(stack);
|
||||
}
|
||||
}
|
||||
} catch (EmptyStackException | TranslateException | InterruptedException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
class ExecutionResult {
|
||||
|
||||
public int idx = -1;
|
||||
public int instructionsProcessed = -1;
|
||||
public TranslateStack stack = new TranslateStack();
|
||||
public Object resultValue;
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.deobfuscation;
|
||||
|
||||
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;
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.flashlite;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.model.FSCommand2ActionItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ActionFSCommand2 extends Action {
|
||||
|
||||
public ActionFSCommand2() {
|
||||
super(0x2D, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FSCommand2";
|
||||
}
|
||||
|
||||
@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) {
|
||||
long numArgs = popLong(stack);
|
||||
GraphTargetItem command = stack.pop();
|
||||
List<GraphTargetItem> args = new ArrayList<>();
|
||||
for (long l = 0; l < numArgs; l++) {
|
||||
args.add(stack.pop());
|
||||
}
|
||||
stack.push(new FSCommand2ActionItem(this, command, args));
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.flashlite;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.model.StrictModeActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.ParseException;
|
||||
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ActionStrictMode extends Action {
|
||||
|
||||
public int mode;
|
||||
|
||||
public ActionStrictMode(SWFInputStream sis) throws IOException {
|
||||
super(0x89, 1);
|
||||
mode = sis.readUI8("mode");
|
||||
}
|
||||
|
||||
public ActionStrictMode(FlasmLexer lexer) throws IOException, ParseException {
|
||||
super(0x89, 1);
|
||||
mode = (int) lexLong(lexer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes(int version) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, version);
|
||||
try {
|
||||
sos.writeUI8(mode);
|
||||
sos.close();
|
||||
} catch (IOException e) {
|
||||
throw new Error("This should never happen.", e);
|
||||
}
|
||||
return surroundWithAction(baos.toByteArray(), version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StrictMode " + mode;
|
||||
}
|
||||
|
||||
@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) {
|
||||
output.add(new StrictModeActionItem(this, mode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPop;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
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.model.LocalData;
|
||||
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ActionItem extends GraphTargetItem implements Serializable {
|
||||
|
||||
public ActionItem() {
|
||||
super(null, NOPRECEDENCE);
|
||||
}
|
||||
|
||||
public ActionItem(GraphSourceItem instruction, int precedence) {
|
||||
super(instruction, precedence);
|
||||
}
|
||||
|
||||
protected boolean isEmptyString(GraphTargetItem target) {
|
||||
if (target instanceof DirectValueActionItem) {
|
||||
if (((DirectValueActionItem) target).value instanceof String) {
|
||||
|
||||
if (((DirectValueActionItem) target).value.equals("")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected GraphTextWriter stripQuotes(GraphTargetItem target, LocalData localData, GraphTextWriter writer) throws InterruptedException {
|
||||
if (target instanceof DirectValueActionItem) {
|
||||
if (((DirectValueActionItem) target).value instanceof String) {
|
||||
return writer.append((String) ((DirectValueActionItem) target).value);
|
||||
}
|
||||
}
|
||||
if (target == null) {
|
||||
return writer;
|
||||
} else {
|
||||
return target.toString(writer, localData);
|
||||
}
|
||||
}
|
||||
|
||||
protected List<GraphSourceItem> toSourceCall(SourceGeneratorLocalData localData, SourceGenerator gen, List<GraphTargetItem> list) throws CompilationException {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ret.addAll(0, list.get(i).toSource(localData, gen));
|
||||
}
|
||||
ret.add(new ActionPush((Long) (long) list.size()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
List<GraphSourceItem> ret = toSource(localData, generator);
|
||||
if (hasReturnValue()) {
|
||||
ret.add(new ActionPop());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem returnType() {
|
||||
return new UnboundedTypeItem();
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionAsciiToChar;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class AsciiToCharActionItem extends ActionItem {
|
||||
|
||||
public AsciiToCharActionItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("chr");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionAsciiToChar());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionCall;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class CallActionItem extends ActionItem {
|
||||
|
||||
public CallActionItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("call");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
stripQuotes(value, localData, writer);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionCall());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionCallFunction;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CallFunctionActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem functionName;
|
||||
public List<GraphTargetItem> arguments;
|
||||
public GraphTargetItem calculatedFunction;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public CallFunctionActionItem(GraphSourceItem instruction, GraphTargetItem functionName, List<GraphTargetItem> arguments) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.functionName = functionName;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
String paramStr = "";
|
||||
stripQuotes(functionName, localData, writer);
|
||||
writer.spaceBeforeCallParenthesies(arguments.size());
|
||||
writer.append("(");
|
||||
for (int t = 0; t < arguments.size(); t++) {
|
||||
if (t > 0) {
|
||||
writer.append(",");
|
||||
}
|
||||
arguments.get(t).toStringNL(writer, localData);
|
||||
}
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(functionName.getNeededSources());
|
||||
for (GraphTargetItem ti : arguments) {
|
||||
ret.addAll(ti.getNeededSources());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
|
||||
if (calculatedFunction == null) {
|
||||
return false;
|
||||
}
|
||||
if (dependencies.contains(calculatedFunction)) {
|
||||
return false;
|
||||
}
|
||||
dependencies.add(calculatedFunction);
|
||||
return calculatedFunction.isCompileTime(dependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
if (calculatedFunction == null) {
|
||||
return null;
|
||||
}
|
||||
return calculatedFunction.getResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 37 * hash + (this.functionName != null ? this.functionName.hashCode() : 0);
|
||||
hash = 37 * hash + (this.arguments != null ? this.arguments.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final CallFunctionActionItem other = (CallFunctionActionItem) obj;
|
||||
if (this.functionName != other.functionName && (this.functionName == null || !this.functionName.equals(other.functionName))) {
|
||||
return false;
|
||||
}
|
||||
if (this.arguments != other.arguments && (this.arguments == null || !this.arguments.equals(other.arguments))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, toSourceCall(localData, generator, arguments), functionName, new ActionCallFunction());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionCallMethod;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CallMethodActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem methodName;
|
||||
public GraphTargetItem scriptObject;
|
||||
public List<GraphTargetItem> arguments;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.addAll(arguments);
|
||||
ret.add(scriptObject);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public CallMethodActionItem(GraphSourceItem instruction, GraphTargetItem scriptObject, GraphTargetItem methodName, List<GraphTargetItem> arguments) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.methodName = methodName;
|
||||
this.arguments = arguments;
|
||||
this.scriptObject = scriptObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
boolean blankMethod = false;
|
||||
if (methodName instanceof DirectValueActionItem) {
|
||||
if (((DirectValueActionItem) methodName).value instanceof Undefined) {
|
||||
blankMethod = true;
|
||||
}
|
||||
if (((DirectValueActionItem) methodName).value instanceof String) {
|
||||
if (((DirectValueActionItem) methodName).value.equals("")) {
|
||||
blankMethod = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!blankMethod) {
|
||||
if (scriptObject.getPrecedence() > this.precedence) {
|
||||
writer.append("(");
|
||||
scriptObject.toString(writer, localData);
|
||||
writer.append(")");
|
||||
} else {
|
||||
scriptObject.toString(writer, localData);
|
||||
}
|
||||
writer.append(".");
|
||||
stripQuotes(methodName, localData, writer);
|
||||
} else {
|
||||
scriptObject.toString(writer, localData);
|
||||
}
|
||||
writer.spaceBeforeCallParenthesies(arguments.size());
|
||||
writer.append("(");
|
||||
|
||||
for (int t = 0; t < arguments.size(); t++) {
|
||||
if (t > 0) {
|
||||
writer.append(",");
|
||||
}
|
||||
arguments.get(t).toStringNL(writer, localData);
|
||||
}
|
||||
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(methodName.getNeededSources());
|
||||
ret.addAll(scriptObject.getNeededSources());
|
||||
for (GraphTargetItem ti : arguments) {
|
||||
ret.addAll(ti.getNeededSources());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, toSourceCall(localData, generator, arguments), scriptObject, methodName, new ActionCallMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf7.ActionCastOp;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CastOpActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem constructor;
|
||||
public GraphTargetItem object;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(constructor);
|
||||
ret.add(object);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public CastOpActionItem(GraphSourceItem instruction, GraphTargetItem constructor, GraphTargetItem object) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.constructor = constructor;
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("(");
|
||||
stripQuotes(constructor, localData, writer);
|
||||
writer.append(")");
|
||||
return object.toString(writer, localData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(constructor.getNeededSources());
|
||||
ret.addAll(object.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, constructor, object, new ActionCastOp());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionCharToAscii;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CharToAsciiActionItem extends ActionItem {
|
||||
|
||||
public CharToAsciiActionItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("ord");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
|
||||
if (value instanceof DirectValueActionItem) {
|
||||
DirectValueActionItem dv = (DirectValueActionItem) value;
|
||||
if (dv.value instanceof String) {
|
||||
String s = (String) dv.value;
|
||||
if (s.length() > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
Object res = value.getResult();
|
||||
String s = res.toString();
|
||||
if (s.length() > 0) {
|
||||
char c = s.charAt(0);
|
||||
return (int) c;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionCharToAscii());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionCloneSprite;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CloneSpriteActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem source;
|
||||
public GraphTargetItem target;
|
||||
public GraphTargetItem depth;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(target);
|
||||
ret.add(source);
|
||||
ret.add(depth);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public CloneSpriteActionItem(GraphSourceItem instruction, GraphTargetItem source, GraphTargetItem target, GraphTargetItem depth) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.source = source;
|
||||
this.target = target;
|
||||
this.depth = depth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("duplicateMovieClip");
|
||||
writer.spaceBeforeCallParenthesies(3);
|
||||
writer.append("(");
|
||||
target.toString(writer, localData);
|
||||
writer.append(",");
|
||||
source.toString(writer, localData);
|
||||
writer.append(",");
|
||||
depth.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(source.getNeededSources());
|
||||
ret.addAll(target.getNeededSources());
|
||||
ret.addAll(depth.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, source, target, depth, new ActionCloneSprite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConstantPool {
|
||||
|
||||
public List<String> constants = new ArrayList<>();
|
||||
|
||||
public ConstantPool() {
|
||||
}
|
||||
|
||||
public ConstantPool(List<String> constants) {
|
||||
this.constants = constants;
|
||||
}
|
||||
|
||||
public void setNew(List<String> constants) {
|
||||
this.constants = constants;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "x " + constants.toString();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return constants.isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDecrement;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class DecrementActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem object;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(object);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public DecrementActionItem(GraphSourceItem instruction, GraphTargetItem object) {
|
||||
super(instruction, PRECEDENCE_ADDITIVE);
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
object.toString(writer, localData);
|
||||
return writer.append(" - 1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
|
||||
if (dependencies.contains(object)) {
|
||||
return false;
|
||||
}
|
||||
dependencies.add(object);
|
||||
return object.isCompileTime(dependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
return EcmaScript.toNumber(object.getResult()) - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(object.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, object, new ActionDecrement());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Deobfuscation;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal2;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DefineLocalActionItem extends ActionItem implements SetTypeActionItem {
|
||||
|
||||
public GraphTargetItem name;
|
||||
//public GraphTargetItem value;
|
||||
private int tempRegister = -1;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(name);
|
||||
if (value != null) {
|
||||
ret.add(value);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(GraphTargetItem value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTempRegister() {
|
||||
return tempRegister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTempRegister(int tempRegister) {
|
||||
this.tempRegister = tempRegister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public DefineLocalActionItem(GraphSourceItem instruction, GraphTargetItem name, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("var ");
|
||||
|
||||
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!Deobfuscation.isValidName(((DirectValueActionItem) name).toStringNoQuotes(localData),"this","super"))){
|
||||
writer.append(Deobfuscation.makeObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData)));
|
||||
} else {
|
||||
stripQuotes(name, localData, writer);
|
||||
}
|
||||
if (value == null) {
|
||||
return writer;
|
||||
}
|
||||
writer.append(" = ");
|
||||
return value.toString(writer, localData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
ret.addAll(name.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getObject() {
|
||||
return new DefineLocalActionItem(src, name, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
if (value == null) {
|
||||
return toSourceMerge(localData, generator, name, new ActionDefineLocal2());
|
||||
} else {
|
||||
return toSourceMerge(localData, generator, name, value, new ActionDefineLocal());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class DefineRegisterActionItem extends ActionItem {
|
||||
|
||||
private final String identifier;
|
||||
private final int register;
|
||||
|
||||
public DefineRegisterActionItem(String identifier, int register) {
|
||||
super(null, PRECEDENCE_PRIMARY);
|
||||
this.identifier = identifier;
|
||||
this.register = register;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
return writer.append("var " + identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDelete;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDelete2;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DeleteActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem object;
|
||||
public GraphTargetItem propertyName;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(object);
|
||||
ret.add(propertyName);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public DeleteActionItem(GraphSourceItem instruction, GraphTargetItem object, GraphTargetItem propertyName) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.object = object;
|
||||
this.propertyName = propertyName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("delete ");
|
||||
if (object == null) {
|
||||
return propertyName.toStringNoQuotes(writer, localData);
|
||||
}
|
||||
object.toStringNoQuotes(writer, localData);
|
||||
writer.append(".");
|
||||
return propertyName.toStringNoQuotes(writer, localData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(object.getNeededSources());
|
||||
ret.addAll(propertyName.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
if (object == null) {
|
||||
return toSourceMerge(localData, generator, propertyName, new ActionDelete2());
|
||||
}
|
||||
return toSourceMerge(localData, generator, object, propertyName, new ActionDelete());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+256
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ConstantIndex;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.ecma.Null;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
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.model.LocalData;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class DirectValueActionItem extends ActionItem {
|
||||
|
||||
public Object value;
|
||||
public List<String> constants;
|
||||
public GraphTargetItem computedRegValue;
|
||||
|
||||
public DirectValueActionItem(Object o) {
|
||||
this(null, 0, o, new ArrayList<String>());
|
||||
}
|
||||
|
||||
public DirectValueActionItem(GraphSourceItem instruction, int instructionPos, Object value, List<String> constants) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.constants = constants;
|
||||
this.value = value;
|
||||
this.pos = instructionPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVariableComputed() {
|
||||
if (computedRegValue != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
if (computedRegValue != null) {
|
||||
return computedRegValue.getResult();
|
||||
}
|
||||
if (value instanceof Double) {
|
||||
return (Double) value;
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
return (double) (Float) value;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
return (double) (Long) value;
|
||||
}
|
||||
if (value instanceof Boolean) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (value instanceof String) {
|
||||
return value;
|
||||
}
|
||||
if (value instanceof ConstantIndex) {
|
||||
return (this.constants.get(((ConstantIndex) value).index));
|
||||
}
|
||||
if (value instanceof RegisterNumber) {
|
||||
return new Undefined(); //has not computed value
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toStringNoQuotes(LocalData localData) {
|
||||
if (value instanceof Double) {
|
||||
if (Double.compare((double) (Double) value, 0) == 0) {
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
if (Float.compare((float) (Float) value, 0) == 0) {
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return (String) value;
|
||||
}
|
||||
if (value instanceof ConstantIndex) {
|
||||
return this.constants.get(((ConstantIndex) value).index);
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendToNoQuotes(GraphTextWriter writer, LocalData localData) {
|
||||
if (value instanceof Double) {
|
||||
if (Double.compare((double) (Double) value, 0) == 0) {
|
||||
return writer.append("0");
|
||||
}
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
if (Float.compare((float) (Float) value, 0) == 0) {
|
||||
return writer.append("0");
|
||||
}
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return writer.append((String) value);
|
||||
}
|
||||
if (value instanceof ConstantIndex) {
|
||||
return writer.append(this.constants.get(((ConstantIndex) value).index));
|
||||
}
|
||||
return writer.append(value.toString());
|
||||
}
|
||||
|
||||
public String toStringNoH(ConstantPool constants) {
|
||||
if (value instanceof Double) {
|
||||
if (Double.compare((double) (Double) value, 0) == 0) {
|
||||
return ("0");
|
||||
}
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
if (Float.compare((float) (Float) value, 0) == 0) {
|
||||
return ("0");
|
||||
}
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return (String) value;
|
||||
}
|
||||
if (value instanceof ConstantIndex) {
|
||||
return (this.constants.get(((ConstantIndex) value).index));
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
if (value instanceof Double) {
|
||||
if (Double.compare((double) (Double) value, 0) == 0) {
|
||||
return writer.append("0");
|
||||
}
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
if (Float.compare((float) (Float) value, 0) == 0) {
|
||||
return writer.append("0");
|
||||
}
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return writer.append("\"" + Helper.escapeString((String) value) + "\"");
|
||||
}
|
||||
if (value instanceof ConstantIndex) {
|
||||
return writer.append("\"" + Helper.escapeString(this.constants.get(((ConstantIndex) value).index)) + "\"");
|
||||
}
|
||||
if (value instanceof RegisterNumber) {
|
||||
return writer.append(((RegisterNumber) value).translate());
|
||||
}
|
||||
return writer.append(value.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
|
||||
if (computedRegValue != null) {
|
||||
if (dependencies.contains(computedRegValue)) {
|
||||
return false;
|
||||
}
|
||||
dependencies.add(computedRegValue);
|
||||
}
|
||||
return (value instanceof Double) || (value instanceof Float) || (value instanceof Boolean) || (value instanceof Long) || (value instanceof Null) || (computedRegValue != null && computedRegValue.isCompileTime(dependencies)) || (value instanceof String) || (value instanceof ConstantIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 71 * hash + Objects.hashCode(this.value);
|
||||
hash = 71 * hash + System.identityHashCode(this.constants);
|
||||
hash = 71 * hash + pos;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valueEquals(GraphTargetItem obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof DirectValueActionItem)) {
|
||||
return false;
|
||||
}
|
||||
final DirectValueActionItem other = (DirectValueActionItem) obj;
|
||||
if (!Objects.equals(this.value, other.value)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.constants, other.constants)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final DirectValueActionItem other = (DirectValueActionItem) obj;
|
||||
if (!Objects.equals(this.value, other.value)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.constants, other.constants)) {
|
||||
return false;
|
||||
}
|
||||
if (other.pos != this.pos) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, new ActionPush(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isString() {
|
||||
return (value instanceof String) || (value instanceof ConstantIndex);
|
||||
}
|
||||
|
||||
public String getAsString() {
|
||||
if (!isString()) {
|
||||
return null;
|
||||
}
|
||||
return (String) getResult();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class EnumerateActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem object;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(object);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public EnumerateActionItem(GraphSourceItem instruction, GraphTargetItem object) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("enumerate ");
|
||||
return object.toString(writer, localData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(object.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable;
|
||||
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.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class EvalActionItem extends ActionItem {
|
||||
|
||||
public EvalActionItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("eval");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionGetVariable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class ExtendsActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem subclass;
|
||||
public GraphTargetItem superclass;
|
||||
|
||||
public ExtendsActionItem(GraphSourceItem instruction, GraphTargetItem subclass, GraphTargetItem superclass) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.subclass = subclass;
|
||||
this.superclass = superclass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
subclass.toString(writer, localData);
|
||||
writer.append(" extends ");
|
||||
return stripQuotes(superclass, localData, writer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(subclass.getNeededSources());
|
||||
ret.addAll(superclass.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.flashlite.ActionFSCommand2;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FSCommand2ActionItem extends ActionItem {
|
||||
|
||||
public String target;
|
||||
public List<GraphTargetItem> arguments;
|
||||
public GraphTargetItem command;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.addAll(arguments);
|
||||
ret.add(command);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public FSCommand2ActionItem(GraphSourceItem instruction, GraphTargetItem command, List<GraphTargetItem> arguments) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.command = command;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("FSCommand2");
|
||||
writer.spaceBeforeCallParenthesies(arguments.size());
|
||||
writer.append("(");
|
||||
command.toString(writer, localData);
|
||||
for (int t = 0; t < arguments.size(); t++) {
|
||||
writer.append(",");
|
||||
arguments.get(t).toString(writer, localData);
|
||||
}
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(command.getNeededSources());
|
||||
for (GraphTargetItem ti : arguments) {
|
||||
ret.addAll(ti.getNeededSources());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
for (GraphTargetItem a : arguments) {
|
||||
ret.addAll(a.toSource(localData, generator));
|
||||
}
|
||||
ret.addAll(command.toSource(localData, generator));
|
||||
ret.add(new ActionPush((Long) (long) arguments.size()));
|
||||
ret.add(new ActionFSCommand2());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true; //FIXME ?
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf3.ActionGetURL;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
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 static com.jpexs.decompiler.graph.GraphTargetItem.toSourceMerge;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class FSCommandActionItem extends ActionItem {
|
||||
|
||||
private final GraphTargetItem command;
|
||||
|
||||
public FSCommandActionItem(GraphSourceItem instruction, GraphTargetItem command) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append("fscommand");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
try {
|
||||
command.appendTo(writer, localData);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(FSCommandActionItem.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
ActionSourceGenerator asg = (ActionSourceGenerator) generator;
|
||||
if ((command instanceof DirectValueActionItem) && ((DirectValueActionItem) command).isString()) {
|
||||
return toSourceMerge(localData, generator, new ActionGetURL("FSCommand:" + ((DirectValueActionItem) command).getAsString(), ""));
|
||||
}
|
||||
return toSourceMerge(localData, generator, new AddActionItem(null, asg.pushConstTargetItem("FSCommand:"), command, true), asg.pushConstTargetItem(""), new ActionGetURL2(1/*GET*/, false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.Deobfuscation;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction;
|
||||
import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class FunctionActionItem extends ActionItem {
|
||||
|
||||
public List<GraphTargetItem> actions;
|
||||
public List<String> constants;
|
||||
public String functionName;
|
||||
public List<String> paramNames;
|
||||
public GraphTargetItem calculatedFunctionName;
|
||||
private int regStart;
|
||||
private List<VariableActionItem> variables;
|
||||
|
||||
public static final int REGISTER_THIS = 1;
|
||||
public static final int REGISTER_ARGUMENTS = 2;
|
||||
public static final int REGISTER_SUPER = 3;
|
||||
public static final int REGISTER_ROOT = 4;
|
||||
public static final int REGISTER_PARENT = 5;
|
||||
public static final int REGISTER_GLOBAL = 6;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.addAll(actions);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public FunctionActionItem() {
|
||||
super(null, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
|
||||
public FunctionActionItem(GraphSourceItem instruction, String functionName, List<String> paramNames, List<GraphTargetItem> actions, List<String> constants, int regStart, List<VariableActionItem> variables) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.actions = actions;
|
||||
this.constants = constants;
|
||||
this.functionName = functionName;
|
||||
this.paramNames = paramNames;
|
||||
this.regStart = regStart;
|
||||
this.variables = variables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("function");
|
||||
if (calculatedFunctionName != null) {
|
||||
writer.append(" ");
|
||||
String fname = calculatedFunctionName.toStringNoQuotes(localData);
|
||||
if (!Deobfuscation.isValidName(fname)) {
|
||||
writer.append(Deobfuscation.makeObfuscatedIdentifier(fname));
|
||||
} else {
|
||||
calculatedFunctionName.appendToNoQuotes(writer, localData);
|
||||
}
|
||||
} else if (!functionName.isEmpty()) {
|
||||
writer.append(" ");
|
||||
if (!Deobfuscation.isValidName(functionName)) {
|
||||
writer.append(Deobfuscation.makeObfuscatedIdentifier(functionName));
|
||||
} else {
|
||||
writer.append(functionName);
|
||||
}
|
||||
}
|
||||
writer.spaceBeforeCallParenthesies(paramNames.size());
|
||||
writer.append("(");
|
||||
|
||||
for (int p = 0; p < paramNames.size(); p++) {
|
||||
if (p > 0) {
|
||||
writer.append(", ");
|
||||
}
|
||||
String pname = paramNames.get(p);
|
||||
if (pname == null || pname.isEmpty()) {
|
||||
pname = new RegisterNumber(regStart + p).translate();
|
||||
}
|
||||
if (!Deobfuscation.isValidName(pname)) {
|
||||
writer.append(Deobfuscation.makeObfuscatedIdentifier(pname));
|
||||
}
|
||||
writer.append(pname);
|
||||
}
|
||||
writer.append(")").startBlock();
|
||||
|
||||
Graph.graphToString(actions, writer, localData);
|
||||
|
||||
return writer.endBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
for (GraphTargetItem ti : actions) {
|
||||
ret.addAll(ti.getNeededSources());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsSemicolon() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
|
||||
for (GraphTargetItem a : actions) {
|
||||
if (dependencies.contains(a)) {
|
||||
return false;
|
||||
}
|
||||
dependencies.add(a);
|
||||
if (!a.isCompileTime(dependencies)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
if (!actions.isEmpty()) {
|
||||
if (actions.get(actions.size() - 1) instanceof ReturnActionItem) {
|
||||
ReturnActionItem r = (ReturnActionItem) actions.get(actions.size() - 1);
|
||||
return r.value.getResult();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsNewLine() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
|
||||
Set<String> usedNames = new HashSet<>();
|
||||
for (VariableActionItem v : variables) {
|
||||
usedNames.add(v.getVariableName());
|
||||
}
|
||||
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
List<Integer> paramRegs = new ArrayList<>();
|
||||
SourceGeneratorLocalData localDataCopy = Helper.deepCopy(localData);
|
||||
localDataCopy.inFunction++;
|
||||
boolean preloadParentFlag = false;
|
||||
boolean preloadRootFlag = false;
|
||||
boolean preloadSuperFlag = false;
|
||||
boolean preloadArgumentsFlag = false;
|
||||
boolean preloadThisFlag = false;
|
||||
boolean preloadGlobalFlag = false;
|
||||
|
||||
boolean suppressParentFlag = false;
|
||||
boolean suppressArgumentsFlag = false;
|
||||
boolean suppressThisFlag = false;
|
||||
|
||||
boolean needsFun2 = false;
|
||||
|
||||
List<String> registerNames = new ArrayList<>();
|
||||
registerNames.add("***** ZERO *****");
|
||||
if (usedNames.contains("this")) {
|
||||
needsFun2 = true;
|
||||
preloadThisFlag = true;
|
||||
registerNames.add("this");
|
||||
} else {
|
||||
suppressThisFlag = true;
|
||||
}
|
||||
if (usedNames.contains("arguments")) {
|
||||
preloadArgumentsFlag = true;
|
||||
needsFun2 = true;
|
||||
registerNames.add("arguments");
|
||||
} else {
|
||||
suppressArgumentsFlag = true;
|
||||
}
|
||||
if (usedNames.contains("super")) {
|
||||
preloadSuperFlag = true;
|
||||
needsFun2 = true;
|
||||
registerNames.add("super");
|
||||
}
|
||||
if (usedNames.contains("_root")) {
|
||||
preloadRootFlag = true;
|
||||
needsFun2 = true;
|
||||
registerNames.add("_root");
|
||||
}
|
||||
if (usedNames.contains("_parent")) {
|
||||
preloadParentFlag = true;
|
||||
needsFun2 = true;
|
||||
registerNames.add("_parent");
|
||||
} else {
|
||||
suppressParentFlag = true;
|
||||
}
|
||||
if (usedNames.contains("_global")) {
|
||||
needsFun2 = true;
|
||||
preloadGlobalFlag = true;
|
||||
registerNames.add("_global");
|
||||
}
|
||||
|
||||
int preloadedNumber = registerNames.size();
|
||||
if (!paramNames.isEmpty()) {
|
||||
needsFun2 = true;
|
||||
}
|
||||
if (localData.inMethod) {
|
||||
needsFun2 = true;
|
||||
}
|
||||
if (localData.inFunction > 1) {
|
||||
needsFun2 = true;
|
||||
}
|
||||
if (needsFun2) {
|
||||
for (int i = 0; i < paramNames.size(); i++) {
|
||||
paramRegs.add(registerNames.size());
|
||||
registerNames.add(paramNames.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (actions != null && !actions.isEmpty()) {
|
||||
localDataCopy.inFunction++;
|
||||
|
||||
for (VariableActionItem v : variables) {
|
||||
String varName = v.getVariableName();
|
||||
GraphTargetItem stored = v.getStoreValue();
|
||||
if (needsFun2) {
|
||||
if (v.isDefinition() && !registerNames.contains(varName)) {
|
||||
registerNames.add(varName);
|
||||
}
|
||||
}
|
||||
|
||||
if (registerNames.contains(varName)) {
|
||||
if (stored != null) {
|
||||
v.setBoxedValue(new StoreRegisterActionItem(null, new RegisterNumber(registerNames.indexOf(varName), varName), stored, false));
|
||||
} else {
|
||||
v.setBoxedValue(new DirectValueActionItem(new RegisterNumber(registerNames.indexOf(varName), varName)));
|
||||
}
|
||||
} else {
|
||||
if (v.isDefinition()) {
|
||||
v.setBoxedValue(new DefineLocalActionItem(null, ((ActionSourceGenerator) generator).pushConstTargetItem(varName), stored));
|
||||
} else {
|
||||
if (stored != null) {
|
||||
v.setBoxedValue(new SetVariableActionItem(null, ((ActionSourceGenerator) generator).pushConstTargetItem(varName), stored));
|
||||
} else {
|
||||
v.setBoxedValue(new GetVariableActionItem(null, ((ActionSourceGenerator) generator).pushConstTargetItem(varName)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
ret.addAll(asGenerator.toActionList(asGenerator.generate(localDataCopy, actions)));
|
||||
}
|
||||
int len = Action.actionsToBytes(asGenerator.toActionList(ret), false, SWF.DEFAULT_VERSION).length;
|
||||
if (!needsFun2 && paramNames.isEmpty()) {
|
||||
ret.add(0, new ActionDefineFunction(functionName, paramNames, len, SWF.DEFAULT_VERSION));
|
||||
} else {
|
||||
ret.add(0, new ActionDefineFunction2(functionName,
|
||||
preloadParentFlag,
|
||||
preloadRootFlag,
|
||||
suppressParentFlag,
|
||||
preloadSuperFlag,
|
||||
suppressArgumentsFlag,
|
||||
preloadArgumentsFlag,
|
||||
suppressThisFlag,
|
||||
preloadThisFlag,
|
||||
preloadGlobalFlag,
|
||||
registerNames.size(), len, SWF.DEFAULT_VERSION, paramNames, paramRegs));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false; //function actually returns itself, but here is false for generator to not add Pop
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Deobfuscation;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionGetMember;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GetMemberActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem object;
|
||||
public GraphTargetItem memberName;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(object);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public GetMemberActionItem(GraphSourceItem instruction, GraphTargetItem object, GraphTargetItem memberName) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.object = object;
|
||||
this.memberName = memberName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
object.toString(writer, localData);
|
||||
if ((!(memberName instanceof DirectValueActionItem)) || (!((DirectValueActionItem) memberName).isString()) || (!Deobfuscation.isValidName(((DirectValueActionItem) memberName).toStringNoQuotes(localData)))) {
|
||||
writer.append("[");
|
||||
memberName.toString(writer, localData);
|
||||
return writer.append("]");
|
||||
}
|
||||
writer.append(".");
|
||||
return stripQuotes(memberName, localData, writer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(object.getNeededSources());
|
||||
ret.addAll(memberName.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 47 * hash + (this.object != null ? this.object.hashCode() : 0);
|
||||
hash = 47 * hash + (this.memberName != null ? this.memberName.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final GetMemberActionItem other = (GetMemberActionItem) obj;
|
||||
if (this.object != other.object && (this.object == null || !this.object.equals(other.object))) {
|
||||
return false;
|
||||
}
|
||||
if (this.memberName != other.memberName && (this.memberName == null || !this.memberName.equals(other.memberName))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, object, memberName, new ActionGetMember());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetProperty;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GetPropertyActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem target;
|
||||
public int propertyIndex;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(target);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public GetPropertyActionItem(GraphSourceItem instruction, GraphTargetItem target, int propertyIndex) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.target = target;
|
||||
this.propertyIndex = propertyIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
if (isEmptyString(target)) {
|
||||
return writer.append(Action.propertyNames[propertyIndex]);
|
||||
}
|
||||
target.toString(writer, localData);
|
||||
return writer.append("." + Action.propertyNames[propertyIndex]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(target.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, target, new ActionPush((Long) (long) propertyIndex), new ActionGetProperty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetTime;
|
||||
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.model.LocalData;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class GetTimeActionItem extends ActionItem {
|
||||
|
||||
public GetTimeActionItem(GraphSourceItem instruction) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append("getTimer");
|
||||
writer.spaceBeforeCallParenthesies(0);
|
||||
return writer.append("()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
return (Double) (double) new Random().nextInt(10000) + 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, new ActionGetTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GetURL2ActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem urlString;
|
||||
public GraphTargetItem targetString;
|
||||
public int sendVarsMethod;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(urlString);
|
||||
ret.add(targetString);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
String methodStr = "";
|
||||
if (sendVarsMethod == 1) {
|
||||
methodStr = ",\"GET\"";
|
||||
}
|
||||
if (sendVarsMethod == 2) {
|
||||
methodStr = ",\"POST\"";
|
||||
}
|
||||
|
||||
writer.append("getURL");
|
||||
writer.spaceBeforeCallParenthesies(2);
|
||||
writer.append("(");
|
||||
urlString.toString(writer, localData);
|
||||
writer.append(",");
|
||||
targetString.toString(writer, localData);
|
||||
return writer.append(methodStr + ")");
|
||||
}
|
||||
|
||||
public GetURL2ActionItem(GraphSourceItem instruction, GraphTargetItem urlString, GraphTargetItem targetString, int method) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.urlString = urlString;
|
||||
this.targetString = targetString;
|
||||
this.sendVarsMethod = method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(urlString.getNeededSources());
|
||||
ret.addAll(targetString.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, urlString, targetString, new ActionGetURL2(sendVarsMethod, false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf3.ActionGetURL;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.util.List;
|
||||
|
||||
public class GetURLActionItem extends ActionItem {
|
||||
|
||||
public String urlString;
|
||||
public String targetString;
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append("getUrl");
|
||||
writer.spaceBeforeCallParenthesies(2);
|
||||
writer.append("(\"");
|
||||
writer.append(Helper.escapeString(urlString) + "\", \"" + Helper.escapeString(targetString));
|
||||
return writer.append("\")");
|
||||
}
|
||||
|
||||
public GetURLActionItem(GraphSourceItem instruction, String urlString, String targetString) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.urlString = urlString;
|
||||
this.targetString = targetString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, new ActionGetURL(urlString, targetString));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Deobfuscation;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class GetVariableActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem name;
|
||||
private GraphTargetItem computedValue;
|
||||
private Object computedResult;
|
||||
private boolean computedCompiletime = false;
|
||||
private boolean computedVariableComputed = false;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public GetVariableActionItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
|
||||
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!Deobfuscation.isValidName(((DirectValueActionItem) name).toStringNoQuotes(localData),"this","super"))){
|
||||
return writer.append(Deobfuscation.makeObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData)));
|
||||
}else if ((!(name instanceof DirectValueActionItem)) || (!((DirectValueActionItem) name).isString())) {
|
||||
writer.append("eval(");
|
||||
name.appendTo(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
return stripQuotes(name, localData, writer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(name.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVariableComputed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
|
||||
if (computedValue == null) {
|
||||
return false;
|
||||
}
|
||||
return computedCompiletime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
if (computedValue == null) {
|
||||
return new Undefined();
|
||||
}
|
||||
return computedResult;
|
||||
}
|
||||
|
||||
public void setComputedValue(GraphTargetItem computedValue) {
|
||||
this.computedValue = computedValue;
|
||||
if (computedValue != null) {
|
||||
computedCompiletime = computedValue.isCompileTime();
|
||||
if (computedCompiletime) {
|
||||
computedResult = computedValue.getResult();
|
||||
}
|
||||
computedVariableComputed = computedValue.isVariableComputed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 13 * hash + (this.name != null ? this.name.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final GetVariableActionItem other = (GetVariableActionItem) obj;
|
||||
if (this.name != other.name && (this.name == null || !this.name.equals(other.name))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valueEquals(GraphTargetItem obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final GetVariableActionItem other = (GetVariableActionItem) obj;
|
||||
if (this.name != other.name && (this.name == null || !this.name.valueEquals(other.name))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, name, new ActionGetVariable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class GetVersionActionItem extends ActionItem {
|
||||
|
||||
public GetVersionActionItem(GraphSourceItem instruction) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append("getVersion");
|
||||
writer.spaceBeforeCallParenthesies(0);
|
||||
return writer.append("()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, new ActionPush("/:$version"), new ActionGetVariable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf3.ActionGotoFrame;
|
||||
import com.jpexs.decompiler.flash.action.swf3.ActionPlay;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGotoFrame2;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GotoFrame2ActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem frame;
|
||||
public boolean sceneBiasFlag;
|
||||
public boolean playFlag;
|
||||
public int sceneBias;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(frame);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public GotoFrame2ActionItem(GraphSourceItem instruction, GraphTargetItem frame, boolean sceneBiasFlag, boolean playFlag, int sceneBias) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.frame = frame;
|
||||
this.sceneBiasFlag = sceneBiasFlag;
|
||||
this.playFlag = playFlag;
|
||||
this.sceneBias = sceneBias;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
String prefix = "gotoAndStop";
|
||||
if (playFlag) {
|
||||
prefix = "gotoAndPlay";
|
||||
}
|
||||
writer.append(prefix);
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
frame.toString(writer, localData);
|
||||
writer.append((sceneBiasFlag ? "," + sceneBias : ""));
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(frame.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
if (!sceneBiasFlag && (frame instanceof DirectValueActionItem) && (((DirectValueActionItem) frame).value instanceof Long)) {
|
||||
return toSourceMerge(localData, generator, new ActionGotoFrame((int) ((long) (Long) ((DirectValueActionItem) frame).value) - 1), playFlag ? new ActionPlay() : null);
|
||||
} else {
|
||||
return toSourceMerge(localData, generator, frame, new ActionGotoFrame2(playFlag, sceneBiasFlag, sceneBias));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf3.ActionGotoFrame;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class GotoFrameActionItem extends ActionItem {
|
||||
|
||||
public int frame;
|
||||
|
||||
public GotoFrameActionItem(GraphSourceItem instruction, int frame) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.frame = frame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append("gotoAndStop");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
writer.append("" + (frame + 1));
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, new ActionGotoFrame(frame));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf3.ActionGoToLabel;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.util.List;
|
||||
|
||||
public class GotoLabelActionItem extends ActionItem {
|
||||
|
||||
public String label;
|
||||
|
||||
public GotoLabelActionItem(GraphSourceItem instruction, String label) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append("gotoAndStop");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(\"");
|
||||
writer.append(Helper.escapeString(label));
|
||||
return writer.append("\")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, new ActionGoToLabel(label));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class ImplementsOpActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem subclass;
|
||||
public List<GraphTargetItem> superclasses;
|
||||
|
||||
public ImplementsOpActionItem(GraphSourceItem instruction, GraphTargetItem subclass, List<GraphTargetItem> superclasses) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.subclass = subclass;
|
||||
this.superclasses = superclasses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
subclass.toString(writer, localData);
|
||||
writer.append(" implements ");
|
||||
for (int i = 0; i < superclasses.size(); i++) {
|
||||
if (i > 0) {
|
||||
writer.append(",");
|
||||
}
|
||||
superclasses.get(i).toString(writer, localData);
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(subclass.getNeededSources());
|
||||
for (GraphTargetItem ti : superclasses) {
|
||||
ret.addAll(ti.getNeededSources());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionIncrement;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class IncrementActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem object;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(object);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public IncrementActionItem(GraphSourceItem instruction, GraphTargetItem object) {
|
||||
super(instruction, PRECEDENCE_ADDITIVE);
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
object.toString(writer, localData);
|
||||
return writer.append(" + 1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
|
||||
if (dependencies.contains(object)) {
|
||||
return false;
|
||||
}
|
||||
dependencies.add(object);
|
||||
return object.isCompileTime(dependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
return EcmaScript.toNumber(object.getResult()) + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(object.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, object, new ActionIncrement());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionInitArray;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InitArrayActionItem extends ActionItem {
|
||||
|
||||
public List<GraphTargetItem> values;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.addAll(values);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public InitArrayActionItem(GraphSourceItem instruction, List<GraphTargetItem> values) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("[");
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
if (i > 0) {
|
||||
writer.append(",");
|
||||
}
|
||||
values.get(i).toString(writer, localData);
|
||||
}
|
||||
return writer.append("]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
for (GraphTargetItem value : values) {
|
||||
ret.addAll(value.getNeededSources());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, toSourceCall(localData, generator, values), new ActionInitArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionInitObject;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.decompiler.graph.model.TernarOpItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InitObjectActionItem extends ActionItem {
|
||||
|
||||
public List<GraphTargetItem> names;
|
||||
public List<GraphTargetItem> values;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.addAll(names);
|
||||
ret.addAll(values);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public InitObjectActionItem(GraphSourceItem instruction, List<GraphTargetItem> names, List<GraphTargetItem> values) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.values = values;
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("{");
|
||||
for (int i = values.size() - 1; i >= 0; i--) {
|
||||
if (i < values.size() - 1) {
|
||||
writer.append(",");
|
||||
}
|
||||
names.get(i).toStringNoQuotes(writer, localData); //AS1/2 do not allow quotes in name here
|
||||
writer.append(":");
|
||||
if (values.get(i) instanceof TernarOpItem) { //Ternar operator contains ":"
|
||||
writer.append("(");
|
||||
values.get(i).toString(writer, localData);
|
||||
writer.append(")");
|
||||
} else {
|
||||
values.get(i).toString(writer, localData);
|
||||
}
|
||||
}
|
||||
return writer.append("}");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
for (GraphTargetItem name : names) {
|
||||
ret.addAll(name.getNeededSources());
|
||||
}
|
||||
for (GraphTargetItem value : values) {
|
||||
ret.addAll(value.getNeededSources());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
for (int i = values.size() - 1; i >= 0; i--) {
|
||||
ret.addAll(names.get(i).toSource(localData, generator));
|
||||
ret.addAll(values.get(i).toSource(localData, generator));
|
||||
}
|
||||
ret.add(new ActionPush((Long) (long) values.size()));
|
||||
ret.add(new ActionInitObject());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
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.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class LoadMovieActionItem extends ActionItem {
|
||||
|
||||
private final GraphTargetItem urlString;
|
||||
private final GraphTargetItem targetString;
|
||||
private final int method;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(urlString);
|
||||
ret.add(targetString);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public LoadMovieActionItem(GraphSourceItem instruction, GraphTargetItem urlString, GraphTargetItem targetString, int method) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.urlString = urlString;
|
||||
this.targetString = targetString;
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
String methodStr = "";
|
||||
if (method == 1) {
|
||||
methodStr = ",\"GET\"";
|
||||
}
|
||||
if (method == 2) {
|
||||
methodStr = ",\"POST\"";
|
||||
}
|
||||
writer.append("loadMovie");
|
||||
writer.spaceBeforeCallParenthesies(2);
|
||||
writer.append("(");
|
||||
urlString.toString(writer, localData);
|
||||
writer.append(",");
|
||||
targetString.toString(writer, localData);
|
||||
return writer.append(methodStr + ")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, urlString, targetString, new ActionGetURL2(method, false, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
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.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class LoadMovieNumActionItem extends ActionItem {
|
||||
|
||||
private final GraphTargetItem urlString;
|
||||
private final GraphTargetItem num;
|
||||
private final int method;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(urlString);
|
||||
ret.add(num);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public LoadMovieNumActionItem(GraphSourceItem instruction, GraphTargetItem urlString, GraphTargetItem num, int method) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.urlString = urlString;
|
||||
this.num = num;
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
String methodStr = "";
|
||||
if (method == 1) {
|
||||
methodStr = ",\"GET\"";
|
||||
}
|
||||
if (method == 2) {
|
||||
methodStr = ",\"POST\"";
|
||||
}
|
||||
writer.append("loadMovieNum");
|
||||
writer.spaceBeforeCallParenthesies(2);
|
||||
writer.append("(");
|
||||
urlString.toString(writer, localData);
|
||||
writer.append(",");
|
||||
num.toString(writer, localData);
|
||||
return writer.append(methodStr + ")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
Object lev = null;
|
||||
if ((num instanceof DirectValueActionItem) && (((DirectValueActionItem) num).value instanceof Long)) {
|
||||
lev = asGenerator.pushConstTargetItem("_level" + ((DirectValueActionItem) num).value);
|
||||
} else {
|
||||
lev = new AddActionItem(src, asGenerator.pushConstTargetItem("_level"), num, true);
|
||||
}
|
||||
return toSourceMerge(localData, generator, urlString, lev, new ActionGetURL2(method, false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
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.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class LoadVariablesActionItem extends ActionItem {
|
||||
|
||||
private final GraphTargetItem urlString;
|
||||
private final GraphTargetItem targetString;
|
||||
private final int method;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(urlString);
|
||||
ret.add(targetString);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public LoadVariablesActionItem(GraphSourceItem instruction, GraphTargetItem urlString, GraphTargetItem targetString, int method) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.urlString = urlString;
|
||||
this.targetString = targetString;
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
String methodStr = "";
|
||||
if (method == 1) {
|
||||
methodStr = ",\"GET\"";
|
||||
}
|
||||
if (method == 2) {
|
||||
methodStr = ",\"POST\"";
|
||||
}
|
||||
writer.append("loadVariables");
|
||||
writer.spaceBeforeCallParenthesies(2);
|
||||
writer.append("(");
|
||||
urlString.toString(writer, localData);
|
||||
writer.append(",");
|
||||
targetString.toString(writer, localData);
|
||||
return writer.append(methodStr + ")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, urlString, targetString, new ActionGetURL2(method, true, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
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.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class LoadVariablesNumActionItem extends ActionItem {
|
||||
|
||||
private final GraphTargetItem urlString;
|
||||
private final GraphTargetItem num;
|
||||
private final int method;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(urlString);
|
||||
ret.add(num);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public LoadVariablesNumActionItem(GraphSourceItem instruction, GraphTargetItem urlString, GraphTargetItem num, int method) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.urlString = urlString;
|
||||
this.num = num;
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
String methodStr = "";
|
||||
if (method == 1) {
|
||||
methodStr = ",\"GET\"";
|
||||
}
|
||||
if (method == 2) {
|
||||
methodStr = ",\"POST\"";
|
||||
}
|
||||
writer.append("loadVariablesNum");
|
||||
writer.spaceBeforeCallParenthesies(2);
|
||||
writer.append("(");
|
||||
urlString.toString(writer, localData);
|
||||
writer.append(",");
|
||||
num.toString(writer, localData);
|
||||
return writer.append(methodStr + ")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
Object lev = null;
|
||||
if ((num instanceof DirectValueActionItem) && (((DirectValueActionItem) num).value instanceof Long)) {
|
||||
lev = asGenerator.pushConstTargetItem("_level" + ((DirectValueActionItem) num).value);
|
||||
} else {
|
||||
lev = new AddActionItem(src, asGenerator.pushConstTargetItem("_level"), num, true);
|
||||
}
|
||||
return toSourceMerge(localData, generator, urlString, lev, new ActionGetURL2(method, true, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionMBAsciiToChar;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class MBAsciiToCharActionItem extends ActionItem {
|
||||
|
||||
public MBAsciiToCharActionItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("mbchr");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionMBAsciiToChar());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionMBCharToAscii;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class MBCharToAsciiActionItem extends ActionItem {
|
||||
|
||||
public MBCharToAsciiActionItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("mbord");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionMBCharToAscii());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionMBStringExtract;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MBStringExtractActionItem extends ActionItem {
|
||||
|
||||
//public GraphTargetItem value;
|
||||
public GraphTargetItem index;
|
||||
public GraphTargetItem count;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(value);
|
||||
ret.add(index);
|
||||
ret.add(count);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public MBStringExtractActionItem(GraphSourceItem instruction, GraphTargetItem value, GraphTargetItem index, GraphTargetItem count) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
this.index = index;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("mbsubstring");
|
||||
writer.spaceBeforeCallParenthesies(3);
|
||||
writer.append("(");
|
||||
value.toString(writer, localData);
|
||||
writer.append(",");
|
||||
index.toString(writer, localData);
|
||||
writer.append(",");
|
||||
count.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
ret.addAll(index.getNeededSources());
|
||||
ret.addAll(count.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, index, count, new ActionMBStringExtract());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionMBStringLength;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class MBStringLengthActionItem extends ActionItem {
|
||||
|
||||
//public GraphTargetItem value;
|
||||
public MBStringLengthActionItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("mblength");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
if (value.getPrecedence() > precedence) {
|
||||
writer.append("(");
|
||||
value.toString(writer, localData);
|
||||
writer.append(")");
|
||||
} else {
|
||||
value.toString(writer, localData);
|
||||
}
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionMBStringLength());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionNewMethod;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NewMethodActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem methodName;
|
||||
public GraphTargetItem scriptObject;
|
||||
public List<GraphTargetItem> arguments;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(scriptObject);
|
||||
ret.addAll(arguments);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public NewMethodActionItem(GraphSourceItem instruction, GraphTargetItem scriptObject, GraphTargetItem methodName, List<GraphTargetItem> arguments) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.methodName = methodName;
|
||||
this.arguments = arguments;
|
||||
this.scriptObject = scriptObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
boolean blankMethod = false;
|
||||
if (methodName instanceof DirectValueActionItem) {
|
||||
if (((DirectValueActionItem) methodName).value instanceof Undefined) {
|
||||
blankMethod = true;
|
||||
} else if (((DirectValueActionItem) methodName).value instanceof String) {
|
||||
if (((DirectValueActionItem) methodName).value.equals("")) {
|
||||
blankMethod = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!blankMethod) {
|
||||
writer.append("new ");
|
||||
}
|
||||
scriptObject.toString(writer, localData);
|
||||
if (!blankMethod) {
|
||||
writer.append(".");
|
||||
if (methodName instanceof DirectValueActionItem) {
|
||||
if (((DirectValueActionItem) methodName).value instanceof Undefined) {
|
||||
} else if (((DirectValueActionItem) methodName).value instanceof String) {
|
||||
((DirectValueActionItem) methodName).toStringNoQuotes(writer, localData);
|
||||
} else {
|
||||
methodName.toString(writer, localData);
|
||||
}
|
||||
} else {
|
||||
methodName.toString(writer, localData);
|
||||
}
|
||||
}
|
||||
writer.spaceBeforeCallParenthesies(arguments.size());
|
||||
writer.append("(");
|
||||
for (int t = 0; t < arguments.size(); t++) {
|
||||
if (t > 0) {
|
||||
writer.append(",");
|
||||
}
|
||||
arguments.get(t).toString(writer, localData);
|
||||
}
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(methodName.getNeededSources());
|
||||
ret.addAll(scriptObject.getNeededSources());
|
||||
for (GraphTargetItem ti : arguments) {
|
||||
ret.addAll(ti.getNeededSources());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, toSourceCall(localData, generator, arguments), scriptObject, methodName, new ActionNewMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionNewObject;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NewObjectActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem objectName;
|
||||
public List<GraphTargetItem> arguments;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(objectName);
|
||||
ret.addAll(arguments);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public NewObjectActionItem(GraphSourceItem instruction, GraphTargetItem objectName, List<GraphTargetItem> arguments) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.objectName = objectName;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("new ");
|
||||
stripQuotes(objectName, localData, writer);
|
||||
writer.spaceBeforeCallParenthesies(arguments.size());
|
||||
writer.append("(");
|
||||
for (int t = 0; t < arguments.size(); t++) {
|
||||
if (t > 0) {
|
||||
writer.append(",");
|
||||
}
|
||||
arguments.get(t).toString(writer, localData);
|
||||
}
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(objectName.getNeededSources());
|
||||
for (GraphTargetItem ti : arguments) {
|
||||
ret.addAll(ti.getNeededSources());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, toSourceCall(localData, generator, arguments), objectName, new ActionNewObject());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf3.ActionNextFrame;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class NextFrameActionItem extends ActionItem {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append("nextFrame");
|
||||
writer.spaceBeforeCallParenthesies(0);
|
||||
return writer.append("()");
|
||||
}
|
||||
|
||||
public NextFrameActionItem(GraphSourceItem instruction) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, new ActionNextFrame());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf3.ActionPlay;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayActionItem extends ActionItem {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append("play");
|
||||
writer.spaceBeforeCallParenthesies(0);
|
||||
return writer.append("()");
|
||||
}
|
||||
|
||||
public PlayActionItem(GraphSourceItem instruction) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, new ActionPlay());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPop;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class PopActionItem extends ActionItem {
|
||||
|
||||
public PopActionItem(GraphSourceItem instruction) {
|
||||
super(instruction, NOPRECEDENCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsSemicolon() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, new ActionPop());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.SubtractActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPop;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionSetProperty;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionSetVariable;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDecrement;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionSetMember;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
|
||||
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.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PostDecrementActionItem extends ActionItem implements SetTypeActionItem {
|
||||
|
||||
public GraphTargetItem object;
|
||||
private int tempRegister = -1;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(object);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public PostDecrementActionItem(GraphSourceItem instruction, GraphTargetItem object) {
|
||||
super(instruction, PRECEDENCE_POSTFIX);
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
object.toString(writer, localData);
|
||||
return writer.append("--");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSideEffect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getValue() {
|
||||
return new SubtractActionItem(null, object, new DirectValueActionItem(null, 0, new Long(1), null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTempRegister(int regIndex) {
|
||||
tempRegister = regIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTempRegister() {
|
||||
return tempRegister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(GraphTargetItem value) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
|
||||
GraphTargetItem val = object;
|
||||
if (val instanceof VariableActionItem) {
|
||||
val = ((VariableActionItem) val).getBoxedValue();
|
||||
}
|
||||
|
||||
if (val instanceof GetVariableActionItem) {
|
||||
GetVariableActionItem gv = (GetVariableActionItem) val;
|
||||
ret.addAll(gv.toSource(localData, generator));
|
||||
ret.remove(ret.size() - 1); //ActionGetVariable
|
||||
ret.addAll(gv.toSource(localData, generator));
|
||||
ret.add(new ActionDecrement());
|
||||
ret.add(new ActionSetVariable());
|
||||
} else if (val instanceof GetMemberActionItem) {
|
||||
GetMemberActionItem mem = (GetMemberActionItem) val;
|
||||
ret.addAll(mem.toSource(localData, generator));
|
||||
ret.remove(ret.size() - 1); //ActionGetMember
|
||||
ret.addAll(mem.toSource(localData, generator));
|
||||
ret.add(new ActionDecrement());
|
||||
ret.add(new ActionSetMember());
|
||||
} else if ((val instanceof DirectValueActionItem) && ((DirectValueActionItem) val).value instanceof RegisterNumber) {
|
||||
RegisterNumber rn = (RegisterNumber) ((DirectValueActionItem) val).value;
|
||||
ret.add(new ActionPush(new RegisterNumber(rn.number)));
|
||||
ret.add(new ActionDecrement());
|
||||
ret.add(new ActionStoreRegister(rn.number));
|
||||
ret.add(new ActionPop());
|
||||
} else if (val instanceof GetPropertyActionItem) {
|
||||
GetPropertyActionItem gp = (GetPropertyActionItem) val;
|
||||
ret.addAll(gp.toSource(localData, generator));
|
||||
ret.remove(ret.size() - 1);
|
||||
ret.addAll(gp.toSource(localData, generator));
|
||||
ret.add(new ActionDecrement());
|
||||
ret.add(new ActionSetProperty());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, object.toSource(localData, generator), toSourceIgnoreReturnValue(localData, generator));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPop;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionSetProperty;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionSetVariable;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionIncrement;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionSetMember;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
|
||||
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.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PostIncrementActionItem extends ActionItem implements SetTypeActionItem {
|
||||
|
||||
public GraphTargetItem object;
|
||||
private int tempRegister = -1;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(object);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public PostIncrementActionItem(GraphSourceItem instruction, GraphTargetItem object) {
|
||||
super(instruction, PRECEDENCE_POSTFIX);
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
object.toString(writer, localData);
|
||||
return writer.append("++");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSideEffect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getValue() {
|
||||
return new AddActionItem(null, object, new DirectValueActionItem(null, 0, new Long(1), null), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTempRegister(int regIndex) {
|
||||
tempRegister = regIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTempRegister() {
|
||||
return tempRegister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(GraphTargetItem value) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
|
||||
GraphTargetItem val = object;
|
||||
if (val instanceof VariableActionItem) {
|
||||
val = ((VariableActionItem) val).getBoxedValue();
|
||||
}
|
||||
|
||||
if (val instanceof GetVariableActionItem) {
|
||||
GetVariableActionItem gv = (GetVariableActionItem) val;
|
||||
ret.addAll(gv.toSource(localData, generator));
|
||||
ret.remove(ret.size() - 1); //ActionGetVariable
|
||||
ret.addAll(gv.toSource(localData, generator));
|
||||
ret.add(new ActionIncrement());
|
||||
ret.add(new ActionSetVariable());
|
||||
} else if (val instanceof GetMemberActionItem) {
|
||||
GetMemberActionItem mem = (GetMemberActionItem) val;
|
||||
ret.addAll(mem.toSource(localData, generator));
|
||||
ret.remove(ret.size() - 1); //ActionGetMember
|
||||
ret.addAll(mem.toSource(localData, generator));
|
||||
ret.add(new ActionIncrement());
|
||||
ret.add(new ActionSetMember());
|
||||
} else if ((val instanceof DirectValueActionItem) && ((DirectValueActionItem) val).value instanceof RegisterNumber) {
|
||||
RegisterNumber rn = (RegisterNumber) ((DirectValueActionItem) val).value;
|
||||
ret.add(new ActionPush(new RegisterNumber(rn.number)));
|
||||
ret.add(new ActionIncrement());
|
||||
ret.add(new ActionStoreRegister(rn.number));
|
||||
ret.add(new ActionPop());
|
||||
} else if (val instanceof GetPropertyActionItem) {
|
||||
GetPropertyActionItem gp = (GetPropertyActionItem) val;
|
||||
ret.addAll(gp.toSource(localData, generator));
|
||||
ret.remove(ret.size() - 1);
|
||||
ret.addAll(gp.toSource(localData, generator));
|
||||
ret.add(new ActionIncrement());
|
||||
ret.add(new ActionSetProperty());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, object.toSource(localData, generator), toSourceIgnoreReturnValue(localData, generator));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf3.ActionPrevFrame;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class PrevFrameActionItem extends ActionItem {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append("prevFrame");
|
||||
writer.spaceBeforeCallParenthesies(0);
|
||||
return writer.append("()");
|
||||
}
|
||||
|
||||
public PrevFrameActionItem(GraphSourceItem instruction) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, new ActionPrevFrame());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
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.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class PrintActionItem extends ActionItem {
|
||||
|
||||
private final GraphTargetItem target;
|
||||
private final GraphTargetItem boundingBox;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(target);
|
||||
ret.add(boundingBox);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public PrintActionItem(GraphSourceItem instruction, GraphTargetItem target, GraphTargetItem boundingBox) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.target = target;
|
||||
this.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("print");
|
||||
writer.spaceBeforeCallParenthesies(2);
|
||||
writer.append("(");
|
||||
target.toString(writer, localData);
|
||||
writer.append(",");
|
||||
boundingBox.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
return toSourceMerge(localData, generator, new AddActionItem(src, asGenerator.pushConstTargetItem("print:#"), boundingBox, true), target, new ActionGetURL2(0, false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
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.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class PrintAsBitmapActionItem extends ActionItem {
|
||||
|
||||
private final GraphTargetItem target;
|
||||
private final GraphTargetItem boundingBox;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(target);
|
||||
ret.add(boundingBox);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public PrintAsBitmapActionItem(GraphSourceItem instruction, GraphTargetItem target, GraphTargetItem boundingBox) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.target = target;
|
||||
this.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("printAsBitmap");
|
||||
writer.spaceBeforeCallParenthesies(2);
|
||||
writer.append("(");
|
||||
target.toString(writer, localData);
|
||||
writer.append(",");
|
||||
boundingBox.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
return toSourceMerge(localData, generator, new AddActionItem(src, asGenerator.pushConstTargetItem("printasbitmap:#"), boundingBox, true), target, new ActionGetURL2(0, false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
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.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class PrintAsBitmapNumActionItem extends ActionItem {
|
||||
|
||||
private final GraphTargetItem num;
|
||||
private final GraphTargetItem boundingBox;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(num);
|
||||
ret.add(boundingBox);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public PrintAsBitmapNumActionItem(GraphSourceItem instruction, GraphTargetItem num, GraphTargetItem boundingBox) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.num = num;
|
||||
this.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("printAsBitmapNum");
|
||||
writer.spaceBeforeCallParenthesies(2);
|
||||
writer.append("(");
|
||||
num.toString(writer, localData);
|
||||
writer.append(",");
|
||||
boundingBox.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
Object lev = null;
|
||||
if ((num instanceof DirectValueActionItem) && (((DirectValueActionItem) num).value instanceof Long)) {
|
||||
lev = asGenerator.pushConstTargetItem("_level" + ((DirectValueActionItem) num).value);
|
||||
} else {
|
||||
lev = new AddActionItem(src, asGenerator.pushConstTargetItem("_level"), num, true);
|
||||
}
|
||||
return toSourceMerge(localData, generator, new AddActionItem(src, asGenerator.pushConstTargetItem("printasbitmap:#"), boundingBox, true), lev, new ActionGetURL2(0, false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
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.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class PrintNumActionItem extends ActionItem {
|
||||
|
||||
private final GraphTargetItem num;
|
||||
private final GraphTargetItem boundingBox;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(num);
|
||||
ret.add(boundingBox);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public PrintNumActionItem(GraphSourceItem instruction, GraphTargetItem num, GraphTargetItem boundingBox) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.num = num;
|
||||
this.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("printNum");
|
||||
writer.spaceBeforeCallParenthesies(2);
|
||||
writer.append("(");
|
||||
num.toString(writer, localData);
|
||||
writer.append(",");
|
||||
boundingBox.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
Object lev = null;
|
||||
if ((num instanceof DirectValueActionItem) && (((DirectValueActionItem) num).value instanceof Long)) {
|
||||
lev = asGenerator.pushConstTargetItem("_level" + ((DirectValueActionItem) num).value);
|
||||
} else {
|
||||
lev = new AddActionItem(src, asGenerator.pushConstTargetItem("_level"), num, true);
|
||||
}
|
||||
return toSourceMerge(localData, generator, new AddActionItem(src, asGenerator.pushConstTargetItem("print:#"), boundingBox, true), lev, new ActionGetURL2(0, false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionRandomNumber;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class RandomNumberActionItem extends ActionItem {
|
||||
|
||||
public RandomNumberActionItem(GraphSourceItem instruction, GraphTargetItem maximum) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = maximum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("random");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionRandomNumber());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionRemoveSprite;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class RemoveSpriteActionItem extends ActionItem {
|
||||
|
||||
public RemoveSpriteActionItem(GraphSourceItem instruction, GraphTargetItem target) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("removeMovieClip");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionRemoveSprite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
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.swf5.ActionEquals2;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionReturn;
|
||||
import com.jpexs.decompiler.flash.ecma.Null;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.ExitItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ReturnActionItem extends ActionItem implements ExitItem {
|
||||
|
||||
//public GraphTargetItem value;
|
||||
public ReturnActionItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("return ");
|
||||
return value.toString(writer, localData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
int forinlevel = asGenerator.getForInLevel(localData);
|
||||
for (int i = 0; i < forinlevel; i++) { //Must POP all remaining values from enumerations (for..in)
|
||||
List<Action> forinret = new ArrayList<>();
|
||||
forinret.add(new ActionPush(new Null()));
|
||||
forinret.add(new ActionEquals2());
|
||||
forinret.add(new ActionNot());
|
||||
ActionIf aforinif = new ActionIf(0);
|
||||
forinret.add(aforinif);
|
||||
aforinif.setJumpOffset(-Action.actionsToBytes(forinret, false, SWF.DEFAULT_VERSION).length);
|
||||
ret.addAll(forinret);
|
||||
}
|
||||
if (value == null) {
|
||||
ret.add(new ActionPush(new Undefined()));
|
||||
} else {
|
||||
ret.addAll(value.toSource(localData, generator));
|
||||
}
|
||||
ret.add(new ActionReturn());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Deobfuscation;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionSetMember;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphPart;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SetMemberActionItem extends ActionItem implements SetTypeActionItem {
|
||||
|
||||
public GraphTargetItem object;
|
||||
public GraphTargetItem objectName;
|
||||
//public GraphTargetItem value;
|
||||
private int tempRegister = -1;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(object);
|
||||
ret.add(value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphPart getFirstPart() {
|
||||
return value.getFirstPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(GraphTargetItem value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTempRegister() {
|
||||
return tempRegister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTempRegister(int tempRegister) {
|
||||
this.tempRegister = tempRegister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public SetMemberActionItem(GraphSourceItem instruction, GraphTargetItem object, GraphTargetItem objectName, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_ASSIGMENT);
|
||||
this.object = object;
|
||||
this.objectName = objectName;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
object.toString(writer, localData);
|
||||
|
||||
if ((!(objectName instanceof DirectValueActionItem)) || (!((DirectValueActionItem) objectName).isString()) || (!Deobfuscation.isValidName(((DirectValueActionItem) objectName).toStringNoQuotes(localData)))) {
|
||||
writer.append("[");
|
||||
objectName.toString(writer, localData);
|
||||
writer.append("]");
|
||||
} else {
|
||||
writer.append(".");
|
||||
stripQuotes(objectName, localData, writer);
|
||||
}
|
||||
writer.append(" = ");
|
||||
return value.toString(writer, localData);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getObject() {
|
||||
return new GetMemberActionItem(src, object, objectName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(object.getNeededSources());
|
||||
ret.addAll(objectName.getNeededSources());
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSideEffect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
int tmpReg = asGenerator.getTempRegister(localData);
|
||||
return toSourceMerge(localData, generator, object, objectName, value, new ActionStoreRegister(tmpReg), new ActionSetMember(), new ActionPush(new RegisterNumber(tmpReg)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, object, objectName, value, new ActionSetMember());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionSetProperty;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphPart;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class SetPropertyActionItem extends ActionItem implements SetTypeActionItem {
|
||||
|
||||
public GraphTargetItem target;
|
||||
public int propertyIndex;
|
||||
//public GraphTargetItem value;
|
||||
|
||||
@Override
|
||||
public GraphPart getFirstPart() {
|
||||
return value.getFirstPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(GraphTargetItem value) {
|
||||
this.value = value;
|
||||
}
|
||||
private int tempRegister = -1;
|
||||
|
||||
@Override
|
||||
public int getTempRegister() {
|
||||
return tempRegister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTempRegister(int tempRegister) {
|
||||
this.tempRegister = tempRegister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public SetPropertyActionItem(GraphSourceItem instruction, GraphTargetItem target, int propertyIndex, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_ASSIGMENT);
|
||||
this.target = target;
|
||||
this.propertyIndex = propertyIndex;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
if (isEmptyString(target)) {
|
||||
writer.append(Action.propertyNames[propertyIndex] + " = ");
|
||||
return value.toString(writer, localData);
|
||||
}
|
||||
target.toString(writer, localData);
|
||||
writer.append("." + Action.propertyNames[propertyIndex] + " = ");
|
||||
return value.toString(writer, localData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getObject() {
|
||||
return new GetPropertyActionItem(src, target, propertyIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(target.getNeededSources());
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSideEffect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
int tmpReg = asGenerator.getTempRegister(localData);
|
||||
return toSourceMerge(localData, generator, target, new ActionPush((Long) (long) propertyIndex), value, new ActionStoreRegister(tmpReg), new ActionSetProperty(), new ActionPush(new RegisterNumber(tmpReg)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, target, new ActionPush((Long) (long) propertyIndex), value, new ActionSetProperty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class SetTarget2ActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem target;
|
||||
|
||||
public SetTarget2ActionItem(GraphSourceItem instruction, GraphTargetItem target) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("tellTarget");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
target.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(target.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.util.List;
|
||||
|
||||
public class SetTargetActionItem extends ActionItem {
|
||||
|
||||
public String target;
|
||||
|
||||
public SetTargetActionItem(GraphSourceItem instruction, String target) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append("tellTarget(\"");
|
||||
writer.append(Helper.escapeString(target));
|
||||
return writer.append("\")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface SetTypeActionItem {
|
||||
|
||||
public GraphTargetItem getObject();
|
||||
|
||||
public GraphTargetItem getValue();
|
||||
|
||||
public void setTempRegister(int regIndex);
|
||||
|
||||
public int getTempRegister();
|
||||
|
||||
public void setValue(GraphTargetItem value);
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Deobfuscation;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionSetVariable;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphPart;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class SetVariableActionItem extends ActionItem implements SetTypeActionItem {
|
||||
|
||||
public GraphTargetItem name;
|
||||
//public GraphTargetItem value;
|
||||
private int tempRegister = -1;
|
||||
|
||||
@Override
|
||||
public GraphPart getFirstPart() {
|
||||
return value.getFirstPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(GraphTargetItem value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTempRegister() {
|
||||
return tempRegister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTempRegister(int tempRegister) {
|
||||
this.tempRegister = tempRegister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public SetVariableActionItem(GraphSourceItem instruction, GraphTargetItem name, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_ASSIGMENT);
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
if (((name instanceof DirectValueActionItem)) && (((DirectValueActionItem) name).isString()) && (!Deobfuscation.isValidName(((DirectValueActionItem) name).toStringNoQuotes(localData),"this","super"))){
|
||||
writer.append(Deobfuscation.makeObfuscatedIdentifier(((DirectValueActionItem) name).toStringNoQuotes(localData)));
|
||||
writer.append(" = ");
|
||||
return value.toString(writer, localData);
|
||||
}else if ((!(name instanceof DirectValueActionItem)) || (!((DirectValueActionItem) name).isString())) {
|
||||
writer.append("set");
|
||||
writer.spaceBeforeCallParenthesies(2);
|
||||
writer.append("(");
|
||||
name.toString(writer, localData);
|
||||
writer.append(",");
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
stripQuotes(name, localData, writer);
|
||||
writer.append(" = ");
|
||||
return value.toString(writer, localData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getObject() {
|
||||
return new GetVariableActionItem(src, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(name.getNeededSources());
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
|
||||
if (dependencies.contains(value)) {
|
||||
return false;
|
||||
}
|
||||
dependencies.add(value);
|
||||
return value.isCompileTime(dependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSideEffect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
int tmpReg = asGenerator.getTempRegister(localData);
|
||||
return toSourceMerge(localData, generator, name, value, new ActionStoreRegister(tmpReg), new ActionSetVariable(), new ActionPush(new RegisterNumber(tmpReg)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, name, value, new ActionSetVariable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionStartDrag;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class StartDragActionItem extends ActionItem {
|
||||
|
||||
public GraphTargetItem target;
|
||||
public GraphTargetItem lockCenter;
|
||||
public GraphTargetItem constrain;
|
||||
public GraphTargetItem y2;
|
||||
public GraphTargetItem x2;
|
||||
public GraphTargetItem y1;
|
||||
public GraphTargetItem x1;
|
||||
|
||||
public StartDragActionItem(GraphSourceItem instruction, GraphTargetItem target, GraphTargetItem lockCenter, GraphTargetItem constrain, GraphTargetItem x1, GraphTargetItem y1, GraphTargetItem x2, GraphTargetItem y2) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.target = target;
|
||||
this.lockCenter = lockCenter;
|
||||
this.constrain = constrain;
|
||||
this.y2 = y2;
|
||||
this.x2 = x2;
|
||||
this.y1 = y1;
|
||||
this.x1 = x1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
boolean hasConstrains = true;
|
||||
if (constrain instanceof DirectValueActionItem) {
|
||||
if (Double.compare(EcmaScript.toNumber(constrain.getResult()), 0) == 0) {
|
||||
hasConstrains = false;
|
||||
}
|
||||
}
|
||||
writer.append("startDrag");
|
||||
writer.spaceBeforeCallParenthesies(2);
|
||||
writer.append("(");
|
||||
target.toString(writer, localData);
|
||||
writer.append(",");
|
||||
lockCenter.toString(writer, localData);
|
||||
if (hasConstrains) {
|
||||
writer.append(",");
|
||||
x1.toString(writer, localData);
|
||||
writer.append(",");
|
||||
y1.toString(writer, localData);
|
||||
writer.append(",");
|
||||
x2.toString(writer, localData);
|
||||
writer.append(",");
|
||||
y2.toString(writer, localData);
|
||||
}
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(target.getNeededSources());
|
||||
ret.addAll(constrain.getNeededSources());
|
||||
ret.addAll(x1.getNeededSources());
|
||||
ret.addAll(x2.getNeededSources());
|
||||
ret.addAll(y1.getNeededSources());
|
||||
ret.addAll(y2.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
boolean hasConstrains = true;
|
||||
if (constrain instanceof DirectValueActionItem) {
|
||||
if (Double.compare(EcmaScript.toNumber(constrain.getResult()), 0) == 0) {
|
||||
hasConstrains = false;
|
||||
}
|
||||
}
|
||||
if (hasConstrains) {
|
||||
return toSourceMerge(localData, generator, x1, y1, x2, y2, constrain, lockCenter, target, new ActionStartDrag());
|
||||
} else {
|
||||
return toSourceMerge(localData, generator, constrain, lockCenter, target, new ActionStartDrag());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf3.ActionStop;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class StopActionItem extends ActionItem {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append("stop");
|
||||
writer.spaceBeforeCallParenthesies(0);
|
||||
return writer.append("()");
|
||||
}
|
||||
|
||||
public StopActionItem(GraphSourceItem instruction) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, new ActionStop());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf3.ActionStopSounds;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class StopAllSoundsActionItem extends ActionItem {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append("stopAllSounds");
|
||||
writer.spaceBeforeCallParenthesies(0);
|
||||
return writer.append("()");
|
||||
}
|
||||
|
||||
public StopAllSoundsActionItem(GraphSourceItem instruction) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, new ActionStopSounds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionEndDrag;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class StopDragActionItem extends ActionItem {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append("stopDrag");
|
||||
writer.spaceBeforeCallParenthesies(0);
|
||||
return writer.append("()");
|
||||
}
|
||||
|
||||
public StopDragActionItem(GraphSourceItem instruction) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, new ActionEndDrag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphPart;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class StoreRegisterActionItem extends ActionItem implements SetTypeActionItem {
|
||||
|
||||
public RegisterNumber register;
|
||||
//public GraphTargetItem value;
|
||||
public boolean define = false;
|
||||
public boolean temporary = false;
|
||||
|
||||
@Override
|
||||
public GraphPart getFirstPart() {
|
||||
return value.getFirstPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(GraphTargetItem value) {
|
||||
this.value = value;
|
||||
}
|
||||
private int tempRegister = -1;
|
||||
|
||||
@Override
|
||||
public int getTempRegister() {
|
||||
return tempRegister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTempRegister(int tempRegister) {
|
||||
this.tempRegister = tempRegister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public StoreRegisterActionItem(GraphSourceItem instruction, RegisterNumber register, GraphTargetItem value, boolean define) {
|
||||
super(instruction, PRECEDENCE_ASSIGMENT);
|
||||
this.value = value;
|
||||
this.register = register;
|
||||
this.define = define;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
if (temporary) {
|
||||
value.toString(writer, localData);
|
||||
} else {
|
||||
if (define) {
|
||||
writer.append("var ");
|
||||
}
|
||||
writer.append(register.translate() + " = ");
|
||||
value.toString(writer, localData);
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getObject() {
|
||||
return new DirectValueActionItem(src, -1, register, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionStoreRegister(register.number));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
|
||||
if (dependencies.contains(value)) {
|
||||
return false;
|
||||
}
|
||||
dependencies.add(value);
|
||||
return value.isCompileTime(dependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
return value.getResult();
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
|
||||
public class StrictModeActionItem extends ActionItem {
|
||||
|
||||
public int mode;
|
||||
|
||||
public StrictModeActionItem(GraphSourceItem instruction, int mode) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append("StrictMode");
|
||||
writer.spaceBeforeCallParenthesies(0);
|
||||
return writer.append("(" + mode + ");"); //I still don't know how AS source of Strict Mode instruction looks like, assuming this...
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false; //FIXME ?
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionStringExtract;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class StringExtractActionItem extends ActionItem {
|
||||
|
||||
//public GraphTargetItem value;
|
||||
public GraphTargetItem index;
|
||||
public GraphTargetItem count;
|
||||
|
||||
public StringExtractActionItem(GraphSourceItem instruction, GraphTargetItem value, GraphTargetItem index, GraphTargetItem count) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
this.index = index;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
value.toString(writer, localData);
|
||||
writer.append(".substr");
|
||||
writer.spaceBeforeCallParenthesies(2);
|
||||
writer.append("(");
|
||||
index.toString(writer, localData);
|
||||
writer.append(",");
|
||||
count.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
ret.addAll(index.getNeededSources());
|
||||
ret.addAll(count.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, index, count, new ActionStringExtract());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionStringLength;
|
||||
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.model.LocalData;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class StringLengthActionItem extends ActionItem {
|
||||
|
||||
//public GraphTargetItem value;
|
||||
public StringLengthActionItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("length");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionStringLength());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionTargetPath;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class TargetPathActionItem extends ActionItem {
|
||||
|
||||
public TargetPathActionItem(GraphSourceItem instruction, GraphTargetItem object) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("targetPath");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionTargetPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TemporaryRegister extends ActionItem {
|
||||
|
||||
private final int regId;
|
||||
|
||||
public TemporaryRegister(int regId, GraphTargetItem value) {
|
||||
super(value.src, value.getPrecedence());
|
||||
this.value = value;
|
||||
this.regId = regId;
|
||||
}
|
||||
|
||||
public int getRegId() {
|
||||
return regId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "temp reg " + regId + ":" + value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
return value.toString(writer, localData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return value.hasReturnValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
return value.getResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
return value.getAllSubItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
return value.getNeededSources();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getNotCoerced() {
|
||||
return value.getNotCoerced();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf7.ActionThrow;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class ThrowActionItem extends ActionItem {
|
||||
|
||||
public ThrowActionItem(GraphSourceItem instruction, GraphTargetItem object) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("throw ");
|
||||
return value.toString(writer, localData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionThrow());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionToInteger;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class ToIntegerActionItem extends ActionItem {
|
||||
|
||||
public ToIntegerActionItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("int");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionToInteger());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionToNumber;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class ToNumberActionItem extends ActionItem {
|
||||
|
||||
public ToNumberActionItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("Number");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionToNumber());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionToString;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class ToStringActionItem extends ActionItem {
|
||||
|
||||
public ToStringActionItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("String");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionToString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf3.ActionToggleQuality;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class ToggleHighQualityActionItem extends ActionItem {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append("toggleHighQuality");
|
||||
writer.spaceBeforeCallParenthesies(0);
|
||||
return writer.append("()");
|
||||
}
|
||||
|
||||
public ToggleHighQualityActionItem(GraphSourceItem instruction) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, new ActionToggleQuality());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionTrace;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
|
||||
public class TraceActionItem extends ActionItem {
|
||||
|
||||
public TraceActionItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("trace");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
value.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionTrace());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionTypeOf;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaType;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class TypeOfActionItem extends ActionItem {
|
||||
|
||||
public TypeOfActionItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("typeof ");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
value.toString(writer, localData);
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
ret.addAll(value.getNeededSources());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
Object res = value.getResult();
|
||||
EcmaType type = EcmaScript.type(res);
|
||||
switch (type) {
|
||||
case STRING:
|
||||
return "string";
|
||||
case BOOLEAN:
|
||||
return "boolean";
|
||||
case NUMBER:
|
||||
return "number";
|
||||
case OBJECT:
|
||||
return "object";
|
||||
case UNDEFINED:
|
||||
return "undefined";
|
||||
case NULL:
|
||||
return "null";
|
||||
}
|
||||
//TODO: function,movieclip
|
||||
return "object";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
|
||||
if (dependencies.contains(value)) {
|
||||
return false;
|
||||
}
|
||||
dependencies.add(value);
|
||||
return value.isCompileTime(dependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, value, new ActionTypeOf());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
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.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class UnLoadMovieActionItem extends ActionItem {
|
||||
|
||||
private final GraphTargetItem targetString;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(targetString);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public UnLoadMovieActionItem(GraphSourceItem instruction, GraphTargetItem targetString) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.targetString = targetString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("unloadMovie");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
targetString.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator, new ActionPush(""), targetString, new ActionGetURL2(0, false, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.operations.AddActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf3.ActionGetURL;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
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.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class UnLoadMovieNumActionItem extends ActionItem {
|
||||
|
||||
private final GraphTargetItem num;
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> getAllSubItems() {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
ret.add(num);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public UnLoadMovieNumActionItem(GraphSourceItem instruction, GraphTargetItem num) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("unloadMovieNum");
|
||||
writer.spaceBeforeCallParenthesies(1);
|
||||
writer.append("(");
|
||||
num.toString(writer, localData);
|
||||
return writer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
if ((num instanceof DirectValueActionItem) && (((DirectValueActionItem) num).value instanceof Long)) {
|
||||
return toSourceMerge(localData, generator, new ActionGetURL("", "_level" + ((DirectValueActionItem) num).value));
|
||||
} else {
|
||||
return toSourceMerge(localData, generator, new ActionPush(""), new AddActionItem(src, asGenerator.pushConstTargetItem("_level"), num, true), new ActionGetURL2(0, false, true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.AppStrings;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
|
||||
public class UnsupportedActionItem extends ActionItem {
|
||||
|
||||
public String value;
|
||||
|
||||
public UnsupportedActionItem(GraphSourceItem instruction, String value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
return writer.append("//" + AppStrings.translate("decompilation.unsupported") + ":" + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model.clauses;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.model.ActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.FunctionActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.GetMemberActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.SetMemberActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
|
||||
import com.jpexs.decompiler.graph.Block;
|
||||
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.model.ContinueItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ClassActionItem extends ActionItem implements Block {
|
||||
|
||||
public List<GraphTargetItem> functions;
|
||||
public List<GraphTargetItem> staticFunctions;
|
||||
public GraphTargetItem extendsOp;
|
||||
public List<GraphTargetItem> implementsOp;
|
||||
public GraphTargetItem className;
|
||||
public GraphTargetItem constructor;
|
||||
public List<MyEntry<GraphTargetItem, GraphTargetItem>> vars;
|
||||
public List<MyEntry<GraphTargetItem, GraphTargetItem>> staticVars;
|
||||
public Set<String> uninitializedVars;
|
||||
|
||||
@Override
|
||||
public List<List<GraphTargetItem>> getSubs() {
|
||||
List<List<GraphTargetItem>> ret = new ArrayList<>();
|
||||
if (functions != null) {
|
||||
ret.add(functions);
|
||||
}
|
||||
if (staticFunctions != null) {
|
||||
ret.add(staticFunctions);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public ClassActionItem(GraphTargetItem className, GraphTargetItem extendsOp, List<GraphTargetItem> implementsOp, GraphTargetItem constructor, List<GraphTargetItem> functions, List<MyEntry<GraphTargetItem, GraphTargetItem>> vars, List<GraphTargetItem> staticFunctions, List<MyEntry<GraphTargetItem, GraphTargetItem>> staticVars) {
|
||||
super(null, NOPRECEDENCE);
|
||||
this.className = className;
|
||||
this.functions = functions;
|
||||
this.vars = vars;
|
||||
this.extendsOp = extendsOp;
|
||||
this.implementsOp = implementsOp;
|
||||
this.staticFunctions = staticFunctions;
|
||||
this.staticVars = staticVars;
|
||||
this.constructor = constructor;
|
||||
|
||||
List<GraphTargetItem> allFunc = new ArrayList<>(functions);
|
||||
if (constructor != null) {
|
||||
allFunc.add(constructor);
|
||||
}
|
||||
this.uninitializedVars = new HashSet<>();
|
||||
List<GraphTargetItem> allUsages = new ArrayList<>();
|
||||
for (GraphTargetItem it : allFunc) {
|
||||
if (it instanceof FunctionActionItem) {
|
||||
FunctionActionItem f = (FunctionActionItem) it;
|
||||
detectUnitializedVars(f.actions, allUsages);
|
||||
}
|
||||
}
|
||||
Set<String> allMembers = new HashSet<>();
|
||||
for (GraphTargetItem it : allUsages) {
|
||||
allMembers.add(it.toStringNoQuotes(LocalData.empty));
|
||||
}
|
||||
uninitializedVars.addAll(allMembers);
|
||||
for (MyEntry<GraphTargetItem, GraphTargetItem> v : vars) {
|
||||
String s = v.key.toStringNoQuotes(LocalData.empty);
|
||||
if (uninitializedVars.contains(s)) {
|
||||
uninitializedVars.remove(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isThis(GraphTargetItem item) {
|
||||
if (item instanceof VariableActionItem) {
|
||||
return "this".equals(((VariableActionItem) item).getVariableName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void detectUnitializedVars(GraphTargetItem item, List<GraphTargetItem> ret) {
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (item instanceof GetMemberActionItem) {
|
||||
GetMemberActionItem gm = (GetMemberActionItem) item;
|
||||
if (isThis(gm.object)) {
|
||||
ret.add(gm.memberName);
|
||||
} else {
|
||||
detectUnitializedVars(gm.object, ret);
|
||||
}
|
||||
}
|
||||
if (item instanceof SetMemberActionItem) {
|
||||
SetMemberActionItem sm = (SetMemberActionItem) item;
|
||||
if (isThis(sm.object)) {
|
||||
ret.add(sm.objectName);
|
||||
} else {
|
||||
detectUnitializedVars(sm.object, ret);
|
||||
}
|
||||
}
|
||||
|
||||
if (item instanceof Block) {
|
||||
Block bl = (Block) item;
|
||||
for (List<GraphTargetItem> list : bl.getSubs()) {
|
||||
detectUnitializedVars(list, ret);
|
||||
}
|
||||
}
|
||||
detectUnitializedVars(item.getAllSubItems(), ret);
|
||||
}
|
||||
|
||||
private void detectUnitializedVars(List<GraphTargetItem> items, List<GraphTargetItem> ret) {
|
||||
for (GraphTargetItem it : items) {
|
||||
detectUnitializedVars(it, ret);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("class ");
|
||||
className.toStringNoQuotes(writer, localData);
|
||||
if (extendsOp != null) {
|
||||
writer.append(" extends ");
|
||||
extendsOp.toStringNoQuotes(writer, localData);
|
||||
}
|
||||
if (!implementsOp.isEmpty()) {
|
||||
writer.append(" implements ");
|
||||
boolean first = true;
|
||||
for (GraphTargetItem t : implementsOp) {
|
||||
if (!first) {
|
||||
writer.append(", ");
|
||||
}
|
||||
first = false;
|
||||
Action.getWithoutGlobal(t).toString(writer, localData);
|
||||
}
|
||||
}
|
||||
writer.startBlock();
|
||||
|
||||
if (constructor != null) {
|
||||
constructor.toString(writer, localData).newLine();
|
||||
}
|
||||
|
||||
for (MyEntry<GraphTargetItem, GraphTargetItem> item : vars) {
|
||||
writer.append("var ");
|
||||
item.key.toStringNoQuotes(writer, localData);
|
||||
writer.append(" = ");
|
||||
item.value.toString(writer, localData);
|
||||
writer.append(";").newLine();
|
||||
}
|
||||
for (String v : uninitializedVars) {
|
||||
writer.append("var ");
|
||||
writer.append(v);
|
||||
writer.append(";").newLine();
|
||||
}
|
||||
for (MyEntry<GraphTargetItem, GraphTargetItem> item : staticVars) {
|
||||
writer.append("static var ");
|
||||
item.key.toStringNoQuotes(writer, localData);
|
||||
writer.append(" = ");
|
||||
item.value.toString(writer, localData);
|
||||
writer.append(";").newLine();
|
||||
}
|
||||
|
||||
for (GraphTargetItem f : functions) {
|
||||
f.toString(writer, localData).newLine();
|
||||
}
|
||||
for (GraphTargetItem f : staticFunctions) {
|
||||
writer.append("static ");
|
||||
f.toString(writer, localData).newLine();
|
||||
}
|
||||
|
||||
return writer.endBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ContinueItem> getContinues() {
|
||||
List<ContinueItem> ret = new ArrayList<>();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsSemicolon() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
SourceGeneratorLocalData localData2 = Helper.deepCopy(localData);
|
||||
asGenerator.setInMethod(localData2, true);
|
||||
ret.addAll(asGenerator.generateTraits(localData2, false, className, extendsOp, implementsOp, constructor, functions, vars, staticFunctions, staticVars));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 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.model.clauses;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionIf;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionJump;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPop;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionSetVariable;
|
||||
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.ActionEnumerate2;
|
||||
import com.jpexs.decompiler.flash.ecma.Null;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.LoopWithType;
|
||||
import com.jpexs.decompiler.flash.helpers.NulWriter;
|
||||
import com.jpexs.decompiler.graph.Block;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.Loop;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.ContinueItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ForInActionItem extends LoopActionItem implements Block {
|
||||
|
||||
public GraphTargetItem variableName;
|
||||
public GraphTargetItem enumVariable;
|
||||
public List<GraphTargetItem> commands;
|
||||
private boolean labelUsed;
|
||||
|
||||
@Override
|
||||
public List<List<GraphTargetItem>> getSubs() {
|
||||
List<List<GraphTargetItem>> ret = new ArrayList<>();
|
||||
if (commands != null) {
|
||||
ret.add(commands);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public ForInActionItem(Action instruction, Loop loop, GraphTargetItem variableName, GraphTargetItem enumVariable, List<GraphTargetItem> commands) {
|
||||
super(instruction, loop);
|
||||
this.variableName = variableName;
|
||||
this.enumVariable = enumVariable;
|
||||
this.commands = commands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsSemicolon() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
if (writer instanceof NulWriter) {
|
||||
((NulWriter) writer).startLoop(loop.id, LoopWithType.LOOP_TYPE_LOOP);
|
||||
}
|
||||
if (labelUsed) {
|
||||
writer.append("loop" + loop.id + ":").newLine();
|
||||
}
|
||||
writer.append("for");
|
||||
if (writer.getFormatting().spaceBeforeParenthesesForParentheses) {
|
||||
writer.append(" ");
|
||||
}
|
||||
writer.append("(");
|
||||
if ((variableName instanceof DirectValueActionItem) && (((DirectValueActionItem) variableName).value instanceof RegisterNumber)) {
|
||||
writer.append("var ");
|
||||
}
|
||||
stripQuotes(variableName, localData, writer);
|
||||
writer.append(" in ");
|
||||
enumVariable.toString(writer, localData);
|
||||
writer.append(")").startBlock();
|
||||
for (GraphTargetItem ti : commands) {
|
||||
ti.toStringSemicoloned(writer, localData).newLine();
|
||||
}
|
||||
writer.endBlock();
|
||||
if (writer instanceof NulWriter) {
|
||||
LoopWithType loopOjb = ((NulWriter) writer).endLoop(loop.id);
|
||||
labelUsed = loopOjb.used;
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ContinueItem> getContinues() {
|
||||
List<ContinueItem> ret = new ArrayList<>();
|
||||
for (GraphTargetItem ti : commands) {
|
||||
if (ti instanceof ContinueItem) {
|
||||
ret.add((ContinueItem) ti);
|
||||
}
|
||||
if (ti instanceof Block) {
|
||||
ret.addAll(((Block) ti).getContinues());
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
List<GraphSourceItem> ret = new ArrayList<>();
|
||||
ActionSourceGenerator asGenerator = (ActionSourceGenerator) generator;
|
||||
HashMap<String, Integer> registerVars = asGenerator.getRegisterVars(localData);
|
||||
ret.addAll(enumVariable.toSource(localData, generator));
|
||||
ret.add(new ActionEnumerate2());
|
||||
|
||||
List<Action> loopExpr = new ArrayList<>();
|
||||
int exprReg = 0;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
if (!registerVars.containsValue(i)) {
|
||||
registerVars.put("__forin" + asGenerator.uniqId(), i);
|
||||
exprReg = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int innerExprReg = asGenerator.getTempRegister(localData);
|
||||
loopExpr.add(new ActionStoreRegister(exprReg));
|
||||
loopExpr.add(new ActionPush(new Null()));
|
||||
loopExpr.add(new ActionEquals2());
|
||||
ActionIf forInEndIf = new ActionIf(0);
|
||||
loopExpr.add(forInEndIf);
|
||||
List<Action> loopBody = new ArrayList<>();
|
||||
loopBody.add(new ActionPush(new RegisterNumber(exprReg)));
|
||||
if (asGenerator.isInFunction(localData) == 2) {
|
||||
loopBody.add(new ActionStoreRegister(innerExprReg));
|
||||
loopBody.add(new ActionPop());
|
||||
} else {
|
||||
loopBody.addAll(0, asGenerator.toActionList(variableName.toSource(localData, generator)));
|
||||
loopBody.add(new ActionSetVariable());
|
||||
}
|
||||
int oldForIn = asGenerator.getForInLevel(localData);
|
||||
asGenerator.setForInLevel(localData, oldForIn + 1);
|
||||
loopBody.addAll(asGenerator.toActionList(asGenerator.generate(localData, commands)));
|
||||
asGenerator.setForInLevel(localData, oldForIn);
|
||||
ActionJump forinJmpBack = new ActionJump(0);
|
||||
loopBody.add(forinJmpBack);
|
||||
int bodyLen = Action.actionsToBytes(loopBody, false, SWF.DEFAULT_VERSION).length;
|
||||
int exprLen = Action.actionsToBytes(loopExpr, false, SWF.DEFAULT_VERSION).length;
|
||||
forinJmpBack.setJumpOffset(-bodyLen - exprLen);
|
||||
forInEndIf.setJumpOffset(bodyLen);
|
||||
ret.addAll(loopExpr);
|
||||
ret.addAll(loopBody);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user