Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move value module from builtins to root #674

Merged
merged 1 commit into from
Sep 7, 2020
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: 2 additions & 2 deletions boa/examples/classes.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use boa::{
builtins::{property::Attribute, value::Value},
builtins::property::Attribute,
class::{Class, ClassBuilder},
exec::Interpreter,
forward_val,
realm::Realm,
Finalize, Result, Trace,
Finalize, Result, Trace, Value,
};

// We create a new struct that is going to represent a person.
Expand Down
2 changes: 1 addition & 1 deletion boa/src/builtins/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
5 changes: 1 addition & 4 deletions boa/src/builtins/bigint/conversions.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion boa/src/builtins/bigint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
6 changes: 1 addition & 5 deletions boa/src/builtins/boolean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion boa/src/builtins/boolean/tests.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
6 changes: 2 additions & 4 deletions boa/src/builtins/console/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions boa/src/builtins/console/tests.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
5 changes: 2 additions & 3 deletions boa/src/builtins/date/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
5 changes: 1 addition & 4 deletions boa/src/builtins/date/tests.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions boa/src/builtins/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions boa/src/builtins/error/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 2 additions & 4 deletions boa/src/builtins/error/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
6 changes: 2 additions & 4 deletions boa/src/builtins/error/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 2 additions & 4 deletions boa/src/builtins/error/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions boa/src/builtins/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, RcStatementList},
BoaProfiler, Result,
syntax::ast::node::{statement_list::RcStatementList, FormalParameter},
BoaProfiler, Result, Value,
};
use bitflags::bitflags;
use gc::{unsafe_empty_trace, Finalize, Trace};
Expand Down
2 changes: 1 addition & 1 deletion boa/src/builtins/global_this/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion boa/src/builtins/infinity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
3 changes: 1 addition & 2 deletions boa/src/builtins/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
6 changes: 2 additions & 4 deletions boa/src/builtins/json/tests.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
3 changes: 1 addition & 2 deletions boa/src/builtins/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 1 addition & 5 deletions boa/src/builtins/math/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 1 addition & 3 deletions boa/src/builtins/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion boa/src/builtins/nan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
3 changes: 1 addition & 2 deletions boa/src/builtins/number/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 4 additions & 5 deletions boa/src/builtins/object/gcobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

use super::{Object, PROTOTYPE};
use crate::{
builtins::{
function::{create_unmapped_arguments_object, BuiltInFunction, Function, NativeFunction},
Value,
builtins::function::{
create_unmapped_arguments_object, BuiltInFunction, Function, NativeFunction,
},
environment::{
function_environment_record::BindingStatus, lexical_environment::new_function_environment,
},
syntax::ast::node::statement_list::RcStatementList,
Executable, Interpreter, Result,
syntax::ast::node::RcStatementList,
Executable, Interpreter, Result, Value,
};
use gc::{Finalize, Gc, GcCell, GcCellRef, GcCellRefMut, Trace};
use std::{
Expand Down
11 changes: 6 additions & 5 deletions boa/src/builtins/object/internal_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
3 changes: 2 additions & 1 deletion boa/src/builtins/object/iter.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
7 changes: 2 additions & 5 deletions boa/src/builtins/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,20 @@

use crate::{
builtins::{
function::Function,
function::{make_builtin_fn, make_constructor_fn, Function},
map::ordered_map::OrderedMap,
property::{Property, PropertyKey},
value::{RcBigInt, RcString, RcSymbol, Value},
BigInt, Date, RegExp,
},
exec::Interpreter,
value::{same_value, RcBigInt, RcString, RcSymbol, Value},
BoaProfiler, Result,
};
use gc::{Finalize, Trace};
use rustc_hash::FxHashMap;
use std::fmt::{Debug, Display, Error, Formatter};
use std::{any::Any, result::Result as StdResult};

use super::function::{make_builtin_fn, make_constructor_fn};
use crate::builtins::value::same_value;

mod gcobject;
mod internal_methods;
mod iter;
Expand Down
4 changes: 1 addition & 3 deletions boa/src/builtins/property/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading