avm2: Remove `Class::class_init`

This commit is contained in:
Lord-McSweeney 2024-06-20 11:34:39 -07:00 committed by Lord-McSweeney
parent 13ee356b8c
commit e222a1646c
2 changed files with 13 additions and 17 deletions

View File

@ -334,11 +334,15 @@ impl<'gc> Class<'gc> {
// This can only happen for non-builtin Vector types,
// so let's create one here directly.
let object_vector_cls = this_read
let object_vector_i_class = this_read
.applications
.get(&None)
.expect("Vector.<*> not initialized?");
let object_vector_c_class = object_vector_i_class
.c_class()
.expect("T$ cannot be generic");
let param = param.expect("Trying to create Vector<*>, which shouldn't happen here");
let name = format!("Vector.<{}>", param.name().to_qualified_name(mc));
@ -353,14 +357,14 @@ impl<'gc> Class<'gc> {
.object_vector
.inner_class_definition(),
),
object_vector_cls.instance_init(),
object_vector_cls.class_init(),
object_vector_i_class.instance_init(),
object_vector_c_class.instance_init(),
context.avm2.classes().class.inner_class_definition(),
mc,
);
new_class.set_param(mc, Some(Some(param)));
new_class.0.write(mc).call_handler = object_vector_cls.call_handler();
new_class.0.write(mc).call_handler = object_vector_i_class.call_handler();
new_class.mark_traits_loaded(context.gc_context);
new_class
@ -1302,17 +1306,6 @@ impl<'gc> Class<'gc> {
self.0.write(mc).native_instance_init = new_native_init;
}
/// Get this class's class initializer.
pub fn class_init(self) -> Method<'gc> {
self.0
.read()
.c_class
.expect("Accessed class_init on a c_class")
.0
.read()
.instance_init
}
/// Set a call handler for this class.
pub fn set_call_handler(self, mc: &Mutation<'gc>, new_call_handler: Method<'gc>) {
self.0.write(mc).call_handler = Some(new_call_handler);

View File

@ -335,9 +335,12 @@ impl<'gc> ClassObject<'gc> {
let object: Object<'gc> = self.into();
let scope = self.0.read().class_scope;
let class = self.0.read().class;
let c_class = self
.inner_class_definition()
.c_class()
.expect("ClassObject stores an i_class");
let class_initializer = class.class_init();
let class_initializer = c_class.instance_init();
let class_init_fn = FunctionObject::from_method(
activation,
class_initializer,