From 6f5601607976ed8cb8c5dbdfcf3804779addc5b0 Mon Sep 17 00:00:00 2001 From: Adrian Wielgosik Date: Mon, 29 Jul 2024 20:36:24 +0200 Subject: [PATCH] avm2: Support recursive Vector> lookups --- core/src/avm2/domain.rs | 4 +--- tests/tests/swfs/avm2/vector_class/Test.as | 14 +++++++++++++- tests/tests/swfs/avm2/vector_class/output.txt | 7 +++++++ tests/tests/swfs/avm2/vector_class/test.swf | Bin 1402 -> 1405 bytes 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/core/src/avm2/domain.rs b/core/src/avm2/domain.rs index 076858734d0c..fb7d88990a80 100644 --- a/core/src/avm2/domain.rs +++ b/core/src/avm2/domain.rs @@ -298,9 +298,7 @@ impl<'gc> Domain<'gc> { let res = self.get_defined_value(activation, name); if let Some(type_name) = type_name { - let type_qname = - QName::from_qualified_name(type_name, api_version, &mut activation.context); - let type_class = self.get_defined_value(activation, type_qname)?; + let type_class = self.get_defined_value_handling_vector(activation, type_name)?; if let Ok(res) = res { let class = res.as_object().ok_or_else(|| { Error::RustError(format!("Vector type {:?} was not an object", res).into()) diff --git a/tests/tests/swfs/avm2/vector_class/Test.as b/tests/tests/swfs/avm2/vector_class/Test.as index 0e93af52a0fe..05fbf1b4c02f 100644 --- a/tests/tests/swfs/avm2/vector_class/Test.as +++ b/tests/tests/swfs/avm2/vector_class/Test.as @@ -58,7 +58,19 @@ trace("Vector.: " + getDefinitionByName(name)); trace("ApplicationDomain.hasDefinition Vector.: " + ApplicationDomain.currentDomain.hasDefinition(name)); trace("ApplicationDomain.getDefinition Vector.: " + ApplicationDomain.currentDomain.getDefinition(name)); - + + vec = new Vector.>(); + name = getQualifiedClassName(vec); + trace("Vector.> name: " + name); + trace("__AS3__.vec::Vector.<__AS3__.vec::Vector.>: " + getDefinitionByName(name)); + trace("ApplicationDomain.hasDefinition __AS3__.vec::Vector.<__AS3__.vec::Vector.>: " + ApplicationDomain.currentDomain.hasDefinition(name)); + trace("ApplicationDomain.getDefinition __AS3__.vec::Vector.<__AS3__.vec::Vector.>: " + ApplicationDomain.currentDomain.getDefinition(name)); + name = "Vector.>"; + trace("Vector.>: " + getDefinitionByName(name)); + trace("ApplicationDomain.hasDefinition Vector.>: " + ApplicationDomain.currentDomain.hasDefinition(name)); + trace("ApplicationDomain.getDefinition Vector.>: " + ApplicationDomain.currentDomain.getDefinition(name)); + trace("Vector. without namespace" + getDefinitionByName("Vector.")); + trace("Vector. without namespace" + getDefinitionByName("Vector.")); try { trace("Vector without namespace: " + getDefinitionByName("Vector")); diff --git a/tests/tests/swfs/avm2/vector_class/output.txt b/tests/tests/swfs/avm2/vector_class/output.txt index 3303705e00d5..80b7d250f4e0 100644 --- a/tests/tests/swfs/avm2/vector_class/output.txt +++ b/tests/tests/swfs/avm2/vector_class/output.txt @@ -25,5 +25,12 @@ Vector. name: __AS3__.vec::Vector. Vector.: [class Vector.] ApplicationDomain.hasDefinition Vector.: true ApplicationDomain.getDefinition Vector.: [class Vector.] +Vector.> name: __AS3__.vec::Vector.<__AS3__.vec::Vector.> +__AS3__.vec::Vector.<__AS3__.vec::Vector.>: [class Vector.<__AS3__.vec::Vector.>] +ApplicationDomain.hasDefinition __AS3__.vec::Vector.<__AS3__.vec::Vector.>: true +ApplicationDomain.getDefinition __AS3__.vec::Vector.<__AS3__.vec::Vector.>: [class Vector.<__AS3__.vec::Vector.>] +Vector.>: [class Vector.<__AS3__.vec::Vector.>] +ApplicationDomain.hasDefinition Vector.>: true +ApplicationDomain.getDefinition Vector.>: [class Vector.<__AS3__.vec::Vector.>] Vector. without namespace[class Vector.] Caught error: ReferenceError: Error #1065: Variable Vector is not defined. diff --git a/tests/tests/swfs/avm2/vector_class/test.swf b/tests/tests/swfs/avm2/vector_class/test.swf index 4c023d41ec74dbf8101e3fca85c0a3b7dde6f215..883a9a43bbd0ce84144331e5417bba5561d69b88 100644 GIT binary patch literal 1405 zcmV-@1%moRS5qq*4*&pooRwBtciKi6oe@HV5Q`m*AjCMhA!%bfAl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