mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-12 16:12:14 +00:00
faster AVM2 constant pool when adding a lot of items to it.
This commit is contained in:
@@ -95,8 +95,6 @@ public class ABC {
|
||||
|
||||
private Map<Integer, Integer> bodyIdxFromMethodIdx;
|
||||
|
||||
private long[] stringOffsets;
|
||||
|
||||
public static final int MINORwithDECIMAL = 17;
|
||||
|
||||
protected Set<EventListener> listeners = new HashSet<>();
|
||||
@@ -114,13 +112,6 @@ public class ABC {
|
||||
public ABC(ABCContainerTag tag) {
|
||||
this.parentTag = tag;
|
||||
this.deobfuscation = null;
|
||||
constants.constant_double.add(null);
|
||||
constants.constant_int.add(null);
|
||||
constants.constant_uint.add(null);
|
||||
constants.constant_string.add(null);
|
||||
constants.constant_multiname.add(null);
|
||||
constants.constant_namespace.add(null);
|
||||
constants.constant_namespace_set.add(null);
|
||||
}
|
||||
|
||||
public SWF getSwf() {
|
||||
@@ -142,6 +133,40 @@ public class ABC {
|
||||
return method_info.size() - 1;
|
||||
}
|
||||
|
||||
public TraitMethodGetterSetter addMethod(int classId, String name, boolean isStatic) {
|
||||
Multiname multiname = new Multiname();
|
||||
multiname.kind = Multiname.QNAME;
|
||||
multiname.name_index = constants.getStringId(name, true);
|
||||
multiname.namespace_index = constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true);
|
||||
int multinameId = constants.getMultinameId(multiname, true);
|
||||
|
||||
MethodInfo methodInfo = new MethodInfo();
|
||||
int methodInfoId = addMethodInfo(methodInfo);
|
||||
MethodBody methodBody = new MethodBody();
|
||||
methodBody.method_info = methodInfoId;
|
||||
addMethodBody(methodBody);
|
||||
methodInfo.setBody(methodBody);
|
||||
|
||||
TraitMethodGetterSetter trait = new TraitMethodGetterSetter();
|
||||
trait.name_index = multinameId;
|
||||
trait.kindType = Trait.TRAIT_METHOD;
|
||||
if (isStatic) {
|
||||
trait.kindFlags = Trait.ATTR_Final;
|
||||
}
|
||||
|
||||
trait.method_info = methodInfoId;
|
||||
if (isStatic) {
|
||||
ClassInfo classInfo = class_info.get(classId);
|
||||
classInfo.static_traits.addTrait(trait);
|
||||
trait.disp_id = classInfo.getNextDispId();
|
||||
} else {
|
||||
InstanceInfo instanceInfo = instance_info.get(classId);
|
||||
instanceInfo.instance_traits.addTrait(trait);
|
||||
}
|
||||
|
||||
return trait;
|
||||
}
|
||||
|
||||
public void addEventListener(EventListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
@@ -366,15 +391,11 @@ public class ABC {
|
||||
major_version = ais.readU16("major_version");
|
||||
logger.log(Level.FINE, "ABC minor_version: {0}, major_version: {1}", new Object[]{minor_version, major_version});
|
||||
|
||||
constants = new AVM2ConstantPool();
|
||||
ais.newDumpLevel("constant_pool", "cpool_info");
|
||||
|
||||
// constant integers
|
||||
int constant_int_pool_count = ais.readU30("int_count");
|
||||
constants.constant_int = new ArrayList<>(constant_int_pool_count);
|
||||
if (constant_int_pool_count > 0) {
|
||||
constants.addInt(0);
|
||||
}
|
||||
constants.ensureIntCapacity(constant_int_pool_count);
|
||||
if (constant_int_pool_count > 1) {
|
||||
ais.newDumpLevel("integers", "integer[]");
|
||||
for (int i = 1; i < constant_int_pool_count; i++) { // index 0 not used. Values 1..n-1
|
||||
@@ -385,10 +406,7 @@ public class ABC {
|
||||
|
||||
// constant unsigned integers
|
||||
int constant_uint_pool_count = ais.readU30("uint_count");
|
||||
constants.constant_uint = new ArrayList<>(constant_uint_pool_count);
|
||||
if (constant_uint_pool_count > 0) {
|
||||
constants.addUInt(0);
|
||||
}
|
||||
constants.ensureUIntCapacity(constant_uint_pool_count);
|
||||
if (constant_uint_pool_count > 1) {
|
||||
ais.newDumpLevel("uintegers", "uinteger[]");
|
||||
for (int i = 1; i < constant_uint_pool_count; i++) { // index 0 not used. Values 1..n-1
|
||||
@@ -399,10 +417,7 @@ public class ABC {
|
||||
|
||||
// constant double
|
||||
int constant_double_pool_count = ais.readU30("double_count");
|
||||
constants.constant_double = new ArrayList<>(constant_double_pool_count);
|
||||
//if (constant_double_pool_count > 0) {
|
||||
constants.addDouble(0);
|
||||
//}
|
||||
constants.ensureDoubleCapacity(constant_double_pool_count);
|
||||
if (constant_double_pool_count > 1) {
|
||||
ais.newDumpLevel("doubles", "double[]");
|
||||
for (int i = 1; i < constant_double_pool_count; i++) { // index 0 not used. Values 1..n-1
|
||||
@@ -414,10 +429,7 @@ public class ABC {
|
||||
// constant decimal
|
||||
if (minor_version >= MINORwithDECIMAL) {
|
||||
int constant_decimal_pool_count = ais.readU30("decimal_count");
|
||||
constants.constant_decimal = new ArrayList<>(constant_decimal_pool_count);
|
||||
if (constant_decimal_pool_count > 0) {
|
||||
constants.addDecimal(null);
|
||||
}
|
||||
constants.ensureDecimalCapacity(constant_decimal_pool_count);
|
||||
if (constant_decimal_pool_count > 1) {
|
||||
ais.newDumpLevel("decimals", "decimal[]");
|
||||
for (int i = 1; i < constant_decimal_pool_count; i++) { // index 0 not used. Values 1..n-1
|
||||
@@ -425,33 +437,23 @@ public class ABC {
|
||||
}
|
||||
ais.endDumpLevel();
|
||||
}
|
||||
} else {
|
||||
constants.constant_decimal = new ArrayList<>(0);
|
||||
}
|
||||
|
||||
// constant string
|
||||
int constant_string_pool_count = ais.readU30("string_count");
|
||||
constants.constant_string = new ArrayList<>(constant_string_pool_count);
|
||||
stringOffsets = new long[constant_string_pool_count];
|
||||
//if (constant_string_pool_count > 0) {
|
||||
constants.addString(null);
|
||||
//}
|
||||
constants.ensureStringCapacity(constant_string_pool_count);
|
||||
if (constant_string_pool_count > 1) {
|
||||
ais.newDumpLevel("strings", "string[]");
|
||||
for (int i = 1; i < constant_string_pool_count; i++) { // index 0 not used. Values 1..n-1
|
||||
long pos = ais.getPosition();
|
||||
constants.addString(ais.readString("string"));
|
||||
stringOffsets[i] = pos;
|
||||
}
|
||||
ais.endDumpLevel();
|
||||
}
|
||||
|
||||
// constant namespace
|
||||
int constant_namespace_pool_count = ais.readU30("namespace_count");
|
||||
constants.constant_namespace = new ArrayList<>(constant_namespace_pool_count);
|
||||
//if (constant_namespace_pool_count > 0) {
|
||||
constants.addNamespace(null);
|
||||
//}
|
||||
constants.ensureNamespaceCapacity(constant_namespace_pool_count);
|
||||
if (constant_namespace_pool_count > 1) {
|
||||
ais.newDumpLevel("namespaces", "namespace[]");
|
||||
for (int i = 1; i < constant_namespace_pool_count; i++) { // index 0 not used. Values 1..n-1
|
||||
@@ -462,10 +464,7 @@ public class ABC {
|
||||
|
||||
// constant namespace set
|
||||
int constant_namespace_set_pool_count = ais.readU30("ns_set_count");
|
||||
constants.constant_namespace_set = new ArrayList<>(constant_namespace_set_pool_count);
|
||||
//if (constant_namespace_set_pool_count > 0) {
|
||||
constants.addNamespaceSet(null);
|
||||
//}
|
||||
constants.ensureNamespaceSetCapacity(constant_namespace_set_pool_count);
|
||||
if (constant_namespace_set_pool_count > 1) {
|
||||
ais.newDumpLevel("ns_sets", "ns_set[]");
|
||||
for (int i = 1; i < constant_namespace_set_pool_count; i++) { // index 0 not used. Values 1..n-1
|
||||
@@ -483,10 +482,7 @@ public class ABC {
|
||||
|
||||
// constant multiname
|
||||
int constant_multiname_pool_count = ais.readU30("multiname_count");
|
||||
constants.constant_multiname = new ArrayList<>(constant_multiname_pool_count);
|
||||
//if (constant_multiname_pool_count > 0) {
|
||||
constants.addMultiname(null);
|
||||
//}
|
||||
constants.ensureMultinameCapacity(constant_multiname_pool_count);
|
||||
if (constant_multiname_pool_count > 1) {
|
||||
ais.newDumpLevel("multiname", "multinames[]");
|
||||
for (int i = 1; i < constant_multiname_pool_count; i++) { // index 0 not used. Values 1..n-1
|
||||
|
||||
@@ -35,8 +35,6 @@ import com.jpexs.helpers.MemoryInputStream;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ABCInputStream implements AutoCloseable {
|
||||
|
||||
@@ -302,7 +300,7 @@ public class ABCInputStream implements AutoCloseable {
|
||||
int name_index = 0;
|
||||
int namespace_set_index = 0;
|
||||
int qname_index = 0;
|
||||
List<Integer> params = new ArrayList<>();
|
||||
int[] params = null;
|
||||
|
||||
newDumpLevel(name, "Multiname");
|
||||
if ((kind == Multiname.QNAME) || (kind == Multiname.QNAMEA)) {
|
||||
@@ -320,8 +318,9 @@ public class ABCInputStream implements AutoCloseable {
|
||||
} else if (kind == Multiname.TYPENAME) {
|
||||
qname_index = readU30("qname_index"); // Multiname index!!!
|
||||
int paramsLength = readU30("paramsLength");
|
||||
params = new int[paramsLength];
|
||||
for (int i = 0; i < paramsLength; i++) {
|
||||
params.add(readU30("param")); // multiname indices!
|
||||
params[i] = readU30("param"); // multiname indices!
|
||||
}
|
||||
} else {
|
||||
throw new IOException("Unknown kind of Multiname:0x" + Integer.toHexString(kind));
|
||||
|
||||
@@ -176,25 +176,21 @@ public class ABCOutputStream extends OutputStream {
|
||||
|
||||
public void writeMultiname(Multiname m) throws IOException {
|
||||
writeU8(m.kind);
|
||||
if ((m.kind == 7) || (m.kind == 0xd)) { // CONSTANT_QName and CONSTANT_QNameA.
|
||||
if ((m.kind == Multiname.QNAME) || (m.kind == Multiname.QNAMEA)) {
|
||||
writeU30(m.namespace_index);
|
||||
writeU30(m.name_index);
|
||||
}
|
||||
if ((m.kind == 9) || (m.kind == 0xe)) { // CONSTANT_Multiname and CONSTANT_MultinameA.
|
||||
} else if ((m.kind == Multiname.MULTINAME) || (m.kind == Multiname.MULTINAMEA)) {
|
||||
writeU30(m.name_index);
|
||||
writeU30(m.namespace_set_index);
|
||||
}
|
||||
if ((m.kind == 0xf) || (m.kind == 0x10)) { // CONSTANT_RTQName and CONSTANT_RTQNameA
|
||||
} else if ((m.kind == Multiname.RTQNAME) || (m.kind == Multiname.RTQNAMEA)) {
|
||||
writeU30(m.name_index);
|
||||
}
|
||||
if ((m.kind == 0x1B) || (m.kind == 0x1C)) { // CONSTANT_MultinameL and CONSTANT_MultinameLA
|
||||
} else if ((m.kind == Multiname.MULTINAMEL) || (m.kind == Multiname.MULTINAMELA)) {
|
||||
writeU30(m.namespace_set_index);
|
||||
}
|
||||
if (m.kind == 0x1D) {
|
||||
} else if (m.kind == Multiname.TYPENAME) {
|
||||
writeU30(m.qname_index);
|
||||
writeU30(m.params.size());
|
||||
for (int i = 0; i < m.params.size(); i++) {
|
||||
writeU30(m.params.get(i));
|
||||
writeU30(m.params.length);
|
||||
for (int i = 0; i < m.params.length; i++) {
|
||||
writeU30(m.params[i]);
|
||||
}
|
||||
}
|
||||
// kind==0x11,0x12 nothing CONSTANT_RTQNameL and CONSTANT_RTQNameLA.
|
||||
|
||||
@@ -777,19 +777,19 @@ public class AVM2Code implements Cloneable {
|
||||
public void removeWrongIndices(AVM2ConstantPool constants) {
|
||||
for (AVM2Instruction ins : code) {
|
||||
for (int i = 0; i < ins.definition.operands.length; i++) {
|
||||
if (ins.definition.operands[i] == DAT_MULTINAME_INDEX && ins.operands[i] >= constants.constant_multiname.size()) {
|
||||
if (ins.definition.operands[i] == DAT_MULTINAME_INDEX && ins.operands[i] >= constants.getMultinameCount()) {
|
||||
ins.operands[i] = 0;
|
||||
}
|
||||
if (ins.definition.operands[i] == DAT_DOUBLE_INDEX && ins.operands[i] >= constants.constant_double.size()) {
|
||||
if (ins.definition.operands[i] == DAT_DOUBLE_INDEX && ins.operands[i] >= constants.getDoubleCount()) {
|
||||
ins.operands[i] = 0;
|
||||
}
|
||||
if (ins.definition.operands[i] == DAT_INT_INDEX && ins.operands[i] >= constants.constant_int.size()) {
|
||||
if (ins.definition.operands[i] == DAT_INT_INDEX && ins.operands[i] >= constants.getIntCount()) {
|
||||
ins.operands[i] = 0;
|
||||
}
|
||||
if (ins.definition.operands[i] == DAT_UINT_INDEX && ins.operands[i] >= constants.constant_uint.size()) {
|
||||
if (ins.definition.operands[i] == DAT_UINT_INDEX && ins.operands[i] >= constants.getUIntCount()) {
|
||||
ins.operands[i] = 0;
|
||||
}
|
||||
if (ins.definition.operands[i] == DAT_STRING_INDEX && ins.operands[i] >= constants.constant_string.size()) {
|
||||
if (ins.definition.operands[i] == DAT_STRING_INDEX && ins.operands[i] >= constants.getStringCount()) {
|
||||
ins.operands[i] = 0;
|
||||
}
|
||||
}
|
||||
@@ -1044,8 +1044,12 @@ public class AVM2Code implements Cloneable {
|
||||
}
|
||||
|
||||
public String toASMSource() {
|
||||
return toASMSource(new AVM2ConstantPool());
|
||||
}
|
||||
|
||||
public String toASMSource(AVM2ConstantPool constants) {
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false);
|
||||
toASMSource(new AVM2ConstantPool(), null, null, null, new ArrayList<>(), ScriptExportMode.PCODE, writer);
|
||||
toASMSource(constants, null, null, null, new ArrayList<>(), ScriptExportMode.PCODE, writer);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Internal;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
import com.jpexs.helpers.HashArrayList;
|
||||
import com.jpexs.helpers.utf8.Utf8PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -34,32 +35,99 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(AVM2ConstantPool.class.getName());
|
||||
|
||||
public List<Long> constant_int = new ArrayList<>();
|
||||
private HashArrayList<Long> constant_int = new HashArrayList<>();
|
||||
|
||||
public List<Long> constant_uint = new ArrayList<>();
|
||||
private HashArrayList<Long> constant_uint = new HashArrayList<>();
|
||||
|
||||
private HashArrayList<Double> constant_double = new HashArrayList<>();
|
||||
|
||||
public List<Double> constant_double = new ArrayList<>();
|
||||
/* Only for some minor versions */
|
||||
private HashArrayList<Decimal> constant_decimal = new HashArrayList<>();
|
||||
|
||||
public List<Decimal> constant_decimal = new ArrayList<>();
|
||||
private HashArrayList<String> constant_string = new HashArrayList<>();
|
||||
|
||||
public List<String> constant_string = new ArrayList<>();
|
||||
private HashArrayList<Namespace> constant_namespace = new HashArrayList<>();
|
||||
|
||||
public List<Namespace> constant_namespace = new ArrayList<>();
|
||||
private HashArrayList<NamespaceSet> constant_namespace_set = new HashArrayList<>();
|
||||
|
||||
public List<NamespaceSet> constant_namespace_set = new ArrayList<>();
|
||||
private HashArrayList<Multiname> constant_multiname = new HashArrayList<>();
|
||||
|
||||
public List<Multiname> constant_multiname = new ArrayList<>();
|
||||
public AVM2ConstantPool() {
|
||||
}
|
||||
|
||||
@Internal
|
||||
public Map<String, DottedChain> dottedChainCache = new HashMap<>();
|
||||
|
||||
private void ensureDefault(List<?> list) {
|
||||
if (list.isEmpty()) {
|
||||
list.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void ensureIntCapacity(int capacity) {
|
||||
constant_int.ensureCapacity(capacity);
|
||||
if (capacity > 0) {
|
||||
ensureDefault(constant_int);
|
||||
}
|
||||
}
|
||||
|
||||
public void ensureNamespaceCapacity(int capacity) {
|
||||
constant_namespace.ensureCapacity(capacity);
|
||||
if (capacity > 0) {
|
||||
ensureDefault(constant_namespace);
|
||||
}
|
||||
}
|
||||
|
||||
public void ensureNamespaceSetCapacity(int capacity) {
|
||||
constant_namespace_set.ensureCapacity(capacity);
|
||||
if (capacity > 0) {
|
||||
ensureDefault(constant_namespace_set);
|
||||
}
|
||||
}
|
||||
|
||||
public void ensureMultinameCapacity(int capacity) {
|
||||
constant_multiname.ensureCapacity(capacity);
|
||||
if (capacity > 0) {
|
||||
ensureDefault(constant_multiname);
|
||||
}
|
||||
}
|
||||
|
||||
public void ensureUIntCapacity(int capacity) {
|
||||
constant_uint.ensureCapacity(capacity);
|
||||
if (capacity > 0) {
|
||||
ensureDefault(constant_uint);
|
||||
}
|
||||
}
|
||||
|
||||
public void ensureDoubleCapacity(int capacity) {
|
||||
constant_double.ensureCapacity(capacity);
|
||||
if (capacity > 0) {
|
||||
ensureDefault(constant_double);
|
||||
}
|
||||
}
|
||||
|
||||
public void ensureDecimalCapacity(int capacity) {
|
||||
constant_decimal.ensureCapacity(capacity);
|
||||
if (capacity > 0) {
|
||||
ensureDefault(constant_decimal);
|
||||
}
|
||||
}
|
||||
|
||||
public void ensureStringCapacity(int capacity) {
|
||||
constant_string.ensureCapacity(capacity);
|
||||
if (capacity > 0) {
|
||||
ensureDefault(constant_string);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized int addInt(long value) {
|
||||
ensureDefault(constant_int);
|
||||
constant_int.add(value);
|
||||
return constant_int.size() - 1;
|
||||
}
|
||||
|
||||
public synchronized int addNamespace(Namespace ns) {
|
||||
ensureDefault(constant_namespace);
|
||||
constant_namespace.add(ns);
|
||||
return constant_namespace.size() - 1;
|
||||
}
|
||||
@@ -69,31 +137,37 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
}
|
||||
|
||||
public synchronized int addNamespaceSet(NamespaceSet nss) {
|
||||
ensureDefault(constant_namespace_set);
|
||||
constant_namespace_set.add(nss);
|
||||
return constant_namespace_set.size() - 1;
|
||||
}
|
||||
|
||||
public synchronized int addMultiname(Multiname m) {
|
||||
ensureDefault(constant_multiname);
|
||||
constant_multiname.add(m);
|
||||
return constant_multiname.size() - 1;
|
||||
}
|
||||
|
||||
public synchronized int addUInt(long value) {
|
||||
ensureDefault(constant_uint);
|
||||
constant_uint.add(value);
|
||||
return constant_uint.size() - 1;
|
||||
}
|
||||
|
||||
public synchronized int addDouble(double value) {
|
||||
ensureDefault(constant_double);
|
||||
constant_double.add(value);
|
||||
return constant_double.size() - 1;
|
||||
}
|
||||
|
||||
public synchronized int addDecimal(Decimal value) {
|
||||
ensureDefault(constant_decimal);
|
||||
constant_decimal.add(value);
|
||||
return constant_decimal.size() - 1;
|
||||
}
|
||||
|
||||
public synchronized int addString(String value) {
|
||||
ensureDefault(constant_string);
|
||||
constant_string.add(value);
|
||||
return constant_string.size() - 1;
|
||||
}
|
||||
@@ -140,6 +214,9 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
|
||||
public long getInt(int index) {
|
||||
try {
|
||||
if (index == 0) {
|
||||
return 0;
|
||||
}
|
||||
return constant_int.get(index);
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
logger.log(Level.SEVERE, "Int not found. Index: " + index, ex);
|
||||
@@ -176,6 +253,9 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
|
||||
public long getUInt(int index) {
|
||||
try {
|
||||
if (index == 0) {
|
||||
return 0;
|
||||
}
|
||||
return constant_uint.get(index);
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
logger.log(Level.SEVERE, "UInt not found. Index: " + index, ex);
|
||||
@@ -185,6 +265,9 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
|
||||
public double getDouble(int index) {
|
||||
try {
|
||||
if (index == 0) {
|
||||
return 0;
|
||||
}
|
||||
return constant_double.get(index);
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
logger.log(Level.SEVERE, "Double not found. Index: " + index, ex);
|
||||
@@ -293,65 +376,27 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
}
|
||||
|
||||
private int getIntId(long value) {
|
||||
for (int i = 1; i < constant_int.size(); i++) {
|
||||
if (constant_int.get(i) == value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return constant_int.indexOf(value);
|
||||
}
|
||||
|
||||
private int getUIntId(long value) {
|
||||
for (int i = 1; i < constant_uint.size(); i++) {
|
||||
if (constant_uint.get(i) == value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return constant_uint.indexOf(value);
|
||||
}
|
||||
|
||||
private int getDoubleId(double value) {
|
||||
for (int i = 1; i < constant_double.size(); i++) {
|
||||
if (Double.isNaN(value) && Double.isNaN(constant_double.get(i))) {
|
||||
return i;
|
||||
}
|
||||
if (Double.compare(constant_double.get(i), value) == 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return constant_double.indexOf(value);
|
||||
}
|
||||
|
||||
private int getStringId(String val) {
|
||||
if (val == null) {
|
||||
return 0;
|
||||
}
|
||||
for (int i = 1; i < constant_string.size(); i++) {
|
||||
if (constant_string.get(i).equals(val)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
private int getStringId(String value) {
|
||||
return constant_string.indexOf(value);
|
||||
}
|
||||
|
||||
private int getMultinameId(Multiname val) {
|
||||
loopm:
|
||||
for (int m = 1; m < constant_multiname.size(); m++) {
|
||||
Multiname mul = constant_multiname.get(m);
|
||||
if (mul.kind == val.kind && mul.name_index == val.name_index && mul.namespace_index == val.namespace_index && mul.namespace_set_index == val.namespace_set_index && mul.qname_index == val.qname_index && mul.params.size() == val.params.size()) {
|
||||
for (int p = 0; p < mul.params.size(); p++) {
|
||||
if (mul.params.get(p) != val.params.get(p)) {
|
||||
continue loopm;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
private int getMultinameId(Multiname value) {
|
||||
return constant_multiname.indexOf(value);
|
||||
}
|
||||
|
||||
public int getQnameId(String name, int namespaceKind, String namespaceName, boolean add) {
|
||||
return getMultinameId(new Multiname(Multiname.QNAME, getStringId(name, add), getNamespaceId(namespaceKind, namespaceName, 0, add), 0, 0, new ArrayList<>()), add);
|
||||
return getMultinameId(new Multiname(Multiname.QNAME, getStringId(name, add), getNamespaceId(namespaceKind, namespaceName, 0, add), 0), add);
|
||||
}
|
||||
|
||||
public int getPublicQnameId(String name, boolean add) {
|
||||
@@ -503,14 +548,14 @@ public class AVM2ConstantPool implements Cloneable {
|
||||
public AVM2ConstantPool clone() {
|
||||
try {
|
||||
AVM2ConstantPool ret = (AVM2ConstantPool) super.clone();
|
||||
ret.constant_int = new ArrayList<>(constant_int);
|
||||
ret.constant_uint = new ArrayList<>(constant_uint);
|
||||
ret.constant_double = new ArrayList<>(constant_double);
|
||||
ret.constant_decimal = new ArrayList<>(constant_decimal);
|
||||
ret.constant_string = new ArrayList<>(constant_string);
|
||||
ret.constant_namespace = new ArrayList<>(constant_namespace);
|
||||
ret.constant_namespace_set = new ArrayList<>(constant_namespace_set);
|
||||
ret.constant_multiname = new ArrayList<>(constant_multiname);
|
||||
ret.constant_int = new HashArrayList<>(constant_int);
|
||||
ret.constant_uint = new HashArrayList<>(constant_uint);
|
||||
ret.constant_double = new HashArrayList<>(constant_double);
|
||||
ret.constant_decimal = new HashArrayList<>(constant_decimal);
|
||||
ret.constant_string = new HashArrayList<>(constant_string);
|
||||
ret.constant_namespace = new HashArrayList<>(constant_namespace);
|
||||
ret.constant_namespace_set = new HashArrayList<>(constant_namespace_set);
|
||||
ret.constant_multiname = new HashArrayList<>(constant_multiname);
|
||||
ret.dottedChainCache = new HashMap<>();
|
||||
return ret;
|
||||
} catch (CloneNotSupportedException ex) {
|
||||
|
||||
@@ -163,7 +163,7 @@ public abstract class InstructionDefinition implements Serializable {
|
||||
protected FullMultinameAVM2Item resolveMultiname(boolean property, TranslateStack stack, AVM2ConstantPool constants, int multinameIndex, AVM2Instruction ins) {
|
||||
GraphTargetItem ns = null;
|
||||
GraphTargetItem name = null;
|
||||
if (multinameIndex > 0 && multinameIndex < constants.constant_multiname.size()) {
|
||||
if (multinameIndex > 0 && multinameIndex < constants.getMultinameCount()) {
|
||||
if (constants.getMultiname(multinameIndex).needsName()) {
|
||||
name = stack.pop();
|
||||
}
|
||||
@@ -177,7 +177,7 @@ public abstract class InstructionDefinition implements Serializable {
|
||||
|
||||
protected int getMultinameRequiredStackSize(AVM2ConstantPool constants, int multinameIndex) {
|
||||
int res = 0;
|
||||
if (multinameIndex > 0 && multinameIndex < constants.constant_multiname.size()) {
|
||||
if (multinameIndex > 0 && multinameIndex < constants.getMultinameCount()) {
|
||||
//Note: In official compiler, the stack can be wrong(greater) for some MULTINAMEL/A, e.g. increments
|
||||
/*
|
||||
var arr=[1,2,3];
|
||||
|
||||
@@ -103,7 +103,7 @@ public class FullMultinameAVM2Item extends AVM2Item {
|
||||
} else {
|
||||
AVM2ConstantPool constants = localData.constantsAvm2;
|
||||
List<DottedChain> fullyQualifiedNames = property ? new ArrayList<>() : localData.fullyQualifiedNames;
|
||||
if (multinameIndex > 0 && multinameIndex < constants.constant_multiname.size()) {
|
||||
if (multinameIndex > 0 && multinameIndex < constants.getMultinameCount()) {
|
||||
writer.append(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames, false));
|
||||
} else {
|
||||
writer.append("§§unknown_multiname");
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -112,19 +113,21 @@ public class InitVectorAVM2Item extends AVM2Item {
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
AVM2SourceGenerator g = (AVM2SourceGenerator) generator;
|
||||
List<GraphSourceItem> ret = toSourceMerge(localData, generator,
|
||||
ins(AVM2Instructions.FindPropertyStrict, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAME, g.abcIndex.getSelectedAbc().constants.getStringId("Vector", true), 0, g.abcIndex.getSelectedAbc().constants.getNamespaceSetId(new NamespaceSet(new int[]{g.abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, "__AS3__.vec", 0, true)}), true), 0, new ArrayList<>()), true)),
|
||||
ins(AVM2Instructions.GetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAME, g.abcIndex.getSelectedAbc().constants.getStringId("Vector", true), 0, allNsSet(g.abcIndex.getSelectedAbc()), 0, new ArrayList<>()), true)),
|
||||
ins(AVM2Instructions.FindPropertyStrict, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAME, g.abcIndex.getSelectedAbc().constants.getStringId("Vector", true), 0, g.abcIndex.getSelectedAbc().constants.getNamespaceSetId(new NamespaceSet(new int[]{g.abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, "__AS3__.vec", 0, true)}), true)), true)),
|
||||
ins(AVM2Instructions.GetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAME, g.abcIndex.getSelectedAbc().constants.getStringId("Vector", true), 0, allNsSet(g.abcIndex.getSelectedAbc())), true)),
|
||||
subtype,
|
||||
ins(AVM2Instructions.ApplyType, 1),
|
||||
new IntegerValueAVM2Item(null, (long) arguments.size()),
|
||||
ins(AVM2Instructions.Construct, 1)
|
||||
);
|
||||
for (int i = 0; i < arguments.size(); i++) {
|
||||
// qname_index == precedence and params == openedNamespaced ???
|
||||
int[] arr = Helper.toIntArray(openedNamespaces);
|
||||
ret.addAll(toSourceMerge(localData, generator,
|
||||
ins(AVM2Instructions.Dup),
|
||||
new IntegerValueAVM2Item(null, (long) i),
|
||||
arguments.get(i),
|
||||
ins(AVM2Instructions.SetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, g.abcIndex.getSelectedAbc().constants.getNamespaceSetId(new NamespaceSet(new int[]{g.abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true)}), true), precedence, openedNamespaces), true))
|
||||
ins(AVM2Instructions.SetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, g.abcIndex.getSelectedAbc().constants.getNamespaceSetId(new NamespaceSet(new int[]{g.abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true)}), true), precedence, arr), true))
|
||||
));
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -93,7 +93,7 @@ public class TryAVM2Item extends AVM2Item implements Block {
|
||||
|
||||
int eti = catchExceptions.get(e).type_index;
|
||||
|
||||
data.declaredType = eti <= 0 ? DottedChain.ALL : localData.constantsAvm2.constant_multiname.get(eti).getNameWithNamespace(localData.constantsAvm2);
|
||||
data.declaredType = eti <= 0 ? DottedChain.ALL : localData.constantsAvm2.getMultiname(eti).getNameWithNamespace(localData.constantsAvm2);
|
||||
writer.hilightSpecial(localName, HighlightSpecialType.TRY_NAME, e, data);
|
||||
writer.append(":");
|
||||
writer.hilightSpecial(catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames), HighlightSpecialType.TRY_TYPE, e);
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitFunction;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
@@ -263,7 +264,7 @@ public class ASM3Parser {
|
||||
int namespace_index = 0;
|
||||
int namespace_set_index = 0;
|
||||
int qname_index = 0;
|
||||
List<Integer> params = new ArrayList<>();
|
||||
int[] params = null;
|
||||
|
||||
switch (s.type) {
|
||||
case ParsedSymbol.TYPE_KEYWORD_NULL:
|
||||
@@ -361,12 +362,14 @@ public class ASM3Parser {
|
||||
expected(ParsedSymbol.TYPE_PARENT_OPEN, "(", lexer);
|
||||
qname_index = parseMultiName(constants, lexer);
|
||||
expected(ParsedSymbol.TYPE_LOWERTHAN, "<", lexer);
|
||||
params.add(parseMultiName(constants, lexer));
|
||||
List<Integer> paramsList = new ArrayList<>();
|
||||
paramsList.add(parseMultiName(constants, lexer));
|
||||
ParsedSymbol nt = lexer.lex();
|
||||
while (nt.type == ParsedSymbol.TYPE_COMMA) {
|
||||
params.add(parseMultiName(constants, lexer));
|
||||
paramsList.add(parseMultiName(constants, lexer));
|
||||
nt = lexer.lex();
|
||||
}
|
||||
params = Helper.toIntArray(paramsList);
|
||||
expected(nt, ParsedSymbol.TYPE_GREATERTHAN, ">");
|
||||
expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer);
|
||||
break;
|
||||
|
||||
@@ -146,7 +146,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
|
||||
return GraphTargetItem.toSourceMerge(localData, this,
|
||||
item.object,
|
||||
ins(AVM2Instructions.GetDescendants, abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAME, abcIndex.getSelectedAbc().constants.getStringId(item.nameStr, true), 0, nsset, 0, new ArrayList<>()), true))
|
||||
ins(AVM2Instructions.GetDescendants, abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAME, abcIndex.getSelectedAbc().constants.getStringId(item.nameStr, true), 0, nsset), true))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
ins(AVM2Instructions.CheckFilter),
|
||||
NameAVM2Item.generateCoerce(localData, this, TypeItem.UNBOUNDED),
|
||||
AssignableAVM2Item.setTemp(localData, this, collectionReg),
|
||||
ins(AVM2Instructions.GetLex, abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, abcIndex.getSelectedAbc().constants.getStringId("XMLList", true), abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true), 0, 0, new ArrayList<>()), true)),
|
||||
ins(AVM2Instructions.GetLex, abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, abcIndex.getSelectedAbc().constants.getStringId("XMLList", true), abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true), 0), true)),
|
||||
ins(AVM2Instructions.PushString, abcIndex.getSelectedAbc().constants.getStringId("", true)),
|
||||
ins(AVM2Instructions.Construct, 1),
|
||||
xmlListSetTemp
|
||||
@@ -316,7 +316,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
for (int i = 0; i < item.openedNamespaces.size(); i++) {
|
||||
nss[i] = item.openedNamespaces.get(i);
|
||||
}
|
||||
trueBody.add(ins(AVM2Instructions.SetProperty, abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, abcIndex.getSelectedAbc().constants.getNamespaceSetId(new NamespaceSet(nss), true), 0, new ArrayList<>()), true)));
|
||||
trueBody.add(ins(AVM2Instructions.SetProperty, abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, abcIndex.getSelectedAbc().constants.getNamespaceSetId(new NamespaceSet(nss), true)), true)));
|
||||
forBody.add(ins(AVM2Instructions.IfFalse, insToBytes(trueBody).length));
|
||||
forBody.addAll(trueBody);
|
||||
forBody.add(ins(AVM2Instructions.PopScope));
|
||||
@@ -694,7 +694,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
ret.add(ins(AVM2Instructions.Dup));
|
||||
ret.add(ins(AVM2Instructions.GetScopeObject, scope));
|
||||
ret.add(ins(AVM2Instructions.Swap));
|
||||
ret.add(ins(AVM2Instructions.SetProperty, abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, abcIndex.getSelectedAbc().constants.getStringId(item.functionName, true), abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, localData.pkg, 0, true), 0, 0, new ArrayList<>()), true)));
|
||||
ret.add(ins(AVM2Instructions.SetProperty, abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, abcIndex.getSelectedAbc().constants.getStringId(item.functionName, true), abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, localData.pkg, 0, true), 0), true)));
|
||||
ret.add(ins(AVM2Instructions.PopScope));
|
||||
localData.scopeStack.remove(localData.scopeStack.size() - 1);
|
||||
}
|
||||
@@ -716,7 +716,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
int finallyEx = -1;
|
||||
for (NameAVM2Item e : item.catchExceptions2) {
|
||||
ABCException aex = new ABCException();
|
||||
aex.name_index = abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, abcIndex.getSelectedAbc().constants.getStringId(e.getVariableName(), true), abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true), 0, 0, new ArrayList<>()), true);
|
||||
aex.name_index = abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, abcIndex.getSelectedAbc().constants.getStringId(e.getVariableName(), true), abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true), 0), true);
|
||||
aex.type_index = typeName(localData, e.type);
|
||||
newex.add(aex);
|
||||
}
|
||||
@@ -1289,7 +1289,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
|
||||
public int traitName(int namespace, String var) {
|
||||
return abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, str(var), namespace, 0, 0, new ArrayList<>()), true);
|
||||
return abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, str(var), namespace, 0), true);
|
||||
}
|
||||
|
||||
public int typeName(SourceGeneratorLocalData localData, GraphTargetItem type) throws CompilationException {
|
||||
@@ -1338,7 +1338,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
public int propertyName(GraphTargetItem name) {
|
||||
if (name instanceof NameAVM2Item) {
|
||||
NameAVM2Item va = (NameAVM2Item) name;
|
||||
return abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, str(va.getVariableName()), namespace(Namespace.KIND_PACKAGE, ""), 0, 0, new ArrayList<>()), true);
|
||||
return abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, str(va.getVariableName()), namespace(Namespace.KIND_PACKAGE, ""), 0), true);
|
||||
}
|
||||
throw new RuntimeException("no prop"); //FIXME
|
||||
}
|
||||
@@ -1638,7 +1638,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
for (int i = 1; i < slotNames.size(); i++) {
|
||||
TraitSlotConst tsc = new TraitSlotConst();
|
||||
tsc.slot_id = slotId++;
|
||||
tsc.name_index = abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, abcIndex.getSelectedAbc().constants.getStringId(slotNames.get(i), true), abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE_INTERNAL, pkg, 0, true), 0, 0, new ArrayList<>()), true);
|
||||
tsc.name_index = abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, abcIndex.getSelectedAbc().constants.getStringId(slotNames.get(i), true), abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE_INTERNAL, pkg, 0, true), 0), true);
|
||||
tsc.type_index = typeName(localData, new TypeItem(slotTypes.get(i)));
|
||||
mbody.traits.traits.add(tsc);
|
||||
}
|
||||
@@ -1673,7 +1673,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
TraitSlotConst tsc = (TraitSlotConst) mbody.traits.traits.get(i);
|
||||
GraphTargetItem type = TypeItem.UNBOUNDED;
|
||||
if (tsc.type_index > 0) {
|
||||
type = new TypeItem(abcIndex.getSelectedAbc().constants.constant_multiname.get(tsc.type_index).getNameWithNamespace(abcIndex.getSelectedAbc().constants));
|
||||
type = new TypeItem(abcIndex.getSelectedAbc().constants.getMultiname(tsc.type_index).getNameWithNamespace(abcIndex.getSelectedAbc().constants));
|
||||
}
|
||||
NameAVM2Item d = new NameAVM2Item(type, 0, tsc.getName(abcIndex.getSelectedAbc()).getName(abcIndex.getSelectedAbc().constants, null, true), NameAVM2Item.getDefaultValue("" + type), true, new ArrayList<>());
|
||||
d.setSlotNumber(tsc.slot_id);
|
||||
@@ -1907,12 +1907,12 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
new Multiname(
|
||||
Multiname.QNAME,
|
||||
abcIndex.getSelectedAbc().constants.getStringId(((ClassAVM2Item) item).className, true),
|
||||
((ClassAVM2Item) item).namespace, 0, 0, new ArrayList<>()), true);
|
||||
((ClassAVM2Item) item).namespace, 0), true);
|
||||
|
||||
if (((ClassAVM2Item) item).extendsOp != null) {
|
||||
instanceInfo.super_index = typeName(localData, ((ClassAVM2Item) item).extendsOp);
|
||||
} else {
|
||||
instanceInfo.super_index = abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, str("Object"), namespace(Namespace.KIND_PACKAGE, ""), 0, 0, new ArrayList<>()), true);
|
||||
instanceInfo.super_index = abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, str("Object"), namespace(Namespace.KIND_PACKAGE, ""), 0), true);
|
||||
}
|
||||
instanceInfo.interfaces = new int[((ClassAVM2Item) item).implementsOp.size()];
|
||||
for (int i = 0; i < ((ClassAVM2Item) item).implementsOp.size(); i++) {
|
||||
@@ -1922,7 +1922,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
if (item instanceof InterfaceAVM2Item) {
|
||||
InstanceInfo instanceInfo = abcIndex.getSelectedAbc().instance_info.get(((TraitClass) traits[k]).class_info);
|
||||
instanceInfo.name_index = abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, abcIndex.getSelectedAbc().constants.getStringId(((InterfaceAVM2Item) item).name, true),
|
||||
abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, ((InterfaceAVM2Item) item).pkg, 0, true), 0, 0, new ArrayList<>()), true);
|
||||
abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, ((InterfaceAVM2Item) item).pkg, 0, true), 0), true);
|
||||
|
||||
instanceInfo.interfaces = new int[((InterfaceAVM2Item) item).superInterfaces.size()];
|
||||
for (int i = 0; i < ((InterfaceAVM2Item) item).superInterfaces.size(); i++) {
|
||||
@@ -1943,8 +1943,8 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
TypeItem sup = (TypeItem) un;
|
||||
int propId = resolveType(localData, sup, abcIndex);
|
||||
int[] nss = new int[]{abcIndex.getSelectedAbc().constants.constant_multiname.get(propId).namespace_index};
|
||||
return abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAME, abcIndex.getSelectedAbc().constants.constant_multiname.get(propId).name_index, 0, abcIndex.getSelectedAbc().constants.getNamespaceSetId(new NamespaceSet(nss), true), 0, new ArrayList<>()), true);
|
||||
int[] nss = new int[]{abcIndex.getSelectedAbc().constants.getMultiname(propId).namespace_index};
|
||||
return abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAME, abcIndex.getSelectedAbc().constants.getMultiname(propId).name_index, 0, abcIndex.getSelectedAbc().constants.getNamespaceSetId(new NamespaceSet(nss), true)), true);
|
||||
|
||||
}
|
||||
|
||||
@@ -2163,8 +2163,8 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
mbCode.add(ins(AVM2Instructions.GetScopeObject, 0));
|
||||
traitScope++;
|
||||
} else {
|
||||
NamespaceSet nsset = new NamespaceSet(new int[]{abcIndex.getSelectedAbc().constants.constant_multiname.get(tc.name_index).namespace_index});
|
||||
mbCode.add(ins(AVM2Instructions.FindPropertyStrict, abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAME, abcIndex.getSelectedAbc().constants.constant_multiname.get(tc.name_index).name_index, 0, abcIndex.getSelectedAbc().constants.getNamespaceSetId(nsset, true), 0, new ArrayList<>()), true)));
|
||||
NamespaceSet nsset = new NamespaceSet(new int[]{abcIndex.getSelectedAbc().constants.getMultiname(tc.name_index).namespace_index});
|
||||
mbCode.add(ins(AVM2Instructions.FindPropertyStrict, abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAME, abcIndex.getSelectedAbc().constants.getMultiname(tc.name_index).name_index, 0, abcIndex.getSelectedAbc().constants.getNamespaceSetId(nsset, true)), true)));
|
||||
}
|
||||
if (abcIndex.getSelectedAbc().instance_info.get(tc.class_info).isInterface()) {
|
||||
mbCode.add(ins(AVM2Instructions.PushNull));
|
||||
@@ -2179,7 +2179,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
new Multiname(origM.kind,
|
||||
abcIndex.getSelectedAbc().constants.getStringId(ci.abc.constants.getString(origM.name_index), true),
|
||||
abcIndex.getSelectedAbc().constants.getNamespaceId(origNs.kind,
|
||||
ci.abc.constants.getString(origNs.name_index), 0, true), 0, 0, new ArrayList<>()), true));
|
||||
ci.abc.constants.getString(origNs.name_index), 0, true), 0), true));
|
||||
}
|
||||
|
||||
//add all parent objects to scopestack
|
||||
@@ -2223,12 +2223,12 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
indices.add(m);
|
||||
continue;
|
||||
}
|
||||
Multiname superName = a.constants.constant_multiname.get(m);
|
||||
Multiname superName = a.constants.getMultiname(m);
|
||||
indices.add(
|
||||
abc.getSelectedAbc().constants.getMultinameId(
|
||||
new Multiname(Multiname.QNAME,
|
||||
abc.getSelectedAbc().constants.getStringId(superName.getName(a.constants, null, true), true),
|
||||
abc.getSelectedAbc().constants.getNamespaceId(superName.getNamespace(a.constants).kind, superName.getNamespace(a.constants).getName(a.constants), 0, true), 0, 0, new ArrayList<>()), true)
|
||||
abc.getSelectedAbc().constants.getNamespaceId(superName.getNamespace(a.constants).kind, superName.getNamespace(a.constants).getName(a.constants), 0, true), 0), true)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2299,13 +2299,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
|
||||
public static void parentNames(AbcIndexing abc, 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.constant_multiname.get(name_index).getNameWithNamespace(abc.getSelectedAbc().constants)));
|
||||
AbcIndexing.ClassIndex ci = abc.findClass(new TypeItem(abc.getSelectedAbc().constants.getMultiname(name_index).getNameWithNamespace(abc.getSelectedAbc().constants)));
|
||||
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.constant_multiname.get(ni).getName(ci.abc.constants, null, true));
|
||||
namespaces.add(ci.abc.constants.constant_multiname.get(ni).getNamespace(ci.abc.constants).getName(ci.abc.constants).toRawString());
|
||||
names.add(ci.abc.constants.getMultiname(ni).getName(ci.abc.constants, null, true));
|
||||
namespaces.add(ci.abc.constants.getMultiname(ni).getNamespace(ci.abc.constants).getName(ci.abc.constants).toRawString());
|
||||
ci = ci.parent;
|
||||
}
|
||||
}
|
||||
@@ -2406,8 +2406,8 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < abc.getSelectedAbc().constants.constant_multiname.size(); i++) {
|
||||
Multiname mname = abc.getSelectedAbc().constants.constant_multiname.get(i);
|
||||
for (int i = 1; i < abc.getSelectedAbc().constants.getMultinameCount(); i++) {
|
||||
Multiname mname = abc.getSelectedAbc().constants.getMultiname(i);
|
||||
if (mname != null && name.equals(mname.getName(abc.getSelectedAbc().constants, null, true))) {
|
||||
if (mname.getNamespace(abc.getSelectedAbc().constants) != null && pkg.equals(mname.getNamespace(abc.getSelectedAbc().constants).getName(abc.getSelectedAbc().constants))) {
|
||||
name_index = i;
|
||||
@@ -2425,15 +2425,16 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
}
|
||||
if (name_index == 0) {
|
||||
name_index = abc.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, abc.getSelectedAbc().constants.getStringId(name, true), abc.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, pkg, 0, true), 0, 0, new ArrayList<>()), true);
|
||||
name_index = abc.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, abc.getSelectedAbc().constants.getStringId(name, true), abc.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, pkg, 0, true), 0), true);
|
||||
}
|
||||
}
|
||||
|
||||
if (item instanceof ApplyTypeAVM2Item) {
|
||||
ApplyTypeAVM2Item atype = (ApplyTypeAVM2Item) item;
|
||||
List<Integer> params = new ArrayList<>();
|
||||
int[] params = new int[atype.params.size()];
|
||||
int i = 0;
|
||||
for (GraphTargetItem s : atype.params) {
|
||||
params.add(resolveType(localData, s, abc));
|
||||
params[i++] = resolveType(localData, s, abc);
|
||||
}
|
||||
return abc.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.TYPENAME, 0, 0, 0, name_index, params), true);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,9 @@ import java.util.Set;
|
||||
public class AbcIndexing {
|
||||
|
||||
private AbcIndexing parent = null;
|
||||
|
||||
private List<ABC> abcs = new ArrayList<>();
|
||||
|
||||
private ABC selectedAbc = null;
|
||||
|
||||
/**
|
||||
@@ -100,8 +102,11 @@ public class AbcIndexing {
|
||||
public static class PropertyDef {
|
||||
|
||||
private final String propName;
|
||||
|
||||
private final GraphTargetItem parent;
|
||||
|
||||
private int propNsIndex = 0;
|
||||
|
||||
private ABC abc = null;
|
||||
|
||||
@Override
|
||||
@@ -172,7 +177,6 @@ public class AbcIndexing {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,9 +185,11 @@ public class AbcIndexing {
|
||||
public static class PropertyNsDef {
|
||||
|
||||
private final String propName;
|
||||
|
||||
private final DottedChain ns;
|
||||
|
||||
private int propNsIndex = 0;
|
||||
|
||||
private ABC abc = null;
|
||||
|
||||
public void setPrivate(ABC abc, int propNsIndex) {
|
||||
@@ -245,15 +251,18 @@ public class AbcIndexing {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class TraitIndex {
|
||||
|
||||
public Trait trait;
|
||||
|
||||
public ABC abc;
|
||||
|
||||
public GraphTargetItem returnType;
|
||||
|
||||
public ValueKind value;
|
||||
|
||||
public GraphTargetItem objType;
|
||||
|
||||
public TraitIndex(Trait trait, ABC abc, GraphTargetItem type, ValueKind value, GraphTargetItem objType) {
|
||||
@@ -263,13 +272,14 @@ public class AbcIndexing {
|
||||
this.value = value;
|
||||
this.objType = objType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class ClassIndex {
|
||||
|
||||
public int index;
|
||||
|
||||
public ABC abc;
|
||||
|
||||
public ClassIndex parent;
|
||||
|
||||
@Override
|
||||
@@ -285,11 +295,15 @@ public class AbcIndexing {
|
||||
}
|
||||
|
||||
private final Map<GraphTargetItem, ClassIndex> classes = new HashMap<>();
|
||||
|
||||
private final Map<PropertyDef, TraitIndex> instanceProperties = new HashMap<>();
|
||||
|
||||
private final Map<PropertyDef, TraitIndex> classProperties = new HashMap<>();
|
||||
|
||||
private final Map<PropertyNsDef, TraitIndex> instanceNsProperties = new HashMap<>();
|
||||
|
||||
private final Map<PropertyNsDef, TraitIndex> classNsProperties = new HashMap<>();
|
||||
|
||||
private final Map<PropertyNsDef, TraitIndex> scriptProperties = new HashMap<>();
|
||||
|
||||
public ClassIndex findClass(GraphTargetItem cls) {
|
||||
@@ -397,7 +411,7 @@ public class AbcIndexing {
|
||||
if (m_index == 0) {
|
||||
return TypeItem.UNBOUNDED;
|
||||
}
|
||||
Multiname m = constants.constant_multiname.get(m_index);
|
||||
Multiname m = constants.getMultiname(m_index);
|
||||
if (m.kind == Multiname.TYPENAME) {
|
||||
GraphTargetItem obj = multinameToType(m.qname_index, constants);
|
||||
List<GraphTargetItem> params = new ArrayList<>();
|
||||
@@ -445,7 +459,7 @@ public 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), multinameToType(name_index, abc.constants), abc, abc.constants.constant_multiname.get(t.name_index).namespace_index);
|
||||
PropertyDef dp = new PropertyDef(t.getName(abc).getName(abc.constants, new ArrayList<>() /*?*/, true), multinameToType(name_index, abc.constants), abc, abc.constants.getMultiname(t.name_index).namespace_index);
|
||||
map.put(dp, new TraitIndex(t, abc, getTraitReturnType(abc, t), propValue, multinameToType(name_index, abc.constants)));
|
||||
}
|
||||
if (mapNs != null) {
|
||||
@@ -568,5 +582,4 @@ public class AbcIndexing {
|
||||
public ABC getSelectedAbc() {
|
||||
return selectedAbc;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class IndexAVM2Item extends AssignableAVM2Item {
|
||||
Reference<Integer> index_temp = new Reference<>(-1);
|
||||
Reference<Integer> val_temp = new Reference<>(-1);
|
||||
AVM2SourceGenerator g = (AVM2SourceGenerator) generator;
|
||||
int indexPropIndex = g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(attr ? Multiname.MULTINAMELA : Multiname.MULTINAMEL, 0, 0, allNsSet(g.abcIndex.getSelectedAbc()), 0, new ArrayList<>()), true);
|
||||
int indexPropIndex = g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(attr ? Multiname.MULTINAMELA : Multiname.MULTINAMEL, 0, 0, allNsSet(g.abcIndex.getSelectedAbc())), true);
|
||||
|
||||
return toSourceMerge(localData, generator,
|
||||
object, dupSetTemp(localData, generator, obj_temp),
|
||||
@@ -110,7 +110,7 @@ public class IndexAVM2Item extends AssignableAVM2Item {
|
||||
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn, boolean call, List<GraphTargetItem> callargs, boolean delete, boolean construct) throws CompilationException {
|
||||
AVM2SourceGenerator g = (AVM2SourceGenerator) generator;
|
||||
int indexPropIndex = g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(attr ? Multiname.MULTINAMELA : Multiname.MULTINAMEL, 0, 0, allNsSet(g.abcIndex.getSelectedAbc()), 0, new ArrayList<>()), true);
|
||||
int indexPropIndex = g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(attr ? Multiname.MULTINAMELA : Multiname.MULTINAMEL, 0, 0, allNsSet(g.abcIndex.getSelectedAbc())), true);
|
||||
Reference<Integer> ret_temp = new Reference<>(-1);
|
||||
|
||||
if (assignedValue != null) {
|
||||
|
||||
@@ -105,14 +105,14 @@ public class NamespacedAVM2Item extends AssignableAVM2Item {
|
||||
if (name != null) {
|
||||
return toSourceMerge(localData, generator,
|
||||
ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)),
|
||||
ins(AVM2Instructions.FindPropertyStrict, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abcIndex.getSelectedAbc().constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)),
|
||||
ins(AVM2Instructions.FindPropertyStrict, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abcIndex.getSelectedAbc().constants.getStringId(name, true), 0, 0), true)),
|
||||
dupSetTemp(localData, generator, name_temp),
|
||||
ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)),
|
||||
dupSetTemp(localData, generator, ns_temp),
|
||||
//Start get original
|
||||
//getTemp(localData, generator, ns_temp), generateCoerce(generator, "Namespace"), ins(AVM2Instructions.FindPropertyStrict, g.abc.getLastAbc().constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abc.getLastAbc().constants.getStringId(variableName, true), 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
//getTemp(localData, generator, ns_temp), generateCoerce(generator, "Namespace"),
|
||||
ins(AVM2Instructions.GetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abcIndex.getSelectedAbc()), 0, new ArrayList<>()), true)),
|
||||
ins(AVM2Instructions.GetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abcIndex.getSelectedAbc())), true)),
|
||||
!isInteger ? ins(AVM2Instructions.ConvertD) : null,
|
||||
//End get original
|
||||
(!post) ? (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)) : null,
|
||||
@@ -122,7 +122,7 @@ public class NamespacedAVM2Item extends AssignableAVM2Item {
|
||||
getTemp(localData, generator, name_temp),
|
||||
getTemp(localData, generator, ns_temp),
|
||||
getTemp(localData, generator, ret_temp),
|
||||
ins(AVM2Instructions.SetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abcIndex.getSelectedAbc()), 0, new ArrayList<>()), true)),
|
||||
ins(AVM2Instructions.SetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abcIndex.getSelectedAbc())), true)),
|
||||
killTemp(localData, generator, Arrays.asList(ret_temp, name_temp, ns_temp))
|
||||
);
|
||||
} else {
|
||||
@@ -156,20 +156,20 @@ public class NamespacedAVM2Item extends AssignableAVM2Item {
|
||||
if (name == null) {
|
||||
if (assignedValue != null) {
|
||||
return toSourceMerge(localData, generator,
|
||||
obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, nameItem, ins(AVM2Instructions.ConvertS), obj != null ? obj : ins(AVM2Instructions.FindPropertyStrict, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true)),
|
||||
obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, nameItem, ins(AVM2Instructions.ConvertS), obj != null ? obj : ins(AVM2Instructions.FindPropertyStrict, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0), true)),
|
||||
ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)), nameItem, ins(AVM2Instructions.ConvertS), assignedValue,
|
||||
needsReturn ? dupSetTemp(localData, generator, ret_temp) : null,
|
||||
ins(AVM2Instructions.SetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true)),
|
||||
ins(AVM2Instructions.SetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0), true)),
|
||||
needsReturn ? getTemp(localData, generator, ret_temp) : null,
|
||||
killTemp(localData, generator, Arrays.asList(ns_temp, index_temp, ret_temp))
|
||||
);
|
||||
} else {
|
||||
return toSourceMerge(localData, generator,
|
||||
obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, nameItem, ins(AVM2Instructions.ConvertS), obj != null ? obj : ins(AVM2Instructions.FindPropertyStrict, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true)),
|
||||
obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, nameItem, ins(AVM2Instructions.ConvertS), obj != null ? obj : ins(AVM2Instructions.FindPropertyStrict, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0), true)),
|
||||
call ? dupSetTemp(localData, generator, obj_temp) : null,
|
||||
ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)), nameItem, ins(AVM2Instructions.ConvertS),
|
||||
construct ? callargs : null,
|
||||
ins(construct ? AVM2Instructions.ConstructProp : delete ? AVM2Instructions.DeleteProperty : AVM2Instructions.GetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true), construct ? callargs.size() : null),
|
||||
ins(construct ? AVM2Instructions.ConstructProp : delete ? AVM2Instructions.DeleteProperty : AVM2Instructions.GetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0), true), construct ? callargs.size() : null),
|
||||
call ? getTemp(localData, generator, obj_temp) : null,
|
||||
call ? callargs : null,
|
||||
call ? ins(AVM2Instructions.Call, callargs.size()) : null,
|
||||
@@ -180,20 +180,20 @@ public class NamespacedAVM2Item extends AssignableAVM2Item {
|
||||
} else {
|
||||
if (assignedValue != null) {
|
||||
return toSourceMerge(localData, generator,
|
||||
obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, obj != null ? obj : ins(AVM2Instructions.FindPropertyStrict, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abcIndex.getSelectedAbc().constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)),
|
||||
obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, obj != null ? obj : ins(AVM2Instructions.FindPropertyStrict, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abcIndex.getSelectedAbc().constants.getStringId(name, true), 0, 0), true)),
|
||||
ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)), assignedValue,
|
||||
needsReturn ? dupSetTemp(localData, generator, ret_temp) : null,
|
||||
ins(AVM2Instructions.SetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abcIndex.getSelectedAbc().constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)),
|
||||
ins(AVM2Instructions.SetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abcIndex.getSelectedAbc().constants.getStringId(name, true), 0, 0), true)),
|
||||
needsReturn ? getTemp(localData, generator, ret_temp) : null,
|
||||
killTemp(localData, generator, Arrays.asList(ns_temp, index_temp, ret_temp))
|
||||
);
|
||||
} else {
|
||||
return toSourceMerge(localData, generator,
|
||||
obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, obj != null ? obj : ins(AVM2Instructions.FindPropertyStrict, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abcIndex.getSelectedAbc().constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)),
|
||||
obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, obj != null ? obj : ins(AVM2Instructions.FindPropertyStrict, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abcIndex.getSelectedAbc().constants.getStringId(name, true), 0, 0), true)),
|
||||
call ? dupSetTemp(localData, generator, obj_temp) : null,
|
||||
ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)),
|
||||
construct ? callargs : null,
|
||||
ins(construct ? AVM2Instructions.ConstructProp : delete ? AVM2Instructions.DeleteProperty : AVM2Instructions.GetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abcIndex.getSelectedAbc().constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true), construct ? callargs.size() : null),
|
||||
ins(construct ? AVM2Instructions.ConstructProp : delete ? AVM2Instructions.DeleteProperty : AVM2Instructions.GetProperty, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abcIndex.getSelectedAbc().constants.getStringId(name, true), 0, 0), true), construct ? callargs.size() : null),
|
||||
call ? getTemp(localData, generator, obj_temp) : null,
|
||||
call ? callargs : null,
|
||||
call ? ins(AVM2Instructions.Call, callargs.size()) : null,
|
||||
|
||||
@@ -95,7 +95,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
if (m_index == 0) {
|
||||
return TypeItem.UNBOUNDED;
|
||||
}
|
||||
Multiname m = constants.constant_multiname.get(m_index);
|
||||
Multiname m = constants.getMultiname(m_index);
|
||||
if (m.kind == Multiname.TYPENAME) {
|
||||
GraphTargetItem obj = multinameToType(m.qname_index, constants);
|
||||
List<GraphTargetItem> params = new ArrayList<>();
|
||||
@@ -222,7 +222,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
propType = outPropType.getVal();
|
||||
propIndex = abc.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME,
|
||||
abc.getSelectedAbc().constants.getStringId(propertyName, true),
|
||||
abc.getSelectedAbc().constants.getNamespaceId(outPropNsKind.getVal(), outPropNs.getVal(), outPropNsIndex.getVal(), true), 0, 0, new ArrayList<>()), true
|
||||
abc.getSelectedAbc().constants.getNamespaceId(outPropNsKind.getVal(), outPropNs.getVal(), outPropNsIndex.getVal(), true), 0), true
|
||||
);
|
||||
propValue = outPropValue.getVal();
|
||||
propValueAbc = outPropValueAbc.getVal();
|
||||
@@ -252,11 +252,11 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
for (int i = 0; i < openedNamespaces.size(); i++) {
|
||||
int nsindex = openedNamespaces.get(i);
|
||||
|
||||
int nsKind = abc.getSelectedAbc().constants.constant_namespace.get(openedNamespaces.get(i)).kind;
|
||||
DottedChain nsname = abc.getSelectedAbc().constants.constant_namespace.get(openedNamespaces.get(i)).getName(abc.getSelectedAbc().constants);
|
||||
int nsKind = abc.getSelectedAbc().constants.getMultiname(openedNamespaces.get(i)).kind;
|
||||
DottedChain nsname = abc.getSelectedAbc().constants.getNamespace(openedNamespaces.get(i)).getName(abc.getSelectedAbc().constants);
|
||||
int name_index = 0;
|
||||
for (int m = 1; m < abc.getSelectedAbc().constants.constant_multiname.size(); m++) {
|
||||
Multiname mname = abc.getSelectedAbc().constants.constant_multiname.get(m);
|
||||
for (int m = 1; m < abc.getSelectedAbc().constants.getMultinameCount(); m++) {
|
||||
Multiname mname = abc.getSelectedAbc().constants.getMultiname(m);
|
||||
if (mname.kind == Multiname.QNAME && mname.getName(abc.getSelectedAbc().constants, null, true).equals(propertyName) && mname.namespace_index == nsindex) {
|
||||
name_index = m;
|
||||
break;
|
||||
@@ -331,7 +331,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
propType = p.returnType;
|
||||
propIndex = abc.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME,
|
||||
abc.getSelectedAbc().constants.getStringId(propertyName, true),
|
||||
abc.getSelectedAbc().constants.getNamespaceId(outPropNsKind.getVal(), outPropNs.getVal(), outPropNsIndex.getVal(), true), 0, 0, new ArrayList<>()), true
|
||||
abc.getSelectedAbc().constants.getNamespaceId(outPropNsKind.getVal(), outPropNs.getVal(), outPropNsIndex.getVal(), true), 0), true
|
||||
);
|
||||
propValue = p.value;
|
||||
propValueAbc = outPropValueAbc.getVal();
|
||||
@@ -359,7 +359,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
}
|
||||
propIndex = abc.getSelectedAbc().constants.getMultinameId(new Multiname(attr ? (pname.isEmpty() ? Multiname.MULTINAMELA : Multiname.MULTINAMEA) : Multiname.MULTINAME,
|
||||
abc.getSelectedAbc().constants.getStringId("*".equals(pname) ? null : pname, true), 0, //Note: name = * is for .@* attribute
|
||||
attr && pname.isEmpty() ? abc.getSelectedAbc().constants.getNamespaceSetId(new NamespaceSet(new int[]{abc.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE_INTERNAL, localData.pkg, 0, true)}), true) : allNsSet(), 0, new ArrayList<>()), true);
|
||||
attr && pname.isEmpty() ? abc.getSelectedAbc().constants.getNamespaceSetId(new NamespaceSet(new int[]{abc.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE_INTERNAL, localData.pkg, 0, true)}), true) : allNsSet()), true);
|
||||
propType = TypeItem.UNBOUNDED;
|
||||
objType = TypeItem.UNBOUNDED;
|
||||
propValue = null;
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -61,7 +60,7 @@ public class XMLAVM2Item extends AVM2Item {
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
AVM2SourceGenerator g = (AVM2SourceGenerator) generator;
|
||||
return toSourceMerge(localData, generator,
|
||||
ins(AVM2Instructions.GetLex, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, g.abcIndex.getSelectedAbc().constants.getStringId("XML", true), g.abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true), 0, 0, new ArrayList<>()), true)),
|
||||
ins(AVM2Instructions.GetLex, g.abcIndex.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.QNAME, g.abcIndex.getSelectedAbc().constants.getStringId("XML", true), g.abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true), 0), true)),
|
||||
value,
|
||||
ins(AVM2Instructions.Construct, 1)
|
||||
);
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.jpexs.decompiler.flash.abc.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Internal;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
@@ -31,6 +33,9 @@ public class ClassInfo {
|
||||
@Internal
|
||||
public boolean deleted;
|
||||
|
||||
@Internal
|
||||
public int lastDispId = -1;
|
||||
|
||||
public ClassInfo() {
|
||||
static_traits = new Traits();
|
||||
}
|
||||
@@ -47,4 +52,21 @@ public class ClassInfo {
|
||||
public String toString(ABC abc, List<DottedChain> fullyQualifiedNames) {
|
||||
return "method_index=" + cinit_index + "\r\n" + static_traits.toString(abc, fullyQualifiedNames);
|
||||
}
|
||||
|
||||
public int getNextDispId() {
|
||||
if (lastDispId == -1) {
|
||||
lastDispId = 0;
|
||||
for (Trait trait : static_traits.traits) {
|
||||
if (trait instanceof TraitMethodGetterSetter) {
|
||||
int dispId = ((TraitMethodGetterSetter) trait).disp_id;
|
||||
if (dispId > lastDispId) {
|
||||
lastDispId = dispId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastDispId++;
|
||||
return lastDispId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Internal;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -62,7 +63,7 @@ public class Multiname {
|
||||
|
||||
public final int qname_index; //for TypeName
|
||||
|
||||
public final List<Integer> params; //for TypeName
|
||||
public final int[] params; //for TypeName
|
||||
|
||||
@Internal
|
||||
public boolean deleted;
|
||||
@@ -85,7 +86,11 @@ public class Multiname {
|
||||
params = null;
|
||||
}
|
||||
|
||||
public Multiname(int kind, int name_index, int namespace_index, int namespace_set_index, int qname_index, List<Integer> params) {
|
||||
public Multiname(int kind, int name_index, int namespace_index, int namespace_set_index) {
|
||||
this(kind, name_index, namespace_index, namespace_set_index, 0, null);
|
||||
}
|
||||
|
||||
public Multiname(int kind, int name_index, int namespace_index, int namespace_set_index, int qname_index, int[] params) {
|
||||
this.kind = kind;
|
||||
this.name_index = name_index;
|
||||
this.namespace_index = namespace_index;
|
||||
@@ -178,7 +183,15 @@ public class Multiname {
|
||||
@Override
|
||||
public String toString() {
|
||||
String kindStr = getKindStr();
|
||||
return "kind=" + kindStr + " name_index=" + name_index + " namespace_index=" + namespace_index + " namespace_set_index=" + namespace_set_index + " qname_index=" + qname_index + " params_size:" + params.size();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("kind=").append(kindStr);
|
||||
sb.append(" name_index=").append(name_index);
|
||||
sb.append(" namespace_index=").append(namespace_index);
|
||||
sb.append(" namespace_set_index=").append(namespace_set_index);
|
||||
sb.append(" qname_index=").append(qname_index);
|
||||
sb.append(" params_size:");
|
||||
sb.append(params == null ? "null" : params.length);
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
@@ -247,11 +260,13 @@ public class Multiname {
|
||||
String tret = getKindStr() + "(";
|
||||
tret += multinameToString(constants, qname_index, fullyQualifiedNames);
|
||||
tret += "<";
|
||||
for (int i = 0; i < params.size(); i++) {
|
||||
if (i > 0) {
|
||||
tret += ",";
|
||||
if (params != null) {
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
if (i > 0) {
|
||||
tret += ",";
|
||||
}
|
||||
tret += multinameToString(constants, params[i], fullyQualifiedNames);
|
||||
}
|
||||
tret += multinameToString(constants, params.get(i), fullyQualifiedNames);
|
||||
}
|
||||
tret += ">";
|
||||
tret += ")";
|
||||
@@ -266,16 +281,17 @@ public class Multiname {
|
||||
}
|
||||
StringBuilder typeNameStr = new StringBuilder();
|
||||
typeNameStr.append(constants.getMultiname(qname_index).getName(constants, fullyQualifiedNames, raw));
|
||||
if (!params.isEmpty()) {
|
||||
if (params != null && params.length > 0) {
|
||||
typeNameStr.append(".<");
|
||||
for (int i = 0; i < params.size(); i++) {
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
if (i > 0) {
|
||||
typeNameStr.append(",");
|
||||
}
|
||||
if (params.get(i) == 0) {
|
||||
int param = params[i];
|
||||
if (param == 0) {
|
||||
typeNameStr.append("*");
|
||||
} else {
|
||||
typeNameStr.append(constants.getMultiname(params.get(i)).getName(constants, fullyQualifiedNames, raw));
|
||||
typeNameStr.append(constants.getMultiname(param).getName(constants, fullyQualifiedNames, raw));
|
||||
}
|
||||
}
|
||||
typeNameStr.append(">");
|
||||
@@ -373,7 +389,7 @@ public class Multiname {
|
||||
if (this.qname_index != other.qname_index) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(params, other.params)) {
|
||||
if (!Arrays.equals(params, other.params)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -100,7 +100,7 @@ public class Namespace {
|
||||
public String getNameWithKind(AVM2ConstantPool constants) {
|
||||
String kindStr = getKindStr();
|
||||
String nameStr = constants.getString(name_index);
|
||||
return kindStr + (nameStr.isEmpty() ? "" : " " + nameStr);
|
||||
return kindStr + (nameStr == null || nameStr.isEmpty() ? "" : " " + nameStr);
|
||||
}
|
||||
|
||||
public String getPrefix(ABC abc) {
|
||||
|
||||
@@ -72,10 +72,10 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
|
||||
int protectedNS = instanceInfo.protectedNS;
|
||||
if (protectedNS != 0) {
|
||||
abc.constants.constant_namespace.get(protectedNS).deleted = d;
|
||||
abc.constants.getNamespace(protectedNS).deleted = d;
|
||||
}
|
||||
|
||||
abc.constants.constant_multiname.get(name_index).deleted = d;
|
||||
abc.constants.getMultiname(name_index).deleted = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -289,7 +289,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
|| (ins.definition instanceof AsTypeIns)) {
|
||||
int m = ins.operands[0];
|
||||
if (m != 0) {
|
||||
if (m < abc.constants.constant_multiname.size()) {
|
||||
if (m < abc.constants.getMultinameCount()) {
|
||||
parseImportsUsagesFromMultiname(abc, imports, uses, abc.constants.getMultiname(m), ignorePackage, fullyQualifiedNames);
|
||||
}
|
||||
}
|
||||
@@ -297,7 +297,7 @@ public class TraitClass extends Trait implements TraitWithSlot {
|
||||
for (int k = 0; k < ins.definition.operands.length; k++) {
|
||||
if (ins.definition.operands[k] == AVM2Code.DAT_MULTINAME_INDEX) {
|
||||
int multinameIndex = ins.operands[k];
|
||||
if (multinameIndex < abc.constants.constant_multiname.size()) {
|
||||
if (multinameIndex < abc.constants.getMultinameCount()) {
|
||||
parseUsagesFromMultiname(abc, imports, uses, abc.constants.getMultiname(multinameIndex), ignorePackage, fullyQualifiedNames);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
|
||||
@Override
|
||||
public void delete(ABC abc, boolean d) {
|
||||
abc.constants.constant_multiname.get(name_index).deleted = d;
|
||||
abc.constants.getMultiname(name_index).deleted = d;
|
||||
abc.method_info.get(method_info).delete(abc, d);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
|
||||
@Override
|
||||
public void delete(ABC abc, boolean d) {
|
||||
abc.constants.constant_multiname.get(name_index).deleted = d;
|
||||
abc.constants.getMultiname(name_index).deleted = d;
|
||||
abc.method_info.get(method_info).delete(abc, d);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
|
||||
@Override
|
||||
public void delete(ABC abc, boolean d) {
|
||||
abc.constants.constant_multiname.get(name_index).deleted = d;
|
||||
abc.constants.getMultiname(name_index).deleted = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
74
libsrc/ffdec_lib/src/com/jpexs/helpers/HashArrayList.java
Normal file
74
libsrc/ffdec_lib/src/com/jpexs/helpers/HashArrayList.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.helpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class HashArrayList<E> extends ArrayList<E> {
|
||||
|
||||
private HashMap<E, Integer> map = new HashMap<>();
|
||||
|
||||
public HashArrayList() {
|
||||
}
|
||||
|
||||
public HashArrayList(Collection<? extends E> c) {
|
||||
for (E e : c) {
|
||||
add(e);
|
||||
}
|
||||
}
|
||||
|
||||
public HashArrayList(int initialCapacity) {
|
||||
super(initialCapacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ensureCapacity(int minCapacity) {
|
||||
super.ensureCapacity(minCapacity);
|
||||
HashMap<E, Integer> oldMap = map;
|
||||
map = new HashMap<>(minCapacity * 10 / 7);
|
||||
map.putAll(oldMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(E e) {
|
||||
map.put(e, size());
|
||||
return super.add(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E set(int index, E element) {
|
||||
map.remove(get(index));
|
||||
map.put(element, index);
|
||||
return super.set(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(Object o) {
|
||||
Integer index = map.get(o);
|
||||
if (index == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
}
|
||||
@@ -607,6 +607,14 @@ public class Helper {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int[] toIntArray(List<Integer> list) {
|
||||
int[] ret = new int[list.size()];
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
ret[i] = list.get(i);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static ByteArrayInputStream getInputStream(byte[]... data) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user