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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = ["nova_cli", "nova_vm", "small_string", "tests"]
exclude = ["nova_lint"]

[workspace.package]
edition = "2021"
edition = "2024"
version = "0.1.0"
license = "MPL-2.0"
homepage = "https://trynova.dev"
Expand Down
4 changes: 2 additions & 2 deletions nova_cli/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use nova_vm::{
ecmascript::{
builtins::{create_builtin_function, ArgumentsList, Behaviour, BuiltinFunctionArgs},
execution::{agent::ExceptionType, Agent, JsResult},
builtins::{ArgumentsList, Behaviour, BuiltinFunctionArgs, create_builtin_function},
execution::{Agent, JsResult, agent::ExceptionType},
types::{
InternalMethods, IntoValue, Object, OrdinaryObject, PropertyDescriptor, PropertyKey,
String, Value,
Expand Down
2 changes: 1 addition & 1 deletion nova_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use helper::{
use nova_vm::{
ecmascript::{
execution::{
agent::{GcAgent, HostHooks, Job, Options},
Agent, JsResult,
agent::{GcAgent, HostHooks, Job, Options},
},
scripts_and_modules::script::{parse_script, script_evaluation},
types::{Object, String as JsString, Value},
Expand Down
2 changes: 1 addition & 1 deletion nova_lint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "nova_lint"
repository = "https://github.com/trynova/nova/tree/main/nova_lint"
description = "A collection of custom lints to ease the development and maintenance of the Nova project."
edition = "2021"
edition = "2024"
version = "0.1.0"
license = "MPL-2.0"
homepage = "https://trynova.dev"
Expand Down
2 changes: 1 addition & 1 deletion nova_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mod utils;

pub(crate) use utils::*;

#[no_mangle]
#[unsafe(no_mangle)]
pub fn register_lints(sess: &rustc_session::Session, lint_store: &mut rustc_lint::LintStore) {
agent_comes_first::register_lints(sess, lint_store);
gc_scope_comes_last::register_lints(sess, lint_store);
Expand Down
2 changes: 1 addition & 1 deletion nova_vm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use small_string::SmallString;
use std::fs::File;
use std::io::{self, prelude::*, BufReader};
use std::io::{self, BufReader, prelude::*};

fn replace_invalid_key_characters(string: &str) -> String {
let mut string = string.to_owned();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ use crate::{
operations_on_objects::{call, call_function, get, get_method, try_get_method},
type_conversion::to_boolean,
},
builtins::{ordinary::ordinary_object_create_with_intrinsics, ArgumentsList},
builtins::{ArgumentsList, ordinary::ordinary_object_create_with_intrinsics},
execution::{
agent::{ExceptionType, JsError},
Agent, JsResult, ProtoIntrinsics,
agent::{ExceptionType, JsError},
},
types::{
Function, IntoValue, Object, PropertyDescriptor, PropertyKey, Value,
BUILTIN_STRING_MEMORY,
BUILTIN_STRING_MEMORY, Function, IntoValue, Object, PropertyDescriptor, PropertyKey,
Value,
},
},
engine::{
context::{Bindable, GcScope, NoGcScope},
Scoped, TryResult,
context::{Bindable, GcScope, NoGcScope},
},
heap::{CompactionLists, HeapMarkAndSweep, WellKnownSymbolIndexes, WorkQueues},
};
Expand Down
33 changes: 16 additions & 17 deletions nova_vm/src/ecmascript/abstract_operations/operations_on_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,33 @@ use super::{
},
};
use crate::{
ecmascript::types::scope_property_keys,
engine::{
context::{Bindable, GcScope, NoGcScope},
rootable::Rootable,
unwrap_try, Scoped, TryResult,
},
};
use crate::{
SmallInteger,
ecmascript::{
abstract_operations::operations_on_iterator_objects::iterator_step_value,
builtins::{
array_create,
ArgumentsList, Array, BuiltinConstructorFunction, array_create,
keyed_collections::map_objects::map_prototype::canonicalize_keyed_collection_key,
ArgumentsList, Array, BuiltinConstructorFunction,
},
execution::{
agent::ExceptionType, new_class_field_initializer_environment, Agent,
ECMAScriptCodeEvaluationState, EnvironmentIndex, ExecutionContext, JsResult,
RealmIdentifier,
Agent, ECMAScriptCodeEvaluationState, EnvironmentIndex, ExecutionContext, JsResult,
RealmIdentifier, agent::ExceptionType, new_class_field_initializer_environment,
},
types::{
Function, InternalMethods, IntoFunction, IntoObject, IntoValue, Number, Object,
OrdinaryObject, PropertyDescriptor, PropertyKey, String, Value, BUILTIN_STRING_MEMORY,
BUILTIN_STRING_MEMORY, Function, InternalMethods, IntoFunction, IntoObject, IntoValue,
Number, Object, OrdinaryObject, PropertyDescriptor, PropertyKey, String, Value,
},
},
engine::{instanceof_operator, Vm},
engine::{Vm, instanceof_operator},
heap::{Heap, ObjectEntry},
SmallInteger,
};
use crate::{
ecmascript::types::scope_property_keys,
engine::{
Scoped, TryResult,
context::{Bindable, GcScope, NoGcScope},
rootable::Rootable,
unwrap_try,
},
};

/// ### [7.3.1 MakeBasicObject ( internalSlotsList )](https://tc39.es/ecma262/#sec-makebasicobject)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@

use crate::ecmascript::abstract_operations::type_conversion::to_numeric_primitive;
use crate::ecmascript::builtins::proxy::abstract_operations::{
validate_non_revoked_proxy, NonRevokedProxy,
NonRevokedProxy, validate_non_revoked_proxy,
};
use crate::ecmascript::types::{InternalSlots, Numeric, Primitive, PropertyKey};
use crate::engine::context::{Bindable, GcScope, NoGcScope};
use crate::engine::TryResult;
use crate::engine::context::{Bindable, GcScope, NoGcScope};
use crate::heap::WellKnownSymbolIndexes;
use crate::{
ecmascript::{
execution::{agent::ExceptionType, Agent, JsResult},
execution::{Agent, JsResult, agent::ExceptionType},
types::{
bigint::BigInt, Function, InternalMethods, IntoValue, Number, Object, String, Value,
Function, InternalMethods, IntoValue, Number, Object, String, Value, bigint::BigInt,
},
},
heap::PrimitiveHeapIndexable,
};

use super::operations_on_objects::get;
use super::type_conversion::{
string_to_big_int, string_to_number, to_boolean, to_primitive, PreferredType,
PreferredType, string_to_big_int, string_to_number, to_boolean, to_primitive,
};

/// ### [7.2.1 RequireObjectCoercible ( argument )](https://tc39.es/ecma262/#sec-requireobjectcoercible)
Expand Down
12 changes: 6 additions & 6 deletions nova_vm/src/ecmascript/abstract_operations/type_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
use num_bigint::Sign;

use crate::ecmascript::types::IntoPrimitive;
use crate::engine::context::{Bindable, GcScope, NoGcScope};
use crate::engine::TryResult;
use crate::engine::context::{Bindable, GcScope, NoGcScope};
use crate::{
SmallInteger,
ecmascript::{
builtins::{
primitive_objects::{PrimitiveObjectData, PrimitiveObjectHeapData},
ArgumentsList,
primitive_objects::{PrimitiveObjectData, PrimitiveObjectHeapData},
},
execution::{agent::ExceptionType, Agent, JsResult},
execution::{Agent, JsResult, agent::ExceptionType},
types::{
BigInt, IntoNumeric, IntoObject, IntoValue, Number, Numeric, Object, Primitive,
PropertyKey, String, Value, BUILTIN_STRING_MEMORY,
BUILTIN_STRING_MEMORY, BigInt, IntoNumeric, IntoObject, IntoValue, Number, Numeric,
Object, Primitive, PropertyKey, String, Value,
},
},
heap::{CreateHeapData, WellKnownSymbolIndexes},
SmallInteger,
};

use super::{
Expand Down
4 changes: 2 additions & 2 deletions nova_vm/src/ecmascript/builders/builtin_function_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::{
},
execution::{Agent, RealmIdentifier},
types::{
BuiltinFunctionHeapData, IntoFunction, IntoObject, IntoValue, Object, ObjectHeapData,
OrdinaryObject, PropertyKey, String, Value, BUILTIN_STRING_MEMORY,
BUILTIN_STRING_MEMORY, BuiltinFunctionHeapData, IntoFunction, IntoObject, IntoValue,
Object, ObjectHeapData, OrdinaryObject, PropertyKey, String, Value,
},
},
engine::context::Bindable,
Expand Down
4 changes: 2 additions & 2 deletions nova_vm/src/ecmascript/builders/ordinary_object_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use crate::{
builtins::{Builtin, BuiltinFunction, BuiltinGetter, BuiltinIntrinsic},
execution::{Agent, RealmIdentifier},
types::{
IntoFunction, IntoObject, IntoValue, ObjectHeapData, OrdinaryObject, PropertyKey,
Value, BUILTIN_STRING_MEMORY,
BUILTIN_STRING_MEMORY, IntoFunction, IntoObject, IntoValue, ObjectHeapData,
OrdinaryObject, PropertyKey, Value,
},
},
heap::{element_array::ElementDescriptor, indexes::ObjectIndex},
Expand Down
8 changes: 4 additions & 4 deletions nova_vm/src/ecmascript/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ pub(crate) mod weak_ref;
pub(crate) mod weak_set;

pub(crate) use arguments::*;
pub(crate) use array::abstract_operations::*;
pub use array::Array;
pub(crate) use array::abstract_operations::*;
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};
pub(crate) use builtin_constructor::{BuiltinConstructorArgs, create_builtin_constructor};
pub use builtin_function::{
create_builtin_function, ArgumentsList, Behaviour, Builtin, BuiltinFunction,
BuiltinFunctionArgs, BuiltinGetter, ConstructorFn, RegularFn as JsFunction, RegularFn,
ArgumentsList, Behaviour, Builtin, BuiltinFunction, BuiltinFunctionArgs, BuiltinGetter,
ConstructorFn, RegularFn as JsFunction, RegularFn, create_builtin_function,
};
pub(crate) use builtin_function::{BuiltinIntrinsic, BuiltinIntrinsicConstructor};
pub use control_abstraction_objects::*;
Expand Down
6 changes: 3 additions & 3 deletions nova_vm/src/ecmascript/builtins/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ use crate::{
abstract_operations::operations_on_objects::{
try_create_data_property_or_throw, try_define_property_or_throw,
},
execution::{agent::Agent, ProtoIntrinsics},
execution::{ProtoIntrinsics, agent::Agent},
types::{
IntoFunction, IntoValue, Number, Object, PropertyDescriptor, PropertyKey, Value,
BUILTIN_STRING_MEMORY,
BUILTIN_STRING_MEMORY, IntoFunction, IntoValue, Number, Object, PropertyDescriptor,
PropertyKey, Value,
},
},
heap::WellKnownSymbolIndexes,
Expand Down
19 changes: 11 additions & 8 deletions nova_vm/src/ecmascript/builtins/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@ use crate::{
},
execution::{Agent, JsResult, ProtoIntrinsics},
types::{
Function, InternalMethods, InternalSlots, IntoObject, IntoValue, Object,
OrdinaryObject, PropertyDescriptor, PropertyKey, Value, BUILTIN_STRING_MEMORY,
BUILTIN_STRING_MEMORY, Function, InternalMethods, InternalSlots, IntoObject, IntoValue,
Object, OrdinaryObject, PropertyDescriptor, PropertyKey, Value,
},
},
engine::{
Scoped, TryResult,
context::{Bindable, GcScope, NoGcScope},
rootable::{HeapRootData, HeapRootRef, Rootable},
unwrap_try, Scoped, TryResult,
unwrap_try,
},
heap::{
CreateHeapData, Heap, HeapMarkAndSweep, WorkQueues,
element_array::{ElementArrays, ElementDescriptor},
indexes::ArrayIndex,
CreateHeapData, Heap, HeapMarkAndSweep, WorkQueues,
},
};

Expand Down Expand Up @@ -251,10 +252,12 @@ impl<'a> InternalSlots<'a> for Array<'a> {
}

fn set_backing_object(self, agent: &mut Agent, backing_object: OrdinaryObject<'static>) {
assert!(agent[self]
.object_index
.replace(backing_object.unbind())
.is_none());
assert!(
agent[self]
.object_index
.replace(backing_object.unbind())
.is_none()
);
}

fn internal_set_extensible(self, agent: &mut Agent, value: bool) {
Expand Down
10 changes: 5 additions & 5 deletions nova_vm/src/ecmascript/builtins/array/abstract_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use crate::ecmascript::abstract_operations::type_conversion::to_uint32_number;
use crate::engine::context::{Bindable, GcScope, NoGcScope};
use crate::engine::TryResult;
use crate::engine::context::{Bindable, GcScope, NoGcScope};
use crate::{
ecmascript::{
abstract_operations::{
Expand All @@ -13,13 +13,13 @@ use crate::{
type_conversion::{to_number, to_uint32},
},
builtins::ArgumentsList,
execution::{agent::ExceptionType, Agent, JsResult},
types::{IntoObject, Number, Object, PropertyDescriptor, Value, BUILTIN_STRING_MEMORY},
execution::{Agent, JsResult, agent::ExceptionType},
types::{BUILTIN_STRING_MEMORY, IntoObject, Number, Object, PropertyDescriptor, Value},
},
heap::{indexes::ArrayIndex, Heap, WellKnownSymbolIndexes},
heap::{Heap, WellKnownSymbolIndexes, indexes::ArrayIndex},
};

use super::{data::SealableElementsVector, Array, ArrayHeapData};
use super::{Array, ArrayHeapData, data::SealableElementsVector};

/// ### [10.4.2.2 ArrayCreate ( length \[ , proto \] )](https://tc39.es/ecma262/#sec-arraycreate)
///
Expand Down
2 changes: 1 addition & 1 deletion nova_vm/src/ecmascript/builtins/array/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use crate::{
ecmascript::types::{OrdinaryObject, Value},
heap::{
CompactionLists, HeapMarkAndSweep, WorkQueues,
element_array::{ElementArrayKey, ElementArrays, ElementDescriptor, ElementsVector},
indexes::ElementIndex,
CompactionLists, HeapMarkAndSweep, WorkQueues,
},
};

Expand Down
18 changes: 10 additions & 8 deletions nova_vm/src/ecmascript/builtins/array_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ use crate::{
},
},
engine::{
Scoped,
context::{Bindable, NoGcScope},
rootable::{HeapRootData, HeapRootRef, Rootable},
Scoped,
},
heap::{
indexes::{ArrayBufferIndex, IntoBaseIndex},
CompactionLists, CreateHeapData, Heap, HeapMarkAndSweep, WorkQueues,
indexes::{ArrayBufferIndex, IntoBaseIndex},
},
};

use abstract_operations::detach_array_buffer;
pub(crate) use abstract_operations::{
allocate_array_buffer, array_buffer_byte_length, clone_array_buffer, get_value_from_buffer,
is_detached_buffer, is_fixed_length_array_buffer, set_value_in_buffer, DetachKey, Ordering,
DetachKey, Ordering, allocate_array_buffer, array_buffer_byte_length, clone_array_buffer,
get_value_from_buffer, is_detached_buffer, is_fixed_length_array_buffer, set_value_in_buffer,
};
use core::ops::{Index, IndexMut};
pub use data::*;
Expand Down Expand Up @@ -242,10 +242,12 @@ impl<'a> InternalSlots<'a> for ArrayBuffer<'a> {
}

fn set_backing_object(self, agent: &mut Agent, backing_object: OrdinaryObject<'static>) {
assert!(agent[self]
.object_index
.replace(backing_object.unbind())
.is_none());
assert!(
agent[self]
.object_index
.replace(backing_object.unbind())
.is_none()
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use crate::ecmascript::abstract_operations::type_conversion::to_index;
use crate::ecmascript::types::{Numeric, Viewable};
use crate::engine::context::{Bindable, GcScope, NoGcScope};
use crate::{
Heap,
ecmascript::{
abstract_operations::operations_on_objects::get,
execution::{agent::ExceptionType, Agent, JsResult},
types::{DataBlock, Function, IntoFunction, Number, Object, Value, BUILTIN_STRING_MEMORY},
execution::{Agent, JsResult, agent::ExceptionType},
types::{BUILTIN_STRING_MEMORY, DataBlock, Function, IntoFunction, Number, Object, Value},
},
heap::indexes::ArrayBufferIndex,
Heap,
};

// TODO: Implement the contents of the `DetachKey` struct?
Expand Down
Loading