Skip to content

Commit

Permalink
Update feature flags to specific feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
nekevss committed Oct 12, 2023
1 parent d281988 commit ead41a2
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 115 deletions.
2 changes: 1 addition & 1 deletion boa_ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rust-version.workspace = true
[features]
serde = ["dep:serde", "boa_interner/serde", "bitflags/serde", "num-bigint/serde"]
arbitrary = ["dep:arbitrary", "boa_interner/arbitrary", "num-bigint/arbitrary"]
experimental = []
temporal = []

[dependencies]
boa_interner.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion boa_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub mod operations;
pub mod pattern;
pub mod property;
pub mod statement;
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
pub mod temporal;
pub mod visitor;

Expand Down
6 changes: 5 additions & 1 deletion boa_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ trace = []
# Enable Boa's additional ECMAScript features for web browsers.
annex-b = ["boa_parser/annex-b"]

# Stage 3 proposals
temporal = ["boa_parser/temporal", "dep:icu_calendar"]
promise-resolvers = []

# Enable experimental features, like Stage 3 proposals.
experimental = ["boa_parser/experimental", "dep:icu_calendar"]
experimental = ["temporal", "promise-resolvers"]

[dependencies]
boa_interner.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl JsBigInt {

/// Utility function for performing `+` operation on more than two values.
#[inline]
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
pub(crate) fn add_n(values: &[Self]) -> Self {
let mut result = Self::zero();
for big_int in values {
Expand Down
8 changes: 4 additions & 4 deletions boa_engine/src/builtins/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ pub mod escape;
pub mod intl;

// TODO: remove `cfg` when `Temporal` gets to stage 4.
#[cfg(any(feature = "intl", feature = "experimental"))]
#[cfg(any(feature = "intl", feature = "temporal"))]
pub(crate) mod options;

#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
pub mod temporal;

pub(crate) use self::{
Expand Down Expand Up @@ -279,7 +279,7 @@ impl Realm {
intl::PluralRules::init(self);
}

#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
{
temporal::TimeZone::init(self);
temporal::Temporal::init(self);
Expand Down Expand Up @@ -393,7 +393,7 @@ pub(crate) fn set_default_global_bindings(context: &mut Context<'_>) -> JsResult
#[cfg(feature = "intl")]
global_binding::<intl::Intl>(context)?;

#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
{
global_binding::<temporal::Temporal>(context)?;
}
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/builtins/promise/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl IntrinsicObject for Promise {
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
);

#[cfg(feature = "experimental")]
#[cfg(feature = "promise-resolvers")]
let builder =
builder.static_method(Self::with_resolvers, crate::js_string!("withResolvers"), 0);

Expand Down Expand Up @@ -471,7 +471,7 @@ impl Promise {
/// functions associated with it.
///
/// [spec]: https://tc39.es/proposal-promise-with-resolvers/#sec-promise.withResolvers
#[cfg(feature = "experimental")]
#[cfg(feature = "promise-resolvers")]
pub(crate) fn with_resolvers(
this: &JsValue,
_args: &[JsValue],
Expand Down
1 change: 0 additions & 1 deletion boa_engine/src/builtins/temporal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ mod plain_year_month;
mod time_zone;
mod zoned_date_time;

#[cfg(feature = "experimental")]
#[cfg(test)]
mod tests;

Expand Down
80 changes: 40 additions & 40 deletions boa_engine/src/context/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,25 +166,25 @@ pub struct StandardConstructors {
segmenter: StandardConstructor,
#[cfg(feature = "intl")]
plural_rules: StandardConstructor,
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
instant: StandardConstructor,
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
plain_date_time: StandardConstructor,
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
plain_date: StandardConstructor,
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
plain_time: StandardConstructor,
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
plain_year_month: StandardConstructor,
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
plain_month_day: StandardConstructor,
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
time_zone: StandardConstructor,
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
duration: StandardConstructor,
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
zoned_date_time: StandardConstructor,
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
calendar: StandardConstructor,
}

Expand Down Expand Up @@ -262,25 +262,25 @@ impl Default for StandardConstructors {
segmenter: StandardConstructor::default(),
#[cfg(feature = "intl")]
plural_rules: StandardConstructor::default(),
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
instant: StandardConstructor::default(),
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
plain_date_time: StandardConstructor::default(),
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
plain_date: StandardConstructor::default(),
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
plain_time: StandardConstructor::default(),
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
plain_year_month: StandardConstructor::default(),
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
plain_month_day: StandardConstructor::default(),
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
time_zone: StandardConstructor::default(),
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
duration: StandardConstructor::default(),
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
zoned_date_time: StandardConstructor::default(),
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
calendar: StandardConstructor::default(),
}
}
Expand Down Expand Up @@ -876,7 +876,7 @@ impl StandardConstructors {
/// [spec]: https://tc39.es/proposal-temporal/#sec-temporal-instant-constructor
#[inline]
#[must_use]
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
pub const fn instant(&self) -> &StandardConstructor {
&self.instant
}
Expand All @@ -889,7 +889,7 @@ impl StandardConstructors {
/// [spec]: https://tc39.es/proposal-temporal/#sec-temporal-plaindatetime-constructor
#[inline]
#[must_use]
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
pub const fn plain_date_time(&self) -> &StandardConstructor {
&self.plain_date_time
}
Expand All @@ -902,7 +902,7 @@ impl StandardConstructors {
/// [spec]: https://tc39.es/proposal-temporal/#sec-temporal-plaindate-constructor
#[inline]
#[must_use]
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
pub const fn plain_date(&self) -> &StandardConstructor {
&self.plain_date
}
Expand All @@ -915,7 +915,7 @@ impl StandardConstructors {
/// [spec]: https://tc39.es/proposal-temporal/#sec-temporal-plaintime-constructor
#[inline]
#[must_use]
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
pub const fn plain_time(&self) -> &StandardConstructor {
&self.plain_time
}
Expand All @@ -928,7 +928,7 @@ impl StandardConstructors {
/// [spec]: https://tc39.es/proposal-temporal/#sec-temporal-plainyearmonth-constructor
#[inline]
#[must_use]
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
pub const fn plain_year_month(&self) -> &StandardConstructor {
&self.plain_year_month
}
Expand All @@ -941,7 +941,7 @@ impl StandardConstructors {
/// [spec]: https://tc39.es/proposal-temporal/#sec-temporal-plainmonthday-constructor
#[inline]
#[must_use]
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
pub const fn plain_month_day(&self) -> &StandardConstructor {
&self.plain_month_day
}
Expand All @@ -954,7 +954,7 @@ impl StandardConstructors {
/// [spec]: https://tc39.es/proposal-temporal/#sec-temporal-timezone-constructor
#[inline]
#[must_use]
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
pub const fn time_zone(&self) -> &StandardConstructor {
&self.time_zone
}
Expand All @@ -967,7 +967,7 @@ impl StandardConstructors {
/// [spec]: https://tc39.es/proposal-temporal/#sec-temporal-duration-constructor
#[inline]
#[must_use]
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
pub const fn duration(&self) -> &StandardConstructor {
&self.duration
}
Expand All @@ -980,7 +980,7 @@ impl StandardConstructors {
/// [spec]: https://tc39.es/proposal-temporal/#sec-temporal-zoneddatetime-constructor
#[inline]
#[must_use]
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
pub const fn zoned_date_time(&self) -> &StandardConstructor {
&self.zoned_date_time
}
Expand All @@ -993,7 +993,7 @@ impl StandardConstructors {
/// [spec]: https://tc39.es/proposal-temporal/#sec-temporal-calendar-constructor
#[inline]
#[must_use]
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
pub const fn calendar(&self) -> &StandardConstructor {
&self.calendar
}
Expand Down Expand Up @@ -1064,11 +1064,11 @@ pub struct IntrinsicObjects {
segments_prototype: JsObject,

/// [`%Temporal%`](https://tc39.es/proposal-temporal/#sec-temporal-objects)
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
temporal: JsObject,

/// [`%Temporal.Now%`](https://tc39.es/proposal-temporal/#sec-temporal-now-object)
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
now: JsObject,
}

Expand Down Expand Up @@ -1098,9 +1098,9 @@ impl Default for IntrinsicObjects {
intl: JsObject::default(),
#[cfg(feature = "intl")]
segments_prototype: JsObject::default(),
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
temporal: JsObject::default(),
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
now: JsObject::default(),
}
}
Expand Down Expand Up @@ -1280,7 +1280,7 @@ impl IntrinsicObjects {
/// Gets the [`%Temporal%`][spec] intrinsic object.
///
/// [spec]: https://tc39.es/proposal-temporal/#sec-temporal-objects
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
#[must_use]
#[inline]
pub fn temporal(&self) -> JsObject {
Expand All @@ -1290,7 +1290,7 @@ impl IntrinsicObjects {
/// Gets the [`%Temporal.Now%`][spec] intrinsic object.
///
/// [spec]: https://tc39.es/proposal-temporal/#sec-temporal-now-object
#[cfg(feature = "experimental")]
#[cfg(feature = "temporal")]
#[must_use]
#[inline]
pub fn now(&self) -> JsObject {
Expand Down Expand Up @@ -1324,7 +1324,7 @@ pub(crate) struct ObjectTemplates {

namespace: ObjectTemplate,

#[cfg(feature = "experimental")]
#[cfg(feature = "promise-resolvers")]
with_resolvers: ObjectTemplate,
}

Expand Down Expand Up @@ -1436,7 +1436,7 @@ impl ObjectTemplates {
let mut namespace = ObjectTemplate::new(root_shape);
namespace.property(JsSymbol::to_string_tag().into(), Attribute::empty());

#[cfg(feature = "experimental")]
#[cfg(feature = "promise-resolvers")]
let with_resolvers = {
let mut with_resolvers = ordinary_object.clone();

Expand Down Expand Up @@ -1469,7 +1469,7 @@ impl ObjectTemplates {
function_without_proto,
function_with_prototype_without_proto,
namespace,
#[cfg(feature = "experimental")]
#[cfg(feature = "promise-resolvers")]
with_resolvers,
}
}
Expand Down Expand Up @@ -1655,7 +1655,7 @@ impl ObjectTemplates {
/// 1. `"promise"`: (`WRITABLE`, `ENUMERABLE`, `CONFIGURABLE`)
/// 2. `"resolve"`: (`WRITABLE`, `ENUMERABLE`, `CONFIGURABLE`)
/// 3. `"reject"`: (`WRITABLE`, `ENUMERABLE`, `CONFIGURABLE`)
#[cfg(feature = "experimental")]
#[cfg(feature = "promise-resolvers")]
pub(crate) const fn with_resolvers(&self) -> &ObjectTemplate {
&self.with_resolvers
}
Expand Down
Loading

0 comments on commit ead41a2

Please sign in to comment.