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
6 changes: 3 additions & 3 deletions nova_vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ oxc_syntax = { workspace = true }
rand = { workspace = true }
ryu-js = { workspace = true }
small_string = { path = "../small_string" }
sonic-rs = { workspace = true, optional = true}
sonic-rs = { workspace = true, optional = true }
wtf8 = { workspace = true }

[features]
default = ["math", "json", "date"]
default = ["math", "json", "date", "array-buffer"]
math = []
json = ["sonic-rs"]
date = []

array-buffer = []
typescript = []

[build-dependencies]
Expand Down
5 changes: 5 additions & 0 deletions nova_vm/src/ecmascript/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

pub(crate) mod arguments;
mod array;
#[cfg(feature = "array-buffer")]
mod array_buffer;
pub mod bound_function;
mod builtin_constructor;
mod builtin_function;
pub(crate) mod control_abstraction_objects;
#[cfg(feature = "array-buffer")]
pub(crate) mod data_view;
#[cfg(feature = "date")]
pub mod date;
Expand All @@ -40,6 +42,7 @@ pub(crate) mod set;
pub(crate) mod shared_array_buffer;
pub(crate) mod structured_data;
pub(crate) mod text_processing;
#[cfg(feature = "array-buffer")]
pub(crate) mod typed_array;
pub(crate) mod weak_map;
pub(crate) mod weak_ref;
Expand All @@ -49,7 +52,9 @@ pub(crate) use arguments::*;
pub(crate) use array::abstract_operations::*;
pub use array::Array;
pub(crate) use array::{ArrayHeapData, SealableElementsVector};
#[cfg(feature = "array-buffer")]
pub use array_buffer::ArrayBuffer;
#[cfg(feature = "array-buffer")]
pub(crate) use array_buffer::ArrayBufferHeapData;
pub use builtin_constructor::BuiltinConstructorFunction;
pub(crate) use builtin_constructor::{create_builtin_constructor, BuiltinConstructorArgs};
Expand Down
1 change: 1 addition & 0 deletions nova_vm/src/ecmascript/builtins/indexed_collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

pub(crate) mod array_objects;
#[cfg(feature = "array-buffer")]
pub(crate) mod typed_array_objects;
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl ArrayIteratorPrototype {
let len: i64 = match array {
// i. If array has a [[TypedArrayName]] internal slot, then
// TODO!
#[cfg(feature = "array-buffer")]
Object::Int8Array(_)
| Object::Uint8Array(_)
| Object::Uint8ClampedArray(_)
Expand Down
32 changes: 29 additions & 3 deletions nova_vm/src/ecmascript/builtins/ordinary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use crate::{
use super::date::data::DateHeapData;
use super::{
control_abstraction_objects::generator_objects::GeneratorHeapData,
data_view::data::DataViewHeapData,
error::ErrorHeapData,
finalization_registry::data::FinalizationRegistryHeapData,
indexed_collections::array_objects::array_iterator_objects::array_iterator::ArrayIteratorHeapData,
Expand All @@ -42,11 +41,14 @@ use super::{
regexp::RegExpHeapData,
set::data::SetHeapData,
shared_array_buffer::data::SharedArrayBufferHeapData,
typed_array::data::TypedArrayHeapData,
weak_map::data::WeakMapHeapData,
weak_ref::data::WeakRefHeapData,
weak_set::data::WeakSetHeapData,
ArrayBufferHeapData, ArrayHeapData,
ArrayHeapData,
};
#[cfg(feature = "array-buffer")]
use super::{
data_view::data::DataViewHeapData, typed_array::data::TypedArrayHeapData, ArrayBufferHeapData,
};

impl Index<OrdinaryObject> for Agent {
Expand Down Expand Up @@ -801,6 +803,7 @@ pub(crate) fn ordinary_object_create_with_intrinsics(

let object = match proto_intrinsics {
ProtoIntrinsics::Array => agent.heap.create(ArrayHeapData::default()).into_object(),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::ArrayBuffer => agent
.heap
.create(ArrayBufferHeapData::default())
Expand Down Expand Up @@ -889,23 +892,28 @@ pub(crate) fn ordinary_object_create_with_intrinsics(
.into_object(),
ProtoIntrinsics::AsyncFunction => todo!(),
ProtoIntrinsics::AsyncGeneratorFunction => todo!(),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::BigInt64Array => agent
.heap
.create(TypedArrayHeapData::default())
.into_object(),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::BigUint64Array => agent
.heap
.create(TypedArrayHeapData::default())
.into_object(),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::DataView => agent.heap.create(DataViewHeapData::default()).into_object(),
ProtoIntrinsics::FinalizationRegistry => agent
.heap
.create(FinalizationRegistryHeapData::default())
.into_object(),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Float32Array => agent
.heap
.create(TypedArrayHeapData::default())
.into_object(),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Float64Array => agent
.heap
.create(TypedArrayHeapData::default())
Expand All @@ -915,14 +923,17 @@ pub(crate) fn ordinary_object_create_with_intrinsics(
.create(GeneratorHeapData::default())
.into_object(),
ProtoIntrinsics::GeneratorFunction => todo!(),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Int16Array => agent
.heap
.create(TypedArrayHeapData::default())
.into_object(),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Int32Array => agent
.heap
.create(TypedArrayHeapData::default())
.into_object(),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Int8Array => agent
.heap
.create(TypedArrayHeapData::default())
Expand All @@ -943,14 +954,17 @@ pub(crate) fn ordinary_object_create_with_intrinsics(
.heap
.create(SharedArrayBufferHeapData::default())
.into_object(),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Uint16Array => agent
.heap
.create(TypedArrayHeapData::default())
.into_object(),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Uint32Array => agent
.heap
.create(TypedArrayHeapData::default())
.into_object(),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Uint8Array => agent
.heap
.create(TypedArrayHeapData::default())
Expand Down Expand Up @@ -1033,15 +1047,19 @@ pub(crate) fn get_prototype_from_constructor(
ProtoIntrinsics::AggregateError => Some(intrinsics.aggregate_error().into_function()),
ProtoIntrinsics::Array => Some(intrinsics.array().into_function()),
ProtoIntrinsics::ArrayIterator => None,
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::ArrayBuffer => Some(intrinsics.array_buffer().into_function()),
ProtoIntrinsics::AsyncFunction => Some(intrinsics.async_function().into_function()),
ProtoIntrinsics::AsyncGeneratorFunction => {
Some(intrinsics.async_generator_function().into_function())
}
ProtoIntrinsics::BigInt => Some(intrinsics.big_int().into_function()),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::BigInt64Array => Some(intrinsics.big_int64_array().into_function()),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::BigUint64Array => Some(intrinsics.big_uint64_array().into_function()),
ProtoIntrinsics::Boolean => Some(intrinsics.boolean().into_function()),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::DataView => Some(intrinsics.data_view().into_function()),
#[cfg(feature = "date")]
ProtoIntrinsics::Date => Some(intrinsics.date().into_function()),
Expand All @@ -1050,15 +1068,20 @@ pub(crate) fn get_prototype_from_constructor(
ProtoIntrinsics::FinalizationRegistry => {
Some(intrinsics.finalization_registry().into_function())
}
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Float32Array => Some(intrinsics.float32_array().into_function()),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Float64Array => Some(intrinsics.float64_array().into_function()),
ProtoIntrinsics::Function => Some(intrinsics.function().into_function()),
ProtoIntrinsics::Generator => None,
ProtoIntrinsics::GeneratorFunction => {
Some(intrinsics.generator_function().into_function())
}
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Int16Array => Some(intrinsics.int16_array().into_function()),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Int32Array => Some(intrinsics.int32_array().into_function()),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Int8Array => Some(intrinsics.int8_array().into_function()),
ProtoIntrinsics::Map => Some(intrinsics.map().into_function()),
ProtoIntrinsics::MapIterator => None,
Expand All @@ -1077,8 +1100,11 @@ pub(crate) fn get_prototype_from_constructor(
ProtoIntrinsics::Symbol => Some(intrinsics.symbol().into_function()),
ProtoIntrinsics::SyntaxError => Some(intrinsics.syntax_error().into_function()),
ProtoIntrinsics::TypeError => Some(intrinsics.type_error().into_function()),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Uint16Array => Some(intrinsics.uint16_array().into_function()),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Uint32Array => Some(intrinsics.uint32_array().into_function()),
#[cfg(feature = "array-buffer")]
ProtoIntrinsics::Uint8Array => Some(intrinsics.uint8_array().into_function()),
ProtoIntrinsics::UriError => Some(intrinsics.uri_error().into_function()),
ProtoIntrinsics::WeakMap => Some(intrinsics.weak_map().into_function()),
Expand Down
2 changes: 2 additions & 0 deletions nova_vm/src/ecmascript/builtins/structured_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

#[cfg(feature = "array-buffer")]
pub(crate) mod array_buffer_objects;
pub(crate) mod atomics_object;
#[cfg(feature = "array-buffer")]
pub(crate) mod data_view_objects;
#[cfg(feature = "json")]
pub(crate) mod json_object;
Expand Down
Loading