|
|
|
@ -55,6 +55,7 @@ impl GcObject {
|
|
|
|
|
///# Panics
|
|
|
|
|
/// Panics if the object is currently mutably borrowed.
|
|
|
|
|
#[inline] |
|
|
|
|
#[track_caller] |
|
|
|
|
pub fn borrow(&self) -> Ref<'_> { |
|
|
|
|
self.try_borrow().expect("Object already mutably borrowed") |
|
|
|
|
} |
|
|
|
@ -67,6 +68,7 @@ impl GcObject {
|
|
|
|
|
///# Panics
|
|
|
|
|
/// Panics if the object is currently borrowed.
|
|
|
|
|
#[inline] |
|
|
|
|
#[track_caller] |
|
|
|
|
pub fn borrow_mut(&self) -> RefMut<'_> { |
|
|
|
|
self.try_borrow_mut().expect("Object already borrowed") |
|
|
|
|
} |
|
|
|
@ -105,6 +107,7 @@ impl GcObject {
|
|
|
|
|
/// Panics if the object is currently mutably borrowed.
|
|
|
|
|
// <https://tc39.es/ecma262/#sec-prepareforordinarycall>
|
|
|
|
|
// <https://tc39.es/ecma262/#sec-ecmascript-function-objects-call-thisargument-argumentslist>
|
|
|
|
|
#[track_caller] |
|
|
|
|
pub fn call(&self, this: &Value, args: &[Value], ctx: &mut Interpreter) -> Result<Value> { |
|
|
|
|
let this_function_object = self.clone(); |
|
|
|
|
let f_body = if let Some(function) = self.borrow().as_function() { |
|
|
|
@ -186,6 +189,7 @@ impl GcObject {
|
|
|
|
|
///# Panics
|
|
|
|
|
/// Panics if the object is currently mutably borrowed.
|
|
|
|
|
// <https://tc39.es/ecma262/#sec-ecmascript-function-objects-construct-argumentslist-newtarget>
|
|
|
|
|
#[track_caller] |
|
|
|
|
pub fn construct(&self, args: &[Value], ctx: &mut Interpreter) -> Result<Value> { |
|
|
|
|
let this = Object::create(self.borrow().get(&PROTOTYPE.into())).into(); |
|
|
|
|
|
|
|
|
|