Implement `Function.prototype.toString`.

This commit is contained in:
David Wendt 2019-10-26 20:26:36 -04:00 committed by Mike Welsh
parent 33c66571f5
commit edf7a19eb7
1 changed files with 16 additions and 0 deletions

View File

@ -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<ReturnValue<'gc>, 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
}