avm2: Don't store more than one object parameter, because there are no classes with multiple paramters.
This commit is contained in:
parent
5c740ef1e1
commit
3b48216762
|
@ -525,7 +525,7 @@ pub fn filter<'gc>(
|
|||
|
||||
let value_type = this
|
||||
.as_class_object()
|
||||
.and_then(|c| c.as_class_params().and_then(|p| p.get(0).copied()))
|
||||
.and_then(|c| c.as_class_params())
|
||||
.ok_or("Cannot filter unparameterized vector")?
|
||||
.unwrap_or(activation.avm2().classes().object);
|
||||
let mut new_storage = VectorStorage::new(0, false, value_type);
|
||||
|
@ -684,7 +684,7 @@ pub fn map<'gc>(
|
|||
|
||||
let value_type = this
|
||||
.as_class_object()
|
||||
.and_then(|c| c.as_class_params().and_then(|p| p.get(0).copied()))
|
||||
.and_then(|c| c.as_class_params())
|
||||
.ok_or("Cannot filter unparameterized vector")?
|
||||
.unwrap_or(activation.avm2().classes().object);
|
||||
let mut new_storage = VectorStorage::new(0, false, value_type);
|
||||
|
|
|
@ -1042,25 +1042,21 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
}
|
||||
}
|
||||
|
||||
if let (Some(my_params), Some(test_params)) =
|
||||
if let (Some(my_param), Some(test_param)) =
|
||||
(class.as_class_params(), test_class.as_class_params())
|
||||
{
|
||||
if my_params.len() == test_params.len() {
|
||||
let mut are_all_params_coercible = true;
|
||||
let mut are_all_params_coercible = true;
|
||||
|
||||
for (my_param, test_param) in my_params.iter().zip(test_params.iter()) {
|
||||
are_all_params_coercible &= match (my_param, test_param) {
|
||||
(Some(my_param), Some(test_param)) => {
|
||||
my_param.has_class_in_chain(*test_param, activation)?
|
||||
}
|
||||
(None, Some(_)) => false,
|
||||
_ => true,
|
||||
}
|
||||
are_all_params_coercible &= match (my_param, test_param) {
|
||||
(Some(my_param), Some(test_param)) => {
|
||||
my_param.has_class_in_chain(test_param, activation)?
|
||||
}
|
||||
(None, Some(_)) => false,
|
||||
_ => true,
|
||||
};
|
||||
|
||||
if are_all_params_coercible {
|
||||
return Ok(true);
|
||||
}
|
||||
if are_all_params_coercible {
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1082,7 +1078,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
/// Get the parameters of this class object, if present.
|
||||
///
|
||||
/// Only specialized generic classes will yield their parameters.
|
||||
fn as_class_params(&self) -> Option<Ref<[Option<Object<'gc>>]>> {
|
||||
fn as_class_params(&self) -> Option<Option<Object<'gc>>> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ use crate::avm2::value::Value;
|
|||
use crate::avm2::Error;
|
||||
use crate::{impl_avm2_custom_object, impl_avm2_custom_object_properties};
|
||||
use gc_arena::{Collect, GcCell, MutationContext};
|
||||
use std::cell::Ref;
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// An Object which can be called to execute its function code.
|
||||
|
@ -54,7 +53,7 @@ pub struct ClassObjectData<'gc> {
|
|||
///
|
||||
/// An individual parameter of `None` signifies the parameter `*`, which is
|
||||
/// represented in AVM2 as `null` with regards to type application.
|
||||
params: Option<Vec<Option<Object<'gc>>>>,
|
||||
params: Option<Option<Object<'gc>>>,
|
||||
|
||||
/// List of all applications of this class.
|
||||
///
|
||||
|
@ -478,14 +477,8 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> {
|
|||
None //AS3 does not have metaclasses
|
||||
}
|
||||
|
||||
fn as_class_params(&self) -> Option<Ref<[Option<Object<'gc>>]>> {
|
||||
let read = self.0.read();
|
||||
|
||||
if read.params.is_some() {
|
||||
Some(Ref::map(read, |r| &r.params.as_ref().unwrap()[..]))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
fn as_class_params(&self) -> Option<Option<Object<'gc>>> {
|
||||
self.0.read().params
|
||||
}
|
||||
|
||||
fn set_class_object(self, _mc: MutationContext<'gc, '_>, _class_object: Object<'gc>) {
|
||||
|
@ -607,7 +600,7 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> {
|
|||
instance_allocator,
|
||||
constructor,
|
||||
native_constructor,
|
||||
params: Some(object_params.to_vec()),
|
||||
params: Some(object_params[0]),
|
||||
applications: HashMap::new(),
|
||||
},
|
||||
));
|
||||
|
|
|
@ -27,7 +27,6 @@ pub fn vector_allocator<'gc>(
|
|||
//getting the parameter type for our storage.
|
||||
let param_type = class
|
||||
.as_class_params()
|
||||
.and_then(|p| p.get(0).copied())
|
||||
.flatten()
|
||||
.unwrap_or_else(|| activation.avm2().classes().object);
|
||||
|
||||
|
|
Loading…
Reference in New Issue