From edf7a19eb7ac49047e2ec8fb3a94ab783292b282 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Sat, 26 Oct 2019 20:26:36 -0400 Subject: [PATCH] Implement `Function.prototype.toString`. --- core/src/avm1/globals/function.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/src/avm1/globals/function.rs b/core/src/avm1/globals/function.rs index 09ffe3f24..e25eb789c 100644 --- a/core/src/avm1/globals/function.rs +++ b/core/src/avm1/globals/function.rs @@ -15,6 +15,7 @@ pub fn constructor<'gc>( Ok(Value::Undefined.into()) } +/// Implements `Function.prototype.call` pub fn call<'gc>( _avm: &mut Avm1<'gc>, _action_context: &mut UpdateContext<'_, 'gc, '_>, @@ -24,6 +25,7 @@ pub fn call<'gc>( Ok(Value::Undefined.into()) } +/// Implements `Function.prototype.apply` pub fn apply<'gc>( _avm: &mut Avm1<'gc>, _action_context: &mut UpdateContext<'_, 'gc, '_>, @@ -33,6 +35,16 @@ pub fn apply<'gc>( Ok(Value::Undefined.into()) } +/// Implements `Function.prototype.toString` +fn to_string<'gc>( + _: &mut Avm1<'gc>, + _: &mut UpdateContext<'_, 'gc, '_>, + _: Object<'gc>, + _: &[Value<'gc>], +) -> Result, Error> { + Ok(ReturnValue::Immediate("[type Function]".into())) +} + /// Partially construct `Function.prototype`. /// /// `__proto__` and other cross-linked properties of this object will *not* @@ -51,6 +63,10 @@ pub fn create_proto<'gc>(gc_context: MutationContext<'gc, '_>, proto: Object<'gc .as_script_object() .unwrap() .force_set_function("apply", apply, gc_context, EnumSet::empty(), this); + function_proto + .as_script_object() + .unwrap() + .force_set_function("toString", to_string, gc_context, EnumSet::empty(), this); function_proto }