|
|
|
@ -15,7 +15,6 @@ use crate::{
|
|
|
|
|
builtins::{BuiltIn, JsArgs}, |
|
|
|
|
context::StandardObjects, |
|
|
|
|
environments::DeclarativeEnvironmentStack, |
|
|
|
|
gc::{self, Finalize, Gc, Trace}, |
|
|
|
|
object::{ |
|
|
|
|
internal_methods::get_prototype_from_constructor, JsObject, NativeObject, Object, |
|
|
|
|
ObjectData, |
|
|
|
@ -24,8 +23,10 @@ use crate::{
|
|
|
|
|
property::{Attribute, PropertyDescriptor, PropertyKey}, |
|
|
|
|
symbol::WellKnownSymbols, |
|
|
|
|
value::IntegerOrInfinity, |
|
|
|
|
BoaProfiler, Context, JsResult, JsString, JsValue, |
|
|
|
|
Context, JsResult, JsString, JsValue, |
|
|
|
|
}; |
|
|
|
|
use boa_gc::{self, Finalize, Gc, Trace}; |
|
|
|
|
use boa_profiler::Profiler; |
|
|
|
|
use dyn_clone::DynClone; |
|
|
|
|
use std::{ |
|
|
|
|
any::Any, |
|
|
|
@ -125,7 +126,7 @@ impl ConstructorKind {
|
|
|
|
|
/// with `Any::downcast_ref` and `Any::downcast_mut` to recover the original
|
|
|
|
|
/// type.
|
|
|
|
|
#[derive(Clone, Debug, Trace, Finalize)] |
|
|
|
|
pub struct Captures(Gc<gc::Cell<Box<dyn NativeObject>>>); |
|
|
|
|
pub struct Captures(Gc<boa_gc::Cell<Box<dyn NativeObject>>>); |
|
|
|
|
|
|
|
|
|
impl Captures { |
|
|
|
|
/// Creates a new capture context.
|
|
|
|
@ -133,7 +134,7 @@ impl Captures {
|
|
|
|
|
where |
|
|
|
|
T: NativeObject, |
|
|
|
|
{ |
|
|
|
|
Self(Gc::new(gc::Cell::new(Box::new(captures)))) |
|
|
|
|
Self(Gc::new(boa_gc::Cell::new(Box::new(captures)))) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Casts `Captures` to `Any`
|
|
|
|
@ -141,7 +142,7 @@ impl Captures {
|
|
|
|
|
/// # Panics
|
|
|
|
|
///
|
|
|
|
|
/// Panics if it's already borrowed as `&mut Any`
|
|
|
|
|
pub fn as_any(&self) -> gc::Ref<'_, dyn Any> { |
|
|
|
|
pub fn as_any(&self) -> boa_gc::Ref<'_, dyn Any> { |
|
|
|
|
Ref::map(self.0.borrow(), |data| data.deref().as_any()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -150,7 +151,7 @@ impl Captures {
|
|
|
|
|
/// # Panics
|
|
|
|
|
///
|
|
|
|
|
/// Panics if it's already borrowed as `&mut Any`
|
|
|
|
|
pub fn as_mut_any(&self) -> gc::RefMut<'_, Box<dyn NativeObject>, dyn Any> { |
|
|
|
|
pub fn as_mut_any(&self) -> boa_gc::RefMut<'_, Box<dyn NativeObject>, dyn Any> { |
|
|
|
|
RefMut::map(self.0.borrow_mut(), |data| data.deref_mut().as_mut_any()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -225,7 +226,7 @@ pub(crate) fn make_builtin_fn<N>(
|
|
|
|
|
N: Into<String>, |
|
|
|
|
{ |
|
|
|
|
let name = name.into(); |
|
|
|
|
let _timer = BoaProfiler::global().start_event(&format!("make_builtin_fn: {name}"), "init"); |
|
|
|
|
let _timer = Profiler::global().start_event(&format!("make_builtin_fn: {name}"), "init"); |
|
|
|
|
|
|
|
|
|
let function = JsObject::from_proto_and_data( |
|
|
|
|
interpreter.standard_objects().function_object().prototype(), |
|
|
|
@ -488,7 +489,7 @@ impl BuiltIn for BuiltInFunctionObject {
|
|
|
|
|
.union(Attribute::CONFIGURABLE); |
|
|
|
|
|
|
|
|
|
fn init(context: &mut Context) -> JsValue { |
|
|
|
|
let _timer = BoaProfiler::global().start_event("function", "init"); |
|
|
|
|
let _timer = Profiler::global().start_event("function", "init"); |
|
|
|
|
|
|
|
|
|
let function_prototype = context.standard_objects().function_object().prototype(); |
|
|
|
|
FunctionBuilder::native(context, Self::prototype) |