diff --git a/core/src/avm2/globals.rs b/core/src/avm2/globals.rs index e08a6a18e..a087e2144 100644 --- a/core/src/avm2/globals.rs +++ b/core/src/avm2/globals.rs @@ -314,7 +314,7 @@ fn function<'gc>( let method = Method::from_builtin(nf, name, mc); let as3fn = FunctionObject::from_method(activation, method, scope, None, None).into(); domain.export_definition(qname, script, mc)?; - global.install_const_late(mc, None, qname, as3fn); + global.install_const_late(mc, qname, as3fn); Ok(()) } @@ -332,7 +332,7 @@ fn dynamic_class<'gc>( let class = class_object.inner_class_definition(); let name = class.read().name(); - global.install_const_late(mc, None, name, class_object.into()); + global.install_const_late(mc, name, class_object.into()); domain.export_definition(name, script, mc) } @@ -375,7 +375,6 @@ fn class<'gc>( let class_object = ClassObject::from_class(activation, class_def, super_class)?; global.install_const_late( activation.context.gc_context, - None, class_name, class_object.into(), ); @@ -395,7 +394,7 @@ fn constant<'gc>( let (_, mut global, mut domain) = script.init(); let name = QName::new(Namespace::package(package), name); domain.export_definition(name, script, mc)?; - global.install_const_late(mc, None, name, value); + global.install_const_late(mc, name, value); Ok(()) } diff --git a/core/src/avm2/globals/vector.rs b/core/src/avm2/globals/vector.rs index 6dff556e6..4d499bdce 100644 --- a/core/src/avm2/globals/vector.rs +++ b/core/src/avm2/globals/vector.rs @@ -73,7 +73,6 @@ pub fn class_init<'gc>( globals.install_const_late( activation.context.gc_context, - None, int_vector_name, int_vector_class.into(), ); @@ -89,7 +88,6 @@ pub fn class_init<'gc>( globals.install_const_late( activation.context.gc_context, - None, uint_vector_name, uint_vector_class.into(), ); @@ -105,7 +103,6 @@ pub fn class_init<'gc>( globals.install_const_late( activation.context.gc_context, - None, number_vector_name, number_vector_class.into(), ); @@ -120,7 +117,6 @@ pub fn class_init<'gc>( globals.install_const_late( activation.context.gc_context, - None, object_vector_name, object_vector_class.into(), ); diff --git a/core/src/avm2/object.rs b/core/src/avm2/object.rs index e193d939e..cec5fe6ea 100644 --- a/core/src/avm2/object.rs +++ b/core/src/avm2/object.rs @@ -560,18 +560,15 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into> + Clone + Copy } - - /// Install a const trait on the global object. /// This should only ever be called on the `global` object, during initialization. fn install_const_late( &mut self, mc: MutationContext<'gc, '_>, - slot_id: Option, name: QName<'gc>, value: Value<'gc>, ) { - let new_slot_id = self.vtable().unwrap().install_const_trait_late(mc, slot_id, name, value.clone()); + let new_slot_id = self.vtable().unwrap().install_const_trait_late(mc, name, value.clone()); self.base_mut(mc).install_const_slot_late(new_slot_id, value); } diff --git a/core/src/avm2/vtable.rs b/core/src/avm2/vtable.rs index 66e780c47..140770546 100644 --- a/core/src/avm2/vtable.rs +++ b/core/src/avm2/vtable.rs @@ -288,30 +288,13 @@ impl<'gc> VTable<'gc> { pub fn install_const_trait_late( self, mc: MutationContext<'gc, '_>, - slot_id: Option, name: QName<'gc>, value: Value<'gc>, ) -> u32 { let mut write = self.0.write(mc); - let new_slot_id = if let Some(slot_id) = slot_id { - - if slot_id == 0 { - write.default_slots.push(Some(value)); - write.default_slots.len() as u32 - 1 - } else { - // Should be safe from slot conflicts, as `global` has a fresh Object vtable. - if slot_id as usize >= write.default_slots.len() { - write.default_slots.resize_with(slot_id as usize + 1, Default::default); - } - write.default_slots[slot_id as usize] = Some(value); - slot_id - } - - } else { - write.default_slots.push(Some(value)); - write.default_slots.len() as u32 - 1 - }; + write.default_slots.push(Some(value)); + let new_slot_id = write.default_slots.len() as u32 - 1; write.resolved_traits.insert(name, Property::new_slot(new_slot_id)); new_slot_id