From 767dfd8278739820c053d35a4579d1247a81c241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 23 Nov 2014 13:21:57 +0100 Subject: [PATCH] Issue #715 namespace resolving fix --- .../avm2/parser/script/AVM2SourceGenerator.java | 3 ++- .../abc/avm2/parser/script/PropertyAVM2Item.java | 2 +- .../abc/avm2/parser/script/UnresolvedAVM2Item.java | 14 +------------- .../flash/abc/types/traits/TraitClass.java | 2 +- 4 files changed, 5 insertions(+), 16 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java index d5eef35eb..ede2508d8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java @@ -1839,7 +1839,8 @@ public class AVM2SourceGenerator implements SourceGenerator { if (fullCustom.equals(m.getNameWithNamespace(a.constants, true))) { if (t instanceof TraitSlotConst) { if (((TraitSlotConst) t).isNamespace()) { - return ((TraitSlotConst) t).value_index; + Namespace ns = a.constants.getNamespace(((TraitSlotConst) t).value_index); + return abc.constants.getNamespaceId(new Namespace(ns.kind, abc.constants.getStringId(ns.getName(a.constants, true),true)), 0, true); } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java index 2f99d8c3e..57fdae658 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java @@ -258,7 +258,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { for (int i = 0; i < openedNamespaces.size(); i++) { int nsindex = openedNamespaces.get(i); int nsKind = abc.constants.constant_namespace.get(openedNamespaces.get(i)).kind; - String nsname = abc.constants.constant_namespace.get(openedNamespaces.get(i)).getName(abc.constants, true); + String nsname = abc.constants.constant_namespace.get(openedNamespaces.get(i)).getName(abc.constants, true); int name_index = 0; for (int m = 1; m < abc.constants.constant_multiname.size(); m++) { Multiname mname = abc.constants.constant_multiname.get(m); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java index 2d69192c1..3e1f4ca6a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java @@ -326,19 +326,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { impName = impName.substring(impName.lastIndexOf('.') + 1); } if (impName.equals(parts.get(0))) { - TypeItem ret = new TypeItem(imp); - /*for (GraphTargetItem s : subtypes) { - if (!subtypes.isEmpty() && parts.size() > 1) { - continue; - } - UnresolvedAVM2Item su = new UnresolvedAVM2Item(new ArrayList(), importedClasses, true, null, line, s, null, openedNamespaces); - su.resolve(thisType, paramTypes, paramNames, abc, otherAbcs, callStack, variables); - if (!(su.resolved instanceof TypeItem)) { - throw new CompilationException("Not a type", line); - } - TypeItem st = (TypeItem) su.resolved; - ret.subtypes.add(st.fullTypeName); - }*/ + TypeItem ret = new TypeItem(imp); resolved = ret; for (int i = 1; i < parts.size(); i++) { resolved = new PropertyAVM2Item(resolved, parts.get(i), abc, otherAbcs, openedNamespaces, new ArrayList()); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index fde7ea4be..818ae7cc9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -91,7 +91,7 @@ public class TraitClass extends Trait implements TraitWithSlot { if (name.isEmpty()) { name = "*"; } - String newimport = ns.getName(abc.constants, false); + String newimport = ns.getName(abc.constants, ns.kind == Namespace.KIND_NAMESPACE); /*if ((ns.kind != Namespace.KIND_PACKAGE) && (ns.kind != Namespace.KIND_NAMESPACE) && (ns.kind != Namespace.KIND_STATIC_PROTECTED)) {