Merge origin/master

Conflicts:
	libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java
	libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java
This commit is contained in:
Jindra Petřík
2015-11-08 11:21:33 +01:00
14 changed files with 136 additions and 80 deletions

View File

@@ -70,7 +70,7 @@ public class ABCOutputStream extends OutputStream {
public void writeU32(long value) throws IOException {
boolean loop = true;
value &= 0xFFFFFFFF;
value &= 0xFFFFFFFFL;
do {
int ret = (int) (value & 0x7F);
if (value < 0x80) {

View File

@@ -64,6 +64,10 @@ public class AVM2ConstantPool implements Cloneable {
return constant_namespace.size() - 1;
}
public int addNamespace(int kind, int nameIndex) {
return addNamespace(new Namespace(kind, nameIndex));
}
public synchronized int addNamespaceSet(NamespaceSet nss) {
constant_namespace_set.add(nss);
return constant_namespace_set.size() - 1;
@@ -249,17 +253,43 @@ public class AVM2ConstantPool implements Cloneable {
return index;
}
public int getNamespaceId(Namespace val, int index) {
public int getNamespaceId(int kind, int nameIndex, int index) {
for (int n = 1; n < constant_namespace.size(); n++) {
Namespace ns = constant_namespace.get(n);
if (ns.name_index == val.name_index && (ns.kind == val.kind)) {
if (ns.name_index == nameIndex && (ns.kind == kind)) {
if (index == 0) {
return n;
}
index--;
}
}
return 0;
return -1;
}
public int getNamespaceId(int kind, int nameIndex, int index, boolean add) {
int id = getNamespaceId(kind, nameIndex, index);
if (add && id == -1) {
id = addNamespace(kind, nameIndex);
}
return id;
}
public int getNamespaceId(int kind, String name, int index, boolean add) {
int nameIndex = getStringId(name, add);
if (nameIndex == -1) {
return -1;
}
return getNamespaceId(kind, nameIndex, index, add);
}
public int getNamespaceId(int kind, DottedChain name, int index, boolean add) {
int nameIndex = getStringId(name, add);
if (nameIndex == -1) {
return -1;
}
return getNamespaceId(kind, nameIndex, index, add);
}
public int getIntId(long value) {
@@ -268,7 +298,7 @@ public class AVM2ConstantPool implements Cloneable {
return i;
}
}
return 0;
return -1;
}
public int getUIntId(long value) {
@@ -277,7 +307,7 @@ public class AVM2ConstantPool implements Cloneable {
return i;
}
}
return 0;
return -1;
}
public int getDoubleId(double value) {
@@ -289,7 +319,7 @@ public class AVM2ConstantPool implements Cloneable {
return i;
}
}
return 0;
return -1;
}
public int getStringId(String val) {
@@ -301,7 +331,7 @@ public class AVM2ConstantPool implements Cloneable {
return i;
}
}
return 0;
return -1;
}
public int getMultinameId(Multiname val) {
@@ -317,11 +347,11 @@ public class AVM2ConstantPool implements Cloneable {
return m;
}
}
return 0;
return -1;
}
public int getQnameId(String name, int namespaceKind, String namespaceName, boolean add) {
return getMultinameId(new Multiname(Multiname.QNAME, getStringId(name, add), getNamespaceId(new Namespace(namespaceKind, getStringId(namespaceName, add)), 0, add), 0, 0, new ArrayList<>()), add);
return getMultinameId(new Multiname(Multiname.QNAME, getStringId(name, add), getNamespaceId(namespaceKind, namespaceName, 0, add), 0, 0, new ArrayList<>()), add);
}
public int getPublicQnameId(String name, boolean add) {
@@ -330,7 +360,7 @@ public class AVM2ConstantPool implements Cloneable {
public int getMultinameId(Multiname val, boolean add) {
int id = getMultinameId(val);
if (add && id == 0) {
if (add && id == -1) {
id = addMultiname(val);
}
return id;
@@ -341,7 +371,7 @@ public class AVM2ConstantPool implements Cloneable {
return 0;
}
int id = getStringId(val);
if (add && id == 0) {
if (add && id == -1) {
id = addString(val);
}
return id;
@@ -357,20 +387,12 @@ public class AVM2ConstantPool implements Cloneable {
public int getIntId(long val, boolean add) {
int id = getIntId(val);
if (add && id == 0) {
if (add && id == -1) {
id = addInt(val);
}
return id;
}
public int getNamespaceId(Namespace val, int index, boolean add) {
int id = getNamespaceId(val, index);
if (add && id == 0) {
id = addNamespace(val);
}
return id;
}
public int getNamespaceSetId(NamespaceSet val) {
loopi:
for (int i = 1; i < constant_namespace_set.size(); i++) {
@@ -392,12 +414,12 @@ public class AVM2ConstantPool implements Cloneable {
}
return i;
}
return 0;
return -1;
}
public int getNamespaceSetId(NamespaceSet val, boolean add) {
int id = getNamespaceSetId(val);
if (add && id == 0) {
if (add && id == -1) {
id = addNamespaceSet(val);
}
return id;
@@ -405,7 +427,7 @@ public class AVM2ConstantPool implements Cloneable {
public int getUIntId(long val, boolean add) {
int id = getUIntId(val);
if (add && id == 0) {
if (add && id == -1) {
id = addUInt(val);
}
return id;
@@ -413,7 +435,7 @@ public class AVM2ConstantPool implements Cloneable {
public int getDoubleId(double val, boolean add) {
int id = getDoubleId(val);
if (add && id == 0) {
if (add && id == -1) {
id = addDouble(val);
}
return id;

View File

@@ -25,6 +25,8 @@ public class AVM2VerifyErrorException extends AVM2ExecutionException {
public static final int BRANCH_TARGET_INVALID_INSTRUCTION = 1021;
public static final int CPOOL_INDEX_OUT_OF_RANGE = 1032;
public AVM2VerifyErrorException(int code) {
super(codeToMessage(code, null));
}
@@ -42,12 +44,15 @@ public class AVM2VerifyErrorException extends AVM2ExecutionException {
case 1014:
msg = "class could not be found";
break;
case 1021:
case BRANCH_TARGET_INVALID_INSTRUCTION:
msg = "At least one branch target was not on a valid instruction in the method.";
break;
case 1030:
msg = "Stack depth is unbalanced";
break;
case CPOOL_INDEX_OUT_OF_RANGE:
msg = "Cpool index " + params[0] + " is out of range " + params[1] + ".";
break;
}
String result = "VerifyError: Error #" + code;

View File

@@ -20,9 +20,9 @@ import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2ExecutionException;
import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.IncLocalIIns;
@@ -67,28 +67,61 @@ public abstract class InstructionDefinition implements Serializable {
StringBuilder s = new StringBuilder();
s.append(instructionName);
for (int i = 0; i < operands.length; i++) {
if ((operands[i] & 0xff00) == AVM2Code.OPT_U30) {
int operand = operands[i];
if ((operand & 0xff00) == AVM2Code.OPT_U30) {
s.append(" U30");
}
if ((operands[i] & 0xff00) == AVM2Code.OPT_U30_SHORT) {
if ((operand & 0xff00) == AVM2Code.OPT_U30_SHORT) {
s.append(" U30");
}
if ((operands[i] & 0xff00) == AVM2Code.OPT_U8) {
if ((operand & 0xff00) == AVM2Code.OPT_U8) {
s.append(" U8");
}
if ((operands[i] & 0xff00) == AVM2Code.OPT_BYTE) {
if ((operand & 0xff00) == AVM2Code.OPT_BYTE) {
s.append(" BYTE");
}
if ((operands[i] & 0xff00) == AVM2Code.OPT_S24) {
if ((operand & 0xff00) == AVM2Code.OPT_S24) {
s.append(" S24");
}
if ((operands[i] & 0xff00) == AVM2Code.OPT_CASE_OFFSETS) {
if ((operand & 0xff00) == AVM2Code.OPT_CASE_OFFSETS) {
s.append(" U30 S24,[S24]...");
}
}
return s.toString();
}
public void verify(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2VerifyErrorException {
for (int i = 0; i < operands.length; i++) {
int operand = operands[i];
if (operand == AVM2Code.DAT_MULTINAME_INDEX) {
int idx = ins.operands[i];
if (idx <= 0 || idx >= constants.getMultinameCount()) {
throw new AVM2VerifyErrorException(AVM2VerifyErrorException.CPOOL_INDEX_OUT_OF_RANGE, new Object[]{idx, constants.getMultinameCount()});
}
} else if (operand == AVM2Code.DAT_DOUBLE_INDEX) {
int idx = ins.operands[i];
if (idx <= 0 || idx >= constants.getDoubleCount()) {
throw new AVM2VerifyErrorException(AVM2VerifyErrorException.CPOOL_INDEX_OUT_OF_RANGE, new Object[]{idx, constants.getDoubleCount()});
}
} else if (operand == AVM2Code.DAT_INT_INDEX) {
int idx = ins.operands[i];
if (idx <= 0 || idx >= constants.getIntCount()) {
throw new AVM2VerifyErrorException(AVM2VerifyErrorException.CPOOL_INDEX_OUT_OF_RANGE, new Object[]{idx, constants.getIntCount()});
}
} else if (operand == AVM2Code.DAT_UINT_INDEX) {
int idx = ins.operands[i];
if (idx <= 0 || idx >= constants.getUIntCount()) {
throw new AVM2VerifyErrorException(AVM2VerifyErrorException.CPOOL_INDEX_OUT_OF_RANGE, new Object[]{idx, constants.getUIntCount()});
}
} else if (operand == AVM2Code.DAT_STRING_INDEX) {
int idx = ins.operands[i];
if (idx <= 0 || idx >= constants.getStringCount()) {
throw new AVM2VerifyErrorException(AVM2VerifyErrorException.CPOOL_INDEX_OUT_OF_RANGE, new Object[]{idx, constants.getStringCount()});
}
}
}
}
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException {
//throw new UnsupportedOperationException("Instruction " + instructionName + " not implemented");
return false;

View File

@@ -112,7 +112,7 @@ 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(new Namespace(Namespace.KIND_PACKAGE, g.abcIndex.getSelectedAbc().constants.getStringId("__AS3__.vec", true)), 0, true)}), true), 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), 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)),
subtype,
ins(AVM2Instructions.ApplyType, 1),
@@ -124,7 +124,7 @@ public class InitVectorAVM2Item extends AVM2Item {
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(new Namespace(Namespace.KIND_PACKAGE, g.abcIndex.getSelectedAbc().constants.getStringId("", true)), 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, openedNamespaces), true))
));
}
return ret;

View File

@@ -253,7 +253,7 @@ public class ASM3Parser {
}
expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer);
return constants.getNamespaceId(new Namespace(kind, name.type == ParsedSymbol.TYPE_KEYWORD_NULL ? 0 : constants.getStringId((String) name.value, true)), index, true);
return constants.getNamespaceId(kind, name.type == ParsedSymbol.TYPE_KEYWORD_NULL ? null : (String) name.value, index, true);
}
private static int parseMultiName(AVM2ConstantPool constants, Flasm3Lexer lexer) throws AVM2ParseException, IOException {
@@ -758,7 +758,7 @@ public class ASM3Parser {
} else {
if (parsedOperand.type == ParsedSymbol.TYPE_STRING) {
int sid = constants.getStringId((String) parsedOperand.value);
if (sid == 0) {
if (sid == -1) {
if ((missingHandler != null) && (missingHandler.missingString((String) parsedOperand.value))) {
sid = constants.addString((String) parsedOperand.value);
} else {
@@ -779,7 +779,7 @@ public class ASM3Parser {
if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) {
long intVal = (Long) parsedOperand.value;
int iid = constants.getIntId(intVal);
if (iid == 0) {
if (iid == -1) {
if ((missingHandler != null) && (missingHandler.missingInt(intVal))) {
iid = constants.addInt(intVal);
} else {
@@ -799,7 +799,7 @@ public class ASM3Parser {
if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) {
long intVal = (Long) parsedOperand.value;
int iid = constants.getUIntId(intVal);
if (iid == 0) {
if (iid == -1) {
if ((missingHandler != null) && (missingHandler.missingUInt(intVal))) {
iid = constants.addUInt(intVal);
} else {
@@ -826,7 +826,7 @@ public class ASM3Parser {
doubleVal = (Double) parsedOperand.value;
}
int did = constants.getDoubleId(doubleVal);
if (did == 0) {
if (did == -1) {
if ((missingHandler != null) && (missingHandler.missingDouble(doubleVal))) {
did = constants.addDouble(doubleVal);
} else {

View File

@@ -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(new Namespace(Namespace.KIND_PACKAGE, abcIndex.getSelectedAbc().constants.getStringId("", true)), 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, 0, new ArrayList<>()), true)),
ins(AVM2Instructions.PushString, abcIndex.getSelectedAbc().constants.getStringId("", true)),
ins(AVM2Instructions.Construct, 1),
xmlListSetTemp
@@ -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(new Namespace(Namespace.KIND_PACKAGE, abcIndex.getSelectedAbc().constants.getStringId(localData.pkg, true)), 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, 0, new ArrayList<>()), 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(new Namespace(Namespace.KIND_PACKAGE, abcIndex.getSelectedAbc().constants.getStringId("", true)), 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, 0, new ArrayList<>()), true);
aex.type_index = typeName(localData, e.type);
newex.add(aex);
}
@@ -1328,7 +1328,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
}
public int namespace(int nsKind, String name) {
return abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(nsKind, str(name)), 0, true);
return abcIndex.getSelectedAbc().constants.getNamespaceId(nsKind, str(name), 0, true);
}
public int str(String name) {
@@ -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(new Namespace(Namespace.KIND_PACKAGE_INTERNAL, abcIndex.getSelectedAbc().constants.getStringId(pkg, true)), 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, 0, new ArrayList<>()), true);
tsc.type_index = typeName(localData, new TypeItem(slotTypes.get(i)));
mbody.traits.traits.add(tsc);
}
@@ -1862,16 +1862,15 @@ public class AVM2SourceGenerator implements SourceGenerator {
if (ti.trait instanceof TraitSlotConst) {
if (((TraitSlotConst) ti.trait).isNamespace()) {
Namespace ns = ti.abc.constants.getNamespace(((TraitSlotConst) ti.trait).value_index);
return abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(ns.kind, abcIndex.getSelectedAbc().constants.getStringId(ns.getName(ti.abc.constants), true)), 0, true);
return abcIndex.getSelectedAbc().constants.getNamespaceId(ns.kind, ns.getName(ti.abc.constants), 0, true);
}
}
}
throw new CompilationException("Namespace not defined", line);
}
namespace = abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(Namespace.KIND_NAMESPACE,
abcIndex.getSelectedAbc().constants.getStringId(outAbc.getVal().constants.getNamespace(value.getVal().value_index).getName(outAbc.getVal().constants), true)
), 0, true);
namespace = abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_NAMESPACE,
outAbc.getVal().constants.getNamespace(value.getVal().value_index).getName(outAbc.getVal().constants), 0, true);
}
return namespace;
}
@@ -1908,7 +1907,6 @@ public class AVM2SourceGenerator implements SourceGenerator {
new Multiname(
Multiname.QNAME,
abcIndex.getSelectedAbc().constants.getStringId(((ClassAVM2Item) item).className, true),
//abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abcIndex.getSelectedAbc().constants.getStringId(((ClassAVM2Item) item).pkg, true)), 0, true)
((ClassAVM2Item) item).namespace, 0, 0, new ArrayList<>()), true);
if (((ClassAVM2Item) item).extendsOp != null) {
@@ -1924,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(new Namespace(Namespace.KIND_PACKAGE, abcIndex.getSelectedAbc().constants.getStringId(((InterfaceAVM2Item) item).pkg, true)), 0, true), 0, 0, new ArrayList<>()), true);
abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, ((InterfaceAVM2Item) item).pkg, 0, true), 0, 0, new ArrayList<>()), true);
instanceInfo.interfaces = new int[((InterfaceAVM2Item) item).superInterfaces.size()];
for (int i = 0; i < ((InterfaceAVM2Item) item).superInterfaces.size(); i++) {
@@ -2180,9 +2178,8 @@ public class AVM2SourceGenerator implements SourceGenerator {
parents.add(abcIndex.getSelectedAbc().constants.getMultinameId(
new Multiname(origM.kind,
abcIndex.getSelectedAbc().constants.getStringId(ci.abc.constants.getString(origM.name_index), true),
abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(origNs.kind, abcIndex.getSelectedAbc().constants.getStringId(
ci.abc.constants.getString(origNs.name_index)
)), 0, true), 0, 0, new ArrayList<Integer>())
abcIndex.getSelectedAbc().constants.getNamespaceId(origNs.kind,
ci.abc.constants.getString(origNs.name_index), 0, true), 0, 0, new ArrayList<>())
));
}
@@ -2232,7 +2229,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
abc.getSelectedAbc().constants.getMultinameId(
new Multiname(Multiname.QNAME,
abc.getSelectedAbc().constants.getStringId(superName.getName(a.constants, null, true), true),
abc.getSelectedAbc().constants.getNamespaceId(new Namespace(superName.getNamespace(a.constants).kind, abc.getSelectedAbc().constants.getStringId(superName.getNamespace(a.constants).getName(a.constants), true)), 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, 0, new ArrayList<>()), true)
);
}
}
@@ -2429,7 +2426,7 @@ 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(new Namespace(Namespace.KIND_PACKAGE, abc.getSelectedAbc().constants.getStringId(pkg, true)), 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, 0, new ArrayList<>()), true);
}
}

View File

@@ -695,7 +695,7 @@ public class ActionScript3Parser {
}
if (namespace == -1) {
if (isInterface) {
namespace = abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(Namespace.KIND_NAMESPACE, abcIndex.getSelectedAbc().constants.getStringId(pkg == null || pkg.isEmpty() ? classNameStr : pkg + ":" + classNameStr, true)), 0, true);
namespace = abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_NAMESPACE, pkg == null || pkg.isEmpty() ? classNameStr : pkg + ":" + classNameStr, 0, true);
} else {
if (packageInternalNs == 0) {
packageInternalNs = abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE_INTERNAL, abcIndex.getSelectedAbc().constants.getStringId(pkg.toRawString(), true)), 0, true);
@@ -979,22 +979,22 @@ public class ActionScript3Parser {
openedNamespaces.add(packageInternalNs = abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE_INTERNAL, abcIndex.getSelectedAbc().constants.getStringId("", true)), 0, true));
}
if (pkg != null && !pkg.isEmpty()) {
openedNamespaces.add(publicNs = abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abcIndex.getSelectedAbc().constants.getStringId("", true)), 0, true));
openedNamespaces.add(publicNs = abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true));
} else {
publicNs = gpublicNs;
}
openedNamespaces.add(privateNs = abcIndex.getSelectedAbc().constants.addNamespace(new Namespace(Namespace.KIND_PRIVATE, abcIndex.getSelectedAbc().constants.getStringId(pkg.toRawString() + ":" + nameStr))));
openedNamespaces.add(abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(Namespace.KIND_NAMESPACE, abcIndex.getSelectedAbc().constants.getStringId(AS3_NAMESPACE, true)), 0, true));
openedNamespaces.add(abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_NAMESPACE, AS3_NAMESPACE, 0, true));
//int privateNs = 0;
int protectedNs = 0;
//int publicNs = namespace;
int protectedStaticNs = 0;
openedNamespaces.add(protectedNs = abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(Namespace.KIND_PROTECTED, abcIndex.getSelectedAbc().constants.getStringId(packageName == null ? (scriptName + "$0:"/*FIXME?*/ + classNameStr) : packageName.isTopLevel() ? classNameStr : packageName.toRawString() + ":" + classNameStr, true)), 0, true));
openedNamespaces.add(protectedStaticNs = abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(Namespace.KIND_STATIC_PROTECTED, abcIndex.getSelectedAbc().constants.getStringId(packageName == null || packageName.isTopLevel() ? classNameStr : packageName.toRawString() + ":" + classNameStr, true)), 0, true));
openedNamespaces.add(protectedNs = abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PROTECTED, packageName == null ? (scriptName + "$0:"/*FIXME?*/ + classNameStr) : packageName.isTopLevel() ? classNameStr : packageName.toRawString() + ":" + classNameStr, 0, true));
openedNamespaces.add(protectedStaticNs = abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_STATIC_PROTECTED, packageName == null || packageName.isTopLevel() ? classNameStr : packageName.toRawString() + ":" + classNameStr, 0, true));
if (extendsStr != null) {
List<Integer> indices = new ArrayList<>();
@@ -1006,7 +1006,7 @@ public class ActionScript3Parser {
if (namespaces.get(i) == null || namespaces.get(i).isEmpty()) {
continue;
}
openedNamespaces.add(abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(Namespace.KIND_STATIC_PROTECTED, abcIndex.getSelectedAbc().constants.getStringId(namespaces.get(i) + ":" + names.get(i), true)), 0, true));
openedNamespaces.add(abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_STATIC_PROTECTED, namespaces.get(i) + ":" + names.get(i), 0, true));
}
}
@@ -1303,7 +1303,7 @@ public class ActionScript3Parser {
case USE:
expectedType(SymbolType.NAMESPACE);
GraphTargetItem ns = type(thisType, pkg, needsActivation, importedClasses, openedNamespaces, variables);
openedNamespaces.add(abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE /*FIXME?*/, abcIndex.getSelectedAbc().constants.getStringId(ns.toString(), true)), 0, true));
openedNamespaces.add(abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE /*FIXME?*/, ns.toString(), 0, true));
break;
case WITH:
needsActivation.setVal(true);
@@ -2341,7 +2341,7 @@ public class ActionScript3Parser {
}
if (isStar) {
openedNamespaces.add(abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abcIndex.getSelectedAbc().constants.getStringId(imp.toString(), true)), 0, true));
openedNamespaces.add(abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, imp.toString(), 0, true));
} else {
importedClasses.add(imp);
}
@@ -2373,7 +2373,7 @@ public class ActionScript3Parser {
List<DottedChain> importedClasses = parseImports(openedNamespaces);
int publicNs;
openedNamespaces.add(publicNs = abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abcIndex.getSelectedAbc().constants.getStringId(name, true)), 0, true));
openedNamespaces.add(publicNs = abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, name, 0, true));
//traits(false, new ArrayList<AssignableAVM2Item>(), new Reference<Boolean>(false), new ArrayList<GraphTargetItem>(), importedClasses, privateNs, 0, publicNs, packageInternalNs, 0, openedNamespaces, name, null, false, items);
//expectedType(SymbolType.CURLY_CLOSE);
@@ -2396,10 +2396,10 @@ public class ActionScript3Parser {
if (className.endsWith(".as")) {
className = className.substring(0, className.length() - 3);
}
openedNamespaces.add(scriptPrivateNs = abcIndex.getSelectedAbc().constants.addNamespace(new Namespace(Namespace.KIND_PRIVATE, 0))); //abc.getLastAbc().constants.getStringId(name + ":" + className, true)
openedNamespaces.add(scriptPrivateNs = abcIndex.getSelectedAbc().constants.addNamespace(Namespace.KIND_PRIVATE, 0)); //abc.getLastAbc().constants.getStringId(name + ":" + className, true)
int publicNs;
openedNamespaces.add(publicNs = abcIndex.getSelectedAbc().constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abcIndex.getSelectedAbc().constants.getStringId("", true)), 0, true));
openedNamespaces.add(publicNs = abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true));
List<GraphTargetItem> items = new ArrayList<>();
traits(fileName, true, new ArrayList<>(), new Reference<>(false), new ArrayList<>(), new ArrayList<>(), scriptPrivateNs, 0, publicNs, 0, 0, openedNamespaces, null, null, false, items);

View File

@@ -52,7 +52,7 @@ public class ConstructSomethingAVM2Item extends CallAVM2Item {
for (int i = 0; i < openedNamespaces.size(); i++) {
nssa[i] = openedNamespaces.get(i);
}
nssa[nssa.length - 1] = abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abc.constants.getStringId("__AS3__.vec", true)), 0, true);
nssa[nssa.length - 1] = abc.constants.getNamespaceId(Namespace.KIND_PACKAGE, "__AS3__.vec", 0, true);
return abc.constants.getNamespaceSetId(new NamespaceSet(nssa), true);
}

View File

@@ -25,7 +25,6 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyStrict
import com.jpexs.decompiler.flash.abc.avm2.model.ApplyTypeAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.InitVectorAVM2Item;
import com.jpexs.decompiler.flash.abc.types.InstanceInfo;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
@@ -223,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(new Namespace(outPropNsKind.getVal(), outPropNs.getVal() == null || outPropNs.getVal().isEmpty() ? 0 : abc.getSelectedAbc().constants.getStringId(outPropNs.getVal(), true)), outPropNsIndex.getVal(), true), 0, 0, new ArrayList<>()), true
abc.getSelectedAbc().constants.getNamespaceId(outPropNsKind.getVal(), outPropNs.getVal(), outPropNsIndex.getVal(), true), 0, 0, new ArrayList<>()), true
);
propValue = outPropValue.getVal();
propValueAbc = outPropValueAbc.getVal();
@@ -332,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(new Namespace(outPropNsKind.getVal(), outPropNs.getVal() == null || outPropNs.getVal().isEmpty() ? 0 : abc.getSelectedAbc().constants.getStringId(outPropNs.getVal(), true)), outPropNsIndex.getVal(), true), 0, 0, new ArrayList<>()), true
abc.getSelectedAbc().constants.getNamespaceId(outPropNsKind.getVal(), outPropNs.getVal(), outPropNsIndex.getVal(), true), 0, 0, new ArrayList<>()), true
);
propValue = p.value;
propValueAbc = outPropValueAbc.getVal();
@@ -341,7 +340,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
}
//if (propertyName != null && AVM2SourceGenerator.searchPrototypeChain(false, abcs, nsname, n.getName(a.constants, null, true), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue)) {
//
//
//}
}
}
@@ -360,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(new Namespace(Namespace.KIND_PACKAGE_INTERNAL, localData.pkg == null || localData.pkg.isEmpty() ? 0 : abc.getSelectedAbc().constants.getStringId(localData.pkg, true)), 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(), 0, new ArrayList<>()), true);
propType = TypeItem.UNBOUNDED;
objType = TypeItem.UNBOUNDED;
propValue = null;

View File

@@ -61,7 +61,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(new Namespace(Namespace.KIND_PACKAGE, g.abcIndex.getSelectedAbc().constants.getStringId("", true)), 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, 0, new ArrayList<>()), true)),
value,
ins(AVM2Instructions.Construct, 1)
);

View File

@@ -52,7 +52,7 @@ public class Multiname {
private static final String[] multinameKindNames = new String[]{"Qname", "QnameA", "Multiname", "MultinameA", "RTQname", "RTQnameA", "MultinameL", "RTQnameL", "RTQnameLA", "MultinameLA", "TypeName"};
public final int kind;
public int kind;
public int name_index;