From 868a98528435ce064fc68d24927775958c4ab46d Mon Sep 17 00:00:00 2001 From: HalidOdat Date: Wed, 2 Sep 2020 01:31:57 +0200 Subject: [PATCH] Move value module from builtins --- boa/examples/classes.rs | 5 ++--- boa/src/builtins/array/mod.rs | 2 +- boa/src/builtins/bigint/conversions.rs | 5 +---- boa/src/builtins/bigint/mod.rs | 2 +- boa/src/builtins/boolean/mod.rs | 6 +----- boa/src/builtins/boolean/tests.rs | 2 +- boa/src/builtins/console/mod.rs | 6 ++---- boa/src/builtins/console/tests.rs | 6 +----- boa/src/builtins/date/mod.rs | 5 ++--- boa/src/builtins/date/tests.rs | 5 +---- boa/src/builtins/error/mod.rs | 3 +-- boa/src/builtins/error/range.rs | 6 ++---- boa/src/builtins/error/reference.rs | 6 ++---- boa/src/builtins/error/syntax.rs | 6 ++---- boa/src/builtins/error/type.rs | 6 ++---- boa/src/builtins/function/mod.rs | 3 +-- boa/src/builtins/global_this/mod.rs | 2 +- boa/src/builtins/infinity/mod.rs | 2 +- boa/src/builtins/json/mod.rs | 3 +-- boa/src/builtins/json/tests.rs | 6 ++---- boa/src/builtins/map/mod.rs | 3 +-- boa/src/builtins/math/mod.rs | 6 +----- boa/src/builtins/mod.rs | 4 +--- boa/src/builtins/nan/mod.rs | 2 +- boa/src/builtins/number/mod.rs | 3 +-- boa/src/builtins/object/gcobject.rs | 7 ++----- boa/src/builtins/object/internal_methods.rs | 11 ++++++----- boa/src/builtins/object/iter.rs | 3 ++- boa/src/builtins/object/mod.rs | 4 ++-- boa/src/builtins/property/mod.rs | 4 +--- boa/src/builtins/regexp/mod.rs | 7 ++----- boa/src/builtins/string/mod.rs | 2 +- boa/src/builtins/symbol/mod.rs | 6 ++---- boa/src/builtins/undefined/mod.rs | 2 +- .../environment/declarative_environment_record.rs | 2 +- boa/src/environment/environment_record_trait.rs | 4 ++-- boa/src/environment/function_environment_record.rs | 3 ++- boa/src/environment/global_environment_record.rs | 6 ++---- boa/src/environment/lexical_environment.rs | 4 ++-- boa/src/environment/object_environment_record.rs | 6 ++---- boa/src/exec/array/mod.rs | 4 ++-- boa/src/exec/block/mod.rs | 4 ++-- boa/src/exec/break_node/mod.rs | 3 +-- boa/src/exec/call/mod.rs | 2 +- boa/src/exec/conditional/mod.rs | 3 +-- boa/src/exec/declaration/mod.rs | 4 ++-- boa/src/exec/field/mod.rs | 2 +- boa/src/exec/identifier/mod.rs | 2 +- boa/src/exec/iteration/mod.rs | 3 +-- boa/src/exec/mod.rs | 4 ++-- boa/src/exec/new/mod.rs | 2 +- boa/src/exec/object/mod.rs | 3 +-- boa/src/exec/operator/mod.rs | 3 +-- boa/src/exec/return_smt/mod.rs | 2 +- boa/src/exec/spread/mod.rs | 2 +- boa/src/exec/statement_list.rs | 2 +- boa/src/exec/switch/mod.rs | 2 +- boa/src/exec/tests.rs | 14 ++++---------- boa/src/exec/throw/mod.rs | 2 +- boa/src/exec/try_node/mod.rs | 3 +-- boa/src/lib.rs | 4 +++- boa/src/realm.rs | 3 +-- boa/src/{builtins => }/value/conversions.rs | 0 boa/src/{builtins => }/value/display.rs | 0 boa/src/{builtins => }/value/equality.rs | 0 boa/src/{builtins => }/value/hash.rs | 0 boa/src/{builtins => }/value/mod.rs | 4 ++-- boa/src/{builtins => }/value/operations.rs | 5 +---- boa/src/{builtins => }/value/rcbigint.rs | 0 boa/src/{builtins => }/value/rcstring.rs | 0 boa/src/{builtins => }/value/rcsymbol.rs | 0 boa/src/{builtins => }/value/tests.rs | 0 boa/src/{builtins => }/value/type.rs | 0 73 files changed, 97 insertions(+), 161 deletions(-) rename boa/src/{builtins => }/value/conversions.rs (100%) rename boa/src/{builtins => }/value/display.rs (100%) rename boa/src/{builtins => }/value/equality.rs (100%) rename boa/src/{builtins => }/value/hash.rs (100%) rename boa/src/{builtins => }/value/mod.rs (99%) rename boa/src/{builtins => }/value/operations.rs (99%) rename boa/src/{builtins => }/value/rcbigint.rs (100%) rename boa/src/{builtins => }/value/rcstring.rs (100%) rename boa/src/{builtins => }/value/rcsymbol.rs (100%) rename boa/src/{builtins => }/value/tests.rs (100%) rename boa/src/{builtins => }/value/type.rs (100%) diff --git a/boa/examples/classes.rs b/boa/examples/classes.rs index 1ddb74ccd00..acc5665236e 100644 --- a/boa/examples/classes.rs +++ b/boa/examples/classes.rs @@ -2,12 +2,11 @@ use boa::{ builtins::{ object::{Class, ClassBuilder}, property::Attribute, - value::Value, }, exec::Interpreter, forward_val, realm::Realm, - Result, + Result, Value, }; use gc::{Finalize, Trace}; @@ -140,7 +139,7 @@ fn main() { if (!Person.is('Hello')) { console.log('\'Hello\' string is not a Person class instance.'); } - + console.log(Person.staticProperty); console.log(person.inheritedProperty); console.log(Person.prototype.inheritedProperty === person.inheritedProperty); diff --git a/boa/src/builtins/array/mod.rs b/boa/src/builtins/array/mod.rs index 58596a94593..3611edfa7cc 100644 --- a/boa/src/builtins/array/mod.rs +++ b/boa/src/builtins/array/mod.rs @@ -17,9 +17,9 @@ use crate::{ builtins::{ object::{ObjectData, PROTOTYPE}, property::{Attribute, Property}, - value::{same_value_zero, Value}, }, exec::Interpreter, + value::{same_value_zero, Value}, BoaProfiler, Result, }; use std::{ diff --git a/boa/src/builtins/bigint/conversions.rs b/boa/src/builtins/bigint/conversions.rs index 572e2899769..b03c759b6cd 100644 --- a/boa/src/builtins/bigint/conversions.rs +++ b/boa/src/builtins/bigint/conversions.rs @@ -1,9 +1,6 @@ use super::BigInt; -use crate::{ - builtins::{Number, Value}, - exec::Interpreter, -}; +use crate::{builtins::Number, exec::Interpreter, Value}; use num_traits::cast::{FromPrimitive, ToPrimitive}; use std::convert::TryFrom; diff --git a/boa/src/builtins/bigint/mod.rs b/boa/src/builtins/bigint/mod.rs index e2e9ffe879b..f22cd2f4796 100644 --- a/boa/src/builtins/bigint/mod.rs +++ b/boa/src/builtins/bigint/mod.rs @@ -16,9 +16,9 @@ use crate::{ builtins::{ function::{make_builtin_fn, make_constructor_fn}, object::ObjectData, - value::{RcBigInt, Value}, }, exec::Interpreter, + value::{RcBigInt, Value}, BoaProfiler, Result, }; diff --git a/boa/src/builtins/boolean/mod.rs b/boa/src/builtins/boolean/mod.rs index 2d907cddaec..70d94fca32c 100644 --- a/boa/src/builtins/boolean/mod.rs +++ b/boa/src/builtins/boolean/mod.rs @@ -13,11 +13,7 @@ mod tests; use super::function::{make_builtin_fn, make_constructor_fn}; -use crate::{ - builtins::{object::ObjectData, value::Value}, - exec::Interpreter, - BoaProfiler, Result, -}; +use crate::{builtins::object::ObjectData, exec::Interpreter, BoaProfiler, Result, Value}; /// Boolean implementation. #[derive(Debug, Clone, Copy)] diff --git a/boa/src/builtins/boolean/tests.rs b/boa/src/builtins/boolean/tests.rs index c0eed466e39..84eae25e80d 100644 --- a/boa/src/builtins/boolean/tests.rs +++ b/boa/src/builtins/boolean/tests.rs @@ -1,4 +1,4 @@ -use crate::{builtins::value::same_value, exec::Interpreter, forward, forward_val, realm::Realm}; +use crate::{exec::Interpreter, forward, forward_val, realm::Realm, value::same_value}; /// Test the correct type is returned from call and construct #[allow(clippy::unwrap_used)] diff --git a/boa/src/builtins/console/mod.rs b/boa/src/builtins/console/mod.rs index be1153d8477..48c5e3bd5fd 100644 --- a/boa/src/builtins/console/mod.rs +++ b/boa/src/builtins/console/mod.rs @@ -17,11 +17,9 @@ mod tests; use crate::{ - builtins::{ - function::make_builtin_fn, - value::{display_obj, RcString, Value}, - }, + builtins::function::make_builtin_fn, exec::Interpreter, + value::{display_obj, RcString, Value}, BoaProfiler, Result, }; use rustc_hash::FxHashMap; diff --git a/boa/src/builtins/console/tests.rs b/boa/src/builtins/console/tests.rs index 68d820dd7b5..8b293f81457 100644 --- a/boa/src/builtins/console/tests.rs +++ b/boa/src/builtins/console/tests.rs @@ -1,8 +1,4 @@ -use crate::{ - builtins::{console::formatter, value::Value}, - exec::Interpreter, - realm::Realm, -}; +use crate::{builtins::console::formatter, exec::Interpreter, realm::Realm, Value}; #[test] fn formatter_no_args_is_empty_string() { diff --git a/boa/src/builtins/date/mod.rs b/boa/src/builtins/date/mod.rs index 9f792aaa8e7..c88801cb920 100644 --- a/boa/src/builtins/date/mod.rs +++ b/boa/src/builtins/date/mod.rs @@ -5,10 +5,9 @@ use crate::{ builtins::{ function::{make_builtin_fn, make_constructor_fn}, object::ObjectData, - value::PreferredType, - Value, }, - BoaProfiler, Interpreter, Result, + value::PreferredType, + BoaProfiler, Interpreter, Result, Value, }; use chrono::{prelude::*, Duration, LocalResult}; use gc::{unsafe_empty_trace, Finalize, Trace}; diff --git a/boa/src/builtins/date/tests.rs b/boa/src/builtins/date/tests.rs index fb005c3f0db..6bb7d9976ed 100644 --- a/boa/src/builtins/date/tests.rs +++ b/boa/src/builtins/date/tests.rs @@ -1,9 +1,6 @@ #![allow(clippy::zero_prefixed_literal)] -use crate::{ - builtins::{object::ObjectData, Value}, - forward, forward_val, Interpreter, Realm, -}; +use crate::{builtins::object::ObjectData, forward, forward_val, Interpreter, Realm, Value}; use chrono::prelude::*; // NOTE: Javascript Uses 0-based months, where chrono uses 1-based months. Many of the assertions look wrong because of diff --git a/boa/src/builtins/error/mod.rs b/boa/src/builtins/error/mod.rs index 6b97c751b9d..5b52b4d2400 100644 --- a/boa/src/builtins/error/mod.rs +++ b/boa/src/builtins/error/mod.rs @@ -14,11 +14,10 @@ use crate::{ builtins::{ function::{make_builtin_fn, make_constructor_fn}, object::ObjectData, - value::Value, }, exec::Interpreter, profiler::BoaProfiler, - Result, + Result, Value, }; pub(crate) mod range; diff --git a/boa/src/builtins/error/range.rs b/boa/src/builtins/error/range.rs index 2b5e635c99e..952d94aff55 100644 --- a/boa/src/builtins/error/range.rs +++ b/boa/src/builtins/error/range.rs @@ -10,12 +10,10 @@ //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError use crate::{ - builtins::{ - function::make_builtin_fn, function::make_constructor_fn, object::ObjectData, value::Value, - }, + builtins::{function::make_builtin_fn, function::make_constructor_fn, object::ObjectData}, exec::Interpreter, profiler::BoaProfiler, - Result, + Result, Value, }; /// JavaScript `RangeError` impleentation. diff --git a/boa/src/builtins/error/reference.rs b/boa/src/builtins/error/reference.rs index 9f20117dd3e..811ddf626af 100644 --- a/boa/src/builtins/error/reference.rs +++ b/boa/src/builtins/error/reference.rs @@ -10,12 +10,10 @@ //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError use crate::{ - builtins::{ - function::make_builtin_fn, function::make_constructor_fn, object::ObjectData, value::Value, - }, + builtins::{function::make_builtin_fn, function::make_constructor_fn, object::ObjectData}, exec::Interpreter, profiler::BoaProfiler, - Result, + Result, Value, }; #[derive(Debug, Clone, Copy)] diff --git a/boa/src/builtins/error/syntax.rs b/boa/src/builtins/error/syntax.rs index c05f0f7fbb5..3e0ca8e2f77 100644 --- a/boa/src/builtins/error/syntax.rs +++ b/boa/src/builtins/error/syntax.rs @@ -12,12 +12,10 @@ //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError use crate::{ - builtins::{ - function::make_builtin_fn, function::make_constructor_fn, object::ObjectData, value::Value, - }, + builtins::{function::make_builtin_fn, function::make_constructor_fn, object::ObjectData}, exec::Interpreter, profiler::BoaProfiler, - Result, + Result, Value, }; /// JavaScript `SyntaxError` impleentation. diff --git a/boa/src/builtins/error/type.rs b/boa/src/builtins/error/type.rs index 60fff80f962..4fc214bdc3b 100644 --- a/boa/src/builtins/error/type.rs +++ b/boa/src/builtins/error/type.rs @@ -16,11 +16,9 @@ //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError use crate::{ - builtins::{ - function::make_builtin_fn, function::make_constructor_fn, object::ObjectData, value::Value, - }, + builtins::{function::make_builtin_fn, function::make_constructor_fn, object::ObjectData}, exec::Interpreter, - BoaProfiler, Result, + BoaProfiler, Result, Value, }; /// JavaScript `TypeError` implementation. diff --git a/boa/src/builtins/function/mod.rs b/boa/src/builtins/function/mod.rs index 25730235245..4b88c729b8c 100644 --- a/boa/src/builtins/function/mod.rs +++ b/boa/src/builtins/function/mod.rs @@ -15,13 +15,12 @@ use crate::{ builtins::{ object::{Object, ObjectData, PROTOTYPE}, property::{Attribute, Property}, - value::Value, Array, }, environment::lexical_environment::Environment, exec::Interpreter, syntax::ast::node::{FormalParameter, StatementList}, - BoaProfiler, Result, + BoaProfiler, Result, Value, }; use bitflags::bitflags; use gc::{unsafe_empty_trace, Finalize, Trace}; diff --git a/boa/src/builtins/global_this/mod.rs b/boa/src/builtins/global_this/mod.rs index 481b619decb..f43d9aa38cd 100644 --- a/boa/src/builtins/global_this/mod.rs +++ b/boa/src/builtins/global_this/mod.rs @@ -10,7 +10,7 @@ //! [spec]: https://tc39.es/ecma262/#sec-globalthis //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis -use crate::{builtins::value::Value, BoaProfiler, Interpreter}; +use crate::{BoaProfiler, Interpreter, Value}; #[cfg(test)] mod tests; diff --git a/boa/src/builtins/infinity/mod.rs b/boa/src/builtins/infinity/mod.rs index 7cb9b78fff3..e0d2b475b9d 100644 --- a/boa/src/builtins/infinity/mod.rs +++ b/boa/src/builtins/infinity/mod.rs @@ -12,7 +12,7 @@ #[cfg(test)] mod tests; -use crate::{builtins::value::Value, BoaProfiler, Interpreter}; +use crate::{BoaProfiler, Interpreter, Value}; /// JavaScript global `Infinity` property. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/boa/src/builtins/json/mod.rs b/boa/src/builtins/json/mod.rs index d674d18d5b5..d4691f6da46 100644 --- a/boa/src/builtins/json/mod.rs +++ b/boa/src/builtins/json/mod.rs @@ -17,10 +17,9 @@ use crate::{ builtins::{ function::make_builtin_fn, property::{Property, PropertyKey}, - value::Value, }, exec::Interpreter, - BoaProfiler, Result, + BoaProfiler, Result, Value, }; use serde_json::{self, Value as JSONValue}; diff --git a/boa/src/builtins/json/tests.rs b/boa/src/builtins/json/tests.rs index 02c661c594b..1f32e91bdd6 100644 --- a/boa/src/builtins/json/tests.rs +++ b/boa/src/builtins/json/tests.rs @@ -1,8 +1,6 @@ use crate::{ - builtins::{object::PROTOTYPE, value::same_value}, - exec::Interpreter, - forward, forward_val, - realm::Realm, + builtins::object::PROTOTYPE, exec::Interpreter, forward, forward_val, realm::Realm, + value::same_value, }; #[test] diff --git a/boa/src/builtins/map/mod.rs b/boa/src/builtins/map/mod.rs index 46aa475ba47..74a38b6d482 100644 --- a/boa/src/builtins/map/mod.rs +++ b/boa/src/builtins/map/mod.rs @@ -5,10 +5,9 @@ use crate::{ builtins::{ object::{ObjectData, PROTOTYPE}, property::{Attribute, Property}, - value::Value, }, exec::Interpreter, - BoaProfiler, Result, + BoaProfiler, Result, Value, }; use ordered_map::OrderedMap; diff --git a/boa/src/builtins/math/mod.rs b/boa/src/builtins/math/mod.rs index be769e61f10..b332c376290 100644 --- a/boa/src/builtins/math/mod.rs +++ b/boa/src/builtins/math/mod.rs @@ -11,11 +11,7 @@ //! [spec]: https://tc39.es/ecma262/#sec-math-object //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math -use crate::{ - builtins::{function::make_builtin_fn, value::Value}, - exec::Interpreter, - BoaProfiler, Result, -}; +use crate::{builtins::function::make_builtin_fn, exec::Interpreter, BoaProfiler, Result, Value}; use std::f64; #[cfg(test)] diff --git a/boa/src/builtins/mod.rs b/boa/src/builtins/mod.rs index 29d1628c33b..c0211b318b3 100644 --- a/boa/src/builtins/mod.rs +++ b/boa/src/builtins/mod.rs @@ -20,7 +20,6 @@ pub mod regexp; pub mod string; pub mod symbol; pub mod undefined; -pub mod value; pub(crate) use self::{ array::Array, @@ -40,9 +39,8 @@ pub(crate) use self::{ string::String, symbol::Symbol, undefined::Undefined, - value::Value, }; -use crate::Interpreter; +use crate::{Interpreter, Value}; /// Initializes builtin objects and functions #[inline] diff --git a/boa/src/builtins/nan/mod.rs b/boa/src/builtins/nan/mod.rs index eeb29c039c9..ceeb53c3b02 100644 --- a/boa/src/builtins/nan/mod.rs +++ b/boa/src/builtins/nan/mod.rs @@ -13,7 +13,7 @@ #[cfg(test)] mod tests; -use crate::{builtins::value::Value, BoaProfiler, Interpreter}; +use crate::{BoaProfiler, Interpreter, Value}; /// JavaScript global `NaN` property. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/boa/src/builtins/number/mod.rs b/boa/src/builtins/number/mod.rs index 28dd2c7468b..a4d1f1cce0d 100644 --- a/boa/src/builtins/number/mod.rs +++ b/boa/src/builtins/number/mod.rs @@ -16,9 +16,8 @@ use super::{ function::{make_builtin_fn, make_constructor_fn}, object::ObjectData, - value::AbstractRelation, }; -use crate::{builtins::value::Value, exec::Interpreter, BoaProfiler, Result}; +use crate::{exec::Interpreter, value::AbstractRelation, BoaProfiler, Result, Value}; use num_traits::float::FloatCore; mod conversions; diff --git a/boa/src/builtins/object/gcobject.rs b/boa/src/builtins/object/gcobject.rs index 15b1d7d12fa..75006182b50 100644 --- a/boa/src/builtins/object/gcobject.rs +++ b/boa/src/builtins/object/gcobject.rs @@ -4,14 +4,11 @@ use super::{Object, PROTOTYPE}; use crate::{ - builtins::{ - function::{create_unmapped_arguments_object, BuiltInFunction, Function}, - Value, - }, + builtins::function::{create_unmapped_arguments_object, BuiltInFunction, Function}, environment::{ function_environment_record::BindingStatus, lexical_environment::new_function_environment, }, - Executable, Interpreter, Result, + Executable, Interpreter, Result, Value, }; use gc::{Finalize, Gc, GcCell, GcCellRef, GcCellRefMut, Trace}; use std::{ diff --git a/boa/src/builtins/object/internal_methods.rs b/boa/src/builtins/object/internal_methods.rs index 8bda40f1ea5..b4f7e578211 100644 --- a/boa/src/builtins/object/internal_methods.rs +++ b/boa/src/builtins/object/internal_methods.rs @@ -5,13 +5,14 @@ //! //! [spec]: https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots -use crate::builtins::{ - object::Object, - property::{Attribute, Property, PropertyKey}, +use crate::{ + builtins::{ + object::Object, + property::{Attribute, Property, PropertyKey}, + }, value::{same_value, Value}, + BoaProfiler, }; -use crate::BoaProfiler; - impl Object { /// Check if object has property. /// diff --git a/boa/src/builtins/object/iter.rs b/boa/src/builtins/object/iter.rs index 801606549d1..504f88c2945 100644 --- a/boa/src/builtins/object/iter.rs +++ b/boa/src/builtins/object/iter.rs @@ -1,4 +1,5 @@ -use super::{Object, Property, PropertyKey, RcString, RcSymbol}; +use super::{Object, Property, PropertyKey}; +use crate::value::{RcString, RcSymbol}; use std::{collections::hash_map, iter::FusedIterator}; impl Object { diff --git a/boa/src/builtins/object/mod.rs b/boa/src/builtins/object/mod.rs index 33dd2815ccf..1d118edb992 100644 --- a/boa/src/builtins/object/mod.rs +++ b/boa/src/builtins/object/mod.rs @@ -18,10 +18,10 @@ use crate::{ function::Function, map::ordered_map::OrderedMap, property::{Attribute, Property, PropertyKey}, - value::{RcBigInt, RcString, RcSymbol, Value}, BigInt, Date, RegExp, }, exec::Interpreter, + value::{RcBigInt, RcString, RcSymbol, Value}, BoaProfiler, Result, }; use gc::{Finalize, Trace}; @@ -33,7 +33,7 @@ use std::result::Result as StdResult; use super::function::{ make_builtin_fn, make_constructor_fn, BuiltInFunction, FunctionFlags, NativeFunction, }; -use crate::builtins::value::same_value; +use crate::value::same_value; mod gcobject; mod internal_methods; diff --git a/boa/src/builtins/property/mod.rs b/boa/src/builtins/property/mod.rs index 4afedf9f94e..9ce6fc5571c 100644 --- a/boa/src/builtins/property/mod.rs +++ b/boa/src/builtins/property/mod.rs @@ -14,9 +14,7 @@ //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty //! [section]: https://tc39.es/ecma262/#sec-property-attributes -use crate::builtins::value::RcString; -use crate::builtins::value::RcSymbol; -use crate::builtins::Value; +use crate::value::{RcString, RcSymbol, Value}; use gc::{Finalize, Trace}; use std::convert::TryFrom; use std::fmt; diff --git a/boa/src/builtins/regexp/mod.rs b/boa/src/builtins/regexp/mod.rs index 214b2807ca3..3ebf101a256 100644 --- a/boa/src/builtins/regexp/mod.rs +++ b/boa/src/builtins/regexp/mod.rs @@ -13,12 +13,9 @@ use regex::Regex; use super::function::{make_builtin_fn, make_constructor_fn}; use crate::{ - builtins::{ - object::ObjectData, - property::Property, - value::{RcString, Value}, - }, + builtins::{object::ObjectData, property::Property}, exec::Interpreter, + value::{RcString, Value}, BoaProfiler, Result, }; use gc::{unsafe_empty_trace, Finalize, Trace}; diff --git a/boa/src/builtins/string/mod.rs b/boa/src/builtins/string/mod.rs index e5a613702d0..b6503d34a3b 100644 --- a/boa/src/builtins/string/mod.rs +++ b/boa/src/builtins/string/mod.rs @@ -17,10 +17,10 @@ use crate::{ builtins::{ object::{Object, ObjectData}, property::Property, - value::{RcString, Value}, RegExp, }, exec::Interpreter, + value::{RcString, Value}, BoaProfiler, Result, }; use regex::Regex; diff --git a/boa/src/builtins/symbol/mod.rs b/boa/src/builtins/symbol/mod.rs index 25ccf148f8c..2ac1c7d7023 100644 --- a/boa/src/builtins/symbol/mod.rs +++ b/boa/src/builtins/symbol/mod.rs @@ -20,11 +20,9 @@ mod tests; use super::function::{make_builtin_fn, make_constructor_fn}; use crate::{ - builtins::{ - property::{Attribute, Property}, - value::{RcString, RcSymbol, Value}, - }, + builtins::property::{Attribute, Property}, exec::Interpreter, + value::{RcString, RcSymbol, Value}, BoaProfiler, Result, }; use gc::{Finalize, Trace}; diff --git a/boa/src/builtins/undefined/mod.rs b/boa/src/builtins/undefined/mod.rs index ae21964a3ae..6913b08d470 100644 --- a/boa/src/builtins/undefined/mod.rs +++ b/boa/src/builtins/undefined/mod.rs @@ -12,7 +12,7 @@ #[cfg(test)] mod tests; -use crate::{builtins::value::Value, BoaProfiler, Interpreter}; +use crate::{BoaProfiler, Interpreter, Value}; /// JavaScript global `undefined` property. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/boa/src/environment/declarative_environment_record.rs b/boa/src/environment/declarative_environment_record.rs index 1b02c1c7a13..99b8eaebc4e 100644 --- a/boa/src/environment/declarative_environment_record.rs +++ b/boa/src/environment/declarative_environment_record.rs @@ -6,11 +6,11 @@ //! More info: [ECMA-262 sec-declarative-environment-records](https://tc39.es/ecma262/#sec-declarative-environment-records) use crate::{ - builtins::value::Value, environment::{ environment_record_trait::EnvironmentRecordTrait, lexical_environment::{Environment, EnvironmentType}, }, + Value, }; use gc::{Finalize, Trace}; use rustc_hash::FxHashMap; diff --git a/boa/src/environment/environment_record_trait.rs b/boa/src/environment/environment_record_trait.rs index 297ecb2215d..7e304d018e9 100644 --- a/boa/src/environment/environment_record_trait.rs +++ b/boa/src/environment/environment_record_trait.rs @@ -9,15 +9,15 @@ //! There are 5 Environment record kinds. They all have methods in common, these are implemented as a the `EnvironmentRecordTrait` //! use crate::{ - builtins::value::Value, environment::lexical_environment::{Environment, EnvironmentType}, + Value, }; use gc::{Finalize, Trace}; use std::fmt::Debug; /// /// -/// In the ECMAScript specification Environment Records are hierachical and have a base class with abstract methods. +/// In the ECMAScript specification Environment Records are hierachical and have a base class with abstract methods. /// In this implementation we have a trait which represents the behaviour of all `EnvironmentRecord` types. pub trait EnvironmentRecordTrait: Debug + Trace + Finalize { /// Determine if an Environment Record has a binding for the String value N. Return true if it does and false if it does not. diff --git a/boa/src/environment/function_environment_record.rs b/boa/src/environment/function_environment_record.rs index c6a5a866a68..0ea6e04ea6d 100644 --- a/boa/src/environment/function_environment_record.rs +++ b/boa/src/environment/function_environment_record.rs @@ -9,12 +9,13 @@ //! More info: use crate::{ - builtins::{object::GcObject, value::Value}, + builtins::object::GcObject, environment::{ declarative_environment_record::DeclarativeEnvironmentRecordBinding, environment_record_trait::EnvironmentRecordTrait, lexical_environment::{Environment, EnvironmentType}, }, + Value, }; use gc::{unsafe_empty_trace, Finalize, Trace}; use rustc_hash::FxHashMap; diff --git a/boa/src/environment/global_environment_record.rs b/boa/src/environment/global_environment_record.rs index 24c6ce7e7db..62b9a5ac050 100644 --- a/boa/src/environment/global_environment_record.rs +++ b/boa/src/environment/global_environment_record.rs @@ -8,16 +8,14 @@ //! More info: use crate::{ - builtins::{ - property::{Attribute, Property}, - Value, - }, + builtins::property::{Attribute, Property}, environment::{ declarative_environment_record::DeclarativeEnvironmentRecord, environment_record_trait::EnvironmentRecordTrait, lexical_environment::{Environment, EnvironmentType}, object_environment_record::ObjectEnvironmentRecord, }, + Value, }; use gc::{Finalize, Trace}; use rustc_hash::FxHashSet; diff --git a/boa/src/environment/lexical_environment.rs b/boa/src/environment/lexical_environment.rs index 2a1ecd448db..4faf63035d3 100644 --- a/boa/src/environment/lexical_environment.rs +++ b/boa/src/environment/lexical_environment.rs @@ -6,7 +6,7 @@ //! This is the entrypoint to lexical environments. use crate::{ - builtins::{object::GcObject, value::Value}, + builtins::object::GcObject, environment::{ declarative_environment_record::DeclarativeEnvironmentRecord, environment_record_trait::EnvironmentRecordTrait, @@ -14,7 +14,7 @@ use crate::{ global_environment_record::GlobalEnvironmentRecord, object_environment_record::ObjectEnvironmentRecord, }, - BoaProfiler, + BoaProfiler, Value, }; use gc::{Gc, GcCell}; use rustc_hash::{FxHashMap, FxHashSet}; diff --git a/boa/src/environment/object_environment_record.rs b/boa/src/environment/object_environment_record.rs index e00f5044dbf..1ffc32038f2 100644 --- a/boa/src/environment/object_environment_record.rs +++ b/boa/src/environment/object_environment_record.rs @@ -7,14 +7,12 @@ //! More info: [Object Records](https://tc39.es/ecma262/#sec-object-environment-records) use crate::{ - builtins::{ - property::{Attribute, Property}, - value::Value, - }, + builtins::property::{Attribute, Property}, environment::{ environment_record_trait::EnvironmentRecordTrait, lexical_environment::{Environment, EnvironmentType}, }, + Value, }; use gc::{Finalize, Trace}; diff --git a/boa/src/exec/array/mod.rs b/boa/src/exec/array/mod.rs index d61788395d5..a83ec78ab47 100644 --- a/boa/src/exec/array/mod.rs +++ b/boa/src/exec/array/mod.rs @@ -2,9 +2,9 @@ use super::{Executable, Interpreter}; use crate::{ - builtins::{Array, Value}, + builtins::Array, syntax::ast::node::{ArrayDecl, Node}, - BoaProfiler, Result, + BoaProfiler, Result, Value, }; impl Executable for ArrayDecl { diff --git a/boa/src/exec/block/mod.rs b/boa/src/exec/block/mod.rs index 4835022ed2b..2cf740512a8 100644 --- a/boa/src/exec/block/mod.rs +++ b/boa/src/exec/block/mod.rs @@ -2,8 +2,8 @@ use super::{Executable, Interpreter, InterpreterState}; use crate::{ - builtins::value::Value, environment::lexical_environment::new_declarative_environment, - syntax::ast::node::Block, BoaProfiler, Result, + environment::lexical_environment::new_declarative_environment, syntax::ast::node::Block, + BoaProfiler, Result, Value, }; impl Executable for Block { diff --git a/boa/src/exec/break_node/mod.rs b/boa/src/exec/break_node/mod.rs index 76acb67db9b..ac0b901d0e9 100644 --- a/boa/src/exec/break_node/mod.rs +++ b/boa/src/exec/break_node/mod.rs @@ -1,8 +1,7 @@ use super::{Executable, Interpreter, InterpreterState}; use crate::{ - builtins::value::Value, syntax::ast::node::{Break, Continue}, - Result, + Result, Value, }; #[cfg(test)] diff --git a/boa/src/exec/call/mod.rs b/boa/src/exec/call/mod.rs index ad4d23f1557..a1246f09577 100644 --- a/boa/src/exec/call/mod.rs +++ b/boa/src/exec/call/mod.rs @@ -1,7 +1,7 @@ use super::{Executable, Interpreter, InterpreterState}; use crate::{ - builtins::value::{Type, Value}, syntax::ast::node::{Call, Node}, + value::{Type, Value}, BoaProfiler, Result, }; diff --git a/boa/src/exec/conditional/mod.rs b/boa/src/exec/conditional/mod.rs index 17409d66ad1..912566924af 100644 --- a/boa/src/exec/conditional/mod.rs +++ b/boa/src/exec/conditional/mod.rs @@ -1,8 +1,7 @@ use super::{Executable, Interpreter}; use crate::{ - builtins::Value, syntax::ast::node::{ConditionalOp, If}, - Result, + Result, Value, }; use std::borrow::Borrow; diff --git a/boa/src/exec/declaration/mod.rs b/boa/src/exec/declaration/mod.rs index 5b5678de107..ae2276b0b5b 100644 --- a/boa/src/exec/declaration/mod.rs +++ b/boa/src/exec/declaration/mod.rs @@ -2,12 +2,12 @@ use super::{Executable, Interpreter}; use crate::{ - builtins::{function::FunctionFlags, Value}, + builtins::function::FunctionFlags, environment::lexical_environment::VariableScope, syntax::ast::node::{ ArrowFunctionDecl, ConstDeclList, FunctionDecl, FunctionExpr, LetDeclList, VarDeclList, }, - BoaProfiler, Result, + BoaProfiler, Result, Value, }; impl Executable for FunctionDecl { diff --git a/boa/src/exec/field/mod.rs b/boa/src/exec/field/mod.rs index 7b854a789bb..2ce38deacc6 100644 --- a/boa/src/exec/field/mod.rs +++ b/boa/src/exec/field/mod.rs @@ -1,7 +1,7 @@ use super::{Executable, Interpreter}; use crate::{ - builtins::value::{Type, Value}, syntax::ast::node::{GetConstField, GetField}, + value::{Type, Value}, Result, }; diff --git a/boa/src/exec/identifier/mod.rs b/boa/src/exec/identifier/mod.rs index 0817642c791..10118f4c100 100644 --- a/boa/src/exec/identifier/mod.rs +++ b/boa/src/exec/identifier/mod.rs @@ -1,5 +1,5 @@ use super::{Executable, Interpreter}; -use crate::{builtins::value::Value, syntax::ast::node::identifier::Identifier, Result}; +use crate::{syntax::ast::node::identifier::Identifier, Result, Value}; impl Executable for Identifier { fn run(&self, interpreter: &mut Interpreter) -> Result { diff --git a/boa/src/exec/iteration/mod.rs b/boa/src/exec/iteration/mod.rs index 5bd86ebfb84..80e914e7b30 100644 --- a/boa/src/exec/iteration/mod.rs +++ b/boa/src/exec/iteration/mod.rs @@ -2,10 +2,9 @@ use super::{Executable, Interpreter, InterpreterState}; use crate::{ - builtins::value::Value, environment::lexical_environment::new_declarative_environment, syntax::ast::node::{DoWhileLoop, ForLoop, WhileLoop}, - BoaProfiler, Result, + BoaProfiler, Result, Value, }; use std::borrow::Borrow; diff --git a/boa/src/exec/mod.rs b/boa/src/exec/mod.rs index 530d01fd5c5..b3086958aad 100644 --- a/boa/src/exec/mod.rs +++ b/boa/src/exec/mod.rs @@ -28,7 +28,6 @@ use crate::{ function::{Function, FunctionFlags, NativeFunction}, object::{Class, ClassBuilder, GcObject, Object, ObjectData, PROTOTYPE}, property::{Property, PropertyKey}, - value::{PreferredType, RcString, RcSymbol, Type, Value}, Console, Symbol, }, realm::Realm, @@ -36,6 +35,7 @@ use crate::{ constant::Const, node::{FormalParameter, Node, StatementList}, }, + value::{PreferredType, RcString, RcSymbol, Type, Value}, BoaProfiler, Result, }; use std::result::Result as StdResult; @@ -365,7 +365,7 @@ impl Interpreter { /// struct MyClass; /// /// impl Class for MyClass { - /// // ... + /// // ... /// } /// /// context.register_global_class::(); diff --git a/boa/src/exec/new/mod.rs b/boa/src/exec/new/mod.rs index eb038481576..476d5d576cb 100644 --- a/boa/src/exec/new/mod.rs +++ b/boa/src/exec/new/mod.rs @@ -1,5 +1,5 @@ use super::{Executable, Interpreter}; -use crate::{builtins::Value, syntax::ast::node::New, BoaProfiler, Result}; +use crate::{syntax::ast::node::New, BoaProfiler, Result, Value}; impl Executable for New { fn run(&self, interpreter: &mut Interpreter) -> Result { diff --git a/boa/src/exec/object/mod.rs b/boa/src/exec/object/mod.rs index ee0649b8755..26fa6ba0b83 100644 --- a/boa/src/exec/object/mod.rs +++ b/boa/src/exec/object/mod.rs @@ -2,10 +2,9 @@ use super::{Executable, Interpreter}; use crate::{ - builtins::value::Value, syntax::ast::node::MethodDefinitionKind, syntax::ast::node::{Object, PropertyDefinition}, - Result, + Result, Value, }; use std::borrow::Borrow; diff --git a/boa/src/exec/operator/mod.rs b/boa/src/exec/operator/mod.rs index 1a33b69b995..c96a7a7cde5 100644 --- a/boa/src/exec/operator/mod.rs +++ b/boa/src/exec/operator/mod.rs @@ -4,13 +4,12 @@ mod tests; use super::{Executable, Interpreter}; use crate::{ - builtins::value::Value, environment::lexical_environment::VariableScope, syntax::ast::{ node::{Assign, BinOp, Node, UnaryOp}, op::{self, AssignOp, BitOp, CompOp, LogOp, NumOp}, }, - BoaProfiler, Result, + BoaProfiler, Result, Value, }; impl Executable for Assign { diff --git a/boa/src/exec/return_smt/mod.rs b/boa/src/exec/return_smt/mod.rs index e77a072dd34..bd5e912f118 100644 --- a/boa/src/exec/return_smt/mod.rs +++ b/boa/src/exec/return_smt/mod.rs @@ -1,5 +1,5 @@ use super::{Executable, Interpreter, InterpreterState}; -use crate::{builtins::value::Value, syntax::ast::node::Return, Result}; +use crate::{syntax::ast::node::Return, Result, Value}; impl Executable for Return { fn run(&self, interpreter: &mut Interpreter) -> Result { diff --git a/boa/src/exec/spread/mod.rs b/boa/src/exec/spread/mod.rs index 20e0f9393c0..1c3d90e0426 100644 --- a/boa/src/exec/spread/mod.rs +++ b/boa/src/exec/spread/mod.rs @@ -1,5 +1,5 @@ use super::{Executable, Interpreter}; -use crate::{builtins::value::Value, syntax::ast::node::Spread, Result}; +use crate::{syntax::ast::node::Spread, Result, Value}; impl Executable for Spread { fn run(&self, interpreter: &mut Interpreter) -> Result { diff --git a/boa/src/exec/statement_list.rs b/boa/src/exec/statement_list.rs index df42d6e71fd..50229fb4fcd 100644 --- a/boa/src/exec/statement_list.rs +++ b/boa/src/exec/statement_list.rs @@ -1,7 +1,7 @@ //! Statement list execution. use super::{Executable, Interpreter, InterpreterState}; -use crate::{builtins::value::Value, syntax::ast::node::StatementList, BoaProfiler, Result}; +use crate::{syntax::ast::node::StatementList, BoaProfiler, Result, Value}; impl Executable for StatementList { fn run(&self, interpreter: &mut Interpreter) -> Result { diff --git a/boa/src/exec/switch/mod.rs b/boa/src/exec/switch/mod.rs index 7c5a66f358b..a145f2e7bd6 100644 --- a/boa/src/exec/switch/mod.rs +++ b/boa/src/exec/switch/mod.rs @@ -1,5 +1,5 @@ use super::{Executable, Interpreter, InterpreterState}; -use crate::{builtins::value::Value, syntax::ast::node::Switch, Result}; +use crate::{syntax::ast::node::Switch, Result, Value}; #[cfg(test)] mod tests; diff --git a/boa/src/exec/tests.rs b/boa/src/exec/tests.rs index d1b3feada82..8fa7d379bbf 100644 --- a/boa/src/exec/tests.rs +++ b/boa/src/exec/tests.rs @@ -1,10 +1,4 @@ -use crate::{ - builtins::{Number, Value}, - exec, - exec::Interpreter, - forward, forward_val, - realm::Realm, -}; +use crate::{builtins::Number, exec, exec::Interpreter, forward, forward_val, realm::Realm, Value}; #[test] fn function_declaration_returns_undefined() { @@ -1163,7 +1157,7 @@ fn array_creation_benchmark() { for (let a = 0; a <= 500; a++) { testArr[a] = ('p' + a); } - + return testArr; })(); "#; @@ -1193,11 +1187,11 @@ fn array_pop_benchmark() { 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28]; - + while (testArray.length > 0) { testArray.pop(); } - + return testArray; })(); "#; diff --git a/boa/src/exec/throw/mod.rs b/boa/src/exec/throw/mod.rs index ae66c9560d0..49761f95cbd 100644 --- a/boa/src/exec/throw/mod.rs +++ b/boa/src/exec/throw/mod.rs @@ -1,5 +1,5 @@ use super::{Executable, Interpreter}; -use crate::{builtins::value::Value, syntax::ast::node::Throw, Result}; +use crate::{syntax::ast::node::Throw, Result, Value}; impl Executable for Throw { #[inline] diff --git a/boa/src/exec/try_node/mod.rs b/boa/src/exec/try_node/mod.rs index fb909e2e39e..4981efcc8b3 100644 --- a/boa/src/exec/try_node/mod.rs +++ b/boa/src/exec/try_node/mod.rs @@ -2,10 +2,9 @@ use super::{Executable, Interpreter}; use crate::{ - builtins::value::Value, environment::lexical_environment::{new_declarative_environment, VariableScope}, syntax::ast::node::Try, - BoaProfiler, Result, + BoaProfiler, Result, Value, }; #[cfg(test)] diff --git a/boa/src/lib.rs b/boa/src/lib.rs index 209d88725d2..85eec438325 100644 --- a/boa/src/lib.rs +++ b/boa/src/lib.rs @@ -40,8 +40,9 @@ pub mod exec; pub mod profiler; pub mod realm; pub mod syntax; +pub mod value; -use crate::{builtins::value::Value, syntax::ast::node::StatementList}; +use crate::syntax::ast::node::StatementList; pub use crate::{ exec::{Executable, Interpreter}, profiler::BoaProfiler, @@ -50,6 +51,7 @@ pub use crate::{ lexer::Lexer, parser::{ParseError, Parser}, }, + value::Value, }; use std::result::Result as StdResult; diff --git a/boa/src/realm.rs b/boa/src/realm.rs index feaad72aa9e..81fc0e1a467 100644 --- a/boa/src/realm.rs +++ b/boa/src/realm.rs @@ -5,14 +5,13 @@ //! A realm is represented in this implementation as a Realm struct with the fields specified from the spec. use crate::{ - builtins::value::Value, environment::{ declarative_environment_record::DeclarativeEnvironmentRecord, global_environment_record::GlobalEnvironmentRecord, lexical_environment::LexicalEnvironment, object_environment_record::ObjectEnvironmentRecord, }, - BoaProfiler, + BoaProfiler, Value, }; use gc::{Gc, GcCell}; use rustc_hash::{FxHashMap, FxHashSet}; diff --git a/boa/src/builtins/value/conversions.rs b/boa/src/value/conversions.rs similarity index 100% rename from boa/src/builtins/value/conversions.rs rename to boa/src/value/conversions.rs diff --git a/boa/src/builtins/value/display.rs b/boa/src/value/display.rs similarity index 100% rename from boa/src/builtins/value/display.rs rename to boa/src/value/display.rs diff --git a/boa/src/builtins/value/equality.rs b/boa/src/value/equality.rs similarity index 100% rename from boa/src/builtins/value/equality.rs rename to boa/src/value/equality.rs diff --git a/boa/src/builtins/value/hash.rs b/boa/src/value/hash.rs similarity index 100% rename from boa/src/builtins/value/hash.rs rename to boa/src/value/hash.rs diff --git a/boa/src/builtins/value/mod.rs b/boa/src/value/mod.rs similarity index 99% rename from boa/src/builtins/value/mod.rs rename to boa/src/value/mod.rs index 145c15e619a..760fe2260e6 100644 --- a/boa/src/builtins/value/mod.rs +++ b/boa/src/value/mod.rs @@ -5,8 +5,8 @@ #[cfg(test)] mod tests; -use super::number::{f64_to_int32, f64_to_uint32}; use crate::builtins::{ + number::{f64_to_int32, f64_to_uint32}, object::{GcObject, Object, ObjectData, PROTOTYPE}, property::{Attribute, Property, PropertyKey}, BigInt, Number, @@ -641,7 +641,7 @@ impl Value { /// # Examples /// /// ``` - /// use boa::builtins::value::Value; + /// use boa::Value; /// /// let value = Value::number(3); /// diff --git a/boa/src/builtins/value/operations.rs b/boa/src/value/operations.rs similarity index 99% rename from boa/src/builtins/value/operations.rs rename to boa/src/value/operations.rs index 8afea841ca9..59942f1b5f0 100644 --- a/boa/src/builtins/value/operations.rs +++ b/boa/src/value/operations.rs @@ -1,8 +1,5 @@ use super::*; -use crate::builtins::{ - number::{f64_to_int32, f64_to_uint32, Number}, - value::PreferredType, -}; +use crate::builtins::number::{f64_to_int32, f64_to_uint32, Number}; impl Value { #[inline] diff --git a/boa/src/builtins/value/rcbigint.rs b/boa/src/value/rcbigint.rs similarity index 100% rename from boa/src/builtins/value/rcbigint.rs rename to boa/src/value/rcbigint.rs diff --git a/boa/src/builtins/value/rcstring.rs b/boa/src/value/rcstring.rs similarity index 100% rename from boa/src/builtins/value/rcstring.rs rename to boa/src/value/rcstring.rs diff --git a/boa/src/builtins/value/rcsymbol.rs b/boa/src/value/rcsymbol.rs similarity index 100% rename from boa/src/builtins/value/rcsymbol.rs rename to boa/src/value/rcsymbol.rs diff --git a/boa/src/builtins/value/tests.rs b/boa/src/value/tests.rs similarity index 100% rename from boa/src/builtins/value/tests.rs rename to boa/src/value/tests.rs diff --git a/boa/src/builtins/value/type.rs b/boa/src/value/type.rs similarity index 100% rename from boa/src/builtins/value/type.rs rename to boa/src/value/type.rs