Free functions always have a `prototype`, this is a holdover from ES3.

This commit is contained in:
David Wendt 2020-03-06 15:26:50 -05:00
parent 0e89cb2175
commit 00186f7602
2 changed files with 18 additions and 2 deletions

View File

@ -1313,13 +1313,21 @@ impl<'gc> Avm2<'gc> {
let method_entry = self.table_method(index)?; let method_entry = self.table_method(index)?;
let scope = self.current_stack_frame().unwrap().read().scope(); let scope = self.current_stack_frame().unwrap().read().scope();
let new_fn = FunctionObject::from_abc_method( let mut new_fn = FunctionObject::from_abc_method(
context.gc_context, context.gc_context,
method_entry, method_entry,
scope, scope,
self.system_prototypes.function, self.system_prototypes.function,
None, None,
); );
let es3_proto = ScriptObject::object(context.gc_context, self.prototypes().object);
new_fn.install_slot(
context.gc_context,
QName::new(Namespace::public_namespace(), "prototype"),
0,
es3_proto.into(),
);
self.push(new_fn); self.push(new_fn);

View File

@ -508,13 +508,21 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
slot_id, function, .. slot_id, function, ..
} => { } => {
let method = Avm2MethodEntry::from_method_index(abc, function.clone()).unwrap(); let method = Avm2MethodEntry::from_method_index(abc, function.clone()).unwrap();
let function = FunctionObject::from_abc_method( let mut function = FunctionObject::from_abc_method(
context.gc_context, context.gc_context,
method, method,
scope, scope,
fn_proto, fn_proto,
None, None,
); );
let es3_proto = ScriptObject::object(context.gc_context, avm.prototypes().object);
function.install_slot(
context.gc_context,
QName::new(Namespace::public_namespace(), "prototype"),
0,
es3_proto.into(),
);
self.install_const(context.gc_context, trait_name, *slot_id, function.into()); self.install_const(context.gc_context, trait_name, *slot_id, function.into());
} }
AbcTraitKind::Const { slot_id, value, .. } => { AbcTraitKind::Const { slot_id, value, .. } => {