mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-24 17:11:03 +00:00
WIP Safe strings handling
This commit is contained in:
@@ -545,10 +545,17 @@ public class IdentifiersDeobfuscation {
|
||||
* words)
|
||||
* @return Printable identifier
|
||||
*/
|
||||
public static String printIdentifier(boolean as3, String s, String... validExceptions) {
|
||||
public static String printIdentifier(SWF swf, boolean as3, String s, String... validExceptions) {
|
||||
if (s == null || s.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (Configuration.useSafeStr.get() && as3) {
|
||||
Map<String, String> map = swf.getAs3ObfuscatedIdentifiers();
|
||||
if (map.containsKey(s)) {
|
||||
return map.get(s);
|
||||
}
|
||||
}
|
||||
|
||||
if (s.startsWith("\u00A7") && s.endsWith("\u00A7")) { // Assuming already printed - TODO:detect better
|
||||
return s;
|
||||
|
||||
@@ -190,12 +190,10 @@ import java.awt.geom.AffineTransform;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
@@ -670,6 +668,11 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
* Event listeners
|
||||
*/
|
||||
private final HashSet<EventListener> listeners = new HashSet<>();
|
||||
|
||||
/**
|
||||
* AS3 obfuscated identifiers map
|
||||
*/
|
||||
private transient Map<String, String> as3ObfuscatedIdentifiersMap = null;
|
||||
|
||||
/**
|
||||
* Lock for characters synchronization
|
||||
@@ -3364,7 +3367,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
}
|
||||
return String.join(File.separator, parts);
|
||||
}
|
||||
return DottedChain.parseNoSuffix(pkg.getName()).toPrintableString(false);
|
||||
return DottedChain.parseNoSuffix(pkg.getName()).toPrintableString(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3375,7 +3378,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
String expName = tag.getSwf().getExportName(tag.getCharacterId());
|
||||
if (expName != null && !expName.isEmpty()) {
|
||||
String[] pathParts = expName.contains(".") ? expName.split("\\.") : new String[]{expName};
|
||||
return IdentifiersDeobfuscation.printIdentifier(false, pathParts[pathParts.length - 1]);
|
||||
return IdentifiersDeobfuscation.printIdentifier(this, false, pathParts[pathParts.length - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3704,7 +3707,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
* @param path Path
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
private static void getVariables(ConstantPool constantPool, BaseLocalData localData, TranslateStack stack, List<GraphTargetItem> output, ActionGraphSource code, int ip, List<MyEntry<DirectValueActionItem, ConstantPool>> variables, List<GraphSourceItem> functions, HashMap<DirectValueActionItem, ConstantPool> strings, List<Integer> visited, HashMap<DirectValueActionItem, String> usageTypes, String path) throws InterruptedException {
|
||||
private static void getVariables(SWF swf, ConstantPool constantPool, BaseLocalData localData, TranslateStack stack, List<GraphTargetItem> output, ActionGraphSource code, int ip, List<MyEntry<DirectValueActionItem, ConstantPool>> variables, List<GraphSourceItem> functions, HashMap<DirectValueActionItem, ConstantPool> strings, List<Integer> visited, HashMap<DirectValueActionItem, String> usageTypes, String path) throws InterruptedException {
|
||||
ActionLocalData aLocalData = (ActionLocalData) localData;
|
||||
boolean debugMode = false;
|
||||
while ((ip > -1) && ip < code.size()) {
|
||||
@@ -3714,7 +3717,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
GraphSourceItem ins = code.get(ip);
|
||||
|
||||
if (debugMode) {
|
||||
System.err.println("Visit " + ip + ": ofs" + Helper.formatAddress(((Action) ins).getAddress()) + ":" + ((Action) ins).getASMSource(new ActionList(code.getCharset()), new HashSet<>(), ScriptExportMode.PCODE) + " stack:" + Helper.stackToString(stack, LocalData.create(new ConstantPool())));
|
||||
System.err.println("Visit " + ip + ": ofs" + Helper.formatAddress(((Action) ins).getAddress()) + ":" + ((Action) ins).getASMSource(new ActionList(code.getCharset()), new HashSet<>(), ScriptExportMode.PCODE) + " stack:" + Helper.stackToString(stack, LocalData.create(new ConstantPool(), swf)));
|
||||
}
|
||||
if (ins.isExit()) {
|
||||
break;
|
||||
@@ -3772,7 +3775,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
ip = code.adr2pos(addr);
|
||||
addr += size;
|
||||
int nextip = code.adr2pos(addr);
|
||||
getVariables(aLocalData.insideDoInitAction, variables, functions, strings, usageTypes, new ActionGraphSource(path, aLocalData.insideDoInitAction, code.getActions().subList(0, nextip), code.version, new HashMap<>(), new HashMap<>(), new HashMap<>(), code.getCharset(), ip), 0, path + (cntName == null ? "" : "/" + cntName));
|
||||
getVariables(swf, aLocalData.insideDoInitAction, variables, functions, strings, usageTypes, new ActionGraphSource(path, aLocalData.insideDoInitAction, code.getActions().subList(0, nextip), code.version, new HashMap<>(), new HashMap<>(), new HashMap<>(), code.getCharset(), ip), 0, path + (cntName == null ? "" : "/" + cntName));
|
||||
ip = nextip;
|
||||
}
|
||||
List<List<GraphTargetItem>> r = new ArrayList<>();
|
||||
@@ -3851,7 +3854,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
for (int b : branches) {
|
||||
TranslateStack brStack = (TranslateStack) stack.clone();
|
||||
if (b >= 0) {
|
||||
getVariables(constantPool, localData, brStack, output, code, b, variables, functions, strings, visited, usageTypes, path);
|
||||
getVariables(swf, constantPool, localData, brStack, output, code, b, variables, functions, strings, visited, usageTypes, path);
|
||||
} else if (debugMode) {
|
||||
System.out.println("Negative branch:" + b);
|
||||
}
|
||||
@@ -3866,6 +3869,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
/**
|
||||
* Gets variables from AS1/2 code.
|
||||
*
|
||||
* @param swf SWF
|
||||
* @param insideDoInitAction Is inside DoInitAction
|
||||
* @param variables Variables
|
||||
* @param functions Functions
|
||||
@@ -3876,9 +3880,9 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
* @param path Path
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
private static void getVariables(boolean insideDoInitAction, List<MyEntry<DirectValueActionItem, ConstantPool>> variables, List<GraphSourceItem> functions, HashMap<DirectValueActionItem, ConstantPool> strings, HashMap<DirectValueActionItem, String> usageTypes, ActionGraphSource code, int addr, String path) throws InterruptedException {
|
||||
private static void getVariables(SWF swf, boolean insideDoInitAction, List<MyEntry<DirectValueActionItem, ConstantPool>> variables, List<GraphSourceItem> functions, HashMap<DirectValueActionItem, ConstantPool> strings, HashMap<DirectValueActionItem, String> usageTypes, ActionGraphSource code, int addr, String path) throws InterruptedException {
|
||||
ActionLocalData localData = new ActionLocalData(null, insideDoInitAction, new HashMap<>() /*??*/);
|
||||
getVariables(null, localData, new TranslateStack(path), new ArrayList<>(), code, code.adr2pos(addr), variables, functions, strings, new ArrayList<>(), usageTypes, path);
|
||||
getVariables(swf, null, localData, new TranslateStack(path), new ArrayList<>(), code, code.adr2pos(addr), variables, functions, strings, new ArrayList<>(), usageTypes, path);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3900,7 +3904,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
ActionList actions = src.getActions();
|
||||
actionsMap.put(src, actions);
|
||||
boolean insideDoInitAction = src instanceof DoInitActionTag;
|
||||
getVariables(insideDoInitAction, variables, functions, strings, usageTypes, new ActionGraphSource(path, insideDoInitAction, actions, version, new HashMap<>(), new HashMap<>(), new HashMap<>(), src.getSwf().getCharset(), 0), 0, path);
|
||||
getVariables(this, insideDoInitAction, variables, functions, strings, usageTypes, new ActionGraphSource(path, insideDoInitAction, actions, version, new HashMap<>(), new HashMap<>(), new HashMap<>(), src.getSwf().getCharset(), 0), 0, path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -3997,6 +4001,24 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all AS3 obfuscated identifiers in this SWF and their suggested SafeStr replacement
|
||||
* @return Map source identifier to SafeStr replacement
|
||||
*/
|
||||
public synchronized Map<String, String> getAs3ObfuscatedIdentifiers() {
|
||||
if (as3ObfuscatedIdentifiersMap != null) {
|
||||
return as3ObfuscatedIdentifiersMap;
|
||||
}
|
||||
Map<String, String> ret = new LinkedHashMap<>();
|
||||
for (Tag tag : getTags()) {
|
||||
if (tag instanceof ABCContainerTag) {
|
||||
ABCContainerTag abcTag = (ABCContainerTag) tag;
|
||||
abcTag.getABC().getObfuscatedIdentifiers(ret);
|
||||
}
|
||||
}
|
||||
return as3ObfuscatedIdentifiersMap = ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deobfuscates AS3 identifiers.
|
||||
*
|
||||
@@ -4512,6 +4534,10 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
|
||||
asmsCache = null;
|
||||
asmsCacheExportFilenames = null;
|
||||
synchronized (this) {
|
||||
as3ObfuscatedIdentifiersMap = null;
|
||||
}
|
||||
|
||||
IdentifiersDeobfuscation.clearCache();
|
||||
}
|
||||
|
||||
@@ -5956,10 +5982,10 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
if (firstTrait instanceof TraitClass) {
|
||||
int cindex = ((TraitClass) firstTrait).class_info;
|
||||
Multiname superName = documentPack.abc.constants.getMultiname(documentPack.abc.instance_info.get(cindex).super_index);
|
||||
String parentClass = superName.getNameWithNamespace(documentPack.abc.constants, true).toRawString();
|
||||
String parentClass = superName.getNameWithNamespace(documentPack.abc, documentPack.abc.constants, true).toRawString();
|
||||
if ("mx.managers.SystemManager".equals(parentClass)) {
|
||||
for (Trait t : documentPack.abc.instance_info.get(cindex).instance_traits.traits) {
|
||||
if ((t instanceof TraitMethodGetterSetter) && "info".equals(t.getName(documentPack.abc).getName(documentPack.abc.constants, new ArrayList<>(), true, true))) {
|
||||
if ((t instanceof TraitMethodGetterSetter) && "info".equals(t.getName(documentPack.abc).getName(documentPack.abc, documentPack.abc.constants, new ArrayList<>(), true, true))) {
|
||||
|
||||
int mi = ((TraitMethodGetterSetter) t).method_info;
|
||||
try {
|
||||
@@ -6053,7 +6079,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
if (cit instanceof SetPropertyAVM2Item) {
|
||||
if (cit.value instanceof GetLexAVM2Item) {
|
||||
GetLexAVM2Item gl = (GetLexAVM2Item) cit.value;
|
||||
ignoredClasses.add(gl.propertyName.getNameWithNamespace(p.abc.constants, true).toRawString());
|
||||
ignoredClasses.add(gl.propertyName.getNameWithNamespace(p.abc, p.abc.constants, true).toRawString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -639,6 +639,89 @@ public class ABC implements Openable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void getObfuscatedIdentifier(int strIndex, Map<String, String> ret) {
|
||||
if (strIndex >= constants.getStringCount()) {
|
||||
return;
|
||||
}
|
||||
if (strIndex <= 0) {
|
||||
return;
|
||||
}
|
||||
String s = constants.getString(strIndex);
|
||||
if (ret.containsKey(s)) {
|
||||
return;
|
||||
}
|
||||
AVM2Deobfuscation deobfuscation = getDeobfuscation();
|
||||
if (deobfuscation.isValidName(strIndex)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret.put(s, AVM2Deobfuscation.SAFE_STR_PREFIX + ret.size());
|
||||
}
|
||||
|
||||
private void getObfuscatedPackageIdentifier(int strIndex, Map<String, String> ret) {
|
||||
if (strIndex >= constants.getStringCount()) {
|
||||
return;
|
||||
}
|
||||
if (strIndex <= 0) {
|
||||
return;
|
||||
}
|
||||
String s = constants.getString(strIndex);
|
||||
if (ret.containsKey(s)) {
|
||||
return;
|
||||
}
|
||||
AVM2Deobfuscation deobfuscation = getDeobfuscation();
|
||||
if (deobfuscation.isValidPackageName(strIndex)) {
|
||||
return;
|
||||
}
|
||||
String[] parts = s.split("\\.", -1);
|
||||
List<String> deobfuscatedList = new ArrayList<>();
|
||||
for (String part : parts) {
|
||||
if (!deobfuscation.isValidNSPart(part)) {
|
||||
deobfuscatedList.add(AVM2Deobfuscation.SAFE_STR_PREFIX + ret.size());
|
||||
ret.put(part, AVM2Deobfuscation.SAFE_STR_PREFIX + ret.size());
|
||||
} else {
|
||||
deobfuscatedList.add(part);
|
||||
}
|
||||
}
|
||||
ret.put(s, String.join(".", deobfuscatedList));
|
||||
}
|
||||
|
||||
public void getObfuscatedIdentifiers(Map<String, String> ret) {
|
||||
for (int i = 0; i < instance_info.size(); i++) {
|
||||
InstanceInfo insti = instance_info.get(i);
|
||||
if (insti.name_index != 0) {
|
||||
getObfuscatedIdentifier(constants.getMultiname(insti.name_index).name_index, ret);
|
||||
if (constants.getMultiname(insti.name_index).namespace_index != 0) {
|
||||
getObfuscatedPackageIdentifier( constants.getNamespace(constants.getMultiname(insti.name_index).namespace_index).name_index, ret);
|
||||
}
|
||||
}
|
||||
if (insti.super_index != 0) {
|
||||
getObfuscatedIdentifier(constants.getMultiname(insti.super_index).name_index, ret);
|
||||
}
|
||||
for (int iface : insti.interfaces) {
|
||||
getObfuscatedIdentifier(constants.getMultiname(iface).name_index, ret);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < constants.getMultinameCount(); i++) {
|
||||
Multiname m = constants.getMultiname(i);
|
||||
int strIndex = m.name_index;
|
||||
if (m.kind == Multiname.MULTINAME && strIndex > 0 && "*".equals(constants.getString(strIndex))) {
|
||||
continue;
|
||||
}
|
||||
getObfuscatedIdentifier(constants.getMultiname(i).name_index, ret);
|
||||
}
|
||||
for (int i = 1; i < constants.getNamespaceCount(); i++) {
|
||||
if (constants.getNamespace(i).kind != Namespace.KIND_PACKAGE) { // only packages
|
||||
continue;
|
||||
}
|
||||
getObfuscatedPackageIdentifier(constants.getNamespace(i).name_index, ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deobfuscates identifiers.
|
||||
*
|
||||
@@ -699,7 +782,7 @@ public class ABC implements Openable {
|
||||
int mIndex = body.getCode().code.get(ip).operands[0];
|
||||
if (mIndex > 0 && mIndex < constants.getMultinameCount()) {
|
||||
Multiname m = constants.getMultiname(mIndex);
|
||||
if (m.getNameWithNamespace(constants, true).toRawString().equals("flash.utils.getDefinitionByName")) {
|
||||
if (m.getNameWithNamespace(this, constants, true).toRawString().equals("flash.utils.getDefinitionByName")) {
|
||||
if (ip > 0) {
|
||||
if (body.getCode().code.get(ip - 1).definition instanceof PushStringIns) {
|
||||
int strIndex = body.getCode().code.get(ip - 1).operands[0];
|
||||
@@ -1269,7 +1352,7 @@ public class ABC implements Openable {
|
||||
*/
|
||||
public MethodBody findBodyClassInitializerByClass(String classNameWithSuffix) {
|
||||
for (int i = 0; i < instance_info.size(); i++) {
|
||||
if (classNameWithSuffix.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, null, true, true))) {
|
||||
if (classNameWithSuffix.equals(constants.getMultiname(instance_info.get(i).name_index).getName(this, constants, null, true, true))) {
|
||||
MethodBody body = findBody(class_info.get(i).cinit_index);
|
||||
if (body != null) {
|
||||
return body;
|
||||
@@ -1288,7 +1371,7 @@ public class ABC implements Openable {
|
||||
*/
|
||||
public MethodBody findBodyInstanceInitializerByClass(String classNameWithSuffix) {
|
||||
for (int i = 0; i < instance_info.size(); i++) {
|
||||
if (classNameWithSuffix.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, null, true, true))) {
|
||||
if (classNameWithSuffix.equals(constants.getMultiname(instance_info.get(i).name_index).getName(this, constants, null, true, true))) {
|
||||
MethodBody body = findBody(instance_info.get(i).iinit_index);
|
||||
if (body != null) {
|
||||
return body;
|
||||
@@ -1308,11 +1391,11 @@ public class ABC implements Openable {
|
||||
*/
|
||||
public MethodBody findBodyByClassAndName(String classNameWithSuffix, String methodNameWithSuffix) {
|
||||
for (int i = 0; i < instance_info.size(); i++) {
|
||||
if (classNameWithSuffix.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, null, true, true))) {
|
||||
if (classNameWithSuffix.equals(constants.getMultiname(instance_info.get(i).name_index).getName(this, constants, null, true, true))) {
|
||||
for (Trait t : instance_info.get(i).instance_traits.traits) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t;
|
||||
if (methodNameWithSuffix.equals(t2.getName(this).getName(constants, null, true, true))) {
|
||||
if (methodNameWithSuffix.equals(t2.getName(this).getName(this, constants, null, true, true))) {
|
||||
MethodBody body = findBody(t2.method_info);
|
||||
if (body != null) {
|
||||
return body;
|
||||
@@ -1324,7 +1407,7 @@ public class ABC implements Openable {
|
||||
for (Trait t : class_info.get(i).static_traits.traits) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t;
|
||||
if (methodNameWithSuffix.equals(t2.getName(this).getName(constants, null, true, true))) {
|
||||
if (methodNameWithSuffix.equals(t2.getName(this).getName(this, constants, null, true, true))) {
|
||||
MethodBody body = findBody(t2.method_info);
|
||||
if (body != null) {
|
||||
return body;
|
||||
@@ -1437,7 +1520,7 @@ public class ABC implements Openable {
|
||||
TraitSlotConst s = ((TraitSlotConst) t);
|
||||
if (s.isNamespace()) {
|
||||
String key = constants.getNamespace(s.value_index).getName(constants).toRawString(); // assume not null
|
||||
DottedChain val = constants.getMultiname(s.name_index).getNameWithNamespace(constants, true);
|
||||
DottedChain val = constants.getMultiname(s.name_index).getNameWithNamespace(this, constants, true);
|
||||
map.put(key, val);
|
||||
}
|
||||
}
|
||||
@@ -1530,7 +1613,7 @@ public class ABC implements Openable {
|
||||
public void dump(OutputStream os) {
|
||||
Utf8PrintWriter output;
|
||||
output = new Utf8PrintWriter(os);
|
||||
constants.dump(output);
|
||||
constants.dump(this, output);
|
||||
for (int i = 0; i < method_info.size(); i++) {
|
||||
output.println("MethodInfo[" + i + "]:" + method_info.get(i).toString(this, new ArrayList<>()));
|
||||
}
|
||||
@@ -1618,7 +1701,7 @@ public class ABC implements Openable {
|
||||
for (int multinameIndex = 1; multinameIndex < constants.getMultinameCount(); multinameIndex++) {
|
||||
Multiname m = constants.getMultiname(multinameIndex);
|
||||
if (m.kind == Multiname.QNAME || m.kind == Multiname.QNAMEA) {
|
||||
String name = m.getName(constants, new ArrayList<>(), true, false);
|
||||
String name = m.getName(this, constants, new ArrayList<>(), true, false);
|
||||
List<Integer> indices = nameToQNameIndices.get(name);
|
||||
if (indices == null) {
|
||||
indices = new ArrayList<>();
|
||||
@@ -1689,7 +1772,7 @@ public class ABC implements Openable {
|
||||
if (classId > -1) {
|
||||
for (Trait t : instance_info.get(classId).instance_traits.traits) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
if (t.getName(this).getName(constants, null, true, true).equals(methodNameWithSuffix)) {
|
||||
if (t.getName(this).getName(this, constants, null, true, true).equals(methodNameWithSuffix)) {
|
||||
return ((TraitMethodGetterSetter) t).method_info;
|
||||
}
|
||||
}
|
||||
@@ -1709,7 +1792,7 @@ public class ABC implements Openable {
|
||||
if (classId > -1) {
|
||||
for (Trait t : instance_info.get(classId).instance_traits.traits) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
if (t.getName(this).getName(constants, null, true, true).equals(methodNameWithSuffix)) {
|
||||
if (t.getName(this).getName(this, constants, null, true, true).equals(methodNameWithSuffix)) {
|
||||
return findBodyIndex(((TraitMethodGetterSetter) t).method_info);
|
||||
}
|
||||
}
|
||||
@@ -1752,7 +1835,7 @@ public class ABC implements Openable {
|
||||
if (instance_info.get(c).deleted) {
|
||||
continue;
|
||||
}
|
||||
DottedChain s = constants.getMultiname(instance_info.get(c).name_index).getNameWithNamespace(constants, true);
|
||||
DottedChain s = constants.getMultiname(instance_info.get(c).name_index).getNameWithNamespace(this, constants, true);
|
||||
if (nameWithSuffix.equals(s.toRawString())) {
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
@@ -41,6 +42,11 @@ public class ClassPath implements Serializable {
|
||||
* Namespace suffix
|
||||
*/
|
||||
public final String namespaceSuffix;
|
||||
|
||||
/**
|
||||
* SWF
|
||||
*/
|
||||
private final SWF swf;
|
||||
|
||||
/**
|
||||
* Constructs a new class path
|
||||
@@ -48,11 +54,13 @@ public class ClassPath implements Serializable {
|
||||
* @param packageStr Package name
|
||||
* @param className Class name
|
||||
* @param namespaceSuffix Namespace suffix
|
||||
* @param SWF swf
|
||||
*/
|
||||
public ClassPath(DottedChain packageStr, String className, String namespaceSuffix) {
|
||||
public ClassPath(DottedChain packageStr, String className, String namespaceSuffix, SWF swf) {
|
||||
this.packageStr = packageStr == null ? DottedChain.TOPLEVEL : packageStr;
|
||||
this.className = className;
|
||||
this.namespaceSuffix = namespaceSuffix;
|
||||
this.swf = swf;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +70,7 @@ public class ClassPath implements Serializable {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return packageStr.add(className, namespaceSuffix).toPrintableString(true);
|
||||
return packageStr.add(className, namespaceSuffix).toPrintableString(swf, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -207,7 +207,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
Multiname name = abc.script_info.get(scriptIndex).traits.traits.get(t).getName(abc);
|
||||
int nskind = name.getSimpleNamespaceKind(abc.constants);
|
||||
if ((nskind == Namespace.KIND_PACKAGE) || (nskind == Namespace.KIND_PACKAGE_INTERNAL)) {
|
||||
scriptName = name.getName(abc.constants, null, false, true);
|
||||
scriptName = name.getName(abc, abc.constants, null, false, true);
|
||||
}
|
||||
}
|
||||
return scriptName;
|
||||
@@ -224,7 +224,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
|
||||
String scriptName = getPathScriptName();
|
||||
DottedChain packageName = getPathPackage();
|
||||
File outDir = new File(directory + File.separatorChar + packageName.toFilePath());
|
||||
File outDir = new File(directory + File.separatorChar + packageName.toFilePath(abc.getSwf()));
|
||||
String fileName = outDir.toString() + File.separator + Helper.makeFileName(scriptName) + extension;
|
||||
return new File(fileName);
|
||||
}
|
||||
@@ -325,7 +325,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
continue;
|
||||
}
|
||||
|
||||
String fullName = t.getName(abc).getNameWithNamespace(abc.constants, false).toPrintableString(true);
|
||||
String fullName = t.getName(abc).getNameWithNamespace(abc, abc.constants, false).toPrintableString(abc.getSwf(), true);
|
||||
writer.appendNoHilight("include \"" + fullName.replace(".", "/") + ".as\";").newLine();
|
||||
}
|
||||
writer.newLine();
|
||||
@@ -771,7 +771,7 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
//String filepath = path.toString().replace('.', '/') + ".as";
|
||||
String pkg = path.packageStr.toString();
|
||||
String cls = path.className;
|
||||
String filename = new File(directoryPath, path.packageStr.toFilePath()).getPath().replace(";", "{{semicolon}}")
|
||||
String filename = new File(directoryPath, path.packageStr.toFilePath(abc.getSwf())).getPath().replace(";", "{{semicolon}}")
|
||||
+ ";"
|
||||
+ swfHash + ":"
|
||||
+ pkg.replace(".", File.separator).replace(";", "{{semicolon}}")
|
||||
|
||||
@@ -1998,7 +1998,7 @@ public class AVM2Code implements Cloneable {
|
||||
if (code.get(ip + plus + 2).definition instanceof SwapIns) {
|
||||
if (code.get(ip + plus + 4).definition instanceof PopScopeIns) {
|
||||
if (code.get(ip + plus + 3).definition instanceof SetPropertyIns) {
|
||||
functionName = abc.constants.getMultiname(code.get(ip + plus + 3).operands[0]).getName(abc.constants, fullyQualifiedNames, true, true);
|
||||
functionName = abc.constants.getMultiname(code.get(ip + plus + 3).operands[0]).getName(abc, abc.constants, fullyQualifiedNames, true, true);
|
||||
localScopeStack.pop(); // with
|
||||
output.remove(output.size() - 1); // with
|
||||
ip = ip + plus + 4; // +1 below
|
||||
@@ -2070,18 +2070,19 @@ public class AVM2Code implements Cloneable {
|
||||
/**
|
||||
* Gets types of local registers.
|
||||
*
|
||||
* @param abc ABC
|
||||
* @param constants Constant pool
|
||||
* @param fullyQualifiedNames Fully qualified names
|
||||
* @return Map from register id to type
|
||||
*/
|
||||
public HashMap<Integer, GraphTargetItem> getLocalRegTypes(AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
public HashMap<Integer, GraphTargetItem> getLocalRegTypes(ABC abc, AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
HashMap<Integer, GraphTargetItem> ret = new HashMap<>();
|
||||
AVM2Instruction prev = null;
|
||||
for (AVM2Instruction ins : code) {
|
||||
if (ins.definition instanceof SetLocalTypeIns) {
|
||||
if (prev != null) {
|
||||
if (prev.definition instanceof CoerceOrConvertTypeIns) {
|
||||
ret.put(((SetLocalTypeIns) ins.definition).getRegisterId(ins), ((CoerceOrConvertTypeIns) prev.definition).getTargetType(constants, prev));
|
||||
ret.put(((SetLocalTypeIns) ins.definition).getRegisterId(ins), ((CoerceOrConvertTypeIns) prev.definition).getTargetType(abc, constants, prev));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2257,7 +2258,7 @@ public class AVM2Code implements Cloneable {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst tsc = (TraitSlotConst) t;
|
||||
Multiname tratMultiname = abc.constants.getMultiname(tsc.name_index);
|
||||
String bodyTraitName = tratMultiname.getName(abc.constants, new ArrayList<>(), true, true);
|
||||
String bodyTraitName = tratMultiname.getName(abc, abc.constants, new ArrayList<>(), true, true);
|
||||
traits.put(bodyTraitName, tsc);
|
||||
}
|
||||
}
|
||||
@@ -2275,7 +2276,7 @@ public class AVM2Code implements Cloneable {
|
||||
if (ss.slotName == null) {
|
||||
break;
|
||||
}
|
||||
propNameStr = ss.slotName.getName(abc.constants, new ArrayList<>(), true, true);
|
||||
propNameStr = ss.slotName.getName(abc, abc.constants, new ArrayList<>(), true, true);
|
||||
value = ss.value;
|
||||
} else if (item instanceof SetPropertyAVM2Item) {
|
||||
SetPropertyAVM2Item sp = (SetPropertyAVM2Item) item;
|
||||
@@ -2323,7 +2324,7 @@ public class AVM2Code implements Cloneable {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
propertyName = propertyMultiName.getName(abc.constants, new ArrayList<>(), true, true);
|
||||
propertyName = propertyMultiName.getName(abc, abc.constants, new ArrayList<>(), true, true);
|
||||
|
||||
if (traits.containsKey(propertyName)) {
|
||||
Slot sl = new Slot(new NewActivationAVM2Item(null, null), propertyMultiName);
|
||||
@@ -2348,8 +2349,8 @@ public class AVM2Code implements Cloneable {
|
||||
if (!beginDeclaredSlotsNames.contains(traitName)) {
|
||||
Slot sl = new Slot(new NewActivationAVM2Item(null, null), abc.constants.getMultiname(traits.get(traitName).name_index));
|
||||
TraitSlotConst tsc = (TraitSlotConst) traits.get(traitName);
|
||||
GraphTargetItem type = AbcIndexing.multinameToType(tsc.type_index, abc.constants);
|
||||
DeclarationAVM2Item d = new DeclarationAVM2Item(new GetLexAVM2Item(null, null, sl.multiname, abc.constants, type, TypeItem.UNBOUNDED /*?*/, false), type);
|
||||
GraphTargetItem type = AbcIndexing.multinameToType(tsc.type_index, abc, abc.constants);
|
||||
DeclarationAVM2Item d = new DeclarationAVM2Item(new GetLexAVM2Item(null, null, sl.multiname, abc, abc.constants, type, TypeItem.UNBOUNDED /*?*/, false), type);
|
||||
declaredSlotsDec.add(d);
|
||||
declaredSlots.add(sl);
|
||||
|
||||
@@ -2415,7 +2416,7 @@ public class AVM2Code implements Cloneable {
|
||||
if (!declaredProperties.contains(propName.resolvedMultinameName)) {
|
||||
if (traits.containsKey(propName.resolvedMultinameName)) {
|
||||
TraitSlotConst tsc = traits.get(propName.resolvedMultinameName);
|
||||
GraphTargetItem type = AbcIndexing.multinameToType(tsc.type_index, abc.constants);
|
||||
GraphTargetItem type = AbcIndexing.multinameToType(tsc.type_index, abc, abc.constants);
|
||||
DeclarationAVM2Item d = new DeclarationAVM2Item(subItem, type);
|
||||
sp.setDeclaration(d);
|
||||
declaredPropsDec.add(d);
|
||||
@@ -2445,14 +2446,14 @@ public class AVM2Code implements Cloneable {
|
||||
SetSlotAVM2Item ssti = (SetSlotAVM2Item) subItem;
|
||||
if (ssti.scope instanceof NewActivationAVM2Item) {
|
||||
Slot sl = new Slot(ssti.scope, ssti.slotName);
|
||||
String slotPropertyName = sl.multiname.getName(abc.constants, new ArrayList<>(), true, false);
|
||||
String slotPropertyName = sl.multiname.getName(abc, abc.constants, new ArrayList<>(), true, false);
|
||||
if (!paramNames.contains(slotPropertyName)) {
|
||||
|
||||
int index = slotListIndexOf(declaredSlots, slotPropertyName, abc);
|
||||
if (index == -1) {
|
||||
GraphTargetItem type = TypeItem.UNBOUNDED;
|
||||
if (traits.containsKey(slotPropertyName)) {
|
||||
type = AbcIndexing.multinameToType(traits.get(slotPropertyName).type_index, abc.constants);
|
||||
type = AbcIndexing.multinameToType(traits.get(slotPropertyName).type_index, abc, abc.constants);
|
||||
}
|
||||
DeclarationAVM2Item d = new DeclarationAVM2Item(subItem, type);
|
||||
ssti.setDeclaration(d);
|
||||
@@ -2549,7 +2550,7 @@ public class AVM2Code implements Cloneable {
|
||||
}
|
||||
HashMap<Integer, GraphTargetItem> localRegTypes = new HashMap<>();
|
||||
for (int i = 0; i < abc.method_info.get(methodIndex).param_types.length; i++) {
|
||||
localRegTypes.put(i + 1, AbcIndexing.multinameToType(abc.method_info.get(methodIndex).param_types[i], abc.constants));
|
||||
localRegTypes.put(i + 1, AbcIndexing.multinameToType(abc.method_info.get(methodIndex).param_types[i], abc, abc.constants));
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -2581,7 +2582,7 @@ public class AVM2Code implements Cloneable {
|
||||
if (value != null && !convertData.assignedValues.containsKey(tsc)) {
|
||||
if (value instanceof NewFunctionAVM2Item) {
|
||||
NewFunctionAVM2Item f = (NewFunctionAVM2Item) value;
|
||||
f.functionName = tsc.getName(abc).getName(abc.constants, fullyQualifiedNames, true, true);
|
||||
f.functionName = tsc.getName(abc).getName(abc, abc.constants, fullyQualifiedNames, true, true);
|
||||
}
|
||||
AssignedValue av = new AssignedValue(ti, value, initializerType, methodIndex);
|
||||
convertData.assignedValues.put(tsc, av);
|
||||
@@ -2670,7 +2671,7 @@ public class AVM2Code implements Cloneable {
|
||||
}
|
||||
if (value instanceof NewFunctionAVM2Item) {
|
||||
NewFunctionAVM2Item f = (NewFunctionAVM2Item) value;
|
||||
f.functionName = tsc.getName(abc).getName(abc.constants, fullyQualifiedNames, true, true);
|
||||
f.functionName = tsc.getName(abc).getName(abc, abc.constants, fullyQualifiedNames, true, true);
|
||||
}
|
||||
AssignedValue av = new AssignedValue(classMultiname == -1 ? ti : null, value, initializerType, methodIndex);
|
||||
convertData.assignedValues.put(tsc, av);
|
||||
@@ -2888,7 +2889,7 @@ public class AVM2Code implements Cloneable {
|
||||
if (param_types[i] == 0) {
|
||||
type = TypeItem.UNBOUNDED;
|
||||
} else {
|
||||
type = new TypeItem(abc.constants.getMultiname(param_types[i]).getNameWithNamespace(abc.constants, true));
|
||||
type = new TypeItem(abc.constants.getMultiname(param_types[i]).getNameWithNamespace(abc, abc.constants, true));
|
||||
}
|
||||
if (d.length > r) {
|
||||
d[r] = new DeclarationAVM2Item(new SetLocalAVM2Item(null, null, r, new NullAVM2Item(null, null), type), type);
|
||||
@@ -2913,7 +2914,7 @@ public class AVM2Code implements Cloneable {
|
||||
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));
|
||||
paramNamesList.add(AVM2Item.localRegName(abc.getSwf(), localRegNames, ir));
|
||||
}
|
||||
injectDeclarations(0, paramNamesList, list, 1, d, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), abc, body);
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.ABCVersionRequirements;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
|
||||
@@ -949,14 +950,16 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
* Finds multiname index based on multiname in other constant pool.
|
||||
*
|
||||
* @param val Value
|
||||
* @param thisAbc This ABC
|
||||
* @param origAbc Original ABC
|
||||
* @param origConst Original constant pool
|
||||
* @return List of multiname indexes
|
||||
*/
|
||||
public List<Integer> getMultinameIds(Multiname val, AVM2ConstantPool origConst) {
|
||||
public List<Integer> getMultinameIds(Multiname val, ABC thisAbc, ABC origAbc, AVM2ConstantPool origConst) {
|
||||
|
||||
List<Integer> ret = new ArrayList<>();
|
||||
for (int i = 1; i < getMultinameCount(); i++) {
|
||||
if (getMultiname(i).qnameEquals(this, val, origConst)) {
|
||||
if (getMultiname(i).qnameEquals(thisAbc, this, val, origAbc, origConst)) {
|
||||
ret.add(i);
|
||||
}
|
||||
}
|
||||
@@ -1196,9 +1199,10 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
/**
|
||||
* Dumps the constant pool.
|
||||
*
|
||||
* @param abc ABC
|
||||
* @param writer Writer
|
||||
*/
|
||||
public void dump(Utf8PrintWriter writer) {
|
||||
public void dump(ABC abc, Utf8PrintWriter writer) {
|
||||
for (int i = 1; i < constant_int.size(); i++) {
|
||||
writer.println("INT[" + i + "]=" + constant_int.get(i));
|
||||
}
|
||||
@@ -1212,7 +1216,7 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
writer.println("String[" + i + "]=" + constant_string.get(i));
|
||||
}
|
||||
for (int i = 1; i < constant_namespace.size(); i++) {
|
||||
writer.println("Namespace[" + i + "]=" + constant_namespace.get(i).toString(this));
|
||||
writer.println("Namespace[" + i + "]=" + constant_namespace.get(i).toString(abc, this));
|
||||
}
|
||||
for (int i = 1; i < constant_namespace_set.size(); i++) {
|
||||
writer.println("NamespaceSet[" + i + "]=" + constant_namespace_set.get(i).toString(this));
|
||||
@@ -1239,14 +1243,15 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
/**
|
||||
* Converts namespace to string.
|
||||
*
|
||||
* @param abc ABC
|
||||
* @param index Namespace index
|
||||
* @return String
|
||||
*/
|
||||
public String namespaceToString(int index) {
|
||||
public String namespaceToString(ABC abc, int index) {
|
||||
if (index == 0) {
|
||||
return "null";
|
||||
}
|
||||
return constant_namespace.get(index).toString(this);
|
||||
return constant_namespace.get(index).toString(abc, this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,8 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class AVM2Deobfuscation {
|
||||
|
||||
public static final String SAFE_STR_PREFIX = "_SafeStr_";
|
||||
|
||||
/**
|
||||
* Default size of random word.
|
||||
*/
|
||||
@@ -97,7 +99,7 @@ public class AVM2Deobfuscation {
|
||||
* @param s String
|
||||
* @return True if string is valid namespace part
|
||||
*/
|
||||
private boolean isValidNSPart(String s) {
|
||||
public boolean isValidNSPart(String s) {
|
||||
boolean isValid = true;
|
||||
if (IdentifiersDeobfuscation.isReservedWord2(s)) {
|
||||
isValid = false;
|
||||
@@ -179,6 +181,23 @@ public class AVM2Deobfuscation {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether string at given index is valid package name
|
||||
* @param strIndex String index
|
||||
* @return True if valid
|
||||
*/
|
||||
public boolean isValidPackageName(int strIndex) {
|
||||
if (strIndex <= 0) {
|
||||
return true;
|
||||
}
|
||||
String s = constants.getString(strIndex);
|
||||
if (builtInNs(s) != null) {
|
||||
return true;
|
||||
}
|
||||
return isValidNSPart(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deobfuscates package name.
|
||||
*
|
||||
@@ -189,16 +208,9 @@ public class AVM2Deobfuscation {
|
||||
* @param renameType Rename type
|
||||
* @return Deobfuscated package name
|
||||
*/
|
||||
public int deobfuscatePackageName(Map<Integer, String> stringUsageTypes, Set<Integer> stringUsages, HashMap<DottedChain, DottedChain> namesMap, int strIndex, RenameType renameType) {
|
||||
if (strIndex <= 0) {
|
||||
return strIndex;
|
||||
}
|
||||
String s = constants.getString(strIndex);
|
||||
if (builtInNs(s) != null) {
|
||||
return strIndex;
|
||||
}
|
||||
boolean isValid = isValidNSPart(s);
|
||||
if (!isValid) {
|
||||
public int deobfuscatePackageName(Map<Integer, String> stringUsageTypes, Set<Integer> stringUsages, HashMap<DottedChain, DottedChain> namesMap, int strIndex, RenameType renameType) {
|
||||
if (!isValidPackageName(strIndex)) {
|
||||
String s = constants.getString(strIndex);
|
||||
DottedChain sChain = DottedChain.parseWithSuffix(s);
|
||||
DottedChain newName;
|
||||
if (namesMap.containsKey(sChain)) {
|
||||
@@ -228,20 +240,13 @@ public class AVM2Deobfuscation {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deobfuscates name.
|
||||
*
|
||||
* @param stringUsageTypes String usage types
|
||||
* @param stringUsages String usages
|
||||
* @param namespaceUsages Namespace usages
|
||||
* @param namesMap Names map
|
||||
* Checks whether string at given index is valid name
|
||||
* @param strIndex String index
|
||||
* @param firstUppercase First uppercase
|
||||
* @param renameType Rename type
|
||||
* @return Deobfuscated name string index
|
||||
* @return True when valid
|
||||
*/
|
||||
public int deobfuscateName(Map<Integer, String> stringUsageTypes, Set<Integer> stringUsages, Set<Integer> namespaceUsages, HashMap<DottedChain, DottedChain> namesMap, int strIndex, boolean firstUppercase, RenameType renameType) {
|
||||
public boolean isValidName(int strIndex) {
|
||||
if (strIndex <= 0) {
|
||||
return strIndex;
|
||||
return true;
|
||||
}
|
||||
String s = constants.getString(strIndex);
|
||||
boolean isValid = true;
|
||||
@@ -264,8 +269,24 @@ public class AVM2Deobfuscation {
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
return isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deobfuscates name.
|
||||
*
|
||||
* @param stringUsageTypes String usage types
|
||||
* @param stringUsages String usages
|
||||
* @param namespaceUsages Namespace usages
|
||||
* @param namesMap Names map
|
||||
* @param strIndex String index
|
||||
* @param firstUppercase First uppercase
|
||||
* @param renameType Rename type
|
||||
* @return Deobfuscated name string index
|
||||
*/
|
||||
public int deobfuscateName(Map<Integer, String> stringUsageTypes, Set<Integer> stringUsages, Set<Integer> namespaceUsages, HashMap<DottedChain, DottedChain> namesMap, int strIndex, boolean firstUppercase, RenameType renameType) {
|
||||
if (!isValidName(strIndex)) {
|
||||
String s = constants.getString(strIndex);
|
||||
DottedChain newname;
|
||||
DottedChain sChain = DottedChain.parseNoSuffix(s);
|
||||
if (namesMap.containsKey(sChain)) {
|
||||
|
||||
@@ -2190,7 +2190,7 @@ public class AVM2Graph extends Graph {
|
||||
}
|
||||
if (construct.object instanceof GetLexAVM2Item) {
|
||||
GetLexAVM2Item glt = (GetLexAVM2Item) construct.object;
|
||||
isXMLList = glt.propertyName.getName(aLocalData.getConstants(), aLocalData.fullyQualifiedNames, true, true).equals("XMLList");
|
||||
isXMLList = glt.propertyName.getName(aLocalData.abc, aLocalData.getConstants(), aLocalData.fullyQualifiedNames, true, true).equals("XMLList");
|
||||
}
|
||||
|
||||
if (isXMLList) {
|
||||
@@ -2733,7 +2733,7 @@ public class AVM2Graph extends Graph {
|
||||
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))) {
|
||||
if (Objects.equals(propName.resolvedMultinameName, AVM2Item.localRegName(abc.getSwf(), aLocalData.localRegNames, lr.regIndex))) {
|
||||
list.remove(i);
|
||||
i--;
|
||||
continue loopi;
|
||||
@@ -2746,7 +2746,7 @@ public class AVM2Graph extends Graph {
|
||||
if (list.get(i) instanceof SetSlotAVM2Item) {
|
||||
SetSlotAVM2Item sslot = (SetSlotAVM2Item) list.get(i);
|
||||
if (sslot.slotObject instanceof NewActivationAVM2Item) {
|
||||
String slotName = sslot.slotName.getName(abc.constants, new ArrayList<>(), true, true);
|
||||
String slotName = sslot.slotName.getName(abc, abc.constants, new ArrayList<>(), true, true);
|
||||
if (sslot.value.getNotCoercedNoDup() instanceof LocalRegAVM2Item) {
|
||||
LocalRegAVM2Item locReg = (LocalRegAVM2Item) sslot.value.getNotCoercedNoDup();
|
||||
if (localRegNames.containsValue(slotName)) {
|
||||
|
||||
+1
-1
@@ -388,7 +388,7 @@ public abstract class InstructionDefinition implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
return new FullMultinameAVM2Item(property, ins, localData.lineStartInstruction, multinameIndex, localData.abc.constants.getMultiname(multinameIndex).getName(localData.getConstants(), new ArrayList<>(), true, true), name, ns);
|
||||
return new FullMultinameAVM2Item(property, ins, localData.lineStartInstruction, multinameIndex, localData.abc.constants.getMultiname(multinameIndex).getName(localData.abc, localData.getConstants(), new ArrayList<>(), true, true), name, ns);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -129,7 +129,7 @@ public class ConstructIns extends InstructionDefinition {
|
||||
}
|
||||
if (obj instanceof GetLexAVM2Item) {
|
||||
GetLexAVM2Item glt = (GetLexAVM2Item) obj;
|
||||
isXML = glt.propertyName.getName(localData.getConstants(), localData.fullyQualifiedNames, true, true).equals("XML");
|
||||
isXML = glt.propertyName.getName(localData.abc, localData.getConstants(), localData.fullyQualifiedNames, true, true).equals("XML");
|
||||
}
|
||||
|
||||
if (isXML) {
|
||||
@@ -157,7 +157,7 @@ public class ConstructIns extends InstructionDefinition {
|
||||
}
|
||||
if (obj instanceof GetLexAVM2Item) {
|
||||
GetLexAVM2Item glt = (GetLexAVM2Item) obj;
|
||||
isRegExp = glt.propertyName.getName(localData.getConstants(), localData.fullyQualifiedNames, true, true).equals("RegExp");
|
||||
isRegExp = glt.propertyName.getName(localData.abc, localData.getConstants(), localData.fullyQualifiedNames, true, true).equals("RegExp");
|
||||
}
|
||||
|
||||
if (isRegExp && (args.size() >= 1) && (args.get(0) instanceof StringAVM2Item) && (args.size() == 1 || (args.size() == 2 && args.get(1) instanceof StringAVM2Item))) {
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class NewClassIns extends InstructionDefinition {
|
||||
writer.finishHilights();
|
||||
String baseType = writer.toString();
|
||||
ABC abc = localData.abc;
|
||||
stack.push(new UnparsedAVM2Item(ins, localData.lineStartInstruction, "§§newclass(" + abc.constants.getMultiname(abc.instance_info.get(clsIndex).name_index).getName(localData.getConstants(), localData.fullyQualifiedNames, false, true) + "," + baseType + ")"));
|
||||
stack.push(new UnparsedAVM2Item(ins, localData.lineStartInstruction, "§§newclass(" + abc.constants.getMultiname(abc.instance_info.get(clsIndex).name_index).getName(localData.abc, localData.getConstants(), localData.fullyQualifiedNames, false, true) + "," + baseType + ")"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ public abstract class GetLocalTypeIns extends InstructionDefinition {
|
||||
List<Trait> ts = localData.getInstanceInfo().get(localData.classIndex).instance_traits.traits;
|
||||
boolean isBasicObject = localData.thisHasDefaultToPrimitive;
|
||||
Multiname m = localData.getInstanceInfo().get(localData.classIndex).getName(localData.getConstants());
|
||||
stack.push(new ThisAVM2Item(ins, localData.lineStartInstruction, m.getNameWithNamespace(localData.getConstants(), true), isBasicObject, false));
|
||||
stack.push(new ThisAVM2Item(ins, localData.lineStartInstruction, m.getNameWithNamespace(localData.abc, localData.getConstants(), true), isBasicObject, false));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class GetGlobalSlotIns extends InstructionDefinition {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst tsc = (TraitSlotConst) t;
|
||||
if (tsc.slot_id == slotIndex) {
|
||||
slotType = AbcIndexing.multinameToType(tsc.type_index, localData.abc.constants);
|
||||
slotType = AbcIndexing.multinameToType(tsc.type_index, localData.abc, localData.abc.constants);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -58,17 +58,17 @@ public class GetLexIns extends InstructionDefinition {
|
||||
Reference<Boolean> isStatic, Reference<GraphTargetItem> type, Reference<GraphTargetItem> callType) {
|
||||
type.setVal(TypeItem.UNKNOWN);
|
||||
callType.setVal(TypeItem.UNKNOWN);
|
||||
String multinameStr = localData.abc.constants.getMultiname(multinameIndex).getName(localData.abc.constants, new ArrayList<>(), true, true);
|
||||
String multinameStr = localData.abc.constants.getMultiname(multinameIndex).getName(localData.abc, localData.abc.constants, new ArrayList<>(), true, true);
|
||||
for (int b = localData.callStack.size() - 1; b >= 0; b--) {
|
||||
MethodBody body = localData.callStack.get(b);
|
||||
for (Trait t : body.traits.traits) {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst tsc = (TraitSlotConst) t;
|
||||
if (Objects.equals(
|
||||
tsc.getName(localData.abc).getName(localData.abc.constants, new ArrayList<>(), true, true),
|
||||
tsc.getName(localData.abc).getName(localData.abc, localData.abc.constants, new ArrayList<>(), true, true),
|
||||
multinameStr
|
||||
)) {
|
||||
GraphTargetItem ty = AbcIndexing.multinameToType(tsc.type_index, localData.abc.constants);
|
||||
GraphTargetItem ty = AbcIndexing.multinameToType(tsc.type_index, localData.abc, localData.abc.constants);
|
||||
type.setVal(ty);
|
||||
callType.setVal(ty);
|
||||
return;
|
||||
@@ -78,7 +78,7 @@ public class GetLexIns extends InstructionDefinition {
|
||||
}
|
||||
|
||||
if (localData.abcIndex != null) {
|
||||
String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc.constants, true).toRawString();
|
||||
String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc, localData.abc.constants, true).toRawString();
|
||||
if (currentClassName != null) {
|
||||
Reference<Boolean> foundStatic = new Reference<>(null);
|
||||
localData.abcIndex.findPropertyTypeOrCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multinameIndex).namespace_index, true, true, true, type, callType, foundStatic);
|
||||
@@ -86,7 +86,7 @@ public class GetLexIns extends InstructionDefinition {
|
||||
|
||||
if (type.getVal().equals(TypeItem.UNKNOWN)) {
|
||||
//TypeItem ti = new TypeItem(localData.abc.constants.getMultiname(multinameIndex).getNameWithNamespace(localData.abc.constants, true));
|
||||
GraphTargetItem ti = AbcIndexing.multinameToType(multinameIndex, localData.abc.constants);
|
||||
GraphTargetItem ti = AbcIndexing.multinameToType(multinameIndex, localData.abc, localData.abc.constants);
|
||||
if (localData.abcIndex.findClass(ti, localData.abc, localData.scriptIndex) != null) {
|
||||
type.setVal(ti);
|
||||
callType.setVal(TypeItem.UNBOUNDED);
|
||||
@@ -116,7 +116,7 @@ public class GetLexIns extends InstructionDefinition {
|
||||
Reference<GraphTargetItem> type = new Reference<>(null);
|
||||
Reference<GraphTargetItem> callType = new Reference<>(null);
|
||||
GetLexIns.resolveLexType(localData, null, multinameIndex, isStatic, type, callType);
|
||||
stack.push(new GetLexAVM2Item(ins, localData.lineStartInstruction, multiname, localData.getConstants(), type.getVal(), callType.getVal(), isStatic.getVal()));
|
||||
stack.push(new GetLexAVM2Item(ins, localData.lineStartInstruction, multiname, localData.abc, localData.getConstants(), type.getVal(), callType.getVal(), isStatic.getVal()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-5
@@ -152,7 +152,7 @@ public class GetPropertyIns extends InstructionDefinition {
|
||||
Reference<Boolean> isStatic, Reference<GraphTargetItem> type, Reference<GraphTargetItem> callType) {
|
||||
type.setVal(TypeItem.UNKNOWN);
|
||||
callType.setVal(TypeItem.UNKNOWN);
|
||||
String multinameStr = localData.abc.constants.getMultiname(multiname.multinameIndex).getName(localData.abc.constants, new ArrayList<>(), true, true);
|
||||
String multinameStr = localData.abc.constants.getMultiname(multiname.multinameIndex).getName(localData.abc, localData.abc.constants, new ArrayList<>(), true, true);
|
||||
if (obj instanceof FindPropertyAVM2Item) {
|
||||
FindPropertyAVM2Item fprop = (FindPropertyAVM2Item) obj;
|
||||
if (fprop.propertyName.equals(multiname)) {
|
||||
@@ -162,10 +162,10 @@ public class GetPropertyIns extends InstructionDefinition {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst tsc = (TraitSlotConst) t;
|
||||
if (Objects.equals(
|
||||
tsc.getName(localData.abc).getName(localData.abc.constants, new ArrayList<>(), true, true),
|
||||
tsc.getName(localData.abc).getName(localData.abc, localData.abc.constants, new ArrayList<>(), true, true),
|
||||
multinameStr
|
||||
)) {
|
||||
GraphTargetItem ty = AbcIndexing.multinameToType(tsc.type_index, localData.abc.constants);
|
||||
GraphTargetItem ty = AbcIndexing.multinameToType(tsc.type_index, localData.abc, localData.abc.constants);
|
||||
type.setVal(ty);
|
||||
callType.setVal(ty);
|
||||
return;
|
||||
@@ -176,13 +176,13 @@ public class GetPropertyIns extends InstructionDefinition {
|
||||
|
||||
if (type.getVal().equals(TypeItem.UNKNOWN)) {
|
||||
if (localData.abcIndex != null) {
|
||||
String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc.constants, true).toRawString();
|
||||
String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc, localData.abc.constants, true).toRawString();
|
||||
if (currentClassName != null) {
|
||||
Reference<Boolean> foundStatic = new Reference<>(null);
|
||||
localData.abcIndex.findPropertyTypeOrCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, true, true, true, type, callType, foundStatic);
|
||||
}
|
||||
if (type.getVal().equals(TypeItem.UNKNOWN)) {
|
||||
GraphTargetItem ti = AbcIndexing.multinameToType(multiname.multinameIndex, localData.abc.constants);
|
||||
GraphTargetItem ti = AbcIndexing.multinameToType(multiname.multinameIndex, localData.abc, localData.abc.constants);
|
||||
if (localData.abcIndex.findClass(ti, localData.abc, localData.scriptIndex) != null) {
|
||||
type.setVal(ti);
|
||||
callType.setVal(ti); //coercion i = int(xx);
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ public class GetSlotIns extends InstructionDefinition {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst tsc = (TraitSlotConst) t;
|
||||
if (tsc.slot_id == slotIndex) {
|
||||
slotType = AbcIndexing.multinameToType(tsc.type_index, localData.abc.constants);
|
||||
slotType = AbcIndexing.multinameToType(tsc.type_index, localData.abc, localData.abc.constants);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns {
|
||||
if (slotname != null) {
|
||||
if (value instanceof LocalRegAVM2Item) {
|
||||
LocalRegAVM2Item lr = (LocalRegAVM2Item) value;
|
||||
String slotNameStr = slotname.getName(localData.getConstants(), localData.fullyQualifiedNames, true, true);
|
||||
String slotNameStr = slotname.getName(localData.abc, localData.getConstants(), localData.fullyQualifiedNames, true, true);
|
||||
if (localData.localRegNames.containsKey(lr.regIndex)) {
|
||||
if (localData.localRegNames.get(lr.regIndex).equals(slotNameStr)) {
|
||||
return; //Register with same name to slot
|
||||
@@ -150,7 +150,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst tsc = (TraitSlotConst) t;
|
||||
if (tsc.slot_id == slotIndex) {
|
||||
slotType = AbcIndexing.multinameToType(tsc.type_index, localData.abc.constants);
|
||||
slotType = AbcIndexing.multinameToType(tsc.type_index, localData.abc, localData.abc.constants);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -68,11 +68,11 @@ public class ConvertMIns extends InstructionDefinition implements CoerceOrConver
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins)));
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.DECIMAL);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -69,11 +69,11 @@ public class ConvertMPIns extends InstructionDefinition implements CoerceOrConve
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins)));
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.DECIMAL);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class CoerceBIns extends InstructionDefinition implements CoerceOrConvert
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.BOOLEAN);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class CoerceDIns extends InstructionDefinition implements CoerceOrConvert
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.NUMBER);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class CoerceIIns extends InstructionDefinition implements CoerceOrConvert
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.INT);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class CoerceUIns extends InstructionDefinition implements CoerceOrConvert
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.UINT);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -78,11 +78,11 @@ public class ConvertF4Ins extends InstructionDefinition implements CoerceOrConve
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins)));
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem("float4");
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -77,11 +77,11 @@ public class ConvertFIns extends InstructionDefinition implements CoerceOrConver
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins)));
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem("float");
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class AsTypeIns extends InstructionDefinition {
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
GraphTargetItem val = stack.pop();
|
||||
|
||||
stack.push(new AsTypeAVM2Item(ins, localData.lineStartInstruction, val, new FullMultinameAVM2Item(false, ins, localData.lineStartInstruction, ins.operands[0], localData.abc.constants.getMultiname(ins.operands[0]).getName(localData.getConstants(), new ArrayList<>(), true, true))));
|
||||
stack.push(new AsTypeAVM2Item(ins, localData.lineStartInstruction, val, new FullMultinameAVM2Item(false, ins, localData.lineStartInstruction, ins.operands[0], localData.abc.constants.getMultiname(ins.operands[0]).getName(localData.abc, localData.getConstants(), new ArrayList<>(), true, true))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -50,7 +50,7 @@ public class CoerceAIns extends InstructionDefinition implements CoerceOrConvert
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new CoerceAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins)));
|
||||
stack.push(new CoerceAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins)));
|
||||
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class CoerceAIns extends InstructionDefinition implements CoerceOrConvert
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return TypeItem.UNBOUNDED;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -84,7 +84,7 @@ public class CoerceIns extends InstructionDefinition implements CoerceOrConvertT
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
stack.push(new CoerceAVM2Item(ins, localData.lineStartInstruction, stack.pop(), AbcIndexing.multinameToType(multinameIndex, localData.getConstants())));
|
||||
stack.push(new CoerceAVM2Item(ins, localData.lineStartInstruction, stack.pop(), AbcIndexing.multinameToType(multinameIndex, localData.abc, localData.getConstants())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,8 +98,8 @@ public class CoerceIns extends InstructionDefinition implements CoerceOrConvertT
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
return AbcIndexing.multinameToType(multinameIndex, constants);
|
||||
return AbcIndexing.multinameToType(multinameIndex, abc, constants);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class CoerceOIns extends InstructionDefinition implements CoerceOrConvert
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.OBJECT);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
@@ -30,9 +31,10 @@ public interface CoerceOrConvertTypeIns {
|
||||
/**
|
||||
* Get target type of coercing or converting.
|
||||
*
|
||||
* @param abc ABC
|
||||
* @param constants Constants
|
||||
* @param ins Instruction
|
||||
* @return Target type
|
||||
*/
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins);
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins);
|
||||
}
|
||||
|
||||
+2
-2
@@ -64,7 +64,7 @@ public class CoerceSIns extends InstructionDefinition implements CoerceOrConvert
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new CoerceAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins)));
|
||||
stack.push(new CoerceAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,7 +78,7 @@ public class CoerceSIns extends InstructionDefinition implements CoerceOrConvert
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.STRING);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ public class ConvertBIns extends InstructionDefinition implements CoerceOrConver
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins)));
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,7 +67,7 @@ public class ConvertBIns extends InstructionDefinition implements CoerceOrConver
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.BOOLEAN);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ public class ConvertDIns extends InstructionDefinition implements CoerceOrConver
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins)));
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,7 +67,7 @@ public class ConvertDIns extends InstructionDefinition implements CoerceOrConver
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.NUMBER);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ public class ConvertIIns extends InstructionDefinition implements CoerceOrConver
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins)));
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,7 +67,7 @@ public class ConvertIIns extends InstructionDefinition implements CoerceOrConver
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.INT);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ public class ConvertOIns extends InstructionDefinition implements CoerceOrConver
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins)));
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,7 +77,7 @@ public class ConvertOIns extends InstructionDefinition implements CoerceOrConver
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.OBJECT);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ public class ConvertSIns extends InstructionDefinition implements CoerceOrConver
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins)));
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,7 +67,7 @@ public class ConvertSIns extends InstructionDefinition implements CoerceOrConver
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.STRING);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ public class ConvertUIns extends InstructionDefinition implements CoerceOrConver
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins)));
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.abc, localData.getConstants(), ins)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,7 +67,7 @@ public class ConvertUIns extends InstructionDefinition implements CoerceOrConver
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
public GraphTargetItem getTargetType(ABC abc, AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.UINT);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class IsTypeIns extends InstructionDefinition {
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
GraphTargetItem value = stack.pop();
|
||||
stack.push(new IsTypeAVM2Item(ins, localData.lineStartInstruction, value, new FullMultinameAVM2Item(false, ins, localData.lineStartInstruction, multinameIndex, localData.abc.constants.getMultiname(multinameIndex).getName(localData.getConstants(), new ArrayList<>(), true, true))));
|
||||
stack.push(new IsTypeAVM2Item(ins, localData.lineStartInstruction, value, new FullMultinameAVM2Item(false, ins, localData.lineStartInstruction, multinameIndex, localData.abc.constants.getMultiname(multinameIndex).getName(localData.abc, localData.getConstants(), new ArrayList<>(), true, true))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2GraphTargetDialect;
|
||||
@@ -193,13 +194,14 @@ public abstract class AVM2Item extends GraphTargetItem {
|
||||
|
||||
/**
|
||||
* Gets local register name.
|
||||
* @param swf SWF
|
||||
* @param localRegNames Local register names
|
||||
* @param reg Register
|
||||
* @return Local register name
|
||||
*/
|
||||
public static String localRegName(HashMap<Integer, String> localRegNames, int reg) {
|
||||
public static String localRegName(SWF swf, HashMap<Integer, String> localRegNames, int reg) {
|
||||
if (localRegNames.containsKey(reg)) {
|
||||
return IdentifiersDeobfuscation.printIdentifier(true, localRegNames.get(reg));
|
||||
return IdentifiersDeobfuscation.printIdentifier(swf, true, localRegNames.get(reg));
|
||||
} else {
|
||||
if (reg == 0) {
|
||||
return "this";
|
||||
|
||||
@@ -65,11 +65,11 @@ public class ClassAVM2Item extends AVM2Item {
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
if (classNameAsStr != null) {
|
||||
if (localData.fullyQualifiedNames != null && localData.fullyQualifiedNames.contains(classNameAsStr)) {
|
||||
return writer.append(classNameAsStr.toPrintableString(true));
|
||||
return writer.append(classNameAsStr.toPrintableString(localData.swf, true));
|
||||
}
|
||||
return writer.append(IdentifiersDeobfuscation.printIdentifier(true, classNameAsStr.getLast()));
|
||||
return writer.append(IdentifiersDeobfuscation.printIdentifier(localData.abc.getSwf(), true, classNameAsStr.getLast()));
|
||||
}
|
||||
return writer.append(className.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true));
|
||||
return writer.append(className.getName(localData.abc, localData.constantsAvm2, localData.fullyQualifiedNames, false, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class DecLocalAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append(localRegName(localData.localRegNames, regIndex));
|
||||
writer.append(localRegName(localData.abc.getSwf(), localData.localRegNames, regIndex));
|
||||
return writer.append("--");
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class FindDefAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
return writer.append(propertyName.getNamespace(localData.constantsAvm2).getName(localData.constantsAvm2).toPrintableString(true)); //assume not null name
|
||||
return writer.append(propertyName.getNamespace(localData.constantsAvm2).getName(localData.constantsAvm2).toPrintableString(localData.swf, true)); //assume not null name
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-4
@@ -156,7 +156,7 @@ public class FullMultinameAVM2Item extends AVM2Item {
|
||||
if (name != null) {
|
||||
cname = name.toString(LocalData.create(new ArrayList<>(), null, abc, localRegNames, fullyQualifiedNames, seenMethods, ScriptExportMode.AS, -1));
|
||||
} else {
|
||||
cname = (abc.constants.getMultiname(multinameIndex).getName(abc.constants, fullyQualifiedNames, true, true));
|
||||
cname = (abc.constants.getMultiname(multinameIndex).getName(abc, abc.constants, fullyQualifiedNames, true, true));
|
||||
}
|
||||
String cns = "";
|
||||
if (namespace != null) {
|
||||
@@ -164,7 +164,7 @@ public class FullMultinameAVM2Item extends AVM2Item {
|
||||
} else {
|
||||
Namespace ns = abc.constants.getMultiname(multinameIndex).getNamespace(abc.constants);
|
||||
if ((ns != null) && (ns.name_index != 0)) {
|
||||
cns = ns.getName(abc.constants).toPrintableString(true);
|
||||
cns = ns.getName(abc.constants).toPrintableString(abc.getSwf(), true);
|
||||
}
|
||||
}
|
||||
return cname.equals(tname) && cns.isEmpty();
|
||||
@@ -206,7 +206,7 @@ public class FullMultinameAVM2Item extends AVM2Item {
|
||||
AVM2ConstantPool constants = localData.constantsAvm2;
|
||||
List<DottedChain> fullyQualifiedNames = property ? new ArrayList<>() : localData.fullyQualifiedNames;
|
||||
if (multinameIndex > 0 && multinameIndex < constants.getMultinameCount()) {
|
||||
String simpleName = constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames, true, false);
|
||||
String simpleName = constants.getMultiname(multinameIndex).getName(localData.abc, constants, fullyQualifiedNames, true, false);
|
||||
if ("*".equals(simpleName)) {
|
||||
writer.append("*");
|
||||
} else {
|
||||
@@ -215,7 +215,7 @@ public class FullMultinameAVM2Item extends AVM2Item {
|
||||
DottedChain customNs = customNsRef.getVal();
|
||||
if (customNs != null) {
|
||||
String nsname = customNs.getLast();
|
||||
String identifier = IdentifiersDeobfuscation.printIdentifier(true, nsname);
|
||||
String identifier = IdentifiersDeobfuscation.printIdentifier(localData.abc.getSwf(), true, nsname);
|
||||
writer.hilightSpecial(identifier, HighlightSpecialType.TYPE_NAME, customNs.toRawString());
|
||||
writer.appendNoHilight("::");
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
@@ -65,17 +66,18 @@ public class GetLexAVM2Item extends AVM2Item {
|
||||
* @param instruction Instruction
|
||||
* @param lineStartIns Line start instruction
|
||||
* @param propertyName Property name
|
||||
* @param abc ABC
|
||||
* @param constants Constants
|
||||
* @param type Type
|
||||
* @param callType Call type
|
||||
* @param isStatic Is static
|
||||
*/
|
||||
public GetLexAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Multiname propertyName, AVM2ConstantPool constants, GraphTargetItem type, GraphTargetItem callType, boolean isStatic) {
|
||||
public GetLexAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Multiname propertyName, ABC abc, AVM2ConstantPool constants, GraphTargetItem type, GraphTargetItem callType, boolean isStatic) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_PRIMARY);
|
||||
this.propertyName = propertyName;
|
||||
this.type = type;
|
||||
this.callType = callType;
|
||||
this.fullPropertyName = propertyName.getNameWithNamespace(constants, true);
|
||||
this.fullPropertyName = propertyName.getNameWithNamespace(abc, constants, true);
|
||||
this.isStatic = isStatic;
|
||||
}
|
||||
|
||||
@@ -94,7 +96,7 @@ public class GetLexAVM2Item extends AVM2Item {
|
||||
DottedChain customNs = customNsRef.getVal();
|
||||
if (customNs != null) {
|
||||
String nsname = customNs.getLast();
|
||||
String identifier = IdentifiersDeobfuscation.printIdentifier(true, nsname);
|
||||
String identifier = IdentifiersDeobfuscation.printIdentifier(localData.abc.getSwf(), true, nsname);
|
||||
writer.hilightSpecial(identifier, HighlightSpecialType.TYPE_NAME, customNs.toRawString());
|
||||
writer.appendNoHilight("::");
|
||||
getSrcData().localName = nsname + "::" + localName;
|
||||
|
||||
@@ -93,7 +93,7 @@ public class GetSlotAVM2Item extends AVM2Item {
|
||||
if (slotName == null) {
|
||||
return slotObject.toString(localData) + ".§§slot[" + slotIndex + "]";
|
||||
}
|
||||
return slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true);
|
||||
return slotName.getName(localData.abc, localData.constantsAvm2, localData.fullyQualifiedNames, false, true);
|
||||
}
|
||||
|
||||
public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class IncLocalAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
writer.append(localRegName(localData.localRegNames, regIndex));
|
||||
writer.append(localRegName(localData.abc.getSwf(), localData.localRegNames, regIndex));
|
||||
return writer.append("++");
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ public class LocalRegAVM2Item extends AVM2Item {
|
||||
return computedValue.toString(writer, localData);
|
||||
}
|
||||
|
||||
String localName = localRegName(localData.localRegNames, regIndex);
|
||||
String localName = localRegName(localData.abc.getSwf(), localData.localRegNames, regIndex);
|
||||
getSrcData().localName = localName;
|
||||
return writer.append(localName);
|
||||
}
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class NameSpaceAVM2Item extends AVM2Item {
|
||||
String nsname = dc != null ? dc.getLast() : null;
|
||||
|
||||
if (nsname != null) {
|
||||
String identifier = IdentifiersDeobfuscation.printIdentifier(true, nsname);
|
||||
String identifier = IdentifiersDeobfuscation.printIdentifier(localData.abc.getSwf(), true, nsname);
|
||||
if (identifier != null && !identifier.isEmpty()) {
|
||||
writer.append(identifier);
|
||||
return writer;
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ public class NewFunctionAVM2Item extends AVM2Item {
|
||||
writer.appendNoHilight(methodIndex);
|
||||
writer.newLine();
|
||||
}
|
||||
abc.method_info.get(methodIndex).getReturnTypeStr(writer, abc.constants, localData.fullyQualifiedNames);
|
||||
abc.method_info.get(methodIndex).getReturnTypeStr(writer, abc, abc.constants, localData.fullyQualifiedNames);
|
||||
writer.startBlock();
|
||||
if (body != null) {
|
||||
List<MethodBody> callStack = new ArrayList<>(localData.callStack);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class PackageAVM2Item extends AVM2Item {
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.appendNoHilight("package");
|
||||
if (!packageName.isEmpty()) {
|
||||
writer.appendNoHilight(" " + DottedChain.parseWithSuffix(packageName).toPrintableString(true));
|
||||
writer.appendNoHilight(" " + DottedChain.parseWithSuffix(packageName).toPrintableString(localData.swf, true));
|
||||
}
|
||||
writer.startBlock();
|
||||
Graph.graphToString(items, writer, localData);
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ public class SetLocalAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assig
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
String localName = localRegName(localData.localRegNames, regIndex);
|
||||
String localName = localRegName(localData.abc.getSwf(), localData.localRegNames, regIndex);
|
||||
getSrcData().localName = localName;
|
||||
writer.append(localName);
|
||||
if (hideValue) {
|
||||
|
||||
@@ -152,7 +152,7 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign
|
||||
if (slotName == null) {
|
||||
return slotObject.toString(localData) + ".§§slot[" + slotIndex + "]";
|
||||
}
|
||||
return slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true);
|
||||
return slotName.getName(localData.abc, localData.constantsAvm2, localData.fullyQualifiedNames, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -114,9 +114,9 @@ public class ThisAVM2Item extends AVM2Item {
|
||||
if (showClassName) {
|
||||
if (className != null) {
|
||||
if (localData.fullyQualifiedNames != null && localData.fullyQualifiedNames.contains(className)) {
|
||||
return writer.append(className.toPrintableString(true)).append(".this");
|
||||
return writer.append(className.toPrintableString(localData.swf, true)).append(".this");
|
||||
}
|
||||
return writer.append(IdentifiersDeobfuscation.printIdentifier(true, className.getLast())).append(".this");
|
||||
return writer.append(IdentifiersDeobfuscation.printIdentifier(localData.abc.getSwf(), true, className.getLast())).append(".this");
|
||||
}
|
||||
}
|
||||
return writer.append("this");
|
||||
|
||||
+3
-3
@@ -92,7 +92,7 @@ public class DeclarationAVM2Item extends AVM2Item {
|
||||
|
||||
if (assignment instanceof LocalRegAVM2Item) { //for..in
|
||||
LocalRegAVM2Item lti = (LocalRegAVM2Item) assignment;
|
||||
String localName = localRegName(localData.localRegNames, lti.regIndex);
|
||||
String localName = localRegName(localData.abc.getSwf(), localData.localRegNames, lti.regIndex);
|
||||
HighlightData srcData = getSrcData();
|
||||
srcData.localName = localName;
|
||||
srcData.declaration = true;
|
||||
@@ -116,7 +116,7 @@ public class DeclarationAVM2Item extends AVM2Item {
|
||||
|
||||
if (assignment instanceof SetLocalAVM2Item) {
|
||||
SetLocalAVM2Item lti = (SetLocalAVM2Item) assignment;
|
||||
String localName = localRegName(localData.localRegNames, lti.regIndex);
|
||||
String localName = localRegName(localData.abc.getSwf(), localData.localRegNames, lti.regIndex);
|
||||
HighlightData srcData = getSrcData();
|
||||
srcData.localName = localName;
|
||||
srcData.declaration = true;
|
||||
@@ -163,7 +163,7 @@ public class DeclarationAVM2Item extends AVM2Item {
|
||||
GraphTargetItem val = spti.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(IdentifiersDeobfuscation.printIdentifier(localData.abc.getSwf(), true, ((FullMultinameAVM2Item) spti.propertyName).resolvedMultinameName));
|
||||
writer.append(":");
|
||||
|
||||
type.appendTry(writer, localData);
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class ExceptionAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
return writer.append(exception.getVarName(localData.constantsAvm2, localData.fullyQualifiedNames));
|
||||
return writer.append(exception.getVarName(localData.abc, localData.constantsAvm2, localData.fullyQualifiedNames));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -142,7 +142,7 @@ public class TryAVM2Item extends AVM2Item implements Block {
|
||||
for (int e = 0; e < catchExceptions.size(); e++) {
|
||||
writer.newLine();
|
||||
writer.append("catch(");
|
||||
String localName = catchExceptions.get(e).getVarName(localData.constantsAvm2, localData.fullyQualifiedNames);
|
||||
String localName = catchExceptions.get(e).getVarName(localData.abc, localData.constantsAvm2, localData.fullyQualifiedNames);
|
||||
if (localName.isEmpty()) {
|
||||
localName = finCatchName;
|
||||
}
|
||||
@@ -153,10 +153,10 @@ public class TryAVM2Item extends AVM2Item implements Block {
|
||||
|
||||
int eti = catchExceptions.get(e).type_index;
|
||||
|
||||
data.declaredType = eti <= 0 ? DottedChain.ALL : localData.constantsAvm2.getMultiname(eti).getNameWithNamespace(localData.constantsAvm2, true);
|
||||
data.declaredType = eti <= 0 ? DottedChain.ALL : localData.constantsAvm2.getMultiname(eti).getNameWithNamespace(localData.abc, localData.constantsAvm2, true);
|
||||
writer.hilightSpecial(localName, HighlightSpecialType.TRY_NAME, e, data);
|
||||
writer.append(":");
|
||||
writer.hilightSpecial(catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames), HighlightSpecialType.TRY_TYPE, e);
|
||||
writer.hilightSpecial(catchExceptions.get(e).getTypeName(localData.abc, localData.constantsAvm2, localData.fullyQualifiedNames), HighlightSpecialType.TRY_TYPE, e);
|
||||
writer.append(")");
|
||||
List<GraphTargetItem> commands = catchCommands.get(e);
|
||||
appendBlock(null, writer, localData, commands);
|
||||
|
||||
+14
-14
@@ -231,7 +231,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
Multiname m = ci.abc.instance_info.get(ci.index).getName(ci.abc.constants);
|
||||
if (m != null) {
|
||||
Namespace ns = ci.abc.instance_info.get(ci.index).getName(ci.abc.constants).getNamespace(ci.abc.constants);
|
||||
String n = m.getName(ci.abc.constants, new ArrayList<>(), true, true /*FIXME!!*/);
|
||||
String n = m.getName(ci.abc, ci.abc.constants, new ArrayList<>(), true, true /*FIXME!!*/);
|
||||
String nsn = ns == null ? null : ns.getRawName(ci.abc.constants);
|
||||
name_index = constants.getQnameId(
|
||||
n,
|
||||
@@ -253,7 +253,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
if (name_index == 0) {
|
||||
if (pkg.isEmpty() && localData.currentScript != null /*FIXME!*/) {
|
||||
for (Trait t : localData.currentScript.traits.traits) {
|
||||
if (t.getName(abc).getName(constants, null, true, true /*FIXME!!*/).equals(name)) {
|
||||
if (t.getName(abc).getName(abc, constants, null, true, true /*FIXME!!*/).equals(name)) {
|
||||
name_index = t.name_index;
|
||||
break;
|
||||
}
|
||||
@@ -727,7 +727,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst tsc = (TraitSlotConst) t;
|
||||
if (tsc.kindType == Trait.TRAIT_SLOT) {
|
||||
if ("_skinParts".equals(tsc.getName(ci.abc).getName(ci.abc.constants, new ArrayList<>(), true, true))) {
|
||||
if ("_skinParts".equals(tsc.getName(ci.abc).getName(ci.abc, ci.abc.constants, new ArrayList<>(), true, true))) {
|
||||
if (d.assignedValues.containsKey(tsc)) {
|
||||
if (d.assignedValues.get(tsc).value instanceof NewObjectAVM2Item) {
|
||||
NewObjectAVM2Item no = (NewObjectAVM2Item) d.assignedValues.get(tsc).value;
|
||||
@@ -1812,7 +1812,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
instanceInfo.super_index = abcIndex.getSelectedAbc().constants.getMultinameId(Multiname.createQName(false, str("Object"), namespace(Namespace.KIND_PACKAGE, "")), true);
|
||||
}
|
||||
if (instanceInfo.super_index != 0) {
|
||||
int foundClass = abc.findClassByName(abc.constants.getMultiname(instanceInfo.super_index).getNameWithNamespace(abc.constants, true));
|
||||
int foundClass = abc.findClassByName(abc.constants.getMultiname(instanceInfo.super_index).getNameWithNamespace(abc, abc.constants, true));
|
||||
if (foundClass > -1) {
|
||||
if (foundClass > minClassIndex) {
|
||||
minClassIndex = foundClass;
|
||||
@@ -1822,7 +1822,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
instanceInfo.interfaces = new int[((ClassAVM2Item) item).implementsOp.size()];
|
||||
for (int i = 0; i < ((ClassAVM2Item) item).implementsOp.size(); i++) {
|
||||
instanceInfo.interfaces[i] = superIntName(localData, ((ClassAVM2Item) item).implementsOp.get(i));
|
||||
int foundIface = abc.findClassByName(abc.constants.getMultiname(instanceInfo.interfaces[i]).getNameWithNamespace(abc.constants, true));
|
||||
int foundIface = abc.findClassByName(abc.constants.getMultiname(instanceInfo.interfaces[i]).getNameWithNamespace(abc, abc.constants, true));
|
||||
if (foundIface > -1) {
|
||||
if (foundIface > minClassIndex) {
|
||||
minClassIndex = foundIface;
|
||||
@@ -1845,7 +1845,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
GraphTargetItem un = ((InterfaceAVM2Item) item).superInterfaces.get(i);
|
||||
instanceInfo.interfaces[i] = superIntName(localData, un);
|
||||
|
||||
int foundIface = abc.findClassByName(abc.constants.getMultiname(instanceInfo.interfaces[i]).getNameWithNamespace(abc.constants, true));
|
||||
int foundIface = abc.findClassByName(abc.constants.getMultiname(instanceInfo.interfaces[i]).getNameWithNamespace(abc, abc.constants, true));
|
||||
if (foundIface > -1) {
|
||||
if (foundIface > minClassIndex) {
|
||||
minClassIndex = foundIface;
|
||||
@@ -2342,7 +2342,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
for (Trait t : scriptInfo.traits.traits) {
|
||||
if (t instanceof TraitClass) {
|
||||
TraitClass tc = (TraitClass) t;
|
||||
DottedChain className = tc.getName(abc).getNameWithNamespace(abc.constants, true);
|
||||
DottedChain className = tc.getName(abc).getNameWithNamespace(abc, abc.constants, true);
|
||||
|
||||
List<Integer> parents = new ArrayList<>();
|
||||
if (documentClass != null && documentClass.equals(className)) {
|
||||
@@ -2356,7 +2356,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
sinitcode.add(ins(AVM2Instructions.PushNull));
|
||||
} else {
|
||||
|
||||
AbcIndexing.ClassIndex ci = abcIndex.findClass(AbcIndexing.multinameToType(abc.instance_info.get(tc.class_info).name_index, constants), abc, scriptIndex);
|
||||
AbcIndexing.ClassIndex ci = abcIndex.findClass(AbcIndexing.multinameToType(abc.instance_info.get(tc.class_info).name_index, abc, constants), abc, scriptIndex);
|
||||
while (ci != null && ci.parent != null) {
|
||||
ci = ci.parent;
|
||||
Multiname origM = ci.abc.constants.getMultiname(ci.abc.instance_info.get(ci.index).name_index);
|
||||
@@ -2430,7 +2430,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
indices.add(
|
||||
abc.getSelectedAbc().constants.getMultinameId(
|
||||
Multiname.createQName(false,
|
||||
abc.getSelectedAbc().constants.getStringId(superName.getName(a.constants, null, true, true /*FIXME!!! ???*/), true),
|
||||
abc.getSelectedAbc().constants.getStringId(superName.getName(a, a.constants, null, true, true /*FIXME!!! ???*/), true),
|
||||
abc.getSelectedAbc().constants.getNamespaceId(superName.getNamespace(a.constants).kind, superName.getNamespace(a.constants).getName(a.constants), 0, true)), true)
|
||||
);
|
||||
}
|
||||
@@ -2449,16 +2449,16 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
if (tsc.type_index == 0) {
|
||||
return TypeItem.UNBOUNDED;
|
||||
}
|
||||
return AbcIndexing.multinameToType(tsc.type_index, abc.getSelectedAbc().constants);
|
||||
return AbcIndexing.multinameToType(tsc.type_index, abc.getSelectedAbc(), abc.getSelectedAbc().constants);
|
||||
}
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter tmgs = (TraitMethodGetterSetter) t;
|
||||
if (tmgs.kindType == Trait.TRAIT_GETTER) {
|
||||
return AbcIndexing.multinameToType(abc.getSelectedAbc().method_info.get(tmgs.method_info).ret_type, abc.getSelectedAbc().constants);
|
||||
return AbcIndexing.multinameToType(abc.getSelectedAbc().method_info.get(tmgs.method_info).ret_type, abc.getSelectedAbc(), abc.getSelectedAbc().constants);
|
||||
}
|
||||
if (tmgs.kindType == Trait.TRAIT_SETTER) {
|
||||
if (abc.getSelectedAbc().method_info.get(tmgs.method_info).param_types.length > 0) {
|
||||
return AbcIndexing.multinameToType(abc.getSelectedAbc().method_info.get(tmgs.method_info).param_types[0], abc.getSelectedAbc().constants);
|
||||
return AbcIndexing.multinameToType(abc.getSelectedAbc().method_info.get(tmgs.method_info).param_types[0], abc.getSelectedAbc(), abc.getSelectedAbc().constants);
|
||||
} else {
|
||||
return TypeItem.UNBOUNDED;
|
||||
}
|
||||
@@ -2557,12 +2557,12 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
* @param outABCs Out ABCs
|
||||
*/
|
||||
public static void parentNames(AbcIndexing abc, int scriptIndex, int name_index, List<Integer> indices, List<String> names, List<String> namespaces, List<ABC> outABCs) {
|
||||
AbcIndexing.ClassIndex ci = abc.findClass(new TypeItem(abc.getSelectedAbc().constants.getMultiname(name_index).getNameWithNamespace(abc.getSelectedAbc().constants, true /*FIXME!!*/)), abc.getSelectedAbc(), scriptIndex);
|
||||
AbcIndexing.ClassIndex ci = abc.findClass(new TypeItem(abc.getSelectedAbc().constants.getMultiname(name_index).getNameWithNamespace(abc.getSelectedAbc(), abc.getSelectedAbc().constants, true /*FIXME!!*/)), abc.getSelectedAbc(), scriptIndex);
|
||||
while (ci != null) {
|
||||
int ni = ci.abc.instance_info.get(ci.index).name_index;
|
||||
indices.add(ni);
|
||||
outABCs.add(ci.abc);
|
||||
names.add(ci.abc.constants.getMultiname(ni).getName(ci.abc.constants, null, true, true/*FIXME!!*/));
|
||||
names.add(ci.abc.constants.getMultiname(ni).getName(ci.abc, ci.abc.constants, null, true, true/*FIXME!!*/));
|
||||
namespaces.add(ci.abc.constants.getMultiname(ni).getNamespace(ci.abc.constants).getName(ci.abc.constants).toRawString());
|
||||
ci = ci.parent;
|
||||
}
|
||||
|
||||
+22
-21
@@ -512,7 +512,7 @@ public final class AbcIndexing {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return abc.constants.getMultiname(abc.instance_info.get(index).name_index).getNameWithNamespace(abc.constants, true).toPrintableString(true);
|
||||
return abc.constants.getMultiname(abc.instance_info.get(index).name_index).getNameWithNamespace(abc, abc.constants, true).toPrintableString(abc.getSwf(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -627,7 +627,7 @@ public final class AbcIndexing {
|
||||
}
|
||||
|
||||
private void getClassIndexTraitNames(List<PropertyDef> ret, List<Boolean> staticRet, ClassIndex ci, boolean getStatic, boolean getInstance, boolean getInheritance, Set<String> used) {
|
||||
GraphTargetItem ciName = multinameToType(ci.abc.instance_info.get(ci.index).name_index, ci.abc.constants);
|
||||
GraphTargetItem ciName = multinameToType(ci.abc.instance_info.get(ci.index).name_index, ci.abc, ci.abc.constants);
|
||||
|
||||
boolean isObject = ciName.equals(new TypeItem("Object"));
|
||||
List<String> ignoredObjectTraits = Arrays.asList("_init", "_dontEnumPrototype", "_setPropertyIsEnumerable");
|
||||
@@ -890,7 +890,7 @@ public final class AbcIndexing {
|
||||
AbcIndexing.ClassIndex ci = findClass(prop.parent, prop.abc, null);
|
||||
if (ci != null && ci.parent != null && (prop.abc == null || prop.propNsIndex == 0)) {
|
||||
AbcIndexing.ClassIndex ciParent = ci.parent;
|
||||
DottedChain parentClass = ciParent.abc.instance_info.get(ciParent.index).getName(ciParent.abc.constants).getNameWithNamespace(ciParent.abc.constants, true);
|
||||
DottedChain parentClass = ciParent.abc.instance_info.get(ciParent.index).getName(ciParent.abc.constants).getNameWithNamespace(ciParent.abc, ciParent.abc.constants, true);
|
||||
TraitIndex pti = findProperty(new PropertyDef(prop.propName, new TypeItem(parentClass), prop.getPropNsString()), findStatic, findInstance, findProtected, foundStatic);
|
||||
if (pti != null) {
|
||||
return pti;
|
||||
@@ -920,10 +920,11 @@ public final class AbcIndexing {
|
||||
/**
|
||||
* Converts multiname to type
|
||||
* @param m_index Multiname index
|
||||
* @param abc ABC
|
||||
* @param constants AVM2 constant pool
|
||||
* @return Type
|
||||
*/
|
||||
public static GraphTargetItem multinameToType(int m_index, AVM2ConstantPool constants) {
|
||||
public static GraphTargetItem multinameToType(int m_index, ABC abc, AVM2ConstantPool constants) {
|
||||
if (m_index == 0) {
|
||||
return TypeItem.UNBOUNDED;
|
||||
}
|
||||
@@ -932,13 +933,13 @@ public final class AbcIndexing {
|
||||
return null;
|
||||
}
|
||||
if (m.kind == Multiname.TYPENAME) {
|
||||
GraphTargetItem obj = multinameToType(m.qname_index, constants);
|
||||
GraphTargetItem obj = multinameToType(m.qname_index, abc, constants);
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
List<GraphTargetItem> params = new ArrayList<>();
|
||||
for (int pm : m.params) {
|
||||
GraphTargetItem r = multinameToType(pm, constants);
|
||||
GraphTargetItem r = multinameToType(pm, abc, constants);
|
||||
if (r == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -950,9 +951,9 @@ public final class AbcIndexing {
|
||||
return new ApplyTypeAVM2Item(null, null, obj, params);
|
||||
} else {
|
||||
if (m.namespace_index != 0 && m.getNamespace(constants).kind == Namespace.KIND_PRIVATE) {
|
||||
return new TypeItem(m.getName(constants, new ArrayList<>(), true, true), "ns:" + m.namespace_index);
|
||||
return new TypeItem(m.getName(abc, constants, new ArrayList<>(), true, true), "ns:" + m.namespace_index);
|
||||
}
|
||||
return new TypeItem(m.getNameWithNamespace(constants, true));
|
||||
return new TypeItem(m.getNameWithNamespace(abc, constants, true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -968,12 +969,12 @@ public final class AbcIndexing {
|
||||
if (tmgs.kindType == Trait.TRAIT_SETTER) {
|
||||
return TypeItem.UNBOUNDED;
|
||||
}
|
||||
return multinameToType(abc.method_info.get(tmgs.method_info).ret_type, abc.constants);
|
||||
return multinameToType(abc.method_info.get(tmgs.method_info).ret_type, abc, abc.constants);
|
||||
}
|
||||
|
||||
if (t instanceof TraitFunction) {
|
||||
TraitFunction tf = (TraitFunction) t;
|
||||
return multinameToType(abc.method_info.get(tf.method_info).ret_type, abc.constants);
|
||||
return multinameToType(abc.method_info.get(tf.method_info).ret_type, abc, abc.constants);
|
||||
|
||||
}
|
||||
return TypeItem.UNBOUNDED;
|
||||
@@ -985,16 +986,16 @@ public final class AbcIndexing {
|
||||
if (tsc.type_index == 0) {
|
||||
return TypeItem.UNBOUNDED;
|
||||
}
|
||||
return multinameToType(tsc.type_index, abc.constants);
|
||||
return multinameToType(tsc.type_index, abc, abc.constants);
|
||||
}
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter tmgs = (TraitMethodGetterSetter) t;
|
||||
if (tmgs.kindType == Trait.TRAIT_GETTER) {
|
||||
return multinameToType(abc.method_info.get(tmgs.method_info).ret_type, abc.constants);
|
||||
return multinameToType(abc.method_info.get(tmgs.method_info).ret_type, abc, abc.constants);
|
||||
}
|
||||
if (tmgs.kindType == Trait.TRAIT_SETTER) {
|
||||
if (abc.method_info.get(tmgs.method_info).param_types.length > 0) {
|
||||
return multinameToType(abc.method_info.get(tmgs.method_info).param_types[0], abc.constants);
|
||||
return multinameToType(abc.method_info.get(tmgs.method_info).param_types[0], abc, abc.constants);
|
||||
} else {
|
||||
return TypeItem.UNBOUNDED;
|
||||
}
|
||||
@@ -1025,13 +1026,13 @@ public final class AbcIndexing {
|
||||
propValue = new ValueKind(tsc.value_index, tsc.value_kind);
|
||||
}
|
||||
if (map != null) {
|
||||
PropertyDef dp = new PropertyDef(t.getName(abc).getName(abc.constants, new ArrayList<>() /*?*/, true, false), multinameToType(name_index, abc.constants), abc, abc.constants.getMultiname(t.name_index).namespace_index);
|
||||
map.put(dp, new TraitIndex(t, abc, getTraitReturnType(abc, t), getTraitCallReturnType(abc, t), propValue, multinameToType(name_index, abc.constants), scriptIndex));
|
||||
PropertyDef dp = new PropertyDef(t.getName(abc).getName(abc, abc.constants, new ArrayList<>() /*?*/, true, false), multinameToType(name_index, abc, abc.constants), abc, abc.constants.getMultiname(t.name_index).namespace_index);
|
||||
map.put(dp, new TraitIndex(t, abc, getTraitReturnType(abc, t), getTraitCallReturnType(abc, t), propValue, multinameToType(name_index, abc, abc.constants), scriptIndex));
|
||||
}
|
||||
if (mapNs != null) {
|
||||
Multiname m = abc.constants.getMultiname(t.name_index);
|
||||
PropertyNsDef ndp = new PropertyNsDef(t.getName(abc).getName(abc.constants, new ArrayList<>() /*?*/, true, true/*FIXME ???*/), m == null || m.namespace_index == 0 ? DottedChain.EMPTY : m.getNamespace(abc.constants).getName(abc.constants), abc, m == null ? 0 : m.namespace_index);
|
||||
TraitIndex ti = new TraitIndex(t, abc, getTraitReturnType(abc, t), getTraitCallReturnType(abc, t), propValue, multinameToType(name_index, abc.constants), scriptIndex);
|
||||
PropertyNsDef ndp = new PropertyNsDef(t.getName(abc).getName(abc, abc.constants, new ArrayList<>() /*?*/, true, true/*FIXME ???*/), m == null || m.namespace_index == 0 ? DottedChain.EMPTY : m.getNamespace(abc.constants).getName(abc.constants), abc, m == null ? 0 : m.namespace_index);
|
||||
TraitIndex ti = new TraitIndex(t, abc, getTraitReturnType(abc, t), getTraitCallReturnType(abc, t), propValue, multinameToType(name_index, abc, abc.constants), scriptIndex);
|
||||
if (!mapNs.containsKey(ndp)) {
|
||||
mapNs.put(ndp, ti);
|
||||
}
|
||||
@@ -1136,7 +1137,7 @@ public final class AbcIndexing {
|
||||
Integer classScriptIndex = nsKind == Namespace.KIND_PACKAGE ? null : i;
|
||||
ClassIndex cindex = new ClassIndex(tc.class_info, abc, null, classScriptIndex);
|
||||
addedClasses.add(cindex);
|
||||
GraphTargetItem cname = multinameToType(ii.name_index, abc.constants);
|
||||
GraphTargetItem cname = multinameToType(ii.name_index, abc, abc.constants);
|
||||
classes.put(new ClassDef(cname, abc, classScriptIndex), cindex);
|
||||
|
||||
indexTraits(abc, ii.name_index, ii.instance_traits, instanceProperties, instanceNsProperties, i);
|
||||
@@ -1148,7 +1149,7 @@ public final class AbcIndexing {
|
||||
for (ClassIndex cindex : addedClasses) {
|
||||
int parentClassName = abc.instance_info.get(cindex.index).super_index;
|
||||
if (parentClassName > 0) {
|
||||
TypeItem parentClass = new TypeItem(abc.constants.getMultiname(parentClassName).getNameWithNamespace(abc.constants, true));
|
||||
TypeItem parentClass = new TypeItem(abc.constants.getMultiname(parentClassName).getNameWithNamespace(abc, abc.constants, true));
|
||||
ClassIndex parentClassIndex = findClass(parentClass, abc, null);
|
||||
if (parentClassIndex == null) {
|
||||
//Parent class can be deleted, do not check. TODO: handle this better
|
||||
@@ -1210,14 +1211,14 @@ public final class AbcIndexing {
|
||||
* @return True if class is instance of another class
|
||||
*/
|
||||
public boolean isInstanceOf(ABC abc, int classIndex, DottedChain searchClassName) {
|
||||
DottedChain clsName = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants, false);
|
||||
DottedChain clsName = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc, abc.constants, false);
|
||||
if (searchClassName.equals(clsName)) {
|
||||
return true;
|
||||
}
|
||||
if (abc.instance_info.get(classIndex).super_index == 0) {
|
||||
return false;
|
||||
}
|
||||
DottedChain parentClassName = abc.constants.getMultiname(abc.instance_info.get(classIndex).super_index).getNameWithNamespace(abc.constants, false);
|
||||
DottedChain parentClassName = abc.constants.getMultiname(abc.instance_info.get(classIndex).super_index).getNameWithNamespace(abc, abc.constants, false);
|
||||
|
||||
AbcIndexing.ClassIndex ci = findClass(new TypeItem(parentClassName), abc, null);
|
||||
if (ci == null) {
|
||||
|
||||
+1
-1
@@ -178,7 +178,7 @@ public class CallAVM2Item extends AVM2Item {
|
||||
if (mi.param_types[i] == 0) {
|
||||
type = TypeItem.UNBOUNDED;
|
||||
} else {
|
||||
type = new TypeItem(abc.constants.getMultiname(mi.param_types[i]).getNameWithNamespace(abc.constants, true /*??*/));
|
||||
type = new TypeItem(abc.constants.getMultiname(mi.param_types[i]).getNameWithNamespace(abc, abc.constants, true /*??*/));
|
||||
}
|
||||
arguments.set(i, AVM2SourceGenerator.handleAndOrCoerce(arguments.get(i), type));
|
||||
}
|
||||
|
||||
+1
-1
@@ -434,7 +434,7 @@ public class NameAVM2Item extends AssignableAVM2Item {
|
||||
for (MethodBody b : callStack) {
|
||||
for (int i = 0; i < b.traits.traits.size(); i++) {
|
||||
Trait t = b.traits.traits.get(i);
|
||||
if (t.getName(abcV).getName(constants, null, true, true).equals(variableName)) {
|
||||
if (t.getName(abcV).getName(abcV, constants, null, true, true).equals(variableName)) {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
if (!localData.traitUsages.containsKey(b)) {
|
||||
localData.traitUsages.put(b, new ArrayList<>());
|
||||
|
||||
+2
-2
@@ -217,11 +217,11 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
for (MethodBody b : callStack) {
|
||||
for (int i = 0; i < b.traits.traits.size(); i++) {
|
||||
Trait t = b.traits.traits.get(i);
|
||||
if (t.getName(abc).getName(constants, null, true, true).equals(propertyName)) {
|
||||
if (t.getName(abc).getName(abc, constants, null, true, true).equals(propertyName)) {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst tsc = (TraitSlotConst) t;
|
||||
objType = new TypeItem(DottedChain.FUNCTION);
|
||||
propType = AbcIndexing.multinameToType(tsc.type_index, constants);
|
||||
propType = AbcIndexing.multinameToType(tsc.type_index, abc, constants);
|
||||
propIndex = tsc.name_index;
|
||||
if (!localData.traitUsages.containsKey(b)) {
|
||||
localData.traitUsages.put(b, new ArrayList<>());
|
||||
|
||||
+2
-2
@@ -625,7 +625,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
if (ci == null) {
|
||||
ntype = new TypeItem("Object");
|
||||
} else {
|
||||
ntype = new TypeItem(ci.abc.instance_info.get(ci.index).getName(ci.abc.constants).getNameWithNamespace(ci.abc.constants, true));
|
||||
ntype = new TypeItem(ci.abc.instance_info.get(ci.index).getName(ci.abc.constants).getNameWithNamespace(ci.abc, ci.abc.constants, true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -650,7 +650,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
}
|
||||
|
||||
if (mustBeType) {
|
||||
throw new CompilationException(name.toPrintableString(true) + " is not an existing type", line);
|
||||
throw new CompilationException(name.toPrintableString(abcIndex.getSelectedAbc().getSwf(), true) + " is not an existing type", line);
|
||||
}
|
||||
resolved = null;
|
||||
GraphTargetItem ret = null;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConvertException;
|
||||
@@ -78,24 +79,26 @@ public class ABCException implements Serializable, Cloneable {
|
||||
|
||||
/**
|
||||
* To string.
|
||||
* @param ABC abc
|
||||
* @param constants AVM2 constant pool
|
||||
* @param fullyQualifiedNames Fully qualified names
|
||||
* @return String
|
||||
*/
|
||||
public String toString(AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
return "Exception: startServer=" + Helper.formatAddress(start) + " end=" + Helper.formatAddress(end) + " target=" + target + " type=\"" + getTypeName(constants, fullyQualifiedNames) + "\" name=\"" + getVarName(constants, fullyQualifiedNames) + "\"";
|
||||
public String toString(ABC abc, AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
return "Exception: startServer=" + Helper.formatAddress(start) + " end=" + Helper.formatAddress(end) + " target=" + target + " type=\"" + getTypeName(abc, constants, fullyQualifiedNames) + "\" name=\"" + getVarName(abc, constants, fullyQualifiedNames) + "\"";
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
* @param ABC abc
|
||||
* @param constants AVM2 constant pool
|
||||
* @param code AVM2 code
|
||||
* @param fullyQualifiedNames Fully qualified names
|
||||
* @return String
|
||||
*/
|
||||
public String toString(AVM2ConstantPool constants, AVM2Code code, List<DottedChain> fullyQualifiedNames) {
|
||||
public String toString(ABC abc, AVM2ConstantPool constants, AVM2Code code, List<DottedChain> fullyQualifiedNames) {
|
||||
try {
|
||||
return "Exception: startServer=" + code.adr2pos(start) + ":" + code.code.get(code.adr2pos(start)).toStringNoAddress(constants, fullyQualifiedNames) + " end=" + code.adr2pos(end) + ":" + code.code.get(code.adr2pos(end)).toStringNoAddress(constants, fullyQualifiedNames) + " target=" + code.adr2pos(target) + ":" + code.code.get(code.adr2pos(target)).toStringNoAddress(constants, fullyQualifiedNames) + " type=\"" + getTypeName(constants, fullyQualifiedNames) + "\" name=\"" + getVarName(constants, fullyQualifiedNames) + "\"";
|
||||
return "Exception: startServer=" + code.adr2pos(start) + ":" + code.code.get(code.adr2pos(start)).toStringNoAddress(constants, fullyQualifiedNames) + " end=" + code.adr2pos(end) + ":" + code.code.get(code.adr2pos(end)).toStringNoAddress(constants, fullyQualifiedNames) + " target=" + code.adr2pos(target) + ":" + code.code.get(code.adr2pos(target)).toStringNoAddress(constants, fullyQualifiedNames) + " type=\"" + getTypeName(abc, constants, fullyQualifiedNames) + "\" name=\"" + getVarName(abc, constants, fullyQualifiedNames) + "\"";
|
||||
} catch (ConvertException ex) {
|
||||
return "";
|
||||
}
|
||||
@@ -111,28 +114,30 @@ public class ABCException implements Serializable, Cloneable {
|
||||
|
||||
/**
|
||||
* Gets variable name.
|
||||
* @param abc ABC
|
||||
* @param constants AVM2 constant pool
|
||||
* @param fullyQualifiedNames Fully qualified names
|
||||
* @return Variable name
|
||||
*/
|
||||
public String getVarName(AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
public String getVarName(ABC abc, AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
if (name_index == 0) {
|
||||
return DEFAULT_EXCEPTION_NAME;
|
||||
}
|
||||
return constants.getMultiname(name_index).getName(constants, fullyQualifiedNames, false, true);
|
||||
return constants.getMultiname(name_index).getName(abc, constants, fullyQualifiedNames, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets type name.
|
||||
* @param abc ABC
|
||||
* @param constants AVM2 constant pool
|
||||
* @param fullyQualifiedNames Fully qualified names
|
||||
* @return Type name
|
||||
*/
|
||||
public String getTypeName(AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
public String getTypeName(ABC abc, AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
if (type_index == 0) {
|
||||
return "*";
|
||||
}
|
||||
return constants.getMultiname(type_index).getName(constants, fullyQualifiedNames, false, true);
|
||||
return constants.getMultiname(type_index).getName(abc, constants, fullyQualifiedNames, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -169,12 +169,12 @@ public class InstanceInfo {
|
||||
final String ASSETS_DIR = assetsDir; // "/_assets/";
|
||||
if (allowEmbed) {
|
||||
if (abc.getSwf() != null) {
|
||||
String className = getName(abc.constants).getNameWithNamespace(abc.constants, false).toRawString();
|
||||
String className = getName(abc.constants).getNameWithNamespace(abc, abc.constants, false).toRawString();
|
||||
CharacterTag ct = abc.getSwf().getCharacterByClass(className);
|
||||
if (ct != null) {
|
||||
String fileName = ct.getCharacterExportFileName();
|
||||
if (Configuration.as3ExportNamesUseClassNamesOnly.get()) {
|
||||
fileName = getName(abc.constants).getNameWithNamespace(abc.constants, false).toRawString();
|
||||
fileName = getName(abc.constants).getNameWithNamespace(abc, abc.constants, false).toRawString();
|
||||
}
|
||||
|
||||
String ext = "";
|
||||
@@ -313,17 +313,17 @@ public class InstanceInfo {
|
||||
}
|
||||
|
||||
writer.appendNoHilight(modifiers + objType);
|
||||
String classTypeName = abc.constants.getMultiname(name_index).getNameWithNamespace(abc.constants, true).toRawString();
|
||||
String classTypeName = abc.constants.getMultiname(name_index).getNameWithNamespace(abc, abc.constants, true).toRawString();
|
||||
|
||||
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, null/* No full names here*/, false, true), HighlightSpecialType.CLASS_NAME, classTypeName);
|
||||
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc, abc.constants, null/* No full names here*/, false, true), HighlightSpecialType.CLASS_NAME, classTypeName);
|
||||
|
||||
if (!isNullable()) {
|
||||
writer.appendNoHilight("!");
|
||||
}
|
||||
|
||||
if (super_index > 0) {
|
||||
String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc.constants, true).toRawString();
|
||||
String parentName = abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames, false, true);
|
||||
String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc, abc.constants, true).toRawString();
|
||||
String parentName = abc.constants.getMultiname(super_index).getName(abc, abc.constants, fullyQualifiedNames, false, true);
|
||||
if (!parentName.equals("Object")) {
|
||||
writer.appendNoHilight(" extends ");
|
||||
writer.hilightSpecial(parentName, HighlightSpecialType.TYPE_NAME, typeName);
|
||||
@@ -339,8 +339,8 @@ public class InstanceInfo {
|
||||
if (i > 0) {
|
||||
writer.append(", ");
|
||||
}
|
||||
String typeName = abc.constants.getMultiname(interfaces[i]).getNameWithNamespace(abc.constants, true).toRawString();
|
||||
writer.hilightSpecial(abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames, false, true), HighlightSpecialType.TYPE_NAME, typeName);
|
||||
String typeName = abc.constants.getMultiname(interfaces[i]).getNameWithNamespace(abc, abc.constants, true).toRawString();
|
||||
writer.hilightSpecial(abc.constants.getMultiname(interfaces[i]).getName(abc, abc.constants, fullyQualifiedNames, false, true), HighlightSpecialType.TYPE_NAME, typeName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -565,7 +565,7 @@ public final class MethodBody implements Cloneable {
|
||||
}
|
||||
List<DottedChain> fullyQualifiedNames2 = new ArrayList<>(fullyQualifiedNames);
|
||||
for (Trait t : traits.traits) {
|
||||
DottedChain tname = DottedChain.parseWithSuffix(t.getName(abc).getName(abc.constants, new ArrayList<>(), false, true));
|
||||
DottedChain tname = DottedChain.parseWithSuffix(t.getName(abc).getName(abc, abc.constants, new ArrayList<>(), false, true));
|
||||
fullyQualifiedNames2.remove(tname);
|
||||
}
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ public class MethodInfo {
|
||||
}
|
||||
DottedChain ptype = DottedChain.ALL;
|
||||
if (param_types[i] > 0) {
|
||||
ptype = constants.getMultiname(param_types[i]).getNameWithNamespace(constants, true);
|
||||
ptype = constants.getMultiname(param_types[i]).getNameWithNamespace(abc, constants, true);
|
||||
}
|
||||
|
||||
HighlightData pdata = new HighlightData();
|
||||
@@ -353,10 +353,10 @@ public class MethodInfo {
|
||||
pdata.regIndex = i + 1;
|
||||
if (!localRegNames.isEmpty()) {
|
||||
pdata.localName = localRegNames.get(i + 1); //assuming it is a slot
|
||||
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true, localRegNames.get(i + 1)), HighlightSpecialType.PARAM_NAME, i, pdata);
|
||||
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, localRegNames.get(i + 1)), HighlightSpecialType.PARAM_NAME, i, pdata);
|
||||
} else if ((paramNames.length > i) && (paramNames[i] != 0) && Configuration.paramNamesEnable.get()) {
|
||||
pdata.localName = constants.getString(paramNames[i]);
|
||||
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true, constants.getString(paramNames[i])), HighlightSpecialType.PARAM_NAME, i, pdata);
|
||||
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, constants.getString(paramNames[i])), HighlightSpecialType.PARAM_NAME, i, pdata);
|
||||
} else {
|
||||
pdata.localName = "param" + (i + 1);
|
||||
writer.hilightSpecial(pdata.localName, HighlightSpecialType.PARAM_NAME, i, pdata);
|
||||
@@ -365,7 +365,7 @@ public class MethodInfo {
|
||||
if (param_types[i] == 0) {
|
||||
writer.hilightSpecial("*", HighlightSpecialType.PARAM, i);
|
||||
} else {
|
||||
writer.hilightSpecial(constants.getMultiname(param_types[i]).getName(constants, fullyQualifiedNames, false, true), HighlightSpecialType.PARAM, i);
|
||||
writer.hilightSpecial(constants.getMultiname(param_types[i]).getName(abc, constants, fullyQualifiedNames, false, true), HighlightSpecialType.PARAM, i);
|
||||
}
|
||||
if (optional != null && flagHas_optional()) {
|
||||
if (i >= param_types.length - optional.length) {
|
||||
@@ -399,27 +399,27 @@ public class MethodInfo {
|
||||
return writer;
|
||||
}
|
||||
|
||||
public GraphTextWriter getReturnTypeStr(GraphTextWriter writer, AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
public GraphTextWriter getReturnTypeStr(GraphTextWriter writer, ABC abc, AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
String rname = "*";
|
||||
if (ret_type > 0) {
|
||||
Multiname multiname = constants.getMultiname(ret_type);
|
||||
if (multiname.kind != Multiname.TYPENAME && multiname.name_index > 0 && constants.getString(multiname.name_index).equals("void")) {
|
||||
rname = "void";
|
||||
} else {
|
||||
rname = multiname.getName(constants, fullyQualifiedNames, false, true);
|
||||
rname = multiname.getName(abc, constants, fullyQualifiedNames, false, true);
|
||||
}
|
||||
}
|
||||
return writer.hilightSpecial(rname, HighlightSpecialType.RETURNS);
|
||||
}
|
||||
|
||||
public String getReturnTypeRaw(AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
public String getReturnTypeRaw(ABC abc, AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
String rname = "*";
|
||||
if (ret_type > 0) {
|
||||
Multiname multiname = constants.getMultiname(ret_type);
|
||||
if (multiname.kind != Multiname.TYPENAME && multiname.name_index > 0 && constants.getString(multiname.name_index).equals("void")) {
|
||||
rname = "void";
|
||||
} else {
|
||||
rname = multiname.getName(constants, fullyQualifiedNames, false, true);
|
||||
rname = multiname.getName(abc, constants, fullyQualifiedNames, false, true);
|
||||
}
|
||||
}
|
||||
return rname;
|
||||
|
||||
@@ -624,18 +624,19 @@ public class Multiname {
|
||||
/**
|
||||
* Converts the typename to string.
|
||||
*
|
||||
* @param abc ABC
|
||||
* @param constants Constant pool
|
||||
* @param fullyQualifiedNames Fully qualified names
|
||||
* @param dontDeobfuscate Don't deobfuscate flag
|
||||
* @param withSuffix With suffix flag
|
||||
* @return Typename as string
|
||||
*/
|
||||
private String typeNameToStr(AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames, boolean dontDeobfuscate, boolean withSuffix) {
|
||||
private String typeNameToStr(ABC abc, AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames, boolean dontDeobfuscate, boolean withSuffix) {
|
||||
if (cyclic) {
|
||||
return "§§cyclic_typename()";
|
||||
}
|
||||
StringBuilder typeNameStr = new StringBuilder();
|
||||
typeNameStr.append(constants.getMultiname(qname_index).getName(constants, fullyQualifiedNames, dontDeobfuscate, withSuffix));
|
||||
typeNameStr.append(constants.getMultiname(qname_index).getName(abc, constants, fullyQualifiedNames, dontDeobfuscate, withSuffix));
|
||||
if (params != null && params.length > 0) {
|
||||
typeNameStr.append(".<");
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
@@ -646,7 +647,7 @@ public class Multiname {
|
||||
if (param == 0) {
|
||||
typeNameStr.append("*");
|
||||
} else {
|
||||
typeNameStr.append(constants.getMultiname(param).getName(constants, fullyQualifiedNames, dontDeobfuscate, withSuffix));
|
||||
typeNameStr.append(constants.getMultiname(param).getName(abc, constants, fullyQualifiedNames, dontDeobfuscate, withSuffix));
|
||||
}
|
||||
}
|
||||
typeNameStr.append(">");
|
||||
@@ -665,7 +666,7 @@ public class Multiname {
|
||||
*/
|
||||
public String getNameWithCustomNamespace(ABC abc, List<DottedChain> fullyQualifiedNames, boolean dontDeobfuscate, boolean withSuffix) {
|
||||
if (kind == TYPENAME) {
|
||||
return typeNameToStr(abc.constants, fullyQualifiedNames, dontDeobfuscate, withSuffix);
|
||||
return typeNameToStr(abc, abc.constants, fullyQualifiedNames, dontDeobfuscate, withSuffix);
|
||||
}
|
||||
if (name_index == -1) {
|
||||
return "";
|
||||
@@ -681,7 +682,7 @@ public class Multiname {
|
||||
String nsname = dc != null ? dc.getLast() : null;
|
||||
|
||||
if (nsname != null && !"AS3".equals(nsname)) {
|
||||
String identifier = dontDeobfuscate ? nsname : IdentifiersDeobfuscation.printIdentifier(true, nsname);
|
||||
String identifier = dontDeobfuscate ? nsname : IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, nsname);
|
||||
if (identifier != null && !identifier.isEmpty()) {
|
||||
return identifier + "::" + name;
|
||||
}
|
||||
@@ -689,10 +690,10 @@ public class Multiname {
|
||||
}
|
||||
|
||||
if (nskind == Namespace.KIND_PACKAGE && fullyQualifiedNames != null && !fullyQualifiedNames.isEmpty() && fullyQualifiedNames.contains(DottedChain.parseWithSuffix(name))) {
|
||||
DottedChain dc = getNameWithNamespace(abc.constants, withSuffix);
|
||||
return dontDeobfuscate ? dc.toRawString() : dc.toPrintableString(true);
|
||||
DottedChain dc = getNameWithNamespace(abc, abc.constants, withSuffix);
|
||||
return dontDeobfuscate ? dc.toRawString() : dc.toPrintableString(abc.getSwf(), true);
|
||||
}
|
||||
return (isAttribute() ? "@" : "") + (dontDeobfuscate ? name : IdentifiersDeobfuscation.printIdentifier(true, name)) + (withSuffix ? getNamespaceSuffix() : "");
|
||||
return (isAttribute() ? "@" : "") + (dontDeobfuscate ? name : IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, name)) + (withSuffix ? getNamespaceSuffix() : "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -708,7 +709,7 @@ public class Multiname {
|
||||
*/
|
||||
public String getNameAndCustomNamespace(ABC abc, List<DottedChain> fullyQualifiedNames, boolean dontDeobfuscate, boolean withSuffix, Reference<DottedChain> customNamespaceRef) {
|
||||
if (kind == TYPENAME) {
|
||||
return typeNameToStr(abc.constants, fullyQualifiedNames, dontDeobfuscate, withSuffix);
|
||||
return typeNameToStr(abc, abc.constants, fullyQualifiedNames, dontDeobfuscate, withSuffix);
|
||||
}
|
||||
if (name_index == -1) {
|
||||
return "";
|
||||
@@ -724,7 +725,7 @@ public class Multiname {
|
||||
String nsname = dc != null ? dc.getLast() : null;
|
||||
|
||||
if (nsname != null && !"AS3".equals(nsname)) {
|
||||
String identifier = dontDeobfuscate ? nsname : IdentifiersDeobfuscation.printIdentifier(true, nsname);
|
||||
String identifier = dontDeobfuscate ? nsname : IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, nsname);
|
||||
if (identifier != null && !identifier.isEmpty()) {
|
||||
customNamespaceRef.setVal(dc);
|
||||
return name;
|
||||
@@ -733,25 +734,26 @@ public class Multiname {
|
||||
}
|
||||
|
||||
if (nskind == Namespace.KIND_PACKAGE && fullyQualifiedNames != null && !fullyQualifiedNames.isEmpty() && fullyQualifiedNames.contains(DottedChain.parseWithSuffix(name))) {
|
||||
DottedChain dc = getNameWithNamespace(abc.constants, withSuffix);
|
||||
return dontDeobfuscate ? dc.toRawString() : dc.toPrintableString(true);
|
||||
DottedChain dc = getNameWithNamespace(abc, abc.constants, withSuffix);
|
||||
return dontDeobfuscate ? dc.toRawString() : dc.toPrintableString(abc.getSwf(), true);
|
||||
}
|
||||
return (isAttribute() ? "@" : "") + (dontDeobfuscate ? name : IdentifiersDeobfuscation.printIdentifier(true, name)) + (withSuffix ? getNamespaceSuffix() : "");
|
||||
return (isAttribute() ? "@" : "") + (dontDeobfuscate ? name : IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, name)) + (withSuffix ? getNamespaceSuffix() : "");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @param abc ABC
|
||||
* @param constants Constant pool
|
||||
* @param fullyQualifiedNames Fully qualified names
|
||||
* @param dontDeobfuscate Don't deobfuscate flag
|
||||
* @param withSuffix With suffix flag
|
||||
* @return Name
|
||||
*/
|
||||
public String getName(AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames, boolean dontDeobfuscate, boolean withSuffix) {
|
||||
public String getName(ABC abc, AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames, boolean dontDeobfuscate, boolean withSuffix) {
|
||||
if (kind == TYPENAME) {
|
||||
return typeNameToStr(constants, fullyQualifiedNames, dontDeobfuscate, withSuffix);
|
||||
return typeNameToStr(abc, constants, fullyQualifiedNames, dontDeobfuscate, withSuffix);
|
||||
}
|
||||
if (name_index == -1) {
|
||||
return "";
|
||||
@@ -774,21 +776,22 @@ public class Multiname {
|
||||
isPublic = true;
|
||||
}
|
||||
if (isPublic && fullyQualifiedNames != null && !fullyQualifiedNames.isEmpty() && fullyQualifiedNames.contains(DottedChain.parseWithSuffix(name))) {
|
||||
DottedChain dc = getNameWithNamespace(constants, withSuffix);
|
||||
return dontDeobfuscate ? dc.toRawString() : dc.toPrintableString(true);
|
||||
DottedChain dc = getNameWithNamespace(abc, constants, withSuffix);
|
||||
return dontDeobfuscate ? dc.toRawString() : dc.toPrintableString(abc.getSwf(), true);
|
||||
}
|
||||
return (isAttribute() ? "@" : "") + (dontDeobfuscate ? name : IdentifiersDeobfuscation.printIdentifier(true, name)) + (withSuffix ? getNamespaceSuffix() : "");
|
||||
return (isAttribute() ? "@" : "") + (dontDeobfuscate ? name : IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, name)) + (withSuffix ? getNamespaceSuffix() : "");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name with namespace.
|
||||
*
|
||||
* @param abc ABC
|
||||
* @param constants Constant pool
|
||||
* @param withSuffix With suffix flag
|
||||
* @return Name with namespace
|
||||
*/
|
||||
public DottedChain getNameWithNamespace(AVM2ConstantPool constants, boolean withSuffix) {
|
||||
public DottedChain getNameWithNamespace(ABC abc, AVM2ConstantPool constants, boolean withSuffix) {
|
||||
DottedChain cached = constants.getCachedMultinameWithNamespace(this);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
@@ -809,7 +812,7 @@ public class Multiname {
|
||||
nsName = ns.getName(constants);
|
||||
}
|
||||
}
|
||||
String name = getName(constants, null, true, false);
|
||||
String name = getName(abc, constants, null, true, false);
|
||||
DottedChain ret;
|
||||
if (nsName != null) {
|
||||
ret = nsName.add(name, withSuffix ? getNamespaceSuffix() : "");
|
||||
@@ -1041,7 +1044,7 @@ public class Multiname {
|
||||
* @param otherCpool Other constant pool
|
||||
* @return True if this qname effectively equals to other qname
|
||||
*/
|
||||
public boolean qnameEquals(AVM2ConstantPool thisCpool, Multiname other, AVM2ConstantPool otherCpool) {
|
||||
public boolean qnameEquals(ABC thisAbc, AVM2ConstantPool thisCpool, Multiname other, ABC otherAbc, AVM2ConstantPool otherCpool) {
|
||||
if (!isEffectivelyQname(thisCpool) || !other.isEffectivelyQname(otherCpool)) {
|
||||
return false;
|
||||
}
|
||||
@@ -1063,7 +1066,7 @@ public class Multiname {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Objects.equals(other.getName(otherCpool, new ArrayList<>(), true, true), getName(thisCpool, new ArrayList<>(), true, true))) {
|
||||
if (!Objects.equals(other.getName(otherAbc, otherCpool, new ArrayList<>(), true, true), getName(thisAbc, thisCpool, new ArrayList<>(), true, true))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Internal;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
@@ -179,12 +180,12 @@ public class Namespace {
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @param ABC abc
|
||||
* @param constants Constant pool
|
||||
* @return String representation
|
||||
*/
|
||||
public String toString(AVM2ConstantPool constants) {
|
||||
return getName(constants).toPrintableString(true);
|
||||
public String toString(ABC abc, AVM2ConstantPool constants) {
|
||||
return getName(constants).toPrintableString(abc.getSwf(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -128,7 +128,7 @@ public class ScriptInfo {
|
||||
if (packageTraits.isEmpty() || packageTraits.size() > 1) {
|
||||
return null;
|
||||
}
|
||||
return traits.traits.get(packageTraits.get(0)).getName(abc).getNameWithNamespace(abc.constants, true);
|
||||
return traits.traits.get(packageTraits.get(0)).getName(abc).getNameWithNamespace(abc, abc.constants, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,7 +180,7 @@ public class ScriptInfo {
|
||||
if ((nskind == Namespace.KIND_PACKAGE_INTERNAL)
|
||||
|| (nskind == Namespace.KIND_PACKAGE)) {
|
||||
DottedChain packageName = name.getSimpleNamespaceName(abc.constants); // assume not null package
|
||||
String objectName = name.getName(abc.constants, null, true, false);
|
||||
String objectName = name.getName(abc, abc.constants, null, true, false);
|
||||
String namespaceSuffix = name.getNamespaceSuffix();
|
||||
List<Integer> traitIndices = new ArrayList<>();
|
||||
|
||||
@@ -190,9 +190,9 @@ public class ScriptInfo {
|
||||
otherTraits.clear();
|
||||
}
|
||||
|
||||
if (packagePrefix == null || packageName.toPrintableString(true).startsWith(packagePrefix)) {
|
||||
if (packagePrefix == null || packageName.toPrintableString(abc.getSwf(), true).startsWith(packagePrefix)) {
|
||||
|
||||
ClassPath cp = new ClassPath(packageName, objectName, namespaceSuffix);
|
||||
ClassPath cp = new ClassPath(packageName, objectName, namespaceSuffix, abc.getSwf());
|
||||
ScriptPack pack = new ScriptPack(cp, abc, allAbcs, scriptIndex, traitIndices);
|
||||
pack.isSimple = isSimple;
|
||||
ret.add(pack);
|
||||
@@ -206,18 +206,18 @@ public class ScriptInfo {
|
||||
Multiname name = t.getName(abc);
|
||||
|
||||
DottedChain packageName = name.getSimpleNamespaceName(abc.constants);
|
||||
String objectName = name.getName(abc.constants, null, true, false);
|
||||
String objectName = name.getName(abc, abc.constants, null, true, false);
|
||||
String namespaceSuffix = name.getNamespaceSuffix();
|
||||
|
||||
List<Integer> traitIndices = new ArrayList<>();
|
||||
|
||||
traitIndices.add(traitIndex);
|
||||
ClassPath cp = new ClassPath(packageName, objectName, namespaceSuffix);
|
||||
ClassPath cp = new ClassPath(packageName, objectName, namespaceSuffix, abc.getSwf());
|
||||
ret.add(new ScriptPack(cp, abc, allAbcs, scriptIndex, traitIndices));
|
||||
}
|
||||
}
|
||||
if (!isSimple) {
|
||||
ret.add(new ScriptPack(new ClassPath(DottedChain.EMPTY, "script_" + scriptIndex, ""), abc, allAbcs, scriptIndex, new ArrayList<>()));
|
||||
ret.add(new ScriptPack(new ClassPath(DottedChain.EMPTY, "script_" + scriptIndex, "", abc.getSwf()), abc, allAbcs, scriptIndex, new ArrayList<>()));
|
||||
}
|
||||
if (packagePrefix == null) {
|
||||
cachedPacks = new ArrayList<>(ret);
|
||||
|
||||
@@ -211,11 +211,11 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
public var attr2;
|
||||
*/
|
||||
if (parent instanceof TraitClass) {
|
||||
String thisName = getName(abc).getName(abc.constants, new ArrayList<>(), true, true);
|
||||
String thisName = getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true);
|
||||
List<Trait> classTraits = abc.class_info.get(((TraitClass) parent).class_info).static_traits.traits;
|
||||
for (Trait t : classTraits) {
|
||||
if (t.kindType == Trait.TRAIT_SLOT) {
|
||||
if ("_skinParts".equals(t.getName(abc).getName(abc.constants, new ArrayList<>(), true, true))) {
|
||||
if ("_skinParts".equals(t.getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true))) {
|
||||
if (t.getName(abc).getNamespace(abc.constants).kind == Namespace.KIND_PRIVATE) {
|
||||
if (convertData.assignedValues.containsKey(t)) {
|
||||
if (convertData.assignedValues.get(t).value instanceof NewObjectAVM2Item) {
|
||||
@@ -332,7 +332,7 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
traitNamesInThisScript.add(it.getName(abc).getName(abc.constants, new ArrayList<>(), true, true));
|
||||
traitNamesInThisScript.add(it.getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true));
|
||||
}
|
||||
for (Trait ct : abc.class_info.get(classIndex).static_traits.traits) {
|
||||
if (publicProtectedOnly) {
|
||||
@@ -341,12 +341,12 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
traitNamesInThisScript.add(ct.getName(abc).getName(abc.constants, new ArrayList<>(), true, true));
|
||||
traitNamesInThisScript.add(ct.getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true));
|
||||
}
|
||||
if (abc.instance_info.get(classIndex).super_index == 0) {
|
||||
return;
|
||||
}
|
||||
DottedChain fullClassName = abc.constants.getMultiname(abc.instance_info.get(classIndex).super_index).getNameWithNamespace(abc.constants, true);
|
||||
DottedChain fullClassName = abc.constants.getMultiname(abc.instance_info.get(classIndex).super_index).getNameWithNamespace(abc, abc.constants, true);
|
||||
AbcIndexing.ClassIndex ci = abcIndex.findClass(new TypeItem(fullClassName), abc, scriptIndex);
|
||||
if (ci != null) {
|
||||
getAllClassTraitNames(traitNamesInThisScript, abcIndex, ci.abc, ci.index, ci.scriptIndex, true);
|
||||
@@ -388,7 +388,7 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
if (st instanceof TraitClass) {
|
||||
getAllClassTraitNames(traitNamesInThisScript, abcIndex, abc, ((TraitClass) st).class_info, scriptIndex, false);
|
||||
} else {
|
||||
traitNamesInThisScript.add(st.getName(abc).getName(abc.constants, new ArrayList<>(), true, true));
|
||||
traitNamesInThisScript.add(st.getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,13 +481,13 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
writer.appendNoHilight("import ");
|
||||
|
||||
if (imp.size() > 1) {
|
||||
writer.appendNoHilight(imp.getWithoutLast().toPrintableString(true));
|
||||
writer.appendNoHilight(imp.getWithoutLast().toPrintableString(abc.getSwf(), true));
|
||||
writer.appendNoHilight(".");
|
||||
}
|
||||
if ("*".equals(imp.getLast())) {
|
||||
writer.appendNoHilight("*");
|
||||
} else {
|
||||
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(true, imp.getLast()), HighlightSpecialType.TYPE_NAME, imp.toRawString());
|
||||
writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, imp.getLast()), HighlightSpecialType.TYPE_NAME, imp.toRawString());
|
||||
}
|
||||
writer.appendNoHilight(";").newLine();
|
||||
hasImport = true;
|
||||
@@ -545,7 +545,7 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
if (METADATA_DEFINITION.equals(name) || METADATA_CTOR_DEFINITION.equals(name)) {
|
||||
continue;
|
||||
}
|
||||
writer.append("[").append(IdentifiersDeobfuscation.printIdentifier(true, name));
|
||||
writer.append("[").append(IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, name));
|
||||
if (!en.getValue().isEmpty()) {
|
||||
writer.append("(");
|
||||
boolean first = true;
|
||||
@@ -555,7 +555,7 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
}
|
||||
first = false;
|
||||
if (key != null && !key.isEmpty()) {
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(true, key)).append("=");
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, key)).append("=");
|
||||
}
|
||||
writer.append("\"");
|
||||
String val = en.getValue().get(key);
|
||||
@@ -629,7 +629,7 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
writer.append(Helper.escapeActionScriptString(m.getSimpleNamespaceName(abc.constants).toRawString()));
|
||||
writer.append("\") ");
|
||||
} else if (dc != null && nsname != null) {
|
||||
String identifier = IdentifiersDeobfuscation.printIdentifier(true, nsname);
|
||||
String identifier = IdentifiersDeobfuscation.printIdentifier(abc.getSwf(), true, nsname);
|
||||
if (identifier != null && !identifier.isEmpty()) {
|
||||
writer.hilightSpecial(identifier, HighlightSpecialType.TYPE_NAME, dc.toRawString()).appendNoHilight(" ");
|
||||
}
|
||||
@@ -872,7 +872,7 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
Multiname name = abc.constants.getMultiname(name_index);
|
||||
int nskind = name.getSimpleNamespaceKind(abc.constants);
|
||||
if ((nskind == Namespace.KIND_PACKAGE) || (nskind == Namespace.KIND_PACKAGE_INTERNAL)) {
|
||||
String nsname = name.getSimpleNamespaceName(abc.constants).toPrintableString(true);
|
||||
String nsname = name.getSimpleNamespaceName(abc.constants).toPrintableString(abc.getSwf(), true);
|
||||
writer.appendNoHilight("package");
|
||||
if (!nsname.isEmpty()) {
|
||||
writer.appendNoHilight(" " + nsname); //assume not null name
|
||||
@@ -881,7 +881,7 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
List<Trait> traits = new ArrayList<>();
|
||||
traits.add(this);
|
||||
writeImports(traits, -1, abcIndex, scriptIndex, classIndex, isStatic, abc, writer, getPackage(abc), fullyQualifiedNames);
|
||||
toString(swfVersion, abcIndex, name.getNameWithNamespace(abc.constants, true).getWithoutLast(), parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel, insideInterface);
|
||||
toString(swfVersion, abcIndex, name.getNameWithNamespace(abc, abc.constants, true).getWithoutLast(), parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel, insideInterface);
|
||||
writer.endBlock();
|
||||
writer.newLine();
|
||||
}
|
||||
@@ -911,7 +911,7 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
Multiname name = abc.constants.getMultiname(name_index);
|
||||
int nskind = name.getSimpleNamespaceKind(abc.constants);
|
||||
if ((nskind == Namespace.KIND_PACKAGE) || (nskind == Namespace.KIND_PACKAGE_INTERNAL)) {
|
||||
String nsname = name.getSimpleNamespaceName(abc.constants).toPrintableString(true);
|
||||
String nsname = name.getSimpleNamespaceName(abc.constants).toPrintableString(abc.getSwf(), true);
|
||||
convert(swfVersion, abcIndex, parent, convertData, path + nsname, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel, scopeStack);
|
||||
}
|
||||
}
|
||||
@@ -999,9 +999,9 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
Multiname name = getName(abc);
|
||||
Namespace ns = name.getNamespace(abc.constants);
|
||||
DottedChain packageName = ns == null ? DottedChain.EMPTY : ns.getName(abc.constants);
|
||||
String objectName = name.getName(abc.constants, null, true, false);
|
||||
String objectName = name.getName(abc, abc.constants, null, true, false);
|
||||
String namespaceSuffix = name.getNamespaceSuffix();
|
||||
return new ClassPath(packageName, objectName, namespaceSuffix); //assume not null name
|
||||
return new ClassPath(packageName, objectName, namespaceSuffix, abc.getSwf()); //assume not null name
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -201,7 +201,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
|
||||
Reference<Boolean> first = new Reference<>(true);
|
||||
|
||||
String instanceInfoName = instanceInfoMultiname.getName(abc.constants, fullyQualifiedNames, false, true);
|
||||
String instanceInfoName = instanceInfoMultiname.getName(abc, abc.constants, fullyQualifiedNames, false, true);
|
||||
|
||||
getMetaData(this, convertData, abc, writer);
|
||||
|
||||
@@ -210,7 +210,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
if (convertData.exportEmbedFlaMode) {
|
||||
allowEmbed = false;
|
||||
if (abc.getSwf() != null) {
|
||||
CharacterTag ct = abc.getSwf().getCharacterByClass(instanceInfoMultiname.getNameWithNamespace(abc.constants, false).toRawString());
|
||||
CharacterTag ct = abc.getSwf().getCharacterByClass(instanceInfoMultiname.getNameWithNamespace(abc, abc.constants, false).toRawString());
|
||||
if (ct == null) {
|
||||
allowEmbed = false;
|
||||
} else {
|
||||
@@ -318,7 +318,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
writer.startMethod(instanceInfo.iinit_index, "iinit");
|
||||
writer.appendNoHilight(modifier);
|
||||
writer.appendNoHilight("function ");
|
||||
writer.appendNoHilight(m.getName(abc.constants, null/*do not want full names here*/, false, true));
|
||||
writer.appendNoHilight(m.getName(abc, abc.constants, null/*do not want full names here*/, false, true));
|
||||
writer.appendNoHilight("(");
|
||||
bodyIndex = abc.findBodyIndex(instanceInfo.iinit_index);
|
||||
MethodBody body = bodyIndex == -1 ? null : abc.bodies.get(bodyIndex);
|
||||
@@ -346,7 +346,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
}
|
||||
if (convertData.ignoreAccessibility) {
|
||||
for (Trait t : instanceInfo.instance_traits.traits) {
|
||||
String traitName = t.getName(abc).getName(abc.constants, new ArrayList<>(), true, false);;
|
||||
String traitName = t.getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, false);;
|
||||
if (traitName.startsWith("__setAcc_")
|
||||
|| traitName.startsWith("__setTab_")) {
|
||||
ignoredInstanceTraitNames.add(traitName);
|
||||
@@ -372,7 +372,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
fullyQualifiedNames = new ArrayList<>();
|
||||
|
||||
InstanceInfo instanceInfo = abc.instance_info.get(class_info);
|
||||
String instanceInfoName = instanceInfo.getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false, true);
|
||||
String instanceInfoName = instanceInfo.getName(abc.constants).getName(abc, abc.constants, fullyQualifiedNames, false, true);
|
||||
ClassInfo classInfo = abc.class_info.get(class_info);
|
||||
|
||||
AbcIndexing index = new AbcIndexing(abc.getSwf());
|
||||
@@ -382,7 +382,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
int nsIndex = abc.constants.getNamespaceId(Namespace.KIND_PACKAGE, DottedChain.TOPLEVEL, sIndex, false);
|
||||
if (nsIndex > -1) {
|
||||
Reference<Boolean> foundStatic = new Reference<>(null);
|
||||
convertData.thisHasDefaultToPrimitive = null == index.findProperty(new AbcIndexing.PropertyDef("toString", new TypeItem(instanceInfo.getName(abc.constants).getNameWithNamespace(abc.constants, true)), abc, nsIndex), false, true, false, foundStatic);
|
||||
convertData.thisHasDefaultToPrimitive = null == index.findProperty(new AbcIndexing.PropertyDef("toString", new TypeItem(instanceInfo.getName(abc.constants).getNameWithNamespace(abc, abc.constants, true)), abc, nsIndex), false, true, false, foundStatic);
|
||||
} else {
|
||||
convertData.thisHasDefaultToPrimitive = true;
|
||||
}
|
||||
@@ -398,7 +398,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
callStack.add(abc.bodies.get(bodyIndex));
|
||||
|
||||
if (!abc.instance_info.get(class_info).isInterface()) {
|
||||
AbcIndexing.ClassIndex cls = abcIndex.findClass(AbcIndexing.multinameToType(abc.instance_info.get(class_info).name_index, abc.constants), abc, scriptIndex);
|
||||
AbcIndexing.ClassIndex cls = abcIndex.findClass(AbcIndexing.multinameToType(abc.instance_info.get(class_info).name_index, abc, abc.constants), abc, scriptIndex);
|
||||
List<AbcIndexing.ClassIndex> clsList = new ArrayList<>();
|
||||
cls = cls.parent;
|
||||
while (cls != null) {
|
||||
@@ -406,7 +406,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
cls = cls.parent;
|
||||
}
|
||||
for (AbcIndexing.ClassIndex cls2 : clsList) {
|
||||
newScopeStack.push(new ClassAVM2Item(cls2.abc.instance_info.get(cls2.index).getName(cls2.abc.constants).getNameWithNamespace(cls2.abc.constants, true)));
|
||||
newScopeStack.push(new ClassAVM2Item(cls2.abc.instance_info.get(cls2.index).getName(cls2.abc.constants).getNameWithNamespace(cls2.abc, cls2.abc.constants, true)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,14 +453,14 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
if (callProp.arguments.get(i) instanceof IntegerValueAVM2Item) {
|
||||
if (callProp.arguments.get(i + 1) instanceof GetLexAVM2Item) {
|
||||
GetLexAVM2Item lex = (GetLexAVM2Item) callProp.arguments.get(i + 1);
|
||||
frameTraitNames.add(lex.propertyName.getName(abc.constants, new ArrayList<>(), false, true));
|
||||
frameTraitNames.add(lex.propertyName.getName(abc, abc.constants, new ArrayList<>(), false, true));
|
||||
} else if (callProp.arguments.get(i + 1) instanceof GetPropertyAVM2Item) {
|
||||
GetPropertyAVM2Item getProp = (GetPropertyAVM2Item) callProp.arguments.get(i + 1);
|
||||
if (getProp.object instanceof ThisAVM2Item) {
|
||||
if (getProp.propertyName instanceof FullMultinameAVM2Item) {
|
||||
FullMultinameAVM2Item framePropName = (FullMultinameAVM2Item) getProp.propertyName;
|
||||
int multinameIndex = framePropName.multinameIndex;
|
||||
frameTraitNames.add(abc.constants.getMultiname(multinameIndex).getName(abc.constants, new ArrayList<>(), false, true));
|
||||
frameTraitNames.add(abc.constants.getMultiname(multinameIndex).getName(abc, abc.constants, new ArrayList<>(), false, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,11 +84,11 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
}
|
||||
getModifiers(abc, isStatic, insideInterface, writer, classIndex);
|
||||
writer.hilightSpecial("function ", HighlightSpecialType.TRAIT_TYPE);
|
||||
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false, true), HighlightSpecialType.TRAIT_NAME);
|
||||
writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc, abc.constants, fullyQualifiedNames, false, true), HighlightSpecialType.TRAIT_NAME);
|
||||
writer.appendNoHilight("(");
|
||||
abc.method_info.get(method_info).getParamStr(writer, abc.constants, body, abc, fullyQualifiedNames);
|
||||
writer.appendNoHilight(") : ");
|
||||
abc.method_info.get(method_info).getReturnTypeStr(writer, abc.constants, fullyQualifiedNames);
|
||||
abc.method_info.get(method_info).getReturnTypeStr(writer, abc, abc.constants, fullyQualifiedNames);
|
||||
return writer;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
@Override
|
||||
public GraphTextWriter toString(int swfVersion, AbcIndexing abcIndex, DottedChain packageName, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel, boolean insideInterface) throws InterruptedException {
|
||||
getMetaData(this, convertData, abc, writer);
|
||||
writer.startMethod(method_info, getName(abc).getName(abc.constants, new ArrayList<>(), true, false));
|
||||
writer.startMethod(method_info, getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, false));
|
||||
toStringHeader(swfVersion, parent, packageName, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel, insideInterface);
|
||||
|
||||
writer.startBlock();
|
||||
@@ -120,7 +120,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
//writeUses(scriptIndex, classIndex, isStatic, abc, writer);
|
||||
List<MethodBody> callStack = new ArrayList<>();
|
||||
callStack.add(abc.bodies.get(bodyIndex));
|
||||
abc.bodies.get(bodyIndex).toString(swfVersion, callStack, abcIndex, path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false, true), exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>());
|
||||
abc.bodies.get(bodyIndex).toString(swfVersion, callStack, abcIndex, path + "." + abc.constants.getMultiname(name_index).getName(abc, abc.constants, fullyQualifiedNames, false, true), exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>());
|
||||
}
|
||||
writer.endBlock();
|
||||
|
||||
@@ -133,13 +133,13 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
@Override
|
||||
public void convert(int swfVersion, AbcIndexing abcIndex, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel, ScopeStack scopeStack) throws InterruptedException {
|
||||
fullyQualifiedNames = new ArrayList<>();
|
||||
writer.startMethod(method_info, getName(abc).getName(abc.constants, new ArrayList<>(), true, false));
|
||||
writer.startMethod(method_info, getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, false));
|
||||
convertHeader(swfVersion, parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (bodyIndex != -1) {
|
||||
List<MethodBody> callStack = new ArrayList<>();
|
||||
callStack.add(abc.bodies.get(bodyIndex));
|
||||
abc.bodies.get(bodyIndex).convert(swfVersion, callStack, abcIndex, convertData, path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false, true), exportMode, isStatic, method_info, scriptIndex, classIndex, abc, this, scopeStack, 0, writer, fullyQualifiedNames, null, true, new HashSet<>(), new ArrayList<>());
|
||||
abc.bodies.get(bodyIndex).convert(swfVersion, callStack, abcIndex, convertData, path + "." + abc.constants.getMultiname(name_index).getName(abc, abc.constants, fullyQualifiedNames, false, true), exportMode, isStatic, method_info, scriptIndex, classIndex, abc, this, scopeStack, 0, writer, fullyQualifiedNames, null, true, new HashSet<>(), new ArrayList<>());
|
||||
}
|
||||
writer.endMethod();
|
||||
}
|
||||
|
||||
+9
-9
@@ -127,19 +127,19 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
}
|
||||
|
||||
writer.hilightSpecial("function " + addKind, HighlightSpecialType.TRAIT_TYPE);
|
||||
writer.hilightSpecial(getName(abc).getName(abc.constants, new ArrayList<>(), false, true), HighlightSpecialType.TRAIT_NAME);
|
||||
writer.hilightSpecial(getName(abc).getName(abc, abc.constants, new ArrayList<>(), false, true), HighlightSpecialType.TRAIT_NAME);
|
||||
writer.appendNoHilight("(");
|
||||
abc.method_info.get(method_info).getParamStr(writer, abc.constants, body, abc, fullyQualifiedNames);
|
||||
writer.appendNoHilight(") : ");
|
||||
abc.method_info.get(method_info).getReturnTypeStr(writer, abc.constants, fullyQualifiedNames);
|
||||
abc.method_info.get(method_info).getReturnTypeStr(writer, abc, abc.constants, fullyQualifiedNames);
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(int swfVersion, AbcIndexing abcIndex, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel, ScopeStack scopeStack) throws InterruptedException {
|
||||
int nsKind = getName(abc).getSimpleNamespaceKind(abc.constants);
|
||||
writer.startMethod(method_info, getName(abc).getName(abc.constants, new ArrayList<>(), true, false));
|
||||
path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames, false, true);
|
||||
writer.startMethod(method_info, getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, false));
|
||||
path = path + "." + getName(abc).getName(abc, abc.constants, fullyQualifiedNames, false, true);
|
||||
convertHeader(swfVersion, parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (exportMode != ScriptExportMode.AS_METHOD_STUBS) {
|
||||
@@ -169,8 +169,8 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
@Override
|
||||
public GraphTextWriter toString(int swfVersion, AbcIndexing abcIndex, DottedChain packageName, Trait parent, ConvertData convertData, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<DottedChain> fullyQualifiedNames, boolean parallel, boolean insideInterface) throws InterruptedException {
|
||||
getMetaData(this, convertData, abc, writer);
|
||||
writer.startMethod(method_info, getName(abc).getName(abc.constants, new ArrayList<>(), true, false));
|
||||
path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames, false, true);
|
||||
writer.startMethod(method_info, getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, false));
|
||||
path = path + "." + getName(abc).getName(abc, abc.constants, fullyQualifiedNames, false, true);
|
||||
toStringHeader(swfVersion, parent, packageName, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel, insideInterface);
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (classIndex != -1 && abc.instance_info.get(classIndex).isInterface() || bodyIndex == -1) {
|
||||
@@ -188,7 +188,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
abc.bodies.get(bodyIndex).toString(swfVersion, callStack, abcIndex, path, exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>());
|
||||
}
|
||||
} else {
|
||||
String retTypeRaw = abc.method_info.get(method_info).getReturnTypeRaw(abc.constants, fullyQualifiedNames);
|
||||
String retTypeRaw = abc.method_info.get(method_info).getReturnTypeRaw(abc, abc.constants, fullyQualifiedNames);
|
||||
switch (retTypeRaw) {
|
||||
case "void":
|
||||
break;
|
||||
@@ -256,10 +256,10 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
@Override
|
||||
public boolean isVisible(boolean isStatic, ABC abc) {
|
||||
if (Configuration.handleSkinPartsAutomatically.get()) {
|
||||
if ("skinParts".equals(getName(abc).getName(abc.constants, new ArrayList<>(), true, true))) {
|
||||
if ("skinParts".equals(getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true))) {
|
||||
if (kindType == TRAIT_GETTER) {
|
||||
MethodInfo mi = abc.method_info.get(method_info);
|
||||
if (mi.param_types.length == 0 && "Object".equals(abc.constants.getMultiname(mi.ret_type).getNameWithNamespace(abc.constants, true).toRawString())) {
|
||||
if (mi.param_types.length == 0 && "Object".equals(abc.constants.getMultiname(mi.ret_type).getNameWithNamespace(abc, abc.constants, true).toRawString())) {
|
||||
if (abc.constants.getNamespace(abc.constants.getMultiname(name_index).namespace_index).kind == Namespace.KIND_PROTECTED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+7
-6
@@ -99,14 +99,15 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
/**
|
||||
* Gets type as string.
|
||||
*
|
||||
* @param abc ABC
|
||||
* @param constants Constant pool
|
||||
* @param fullyQualifiedNames Fully qualified names
|
||||
* @return Type as string
|
||||
*/
|
||||
public String getType(AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
public String getType(ABC abc, AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
String typeStr = "*";
|
||||
if (type_index > 0) {
|
||||
typeStr = constants.getMultiname(type_index).getName(constants, fullyQualifiedNames, false, true);
|
||||
typeStr = constants.getMultiname(type_index).getName(abc, constants, fullyQualifiedNames, false, true);
|
||||
}
|
||||
return typeStr;
|
||||
}
|
||||
@@ -120,7 +121,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
* @return Writer
|
||||
*/
|
||||
public GraphTextWriter getNameStr(GraphTextWriter writer, ABC abc, List<DottedChain> fullyQualifiedNames) {
|
||||
String typeStr = getType(abc.constants, fullyQualifiedNames);
|
||||
String typeStr = getType(abc, abc.constants, fullyQualifiedNames);
|
||||
ValueKind val = null;
|
||||
if (value_kind != 0) {
|
||||
val = new ValueKind(value_index, value_kind);
|
||||
@@ -137,7 +138,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
typeStr = "";
|
||||
}
|
||||
writer.hilightSpecial(slotconst + " ", HighlightSpecialType.TRAIT_TYPE);
|
||||
writer.hilightSpecial(getName(abc).getName(abc.constants, new ArrayList<>(), false, true), HighlightSpecialType.TRAIT_NAME);
|
||||
writer.hilightSpecial(getName(abc).getName(abc, abc.constants, new ArrayList<>(), false, true), HighlightSpecialType.TRAIT_NAME);
|
||||
writer.hilightSpecial(typeStr, HighlightSpecialType.TRAIT_TYPE_NAME);
|
||||
return writer;
|
||||
}
|
||||
@@ -356,9 +357,9 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
Hide: private static var _skinParts
|
||||
(part of [SkinPart] compilations)
|
||||
*/
|
||||
if (isStatic && "_skinParts".equals(getName(abc).getName(abc.constants, new ArrayList<>(), true, true))) {
|
||||
if (isStatic && "_skinParts".equals(getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true))) {
|
||||
if (kindType == Trait.TRAIT_SLOT) {
|
||||
if ("_skinParts".equals(getName(abc).getName(abc.constants, new ArrayList<>(), true, true))) {
|
||||
if ("_skinParts".equals(getName(abc).getName(abc, abc.constants, new ArrayList<>(), true, true))) {
|
||||
if (getName(abc).getNamespace(abc.constants).kind == Namespace.KIND_PRIVATE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ public class Traits implements Cloneable, Serializable {
|
||||
if (!trait.isVisible(isStatic, abc)) {
|
||||
continue;
|
||||
}
|
||||
if (ignoredTraitNames.contains(trait.getName(abc).getName(abc.constants, new ArrayList<>(), false, false))) {
|
||||
if (ignoredTraitNames.contains(trait.getName(abc).getName(abc, abc.constants, new ArrayList<>(), false, false))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public class ClassNameMultinameUsage extends MultinameUsage implements Definitio
|
||||
public String toString() {
|
||||
InstanceInfo ii = abc.instance_info.get(classIndex);
|
||||
String kind = ii.isInterface() ? "interface" : "class";
|
||||
return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc.constants, true).toPrintableString(true) + " name";
|
||||
return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc, abc.constants, true).toPrintableString(abc.getSwf(), true) + " name";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -86,8 +86,8 @@ public abstract class MultinameUsage implements Usage {
|
||||
return false;
|
||||
}
|
||||
if ((thisM.kind == Multiname.QNAME || thisM.kind == Multiname.QNAMEA) && otherM.kind == thisM.kind) {
|
||||
String thisName = thisM.getName(abc.constants, new ArrayList<>(), true, true);
|
||||
String otherName = otherM.getName(other.abc.constants, new ArrayList<>(), true, true);
|
||||
String thisName = thisM.getName(abc, abc.constants, new ArrayList<>(), true, true);
|
||||
String otherName = otherM.getName(other.abc, other.abc.constants, new ArrayList<>(), true, true);
|
||||
Namespace thisNs = thisM.getNamespace(abc.constants);
|
||||
Namespace otherNs = otherM.getNamespace(other.abc.constants);
|
||||
if (!Objects.equals(thisName, otherName)) {
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class SuperClassMultinameUsage extends MultinameUsage implements InsideCl
|
||||
public String toString() {
|
||||
InstanceInfo ii = abc.instance_info.get(classIndex);
|
||||
String kind = ii.isInterface() ? "interface" : "class";
|
||||
return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc.constants, true) + " extends";
|
||||
return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc, abc.constants, true) + " extends";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class SuperInterfaceMultinameUsage extends MultinameUsage implements Insi
|
||||
public String toString() {
|
||||
InstanceInfo ii = abc.instance_info.get(classIndex);
|
||||
String kind = ii.isInterface() ? "interface" : "class";
|
||||
return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc.constants, true) + " " + (ii.isInterface() ? "extends" : "implements");
|
||||
return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc, abc.constants, true) + " " + (ii.isInterface() ? "extends" : "implements");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -100,10 +100,10 @@ public abstract class TraitMultinameUsage extends MultinameUsage implements Insi
|
||||
if (classIndex != -1) {
|
||||
InstanceInfo ii = abc.instance_info.get(classIndex);
|
||||
String kind = ii.isInterface() ? "interface" : "class";
|
||||
return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc.constants, true).toPrintableString(true);
|
||||
return kind + " " + ii.getName(abc.constants).getNameWithNamespace(abc, abc.constants, true).toPrintableString(abc.getSwf(), true);
|
||||
}
|
||||
DottedChain scriptSimpleName = abc.script_info.get(scriptIndex).getSimplePackName(abc);
|
||||
return "script " + (scriptSimpleName == null ? "" + scriptIndex : scriptSimpleName.toPrintableString(true));
|
||||
return "script " + (scriptSimpleName == null ? "" + scriptIndex : scriptSimpleName.toPrintableString(abc.getSwf(), true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.action;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.action.model.ConstantPool;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
|
||||
@@ -31,7 +32,8 @@ public interface StoreTypeAction {
|
||||
*
|
||||
* @param stack Stack
|
||||
* @param cpool Constant pool
|
||||
* @param swf SWF
|
||||
* @return Variable name
|
||||
*/
|
||||
public String getVariableName(TranslateStack stack, ConstantPool cpool);
|
||||
public String getVariableName(TranslateStack stack, ConstantPool cpool, SWF swf);
|
||||
}
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public class UninitializedClassFieldsDetector {
|
||||
DoInitActionTag doi = (DoInitActionTag) asm;
|
||||
String exportName = doi.getSwf().getExportName(doi.spriteId);
|
||||
if (exportName != null) {
|
||||
asmPath = DottedChain.parseNoSuffix(exportName).toPrintableString(false);
|
||||
asmPath = DottedChain.parseNoSuffix(exportName).toPrintableString(doi.getSwf(), false);
|
||||
}
|
||||
}
|
||||
for (ProgressListener listener : progressListeners) {
|
||||
|
||||
+3
-3
@@ -142,7 +142,7 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue {
|
||||
}
|
||||
|
||||
if (value instanceof RegisterNumber) {
|
||||
return IdentifiersDeobfuscation.printIdentifier(false, ((RegisterNumber) value).translate());
|
||||
return IdentifiersDeobfuscation.printIdentifier(localData.swf, false, ((RegisterNumber) value).translate());
|
||||
}
|
||||
|
||||
return value.toString();
|
||||
@@ -164,7 +164,7 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue {
|
||||
}
|
||||
|
||||
if (value instanceof RegisterNumber) {
|
||||
return writer.append(IdentifiersDeobfuscation.printIdentifier(false, ((RegisterNumber) value).translate()));
|
||||
return writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, ((RegisterNumber) value).translate()));
|
||||
}
|
||||
|
||||
return writer.append(value.toString());
|
||||
@@ -197,7 +197,7 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue {
|
||||
srcData.localName = ((RegisterNumber) value).translate();
|
||||
srcData.regIndex = ((RegisterNumber) value).number;
|
||||
|
||||
return writer.appendWithData(IdentifiersDeobfuscation.printIdentifier(false, ((RegisterNumber) value).translate()), srcData);
|
||||
return writer.appendWithData(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, ((RegisterNumber) value).translate()), srcData);
|
||||
}
|
||||
return writer.append(EcmaScript.toString(value));
|
||||
}
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ public class GetMemberActionItem extends ActionItem {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilderTextWriter sbw = new StringBuilderTextWriter(new CodeFormatting(), sb);
|
||||
stripQuotes(memberName, localData, sbw);
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(false, sb.toString()));
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, sb.toString()));
|
||||
return writer;
|
||||
}
|
||||
if (((!(memberName instanceof DirectValueActionItem)) || (!((DirectValueActionItem) memberName).isString()) || (!printObfuscatedMemberName && !IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) memberName).toStringNoQuotes(localData))))) {
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ public class GetVariableActionItem extends ActionItem {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilderTextWriter sbw = new StringBuilderTextWriter(new CodeFormatting(), sb);
|
||||
stripQuotes(name, localData, sbw);
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(false, sb.toString()));
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, sb.toString()));
|
||||
return writer;
|
||||
}
|
||||
if ((name instanceof DirectValueActionItem) && (((DirectValueActionItem) name).isString()) && (printObfuscatedName || IdentifiersDeobfuscation.isValidNameWithDot(false, ((DirectValueActionItem) name).toStringNoQuotes(localData), "this", "super"))) {
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ public class InitObjectActionItem extends ActionItem {
|
||||
//AS1/2 does not allow quotes in name here
|
||||
if ((names.get(i) instanceof DirectValueActionItem)
|
||||
&& (((DirectValueActionItem) names.get(i)).isSimpleValue())) {
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(false, names.get(i).toStringNoQuotes(localData)));
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, names.get(i).toStringNoQuotes(localData)));
|
||||
} else {
|
||||
writer.append("(");
|
||||
names.get(i).appendTo(writer, localData);
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ public class NewObjectActionItem extends ActionItem {
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
writer.append("new ");
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(false, objectName.toStringNoQuotes(localData)));
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, objectName.toStringNoQuotes(localData)));
|
||||
writer.spaceBeforeCallParenthesis(arguments.size());
|
||||
writer.append("(");
|
||||
for (int t = 0; t < arguments.size(); t++) {
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ public class SetVariableActionItem extends ActionItem implements SetTypeActionIt
|
||||
//TODO: handle result needed better, without identifierdeobfuscation
|
||||
HighlightData srcData = getSrcData();
|
||||
srcData.localName = name.toStringNoQuotes(localData);
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(false, name.toStringNoQuotes(localData)));
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, name.toStringNoQuotes(localData)));
|
||||
if (compoundOperator != null) {
|
||||
writer.append(" ");
|
||||
writer.append(compoundOperator);
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ public class StoreRegisterActionItem extends ActionItem implements SetTypeAction
|
||||
srcData.declaredType = DottedChain.ALL;
|
||||
writer.append("var ");
|
||||
}
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(false, register.translate()));
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, register.translate()));
|
||||
|
||||
if (compoundOperator != null) {
|
||||
writer.append(" ");
|
||||
|
||||
+1
-1
@@ -250,7 +250,7 @@ public class ClassActionItem extends ActionItem implements Block {
|
||||
item.getValue().toString(writer, localData).newLine();
|
||||
} else {
|
||||
writer.append("var ");
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(false, item.getKey().toStringNoQuotes(localData)));
|
||||
writer.append(IdentifiersDeobfuscation.printIdentifier(localData.swf, false, item.getKey().toStringNoQuotes(localData)));
|
||||
if (item.getValue() != null) {
|
||||
writer.append(" = ");
|
||||
item.getValue().toString(writer, localData);
|
||||
|
||||
+6
-1
@@ -253,6 +253,11 @@ public class ActionScript2Parser {
|
||||
* Charset
|
||||
*/
|
||||
private String charset;
|
||||
|
||||
/**
|
||||
* SWF
|
||||
*/
|
||||
private SWF swf;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -2056,7 +2061,7 @@ public class ActionScript2Parser {
|
||||
}
|
||||
|
||||
private boolean isCastOp(GraphTargetItem item) {
|
||||
LocalData localData = LocalData.create(new ConstantPool(constantPool));
|
||||
LocalData localData = LocalData.create(new ConstantPool(constantPool), this.swf);
|
||||
List<String> items = new ArrayList<>();
|
||||
while (item instanceof GetMemberActionItem) {
|
||||
GetMemberActionItem mem = (GetMemberActionItem) item;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.swf4;
|
||||
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.action.StoreTypeAction;
|
||||
@@ -196,10 +197,10 @@ public class ActionSetVariable extends Action implements StoreTypeAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVariableName(TranslateStack stack, ConstantPool cpool) {
|
||||
public String getVariableName(TranslateStack stack, ConstantPool cpool, SWF swf) {
|
||||
if (stack.size() < 2) {
|
||||
return null;
|
||||
}
|
||||
return stack.get(stack.size() - 2).toStringNoQuotes(LocalData.create(cpool));
|
||||
return stack.get(stack.size() - 2).toStringNoQuotes(LocalData.create(cpool, swf));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.swf5;
|
||||
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
@@ -218,7 +219,7 @@ public class ActionStoreRegister extends Action implements StoreTypeAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVariableName(TranslateStack stack, ConstantPool cpool) {
|
||||
public String getVariableName(TranslateStack stack, ConstantPool cpool, SWF swf) {
|
||||
return "__register" + registerNumber;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1158,6 +1158,10 @@ public final class Configuration {
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
@ConfigurationInternal
|
||||
public static ConfigurationItem<Boolean> showHeapStatusWidget = null;
|
||||
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
@ConfigurationCategory("script")
|
||||
public static ConfigurationItem<Boolean> useSafeStr = null;
|
||||
|
||||
private static Map<String, String> configurationDescriptions = new LinkedHashMap<>();
|
||||
private static Map<String, String> configurationTitles = new LinkedHashMap<>();
|
||||
|
||||
+5
-5
@@ -163,7 +163,7 @@ public class AS3ScriptExporter {
|
||||
if (((SetLocalAVM2Item) asg).regIndex == ((LocalRegAVM2Item) sp.object).regIndex) {
|
||||
GraphTargetItem val = sp.value;
|
||||
if (sp.propertyName instanceof FullMultinameAVM2Item) {
|
||||
String propName = pack.abc.constants.getMultiname(((FullMultinameAVM2Item) sp.propertyName).multinameIndex).getName(pack.abc.constants, new ArrayList<>(), true, true);
|
||||
String propName = pack.abc.constants.getMultiname(((FullMultinameAVM2Item) sp.propertyName).multinameIndex).getName(pack.abc, pack.abc.constants, new ArrayList<>(), true, true);
|
||||
if (val instanceof CallPropertyAVM2Item) {
|
||||
CallPropertyAVM2Item cap = (CallPropertyAVM2Item) val;
|
||||
if (cp.propertyName instanceof FullMultinameAVM2Item) {
|
||||
@@ -253,7 +253,7 @@ public class AS3ScriptExporter {
|
||||
private String getTagName(ScriptPack pack, int classMIndex, int nameMindex, Map<String, String> namespaces) {
|
||||
Multiname m = pack.abc.constants.getMultiname(classMIndex);
|
||||
Multiname mn = pack.abc.constants.getMultiname(nameMindex);
|
||||
String parentName = mn.getName(pack.abc.constants, new ArrayList<>(), true, true);
|
||||
String parentName = mn.getName(pack.abc, pack.abc.constants, new ArrayList<>(), true, true);
|
||||
String pkg = m.getNamespace(pack.abc.constants).getName(pack.abc.constants).toRawString();
|
||||
pkg += ".*";
|
||||
String ns = null;
|
||||
@@ -315,7 +315,7 @@ public class AS3ScriptExporter {
|
||||
if (it instanceof InitPropertyAVM2Item) {
|
||||
InitPropertyAVM2Item ip = (InitPropertyAVM2Item) it;
|
||||
if (ip.object instanceof ThisAVM2Item) {
|
||||
String propName = pack.abc.constants.getMultiname(ip.propertyName.multinameIndex).getName(pack.abc.constants, new ArrayList<>(), true, true);
|
||||
String propName = pack.abc.constants.getMultiname(ip.propertyName.multinameIndex).getName(pack.abc, pack.abc.constants, new ArrayList<>(), true, true);
|
||||
GraphTargetItem val = ((InitPropertyAVM2Item) it).value;
|
||||
if (val instanceof CallPropertyAVM2Item) {
|
||||
CallPropertyAVM2Item cp = (CallPropertyAVM2Item) val;
|
||||
@@ -335,7 +335,7 @@ public class AS3ScriptExporter {
|
||||
ConstructPropAVM2Item cp = (ConstructPropAVM2Item) val;
|
||||
if (cp.propertyName instanceof FullMultinameAVM2Item) {
|
||||
Multiname m = pack.abc.constants.getMultiname(((FullMultinameAVM2Item) cp.propertyName).multinameIndex);
|
||||
if ("mx.core.DeferredInstanceFromFunction".equals("" + m.getNameWithNamespace(pack.abc.constants, true))) {
|
||||
if ("mx.core.DeferredInstanceFromFunction".equals("" + m.getNameWithNamespace(pack.abc, pack.abc.constants, true))) {
|
||||
if (!cp.args.isEmpty()) {
|
||||
if (cp.args.get(0) instanceof GetPropertyAVM2Item) {
|
||||
GetPropertyAVM2Item gp = (GetPropertyAVM2Item) cp.args.get(0);
|
||||
@@ -411,7 +411,7 @@ public class AS3ScriptExporter {
|
||||
Set<String> files = new HashSet<>();
|
||||
String documentClass = swf.getDocumentClass();
|
||||
StringBuffer includeClassesBuilder = new StringBuffer();
|
||||
String documentPkg = documentClass != null ? DottedChain.parseNoSuffix(documentClass).getWithoutLast().toPrintableString(true) : null;
|
||||
String documentPkg = documentClass != null ? DottedChain.parseNoSuffix(documentClass).getWithoutLast().toPrintableString(swf, true) : null;
|
||||
|
||||
StringBuilder importsBuilder = new StringBuilder();
|
||||
|
||||
|
||||
+3
-3
@@ -135,7 +135,7 @@ public class DependencyParser {
|
||||
return;
|
||||
}
|
||||
Namespace ns = m.getNamespace(abc.constants);
|
||||
String name = m.getName(abc.constants, fullyQualifiedNames, true, true);
|
||||
String name = m.getName(abc, abc.constants, fullyQualifiedNames, true, true);
|
||||
NamespaceSet nss = m.getNamespaceSet(abc.constants);
|
||||
if (ns != null) {
|
||||
parseDependenciesFromNS(abcIndex, ignoredCustom, abc, dependencies, m.namespace_index, ignorePackage, name, dependencyType, uses);
|
||||
@@ -271,7 +271,7 @@ public class DependencyParser {
|
||||
}
|
||||
if (classIndex > -1 && ins.definition instanceof GetOuterScopeIns) {
|
||||
if (ins.operands[0] > 0) { //first is global
|
||||
DottedChain type = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants, true);
|
||||
DottedChain type = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc, abc.constants, true);
|
||||
AbcIndexing.ClassIndex cls = abcIndex.findClass(new TypeItem(type), abc, scriptIndex);
|
||||
List<AbcIndexing.ClassIndex> clsList = new ArrayList<>();
|
||||
cls = cls.parent;
|
||||
@@ -281,7 +281,7 @@ public class DependencyParser {
|
||||
}
|
||||
if (ins.operands[0] < 1 + clsList.size()) {
|
||||
AbcIndexing.ClassIndex cls2 = clsList.get(ins.operands[0] - 1);
|
||||
DottedChain nimport = cls2.abc.instance_info.get(cls2.index).getName(cls2.abc.constants).getNameWithNamespace(cls2.abc.constants, true);
|
||||
DottedChain nimport = cls2.abc.instance_info.get(cls2.index).getName(cls2.abc.constants).getNameWithNamespace(cls2.abc, cls2.abc.constants, true);
|
||||
Dependency depExp = new Dependency(nimport, DependencyType.EXPRESSION);
|
||||
if (!dependencies.contains(depExp)) {
|
||||
dependencies.add(depExp);
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ public class LinkReportExporter {
|
||||
ns = abc.constants.getNamespace(nss.namespaces[0]);
|
||||
}
|
||||
String pkgName = ns == null ? "" : ns.getName(abc.constants).toRawString();
|
||||
String clsName = multiName.getName(abc.constants, new ArrayList<>(), true, true);
|
||||
String clsName = multiName.getName(abc, abc.constants, new ArrayList<>(), true, true);
|
||||
return pkgName.isEmpty() ? clsName : pkgName + ":" + clsName;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,11 +112,11 @@ public class MxmlcAs3ScriptReplacer extends MxmlcRunner implements As3ScriptRepl
|
||||
if (ii.deleted) {
|
||||
return true;
|
||||
}
|
||||
if (ii.super_index != 0 && isParentDeleted(abc, allAbcs, abc.constants.getMultiname(ii.super_index).getNameWithNamespace(abc.constants, false))) {
|
||||
if (ii.super_index != 0 && isParentDeleted(abc, allAbcs, abc.constants.getMultiname(ii.super_index).getNameWithNamespace(abc, abc.constants, false))) {
|
||||
return true;
|
||||
}
|
||||
for (int iface : ii.interfaces) {
|
||||
if (isParentDeleted(abc, allAbcs, abc.constants.getMultiname(iface).getNameWithNamespace(abc.constants, false))) {
|
||||
if (isParentDeleted(abc, allAbcs, abc.constants.getMultiname(iface).getNameWithNamespace(abc, abc.constants, false))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,10 +240,10 @@ public class ABCSearchResult implements Serializable, ScriptSearchResult {
|
||||
boolean isStatic = traitId < staticTraitCount;
|
||||
|
||||
if (isStatic) {
|
||||
return abc.class_info.get(classIndex).static_traits.traits.get(traitId).getName(abc).getName(abc.constants, null, false, true);
|
||||
return abc.class_info.get(classIndex).static_traits.traits.get(traitId).getName(abc).getName(abc, abc.constants, null, false, true);
|
||||
} else {
|
||||
int index = traitId - staticTraitCount;
|
||||
return abc.instance_info.get(classIndex).instance_traits.traits.get(index).getName(abc).getName(abc.constants, null, false, true);
|
||||
return abc.instance_info.get(classIndex).instance_traits.traits.get(index).getName(abc).getName(abc, abc.constants, null, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user