Browse Source

Async Function

optimization/static-shapes
Haled Odat 1 year ago
parent
commit
ea8c3ff2d6
  1. 15
      boa_builtins/build.rs
  2. 24
      boa_engine/src/builtins/async_function/mod.rs
  3. 31
      boa_engine/src/builtins/async_generator_function/mod.rs

15
boa_builtins/build.rs

@ -1071,9 +1071,22 @@ fn main() -> io::Result<()> {
.method(utf16!("return"))
.method(utf16!("throw"))
.property(WellKnown::ToStringTag, Attribute::CONFIGURABLE)
.property(utf16!("CONSTRUCTOR"), Attribute::CONFIGURABLE)
.property(utf16!("constructor"), Attribute::CONFIGURABLE)
.build(file)?;
BuiltInBuilderConstructor::new(&context, "ASYNC_FUNCTION")
.property(WellKnown::ToStringTag, Attribute::CONFIGURABLE)
.build(file)?;
BuiltInBuilderConstructor::with_constructor_attributes(
&context,
"ASYNC_GENERATOR_FUNCTION",
Attribute::CONFIGURABLE,
)
.property(utf16!("prototype"), Attribute::CONFIGURABLE)
.property(WellKnown::ToStringTag, Attribute::CONFIGURABLE)
.build(file)?;
#[cfg(feature = "intl")]
{
BuiltInBuilder::new(&context, "INTL_OBJECT")

24
boa_engine/src/builtins/async_function/mod.rs

@ -10,9 +10,7 @@
use crate::{
builtins::{function::BuiltInFunctionObject, BuiltInObject},
context::intrinsics::{Intrinsics, StandardConstructor, StandardConstructors},
property::Attribute,
realm::Realm,
symbol::JsSymbol,
Context, JsResult, JsValue,
};
use boa_profiler::Profiler;
@ -27,17 +25,17 @@ impl IntrinsicObject for AsyncFunction {
fn init(realm: &Realm) {
let _timer = Profiler::global().start_event(Self::NAME, "init");
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.prototype(realm.intrinsics().constructors().function().constructor())
.inherits(Some(
realm.intrinsics().constructors().function().prototype(),
))
.property(
JsSymbol::to_string_tag(),
Self::NAME,
Attribute::CONFIGURABLE,
)
.build();
BuiltInBuilder::from_standard_constructor_static_shape::<Self>(
realm,
&boa_builtins::ASYNC_FUNCTION_CONSTRUCTOR_STATIC_SHAPE,
&boa_builtins::ASYNC_FUNCTION_PROTOTYPE_STATIC_SHAPE,
)
.prototype(realm.intrinsics().constructors().function().constructor())
.inherits(Some(
realm.intrinsics().constructors().function().prototype(),
))
.property(Self::NAME)
.build();
}
fn get(intrinsics: &Intrinsics) -> crate::object::JsObject {

31
boa_engine/src/builtins/async_generator_function/mod.rs

@ -8,10 +8,8 @@
use crate::{
builtins::{function::BuiltInFunctionObject, BuiltInObject},
context::intrinsics::{Intrinsics, StandardConstructor, StandardConstructors},
object::{JsObject, PROTOTYPE},
property::Attribute,
object::JsObject,
realm::Realm,
symbol::JsSymbol,
value::JsValue,
Context, JsResult,
};
@ -27,22 +25,17 @@ impl IntrinsicObject for AsyncGeneratorFunction {
fn init(realm: &Realm) {
let _timer = Profiler::global().start_event(Self::NAME, "init");
BuiltInBuilder::from_standard_constructor::<Self>(realm)
.inherits(Some(
realm.intrinsics().constructors().function().prototype(),
))
.constructor_attributes(Attribute::CONFIGURABLE)
.property(
PROTOTYPE,
realm.intrinsics().objects().async_generator(),
Attribute::CONFIGURABLE,
)
.property(
JsSymbol::to_string_tag(),
Self::NAME,
Attribute::CONFIGURABLE,
)
.build();
BuiltInBuilder::from_standard_constructor_static_shape::<Self>(
realm,
&boa_builtins::ASYNC_GENERATOR_FUNCTION_CONSTRUCTOR_STATIC_SHAPE,
&boa_builtins::ASYNC_GENERATOR_FUNCTION_PROTOTYPE_STATIC_SHAPE,
)
.inherits(Some(
realm.intrinsics().constructors().function().prototype(),
))
.property(realm.intrinsics().objects().async_generator())
.property(Self::NAME)
.build();
}
fn get(intrinsics: &Intrinsics) -> JsObject {

Loading…
Cancel
Save