mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-18 09:28:23 +00:00
Fixed: #1188 AS3 Static initializer - init slot/const only when not referencing other property
This commit is contained in:
@@ -252,6 +252,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.InitPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item;
|
||||
@@ -1945,6 +1947,17 @@ public class AVM2Code implements Cloneable {
|
||||
multinameIndex = ((FullMultinameAVM2Item) ((SetPropertyAVM2Item) ti).propertyName).multinameIndex;
|
||||
value = ((SetPropertyAVM2Item) ti).value;
|
||||
}
|
||||
Set<GraphTargetItem> subItems = value.getAllSubItemsRecursively();
|
||||
subItems.add(value);
|
||||
for (GraphTargetItem item : subItems) {
|
||||
if ((item instanceof GetPropertyAVM2Item) || (item instanceof GetLexAVM2Item)) { //references other property
|
||||
continue loopi;
|
||||
}
|
||||
|
||||
if (item instanceof LocalRegAVM2Item) { //it is surely in static initializer block, not in slot/const
|
||||
continue loopi;
|
||||
}
|
||||
}
|
||||
Multiname m = abc.constants.getMultiname(multinameIndex);
|
||||
for (Traits ts : initTraits) {
|
||||
for (Trait t : ts.traits) {
|
||||
|
||||
@@ -329,4 +329,38 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase {
|
||||
+ " }\n"
|
||||
+ "}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitializer() {
|
||||
decompileScriptPack("standard", "tests_classes.TestInitializer", "package tests_classes\n"
|
||||
+ "{\n"
|
||||
+ " public class TestInitializer\n"
|
||||
+ " {\n"
|
||||
+ " public static var s_alpha:RegExp = /[a-z]+/;\n"
|
||||
+ " \n"
|
||||
+ " public static var s_regs:Array;\n"
|
||||
+ " \n"
|
||||
+ " public static var s_numbers:RegExp = /[0-9]+/;\n"
|
||||
+ " \n"
|
||||
+ " {\n"
|
||||
+ " s_regs = [s_alpha,s_numbers];\n"
|
||||
+ " }\n"
|
||||
+ " \n"
|
||||
+ " public var i_email:RegExp;\n"
|
||||
+ " \n"
|
||||
+ " public var i_link:RegExp;\n"
|
||||
+ " \n"
|
||||
+ " public var i_regs:Array;\n"
|
||||
+ " \n"
|
||||
+ " public function TestInitializer()\n"
|
||||
+ " {\n"
|
||||
+ " this.i_email = /.*@.*\\..*/;\n"
|
||||
+ " this.i_link = /<a href=\".*\">/;\n"
|
||||
+ " this.i_regs = [this.i_email,this.i_link];\n"
|
||||
+ " super();\n"
|
||||
+ " trace(s_regs[1]);\n"
|
||||
+ " }\n"
|
||||
+ " }\n"
|
||||
+ "}");
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -6,8 +6,7 @@ package
|
||||
import tests_classes.mypackage1.SetupMyPackage1;
|
||||
import tests_classes.mypackage2.SetupMyPackage2;
|
||||
import tests_classes.mypackage3.SetupMyPackage3;
|
||||
import tests_classes.TestThisOutsideClass;
|
||||
import tests_classes.TestImports;
|
||||
import tests_classes.*;
|
||||
|
||||
/**
|
||||
* ...
|
||||
@@ -102,9 +101,11 @@ package
|
||||
|
||||
TestThisOutsideClass;
|
||||
TestImports;
|
||||
TestInitializer;
|
||||
|
||||
public function Main()
|
||||
{
|
||||
new TestInitializer();
|
||||
if (stage) init();
|
||||
else addEventListener(Event.ADDED_TO_STAGE, init);
|
||||
}
|
||||
|
||||
28
libsrc/ffdec_lib/testdata/as3_new/src/tests_classes/TestInitializer.as
vendored
Normal file
28
libsrc/ffdec_lib/testdata/as3_new/src/tests_classes/TestInitializer.as
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
package tests_classes
|
||||
{
|
||||
/**
|
||||
* ...
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TestInitializer
|
||||
{
|
||||
public static var s_alpha:RegExp = /[a-z]+/;
|
||||
public static var s_regs:Array;
|
||||
public static var s_numbers:RegExp = /[0-9]+/;
|
||||
|
||||
public var i_email:RegExp = /.*@.*\..*/
|
||||
public var i_link:RegExp = /<a href=".*">/;
|
||||
public var i_regs:Array = [i_email,i_link];
|
||||
|
||||
{
|
||||
s_regs = [s_alpha, s_numbers];
|
||||
}
|
||||
|
||||
public function TestInitializer()
|
||||
{
|
||||
trace(s_regs[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user