diff --git a/core/src/avm1/globals.rs b/core/src/avm1/globals.rs index be67efaac..de8827042 100644 --- a/core/src/avm1/globals.rs +++ b/core/src/avm1/globals.rs @@ -534,7 +534,7 @@ pub fn create_globals<'gc>( Object<'gc>, as_broadcaster::BroadcasterFunctions<'gc>, ) { - let object_proto = ScriptObject::object_cell(gc_context, None); + let object_proto = ScriptObject::new(gc_context, None).into(); let function_proto = function::create_proto(gc_context, object_proto); object::fill_proto(gc_context, object_proto, function_proto); diff --git a/core/src/avm1/globals/function.rs b/core/src/avm1/globals/function.rs index 9cf01f3d7..b93fab8b3 100644 --- a/core/src/avm1/globals/function.rs +++ b/core/src/avm1/globals/function.rs @@ -117,8 +117,12 @@ pub fn apply<'gc>( /// returned object is also a bare object, which will need to be linked into /// the prototype of `Object`. pub fn create_proto<'gc>(gc_context: MutationContext<'gc, '_>, proto: Object<'gc>) -> Object<'gc> { - let function_proto = ScriptObject::object_cell(gc_context, Some(proto)); - let object = function_proto.as_script_object().unwrap(); - define_properties_on(PROTO_DECLS, gc_context, object, function_proto); - function_proto + let function_proto = ScriptObject::new(gc_context, Some(proto)); + define_properties_on( + PROTO_DECLS, + gc_context, + function_proto, + function_proto.into(), + ); + function_proto.into() } diff --git a/core/src/avm1/object/script_object.rs b/core/src/avm1/object/script_object.rs index 2d4ce26d1..e024c4290 100644 --- a/core/src/avm1/object/script_object.rs +++ b/core/src/avm1/object/script_object.rs @@ -87,14 +87,6 @@ impl<'gc> ScriptObject<'gc> { object } - /// Constructs and allocates an empty but normal object in one go. - pub fn object_cell( - gc_context: MutationContext<'gc, '_>, - proto: Option>, - ) -> Object<'gc> { - Self::new(gc_context, proto).into() - } - /// Constructs an object with no properties, not even builtins. /// /// Intended for constructing scope chains, since they exclusively use the diff --git a/core/src/avm1/scope.rs b/core/src/avm1/scope.rs index fda650841..04f4a697d 100644 --- a/core/src/avm1/scope.rs +++ b/core/src/avm1/scope.rs @@ -52,7 +52,7 @@ impl<'gc> Scope<'gc> { Scope { parent: Some(parent), class: ScopeClass::Local, - values: ScriptObject::object_cell(mc, None), + values: ScriptObject::new(mc, None).into(), } } @@ -104,7 +104,7 @@ impl<'gc> Scope<'gc> { Self { parent: None, class: ScopeClass::Global, - values: ScriptObject::object_cell(mc, None), + values: ScriptObject::new(mc, None).into(), }, ) }) diff --git a/core/src/avm1/value.rs b/core/src/avm1/value.rs index 2dfdd1c83..b73cec2e7 100644 --- a/core/src/avm1/value.rs +++ b/core/src/avm1/value.rs @@ -889,7 +889,7 @@ mod test { protos.function, ); - let o = ScriptObject::object_cell(activation.context.gc_context, Some(protos.object)); + let o = ScriptObject::new(activation.context.gc_context, Some(protos.object)); o.define_value( activation.context.gc_context, "valueOf", @@ -898,7 +898,7 @@ mod test { ); assert_eq!( - Value::Object(o).to_primitive_num(activation).unwrap(), + Value::from(o).to_primitive_num(activation).unwrap(), 5.into() );