Skip to content

Commit

Permalink
Moved src/value/rcstring.rs => src/string.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Jun 30, 2021
1 parent 2619f06 commit 937abfd
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 27 deletions.
4 changes: 2 additions & 2 deletions boa/src/builtins/console/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use crate::{
builtins::BuiltIn,
object::ObjectInitializer,
property::Attribute,
value::{display::display_obj, JsString, Value},
BoaProfiler, Context, Result,
value::{display::display_obj, Value},
BoaProfiler, Context, JsString, Result,
};
use rustc_hash::FxHashMap;
use std::time::SystemTime;
Expand Down
3 changes: 2 additions & 1 deletion boa/src/builtins/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
use crate::{
builtins::BuiltIn,
object::Object,
object::ObjectInitializer,
property::{Attribute, DataDescriptor, PropertyKey},
symbol::WellKnownSymbols,
value::IntegerOrInfinity,
BoaProfiler, Context, Result, Value,
};
use crate::{object::Object, symbol::WellKnownSymbols};
use serde::Serialize;
use serde_json::{self, ser::PrettyFormatter, Serializer, Value as JSONValue};

Expand Down
6 changes: 3 additions & 3 deletions boa/src/builtins/object/for_in_iterator.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::value::JsString;
use crate::{
builtins::{function::make_builtin_fn, iterable::create_iter_result_object},
gc::{Finalize, Trace},
object::{GcObject, ObjectData},
property::PropertyKey,
property::{Attribute, DataDescriptor},
BoaProfiler, Context, Result, Value,
symbol::WellKnownSymbols,
BoaProfiler, Context, JsString, Result, Value,
};
use crate::{property::PropertyKey, symbol::WellKnownSymbols};
use rustc_hash::FxHashSet;
use std::collections::VecDeque;

Expand Down
3 changes: 1 addition & 2 deletions boa/src/builtins/regexp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ use crate::{
object::{ConstructorBuilder, FunctionBuilder, GcObject, ObjectData, PROTOTYPE},
property::{Attribute, DataDescriptor},
symbol::WellKnownSymbols,
value::{JsString, Value},
BoaProfiler, Context, Result,
BoaProfiler, Context, JsString, Result, Value,
};
use regress::Regex;

Expand Down
3 changes: 1 addition & 2 deletions boa/src/builtins/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ use crate::{
object::{ConstructorBuilder, Object, ObjectData},
property::Attribute,
symbol::WellKnownSymbols,
value::{JsString, Value},
BoaProfiler, Context, Result,
BoaProfiler, Context, JsString, Result, Value,
};
use regress::Regex;
use std::{
Expand Down
5 changes: 1 addition & 4 deletions boa/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ use crate::{
},
Parser,
},
value::{JsString, Value},
BoaProfiler, Executable, Result,
BoaProfiler, Executable, JsString, Result, Value,
};

#[cfg(feature = "console")]
Expand Down Expand Up @@ -639,8 +638,6 @@ impl Context {
#[allow(clippy::unit_arg, clippy::drop_copy)]
#[inline]
pub fn eval<T: AsRef<[u8]>>(&mut self, src: T) -> Result<Value> {
println!("Size of JsString: {}", std::mem::size_of::<JsString>(),);
println!("Size of Value: {}", std::mem::size_of::<Value>(),);
let main_timer = BoaProfiler::global().start_event("Main", "Main");
let src_bytes: &[u8] = src.as_ref();

Expand Down
3 changes: 2 additions & 1 deletion boa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub mod object;
pub mod profiler;
pub mod property;
pub mod realm;
pub mod string;
pub mod symbol;
// syntax module has a lot of acronyms
#[allow(clippy::upper_case_acronyms)]
Expand All @@ -69,7 +70,7 @@ pub(crate) use crate::{exec::Executable, profiler::BoaProfiler};

// Export things to root level
#[doc(inline)]
pub use crate::{context::Context, value::Value};
pub use crate::{context::Context, string::JsString, value::Value};

use crate::syntax::{
ast::node::StatementList,
Expand Down
2 changes: 1 addition & 1 deletion boa/src/object/iter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{Object, PropertyDescriptor, PropertyKey};
use crate::{symbol::RcSymbol, value::JsString};
use crate::{symbol::RcSymbol, JsString};
use std::{collections::hash_map, iter::FusedIterator};

impl Object {
Expand Down
4 changes: 2 additions & 2 deletions boa/src/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use crate::{
gc::{Finalize, Trace},
property::{AccessorDescriptor, Attribute, DataDescriptor, PropertyDescriptor, PropertyKey},
symbol::RcSymbol,
value::{JsString, RcBigInt, Value},
BoaProfiler, Context,
value::{RcBigInt, Value},
BoaProfiler, Context, JsString,
};
use rustc_hash::FxHashMap;
use std::{
Expand Down
2 changes: 1 addition & 1 deletion boa/src/property/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
gc::{Finalize, Trace},
object::GcObject,
symbol::RcSymbol,
value::{JsString, Value},
JsString, Value,
};
use std::{convert::TryFrom, fmt};

Expand Down
4 changes: 2 additions & 2 deletions boa/src/value/rcstring.rs → boa/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Inner {
// Get offset into the string data.
let data = (*inner).data.as_mut_ptr();

debug_assert!(std::ptr::eq((inner as *mut u8).add(offset), data));
debug_assert!(std::ptr::eq(inner.cast::<u8>().add(offset), data));

// Copy string data into data offset.
copy_nonoverlapping(s.as_ptr(), data, s.len());
Expand Down Expand Up @@ -85,7 +85,7 @@ impl Inner {
// Get offset into the string data.
let data = (*inner).data.as_mut_ptr();

debug_assert!(std::ptr::eq((inner as *mut u8).add(offset), data));
debug_assert!(std::ptr::eq(inner.cast::<u8>().add(offset), data));

// Copy the two string data into data offset.
copy_nonoverlapping(x.as_ptr(), data, x.len());
Expand Down
2 changes: 1 addition & 1 deletion boa/src/symbol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod rcsymbol;

use crate::{
gc::{Finalize, Trace},
value::JsString,
JsString,
};
use std::{
cell::Cell,
Expand Down
4 changes: 1 addition & 3 deletions boa/src/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
object::{GcObject, Object, ObjectData},
property::{Attribute, DataDescriptor, PropertyDescriptor, PropertyKey},
symbol::{RcSymbol, WellKnownSymbols},
BoaProfiler, Context, Result,
BoaProfiler, Context, JsString, Result,
};
use gc::{Finalize, Trace};
use serde_json::{Number as JSONNumber, Value as JSONValue};
Expand All @@ -31,7 +31,6 @@ mod equality;
mod hash;
mod operations;
mod rcbigint;
mod rcstring;
mod r#type;

pub use conversions::*;
Expand All @@ -41,7 +40,6 @@ pub use hash::*;
pub use operations::*;
pub use r#type::Type;
pub use rcbigint::RcBigInt;
pub use rcstring::JsString;

/// A Javascript value
#[derive(Trace, Finalize, Debug, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions boa/src/vm/compilation.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use crate::{syntax::ast::Const, syntax::ast::Node, value::RcBigInt, value::RcString};
use crate::{syntax::ast::Const, syntax::ast::Node, value::RcBigInt, JsString};

#[derive(Debug, Default)]
/// The compiler struct holds all the instructions.
Expand All @@ -19,7 +19,7 @@ impl Compiler {
/// This specilaized method puts the string value in the pool then adds an instructions which points to the correct index
pub fn add_string_instruction<S>(&mut self, string: S)
where
S: Into<RcString>,
S: Into<JsString>,
{
let index = self.pool.len();
self.add_instruction(Instruction::String(index));
Expand Down

0 comments on commit 937abfd

Please sign in to comment.