mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-15 23:08:13 +00:00
Fixed #1892 AS3 - Package internal custom namespaces
This commit is contained in:
@@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
|
||||
- [#1891] AS3 - duplicate variable declaration in some cases
|
||||
- All SWF classes inside DoABC tags in the taglist view
|
||||
- Exception on package selection inside DoABC tag on taglist view
|
||||
- [#1892] AS3 - Package internal custom namespaces
|
||||
|
||||
## [17.0.2] - 2022-11-22
|
||||
### Fixed
|
||||
@@ -2661,6 +2662,7 @@ All notable changes to this project will be documented in this file.
|
||||
[#1890]: https://www.free-decompiler.com/flash/issues/1890
|
||||
[#1810]: https://www.free-decompiler.com/flash/issues/1810
|
||||
[#1891]: https://www.free-decompiler.com/flash/issues/1891
|
||||
[#1892]: https://www.free-decompiler.com/flash/issues/1892
|
||||
[#1882]: https://www.free-decompiler.com/flash/issues/1882
|
||||
[#1880]: https://www.free-decompiler.com/flash/issues/1880
|
||||
[#1881]: https://www.free-decompiler.com/flash/issues/1881
|
||||
|
||||
@@ -2128,10 +2128,13 @@ public class ABC implements Openable {
|
||||
return null;
|
||||
}
|
||||
Namespace ns = constants.getNamespace(link_ns_index);
|
||||
if (ns.kind != Namespace.KIND_NAMESPACE) {
|
||||
if (ns.kind != Namespace.KIND_NAMESPACE && ns.kind != Namespace.KIND_PACKAGE_INTERNAL) {
|
||||
return null;
|
||||
}
|
||||
String name = constants.getString(ns.name_index);
|
||||
if (name.equals("http://adobe.com/AS3/2006/builtin")) {
|
||||
return null;
|
||||
}
|
||||
for (ABCContainerTag abcTag : getAbcTags()) {
|
||||
DottedChain dc = abcTag.getABC().nsValueToName(name);
|
||||
nsname = dc.getLast();
|
||||
|
||||
@@ -135,7 +135,7 @@ public class FullMultinameAVM2Item extends AVM2Item {
|
||||
AVM2ConstantPool constants = localData.constantsAvm2;
|
||||
List<DottedChain> fullyQualifiedNames = property ? new ArrayList<>() : localData.fullyQualifiedNames;
|
||||
if (multinameIndex > 0 && multinameIndex < constants.getMultinameCount()) {
|
||||
writer.append(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames, false, true));
|
||||
writer.append(constants.getMultiname(multinameIndex).getNameWithCustomNamespace(localData.abc, fullyQualifiedNames, false, true));
|
||||
} else {
|
||||
writer.append("§§multiname(").append(multinameIndex).append(")");
|
||||
}
|
||||
|
||||
@@ -363,7 +363,8 @@ public class Multiname {
|
||||
} else {
|
||||
String name = abc.constants.getString(name_index);
|
||||
|
||||
if (namespace_index > 0 && getNamespace(abc.constants).kind == Namespace.KIND_NAMESPACE) {
|
||||
int nskind = namespace_index <= 0 ? -1 : getNamespace(abc.constants).kind;
|
||||
if (nskind == Namespace.KIND_NAMESPACE || nskind == Namespace.KIND_PACKAGE_INTERNAL) {
|
||||
DottedChain dc = abc.findCustomNs(namespace_index);
|
||||
String nsname = dc != null ? dc.getLast() : null;
|
||||
|
||||
|
||||
@@ -190,6 +190,21 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void writeUses(int scriptIndex, int classIndex, boolean isStatic, ABC abc, GraphTextWriter writer) throws InterruptedException {
|
||||
List<Dependency> dependencies = new ArrayList<>();
|
||||
List<String> uses = new ArrayList<>();
|
||||
String customNs = null;
|
||||
Namespace ns = getName(abc).getNamespace(abc.constants);
|
||||
if (ns.kind == Namespace.KIND_NAMESPACE) {
|
||||
customNs = ns.getName(abc.constants).toRawString();
|
||||
}
|
||||
getDependencies(scriptIndex, classIndex, isStatic, customNs, abc, dependencies, uses, null, new ArrayList<>());
|
||||
for (String us : uses) {
|
||||
writer.appendNoHilight("use namespace " + us + ";").newLine();
|
||||
}
|
||||
}
|
||||
|
||||
public void writeImportsUsages(int scriptIndex, int classIndex, boolean isStatic, ABC abc, GraphTextWriter writer, DottedChain ignorePackage, List<DottedChain> fullyQualifiedNames) throws InterruptedException {
|
||||
|
||||
List<String> namesInThisPackage = new ArrayList<>();
|
||||
@@ -275,12 +290,12 @@ public abstract class Trait implements Cloneable, Serializable {
|
||||
if (hasImport) {
|
||||
writer.newLine();
|
||||
}
|
||||
for (String us : uses) {
|
||||
/*for (String us : uses) {
|
||||
writer.appendNoHilight("use namespace " + us + ";").newLine();
|
||||
}
|
||||
if (uses.size() > 0) {
|
||||
writer.newLine();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public final GraphTextWriter getMetaData(Trait parent, ConvertData convertData, ABC abc, GraphTextWriter writer) {
|
||||
|
||||
@@ -90,6 +90,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
|
||||
writer.startBlock();
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (bodyIndex != -1) {
|
||||
//writeUses(scriptIndex, classIndex, isStatic, abc, writer);
|
||||
abc.bodies.get(bodyIndex).toString(abcIndex,path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false, true), exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>());
|
||||
}
|
||||
writer.endBlock();
|
||||
|
||||
@@ -145,6 +145,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
convertTraitHeader(abc, writer);
|
||||
}
|
||||
if (bodyIndex != -1) {
|
||||
//writeUses(scriptIndex, classIndex, isStatic, abc, writer);
|
||||
abc.bodies.get(bodyIndex).toString(abcIndex, path, exportMode, abc, this, writer, fullyQualifiedNames, new HashSet<>());
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -189,7 +189,7 @@ public class DependencyParser {
|
||||
private static boolean parseUsagesFromNS(String ignoredCustom, ABC abc, List<Dependency> dependencies, List<String> uses, int namespace_index, DottedChain ignorePackage, String name) {
|
||||
Namespace ns = abc.constants.getNamespace(namespace_index);
|
||||
|
||||
if (ns.kind == Namespace.KIND_NAMESPACE) {
|
||||
if (ns.kind == Namespace.KIND_NAMESPACE || ns.kind == Namespace.KIND_PACKAGE_INTERNAL) {
|
||||
String nsVal = ns.getName(abc.constants).toRawString();
|
||||
for (ABCContainerTag abcTag : abc.getAbcTags()) {
|
||||
DottedChain nsimport = abcTag.getABC().nsValueToName(nsVal);
|
||||
@@ -199,7 +199,7 @@ public class DependencyParser {
|
||||
if (!nsimport.isEmpty()) {
|
||||
|
||||
Dependency depNs = new Dependency(nsimport, DependencyType.NAMESPACE);
|
||||
if (!nsimport.getWithoutLast().equals(ignorePackage) && !dependencies.contains(depNs)) {
|
||||
if ((ignorePackage == null || !nsimport.getWithoutLast().equals(ignorePackage)) && !dependencies.contains(depNs)) {
|
||||
dependencies.add(depNs);
|
||||
}
|
||||
if (ignoredCustom != null && nsVal.equals(ignoredCustom)) {
|
||||
|
||||
@@ -1271,7 +1271,8 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
+ "var a:* = ns::unnamespacedFunc();\r\n"
|
||||
+ "var b:* = ns::[name];\r\n"
|
||||
+ "trace(b.c);\r\n"
|
||||
+ "var c:int = myInternal::neco;\r\n",
|
||||
+ "var c:int = myInternal::neco;\r\n"
|
||||
+ "var d:int = myInternal2::neco;\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1266,7 +1266,8 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
+ "var a:* = ns::unnamespacedFunc();\r\n"
|
||||
+ "var b:* = ns::[name];\r\n"
|
||||
+ "trace(b.c);\r\n"
|
||||
+ "var c:* = myInternal::neco;\r\n",
|
||||
+ "var c:* = myInternal::neco;\r\n"
|
||||
+ "var d:* = this.myInternal2::neco;\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,10 +1,15 @@
|
||||
package tests
|
||||
{
|
||||
import tests_other.myInternal;
|
||||
import tests_other.myInternal2;
|
||||
|
||||
|
||||
|
||||
public class TestNames
|
||||
{
|
||||
myInternal var neco:int;
|
||||
myInternal var neco:int;
|
||||
myInternal2 var neco:int;
|
||||
var nic:int;
|
||||
|
||||
public function run():*
|
||||
{
|
||||
@@ -13,8 +18,10 @@ package tests
|
||||
var a:* = ns::unnamespacedFunc();
|
||||
var b:* = ns::[name];
|
||||
trace(b.c);
|
||||
var c:* = myInternal::neco;
|
||||
}
|
||||
var c:* = myInternal::neco;
|
||||
use namespace myInternal2;
|
||||
var d:* = neco;
|
||||
}
|
||||
|
||||
public function getNamespace():Namespace
|
||||
{
|
||||
@@ -30,5 +37,10 @@ package tests
|
||||
{
|
||||
trace("hello");
|
||||
}
|
||||
|
||||
myInternal2 function namespacedFunc2() : void
|
||||
{
|
||||
trace("hello");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
4
libsrc/ffdec_lib/testdata/as3_new/src/tests_other/myInternal2.as
vendored
Normal file
4
libsrc/ffdec_lib/testdata/as3_new/src/tests_other/myInternal2.as
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
package tests_other
|
||||
{
|
||||
public namespace myInternal2;
|
||||
}
|
||||
Reference in New Issue
Block a user