Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion nova_vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ default = [
"shared-array-buffer",
"weak-refs",
"atomics",
"regexp"
"regexp",
"set"
]
array-buffer = []
atomics = ["array-buffer", "shared-array-buffer"]
Expand All @@ -51,6 +52,7 @@ math = []
regexp = []
shared-array-buffer = []
weak-refs = []
set = []
typescript = []

[build-dependencies]
Expand Down
1 change: 1 addition & 0 deletions nova_vm/src/ecmascript/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub(crate) mod proxy;
pub(crate) mod reflection;
#[cfg(feature = "regexp")]
pub(crate) mod regexp;
#[cfg(feature = "set")]
pub(crate) mod set;
#[cfg(feature = "shared-array-buffer")]
pub(crate) mod shared_array_buffer;
Expand Down
1 change: 1 addition & 0 deletions nova_vm/src/ecmascript/builtins/keyed_collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

pub(crate) mod map_objects;
#[cfg(feature = "set")]
pub(crate) mod set_objects;
#[cfg(feature = "weak-refs")]
pub(crate) mod weak_map_objects;
Expand Down
25 changes: 13 additions & 12 deletions nova_vm/src/ecmascript/builtins/ordinary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,22 @@ use super::regexp::RegExpHeapData;
#[cfg(feature = "shared-array-buffer")]
use super::shared_array_buffer::data::SharedArrayBufferHeapData;
use super::{
control_abstraction_objects::generator_objects::GeneratorHeapData,
error::ErrorHeapData,
control_abstraction_objects::generator_objects::GeneratorHeapData, error::ErrorHeapData,
finalization_registry::data::FinalizationRegistryHeapData,
indexed_collections::array_objects::array_iterator_objects::array_iterator::ArrayIteratorHeapData,
keyed_collections::{
map_objects::map_iterator_objects::map_iterator::MapIteratorHeapData,
set_objects::set_iterator_objects::set_iterator::SetIteratorHeapData,
},
map::data::MapHeapData,
module::Module,
primitive_objects::PrimitiveObjectHeapData,
promise::data::PromiseHeapData,
set::data::SetHeapData,
ArrayHeapData,
keyed_collections::map_objects::map_iterator_objects::map_iterator::MapIteratorHeapData,
map::data::MapHeapData, module::Module, primitive_objects::PrimitiveObjectHeapData,
promise::data::PromiseHeapData, ArrayHeapData,
};
#[cfg(feature = "array-buffer")]
use super::{
data_view::data::DataViewHeapData, typed_array::data::TypedArrayHeapData, ArrayBufferHeapData,
};
#[cfg(feature = "set")]
use super::{
keyed_collections::set_objects::set_iterator_objects::set_iterator::SetIteratorHeapData,
set::data::SetHeapData,
};
#[cfg(feature = "weak-refs")]
use super::{
weak_map::data::WeakMapHeapData, weak_ref::data::WeakRefHeapData,
Expand Down Expand Up @@ -1274,7 +1271,9 @@ pub(crate) fn ordinary_object_create_with_intrinsics<'a>(
ProtoIntrinsics::Promise => agent.heap.create(PromiseHeapData::default()).into_object(),
#[cfg(feature = "regexp")]
ProtoIntrinsics::RegExp => agent.heap.create(RegExpHeapData::default()).into_object(),
#[cfg(feature = "set")]
ProtoIntrinsics::Set => agent.heap.create(SetHeapData::default()).into_object(),
#[cfg(feature = "set")]
ProtoIntrinsics::SetIterator => agent
.heap
.create(SetIteratorHeapData::default())
Expand Down Expand Up @@ -1440,7 +1439,9 @@ pub(crate) fn get_prototype_from_constructor<'a>(
ProtoIntrinsics::ReferenceError => Some(intrinsics.reference_error().into_function()),
#[cfg(feature = "regexp")]
ProtoIntrinsics::RegExp => Some(intrinsics.reg_exp().into_function()),
#[cfg(feature = "set")]
ProtoIntrinsics::Set => Some(intrinsics.set().into_function()),
#[cfg(feature = "set")]
ProtoIntrinsics::SetIterator => None,
#[cfg(feature = "shared-array-buffer")]
ProtoIntrinsics::SharedArrayBuffer => {
Expand Down
24 changes: 13 additions & 11 deletions nova_vm/src/ecmascript/execution/realm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,17 +833,19 @@ pub(crate) fn set_default_global_bindings<'a>(
}

// 19.3.27 Set ( . . . )
let name = PropertyKey::from(BUILTIN_STRING_MEMORY.Set);
let value = agent.get_realm(realm_id).intrinsics().set();
let desc = PropertyDescriptor {
value: Some(value.into_value()),
writable: Some(true),
enumerable: Some(false),
configurable: Some(true),
..Default::default()
};
define_property_or_throw(agent, global, name, desc, gc.reborrow())?;

#[cfg(feature = "set")]
{
let name = PropertyKey::from(BUILTIN_STRING_MEMORY.Set);
let value = agent.get_realm(realm_id).intrinsics().set();
let desc = PropertyDescriptor {
value: Some(value.into_value()),
writable: Some(true),
enumerable: Some(false),
configurable: Some(true),
..Default::default()
};
define_property_or_throw(agent, global, name, desc, gc.reborrow())?;
}
// 19.3.28 SharedArrayBuffer ( . . . )
#[cfg(feature = "shared-array-buffer")]
{
Expand Down
28 changes: 17 additions & 11 deletions nova_vm/src/ecmascript/execution/realm/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use super::RealmIdentifier;
#[cfg(feature = "set")]
use crate::ecmascript::builtins::keyed_collections::set_objects::{
set_constructor::SetConstructor,
set_iterator_objects::set_iterator_prototype::SetIteratorPrototype,
set_prototype::SetPrototype,
};
#[cfg(feature = "weak-refs")]
use crate::ecmascript::builtins::keyed_collections::{
weak_map_objects::{
Expand Down Expand Up @@ -85,17 +91,10 @@ use crate::{
array_iterator_objects::array_iterator_prototype::ArrayIteratorPrototype,
array_prototype::ArrayPrototype,
},
keyed_collections::{
map_objects::{
map_constructor::MapConstructor,
map_iterator_objects::map_iterator_prototype::MapIteratorPrototype,
map_prototype::MapPrototype,
},
set_objects::{
set_constructor::SetConstructor,
set_iterator_objects::set_iterator_prototype::SetIteratorPrototype,
set_prototype::SetPrototype,
},
keyed_collections::map_objects::{
map_constructor::MapConstructor,
map_iterator_objects::map_iterator_prototype::MapIteratorPrototype,
map_prototype::MapPrototype,
},
managing_memory::finalization_registry_objects::{
finalization_registry_constructor::FinalizationRegistryConstructor,
Expand Down Expand Up @@ -206,7 +205,9 @@ pub enum ProtoIntrinsics {
ReferenceError,
#[cfg(feature = "regexp")]
RegExp,
#[cfg(feature = "set")]
Set,
#[cfg(feature = "set")]
SetIterator,
#[cfg(feature = "shared-array-buffer")]
SharedArrayBuffer,
Expand Down Expand Up @@ -312,8 +313,11 @@ impl Intrinsics {
MapPrototype::create_intrinsic(agent, realm);
MapConstructor::create_intrinsic(agent, realm);
MapIteratorPrototype::create_intrinsic(agent, realm);
#[cfg(feature = "set")]
SetPrototype::create_intrinsic(agent, realm);
#[cfg(feature = "set")]
SetConstructor::create_intrinsic(agent, realm);
#[cfg(feature = "set")]
SetIteratorPrototype::create_intrinsic(agent, realm);
#[cfg(feature = "weak-refs")]
WeakMapPrototype::create_intrinsic(agent, realm);
Expand Down Expand Up @@ -419,7 +423,9 @@ impl Intrinsics {
ProtoIntrinsics::Promise => self.promise_prototype().into(),
#[cfg(feature = "regexp")]
ProtoIntrinsics::RegExp => self.reg_exp_prototype().into(),
#[cfg(feature = "set")]
ProtoIntrinsics::Set => self.set_prototype().into(),
#[cfg(feature = "set")]
ProtoIntrinsics::SetIterator => self.set_iterator_prototype().into(),
#[cfg(feature = "shared-array-buffer")]
ProtoIntrinsics::SharedArrayBuffer => self.shared_array_buffer_prototype().into(),
Expand Down
6 changes: 4 additions & 2 deletions nova_vm/src/ecmascript/types/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ pub(crate) use value::{
FINALIZATION_REGISTRY_DISCRIMINANT, FLOAT_DISCRIMINANT, GENERATOR_DISCRIMINANT,
INTEGER_DISCRIMINANT, ITERATOR_DISCRIMINANT, MAP_DISCRIMINANT, MAP_ITERATOR_DISCRIMINANT,
MODULE_DISCRIMINANT, NUMBER_DISCRIMINANT, OBJECT_DISCRIMINANT, PROMISE_DISCRIMINANT,
PROXY_DISCRIMINANT, SET_DISCRIMINANT, SET_ITERATOR_DISCRIMINANT, SMALL_BIGINT_DISCRIMINANT,
SMALL_STRING_DISCRIMINANT, STRING_DISCRIMINANT, SYMBOL_DISCRIMINANT,
PROXY_DISCRIMINANT, SMALL_BIGINT_DISCRIMINANT, SMALL_STRING_DISCRIMINANT, STRING_DISCRIMINANT,
SYMBOL_DISCRIMINANT,
};
#[cfg(feature = "array-buffer")]
pub(crate) use value::{
Expand All @@ -67,5 +67,7 @@ pub(crate) use value::{
UINT_16_ARRAY_DISCRIMINANT, UINT_32_ARRAY_DISCRIMINANT, UINT_8_ARRAY_DISCRIMINANT,
UINT_8_CLAMPED_ARRAY_DISCRIMINANT,
};
#[cfg(feature = "set")]
pub(crate) use value::{SET_DISCRIMINANT, SET_ITERATOR_DISCRIMINANT};
#[cfg(feature = "weak-refs")]
pub(crate) use value::{WEAK_MAP_DISCRIMINANT, WEAK_REF_DISCRIMINANT, WEAK_SET_DISCRIMINANT};
Loading
Loading