create method for different multiname types

This commit is contained in:
honfika@gmail.com
2015-11-10 11:05:47 +01:00
parent f60e5c5f23
commit 7bdecd990a
16 changed files with 244 additions and 222 deletions

View File

@@ -296,38 +296,39 @@ public class ABCInputStream implements AutoCloseable {
public Multiname readMultiname(String name) throws IOException {
int kind = readU8("kind");
int namespace_index = 0;
int name_index = 0;
int namespace_set_index = 0;
int qname_index = 0;
int[] params = null;
Multiname result = null;
newDumpLevel(name, "Multiname");
if ((kind == Multiname.QNAME) || (kind == Multiname.QNAMEA)) {
namespace_index = readU30("namespace_index");
name_index = readU30("name_index");
int namespace_index = readU30("namespace_index");
int name_index = readU30("name_index");
result = Multiname.createQName(kind == Multiname.QNAMEA, name_index, namespace_index);
} else if ((kind == Multiname.RTQNAME) || (kind == Multiname.RTQNAMEA)) {
name_index = readU30("name_index");
int name_index = readU30("name_index");
result = Multiname.createRTQName(kind == Multiname.RTQNAMEA, name_index);
} else if ((kind == Multiname.RTQNAMEL) || (kind == Multiname.RTQNAMELA)) {
result = Multiname.createRTQNameL(kind == Multiname.RTQNAMELA);
} else if ((kind == Multiname.MULTINAME) || (kind == Multiname.MULTINAMEA)) {
name_index = readU30("name_index");
namespace_set_index = readU30("namespace_set_index");
int name_index = readU30("name_index");
int namespace_set_index = readU30("namespace_set_index");
result = Multiname.createMultiname(kind == Multiname.MULTINAMEA, name_index, namespace_set_index);
} else if ((kind == Multiname.MULTINAMEL) || (kind == Multiname.MULTINAMELA)) {
namespace_set_index = readU30("namespace_set_index");
int namespace_set_index = readU30("namespace_set_index");
result = Multiname.createMultinameL(kind == Multiname.MULTINAMELA, namespace_set_index);
} else if (kind == Multiname.TYPENAME) {
qname_index = readU30("qname_index"); // Multiname index!!!
int qname_index = readU30("qname_index"); // Multiname index!!!
int paramsLength = readU30("paramsLength");
params = new int[paramsLength];
int[] params = new int[paramsLength];
for (int i = 0; i < paramsLength; i++) {
params[i] = readU30("param"); // multiname indices!
}
result = Multiname.createTypeName(qname_index, params);
} else {
throw new IOException("Unknown kind of Multiname:0x" + Integer.toHexString(kind));
}
endDumpLevel();
return new Multiname(kind, name_index, namespace_index, namespace_set_index, qname_index, params);
return result;
}
public MethodInfo readMethodInfo(String name) throws IOException {

View File

@@ -396,7 +396,7 @@ public class AVM2ConstantPool implements Cloneable {
}
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), add);
return getMultinameId(Multiname.createQName(false, getStringId(name, add), getNamespaceId(namespaceKind, namespaceName, 0, add)), add);
}
public int getPublicQnameId(String name, boolean add) {
@@ -438,17 +438,17 @@ public class AVM2ConstantPool implements Cloneable {
return id;
}
private int getNamespaceSetId(NamespaceSet val) {
private int getNamespaceSetId(int[] namespaces) {
loopi:
for (int i = 1; i < constant_namespace_set.size(); i++) {
NamespaceSet ts = constant_namespace_set.get(i);
if (ts.namespaces.length != val.namespaces.length) {
if (ts.namespaces.length != namespaces.length) {
continue;
}
for (int j = 0; j < val.namespaces.length; j++) {
for (int j = 0; j < namespaces.length; j++) {
boolean found = false;
for (int k = 0; k < val.namespaces.length; k++) {
if (ts.namespaces[j] == val.namespaces[k]) {
for (int k = 0; k < namespaces.length; k++) {
if (ts.namespaces[j] == namespaces[k]) {
found = true;
break;
}
@@ -462,10 +462,10 @@ public class AVM2ConstantPool implements Cloneable {
return -1;
}
public int getNamespaceSetId(NamespaceSet val, boolean add) {
int id = getNamespaceSetId(val);
public int getNamespaceSetId(int[] namespaces, boolean add) {
int id = getNamespaceSetId(namespaces);
if (add && id == -1) {
id = addNamespaceSet(val);
id = addNamespaceSet(new NamespaceSet(namespaces));
}
return id;
}
@@ -498,7 +498,6 @@ public class AVM2ConstantPool implements Cloneable {
}
public void dump(Utf8PrintWriter writer) {
String s = "";
for (int i = 1; i < constant_int.size(); i++) {
writer.println("INT[" + i + "]=" + constant_int.get(i));
}

View File

@@ -18,12 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.DottedChain;
@@ -61,11 +61,8 @@ public class InitVectorAVM2Item extends AVM2Item {
List<Integer> openedNamespaces;
private int allNsSet(ABC abc) {
int[] nssa = new int[openedNamespaces.size()];
for (int i = 0; i < openedNamespaces.size(); i++) {
nssa[i] = openedNamespaces.get(i);
}
return abc.constants.getNamespaceSetId(new NamespaceSet(nssa), true);
int[] nssa = Helper.toIntArray(openedNamespaces);
return abc.constants.getNamespaceSetId(nssa, true);
}
public InitVectorAVM2Item(AVM2Instruction ins, GraphTargetItem subtype, List<GraphTargetItem> arguments) {
@@ -112,9 +109,11 @@ public class InitVectorAVM2Item extends AVM2Item {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
AVM2SourceGenerator g = (AVM2SourceGenerator) generator;
ABC abc = g.abcIndex.getSelectedAbc();
AVM2ConstantPool constants = abc.constants;
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)), 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)),
ins(AVM2Instructions.FindPropertyStrict, constants.getMultinameId(Multiname.createMultiname(false, constants.getStringId("Vector", true), constants.getNamespaceSetId(new int[]{constants.getNamespaceId(Namespace.KIND_PACKAGE, "__AS3__.vec", 0, true)}, true)), true)),
ins(AVM2Instructions.GetProperty, constants.getMultinameId(Multiname.createMultiname(false, constants.getStringId("Vector", true), allNsSet(abc)), true)),
subtype,
ins(AVM2Instructions.ApplyType, 1),
new IntegerValueAVM2Item(null, (long) arguments.size()),
@@ -127,7 +126,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(Namespace.KIND_PACKAGE, "", 0, true)}), true)), true))
ins(AVM2Instructions.SetProperty, constants.getMultinameId(Multiname.createMultinameL(false, constants.getNamespaceSetId(new int[]{constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true)}, true)), true))
));
}
return ret;

View File

@@ -260,11 +260,6 @@ public class ASM3Parser {
private static int parseMultiName(AVM2ConstantPool constants, Flasm3Lexer lexer) throws AVM2ParseException, IOException {
ParsedSymbol s = lexer.lex();
int kind = 0;
int name_index = 0;
int namespace_index = 0;
int namespace_set_index = 0;
int qname_index = 0;
int[] params = null;
switch (s.type) {
case ParsedSymbol.TYPE_KEYWORD_NULL:
@@ -306,13 +301,15 @@ public class ASM3Parser {
throw new AVM2ParseException("Name expected", lexer.yyline());
}
switch (s.type) {
case ParsedSymbol.TYPE_KEYWORD_QNAME:
case ParsedSymbol.TYPE_KEYWORD_QNAMEA:
Multiname multiname = null;
switch (kind) {
case Multiname.QNAME:
case Multiname.QNAMEA: {
expected(ParsedSymbol.TYPE_PARENT_OPEN, "(", lexer);
namespace_index = parseNamespace(constants, lexer);
int namespace_index = parseNamespace(constants, lexer);
expected(ParsedSymbol.TYPE_COMMA, ",", lexer);
ParsedSymbol name = lexer.lex();
int name_index;
if (name.type == ParsedSymbol.TYPE_KEYWORD_NULL) {
name_index = 0;
} else {
@@ -320,11 +317,14 @@ public class ASM3Parser {
name_index = constants.getStringId((String) name.value, true);
}
expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer);
multiname = Multiname.createQName(kind == Multiname.QNAMEA, name_index, namespace_index);
break;
case ParsedSymbol.TYPE_KEYWORD_RTQNAME:
case ParsedSymbol.TYPE_KEYWORD_RTQNAMEA:
}
case Multiname.RTQNAME:
case Multiname.RTQNAMEA: {
expected(ParsedSymbol.TYPE_PARENT_OPEN, "(", lexer);
ParsedSymbol rtqName = lexer.lex();
int name_index;
if (rtqName.type == ParsedSymbol.TYPE_KEYWORD_NULL) {
name_index = 0;
} else {
@@ -332,16 +332,21 @@ public class ASM3Parser {
name_index = constants.getStringId((String) rtqName.value, true);
}
expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer);
multiname = Multiname.createRTQName(kind == Multiname.RTQNAMEA, name_index);
break;
case ParsedSymbol.TYPE_KEYWORD_RTQNAMEL:
case ParsedSymbol.TYPE_KEYWORD_RTQNAMELA:
}
case Multiname.RTQNAMEL:
case Multiname.RTQNAMELA: {
expected(ParsedSymbol.TYPE_PARENT_OPEN, "(", lexer);
expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer);
multiname = Multiname.createRTQNameL(kind == Multiname.RTQNAMELA);
break;
case ParsedSymbol.TYPE_KEYWORD_MULTINAME:
case ParsedSymbol.TYPE_KEYWORD_MULTINAMEA:
}
case Multiname.MULTINAME:
case Multiname.MULTINAMEA: {
expected(ParsedSymbol.TYPE_PARENT_OPEN, "(", lexer);
ParsedSymbol mName = lexer.lex();
int name_index;
if (mName.type == ParsedSymbol.TYPE_KEYWORD_NULL) {
name_index = 0;
} else {
@@ -349,18 +354,22 @@ public class ASM3Parser {
name_index = constants.getStringId((String) mName.value, true);
}
expected(ParsedSymbol.TYPE_COMMA, ",", lexer);
namespace_set_index = parseNamespaceSet(constants, lexer);
int namespace_set_index = parseNamespaceSet(constants, lexer);
expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer);
multiname = Multiname.createMultiname(kind == Multiname.MULTINAMEA, name_index, namespace_set_index);
break;
case ParsedSymbol.TYPE_KEYWORD_MULTINAMEL:
case ParsedSymbol.TYPE_KEYWORD_MULTINAMELA:
}
case Multiname.MULTINAMEL:
case Multiname.MULTINAMELA: {
expected(ParsedSymbol.TYPE_PARENT_OPEN, "(", lexer);
namespace_set_index = parseNamespaceSet(constants, lexer);
int namespace_set_index = parseNamespaceSet(constants, lexer);
expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer);
multiname = Multiname.createMultinameL(kind == Multiname.MULTINAMELA, namespace_set_index);
break;
case ParsedSymbol.TYPE_KEYWORD_TYPENAME:
}
case Multiname.TYPENAME: {
expected(ParsedSymbol.TYPE_PARENT_OPEN, "(", lexer);
qname_index = parseMultiName(constants, lexer);
int qname_index = parseMultiName(constants, lexer);
expected(ParsedSymbol.TYPE_LOWERTHAN, "<", lexer);
List<Integer> paramsList = new ArrayList<>();
paramsList.add(parseMultiName(constants, lexer));
@@ -369,13 +378,15 @@ public class ASM3Parser {
paramsList.add(parseMultiName(constants, lexer));
nt = lexer.lex();
}
params = Helper.toIntArray(paramsList);
int[] params = Helper.toIntArray(paramsList);
expected(nt, ParsedSymbol.TYPE_GREATERTHAN, ">");
expected(ParsedSymbol.TYPE_PARENT_CLOSE, ")", lexer);
multiname = Multiname.createTypeName(qname_index, params);
break;
}
}
return constants.getMultinameId(new Multiname(kind, name_index, namespace_index, namespace_set_index, qname_index, params), true);
return constants.getMultinameId(multiname, true);
}
public static ValueKind parseValue(AVM2ConstantPool constants, Flasm3Lexer lexer) throws IOException, AVM2ParseException {

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
@@ -56,7 +57,6 @@ import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
import com.jpexs.decompiler.flash.abc.types.ScriptInfo;
import com.jpexs.decompiler.flash.abc.types.ValueKind;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
@@ -91,6 +91,7 @@ import com.jpexs.decompiler.graph.model.TernarOpItem;
import com.jpexs.decompiler.graph.model.TrueItem;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import com.jpexs.decompiler.graph.model.WhileItem;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
@@ -142,11 +143,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
for (int i = 0; i < item.openedNamespaces.size(); i++) {
nssa[i] = item.openedNamespaces.get(i);
}
int nsset = abcIndex.getSelectedAbc().constants.getNamespaceSetId(new NamespaceSet(nssa), true);
AVM2ConstantPool constants = abcIndex.getSelectedAbc().constants;
int nsset = constants.getNamespaceSetId(nssa, true);
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), true))
ins(AVM2Instructions.GetDescendants, constants.getMultinameId(Multiname.createMultiname(false, constants.getStringId(item.nameStr, true), nsset), true))
);
}
@@ -282,6 +285,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
final Reference<Integer> collectionReg = new Reference<>(0);
final Reference<Integer> xmlListReg = new Reference<>(0);
List<GraphSourceItem> xmlListSetTemp = AssignableAVM2Item.setTemp(localData, this, xmlListReg);
AVM2ConstantPool constants = abcIndex.getSelectedAbc().constants;
ret.addAll(GraphTargetItem.toSourceMerge(localData, this,
ins(AVM2Instructions.PushByte, 0),
AssignableAVM2Item.setTemp(localData, this, counterReg),
@@ -289,8 +293,8 @@ 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), true)),
ins(AVM2Instructions.PushString, abcIndex.getSelectedAbc().constants.getStringId("", true)),
ins(AVM2Instructions.GetLex, constants.getMultinameId(Multiname.createQName(false, constants.getStringId("XMLList", true), constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true)), true)),
ins(AVM2Instructions.PushString, constants.getStringId("", true)),
ins(AVM2Instructions.Construct, 1),
xmlListSetTemp
));
@@ -312,11 +316,8 @@ public class AVM2SourceGenerator implements SourceGenerator {
trueBody.addAll(toInsList(AssignableAVM2Item.getTemp(localData, this, xmlListReg)));
trueBody.addAll(toInsList(AssignableAVM2Item.getTemp(localData, this, counterReg)));
trueBody.addAll(toInsList(AssignableAVM2Item.getTemp(localData, this, tempVal1)));
int[] nss = new int[item.openedNamespaces.size()];
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)), true)));
int[] nss = Helper.toIntArray(item.openedNamespaces);
trueBody.add(ins(AVM2Instructions.SetProperty, constants.getMultinameId(Multiname.createMultinameL(false, constants.getNamespaceSetId(nss, true)), true)));
forBody.add(ins(AVM2Instructions.IfFalse, insToBytes(trueBody).length));
forBody.addAll(trueBody);
forBody.add(ins(AVM2Instructions.PopScope));
@@ -689,12 +690,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
scope = localData.scopeStack.size();
localData.scopeStack.add(new PropertyAVM2Item(null, item.functionName, abcIndex, new ArrayList<>(), localData.callStack));
}
ret.add(ins(AVM2Instructions.NewFunction, method(false, abcIndex.getSelectedAbc().constants.getStringId(item.functionName, true), true, false, localData.callStack, localData.pkg, item.needsActivation, item.subvariables, 0 /*Set later*/, item.hasRest, item.line, localData.currentClass, null, false, localData, item.paramTypes, item.paramNames, item.paramValues, item.body, item.retType)));
AVM2ConstantPool constants = abcIndex.getSelectedAbc().constants;
ret.add(ins(AVM2Instructions.NewFunction, method(false, constants.getStringId(item.functionName, true), true, false, localData.callStack, localData.pkg, item.needsActivation, item.subvariables, 0 /*Set later*/, item.hasRest, item.line, localData.currentClass, null, false, localData, item.paramTypes, item.paramNames, item.paramValues, item.body, item.retType)));
if (!item.functionName.isEmpty()) {
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), true)));
ret.add(ins(AVM2Instructions.SetProperty, constants.getMultinameId(Multiname.createQName(false, constants.getStringId(item.functionName, true), constants.getNamespaceId(Namespace.KIND_PACKAGE, localData.pkg, 0, true)), true)));
ret.add(ins(AVM2Instructions.PopScope));
localData.scopeStack.remove(localData.scopeStack.size() - 1);
}
@@ -716,7 +718,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), true);
aex.name_index = abcIndex.getSelectedAbc().constants.getMultinameId(Multiname.createQName(false, abcIndex.getSelectedAbc().constants.getStringId(e.getVariableName(), true), abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true)), true);
aex.type_index = typeName(localData, e.type);
newex.add(aex);
}
@@ -1289,7 +1291,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), true);
return abcIndex.getSelectedAbc().constants.getMultinameId(Multiname.createQName(false, str(var), namespace), true);
}
public int typeName(SourceGeneratorLocalData localData, GraphTargetItem type) throws CompilationException {
@@ -1338,7 +1340,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), true);
return abcIndex.getSelectedAbc().constants.getMultinameId(Multiname.createQName(false, str(va.getVariableName()), namespace(Namespace.KIND_PACKAGE, "")), true);
}
throw new RuntimeException("no prop"); //FIXME
}
@@ -1638,7 +1640,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), true);
tsc.name_index = abcIndex.getSelectedAbc().constants.getMultinameId(Multiname.createQName(false, abcIndex.getSelectedAbc().constants.getStringId(slotNames.get(i), true), abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE_INTERNAL, pkg, 0, true)), true);
tsc.type_index = typeName(localData, new TypeItem(slotTypes.get(i)));
mbody.traits.traits.add(tsc);
}
@@ -1904,15 +1906,15 @@ public class AVM2SourceGenerator implements SourceGenerator {
InstanceInfo instanceInfo = abcIndex.getSelectedAbc().instance_info.get(((TraitClass) traits[k]).class_info);
instanceInfo.name_index = abcIndex.getSelectedAbc().constants.getMultinameId(
new Multiname(
Multiname.QNAME,
Multiname.createQName(
false,
abcIndex.getSelectedAbc().constants.getStringId(((ClassAVM2Item) item).className, true),
((ClassAVM2Item) item).namespace, 0), true);
((ClassAVM2Item) item).namespace), 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), true);
instanceInfo.super_index = abcIndex.getSelectedAbc().constants.getMultinameId(Multiname.createQName(false, str("Object"), namespace(Namespace.KIND_PACKAGE, "")), true);
}
instanceInfo.interfaces = new int[((ClassAVM2Item) item).implementsOp.size()];
for (int i = 0; i < ((ClassAVM2Item) item).implementsOp.size(); i++) {
@@ -1920,9 +1922,11 @@ 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), true);
ABC abc = abcIndex.getSelectedAbc();
AVM2ConstantPool constants = abc.constants;
InstanceInfo instanceInfo = abc.instance_info.get(((TraitClass) traits[k]).class_info);
instanceInfo.name_index = constants.getMultinameId(Multiname.createQName(false, constants.getStringId(((InterfaceAVM2Item) item).name, true),
constants.getNamespaceId(Namespace.KIND_PACKAGE, ((InterfaceAVM2Item) item).pkg, 0, true)), true);
instanceInfo.interfaces = new int[((InterfaceAVM2Item) item).superInterfaces.size()];
for (int i = 0; i < ((InterfaceAVM2Item) item).superInterfaces.size(); i++) {
@@ -1944,7 +1948,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
TypeItem sup = (TypeItem) un;
int propId = resolveType(localData, sup, abcIndex);
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);
return abcIndex.getSelectedAbc().constants.getMultinameId(Multiname.createMultiname(false, abcIndex.getSelectedAbc().constants.getMultiname(propId).name_index, abcIndex.getSelectedAbc().constants.getNamespaceSetId(nss, true)), true);
}
@@ -2143,9 +2147,11 @@ public class AVM2SourceGenerator implements SourceGenerator {
abcIndex.refreshSelected();
MethodInfo mi = new MethodInfo(new int[0], 0, abcIndex.getSelectedAbc().constants.getStringId("", true), 0, new ValueKind[0], new int[0]);
MethodBody mb = new MethodBody(abcIndex.getSelectedAbc(), new Traits(), new byte[0], new ABCException[0]);
mb.method_info = abcIndex.getSelectedAbc().addMethodInfo(mi);
ABC abc = abcIndex.getSelectedAbc();
AVM2ConstantPool constants = abc.constants;
MethodInfo mi = new MethodInfo(new int[0], 0, constants.getStringId("", true), 0, new ValueKind[0], new int[0]);
MethodBody mb = new MethodBody(abc, new Traits(), new byte[0], new ABCException[0]);
mb.method_info = abc.addMethodInfo(mi);
mb.setCode(new AVM2Code());
List<AVM2Instruction> mbCode = mb.getCode().code;
mbCode.add(ins(AVM2Instructions.GetLocal0));
@@ -2163,23 +2169,25 @@ public class AVM2SourceGenerator implements SourceGenerator {
mbCode.add(ins(AVM2Instructions.GetScopeObject, 0));
traitScope++;
} else {
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)));
int[] nsset = new int[]{constants.getMultiname(tc.name_index).namespace_index};
mbCode.add(ins(AVM2Instructions.FindPropertyStrict, constants.getMultinameId(Multiname.createMultiname(false, constants.getMultiname(tc.name_index).name_index, constants.getNamespaceSetId(nsset, true)), true)));
}
if (abcIndex.getSelectedAbc().instance_info.get(tc.class_info).isInterface()) {
if (abc.instance_info.get(tc.class_info).isInterface()) {
mbCode.add(ins(AVM2Instructions.PushNull));
} else {
AbcIndexing.ClassIndex ci = abcIndex.findClass(AbcIndexing.multinameToType(abcIndex.getSelectedAbc().instance_info.get(tc.class_info).name_index, abcIndex.getSelectedAbc().constants));
AbcIndexing.ClassIndex ci = abcIndex.findClass(AbcIndexing.multinameToType(abc.instance_info.get(tc.class_info).name_index, constants));
while (ci != null && ci.parent != null) {
ci = ci.parent;
Multiname origM = ci.abc.constants.getMultiname(ci.abc.instance_info.get(ci.index).name_index);
Namespace origNs = ci.abc.constants.getNamespace(origM.namespace_index);
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(origNs.kind,
ci.abc.constants.getString(origNs.name_index), 0, true), 0), true));
if (origM.kind == Multiname.QNAME || origM.kind == Multiname.QNAMEA) {
parents.add(constants.getMultinameId(
Multiname.createQName(origM.kind == Multiname.QNAMEA,
constants.getStringId(ci.abc.constants.getString(origM.name_index), true),
constants.getNamespaceId(origNs.kind,
ci.abc.constants.getString(origNs.name_index), 0, true)), true));
}
}
//add all parent objects to scopestack
@@ -2203,8 +2211,8 @@ public class AVM2SourceGenerator implements SourceGenerator {
}
mbCode.add(ins(AVM2Instructions.ReturnVoid));
mb.autoFillStats(abcIndex.getSelectedAbc(), 1, false);
abcIndex.getSelectedAbc().addMethodBody(mb);
mb.autoFillStats(abc, 1, false);
abc.addMethodBody(mb);
si.init_index = mb.method_info;
localData.pkg = DottedChain.EMPTY; //FIXME: pkg.packageName;
generateTraitsPhase3(1/*??*/, false, null, null, true, localData, commands, si.traits, traitArr, initScopes, class_index);
@@ -2226,9 +2234,9 @@ public class AVM2SourceGenerator implements SourceGenerator {
Multiname superName = a.constants.getMultiname(m);
indices.add(
abc.getSelectedAbc().constants.getMultinameId(
new Multiname(Multiname.QNAME,
Multiname.createQName(false,
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), true)
abc.getSelectedAbc().constants.getNamespaceId(superName.getNamespace(a.constants).kind, superName.getNamespace(a.constants).getName(a.constants), 0, true)), true)
);
}
}
@@ -2353,13 +2361,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
}
}
public static int resolveType(SourceGeneratorLocalData localData, GraphTargetItem item, AbcIndexing abc) throws CompilationException {
public static int resolveType(SourceGeneratorLocalData localData, GraphTargetItem item, AbcIndexing abcIndex) throws CompilationException {
int name_index = 0;
GraphTargetItem typeItem = null;
if (item instanceof UnresolvedAVM2Item) {
String fullClass = localData.getFullClass();
item = ((UnresolvedAVM2Item) item).resolve(new TypeItem(fullClass), new ArrayList<>(), new ArrayList<>(), abc, new ArrayList<>(), new ArrayList<>());
item = ((UnresolvedAVM2Item) item).resolve(new TypeItem(fullClass), new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), new ArrayList<>());
}
if (item instanceof TypeItem) {
typeItem = item;
@@ -2370,7 +2378,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
}
if (typeItem instanceof UnresolvedAVM2Item) {
String fullClass = localData.getFullClass();
typeItem = ((UnresolvedAVM2Item) typeItem).resolve(new TypeItem(fullClass), new ArrayList<>(), new ArrayList<>(), abc, new ArrayList<>(), new ArrayList<>());
typeItem = ((UnresolvedAVM2Item) typeItem).resolve(new TypeItem(fullClass), new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), new ArrayList<>());
}
if (!(typeItem instanceof TypeItem)) {
@@ -2392,24 +2400,26 @@ public class AVM2SourceGenerator implements SourceGenerator {
}
}
}*/
AbcIndexing.ClassIndex ci = abc.findClass(new TypeItem(dname));
ABC abc = abcIndex.getSelectedAbc();
AVM2ConstantPool constants = abc.constants;
AbcIndexing.ClassIndex ci = abcIndex.findClass(new TypeItem(dname));
if (ci != null) {
Multiname m = ci.abc.instance_info.get(ci.index).getName(ci.abc.constants);
if (m != null) {
Namespace ns = ci.abc.instance_info.get(ci.index).getName(ci.abc.constants).getNamespace(ci.abc.constants);
String n = m.getName(ci.abc.constants, new ArrayList<DottedChain>(), true);
String n = m.getName(ci.abc.constants, new ArrayList<>(), true);
String nsn = ns == null ? null : ns.getName(ci.abc.constants).toRawString();
name_index = abc.getSelectedAbc().constants.getQnameId(
name_index = constants.getQnameId(
n,
ns == null ? Namespace.KIND_PACKAGE : ns.kind,
nsn, true);
}
}
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))) {
for (int i = 1; i < constants.getMultinameCount(); i++) {
Multiname mname = constants.getMultiname(i);
if (mname != null && name.equals(mname.getName(constants, null, true))) {
if (mname.getNamespace(constants) != null && pkg.equals(mname.getNamespace(constants).getName(constants))) {
name_index = i;
break;
}
@@ -2418,14 +2428,14 @@ public class AVM2SourceGenerator implements SourceGenerator {
if (name_index == 0) {
if (pkg.isEmpty() && localData.currentScript != null /*FIXME!*/) {
for (Trait t : localData.currentScript.traits.traits) {
if (t.getName(abc.getSelectedAbc()).getName(abc.getSelectedAbc().constants, null, true).equals(name)) {
if (t.getName(abc).getName(constants, null, true).equals(name)) {
name_index = t.name_index;
break;
}
}
}
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), true);
name_index = constants.getMultinameId(Multiname.createQName(false, constants.getStringId(name, true), constants.getNamespaceId(Namespace.KIND_PACKAGE, pkg, 0, true)), true);
}
}
@@ -2434,9 +2444,9 @@ public class AVM2SourceGenerator implements SourceGenerator {
int[] params = new int[atype.params.size()];
int i = 0;
for (GraphTargetItem s : atype.params) {
params[i++] = resolveType(localData, s, abc);
params[i++] = resolveType(localData, s, abcIndex);
}
return abc.getSelectedAbc().constants.getMultinameId(new Multiname(Multiname.TYPENAME, 0, 0, 0, name_index, params), true);
return constants.getMultinameId(Multiname.createTypeName(name_index, params), true);
}
return name_index;

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SWC;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.model.ApplyTypeAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item;
@@ -965,9 +966,6 @@ public class ActionScript3Parser {
private GraphTargetItem classTraits(List<Map.Entry<String, Map<String, String>>> metadata, String scriptName, int gpublicNs, DottedChain pkg, List<DottedChain> importedClasses, boolean isDynamic, boolean isFinal, List<Integer> openedNamespaces, DottedChain packageName, int namespace, boolean isInterface, String nameStr, GraphTargetItem extendsStr, List<GraphTargetItem> implementsStr, List<AssignableAVM2Item> variables) throws IOException, AVM2ParseException, CompilationException {
GraphTargetItem ret = null;
ParsedSymbol s = null;
List<GraphTargetItem> traits = new ArrayList<>();
String classNameStr = nameStr;
@@ -977,28 +975,29 @@ public class ActionScript3Parser {
int publicNs = 0;
int privateNs = 0;
int packageInternalNs = 0;
AVM2ConstantPool constants = abcIndex.getSelectedAbc().constants;
if (pkg != null && !pkg.isEmpty()) {
openedNamespaces.add(packageInternalNs = abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE_INTERNAL, abcIndex.getSelectedAbc().constants.getStringId(pkg, true), 0, true));
openedNamespaces.add(packageInternalNs = constants.getNamespaceId(Namespace.KIND_PACKAGE_INTERNAL, pkg, 0, true));
} else {
openedNamespaces.add(packageInternalNs = abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE_INTERNAL, abcIndex.getSelectedAbc().constants.getStringId("", true), 0, true));
openedNamespaces.add(packageInternalNs = constants.getNamespaceId(Namespace.KIND_PACKAGE_INTERNAL, "", 0, true));
}
if (pkg != null && !pkg.isEmpty()) {
openedNamespaces.add(publicNs = abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true));
openedNamespaces.add(publicNs = 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, true))));
openedNamespaces.add(privateNs = constants.addNamespace(new Namespace(Namespace.KIND_PRIVATE, constants.getStringId(pkg.toRawString() + ":" + nameStr, true))));
openedNamespaces.add(abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_NAMESPACE, AS3_NAMESPACE, 0, true));
openedNamespaces.add(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(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));
openedNamespaces.add(protectedNs = constants.getNamespaceId(Namespace.KIND_PROTECTED, packageName == null ? (scriptName + "$0:"/*FIXME?*/ + classNameStr) : packageName.isTopLevel() ? classNameStr : packageName.toRawString() + ":" + classNameStr, 0, true));
openedNamespaces.add(protectedStaticNs = constants.getNamespaceId(Namespace.KIND_STATIC_PROTECTED, packageName == null || packageName.isTopLevel() ? classNameStr : packageName.toRawString() + ":" + classNameStr, 0, true));
if (extendsStr != null) {
List<Integer> indices = new ArrayList<>();
@@ -1010,7 +1009,7 @@ public class ActionScript3Parser {
if (namespaces.get(i) == null || namespaces.get(i).isEmpty()) {
continue;
}
openedNamespaces.add(abcIndex.getSelectedAbc().constants.getNamespaceId(Namespace.KIND_STATIC_PROTECTED, namespaces.get(i) + ":" + names.get(i), 0, true));
openedNamespaces.add(constants.getNamespaceId(Namespace.KIND_STATIC_PROTECTED, namespaces.get(i) + ":" + names.get(i), 0, true));
}
}

View File

@@ -21,7 +21,6 @@ import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -53,7 +52,7 @@ public class ConstructSomethingAVM2Item extends CallAVM2Item {
nssa[i] = openedNamespaces.get(i);
}
nssa[nssa.length - 1] = abc.constants.getNamespaceId(Namespace.KIND_PACKAGE, "__AS3__.vec", 0, true);
return abc.constants.getNamespaceSetId(new NamespaceSet(nssa), true);
return abc.constants.getNamespaceSetId(nssa, true);
}

View File

@@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -28,6 +27,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.Arrays;
import java.util.List;
@@ -55,11 +55,8 @@ public class IndexAVM2Item extends AssignableAVM2Item {
}
private int allNsSet(ABC abc) {
int[] nssa = new int[openedNamespaces.size()];
for (int i = 0; i < openedNamespaces.size(); i++) {
nssa[i] = openedNamespaces.get(i);
}
return abc.constants.getNamespaceSetId(new NamespaceSet(nssa), true);
int[] nssa = Helper.toIntArray(openedNamespaces);
return abc.constants.getNamespaceSetId(nssa, true);
}
@Override
@@ -88,7 +85,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())), true);
int indexPropIndex = g.abcIndex.getSelectedAbc().constants.getMultinameId(Multiname.createMultinameL(attr, allNsSet(g.abcIndex.getSelectedAbc())), true);
return toSourceMerge(localData, generator,
object, dupSetTemp(localData, generator, obj_temp),
@@ -110,7 +107,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())), true);
int indexPropIndex = g.abcIndex.getSelectedAbc().constants.getMultinameId(Multiname.createMultinameL(attr, allNsSet(g.abcIndex.getSelectedAbc())), true);
Reference<Integer> ret_temp = new Reference<>(-1);
if (assignedValue != null) {

View File

@@ -17,14 +17,12 @@
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NanAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.UndefinedAVM2Item;
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -152,14 +150,6 @@ public class NameAVM2Item extends AssignableAVM2Item {
return writer;
}
private int allNsSet(ABC abc) {
int[] nssa = new int[openedNamespaces.size()];
for (int i = 0; i < openedNamespaces.size(); i++) {
nssa[i] = openedNamespaces.get(i);
}
return abc.constants.getNamespaceSetId(new NamespaceSet(nssa), true);
}
public static GraphTargetItem getDefaultValue(String type) {
switch (type) {
case "*":

View File

@@ -18,9 +18,9 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.DottedChain;
@@ -29,6 +29,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.Arrays;
import java.util.List;
@@ -62,11 +63,8 @@ public class NamespacedAVM2Item extends AssignableAVM2Item {
}
private int allNsSet(ABC abc) {
int[] nssa = new int[openedNamespaces.size()];
for (int i = 0; i < openedNamespaces.size(); i++) {
nssa[i] = openedNamespaces.get(i);
}
return abc.constants.getNamespaceSetId(new NamespaceSet(nssa), true);
int[] nssa = Helper.toIntArray(openedNamespaces);
return abc.constants.getNamespaceSetId(nssa, true);
}
@Override
@@ -102,17 +100,19 @@ public class NamespacedAVM2Item extends AssignableAVM2Item {
killTemp(localData, generator, Arrays.asList(ret_temp, name_temp, ns_temp)));
} else
*/
ABC abc = g.abcIndex.getSelectedAbc();
AVM2ConstantPool constants = abc.constants;
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), true)),
ins(AVM2Instructions.FindPropertyStrict, constants.getMultinameId(Multiname.createRTQName(false, constants.getStringId(name, true)), 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())), true)),
ins(AVM2Instructions.GetProperty, constants.getMultinameId(Multiname.createMultinameL(false, allNsSet(abc)), 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())), true)),
ins(AVM2Instructions.SetProperty, constants.getMultinameId(Multiname.createMultinameL(false, allNsSet(abc)), true)),
killTemp(localData, generator, Arrays.asList(ret_temp, name_temp, ns_temp))
);
} else {
@@ -153,23 +153,24 @@ public class NamespacedAVM2Item extends AssignableAVM2Item {
Reference<Integer> obj_temp = new Reference<>(-1);
AVM2ConstantPool constants = g.abcIndex.getSelectedAbc().constants;
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), 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, constants.getMultinameId(Multiname.createRTQNameL(false), 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), true)),
ins(AVM2Instructions.SetProperty, constants.getMultinameId(Multiname.createRTQNameL(false), 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), 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, constants.getMultinameId(Multiname.createRTQNameL(false), 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), true), construct ? callargs.size() : null),
ins(construct ? AVM2Instructions.ConstructProp : delete ? AVM2Instructions.DeleteProperty : AVM2Instructions.GetProperty, constants.getMultinameId(Multiname.createRTQNameL(false), true), construct ? callargs.size() : null),
call ? getTemp(localData, generator, obj_temp) : null,
call ? callargs : null,
call ? ins(AVM2Instructions.Call, callargs.size()) : null,
@@ -180,20 +181,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), true)),
obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, obj != null ? obj : ins(AVM2Instructions.FindPropertyStrict, constants.getMultinameId(Multiname.createRTQName(attr, constants.getStringId(name, true)), 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), true)),
ins(AVM2Instructions.SetProperty, constants.getMultinameId(Multiname.createRTQName(attr, constants.getStringId(name, true)), 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), true)),
obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, obj != null ? obj : ins(AVM2Instructions.FindPropertyStrict, constants.getMultinameId(Multiname.createRTQName(attr, constants.getStringId(name, true)), 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), true), construct ? callargs.size() : null),
ins(construct ? AVM2Instructions.ConstructProp : delete ? AVM2Instructions.DeleteProperty : AVM2Instructions.GetProperty, constants.getMultinameId(Multiname.createRTQName(attr, constants.getStringId(name, true)), true), construct ? callargs.size() : null),
call ? getTemp(localData, generator, obj_temp) : null,
call ? callargs : null,
call ? ins(AVM2Instructions.Call, callargs.size()) : null,

View File

@@ -28,7 +28,6 @@ import com.jpexs.decompiler.flash.abc.avm2.model.InitVectorAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
import com.jpexs.decompiler.flash.abc.types.ScriptInfo;
import com.jpexs.decompiler.flash.abc.types.ValueKind;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
@@ -41,6 +40,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.Arrays;
import java.util.HashMap;
@@ -56,7 +56,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
public GraphTargetItem object;
public AbcIndexing abc;
public AbcIndexing abcIndex;
private final List<Integer> openedNamespaces;
@@ -66,14 +66,14 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
@Override
public AssignableAVM2Item copy() {
PropertyAVM2Item p = new PropertyAVM2Item(object, propertyName, abc, openedNamespaces, callStack);
PropertyAVM2Item p = new PropertyAVM2Item(object, propertyName, abcIndex, openedNamespaces, callStack);
return p;
}
public PropertyAVM2Item(GraphTargetItem object, String propertyName, AbcIndexing abc, List<Integer> openedNamespaces, List<MethodBody> callStack) {
public PropertyAVM2Item(GraphTargetItem object, String propertyName, AbcIndexing abcIndex, List<Integer> openedNamespaces, List<MethodBody> callStack) {
this.propertyName = propertyName;
this.object = object;
this.abc = abc;
this.abcIndex = abcIndex;
this.openedNamespaces = openedNamespaces;
this.callStack = callStack;
}
@@ -83,12 +83,9 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
return writer;
}
private int allNsSet() {
int[] nssa = new int[openedNamespaces.size()];
for (int i = 0; i < openedNamespaces.size(); i++) {
nssa[i] = openedNamespaces.get(i);
}
return abc.getSelectedAbc().constants.getNamespaceSetId(new NamespaceSet(nssa), true);
private int allNsSet(ABC abc) {
int[] nssa = Helper.toIntArray(openedNamespaces);
return abc.constants.getNamespaceSetId(nssa, true);
}
public static GraphTargetItem multinameToType(int m_index, AVM2ConstantPool constants) {
@@ -132,6 +129,8 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
}
GraphTargetItem propType = null;
int propIndex = 0;
ABC abc = abcIndex.getSelectedAbc();
AVM2ConstantPool constants = abc.constants;
if (!propertyName.startsWith("@")) {
if (scopeStack.isEmpty()) { //Everything is multiname when with command
@@ -217,12 +216,12 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
Reference<GraphTargetItem> outPropType = new Reference<>(null);
Reference<ValueKind> outPropValue = new Reference<>(null);
Reference<ABC> outPropValueAbc = new Reference<>(null);
if (AVM2SourceGenerator.searchPrototypeChain(localData.privateNs, localData.protectedNs, false, abc, ftn.getWithoutLast(), ftn.getLast(), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc)) {
if (AVM2SourceGenerator.searchPrototypeChain(localData.privateNs, localData.protectedNs, false, abcIndex, ftn.getWithoutLast(), ftn.getLast(), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc)) {
objType = new TypeItem(outNs.getVal().add(outName.getVal()));
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), true
propIndex = constants.getMultinameId(Multiname.createQName(false,
constants.getStringId(propertyName, true),
constants.getNamespaceId(outPropNsKind.getVal(), outPropNs.getVal(), outPropNsIndex.getVal(), true)), true
);
propValue = outPropValue.getVal();
propValueAbc = outPropValueAbc.getVal();
@@ -233,11 +232,11 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
for (MethodBody b : callStack) {
for (int i = 0; i < b.traits.traits.size(); i++) {
Trait t = b.traits.traits.get(i);
if (t.getName(abc.getSelectedAbc()).getName(abc.getSelectedAbc().constants, null, true).equals(propertyName)) {
if (t.getName(abc).getName(constants, null, true).equals(propertyName)) {
if (t instanceof TraitSlotConst) {
TraitSlotConst tsc = (TraitSlotConst) t;
objType = new TypeItem(DottedChain.FUNCTION);
propType = multinameToType(tsc.type_index, abc.getSelectedAbc().constants);
propType = multinameToType(tsc.type_index, constants);
propIndex = tsc.name_index;
if (!localData.traitUsages.containsKey(b)) {
localData.traitUsages.put(b, new ArrayList<>());
@@ -252,62 +251,62 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
for (int i = 0; i < openedNamespaces.size(); i++) {
int nsindex = openedNamespaces.get(i);
int nsKind = abc.getSelectedAbc().constants.getNamespace(openedNamespaces.get(i)).kind;
DottedChain nsname = abc.getSelectedAbc().constants.getNamespace(openedNamespaces.get(i)).getName(abc.getSelectedAbc().constants);
int nsKind = constants.getNamespace(openedNamespaces.get(i)).kind;
DottedChain nsname = constants.getNamespace(openedNamespaces.get(i)).getName(constants);
int name_index = 0;
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) {
for (int m = 1; m < constants.getMultinameCount(); m++) {
Multiname mname = constants.getMultiname(m);
if (mname.kind == Multiname.QNAME && mname.getName(constants, null, true).equals(propertyName) && mname.namespace_index == nsindex) {
name_index = m;
break;
}
}
if (name_index > 0) {
for (int c = 0; c < abc.getSelectedAbc().instance_info.size(); c++) {
if (abc.getSelectedAbc().instance_info.get(c).deleted) {
for (int c = 0; c < abc.instance_info.size(); c++) {
if (abc.instance_info.get(c).deleted) {
continue;
}
for (Trait t : abc.getSelectedAbc().instance_info.get(c).instance_traits.traits) {
for (Trait t : abc.instance_info.get(c).instance_traits.traits) {
if (t.name_index == name_index) {
objType = multinameToType(abc.getSelectedAbc().instance_info.get(c).name_index, abc.getSelectedAbc().constants);
propType = AVM2SourceGenerator.getTraitReturnType(abc, t);
objType = multinameToType(abc.instance_info.get(c).name_index, constants);
propType = AVM2SourceGenerator.getTraitReturnType(abcIndex, t);
propIndex = t.name_index;
if (t instanceof TraitSlotConst) {
TraitSlotConst tsc = (TraitSlotConst) t;
propValue = new ValueKind(tsc.value_index, tsc.value_kind);
propValueAbc = abc.getSelectedAbc();
propValueAbc = abc;
}
break loopobjType;
}
}
for (Trait t : abc.getSelectedAbc().class_info.get(c).static_traits.traits) {
for (Trait t : abc.class_info.get(c).static_traits.traits) {
if (t.name_index == name_index) {
objType = multinameToType(abc.getSelectedAbc().instance_info.get(c).name_index, abc.getSelectedAbc().constants);
propType = AVM2SourceGenerator.getTraitReturnType(abc, t);
objType = multinameToType(abc.instance_info.get(c).name_index, constants);
propType = AVM2SourceGenerator.getTraitReturnType(abcIndex, t);
propIndex = t.name_index;
if (t instanceof TraitSlotConst) {
TraitSlotConst tsc = (TraitSlotConst) t;
propValue = new ValueKind(tsc.value_index, tsc.value_kind);
propValueAbc = abc.getSelectedAbc();
propValueAbc = abc;
}
break loopobjType;
}
}
}
for (ScriptInfo si : abc.getSelectedAbc().script_info) {
for (ScriptInfo si : abc.script_info) {
if (si.deleted) {
continue;
}
for (Trait t : si.traits.traits) {
if (t.name_index == name_index) {
objType = new TypeItem(DottedChain.OBJECT);
propType = AVM2SourceGenerator.getTraitReturnType(abc, t);
propType = AVM2SourceGenerator.getTraitReturnType(abcIndex, t);
propIndex = t.name_index;
if (t instanceof TraitSlotConst) {
TraitSlotConst tsc = (TraitSlotConst) t;
propValue = new ValueKind(tsc.value_index, tsc.value_kind);
propValueAbc = abc.getSelectedAbc();
propValueAbc = abc;
}
break loopobjType;
}
@@ -315,7 +314,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
}
}
if (nsKind == Namespace.KIND_PACKAGE && propertyName != null) {
AbcIndexing.TraitIndex p = abc.findNsProperty(new AbcIndexing.PropertyNsDef(propertyName, nsname, abc.getSelectedAbc(), openedNamespaces.get(i)), true, true);
AbcIndexing.TraitIndex p = abcIndex.findNsProperty(new AbcIndexing.PropertyNsDef(propertyName, nsname, abc, openedNamespaces.get(i)), true, true);
Reference<String> outName = new Reference<>("");
Reference<DottedChain> outNs = new Reference<>(DottedChain.EMPTY);
@@ -326,12 +325,12 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
Reference<ValueKind> outPropValue = new Reference<>(null);
Reference<ABC> outPropValueAbc = new Reference<>(null);
if (p != null && (p.objType instanceof TypeItem)) {
if (AVM2SourceGenerator.searchPrototypeChain(localData.privateNs, localData.protectedNs, false, abc, nsname, (((TypeItem) p.objType).fullTypeName.getLast()), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc)) {
if (AVM2SourceGenerator.searchPrototypeChain(localData.privateNs, localData.protectedNs, false, abcIndex, nsname, (((TypeItem) p.objType).fullTypeName.getLast()), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc)) {
objType = new TypeItem(outNs.getVal().add(outName.getVal()));
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), true
propIndex = constants.getMultinameId(Multiname.createQName(false,
constants.getStringId(propertyName, true),
constants.getNamespaceId(outPropNsKind.getVal(), outPropNs.getVal(), outPropNsIndex.getVal(), true)), true
);
propValue = p.value;
propValueAbc = outPropValueAbc.getVal();
@@ -357,9 +356,15 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
if (attr) {
pname = pname.substring(1);
}
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()), true);
Multiname multiname;
if (attr && pname.isEmpty()) {
multiname = Multiname.createMultinameL(true,
constants.getNamespaceSetId(new int[]{constants.getNamespaceId(Namespace.KIND_PACKAGE_INTERNAL, localData.pkg, 0, true)}, true));
} else {
int name_index = constants.getStringId("*".equals(pname) ? null : pname, true); //Note: name = * is for .@* attribute
multiname = Multiname.createMultiname(attr, name_index, allNsSet(abc));
}
propIndex = constants.getMultinameId(multiname, true);
propType = TypeItem.UNBOUNDED;
objType = TypeItem.UNBOUNDED;
propValue = null;
@@ -630,7 +635,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
/*List<ABC> abcs = new ArrayList<>();
abcs.add(abc);
abcs.addAll(otherABCs);*/
if (!localData.subMethod && cname != null && AVM2SourceGenerator.searchPrototypeChain(localData.privateNs, localData.protectedNs, true, abc, pkgName, cname, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc) && (localData.currentClass.equals(outNs.getVal().add(outName.getVal())))) {
if (!localData.subMethod && cname != null && AVM2SourceGenerator.searchPrototypeChain(localData.privateNs, localData.protectedNs, true, abcIndex, pkgName, cname, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc) && (localData.currentClass.equals(outNs.getVal().add(outName.getVal())))) {
NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), 0, "this", null, false, openedNamespaces);
nobj.setRegNumber(0);
obj = nobj;

View File

@@ -17,7 +17,6 @@
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
import com.jpexs.decompiler.flash.abc.avm2.model.InitVectorAVM2Item;
@@ -26,9 +25,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.NanAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.UndefinedAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.DottedChain;
@@ -184,14 +181,6 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
return writer;
}
private int allNsSet(ABC abc) {
int[] nssa = new int[openedNamespaces.size()];
for (int i = 0; i < openedNamespaces.size(); i++) {
nssa[i] = openedNamespaces.get(i);
}
return abc.constants.getNamespaceSetId(new NamespaceSet(nssa), true);
}
public static GraphTargetItem getDefaultValue(String type) {
switch (type) {
case "*":

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.abc.types.Multiname;
@@ -59,8 +60,9 @@ public class XMLAVM2Item extends AVM2Item {
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
AVM2SourceGenerator g = (AVM2SourceGenerator) generator;
AVM2ConstantPool constants = g.abcIndex.getSelectedAbc().constants;
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), true)),
ins(AVM2Instructions.GetLex, constants.getMultinameId(Multiname.createQName(false, constants.getStringId("XML", true), constants.getNamespaceId(Namespace.KIND_PACKAGE, "", 0, true)), true)),
value,
ins(AVM2Instructions.Construct, 1)
);

View File

@@ -86,11 +86,7 @@ public class Multiname {
params = null;
}
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) {
private 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;
@@ -102,6 +98,30 @@ public class Multiname {
}
}
public static Multiname createQName(boolean attribute, int name_index, int namespace_index) {
return new Multiname(attribute ? QNAMEA : QNAME, name_index, namespace_index, 0, 0, null);
}
public static Multiname createRTQName(boolean attribute, int name_index) {
return new Multiname(attribute ? RTQNAMEA : RTQNAME, name_index, 0, 0, 0, null);
}
public static Multiname createRTQNameL(boolean attribute) {
return new Multiname(attribute ? RTQNAMELA : RTQNAMEL, 0, 0, 0, 0, null);
}
public static Multiname createMultiname(boolean attribute, int name_index, int namespace_set_index) {
return new Multiname(attribute ? MULTINAMEA : MULTINAME, name_index, 0, namespace_set_index, 0, null);
}
public static Multiname createMultinameL(boolean attribute, int namespace_set_index) {
return new Multiname(attribute ? MULTINAMELA : MULTINAMEL, 0, 0, namespace_set_index, 0, null);
}
public static Multiname createTypeName(int qname_index, int[] params) {
return new Multiname(TYPENAME, 0, 0, 0, qname_index, params);
}
public boolean isAttribute() {
if (kind == QNAMEA) {
return true;