mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-03 17:05:12 +00:00
Merge branch 'dev' into fix/convert-performance-issues
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package com.jpexs.decompiler.flash;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface DeobfuscationListener {
|
||||
public void itemDeobfuscated();
|
||||
}
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash;
|
||||
|
||||
import com.jpexs.decompiler.graph.Loop;
|
||||
|
||||
@@ -168,6 +168,7 @@ import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.ImmediateFuture;
|
||||
import com.jpexs.helpers.NulStream;
|
||||
import com.jpexs.helpers.ProgressListener;
|
||||
import com.jpexs.helpers.Reference;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.awt.AlphaComposite;
|
||||
@@ -1949,7 +1950,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
}
|
||||
}
|
||||
|
||||
protected void informListeners(String event, Object data) {
|
||||
public void informListeners(String event, Object data) {
|
||||
for (EventListener listener : listeners) {
|
||||
listener.handleEvent(event, data);
|
||||
}
|
||||
@@ -3353,13 +3354,24 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
public void deobfuscate(DeobfuscationLevel level) throws InterruptedException {
|
||||
List<ABCContainerTag> atags = getAbcList();
|
||||
|
||||
int apos = 0;
|
||||
for (ABCContainerTag tag : atags) {
|
||||
apos++;
|
||||
final int fpos = apos;
|
||||
Reference<Integer> numDeoScripts = new Reference<>(0);
|
||||
DeobfuscationListener deoListener = new DeobfuscationListener() {
|
||||
@Override
|
||||
public void itemDeobfuscated() {
|
||||
numDeoScripts.setVal(numDeoScripts.getVal() + 1);
|
||||
informListeners("deobfuscate_pcode", "abc " + fpos + "/" + atags.size() + " script " + numDeoScripts.getVal() + "/" + tag.getABC().script_info.size());
|
||||
}
|
||||
};
|
||||
if (level == DeobfuscationLevel.LEVEL_REMOVE_DEAD_CODE) {
|
||||
tag.getABC().removeDeadCode();
|
||||
tag.getABC().removeDeadCode(deoListener);
|
||||
} else if (level == DeobfuscationLevel.LEVEL_REMOVE_TRAPS) {
|
||||
tag.getABC().removeTraps();
|
||||
tag.getABC().removeTraps(deoListener);
|
||||
} else if (level == DeobfuscationLevel.LEVEL_RESTORE_CONTROL_FLOW) {
|
||||
tag.getABC().removeTraps();
|
||||
tag.getABC().removeTraps(deoListener);
|
||||
}
|
||||
|
||||
((Tag) tag).setModified(true);
|
||||
@@ -3374,14 +3386,14 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
* @param decompileDir Directory to virtual decompile (will affect
|
||||
* debugfile)
|
||||
*/
|
||||
public void enableDebugging(boolean injectAS3Code, File decompileDir) {
|
||||
public void enableDebugging(boolean injectAS3Code, File decompileDir) throws InterruptedException {
|
||||
enableDebugging(injectAS3Code, decompileDir, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables debugging. Adds tags to enable debugging.
|
||||
*/
|
||||
public void enableDebugging() {
|
||||
public void enableDebugging() throws InterruptedException {
|
||||
enableDebugging(false, null, false);
|
||||
}
|
||||
|
||||
@@ -3394,7 +3406,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
* debugfile)
|
||||
* @param telemetry Enable telemetry info?
|
||||
*/
|
||||
public void enableDebugging(boolean injectAS3Code, File decompileDir, boolean telemetry) {
|
||||
public void enableDebugging(boolean injectAS3Code, File decompileDir, boolean telemetry) throws InterruptedException {
|
||||
enableDebugging(injectAS3Code, decompileDir, telemetry, false);
|
||||
}
|
||||
|
||||
@@ -3402,9 +3414,15 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
* Injects debugline and debugfile instructions to AS3 P-code (lines of
|
||||
* P-code)
|
||||
*/
|
||||
public void injectAS3PcodeDebugInfo() {
|
||||
public void injectAS3PcodeDebugInfo() throws InterruptedException {
|
||||
List<ScriptPack> packs = getAS3Packs();
|
||||
int i = 0;
|
||||
for (ScriptPack s : packs) {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
i++;
|
||||
informListeners("inject_debuginfo", "" + i + "/" + packs.size() + ": " + s.getPath());
|
||||
int abcIndex = s.allABCs.indexOf(s.abc);
|
||||
if (s.isSimple) {
|
||||
s.injectPCodeDebugInfo(abcIndex);
|
||||
@@ -3417,9 +3435,15 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
*
|
||||
* @param decompileDir Directory to set file information paths
|
||||
*/
|
||||
public void injectAS3DebugInfo(File decompileDir) {
|
||||
public void injectAS3DebugInfo(File decompileDir) throws InterruptedException {
|
||||
List<ScriptPack> packs = getAS3Packs();
|
||||
int i = 0;
|
||||
for (ScriptPack s : packs) {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
i++;
|
||||
informListeners("inject_debuginfo", "" + i + "/" + packs.size() + ": " + s.getPath());
|
||||
if (s.isSimple) {
|
||||
s.injectDebugInfo(decompileDir);
|
||||
}
|
||||
@@ -3436,7 +3460,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
* @param telemetry Enable telemetry info?
|
||||
* @param pcodeLevel inject Pcode lines instead of decompiled lines
|
||||
*/
|
||||
public void enableDebugging(boolean injectAS3Code, File decompileDir, boolean telemetry, boolean pcodeLevel) {
|
||||
public void enableDebugging(boolean injectAS3Code, File decompileDir, boolean telemetry, boolean pcodeLevel) throws InterruptedException {
|
||||
|
||||
if (injectAS3Code) {
|
||||
if (pcodeLevel) {
|
||||
@@ -3520,7 +3544,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
return r;
|
||||
}
|
||||
|
||||
public boolean generatePCodeSwdFile(File file, Map<String, Set<Integer>> breakpoints) throws IOException {
|
||||
public boolean generatePCodeSwdFile(File file, Map<String, Set<Integer>> breakpoints) throws IOException, InterruptedException {
|
||||
DebugIDTag dit = getDebugId();
|
||||
if (dit == null) {
|
||||
return false;
|
||||
@@ -3540,6 +3564,10 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
List<String> names = new ArrayList<>(asms.keySet());
|
||||
Collections.sort(names);
|
||||
for (String name : names) {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
informListeners("generate_swd", name);
|
||||
moduleId++;
|
||||
String sname = "#PCODE " + name;
|
||||
int bitmap = SWD.bitmapAction;
|
||||
@@ -3611,6 +3639,10 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
List<String> names = new ArrayList<>(asms.keySet());
|
||||
Collections.sort(names);
|
||||
for (String name : names) {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
informListeners("generate_swd", name);
|
||||
List<SWD.DebugRegisters> regitems = new ArrayList<>();
|
||||
moduleId++;
|
||||
HighlightedText cs;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.DeobfuscationListener;
|
||||
import com.jpexs.decompiler.flash.EndOfStreamException;
|
||||
import com.jpexs.decompiler.flash.EventListener;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
@@ -232,14 +233,24 @@ public class ABC {
|
||||
}
|
||||
|
||||
public int removeTraps() throws InterruptedException {
|
||||
return removeTraps(null);
|
||||
}
|
||||
public int removeTraps(DeobfuscationListener listener) throws InterruptedException {
|
||||
int rem = 0;
|
||||
for (int s = 0; s < script_info.size(); s++) {
|
||||
rem += script_info.get(s).removeTraps(s, this, "");
|
||||
if (listener != null) {
|
||||
listener.itemDeobfuscated();
|
||||
}
|
||||
}
|
||||
return rem;
|
||||
}
|
||||
|
||||
public int removeDeadCode() throws InterruptedException {
|
||||
return removeDeadCode(null);
|
||||
}
|
||||
|
||||
public int removeDeadCode(DeobfuscationListener listener) throws InterruptedException {
|
||||
int rem = 0;
|
||||
for (MethodBody body : bodies) {
|
||||
rem += body.removeDeadCode(constants, null/*FIXME*/, method_info.get(body.method_info));
|
||||
|
||||
@@ -423,7 +423,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
Trait trait = abc.findTraitByTraitId(classIndex, traitIndex);
|
||||
if (((trait instanceof TraitMethodGetterSetter) && (((TraitMethodGetterSetter) trait).method_info != methodIndex))
|
||||
|| ((trait instanceof TraitFunction) && (((TraitFunction) trait).method_info != methodIndex))) {
|
||||
continue; //inner anonymous function - ignore. TODO: make work
|
||||
//continue; //inner anonymous function - ignore. TODO: make work
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -248,8 +248,10 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.xml.DXNSIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.xml.DXNSLateIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.xml.EscXAttrIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.xml.EscXElemIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.InitPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
@@ -1861,7 +1863,7 @@ public class AVM2Code implements Cloneable {
|
||||
return assignment;
|
||||
}
|
||||
|
||||
private void injectDeclarations(List<GraphTargetItem> items, int minreg, DeclarationAVM2Item[] declaredRegisters, List<Slot> declaredSlots, List<DeclarationAVM2Item> declaredSlotsDec, ABC abc, MethodBody body) {
|
||||
private void injectDeclarations(List<String> paramNames, List<GraphTargetItem> items, int minreg, DeclarationAVM2Item[] declaredRegisters, List<Slot> declaredSlots, List<DeclarationAVM2Item> declaredSlotsDec, List<String> declaredProperties, List<DeclarationAVM2Item> declaredPropsDec, ABC abc, MethodBody body) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
GraphTargetItem currentItem = items.get(i);
|
||||
List<GraphTargetItem> itemsOnLine = new ArrayList<>();
|
||||
@@ -1905,35 +1907,72 @@ public class AVM2Code implements Cloneable {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (subItem instanceof SetPropertyAVM2Item) {
|
||||
SetPropertyAVM2Item sp = (SetPropertyAVM2Item) subItem;
|
||||
if (sp.object instanceof FindPropertyAVM2Item) {
|
||||
if (sp.propertyName instanceof FullMultinameAVM2Item) {
|
||||
FullMultinameAVM2Item propName = (FullMultinameAVM2Item) sp.propertyName;
|
||||
if (!paramNames.contains(propName.resolvedMultinameName)) {
|
||||
if (!declaredProperties.contains(propName.resolvedMultinameName)) {
|
||||
for (int t = 0; t < body.traits.traits.size(); t++) {
|
||||
if (body.traits.traits.get(t).getName(abc).getName(abc.constants, new ArrayList<DottedChain>(), true, false)
|
||||
.equals(propName.resolvedMultinameName)) {
|
||||
if (body.traits.traits.get(t) instanceof TraitSlotConst) {
|
||||
GraphTargetItem type = PropertyAVM2Item.multinameToType(((TraitSlotConst) body.traits.traits.get(t)).type_index, abc.constants);
|
||||
DeclarationAVM2Item d = new DeclarationAVM2Item(subItem, type);
|
||||
sp.setDeclaration(d);
|
||||
declaredPropsDec.add(d);
|
||||
declaredProperties.add(propName.resolvedMultinameName);
|
||||
if (subItem == currentItem) {
|
||||
items.set(i, d);
|
||||
} else {
|
||||
d.showValue = false;
|
||||
items.add(i, d);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int idx = declaredProperties.indexOf(propName.resolvedMultinameName);
|
||||
sp.setDeclaration(declaredPropsDec.get(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (subItem instanceof SetSlotAVM2Item) {
|
||||
SetSlotAVM2Item ssti = (SetSlotAVM2Item) subItem;
|
||||
if (ssti.scope instanceof NewActivationAVM2Item) {
|
||||
Slot sl = new Slot(ssti.scope, ssti.slotName);
|
||||
if (!declaredSlots.contains(sl)) {
|
||||
GraphTargetItem type = TypeItem.UNBOUNDED;
|
||||
for (int t = 0; t < body.traits.traits.size(); t++) {
|
||||
if (body.traits.traits.get(t).getName(abc) == sl.multiname) {
|
||||
if (body.traits.traits.get(t) instanceof TraitSlotConst) {
|
||||
type = PropertyAVM2Item.multinameToType(((TraitSlotConst) body.traits.traits.get(t)).type_index, abc.constants);
|
||||
if (!paramNames.contains(sl.multiname.getName(abc.constants, new ArrayList<>(), true, false))) {
|
||||
|
||||
if (!declaredSlots.contains(sl)) {
|
||||
GraphTargetItem type = TypeItem.UNBOUNDED;
|
||||
for (int t = 0; t < body.traits.traits.size(); t++) {
|
||||
if (body.traits.traits.get(t).getName(abc) == sl.multiname) {
|
||||
if (body.traits.traits.get(t) instanceof TraitSlotConst) {
|
||||
type = PropertyAVM2Item.multinameToType(((TraitSlotConst) body.traits.traits.get(t)).type_index, abc.constants);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DeclarationAVM2Item d = new DeclarationAVM2Item(subItem, type);
|
||||
ssti.setDeclaration(d);
|
||||
declaredSlotsDec.add(d);
|
||||
declaredSlots.add(sl);
|
||||
DeclarationAVM2Item d = new DeclarationAVM2Item(subItem, type);
|
||||
ssti.setDeclaration(d);
|
||||
declaredSlotsDec.add(d);
|
||||
declaredSlots.add(sl);
|
||||
|
||||
if (subItem == currentItem) {
|
||||
items.set(i, d);
|
||||
} else {
|
||||
d.showValue = false;
|
||||
items.add(i, d);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (subItem == currentItem) {
|
||||
items.set(i, d);
|
||||
} else {
|
||||
d.showValue = false;
|
||||
items.add(i, d);
|
||||
i++;
|
||||
int idx = declaredSlots.indexOf(sl);
|
||||
ssti.setDeclaration(declaredSlotsDec.get(idx));
|
||||
}
|
||||
|
||||
} else {
|
||||
int idx = declaredSlots.indexOf(sl);
|
||||
ssti.setDeclaration(declaredSlotsDec.get(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1942,7 +1981,7 @@ public class AVM2Code implements Cloneable {
|
||||
if (currentItem instanceof Block) {
|
||||
Block blk = (Block) currentItem;
|
||||
for (List<GraphTargetItem> sub : blk.getSubs()) {
|
||||
injectDeclarations(sub, minreg, declaredRegisters, declaredSlots, declaredSlotsDec, abc, body);
|
||||
injectDeclarations(paramNames, sub, minreg, declaredRegisters, declaredSlots, declaredSlotsDec, declaredProperties, declaredPropsDec, abc, body);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2088,7 +2127,12 @@ public class AVM2Code implements Cloneable {
|
||||
//
|
||||
|
||||
//int minreg = abc.method_info.get(body.method_info).getMaxReservedReg() + 1;
|
||||
injectDeclarations(list, 1, d, new ArrayList<>(), new ArrayList<>(), abc, body);
|
||||
HashMap<Integer, String> registerNames = body.getLocalRegNames(abc);
|
||||
List<String> paramNamesList = new ArrayList<>();
|
||||
for (int ir = 0; ir < r; ir++) {
|
||||
paramNamesList.add(AVM2Item.localRegName(localRegNames, ir));
|
||||
}
|
||||
injectDeclarations(paramNamesList, list, 1, d, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), abc, body);
|
||||
|
||||
int lastPos = list.size() - 1;
|
||||
if (lastPos < 0) {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2;
|
||||
|
||||
import com.jpexs.decompiler.flash.FinalProcessLocalData;
|
||||
import com.jpexs.decompiler.graph.Loop;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class AVM2FinalProcessLocalData extends FinalProcessLocalData {
|
||||
|
||||
public HashMap<Integer, String> localRegNames;
|
||||
|
||||
public AVM2FinalProcessLocalData(List<Loop> loops, HashMap<Integer, String> localRegNames) {
|
||||
super(loops);
|
||||
this.localRegNames = localRegNames;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.FinalProcessLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2FinalProcessLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.CodeStats;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
@@ -46,6 +47,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushByteIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushScopeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceAIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertIIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ConstructAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FilteredCheckAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item;
|
||||
@@ -114,6 +116,7 @@ import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
@@ -462,15 +465,17 @@ public class AVM2Graph extends Graph {
|
||||
}
|
||||
}
|
||||
|
||||
//return in finally block is joined after switch decision
|
||||
for (GraphPart p : switchPart.nextParts) {
|
||||
//This caused problems, so it's commented out
|
||||
//the tests still pass, so I can only wonder why it's there. :-(
|
||||
//return in finally block is joined after switch decision
|
||||
/*for (GraphPart p : switchPart.nextParts) {
|
||||
for (GraphPart r : p.refs) {
|
||||
if (r != switchPart) {
|
||||
localData.finallyJumps.put(r, p);
|
||||
localData.finallyJumpsToFinallyIndex.put(r, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
localData.ignoredSwitches.put(e, switchPart);
|
||||
} else {
|
||||
@@ -1964,6 +1969,24 @@ public class AVM2Graph extends Graph {
|
||||
Map<Integer, String> localRegNames = body.getLocalRegNames(abc);
|
||||
loopi:
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (list.get(i) instanceof SetPropertyAVM2Item) {
|
||||
SetPropertyAVM2Item sp = (SetPropertyAVM2Item) list.get(i);
|
||||
if (sp.object instanceof FindPropertyAVM2Item) {
|
||||
if (sp.propertyName instanceof FullMultinameAVM2Item) {
|
||||
FullMultinameAVM2Item propName = (FullMultinameAVM2Item) sp.propertyName;
|
||||
if (sp.value instanceof LocalRegAVM2Item) {
|
||||
LocalRegAVM2Item lr = (LocalRegAVM2Item) sp.value;
|
||||
AVM2FinalProcessLocalData aLocalData = (AVM2FinalProcessLocalData) localData;
|
||||
if (Objects.equals(propName.resolvedMultinameName, AVM2Item.localRegName(aLocalData.localRegNames, lr.regIndex))) {
|
||||
list.remove(i);
|
||||
i--;
|
||||
continue loopi;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (list.get(i) instanceof SetSlotAVM2Item) {
|
||||
SetSlotAVM2Item sslot = (SetSlotAVM2Item) list.get(i);
|
||||
if (sslot.slotObject instanceof NewActivationAVM2Item) {
|
||||
@@ -2153,7 +2176,7 @@ public class AVM2Graph extends Graph {
|
||||
|
||||
@Override
|
||||
protected FinalProcessLocalData getFinalData(BaseLocalData localData, List<Loop> loops, List<ThrowState> throwStates) {
|
||||
FinalProcessLocalData finalProcess = super.getFinalData(localData, loops, throwStates);
|
||||
FinalProcessLocalData finalProcess = new AVM2FinalProcessLocalData(loops, ((AVM2LocalData) localData).localRegNames);
|
||||
finalProcess.registerUsage = ((AVM2LocalData) localData).setLocalPosToGetLocalPos;
|
||||
return finalProcess;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
|
||||
@@ -89,7 +90,7 @@ public abstract class AVM2Item extends GraphTargetItem {
|
||||
}
|
||||
|
||||
if (!empty && object != null) {
|
||||
if (!empty && object != null) {
|
||||
if (object.getPrecedence() > PRECEDENCE_PRIMARY || (object instanceof IntegerValueAVM2Item)) {
|
||||
writer.append("(");
|
||||
object.toString(writer, localData);
|
||||
writer.append(")");
|
||||
|
||||
@@ -52,7 +52,13 @@ public class CallMethodAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
receiver.toString(writer, localData);
|
||||
if (receiver.getPrecedence() > getPrecedence() || (receiver instanceof IntegerValueAVM2Item)) {
|
||||
writer.append("(");
|
||||
receiver.toString(writer, localData);
|
||||
writer.append(")");
|
||||
} else {
|
||||
receiver.toString(writer, localData);
|
||||
}
|
||||
writer.append(".");
|
||||
writer.append(methodName);
|
||||
writer.spaceBeforeCallParenthesies(arguments.size());
|
||||
|
||||
@@ -52,7 +52,13 @@ public class CallStaticAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
receiver.toString(writer, localData);
|
||||
if (receiver.getPrecedence() > getPrecedence() || (receiver instanceof IntegerValueAVM2Item)) {
|
||||
writer.append("(");
|
||||
receiver.toString(writer, localData);
|
||||
writer.append(")");
|
||||
} else {
|
||||
receiver.toString(writer, localData);
|
||||
}
|
||||
writer.append(".");
|
||||
writer.append(methodName);
|
||||
writer.spaceBeforeCallParenthesies(arguments.size());
|
||||
|
||||
@@ -16,12 +16,15 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
|
||||
|
||||
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetSlotAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.SetPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.SetSlotAVM2Item;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightData;
|
||||
@@ -148,6 +151,39 @@ public class DeclarationAVM2Item extends AVM2Item {
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
|
||||
if (assignment instanceof SetPropertyAVM2Item) {
|
||||
SetPropertyAVM2Item spti = (SetPropertyAVM2Item) assignment;
|
||||
HighlightData srcData = getSrcData();
|
||||
srcData.localName = ((FullMultinameAVM2Item) spti.propertyName).resolvedMultinameName;
|
||||
srcData.declaration = true;
|
||||
|
||||
GraphTargetItem val = spti.value;
|
||||
GraphTargetItem coerType = TypeItem.UNBOUNDED;
|
||||
if (spti.value instanceof CoerceAVM2Item) {
|
||||
coerType = ((CoerceAVM2Item) spti.value).typeObj;
|
||||
}
|
||||
if (spti.value instanceof ConvertAVM2Item) {
|
||||
coerType = ((ConvertAVM2Item) spti.value).type;
|
||||
}
|
||||
//strip coerce if its declared as this type
|
||||
if (coerType.equals(type) && !coerType.equals(TypeItem.UNBOUNDED)) {
|
||||
val = val.value;
|
||||
}
|
||||
|
||||
srcData.declaredType = (type instanceof TypeItem) ? ((TypeItem) type).fullTypeName : DottedChain.ALL;
|
||||
writer.append("var ");
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(true, ((FullMultinameAVM2Item) spti.propertyName).resolvedMultinameName));
|
||||
writer.append(":");
|
||||
|
||||
type.appendTry(writer, localData);
|
||||
if (showValue) {
|
||||
writer.append(" = ");
|
||||
val.toString(writer, localData);
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
|
||||
writer.append("var ");
|
||||
return assignment.toString(writer, localData);
|
||||
}
|
||||
|
||||
@@ -1260,8 +1260,8 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
public void generateClass(List<DottedChain> importedClasses, List<AssignableAVM2Item> cinitVariables, boolean cinitNeedsActivation, List<GraphTargetItem> cinit, List<NamespaceItem> openedNamespaces, int namespace, int initScope, DottedChain pkg, ClassInfo classInfo, InstanceInfo instanceInfo, SourceGeneratorLocalData localData, boolean isInterface, String name, String superName, GraphTargetItem extendsVal, List<GraphTargetItem> implementsStr, GraphTargetItem iinit, List<AssignableAVM2Item> iinitVariables, boolean iinitNeedsActivation, List<GraphTargetItem> traitItems, Reference<Integer> class_index) throws AVM2ParseException, CompilationException {
|
||||
localData.currentClass = name;
|
||||
localData.pkg = pkg;
|
||||
localData.privateNs = abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PRIVATE, pkg.toRawString() + ":" + name, 0, true);
|
||||
localData.protectedNs = abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PROTECTED, pkg.toRawString() + ":" + name, 0, true);
|
||||
localData.privateNs = abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PRIVATE, pkg.toRawString().isEmpty() ? name : pkg.toRawString() + ":" + name, 0, true);
|
||||
localData.protectedNs = abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PROTECTED, pkg.toRawString().isEmpty() ? name : pkg.toRawString() + ":" + name, 0, true);
|
||||
if (extendsVal == null && !isInterface) {
|
||||
extendsVal = new TypeItem(DottedChain.OBJECT);
|
||||
}
|
||||
@@ -1621,7 +1621,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
UnresolvedAVM2Item n = (UnresolvedAVM2Item) an;
|
||||
if (n.resolved == null) {
|
||||
String fullClass = localData.getFullClass();
|
||||
GraphTargetItem res = n.resolve(localData.currentClass, new TypeItem(fullClass), paramTypes, paramNames, abcIndex, callStack, subvariables);
|
||||
GraphTargetItem res = n.resolve(localData, localData.currentClass, new TypeItem(fullClass), paramTypes, paramNames, abcIndex, callStack, subvariables);
|
||||
if (res instanceof AssignableAVM2Item) {
|
||||
subvariables.set(i, (AssignableAVM2Item) res);
|
||||
} else {
|
||||
@@ -1638,7 +1638,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
UnresolvedAVM2Item n = (UnresolvedAVM2Item) an;
|
||||
if (n.resolved == null) {
|
||||
String fullClass = localData.getFullClass();
|
||||
GraphTargetItem res = n.resolve(localData.currentClass, new TypeItem(fullClass), paramTypes, paramNames, abcIndex, callStack, subvariables);
|
||||
GraphTargetItem res = n.resolve(localData, localData.currentClass, new TypeItem(fullClass), paramTypes, paramNames, abcIndex, callStack, subvariables);
|
||||
paramTypes.set(t, res);
|
||||
}
|
||||
}
|
||||
@@ -1689,8 +1689,10 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
NameAVM2Item n = (NameAVM2Item) an;
|
||||
if (n.getVariableName().equals("arguments") & !n.isDefinition()) {
|
||||
registerNames.add("arguments");
|
||||
registerTypes.add(new TypeItem("Object"));
|
||||
registerTypes.add(new TypeItem("Array"));
|
||||
registerLines.add(0); //?
|
||||
slotNames.add(n.getVariableName());
|
||||
slotTypes.add(new TypeItem("Array"));
|
||||
hasArguments = true;
|
||||
break;
|
||||
}
|
||||
@@ -1916,8 +1918,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
declarations.add(d);
|
||||
}
|
||||
}
|
||||
boolean addRet = false;
|
||||
if (body != null) {
|
||||
body.addAll(0, declarations);
|
||||
if (body.isEmpty() || (!((body.get(body.size() - 1) instanceof ReturnValueAVM2Item)
|
||||
|| (body.get(body.size() - 1) instanceof ReturnVoidAVM2Item)))) {
|
||||
addRet = true;
|
||||
}
|
||||
}
|
||||
|
||||
localData.exceptions = new ArrayList<>();
|
||||
@@ -1994,23 +2001,20 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
}
|
||||
for (int i = 1; i < registerNames.size(); i++) {
|
||||
if (!needsActivation) {
|
||||
mbodyCode.add(i - 1, ins(AVM2Instructions.Debug, 1, str(registerNames.get(i)), i - 1, (int) registerLines.get(i)));
|
||||
}
|
||||
mbodyCode.add(i - 1, ins(AVM2Instructions.Debug, 1, str(registerNames.get(i)), i - 1, (int) registerLines.get(i)));
|
||||
}
|
||||
if (!subMethod) {
|
||||
mbodyCode.add(0, new AVM2Instruction(0, AVM2Instructions.GetLocal0, null));
|
||||
mbodyCode.add(1, new AVM2Instruction(0, AVM2Instructions.PushScope, null));
|
||||
}
|
||||
boolean addRet = false;
|
||||
if (!mbodyCode.isEmpty()) {
|
||||
/*if (!mbodyCode.isEmpty()) {
|
||||
InstructionDefinition lastDef = mbodyCode.get(mbodyCode.size() - 1).definition;
|
||||
if (!((lastDef instanceof ReturnVoidIns) || (lastDef instanceof ReturnValueIns))) {
|
||||
addRet = true;
|
||||
}
|
||||
} else {
|
||||
addRet = true;
|
||||
}
|
||||
}*/
|
||||
if (addRet) {
|
||||
if (retType.toString().equals("*") || retType.toString().equals("void") || constructor) {
|
||||
mbodyCode.add(new AVM2Instruction(0, AVM2Instructions.ReturnVoid, null));
|
||||
@@ -2172,7 +2176,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
|
||||
public int superIntName(SourceGeneratorLocalData localData, GraphTargetItem un) throws CompilationException {
|
||||
if (un instanceof UnresolvedAVM2Item) {
|
||||
((UnresolvedAVM2Item) un).resolve(localData.currentClass, null, new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), new ArrayList<>());
|
||||
((UnresolvedAVM2Item) un).resolve(localData, localData.currentClass, null, new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), new ArrayList<>());
|
||||
un = ((UnresolvedAVM2Item) un).resolved;
|
||||
}
|
||||
if (!(un instanceof TypeItem)) { //not applyType
|
||||
@@ -2606,31 +2610,34 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
return TypeItem.UNBOUNDED;
|
||||
}
|
||||
|
||||
public static boolean searchPrototypeChain(List<Integer> otherNs, int privateNs, int protectedNs, boolean instanceOnly, AbcIndexing abc, DottedChain pkg, String obj, String propertyName, Reference<String> outName, Reference<DottedChain> outNs, Reference<DottedChain> outPropNs, Reference<Integer> outPropNsKind, Reference<Integer> outPropNsIndex, Reference<GraphTargetItem> outPropType, Reference<ValueKind> outPropValue, Reference<ABC> outPropValueAbc) {
|
||||
public static boolean searchPrototypeChain(List<Integer> otherNs, int privateNs, int protectedNs, boolean instanceOnly, AbcIndexing abc, DottedChain pkg, String obj, String propertyName, Reference<String> outName, Reference<DottedChain> outNs, Reference<DottedChain> outPropNs, Reference<Integer> outPropNsKind, Reference<Integer> outPropNsIndex, Reference<GraphTargetItem> outPropType, Reference<ValueKind> outPropValue, Reference<ABC> outPropValueAbc, Reference<Boolean> isType) {
|
||||
// private and protected namespaces first so we find overriding functions before overridden functions
|
||||
if (searchPrototypeChain(privateNs, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc)) {
|
||||
if (searchPrototypeChain(privateNs, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType)) {
|
||||
return true;
|
||||
}
|
||||
if (searchPrototypeChain(protectedNs, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc)) {
|
||||
if (searchPrototypeChain(protectedNs, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int ns : otherNs) {
|
||||
if (searchPrototypeChain(ns, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc)) {
|
||||
if (searchPrototypeChain(ns, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return searchPrototypeChain(0, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc);
|
||||
return searchPrototypeChain(0, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType);
|
||||
}
|
||||
|
||||
private static boolean searchPrototypeChain(int selectedNs, boolean instanceOnly, AbcIndexing abc, DottedChain pkg, String obj, String propertyName, Reference<String> outName, Reference<DottedChain> outNs, Reference<DottedChain> outPropNs, Reference<Integer> outPropNsKind, Reference<Integer> outPropNsIndex, Reference<GraphTargetItem> outPropType, Reference<ValueKind> outPropValue, Reference<ABC> outPropValueAbc) {
|
||||
|
||||
private static boolean searchPrototypeChain(int selectedNs, boolean instanceOnly, AbcIndexing abc, DottedChain pkg, String obj, String propertyName, Reference<String> outName, Reference<DottedChain> outNs, Reference<DottedChain> outPropNs, Reference<Integer> outPropNsKind, Reference<Integer> outPropNsIndex, Reference<GraphTargetItem> outPropType, Reference<ValueKind> outPropValue, Reference<ABC> outPropValueAbc, Reference<Boolean> isType) {
|
||||
isType.setVal(false);
|
||||
AbcIndexing.TraitIndex sp = abc.findScriptProperty(pkg.addWithSuffix(propertyName));
|
||||
if (sp == null) {
|
||||
sp = abc.findProperty(new AbcIndexing.PropertyDef(propertyName, new TypeItem(pkg.addWithSuffix(obj)), abc.getSelectedAbc(), selectedNs), !instanceOnly, true);
|
||||
}
|
||||
if (sp != null) {
|
||||
if (sp.trait instanceof TraitClass) {
|
||||
isType.setVal(true);
|
||||
}
|
||||
if (sp.objType instanceof TypeItem) {
|
||||
outName.setVal(((TypeItem) sp.objType).fullTypeName.getLast());
|
||||
outNs.setVal(((TypeItem) sp.objType).fullTypeName.getWithoutLast());
|
||||
@@ -2712,7 +2719,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
|
||||
if (item instanceof UnresolvedAVM2Item) {
|
||||
String fullClass = localData.getFullClass();
|
||||
item = ((UnresolvedAVM2Item) item).resolve(localData.currentClass, new TypeItem(fullClass), new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), new ArrayList<>());
|
||||
item = ((UnresolvedAVM2Item) item).resolve(localData, localData.currentClass, new TypeItem(fullClass), new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), new ArrayList<>());
|
||||
}
|
||||
if (item instanceof TypeItem) {
|
||||
typeItem = item;
|
||||
@@ -2725,7 +2732,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
if (typeItem instanceof UnresolvedAVM2Item) {
|
||||
String fullClass = localData.getFullClass();
|
||||
typeItem = ((UnresolvedAVM2Item) typeItem).resolve(localData.currentClass, new TypeItem(fullClass), new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), new ArrayList<>());
|
||||
typeItem = ((UnresolvedAVM2Item) typeItem).resolve(localData, localData.currentClass, new TypeItem(fullClass), new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), new ArrayList<>());
|
||||
}
|
||||
|
||||
if (!(typeItem instanceof TypeItem)) {
|
||||
|
||||
@@ -58,6 +58,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.clauses.TryAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.AsTypeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.BitAndAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.BitNotAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.BitOrAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.BitXorAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.DeletePropertyAVM2Item;
|
||||
@@ -155,7 +156,7 @@ public class ActionScript3Parser {
|
||||
return uniqLast;
|
||||
}
|
||||
|
||||
private List<GraphTargetItem> commands(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, Stack<Loop> loops, Map<Loop, String> loopLabels, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, int forinlevel, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
|
||||
private List<GraphTargetItem> commands(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, Stack<Loop> loops, Map<Loop, String> loopLabels, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, int forinlevel, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, InterruptedException {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
if (debugMode) {
|
||||
System.out.println("commands:");
|
||||
@@ -170,7 +171,7 @@ public class ActionScript3Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private GraphTargetItem type(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
|
||||
private GraphTargetItem type(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, InterruptedException {
|
||||
ParsedSymbol s = lex();
|
||||
if (s.type == SymbolType.MULTIPLY) {
|
||||
return new UnboundedTypeItem();
|
||||
@@ -185,7 +186,7 @@ public class ActionScript3Parser {
|
||||
return t;
|
||||
}
|
||||
|
||||
private GraphTargetItem memberOrCall(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, GraphTargetItem newcmds, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
|
||||
private GraphTargetItem memberOrCall(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, GraphTargetItem newcmds, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, InterruptedException {
|
||||
if (debugMode) {
|
||||
System.out.println("memberOrCall:");
|
||||
}
|
||||
@@ -239,7 +240,7 @@ public class ActionScript3Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private GraphTargetItem applyType(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, GraphTargetItem obj, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
|
||||
private GraphTargetItem applyType(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, GraphTargetItem obj, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, InterruptedException {
|
||||
GraphTargetItem ret = obj;
|
||||
ParsedSymbol s = lex();
|
||||
if (s.type == SymbolType.TYPENAME) {
|
||||
@@ -271,7 +272,7 @@ public class ActionScript3Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private GraphTargetItem member(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, GraphTargetItem obj, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
|
||||
private GraphTargetItem member(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, GraphTargetItem obj, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, InterruptedException {
|
||||
if (debugMode) {
|
||||
System.out.println("member:");
|
||||
}
|
||||
@@ -338,7 +339,7 @@ public class ActionScript3Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private GraphTargetItem name(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, boolean typeOnly, List<NamespaceItem> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables, List<DottedChain> importedClasses) throws IOException, AVM2ParseException {
|
||||
private GraphTargetItem name(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, boolean typeOnly, List<NamespaceItem> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables, List<DottedChain> importedClasses) throws IOException, AVM2ParseException, InterruptedException {
|
||||
ParsedSymbol s = lex();
|
||||
DottedChain name = new DottedChain(new String[]{}, "");
|
||||
String name2 = "";
|
||||
@@ -446,13 +447,16 @@ public class ActionScript3Parser {
|
||||
}
|
||||
}
|
||||
|
||||
private ParsedSymbol expectedType(Object... type) throws IOException, AVM2ParseException {
|
||||
private ParsedSymbol expectedType(Object... type) throws IOException, AVM2ParseException, InterruptedException {
|
||||
ParsedSymbol symb = lex();
|
||||
expected(symb, lexer.yyline(), type);
|
||||
return symb;
|
||||
}
|
||||
|
||||
private ParsedSymbol lex() throws IOException, AVM2ParseException {
|
||||
private ParsedSymbol lex() throws IOException, AVM2ParseException, InterruptedException {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
ParsedSymbol ret = lexer.lex();
|
||||
if (debugMode) {
|
||||
System.out.println(ret);
|
||||
@@ -460,7 +464,7 @@ public class ActionScript3Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private List<GraphTargetItem> call(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
|
||||
private List<GraphTargetItem> call(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, InterruptedException {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
//expected(SymbolType.PARENT_OPEN); //MUST BE HANDLED BY CALLER
|
||||
ParsedSymbol s = lex();
|
||||
@@ -475,12 +479,12 @@ public class ActionScript3Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private MethodAVM2Item method(List<List<NamespaceItem>> allOpenedNamespaces, boolean outsidePackage, boolean isPrivate, List<Map.Entry<String, Map<String, String>>> metadata, NamespaceItem pkg, boolean isInterface, String customAccess, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, boolean override, boolean isFinal, TypeItem thisType, List<NamespaceItem> openedNamespaces, boolean isStatic, String functionName, boolean isMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
|
||||
private MethodAVM2Item method(List<List<NamespaceItem>> allOpenedNamespaces, boolean outsidePackage, boolean isPrivate, List<Map.Entry<String, Map<String, String>>> metadata, NamespaceItem pkg, boolean isInterface, String customAccess, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, boolean override, boolean isFinal, TypeItem thisType, List<NamespaceItem> openedNamespaces, boolean isStatic, String functionName, boolean isMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, InterruptedException {
|
||||
FunctionAVM2Item f = function(allOpenedNamespaces, metadata, pkg, isInterface, needsActivation, importedClasses, thisType, openedNamespaces, functionName, isMethod, variables);
|
||||
return new MethodAVM2Item(allOpenedNamespaces, outsidePackage, isPrivate, f.metadata, f.pkg, f.isInterface, customAccess, f.needsActivation, f.hasRest, f.line, override, isFinal, isStatic, functionName, f.paramTypes, f.paramNames, f.paramValues, f.body, f.subvariables, f.retType);
|
||||
}
|
||||
|
||||
private FunctionAVM2Item function(List<List<NamespaceItem>> allOpenedNamespaces, List<Map.Entry<String, Map<String, String>>> metadata, NamespaceItem pkg, boolean isInterface, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, TypeItem thisType, List<NamespaceItem> openedNamespaces, String functionName, boolean isMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
|
||||
private FunctionAVM2Item function(List<List<NamespaceItem>> allOpenedNamespaces, List<Map.Entry<String, Map<String, String>>> metadata, NamespaceItem pkg, boolean isInterface, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, TypeItem thisType, List<NamespaceItem> openedNamespaces, String functionName, boolean isMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, InterruptedException {
|
||||
|
||||
openedNamespaces = new ArrayList<>(openedNamespaces); //local copy
|
||||
allOpenedNamespaces.add(openedNamespaces);
|
||||
@@ -561,7 +565,7 @@ public class ActionScript3Parser {
|
||||
return new FunctionAVM2Item(metadata, pkg, isInterface, needsActivation2.getVal(), hasRest, line, functionName, paramTypes, paramNames, paramValues, body, subvariables, retType);
|
||||
}
|
||||
|
||||
private List<Map.Entry<String, Map<String, String>>> parseMetadata() throws IOException, AVM2ParseException {
|
||||
private List<Map.Entry<String, Map<String, String>>> parseMetadata() throws IOException, AVM2ParseException, InterruptedException {
|
||||
List<Map.Entry<String, Map<String, String>>> metadata = new ArrayList<>();
|
||||
ParsedSymbol s = lex();
|
||||
while (s.isType(SymbolType.BRACKET_OPEN)) {
|
||||
@@ -600,12 +604,12 @@ public class ActionScript3Parser {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
private void classTraits(List<List<NamespaceItem>> allOpenedNamespaces, boolean outsidePackage, List<AssignableAVM2Item> cinitVariables, Reference<Boolean> cinitNeedsActivation, List<GraphTargetItem> cinit, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, NamespaceItem pkg, String classNameStr, boolean isInterface, List<GraphTargetItem> traits, List<AssignableAVM2Item> iinitVariables, Reference<Boolean> iinitNeedsActivation, Reference<GraphTargetItem> iinit) throws AVM2ParseException, IOException, CompilationException {
|
||||
private void classTraits(List<List<NamespaceItem>> allOpenedNamespaces, boolean outsidePackage, List<AssignableAVM2Item> cinitVariables, Reference<Boolean> cinitNeedsActivation, List<GraphTargetItem> cinit, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, NamespaceItem pkg, String classNameStr, boolean isInterface, List<GraphTargetItem> traits, List<AssignableAVM2Item> iinitVariables, Reference<Boolean> iinitNeedsActivation, Reference<GraphTargetItem> iinit) throws AVM2ParseException, IOException, CompilationException, InterruptedException {
|
||||
|
||||
NamespaceItem publicNs = new NamespaceItem("", Namespace.KIND_PACKAGE);
|
||||
NamespaceItem privateNs = new NamespaceItem(pkg.name.toRawString() + ":" + classNameStr, Namespace.KIND_PRIVATE);
|
||||
NamespaceItem protectedNs = new NamespaceItem(pkg.name.toRawString() + ":" + classNameStr, Namespace.KIND_PROTECTED);
|
||||
NamespaceItem staticProtectedNs = new NamespaceItem(pkg.name.toRawString() + ":" + classNameStr, Namespace.KIND_STATIC_PROTECTED);
|
||||
NamespaceItem privateNs = new NamespaceItem(pkg.name.toRawString().isEmpty() ? classNameStr : pkg.name.toRawString() + ":" + classNameStr, Namespace.KIND_PRIVATE);
|
||||
NamespaceItem protectedNs = new NamespaceItem(pkg.name.toRawString().isEmpty() ? classNameStr : pkg.name.toRawString() + ":" + classNameStr, Namespace.KIND_PROTECTED);
|
||||
NamespaceItem staticProtectedNs = new NamespaceItem(pkg.name.toRawString().isEmpty() ? classNameStr : pkg.name.toRawString() + ":" + classNameStr, Namespace.KIND_STATIC_PROTECTED);
|
||||
NamespaceItem packageInternalNs = new NamespaceItem(pkg.name, Namespace.KIND_PACKAGE_INTERNAL);
|
||||
|
||||
openedNamespaces = new ArrayList<>(openedNamespaces);
|
||||
@@ -868,14 +872,14 @@ public class ActionScript3Parser {
|
||||
}
|
||||
}
|
||||
|
||||
private void scriptTraits(List<List<NamespaceItem>> allOpenedNamespaces, int scriptIndex, String scriptName, List<GraphTargetItem> traits) throws AVM2ParseException, IOException, CompilationException {
|
||||
private void scriptTraits(List<List<NamespaceItem>> allOpenedNamespaces, int scriptIndex, String scriptName, List<GraphTargetItem> traits) throws AVM2ParseException, IOException, CompilationException, InterruptedException {
|
||||
|
||||
while (scriptTraitsBlock(allOpenedNamespaces, scriptIndex, scriptName, traits)) {
|
||||
//empty
|
||||
}
|
||||
}
|
||||
|
||||
private boolean scriptTraitsBlock(List<List<NamespaceItem>> allOpenedNamespaces, int scriptIndex, String scriptName, List<GraphTargetItem> traits) throws AVM2ParseException, IOException, CompilationException {
|
||||
private boolean scriptTraitsBlock(List<List<NamespaceItem>> allOpenedNamespaces, int scriptIndex, String scriptName, List<GraphTargetItem> traits) throws AVM2ParseException, IOException, CompilationException, InterruptedException {
|
||||
ParsedSymbol s;
|
||||
boolean inPackage = false;
|
||||
s = lex();
|
||||
@@ -1010,7 +1014,8 @@ public class ActionScript3Parser {
|
||||
List<String> names = new ArrayList<>();
|
||||
List<String> namespaces = new ArrayList<>();
|
||||
//FIXME for Private classes in script (?)
|
||||
AVM2SourceGenerator.parentNamesAddNames(abcIndex, AVM2SourceGenerator.resolveType(new SourceGeneratorLocalData(new HashMap<>(), 0, false, 0), ((TypeItem) ((UnresolvedAVM2Item) extendsTypeStr).resolve(pkgName.addWithSuffix(subNameStr).toRawString(), null, new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), new ArrayList<>())), abcIndex), indices, names, namespaces);
|
||||
AVM2SourceGenerator.parentNamesAddNames(abcIndex, AVM2SourceGenerator.resolveType(new SourceGeneratorLocalData(new HashMap<>(), 0, false, 0), ((TypeItem) ((UnresolvedAVM2Item) extendsTypeStr)
|
||||
.resolve(null, pkgName.addWithSuffix(subNameStr).toRawString(), null, new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), new ArrayList<>())), abcIndex), indices, names, namespaces);
|
||||
for (int i = 0; i < names.size(); i++) {
|
||||
if (namespaces.get(i) == null || namespaces.get(i).isEmpty()) {
|
||||
continue;
|
||||
@@ -1218,7 +1223,7 @@ public class ActionScript3Parser {
|
||||
}
|
||||
}
|
||||
|
||||
private List<GraphTargetItem> xmltag(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> usesVars, List<String> openedTags, Reference<Integer> closedVarTags, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
|
||||
private List<GraphTargetItem> xmltag(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> usesVars, List<String> openedTags, Reference<Integer> closedVarTags, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, InterruptedException {
|
||||
ParsedSymbol s;
|
||||
List<GraphTargetItem> rets = new ArrayList<>();
|
||||
//GraphTargetItem ret = null;
|
||||
@@ -1347,7 +1352,7 @@ public class ActionScript3Parser {
|
||||
return rets;
|
||||
}
|
||||
|
||||
private GraphTargetItem xml(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
|
||||
private GraphTargetItem xml(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, InterruptedException {
|
||||
List<String> openedTags = new ArrayList<>();
|
||||
int closedVarTags = 0;
|
||||
|
||||
@@ -1358,7 +1363,7 @@ public class ActionScript3Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private GraphTargetItem command(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, Stack<Loop> loops, Map<Loop, String> loopLabels, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, int forinlevel, boolean mustBeCommand, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
|
||||
private GraphTargetItem command(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, Stack<Loop> loops, Map<Loop, String> loopLabels, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, int forinlevel, boolean mustBeCommand, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, InterruptedException {
|
||||
LexBufferer buf = new LexBufferer();
|
||||
lexer.addListener(buf);
|
||||
GraphTargetItem ret = null;
|
||||
@@ -1749,7 +1754,7 @@ public class ActionScript3Parser {
|
||||
UnresolvedAVM2Item ui = (UnresolvedAVM2Item) a;
|
||||
if (ui.getVariableName().equals(DottedChain.parseWithSuffix(e.getVariableName()))) {
|
||||
try {
|
||||
ui.resolve(null, null, new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), variables);
|
||||
ui.resolve(null, null, null, new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), variables);
|
||||
} catch (CompilationException ex) {
|
||||
// ignore
|
||||
}
|
||||
@@ -1772,7 +1777,7 @@ public class ActionScript3Parser {
|
||||
for (NameAVM2Item e : catchExceptions) {
|
||||
if (ui.getVariableName().equals(DottedChain.parseWithSuffix(e.getVariableName()))) {
|
||||
try {
|
||||
ui.resolve(null, null, new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), variables);
|
||||
ui.resolve(null, null, null, new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), variables);
|
||||
} catch (CompilationException ex) {
|
||||
// ignore
|
||||
}
|
||||
@@ -1835,7 +1840,7 @@ public class ActionScript3Parser {
|
||||
|
||||
}
|
||||
|
||||
private GraphTargetItem expression(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables, boolean allowComma) throws IOException, AVM2ParseException {
|
||||
private GraphTargetItem expression(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables, boolean allowComma) throws IOException, AVM2ParseException, InterruptedException {
|
||||
return expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, allowRemainder, variables, allowComma);
|
||||
}
|
||||
|
||||
@@ -1869,7 +1874,7 @@ public class ActionScript3Parser {
|
||||
return (item instanceof NameAVM2Item);
|
||||
}
|
||||
|
||||
private int brackets(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, List<GraphTargetItem> ret, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
|
||||
private int brackets(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, List<GraphTargetItem> ret, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, InterruptedException {
|
||||
ParsedSymbol s = lex();
|
||||
int arrCnt = 0;
|
||||
if (s.type == SymbolType.BRACKET_OPEN) {
|
||||
@@ -1893,7 +1898,7 @@ public class ActionScript3Parser {
|
||||
return arrCnt;
|
||||
}
|
||||
|
||||
private GraphTargetItem expression(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, boolean allowEmpty, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables, boolean allowComma) throws IOException, AVM2ParseException {
|
||||
private GraphTargetItem expression(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, boolean allowEmpty, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables, boolean allowComma) throws IOException, AVM2ParseException, InterruptedException {
|
||||
|
||||
List<GraphTargetItem> commaItems = new ArrayList<>();
|
||||
ParsedSymbol symb;
|
||||
@@ -1953,7 +1958,7 @@ public class ActionScript3Parser {
|
||||
}
|
||||
}
|
||||
|
||||
private ParsedSymbol peekExprToken() throws IOException, AVM2ParseException {
|
||||
private ParsedSymbol peekExprToken() throws IOException, AVM2ParseException, InterruptedException {
|
||||
ParsedSymbol lookahead = lex();
|
||||
xmlToLowerThanFix(lookahead);
|
||||
regexpToDivideFix(lookahead);
|
||||
@@ -1962,7 +1967,7 @@ public class ActionScript3Parser {
|
||||
return lookahead;
|
||||
}
|
||||
|
||||
private GraphTargetItem expression1(List<List<NamespaceItem>> allOpenedNamespaces, GraphTargetItem lhs, int min_precedence, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, boolean allowEmpty, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
|
||||
private GraphTargetItem expression1(List<List<NamespaceItem>> allOpenedNamespaces, GraphTargetItem lhs, int min_precedence, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, boolean allowEmpty, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, InterruptedException {
|
||||
if (debugMode) {
|
||||
System.out.println("expression1:");
|
||||
}
|
||||
@@ -2175,7 +2180,7 @@ public class ActionScript3Parser {
|
||||
return lhs;
|
||||
}
|
||||
|
||||
private GraphTargetItem expressionPrimary(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, boolean allowEmpty, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException {
|
||||
private GraphTargetItem expressionPrimary(List<List<NamespaceItem>> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference<Boolean> needsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, boolean allowEmpty, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, InterruptedException {
|
||||
if (debugMode) {
|
||||
System.out.println("primary:");
|
||||
}
|
||||
@@ -2252,7 +2257,7 @@ public class ActionScript3Parser {
|
||||
break;
|
||||
case NEGATE:
|
||||
ret = expressionPrimary(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, false, variables);
|
||||
ret = new NegAVM2Item(null, null, ret);
|
||||
ret = new BitNotAVM2Item(null, null, ret);
|
||||
|
||||
break;
|
||||
case MINUS:
|
||||
@@ -2470,7 +2475,7 @@ public class ActionScript3Parser {
|
||||
|
||||
private List<String> constantPool;
|
||||
|
||||
private List<DottedChain> parseImportsUsages(List<NamespaceItem> openedNamespaces) throws IOException, AVM2ParseException {
|
||||
private List<DottedChain> parseImportsUsages(List<NamespaceItem> openedNamespaces) throws IOException, AVM2ParseException, InterruptedException {
|
||||
|
||||
ParsedSymbol s;
|
||||
List<DottedChain> importedClasses = new ArrayList<>();
|
||||
@@ -2517,7 +2522,7 @@ public class ActionScript3Parser {
|
||||
return importedClasses;
|
||||
}
|
||||
|
||||
private List<GraphTargetItem> parseScript(List<List<NamespaceItem>> allOpenedNamespaces, int scriptIndex, String fileName) throws IOException, AVM2ParseException, CompilationException {
|
||||
private List<GraphTargetItem> parseScript(List<List<NamespaceItem>> allOpenedNamespaces, int scriptIndex, String fileName) throws IOException, AVM2ParseException, CompilationException, InterruptedException {
|
||||
|
||||
//int scriptPrivateNs;
|
||||
if (fileName.contains("/")) {
|
||||
@@ -2531,7 +2536,7 @@ public class ActionScript3Parser {
|
||||
return items;
|
||||
}
|
||||
|
||||
public List<GraphTargetItem> scriptTraitsFromString(List<List<NamespaceItem>> allOpenedNamespaces, String str, String fileName, int scriptIndex) throws AVM2ParseException, IOException, CompilationException {
|
||||
public List<GraphTargetItem> scriptTraitsFromString(List<List<NamespaceItem>> allOpenedNamespaces, String str, String fileName, int scriptIndex) throws AVM2ParseException, IOException, CompilationException, InterruptedException {
|
||||
lexer = new ActionScriptLexer(str);
|
||||
|
||||
List<GraphTargetItem> ret = parseScript(allOpenedNamespaces, scriptIndex, fileName);
|
||||
@@ -2548,7 +2553,7 @@ public class ActionScript3Parser {
|
||||
abcIndex.getSelectedAbc().script_info.add(gen.generateScriptInfo(allOpenedNamespaces, localData, items, classPos));
|
||||
}
|
||||
|
||||
public void addScript(String s, String fileName, int classPos, int scriptIndex) throws AVM2ParseException, IOException, CompilationException {
|
||||
public void addScript(String s, String fileName, int classPos, int scriptIndex) throws AVM2ParseException, IOException, CompilationException, InterruptedException {
|
||||
List<List<NamespaceItem>> allOpenedNamespaces = new ArrayList<>();
|
||||
List<GraphTargetItem> traits = scriptTraitsFromString(allOpenedNamespaces, s, fileName, scriptIndex);
|
||||
addScriptFromTree(allOpenedNamespaces, traits, classPos);
|
||||
|
||||
@@ -78,34 +78,34 @@ public class CallAVM2Item extends AVM2Item {
|
||||
}
|
||||
if (callable instanceof NameAVM2Item) {
|
||||
NameAVM2Item n = (NameAVM2Item) callable;
|
||||
/*List<ABC> allAbcs = new ArrayList<>();
|
||||
allAbcs.add(g.abc);
|
||||
allAbcs.addAll(g.allABCs);*/
|
||||
String cname = localData.currentClass;
|
||||
DottedChain pkgName = localData.pkg;
|
||||
GraphTargetItem obj = null;
|
||||
Reference<String> outName = new Reference<>("");
|
||||
Reference<DottedChain> outNs = new Reference<>(DottedChain.EMPTY);
|
||||
Reference<DottedChain> outPropNs = new Reference<>(DottedChain.EMPTY);
|
||||
Reference<Integer> outPropNsKind = new Reference<>(1);
|
||||
Reference<Integer> outPropNsIndex = new Reference<>(0);
|
||||
Reference<GraphTargetItem> outPropType = new Reference<>(null);
|
||||
Reference<ValueKind> outPropValue = new Reference<>(null);
|
||||
Reference<ABC> outPropValueABC = new Reference<>(null);
|
||||
List<Integer> otherNs = new ArrayList<>();
|
||||
for (NamespaceItem on : openedNamespaces) {
|
||||
if (on.isResolved()) {
|
||||
otherNs.add(on.getCpoolIndex(g.abcIndex));
|
||||
if (!localData.registerVars.containsKey(n.getVariableName())) {
|
||||
String cname = localData.currentClass;
|
||||
DottedChain pkgName = localData.pkg;
|
||||
GraphTargetItem obj = null;
|
||||
Reference<String> outName = new Reference<>("");
|
||||
Reference<DottedChain> outNs = new Reference<>(DottedChain.EMPTY);
|
||||
Reference<DottedChain> outPropNs = new Reference<>(DottedChain.EMPTY);
|
||||
Reference<Integer> outPropNsKind = new Reference<>(1);
|
||||
Reference<Integer> outPropNsIndex = new Reference<>(0);
|
||||
Reference<GraphTargetItem> outPropType = new Reference<>(null);
|
||||
Reference<ValueKind> outPropValue = new Reference<>(null);
|
||||
Reference<ABC> outPropValueABC = new Reference<>(null);
|
||||
List<Integer> otherNs = new ArrayList<>();
|
||||
Reference<Boolean> isType = new Reference<>(false);
|
||||
for (NamespaceItem on : openedNamespaces) {
|
||||
if (on.isResolved()) {
|
||||
otherNs.add(on.getCpoolIndex(g.abcIndex));
|
||||
}
|
||||
}
|
||||
if (cname != null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, true, g.abcIndex, pkgName, cname, n.getVariableName(), outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueABC, isType)) {
|
||||
NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), n.line, "this", null, false, n.openedNamespaces, abcIndex);
|
||||
nobj.setRegNumber(0);
|
||||
obj = nobj;
|
||||
}
|
||||
PropertyAVM2Item p = new PropertyAVM2Item(obj, n.getVariableName(), g.abcIndex, n.openedNamespaces, new ArrayList<>());
|
||||
p.setAssignedValue(n.getAssignedValue());
|
||||
callable = p;
|
||||
}
|
||||
if (cname != null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, true, g.abcIndex, pkgName, cname, n.getVariableName(), outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueABC)) {
|
||||
NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), n.line, "this", null, false, n.openedNamespaces, abcIndex);
|
||||
nobj.setRegNumber(0);
|
||||
obj = nobj;
|
||||
}
|
||||
PropertyAVM2Item p = new PropertyAVM2Item(obj, n.getVariableName(), g.abcIndex, n.openedNamespaces, new ArrayList<>());
|
||||
p.setAssignedValue(n.getAssignedValue());
|
||||
callable = p;
|
||||
}
|
||||
|
||||
int propIndex = -1;
|
||||
@@ -133,6 +133,7 @@ public class CallAVM2Item extends AVM2Item {
|
||||
Reference<GraphTargetItem> outPropType = new Reference<>(null);
|
||||
Reference<ValueKind> outPropValue = new Reference<>(null);
|
||||
Reference<ABC> outPropValueAbc = new Reference<>(null);
|
||||
Reference<Boolean> isType = new Reference<>(false);
|
||||
|
||||
List<Integer> otherNs = new ArrayList<>();
|
||||
for (NamespaceItem n : openedNamespaces) {
|
||||
@@ -141,7 +142,7 @@ public class CallAVM2Item extends AVM2Item {
|
||||
}
|
||||
}
|
||||
|
||||
if (cname != null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, true, g.abcIndex, pkgName, cname, prop.propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) {
|
||||
if (cname != null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, true, g.abcIndex, pkgName, cname, prop.propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) {
|
||||
NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), 0, "this", null, false, new ArrayList<>(), abcIndex);
|
||||
nobj.setRegNumber(0);
|
||||
obj = nobj;
|
||||
|
||||
@@ -154,13 +154,16 @@ public class IndexAVM2Item extends AssignableAVM2Item {
|
||||
} else {
|
||||
return toSourceMerge(localData, generator,
|
||||
object,
|
||||
call ? ins(AVM2Instructions.Dup) : null,
|
||||
call ? dupSetTemp(localData, generator, ret_temp) : null,
|
||||
index,
|
||||
construct ? getTemp(localData, generator, ret_temp) : null,
|
||||
construct ? callargs : null,
|
||||
ins(construct ? AVM2Instructions.ConstructProp : delete ? AVM2Instructions.DeleteProperty : AVM2Instructions.GetProperty, indexPropIndex, construct ? callargs.size() : null),
|
||||
call ? getTemp(localData, generator, ret_temp) : null,
|
||||
call ? callargs : null,
|
||||
call ? ins(AVM2Instructions.Call, callargs.size()) : null,
|
||||
needsReturn ? null : ins(AVM2Instructions.Pop));
|
||||
needsReturn ? null : ins(AVM2Instructions.Pop),
|
||||
(call || construct) ? killTemp(localData, generator, Arrays.asList(ret_temp)) : null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -89,8 +89,9 @@ public class NamespaceItem {
|
||||
PropertyAVM2Item prop = new PropertyAVM2Item(null, custom, abcIndex, openedNamespaces, new ArrayList<>());
|
||||
Reference<ValueKind> value = new Reference<>(null);
|
||||
Reference<ABC> outAbc = new Reference<>(null);
|
||||
Reference<Boolean> isType = new Reference<>(false);
|
||||
|
||||
prop.resolve(true, localData, new Reference<>(null), new Reference<>(null), new Reference<>(0), value, outAbc);
|
||||
prop.resolve(true, localData, isType, new Reference<>(null), new Reference<>(null), new Reference<>(0), value, outAbc);
|
||||
boolean resolved = true;
|
||||
if (value.getVal() == null) {
|
||||
resolved = false;
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
import com.jpexs.decompiler.flash.abc.types.ScriptInfo;
|
||||
import com.jpexs.decompiler.flash.abc.types.ValueKind;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitClass;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
@@ -132,7 +133,8 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
return multinameToType(new HashSet<>(), m_index, constants);
|
||||
}
|
||||
|
||||
public void resolve(boolean mustExist, SourceGeneratorLocalData localData, Reference<GraphTargetItem> objectType, Reference<GraphTargetItem> propertyType, Reference<Integer> propertyIndex, Reference<ValueKind> propertyValue, Reference<ABC> propertyValueABC) throws CompilationException {
|
||||
public void resolve(boolean mustExist, SourceGeneratorLocalData localData, Reference<Boolean> isType, Reference<GraphTargetItem> objectType, Reference<GraphTargetItem> propertyType, Reference<Integer> propertyIndex, Reference<ValueKind> propertyValue, Reference<ABC> propertyValueABC) throws CompilationException {
|
||||
isType.setVal(false);
|
||||
GraphTargetItem thisType = new TypeItem(localData.getFullClass());
|
||||
GraphTargetItem objType = null;
|
||||
GraphTargetItem objSubType = null;
|
||||
@@ -269,7 +271,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
propValueAbc = sp.abc;
|
||||
}
|
||||
}
|
||||
if (propType == null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, false, abcIndex, ftn.getWithoutLast(), ftn.getLast(), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc)) {
|
||||
if (propType == null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, false, abcIndex, ftn.getWithoutLast(), ftn.getLast(), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType)) {
|
||||
objType = new TypeItem(outNs.getVal().addWithSuffix(outName.getVal()));
|
||||
propType = outPropType.getVal();
|
||||
propIndex = constants.getMultinameId(Multiname.createQName(false,
|
||||
@@ -356,6 +358,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
}
|
||||
for (Trait t : si.traits.traits) {
|
||||
if (t.name_index == name_index) {
|
||||
isType.setVal(t instanceof TraitClass);
|
||||
objType = new TypeItem(DottedChain.OBJECT);
|
||||
propType = AVM2SourceGenerator.getTraitReturnType(abcIndex, t);
|
||||
propIndex = t.name_index;
|
||||
@@ -387,7 +390,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
otherns.add(n.getCpoolIndex(abcIndex));
|
||||
}
|
||||
}
|
||||
if (AVM2SourceGenerator.searchPrototypeChain(otherns, localData.privateNs, localData.protectedNs, false, abcIndex, nsname, (((TypeItem) p.objType).fullTypeName.getLast()), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc)) {
|
||||
if (AVM2SourceGenerator.searchPrototypeChain(otherns, localData.privateNs, localData.protectedNs, false, abcIndex, nsname, (((TypeItem) p.objType).fullTypeName.getLast()), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType)) {
|
||||
objType = new TypeItem(outNs.getVal().addWithSuffix(outName.getVal()));
|
||||
propType = p.returnType;
|
||||
propIndex = constants.getMultinameId(Multiname.createQName(false,
|
||||
@@ -446,7 +449,8 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
Reference<Integer> propIndex = new Reference<>(0);
|
||||
Reference<ValueKind> outPropValue = new Reference<>(null);
|
||||
Reference<ABC> outPropValueAbc = new Reference<>(null);
|
||||
resolve(false, localData, objType, propType, propIndex, outPropValue, outPropValueAbc);
|
||||
Reference<Boolean> isType = new Reference<>(false);
|
||||
resolve(false, localData, isType, objType, propType, propIndex, outPropValue, outPropValueAbc);
|
||||
return propIndex.getVal();
|
||||
}
|
||||
|
||||
@@ -458,8 +462,9 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
Reference<Integer> propIndex = new Reference<>(0);
|
||||
Reference<ValueKind> outPropValue = new Reference<>(null);
|
||||
Reference<ABC> outPropValueAbc = new Reference<>(null);
|
||||
Reference<Boolean> isType = new Reference<>(false);
|
||||
try {
|
||||
resolve(false, new SourceGeneratorLocalData(new HashMap<>(), 0, false, 0)/*???*/, objType, propType, propIndex, outPropValue, outPropValueAbc);
|
||||
resolve(false, new SourceGeneratorLocalData(new HashMap<>(), 0, false, 0)/*???*/, isType, objType, propType, propIndex, outPropValue, outPropValueAbc);
|
||||
|
||||
return propType.getVal();
|
||||
} catch (CompilationException ex) {
|
||||
@@ -475,8 +480,9 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
Reference<Integer> propIndex = new Reference<>(0);
|
||||
Reference<ValueKind> outPropValue = new Reference<>(null);
|
||||
Reference<ABC> outPropValueAbc = new Reference<>(null);
|
||||
Reference<Boolean> isType = new Reference<>(false);
|
||||
|
||||
resolve(false, localData, objType, propType, propIndex, outPropValue, outPropValueAbc);
|
||||
resolve(false, localData, isType, objType, propType, propIndex, outPropValue, outPropValueAbc);
|
||||
|
||||
int propertyId = propIndex.getVal();
|
||||
Object obj = resolveObject(localData, generator);
|
||||
@@ -539,6 +545,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
Reference<GraphTargetItem> outPropType = new Reference<>(null);
|
||||
Reference<ValueKind> outPropValue = new Reference<>(null);
|
||||
Reference<ABC> outPropValueAbc = new Reference<>(null);
|
||||
Reference<Boolean> isType = new Reference<>(false);
|
||||
|
||||
/*List<ABC> abcs = new ArrayList<>();
|
||||
abcs.add(abc);
|
||||
@@ -549,7 +556,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
otherNs.add(n.getCpoolIndex(abcIndex));
|
||||
}
|
||||
}
|
||||
if (!localData.subMethod && cname != null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, true, abcIndex, pkgName, cname, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) {
|
||||
if (!localData.subMethod && cname != null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, true, abcIndex, pkgName, cname, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) {
|
||||
NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), 0, "this", null, false, openedNamespaces, abcIndex);
|
||||
nobj.setRegNumber(0);
|
||||
obj = nobj;
|
||||
@@ -560,7 +567,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
Reference<ValueKind> propValue = new Reference<>(null);
|
||||
Reference<ABC> propValueAbc = new Reference<>(null);
|
||||
|
||||
resolve(false, localData, objType, propType, propIndex, outPropValue, propValueAbc);
|
||||
resolve(false, localData, isType, objType, propType, propIndex, outPropValue, propValueAbc);
|
||||
obj = ins(AVM2Instructions.FindPropertyStrict, propIndex.getVal());
|
||||
}
|
||||
}
|
||||
@@ -575,8 +582,9 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
Reference<Integer> propIndex = new Reference<>(0);
|
||||
Reference<ValueKind> outPropValue = new Reference<>(null);
|
||||
Reference<ABC> outPropValueAbc = new Reference<>(null);
|
||||
Reference<Boolean> isType = new Reference<>(false);
|
||||
|
||||
resolve(false, localData, objType, propType, propIndex, outPropValue, outPropValueAbc);
|
||||
resolve(false, localData, isType, objType, propType, propIndex, outPropValue, outPropValueAbc);
|
||||
|
||||
int propertyId = propIndex.getVal();
|
||||
Object obj = resolveObject(localData, generator);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item;
|
||||
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.UndefinedAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
import com.jpexs.decompiler.flash.abc.types.ValueKind;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
@@ -36,6 +38,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.helpers.Reference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -284,7 +287,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
throw new RuntimeException("Cannot assign");
|
||||
}
|
||||
|
||||
public GraphTargetItem resolve(String currentClass, GraphTargetItem thisType, List<GraphTargetItem> paramTypes, List<String> paramNames, AbcIndexing abc, List<MethodBody> callStack, List<AssignableAVM2Item> variables) throws CompilationException {
|
||||
public GraphTargetItem resolve(SourceGeneratorLocalData localData /*can be null!!!*/, String currentClass, GraphTargetItem thisType, List<GraphTargetItem> paramTypes, List<String> paramNames, AbcIndexing abc, List<MethodBody> callStack, List<AssignableAVM2Item> variables) throws CompilationException {
|
||||
if (scopeStack.isEmpty()) { //Everything is multiname property in with command
|
||||
|
||||
//search for variable
|
||||
@@ -313,7 +316,49 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
}
|
||||
}
|
||||
|
||||
if (currentClass != null) {
|
||||
if ((paramNames.contains(name.get(0)) || name.get(0).equals("arguments"))) {
|
||||
int ind = paramNames.indexOf(name.get(0));
|
||||
GraphTargetItem t = TypeItem.UNBOUNDED;
|
||||
if (ind == -1) {
|
||||
|
||||
} else if (ind < paramTypes.size()) {
|
||||
t = paramTypes.get(ind);
|
||||
} //else rest parameter
|
||||
|
||||
GraphTargetItem ret = new NameAVM2Item(t, line, name.get(0), null, false, openedNamespaces, abcIndex);
|
||||
resolved = ret;
|
||||
for (int i = 1; i < name.size(); i++) {
|
||||
resolved = new PropertyAVM2Item(resolved, name.get(i), abc, openedNamespaces, new ArrayList<>());
|
||||
if (i == name.size() - 1) {
|
||||
((PropertyAVM2Item) resolved).assignedValue = assignedValue;
|
||||
}
|
||||
}
|
||||
if (name.size() == 1) {
|
||||
((NameAVM2Item) ret).setAssignedValue(assignedValue);
|
||||
}
|
||||
return resolvedRoot = ret;
|
||||
}
|
||||
|
||||
boolean isProperty = false;
|
||||
if (localData != null) { //resolve can be called without localData
|
||||
PropertyAVM2Item resolvedx = new PropertyAVM2Item(null, name.get(0), abc, openedNamespaces, callStack);
|
||||
((PropertyAVM2Item) resolvedx).scopeStack = scopeStack;
|
||||
((PropertyAVM2Item) resolvedx).setAssignedValue(assignedValue);
|
||||
Reference<GraphTargetItem> objectType = new Reference<>(null);
|
||||
Reference<GraphTargetItem> propertyType = new Reference<>(null);
|
||||
Reference<Integer> propertyIndex = new Reference<>(null);
|
||||
Reference<ValueKind> propertyValue = new Reference<>(null);
|
||||
Reference<ABC> propertyValueABC = new Reference<>(null);
|
||||
Reference<Boolean> isType = new Reference<>(false);
|
||||
|
||||
resolvedx.resolve(true, localData, isType, objectType, propertyType, propertyIndex, propertyValue, propertyValueABC);
|
||||
|
||||
if (objectType.getVal() != null && !isType.getVal()) {
|
||||
isProperty = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentClass != null && !isProperty) {
|
||||
DottedChain classChain = DottedChain.parseWithSuffix(currentClass);
|
||||
DottedChain pkg = classChain.getWithoutLast();
|
||||
|
||||
@@ -334,87 +379,87 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
}
|
||||
|
||||
//Search for types in imported classes
|
||||
for (DottedChain imp : importedClasses) {
|
||||
String impName = imp.getLast();
|
||||
if (!isProperty) {
|
||||
for (DottedChain imp : importedClasses) {
|
||||
String impName = imp.getLast();
|
||||
|
||||
if (impName.equals(name.get(0))) {
|
||||
TypeItem ret = new TypeItem(imp);
|
||||
resolved = ret;
|
||||
for (int i = 1; i < name.size(); i++) {
|
||||
resolved = new PropertyAVM2Item(resolved, name.get(i), abc, openedNamespaces, new ArrayList<>());
|
||||
if (i == name.size() - 1) {
|
||||
((PropertyAVM2Item) resolved).assignedValue = assignedValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (name.size() == 1) {
|
||||
AbcIndexing.TraitIndex ti = abc.findScriptProperty(imp);
|
||||
if (ti != null && (ti.trait instanceof TraitSlotConst)) {
|
||||
resolved = new ImportedSlotConstItem(ret);
|
||||
if (assignedValue != null) {
|
||||
((ImportedSlotConstItem) resolved).assignedValue = assignedValue;
|
||||
if (impName.equals(name.get(0))) {
|
||||
TypeItem ret = new TypeItem(imp);
|
||||
resolved = ret;
|
||||
for (int i = 1; i < name.size(); i++) {
|
||||
resolved = new PropertyAVM2Item(resolved, name.get(i), abc, openedNamespaces, new ArrayList<>());
|
||||
if (i == name.size() - 1) {
|
||||
((PropertyAVM2Item) resolved).assignedValue = assignedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resolvedRoot = ret;
|
||||
if (name.size() == 1) {
|
||||
AbcIndexing.TraitIndex ti = abc.findScriptProperty(imp);
|
||||
if (ti != null && (ti.trait instanceof TraitSlotConst)) {
|
||||
resolved = new ImportedSlotConstItem(ret);
|
||||
if (assignedValue != null) {
|
||||
((ImportedSlotConstItem) resolved).assignedValue = assignedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resolvedRoot = ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Search all fully qualitfied types
|
||||
/*List<ABC> allAbcs = new ArrayList<>();
|
||||
allAbcs.add(abc);
|
||||
allAbcs.addAll(otherAbcs);*/
|
||||
for (int i = 0; i < name.size(); i++) {
|
||||
DottedChain fname = name.subChain(i + 1);
|
||||
AbcIndexing.ClassIndex ci = abc.findClass(new TypeItem(fname));
|
||||
if (ci != null) {
|
||||
if (!subtypes.isEmpty() && name.size() > i + 1) {
|
||||
continue;
|
||||
}
|
||||
TypeItem ret = new TypeItem(fname);
|
||||
resolved = ret;
|
||||
for (int j = i + 1; j < name.size(); j++) {
|
||||
resolved = new PropertyAVM2Item(resolved, name.get(j), abc, openedNamespaces, new ArrayList<>());
|
||||
if (j == name.size() - 1) {
|
||||
((PropertyAVM2Item) resolved).assignedValue = assignedValue;
|
||||
if (!isProperty) {
|
||||
for (int i = 0; i < name.size(); i++) {
|
||||
DottedChain fname = name.subChain(i + 1);
|
||||
AbcIndexing.ClassIndex ci = abc.findClass(new TypeItem(fname));
|
||||
if (ci != null) {
|
||||
if (!subtypes.isEmpty() && name.size() > i + 1) {
|
||||
continue;
|
||||
}
|
||||
TypeItem ret = new TypeItem(fname);
|
||||
resolved = ret;
|
||||
for (int j = i + 1; j < name.size(); j++) {
|
||||
resolved = new PropertyAVM2Item(resolved, name.get(j), abc, openedNamespaces, new ArrayList<>());
|
||||
if (j == name.size() - 1) {
|
||||
((PropertyAVM2Item) resolved).assignedValue = assignedValue;
|
||||
}
|
||||
}
|
||||
if (name.size() == i + 1 && assignedValue != null) {
|
||||
throw new CompilationException("Cannot assign type", line);
|
||||
}
|
||||
}
|
||||
if (name.size() == i + 1 && assignedValue != null) {
|
||||
throw new CompilationException("Cannot assign type", line);
|
||||
}
|
||||
|
||||
return resolvedRoot = ret;
|
||||
return resolvedRoot = ret;
|
||||
}
|
||||
}
|
||||
|
||||
//Search for types in opened namespaces
|
||||
for (NamespaceItem n : openedNamespaces) {
|
||||
Namespace ons = abc.getSelectedAbc().constants.getNamespace(n.getCpoolIndex(abc));
|
||||
TypeItem ti = new TypeItem(ons.getName(abc.getSelectedAbc().constants).addWithSuffix(name.get(0)));
|
||||
AbcIndexing.ClassIndex ci = abc.findClass(ti);
|
||||
if (ci != null) {
|
||||
if (!subtypes.isEmpty() && name.size() > 1) {
|
||||
continue;
|
||||
}
|
||||
TypeItem ret = ti;
|
||||
resolved = ret;
|
||||
for (int i = 1; i < name.size(); i++) {
|
||||
resolved = new PropertyAVM2Item(resolved, name.get(i), abc, openedNamespaces, new ArrayList<>());
|
||||
if (i == name.size() - 1) {
|
||||
((PropertyAVM2Item) resolved).assignedValue = assignedValue;
|
||||
}
|
||||
}
|
||||
if (name.size() == 1 && assignedValue != null) {
|
||||
throw new CompilationException("Cannot assign type", line);
|
||||
}
|
||||
|
||||
return resolvedRoot = ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Search for types in opened namespaces
|
||||
for (NamespaceItem n : openedNamespaces) {
|
||||
Namespace ons = abc.getSelectedAbc().constants.getNamespace(n.getCpoolIndex(abc));
|
||||
TypeItem ti = new TypeItem(ons.getName(abc.getSelectedAbc().constants).addWithSuffix(name.get(0)));
|
||||
AbcIndexing.ClassIndex ci = abc.findClass(ti);
|
||||
if (ci != null) {
|
||||
if (!subtypes.isEmpty() && name.size() > 1) {
|
||||
continue;
|
||||
}
|
||||
TypeItem ret = ti;
|
||||
resolved = ret;
|
||||
for (int i = 1; i < name.size(); i++) {
|
||||
resolved = new PropertyAVM2Item(resolved, name.get(i), abc, openedNamespaces, new ArrayList<>());
|
||||
if (i == name.size() - 1) {
|
||||
((PropertyAVM2Item) resolved).assignedValue = assignedValue;
|
||||
}
|
||||
}
|
||||
if (name.size() == 1 && assignedValue != null) {
|
||||
throw new CompilationException("Cannot assign type", line);
|
||||
}
|
||||
|
||||
return resolvedRoot = ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (name.get(
|
||||
0).equals("this") || name.get(0).equals("super")) {
|
||||
if (!isProperty && (name.get(0).equals("this") || name.get(0).equals("super"))) {
|
||||
if (thisType == null) {
|
||||
throw new CompilationException("Cannot use this in that context", line);
|
||||
}
|
||||
@@ -448,41 +493,9 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
return resolvedRoot = ret;
|
||||
}
|
||||
|
||||
if (paramNames.contains(name.get(0)) || name.get(0).equals("arguments")) {
|
||||
int ind = paramNames.indexOf(name.get(0));
|
||||
GraphTargetItem t = TypeItem.UNBOUNDED;
|
||||
if (ind == -1) {
|
||||
|
||||
} else if (ind < paramTypes.size()) {
|
||||
t = paramTypes.get(ind);
|
||||
} //else rest parameter
|
||||
|
||||
GraphTargetItem ret = new NameAVM2Item(t, line, name.get(0), null, false, openedNamespaces, abcIndex);
|
||||
resolved = ret;
|
||||
for (int i = 1; i < name.size(); i++) {
|
||||
resolved = new PropertyAVM2Item(resolved, name.get(i), abc, openedNamespaces, new ArrayList<>());
|
||||
if (i == name.size() - 1) {
|
||||
((PropertyAVM2Item) resolved).assignedValue = assignedValue;
|
||||
}
|
||||
}
|
||||
if (name.size() == 1) {
|
||||
((NameAVM2Item) ret).setAssignedValue(assignedValue);
|
||||
}
|
||||
return resolvedRoot = ret;
|
||||
}
|
||||
|
||||
if (/*!subtypes.isEmpty() && */name.size()
|
||||
== 1 && name.get(0).equals("Vector")) {
|
||||
if (!isProperty && (name.size() == 1 && name.get(0).equals("Vector"))) {
|
||||
TypeItem ret = new TypeItem(InitVectorAVM2Item.VECTOR_FQN);
|
||||
/*for (String s : subtypes) {
|
||||
UnresolvedAVM2Item su = new UnresolvedAVM2Item(new ArrayList<>(), importedClasses, true, null, line, s, null, openedNamespaces);
|
||||
su.resolve(thisType, paramTypes, paramNames, abc, otherAbcs, callStack, variables);
|
||||
if (!(su.resolved instanceof TypeItem)) {
|
||||
throw new CompilationException("Not a type", line);
|
||||
}
|
||||
TypeItem st = (TypeItem) su.resolved;
|
||||
ret.subtypes.add(st.fullTypeName);
|
||||
}*/
|
||||
resolved = ret;
|
||||
return resolvedRoot = ret;
|
||||
}
|
||||
@@ -492,9 +505,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
}
|
||||
resolved = null;
|
||||
GraphTargetItem ret = null;
|
||||
for (int i = 0;
|
||||
i < name.size();
|
||||
i++) {
|
||||
for (int i = 0; i < name.size(); i++) {
|
||||
resolved = new PropertyAVM2Item(resolved, name.get(i), abc, openedNamespaces, callStack);
|
||||
if (ret == null) {
|
||||
((PropertyAVM2Item) resolved).scopeStack = scopeStack;
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.usages;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
@@ -39,6 +40,14 @@ public class MethodNameMultinameUsage extends MethodMultinameUsage implements De
|
||||
TraitMultinameUsage otherTrait = (TraitMultinameUsage) other;
|
||||
if (otherTrait.classIndex == classIndex && otherTrait.traitsType == traitsType && otherTrait.parentTraitIndex == parentTraitIndex) {
|
||||
if (other.sameMultinameName(this)) {
|
||||
|
||||
if(other instanceof MethodNameMultinameUsage){
|
||||
MethodNameMultinameUsage otherM = (MethodNameMultinameUsage)other;
|
||||
//getter/setter/method must match
|
||||
if(otherM.traits.traits.get(otherM.traitIndex).kindType != traits.traits.get(traitIndex).kindType){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import static com.jpexs.decompiler.flash.action.Action.adr2ip;
|
||||
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.GetMemberActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.GetPropertyActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.GetVariableActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.SetTarget2ActionItem;
|
||||
@@ -492,8 +493,7 @@ public class ActionGraph extends Graph {
|
||||
caseValuesMap.add(set.rightSide);
|
||||
if (set.leftSide instanceof StoreRegisterActionItem) {
|
||||
switchedObject = ((StoreRegisterActionItem) set.leftSide).value;
|
||||
}
|
||||
if (set.leftSide instanceof GetVariableActionItem) {
|
||||
} else {
|
||||
switchedObject = set.leftSide;
|
||||
}
|
||||
|
||||
@@ -600,7 +600,8 @@ public class ActionGraph extends Graph {
|
||||
@Override
|
||||
public SecondPassData prepareSecondPass(List<GraphTargetItem> list) {
|
||||
ActionSecondPassData spd = new ActionSecondPassData();
|
||||
checkSecondPassSwitches(list, spd.switchParts, spd.switchOnFalseParts, spd.switchCaseExpressions);
|
||||
Set<GraphPart> processedIfs = new HashSet<>();
|
||||
checkSecondPassSwitches(processedIfs, list, spd.switchParts, spd.switchOnFalseParts, spd.switchCaseExpressions);
|
||||
|
||||
if (spd.switchParts.isEmpty()) {
|
||||
return null; //no need to second pass
|
||||
@@ -608,64 +609,75 @@ public class ActionGraph extends Graph {
|
||||
return spd;
|
||||
}
|
||||
|
||||
private void checkSecondPassSwitches(List<GraphTargetItem> list, List<List<GraphPart>> allSwitchParts, List<List<GraphPart>> allSwitchOnFalseParts, List<List<GraphTargetItem>> allSwitchExpressions) {
|
||||
private void checkSecondPassSwitches(Set<GraphPart> processedIfs, List<GraphTargetItem> list, List<List<GraphPart>> allSwitchParts, List<List<GraphPart>> allSwitchOnFalseParts, List<List<GraphTargetItem>> allSwitchExpressions) {
|
||||
for (GraphTargetItem item : list) {
|
||||
List<List<GraphTargetItem>> walkNext = new ArrayList<>();
|
||||
boolean canUseBlock = true;
|
||||
if (item instanceof IfItem) {
|
||||
IfItem ii = (IfItem) item;
|
||||
boolean isNeq = true;
|
||||
if ((ii.expression instanceof StrictNeqActionItem) || (ii.expression instanceof StrictEqActionItem)) {
|
||||
isNeq = (ii.expression instanceof StrictNeqActionItem);
|
||||
if (!processedIfs.contains(ii.decisionPart)) {
|
||||
if ((ii.expression instanceof StrictNeqActionItem) || (ii.expression instanceof StrictEqActionItem)) {
|
||||
isNeq = (ii.expression instanceof StrictNeqActionItem);
|
||||
|
||||
List<GraphPart> switchParts = new ArrayList<>();
|
||||
List<GraphTargetItem> switchExpressions = new ArrayList<>();
|
||||
List<GraphPart> switchOnFalseParts = new ArrayList<>();
|
||||
BinaryOpItem sneq = (BinaryOpItem) ii.expression;
|
||||
if ((sneq.leftSide instanceof StoreRegisterActionItem) || (sneq.leftSide instanceof GetVariableActionItem)) {
|
||||
List<GraphPart> switchParts = new ArrayList<>();
|
||||
List<GraphTargetItem> switchExpressions = new ArrayList<>();
|
||||
List<GraphPart> switchOnFalseParts = new ArrayList<>();
|
||||
BinaryOpItem sneq = (BinaryOpItem) ii.expression;
|
||||
if (true) {
|
||||
/*(sneq.leftSide instanceof StoreRegisterActionItem)
|
||||
|| (sneq.leftSide instanceof GetVariableActionItem)
|
||||
|| (sneq.leftSide instanceof GetMemberActionItem)
|
||||
) {*/
|
||||
|
||||
int regId = -1;
|
||||
GetVariableActionItem svar = null;
|
||||
if (sneq.leftSide instanceof StoreRegisterActionItem) {
|
||||
StoreRegisterActionItem sr = (StoreRegisterActionItem) sneq.leftSide;
|
||||
regId = sr.register.number;
|
||||
} else {
|
||||
svar = (GetVariableActionItem) sneq.leftSide;
|
||||
}
|
||||
int regId = -1;
|
||||
GraphTargetItem svar = null;
|
||||
if (sneq.leftSide instanceof StoreRegisterActionItem) {
|
||||
StoreRegisterActionItem sr = (StoreRegisterActionItem) sneq.leftSide;
|
||||
regId = sr.register.number;
|
||||
} else {
|
||||
svar = sneq.leftSide;
|
||||
}
|
||||
|
||||
switchParts.add(ii.decisionPart);
|
||||
switchExpressions.add(sneq.rightSide);
|
||||
switchOnFalseParts.add(ii.onTruePart);
|
||||
switchParts.add(ii.decisionPart);
|
||||
switchExpressions.add(sneq.rightSide);
|
||||
switchOnFalseParts.add(ii.onTruePart);
|
||||
|
||||
IfItem ii2 = ii;
|
||||
while (true) {
|
||||
if ((isNeq && (!ii2.onTrue.isEmpty() && (ii2.onTrue.get(0) instanceof IfItem)))
|
||||
|| (!isNeq && (!ii2.onFalse.isEmpty() && (ii2.onFalse.get(0) instanceof IfItem)))) {
|
||||
ii2 = (IfItem) (isNeq ? ii2.onTrue.get(0) : ii2.onFalse.get(0));
|
||||
if ((ii2.expression instanceof StrictNeqActionItem) || (ii2.expression instanceof StrictEqActionItem)) {
|
||||
isNeq = (ii2.expression instanceof StrictNeqActionItem);
|
||||
sneq = ((BinaryOpItem) ii2.expression);
|
||||
if (sneq.leftSide instanceof DirectValueActionItem) {
|
||||
DirectValueActionItem dv = (DirectValueActionItem) sneq.leftSide;
|
||||
if (dv.value instanceof RegisterNumber) {
|
||||
RegisterNumber rn = (RegisterNumber) dv.value;
|
||||
if (rn.number == regId) {
|
||||
switchParts.add(ii2.decisionPart);
|
||||
switchOnFalseParts.add(ii2.onTruePart);
|
||||
switchExpressions.add(sneq.rightSide);
|
||||
walkNext.add(isNeq ? ii2.onFalse : ii2.onTrue);
|
||||
IfItem ii2 = ii;
|
||||
IfItem lastOkayIi = ii;
|
||||
while (true) {
|
||||
if ((isNeq && (!ii2.onTrue.isEmpty() && (ii2.onTrue.get(0) instanceof IfItem)))
|
||||
|| (!isNeq && (!ii2.onFalse.isEmpty() && (ii2.onFalse.get(0) instanceof IfItem)))) {
|
||||
ii2 = (IfItem) (isNeq ? ii2.onTrue.get(0) : ii2.onFalse.get(0));
|
||||
if ((ii2.expression instanceof StrictNeqActionItem) || (ii2.expression instanceof StrictEqActionItem)) {
|
||||
isNeq = (ii2.expression instanceof StrictNeqActionItem);
|
||||
sneq = ((BinaryOpItem) ii2.expression);
|
||||
if (sneq.leftSide instanceof DirectValueActionItem) {
|
||||
DirectValueActionItem dv = (DirectValueActionItem) sneq.leftSide;
|
||||
if (dv.value instanceof RegisterNumber) {
|
||||
RegisterNumber rn = (RegisterNumber) dv.value;
|
||||
if (rn.number == regId) {
|
||||
processedIfs.add(ii.decisionPart);
|
||||
processedIfs.add(ii2.decisionPart);
|
||||
switchParts.add(ii2.decisionPart);
|
||||
switchOnFalseParts.add(ii2.onTruePart);
|
||||
switchExpressions.add(sneq.rightSide);
|
||||
lastOkayIi = ii2;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else if (svar != null) {
|
||||
if (sneq.leftSide.valueEquals(svar)) {
|
||||
processedIfs.add(ii.decisionPart);
|
||||
processedIfs.add(ii2.decisionPart);
|
||||
switchParts.add(ii2.decisionPart);
|
||||
switchOnFalseParts.add(ii2.onTruePart);
|
||||
switchExpressions.add(sneq.rightSide);
|
||||
lastOkayIi = ii2;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else if (svar != null && sneq.leftSide instanceof GetVariableActionItem) {
|
||||
if (sneq.leftSide.valueEquals(svar)) {
|
||||
switchParts.add(ii2.decisionPart);
|
||||
switchOnFalseParts.add(ii2.onTruePart);
|
||||
switchExpressions.add(sneq.rightSide);
|
||||
walkNext.add(isNeq ? ii2.onFalse : ii2.onTrue);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -675,29 +687,22 @@ public class ActionGraph extends Graph {
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (switchParts.size() > 1) {
|
||||
allSwitchParts.add(switchParts);
|
||||
allSwitchOnFalseParts.add(switchOnFalseParts);
|
||||
allSwitchExpressions.add(switchExpressions);
|
||||
walkNext.add(ii2.onFalse);
|
||||
canUseBlock = false;
|
||||
if (switchParts.size() > 1) {
|
||||
allSwitchParts.add(switchParts);
|
||||
allSwitchOnFalseParts.add(switchOnFalseParts);
|
||||
allSwitchExpressions.add(switchExpressions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((item instanceof Block) && (canUseBlock)) {
|
||||
if ((item instanceof Block)) {
|
||||
for (List<GraphTargetItem> sub : ((Block) item).getSubs()) {
|
||||
checkSecondPassSwitches(sub, allSwitchParts, allSwitchOnFalseParts, allSwitchExpressions);
|
||||
checkSecondPassSwitches(processedIfs, sub, allSwitchParts, allSwitchOnFalseParts, allSwitchExpressions);
|
||||
}
|
||||
}
|
||||
for (List<GraphTargetItem> next : walkNext) {
|
||||
checkSecondPassSwitches(next, allSwitchParts, allSwitchOnFalseParts, allSwitchExpressions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,8 @@ public class CallMethodActionItem extends ActionItem {
|
||||
}
|
||||
|
||||
if (!blankMethod) {
|
||||
if (scriptObject.getPrecedence() > this.precedence) {
|
||||
if (scriptObject.getPrecedence() > this.precedence
|
||||
|| ((scriptObject instanceof DirectValueActionItem) && (((DirectValueActionItem) scriptObject).value instanceof Long))) {
|
||||
writer.append("(");
|
||||
scriptObject.toString(writer, localData);
|
||||
writer.append(")");
|
||||
|
||||
@@ -91,7 +91,13 @@ public class SetMemberActionItem extends ActionItem implements SetTypeActionItem
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
object.toString(writer, localData);
|
||||
if (((object instanceof DirectValueActionItem) && (((DirectValueActionItem) object).value instanceof Long))) {
|
||||
writer.append("(");
|
||||
object.toString(writer, localData);
|
||||
writer.append(")");
|
||||
} else {
|
||||
object.toString(writer, localData);
|
||||
}
|
||||
|
||||
if ((!(objectName instanceof DirectValueActionItem)) || (!((DirectValueActionItem) objectName).isString()) || (!IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) objectName).toStringNoQuotes(localData)))) {
|
||||
writer.append("[");
|
||||
|
||||
@@ -263,7 +263,7 @@ public class ActionScript2Parser {
|
||||
return "" + uniqLast;
|
||||
}
|
||||
|
||||
private List<GraphTargetItem> commands(boolean inFunction, boolean inMethod, int forinlevel, boolean inTellTarget, List<VariableActionItem> variables, List<FunctionActionItem> functions, Reference<Boolean> hasEval) throws IOException, ActionParseException {
|
||||
private List<GraphTargetItem> commands(boolean inFunction, boolean inMethod, int forinlevel, boolean inTellTarget, List<VariableActionItem> variables, List<FunctionActionItem> functions, Reference<Boolean> hasEval) throws IOException, ActionParseException, InterruptedException {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
if (debugMode) {
|
||||
System.out.println("commands:");
|
||||
@@ -278,7 +278,7 @@ public class ActionScript2Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private GraphTargetItem type(List<VariableActionItem> variables) throws IOException, ActionParseException {
|
||||
private GraphTargetItem type(List<VariableActionItem> variables) throws IOException, ActionParseException, InterruptedException {
|
||||
GraphTargetItem ret;
|
||||
|
||||
ParsedSymbol s = lex();
|
||||
@@ -329,13 +329,16 @@ public class ActionScript2Parser {
|
||||
}
|
||||
}
|
||||
|
||||
private ParsedSymbol expectedType(Object... type) throws IOException, ActionParseException {
|
||||
private ParsedSymbol expectedType(Object... type) throws IOException, ActionParseException, InterruptedException {
|
||||
ParsedSymbol symb = lex();
|
||||
expected(symb, lexer.yyline(), type);
|
||||
return symb;
|
||||
}
|
||||
|
||||
private ParsedSymbol lex() throws IOException, ActionParseException {
|
||||
private ParsedSymbol lex() throws IOException, ActionParseException, InterruptedException {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
ParsedSymbol ret = lexer.lex();
|
||||
if (debugMode) {
|
||||
System.out.println(ret);
|
||||
@@ -343,7 +346,7 @@ public class ActionScript2Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private List<GraphTargetItem> call(boolean inFunction, boolean inMethod, boolean inTellTarget, List<VariableActionItem> variables, List<FunctionActionItem> functions, Reference<Boolean> hasEval) throws IOException, ActionParseException {
|
||||
private List<GraphTargetItem> call(boolean inFunction, boolean inMethod, boolean inTellTarget, List<VariableActionItem> variables, List<FunctionActionItem> functions, Reference<Boolean> hasEval) throws IOException, ActionParseException, InterruptedException {
|
||||
List<GraphTargetItem> ret = new ArrayList<>();
|
||||
//expected(SymbolType.PARENT_OPEN); //MUST BE HANDLED BY CALLER
|
||||
ParsedSymbol s = lex();
|
||||
@@ -358,7 +361,7 @@ public class ActionScript2Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private FunctionActionItem function(boolean withBody, String functionName, boolean isMethod, List<VariableActionItem> variables, List<FunctionActionItem> functions, boolean inTellTarget, Reference<Boolean> hasEval) throws IOException, ActionParseException {
|
||||
private FunctionActionItem function(boolean withBody, String functionName, boolean isMethod, List<VariableActionItem> variables, List<FunctionActionItem> functions, boolean inTellTarget, Reference<Boolean> hasEval) throws IOException, ActionParseException, InterruptedException {
|
||||
GraphTargetItem ret = null;
|
||||
ParsedSymbol s;
|
||||
expectedType(SymbolType.PARENT_OPEN);
|
||||
@@ -401,7 +404,7 @@ public class ActionScript2Parser {
|
||||
return retf;
|
||||
}
|
||||
|
||||
private GraphTargetItem traits(boolean isInterface, GraphTargetItem nameStr, GraphTargetItem extendsStr, List<GraphTargetItem> implementsStr, List<VariableActionItem> variables, List<FunctionActionItem> functions, boolean inTellTarget, Reference<Boolean> hasEval) throws IOException, ActionParseException {
|
||||
private GraphTargetItem traits(boolean isInterface, GraphTargetItem nameStr, GraphTargetItem extendsStr, List<GraphTargetItem> implementsStr, List<VariableActionItem> variables, List<FunctionActionItem> functions, boolean inTellTarget, Reference<Boolean> hasEval) throws IOException, ActionParseException, InterruptedException {
|
||||
|
||||
GraphTargetItem ret = null;
|
||||
/*for (int i = 0; i < nameStr.size() - 1; i++) {
|
||||
@@ -543,7 +546,7 @@ public class ActionScript2Parser {
|
||||
}
|
||||
}
|
||||
|
||||
private GraphTargetItem expressionCommands(ParsedSymbol s, boolean inFunction, boolean inMethod, boolean inTellTarget, int forinlevel, List<VariableActionItem> variables, List<FunctionActionItem> functions, Reference<Boolean> hasEval) throws IOException, ActionParseException {
|
||||
private GraphTargetItem expressionCommands(ParsedSymbol s, boolean inFunction, boolean inMethod, boolean inTellTarget, int forinlevel, List<VariableActionItem> variables, List<FunctionActionItem> functions, Reference<Boolean> hasEval) throws IOException, ActionParseException, InterruptedException {
|
||||
if (debugMode) {
|
||||
System.out.println("expressionCommands:");
|
||||
}
|
||||
@@ -950,7 +953,7 @@ public class ActionScript2Parser {
|
||||
}
|
||||
}
|
||||
|
||||
private GraphTargetItem command(boolean inFunction, boolean inMethod, int forinlevel, boolean inTellTarget, boolean mustBeCommand, List<VariableActionItem> variables, List<FunctionActionItem> functions, Reference<Boolean> hasEval) throws IOException, ActionParseException {
|
||||
private GraphTargetItem command(boolean inFunction, boolean inMethod, int forinlevel, boolean inTellTarget, boolean mustBeCommand, List<VariableActionItem> variables, List<FunctionActionItem> functions, Reference<Boolean> hasEval) throws IOException, ActionParseException, InterruptedException {
|
||||
LexBufferer buf = new LexBufferer();
|
||||
lexer.addListener(buf);
|
||||
GraphTargetItem ret = null;
|
||||
@@ -1375,7 +1378,7 @@ public class ActionScript2Parser {
|
||||
|
||||
}
|
||||
|
||||
private GraphTargetItem expression(boolean inFunction, boolean inMethod, boolean inTellTarget, boolean allowRemainder, List<VariableActionItem> variables, List<FunctionActionItem> functions, boolean allowComma, Reference<Boolean> hasEval) throws IOException, ActionParseException {
|
||||
private GraphTargetItem expression(boolean inFunction, boolean inMethod, boolean inTellTarget, boolean allowRemainder, List<VariableActionItem> variables, List<FunctionActionItem> functions, boolean allowComma, Reference<Boolean> hasEval) throws IOException, ActionParseException, InterruptedException {
|
||||
if (debugMode) {
|
||||
System.out.println("expression:");
|
||||
}
|
||||
@@ -1402,7 +1405,7 @@ public class ActionScript2Parser {
|
||||
return new CommaExpressionItem(null, null, commaItems);
|
||||
}
|
||||
|
||||
private ParsedSymbol peekLex() throws IOException, ActionParseException {
|
||||
private ParsedSymbol peekLex() throws IOException, ActionParseException, InterruptedException {
|
||||
ParsedSymbol lookahead = lex();
|
||||
lexer.pushback(lookahead);
|
||||
return lookahead;
|
||||
@@ -1435,7 +1438,7 @@ public class ActionScript2Parser {
|
||||
return s.type.getPrecedence();
|
||||
}
|
||||
|
||||
private GraphTargetItem expression1(GraphTargetItem lhs, int min_precedence, boolean inFunction, boolean inMethod, boolean inTellTarget, boolean allowRemainder, List<VariableActionItem> variables, List<FunctionActionItem> functions, Reference<Boolean> hasEval) throws IOException, ActionParseException {
|
||||
private GraphTargetItem expression1(GraphTargetItem lhs, int min_precedence, boolean inFunction, boolean inMethod, boolean inTellTarget, boolean allowRemainder, List<VariableActionItem> variables, List<FunctionActionItem> functions, Reference<Boolean> hasEval) throws IOException, ActionParseException, InterruptedException {
|
||||
ParsedSymbol op;
|
||||
GraphTargetItem rhs;
|
||||
GraphTargetItem mhs = null;
|
||||
@@ -1663,7 +1666,7 @@ public class ActionScript2Parser {
|
||||
return (item instanceof VariableActionItem);
|
||||
}
|
||||
|
||||
private int brackets(List<GraphTargetItem> ret, boolean inFunction, boolean inMethod, boolean inTellTarget, List<VariableActionItem> variables, List<FunctionActionItem> functions, Reference<Boolean> hasEval) throws IOException, ActionParseException {
|
||||
private int brackets(List<GraphTargetItem> ret, boolean inFunction, boolean inMethod, boolean inTellTarget, List<VariableActionItem> variables, List<FunctionActionItem> functions, Reference<Boolean> hasEval) throws IOException, ActionParseException, InterruptedException {
|
||||
ParsedSymbol s = lex();
|
||||
int arrCnt = 0;
|
||||
if (s.type == SymbolType.BRACKET_OPEN) {
|
||||
@@ -1687,7 +1690,7 @@ public class ActionScript2Parser {
|
||||
return arrCnt;
|
||||
}
|
||||
|
||||
private GraphTargetItem handleVariable(ParsedSymbol s, GraphTargetItem ret, List<VariableActionItem> variables, Reference<Boolean> allowMemberOrCall, boolean inFunction, boolean inMethod, boolean inTellTarget, List<FunctionActionItem> functions, Reference<Boolean> hasEval) throws IOException, ActionParseException {
|
||||
private GraphTargetItem handleVariable(ParsedSymbol s, GraphTargetItem ret, List<VariableActionItem> variables, Reference<Boolean> allowMemberOrCall, boolean inFunction, boolean inMethod, boolean inTellTarget, List<FunctionActionItem> functions, Reference<Boolean> hasEval) throws IOException, ActionParseException, InterruptedException {
|
||||
if (s.value.equals("not")) {
|
||||
ret = new NotItem(null, null, expressionPrimary(false, inFunction, inMethod, inTellTarget, false, variables, functions, true, hasEval));
|
||||
} else {
|
||||
@@ -1710,7 +1713,7 @@ public class ActionScript2Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private GraphTargetItem expressionPrimary(boolean allowEmpty, boolean inFunction, boolean inMethod, boolean inTellTarget, boolean allowRemainder, List<VariableActionItem> variables, List<FunctionActionItem> functions, boolean allowCall, Reference<Boolean> hasEval) throws IOException, ActionParseException {
|
||||
private GraphTargetItem expressionPrimary(boolean allowEmpty, boolean inFunction, boolean inMethod, boolean inTellTarget, boolean allowRemainder, List<VariableActionItem> variables, List<FunctionActionItem> functions, boolean allowCall, Reference<Boolean> hasEval) throws IOException, ActionParseException, InterruptedException {
|
||||
if (debugMode) {
|
||||
System.out.println("primary:");
|
||||
}
|
||||
@@ -2008,7 +2011,7 @@ public class ActionScript2Parser {
|
||||
return false;
|
||||
}
|
||||
|
||||
private GraphTargetItem memberOrCall(GraphTargetItem ret, boolean inFunction, boolean inMethod, boolean inTellTarget, List<VariableActionItem> variables, List<FunctionActionItem> functions, boolean allowCall, Reference<Boolean> hasEval) throws IOException, ActionParseException {
|
||||
private GraphTargetItem memberOrCall(GraphTargetItem ret, boolean inFunction, boolean inMethod, boolean inTellTarget, List<VariableActionItem> variables, List<FunctionActionItem> functions, boolean allowCall, Reference<Boolean> hasEval) throws IOException, ActionParseException, InterruptedException {
|
||||
ParsedSymbol op = lex();
|
||||
while (op.isType(SymbolType.PARENT_OPEN, SymbolType.BRACKET_OPEN, SymbolType.DOT)) {
|
||||
if (op.type == SymbolType.PARENT_OPEN) {
|
||||
@@ -2100,7 +2103,7 @@ public class ActionScript2Parser {
|
||||
|
||||
private List<String> constantPool;
|
||||
|
||||
public List<GraphTargetItem> treeFromString(String str, List<String> constantPool) throws ActionParseException, IOException {
|
||||
public List<GraphTargetItem> treeFromString(String str, List<String> constantPool) throws ActionParseException, IOException, InterruptedException {
|
||||
List<GraphTargetItem> retTree = new ArrayList<>();
|
||||
this.constantPool = constantPool;
|
||||
lexer = new ActionScriptLexer(new StringReader(str));
|
||||
@@ -2391,7 +2394,7 @@ public class ActionScript2Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<Action> actionsFromString(String s) throws ActionParseException, IOException, CompilationException {
|
||||
public List<Action> actionsFromString(String s) throws ActionParseException, IOException, CompilationException, InterruptedException {
|
||||
try {
|
||||
List<String> constantPool = new ArrayList<>();
|
||||
List<GraphTargetItem> tree = treeFromString(s, constantPool);
|
||||
|
||||
@@ -179,6 +179,8 @@ public class PreviewExporter {
|
||||
Logger.getLogger(PreviewExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (ActionParseException ex) {
|
||||
Logger.getLogger(PreviewExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(PreviewExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
overVideoButton.actions.add(bca);
|
||||
|
||||
@@ -205,6 +207,8 @@ public class PreviewExporter {
|
||||
Logger.getLogger(PreviewExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (ActionParseException ex) {
|
||||
Logger.getLogger(PreviewExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(PreviewExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
progressBarButton.actions.add(bca);
|
||||
|
||||
@@ -238,6 +242,8 @@ public class PreviewExporter {
|
||||
Logger.getLogger(PreviewExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (ActionParseException ex) {
|
||||
Logger.getLogger(PreviewExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(PreviewExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
doAction.writeTag(sos2);
|
||||
@@ -429,8 +435,8 @@ public class PreviewExporter {
|
||||
RECT r = ((BoundedTag) treeItem).getRect();
|
||||
rxmin = r.Xmin;
|
||||
rymin = r.Ymin;
|
||||
/*mat.translateX = -r.Xmin;
|
||||
mat.translateY = -r.Ymin;*/
|
||||
mat.translateX = -r.Xmin;
|
||||
mat.translateY = -r.Ymin;
|
||||
mat.translateX = mat.translateX + width / 2 - r.getWidth() / 2;
|
||||
mat.translateY = mat.translateY + (showControls ? height - progressBarHeight * 20 : height) / 2 - r.getHeight() / 2;
|
||||
} else {
|
||||
|
||||
@@ -41,7 +41,10 @@ public class AS2ScriptImporter {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(AS2ScriptImporter.class.getName());
|
||||
|
||||
public int importScripts(String scriptsFolder, Map<String, ASMSource> asms) {
|
||||
public int importScripts(String scriptsFolder, Map<String, ASMSource> asms) throws InterruptedException {
|
||||
return importScripts(scriptsFolder, asms, null);
|
||||
}
|
||||
public int importScripts(String scriptsFolder, Map<String, ASMSource> asms, ScriptImporterProgressListener listener) throws InterruptedException {
|
||||
if (!scriptsFolder.endsWith(File.separator)) {
|
||||
scriptsFolder += File.separator;
|
||||
}
|
||||
@@ -50,6 +53,9 @@ public class AS2ScriptImporter {
|
||||
|
||||
int importCount = 0;
|
||||
for (String key : asms.keySet()) {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
ASMSource asm = asms.get(key);
|
||||
String currentOutDir = scriptsFolder + key + File.separator;
|
||||
currentOutDir = new File(currentOutDir).getParentFile().toString() + File.separator;
|
||||
@@ -71,6 +77,7 @@ public class AS2ScriptImporter {
|
||||
|
||||
String fileName = Path.combine(currentOutDir, name) + ".as";
|
||||
if (new File(fileName).exists()) {
|
||||
asm.getSwf().informListeners("importing_as", fileName);
|
||||
String txt = Helper.readTextFile(fileName);
|
||||
|
||||
ActionScript2Parser par = new ActionScript2Parser(asm.getSwf(), asm);
|
||||
@@ -82,16 +89,22 @@ public class AS2ScriptImporter {
|
||||
logger.log(Level.SEVERE, "%error% on line %line%, file: %file%".replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)).replace("%file%", fileName), ex);
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.SEVERE, "error during script import, file: %file%".replace("%file%", fileName), ex);
|
||||
} catch (InterruptedException ex) {
|
||||
return importCount;
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, "error during script import, file: %file%".replace("%file%", fileName), ex);
|
||||
}
|
||||
|
||||
asm.setModified();
|
||||
importCount++;
|
||||
if (listener != null) {
|
||||
listener.scriptImported();
|
||||
}
|
||||
}
|
||||
|
||||
fileName = Path.combine(currentOutDir, name) + ".pcode";
|
||||
if (new File(fileName).exists()) {
|
||||
asm.getSwf().informListeners("importing_as", fileName);
|
||||
String txt = Helper.readTextFile(fileName);
|
||||
|
||||
try {
|
||||
@@ -104,19 +117,27 @@ public class AS2ScriptImporter {
|
||||
|
||||
asm.setModified();
|
||||
importCount++;
|
||||
if (listener != null) {
|
||||
listener.scriptImported();
|
||||
}
|
||||
}
|
||||
|
||||
fileName = Path.combine(currentOutDir, name) + ".hex";
|
||||
if (new File(fileName).exists()) {
|
||||
asm.getSwf().informListeners("importing_as", fileName);
|
||||
String txt = Helper.readTextFile(fileName);
|
||||
|
||||
asm.setActionBytes(Helper.getBytesFromHexaText(txt));
|
||||
asm.setModified();
|
||||
importCount++;
|
||||
if (listener != null) {
|
||||
listener.scriptImported();
|
||||
}
|
||||
}
|
||||
|
||||
fileName = Path.combine(currentOutDir, name) + ".txt";
|
||||
if (new File(fileName).exists()) {
|
||||
asm.getSwf().informListeners("importing_as", fileName);
|
||||
String txt = Helper.readTextFile(fileName);
|
||||
|
||||
try {
|
||||
@@ -126,6 +147,9 @@ public class AS2ScriptImporter {
|
||||
}
|
||||
asm.setModified();
|
||||
importCount++;
|
||||
if (listener != null) {
|
||||
listener.scriptImported();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,16 +34,24 @@ public class AS3ScriptImporter {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(AS3ScriptImporter.class.getName());
|
||||
|
||||
public int importScripts(As3ScriptReplacerInterface scriptReplacer, String scriptsFolder, List<ScriptPack> packs) {
|
||||
public int importScripts(As3ScriptReplacerInterface scriptReplacer, String scriptsFolder, List<ScriptPack> packs) throws InterruptedException {
|
||||
return importScripts(scriptReplacer, scriptsFolder, packs, null);
|
||||
}
|
||||
|
||||
public int importScripts(As3ScriptReplacerInterface scriptReplacer, String scriptsFolder, List<ScriptPack> packs, ScriptImporterProgressListener listener) throws InterruptedException {
|
||||
if (!scriptsFolder.endsWith(File.separator)) {
|
||||
scriptsFolder += File.separator;
|
||||
}
|
||||
|
||||
int importCount = 0;
|
||||
for (ScriptPack pack : packs) {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
return importCount;
|
||||
}
|
||||
try {
|
||||
File file = pack.getExportFile(scriptsFolder, new ScriptExportSettings(ScriptExportMode.AS, false, false));
|
||||
if (file.exists()) {
|
||||
pack.getSwf().informListeners("importing_as", file.getAbsolutePath());
|
||||
String fileName = file.getAbsolutePath();
|
||||
String txt = Helper.readTextFile(fileName);
|
||||
|
||||
@@ -54,10 +62,13 @@ public class AS3ScriptImporter {
|
||||
logger.log(Level.SEVERE, "%error% on line %line%, column %col%, file: %file%".replace("%error%", item.getMessage()).replace("%line%", Long.toString(item.getLine())).replace("%file%", fileName).replace("%col%", "" + item.getCol()));
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
logger.log(Level.SEVERE, "error during script import, file: %file%".replace("%file%", fileName), ex);
|
||||
return importCount;
|
||||
}
|
||||
|
||||
importCount++;
|
||||
if (listener != null) {
|
||||
listener.scriptImported();
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.jpexs.decompiler.flash.importers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface ScriptImporterProgressListener {
|
||||
public void scriptImported();
|
||||
}
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
@@ -145,6 +146,9 @@ public class DefineFontInfo2Tag extends FontInfoTag {
|
||||
|
||||
@Override
|
||||
public void addFontCharacter(int index, int character) {
|
||||
if (character > 255) {
|
||||
fontFlagsWideCodes = true;
|
||||
}
|
||||
codeTable.add(index, character);
|
||||
setModified(true);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
@@ -146,6 +147,9 @@ public class DefineFontInfoTag extends FontInfoTag {
|
||||
|
||||
@Override
|
||||
public void addFontCharacter(int index, int character) {
|
||||
if (character > 255) {
|
||||
fontFlagsWideCodes = true;
|
||||
}
|
||||
codeTable.add(index, character);
|
||||
setModified(true);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class DepthState {
|
||||
public int depth = -1;
|
||||
|
||||
public int characterId = -1;
|
||||
|
||||
@@ -113,6 +114,7 @@ public class DepthState {
|
||||
time = obj.time;
|
||||
placeObjectTag = obj.placeObjectTag;
|
||||
minPlaceObjectNum = obj.minPlaceObjectNum;
|
||||
depth = obj.depth;
|
||||
if (sameInstance) {
|
||||
time++;
|
||||
instanceId = obj.instanceId;
|
||||
|
||||
@@ -312,6 +312,7 @@ public class Timeline {
|
||||
DepthState fl = frame.layers.get(depth);
|
||||
if (fl == null) {
|
||||
frame.layers.put(depth, fl = new DepthState(swf, frame));
|
||||
fl.depth = depth;
|
||||
}
|
||||
frame.layersChanged = true;
|
||||
fl.placeObjectTag = po;
|
||||
|
||||
@@ -360,38 +360,6 @@ public class Graph {
|
||||
}
|
||||
}
|
||||
|
||||
for (GraphPart p : parts) {
|
||||
if (loopContinues.contains(p)) {
|
||||
break;
|
||||
}
|
||||
boolean common = true;
|
||||
for (GraphPart q : parts) {
|
||||
if (q == p) {
|
||||
continue;
|
||||
}
|
||||
if (!q.leadsTo(localData, this, code, p, loops, throwStates, false /*!!THROW*/)) {
|
||||
common = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (common) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
/*loopi:
|
||||
for (int i = 0; i < parts.size(); i++) {
|
||||
for (int j = 0; j < parts.size(); j++) {
|
||||
if (j == i) {
|
||||
continue;
|
||||
}
|
||||
if (parts.get(i).leadsTo(localData, this, code, parts.get(j), loops)) {
|
||||
parts.remove(i);
|
||||
i--;
|
||||
continue loopi;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
List<Set<GraphPart>> reachable = new ArrayList<>();
|
||||
Set<GraphPart> allReachable = new LinkedHashSet<>();
|
||||
for (GraphPart p : parts) {
|
||||
@@ -404,37 +372,76 @@ public class Graph {
|
||||
allReachable.add(p);
|
||||
allReachable.addAll(r1);
|
||||
}
|
||||
int maxCommonLevel = 0;
|
||||
GraphPart maxCommonLevelPart = null;
|
||||
Set<GraphPart> visited = new HashSet<>();
|
||||
for (GraphPart p : allReachable) {
|
||||
if (loopContinues.contains(p)) {
|
||||
break;
|
||||
}
|
||||
if (visited.contains(p)) {
|
||||
int maxCommonLevel = -1;
|
||||
GraphPart maxCommonPart = null;
|
||||
for (GraphPart r : allReachable) {
|
||||
if (loopContinues.contains(r)) {
|
||||
continue;
|
||||
}
|
||||
visited.add(p);
|
||||
boolean common = true;
|
||||
int commonLevel = 0;
|
||||
for (Set<GraphPart> r : reachable) {
|
||||
if (r.contains(p)) {
|
||||
for (GraphPart p : parts) {
|
||||
if (p == r) {
|
||||
commonLevel++;
|
||||
continue;
|
||||
}
|
||||
if (!p.leadsTo(localData, this, code, r, loops, throwStates, false)) {
|
||||
common = false;
|
||||
} else {
|
||||
commonLevel++;
|
||||
}
|
||||
}
|
||||
//System.err.println("commonlevel of " + p + " is " + commonLevel);
|
||||
if (commonLevel <= maxCommonLevel) {
|
||||
continue;
|
||||
}
|
||||
maxCommonLevel = commonLevel;
|
||||
maxCommonLevelPart = p;
|
||||
}
|
||||
//System.err.println("maxclevel = " + maxCommonLevel);
|
||||
//System.err.println("maxclevelpart = " + maxCommonLevelPart);
|
||||
if (common) {
|
||||
Stack<GraphPart> toProcess = new Stack<>();
|
||||
Set<GraphPart> visited = new HashSet<>();
|
||||
toProcess.addAll(parts);
|
||||
|
||||
loopprocess:
|
||||
while (!toProcess.isEmpty()) {
|
||||
GraphPart p = toProcess.pop();
|
||||
if (p == r) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (loopContinues.contains(p)) {
|
||||
continue;
|
||||
}
|
||||
if (visited.contains(p)) {
|
||||
continue;
|
||||
}
|
||||
visited.add(p);
|
||||
for (GraphPart n : p.nextParts) {
|
||||
if (n == r) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (loopContinues.contains(n)) {
|
||||
continue;
|
||||
}
|
||||
if (visited.contains(n)) {
|
||||
continue;
|
||||
}
|
||||
if (!n.leadsTo(localData, this, code, r, loops, throwStates, false)) {
|
||||
common = false;
|
||||
break loopprocess;
|
||||
}
|
||||
}
|
||||
toProcess.addAll(p.nextParts);
|
||||
}
|
||||
|
||||
if (common) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
if (commonLevel > maxCommonLevel) {
|
||||
maxCommonPart = r;
|
||||
maxCommonLevel = commonLevel;
|
||||
}
|
||||
}
|
||||
if (maxCommonLevel <= 1) {
|
||||
return null;
|
||||
}
|
||||
return maxCommonLevelPart;
|
||||
return maxCommonPart;
|
||||
}
|
||||
|
||||
public GraphPart getNextNoJump(GraphPart part, BaseLocalData localData) {
|
||||
@@ -2085,8 +2092,7 @@ public class Graph {
|
||||
output.addAll(ex.getOutput());
|
||||
for (GraphPart p : allParts) {
|
||||
if (p.containsIP(ex.getIp())) {
|
||||
if (ipStart == p.start) {
|
||||
//can this happen? TODO: find some example in the wild
|
||||
if (ex.getIp() == p.start) {
|
||||
currentRet.addAll(output);
|
||||
//to check for stopparts,etc. we need to call printGraph again
|
||||
part = p;
|
||||
|
||||
Reference in New Issue
Block a user