Skip to content

Commit 13bc6b1

Browse files
committed
Rename RcSymbol to JsString
1 parent ad972f7 commit 13bc6b1

File tree

10 files changed

+136
-142
lines changed

10 files changed

+136
-142
lines changed

boa/src/builtins/symbol/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::{
2222
builtins::BuiltIn,
2323
object::{ConstructorBuilder, FunctionBuilder},
2424
property::Attribute,
25-
symbol::{RcSymbol, WellKnownSymbols},
25+
symbol::{JsSymbol, WellKnownSymbols},
2626
value::Value,
2727
BoaProfiler, Context, Result,
2828
};
@@ -130,10 +130,10 @@ impl Symbol {
130130
_ => None,
131131
};
132132

133-
Ok(context.construct_symbol(description).into())
133+
Ok(JsSymbol::new(description).into())
134134
}
135135

136-
fn this_symbol_value(value: &Value, context: &mut Context) -> Result<RcSymbol> {
136+
fn this_symbol_value(value: &Value, context: &mut Context) -> Result<JsSymbol> {
137137
match value {
138138
Value::Symbol(ref symbol) => return Ok(symbol.clone()),
139139
Value::Object(ref object) => {
@@ -161,8 +161,7 @@ impl Symbol {
161161
#[allow(clippy::wrong_self_convention)]
162162
pub(crate) fn to_string(this: &Value, _: &[Value], context: &mut Context) -> Result<Value> {
163163
let symbol = Self::this_symbol_value(this, context)?;
164-
let description = symbol.description().unwrap_or("");
165-
Ok(Value::from(format!("Symbol({})", description)))
164+
Ok(symbol.to_string().into())
166165
}
167166

168167
/// `get Symbol.prototype.description`
@@ -180,7 +179,8 @@ impl Symbol {
180179
_: &[Value],
181180
context: &mut Context,
182181
) -> Result<Value> {
183-
if let Some(ref description) = Self::this_symbol_value(this, context)?.description {
182+
let symbol = Self::this_symbol_value(this, context)?;
183+
if let Some(ref description) = symbol.description() {
184184
Ok(description.clone().into())
185185
} else {
186186
Ok(Value::undefined())

boa/src/context.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use crate::{
1111
object::{FunctionBuilder, GcObject, Object, PROTOTYPE},
1212
property::{Attribute, DataDescriptor, PropertyKey},
1313
realm::Realm,
14-
symbol::{RcSymbol, Symbol},
1514
syntax::{
1615
ast::{
1716
node::{
@@ -22,8 +21,7 @@ use crate::{
2221
},
2322
Parser,
2423
},
25-
value::{RcString, Value},
26-
BoaProfiler, Executable, Result,
24+
BoaProfiler, Executable, Result, Value,
2725
};
2826

2927
#[cfg(feature = "console")]
@@ -300,12 +298,6 @@ impl Context {
300298
builtins::init(self);
301299
}
302300

303-
/// Construct a new `Symbol` with an optional description.
304-
#[inline]
305-
pub fn construct_symbol(&mut self, description: Option<RcString>) -> RcSymbol {
306-
RcSymbol::from(Symbol::new(description))
307-
}
308-
309301
/// Construct an empty object.
310302
#[inline]
311303
pub fn construct_object(&self) -> GcObject {

boa/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub(crate) use crate::{exec::Executable, profiler::BoaProfiler};
6969

7070
// Export things to root level
7171
#[doc(inline)]
72-
pub use crate::{context::Context, value::Value};
72+
pub use crate::{context::Context, symbol::JsSymbol, value::Value};
7373

7474
use crate::syntax::{
7575
ast::node::StatementList,

boa/src/object/iter.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{Object, PropertyDescriptor, PropertyKey};
2-
use crate::{symbol::RcSymbol, value::RcString};
2+
use crate::{value::RcString, JsSymbol};
33
use std::{collections::hash_map, iter::FusedIterator};
44

55
impl Object {
@@ -110,7 +110,7 @@ impl Object {
110110
pub struct Iter<'a> {
111111
indexed_properties: hash_map::Iter<'a, u32, PropertyDescriptor>,
112112
string_properties: hash_map::Iter<'a, RcString, PropertyDescriptor>,
113-
symbol_properties: hash_map::Iter<'a, RcSymbol, PropertyDescriptor>,
113+
symbol_properties: hash_map::Iter<'a, JsSymbol, PropertyDescriptor>,
114114
}
115115

116116
impl<'a> Iterator for Iter<'a> {
@@ -180,10 +180,10 @@ impl FusedIterator for Values<'_> {}
180180

181181
/// An iterator over the `Symbol` property entries of an `Object`
182182
#[derive(Debug, Clone)]
183-
pub struct SymbolProperties<'a>(hash_map::Iter<'a, RcSymbol, PropertyDescriptor>);
183+
pub struct SymbolProperties<'a>(hash_map::Iter<'a, JsSymbol, PropertyDescriptor>);
184184

185185
impl<'a> Iterator for SymbolProperties<'a> {
186-
type Item = (&'a RcSymbol, &'a PropertyDescriptor);
186+
type Item = (&'a JsSymbol, &'a PropertyDescriptor);
187187

188188
#[inline]
189189
fn next(&mut self) -> Option<Self::Item> {
@@ -207,10 +207,10 @@ impl FusedIterator for SymbolProperties<'_> {}
207207

208208
/// An iterator over the keys (`RcSymbol`) of an `Object`.
209209
#[derive(Debug, Clone)]
210-
pub struct SymbolPropertyKeys<'a>(hash_map::Keys<'a, RcSymbol, PropertyDescriptor>);
210+
pub struct SymbolPropertyKeys<'a>(hash_map::Keys<'a, JsSymbol, PropertyDescriptor>);
211211

212212
impl<'a> Iterator for SymbolPropertyKeys<'a> {
213-
type Item = &'a RcSymbol;
213+
type Item = &'a JsSymbol;
214214

215215
#[inline]
216216
fn next(&mut self) -> Option<Self::Item> {
@@ -234,7 +234,7 @@ impl FusedIterator for SymbolPropertyKeys<'_> {}
234234

235235
/// An iterator over the `Symbol` values (`Property`) of an `Object`.
236236
#[derive(Debug, Clone)]
237-
pub struct SymbolPropertyValues<'a>(hash_map::Values<'a, RcSymbol, PropertyDescriptor>);
237+
pub struct SymbolPropertyValues<'a>(hash_map::Values<'a, JsSymbol, PropertyDescriptor>);
238238

239239
impl<'a> Iterator for SymbolPropertyValues<'a> {
240240
type Item = &'a PropertyDescriptor;

boa/src/object/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ use crate::{
1414
context::StandardConstructor,
1515
gc::{Finalize, Trace},
1616
property::{AccessorDescriptor, Attribute, DataDescriptor, PropertyDescriptor, PropertyKey},
17-
symbol::RcSymbol,
1817
value::{RcBigInt, RcString, Value},
19-
BoaProfiler, Context,
18+
BoaProfiler, Context, JsSymbol,
2019
};
2120
use rustc_hash::FxHashMap;
2221
use std::{
@@ -71,7 +70,7 @@ pub struct Object {
7170
/// Properties
7271
string_properties: FxHashMap<RcString, PropertyDescriptor>,
7372
/// Symbol Properties
74-
symbol_properties: FxHashMap<RcSymbol, PropertyDescriptor>,
73+
symbol_properties: FxHashMap<JsSymbol, PropertyDescriptor>,
7574
/// Instance prototype `__proto__`.
7675
prototype: Value,
7776
/// Whether it can have new properties added to it.
@@ -95,7 +94,7 @@ pub enum ObjectData {
9594
String(RcString),
9695
StringIterator(StringIterator),
9796
Number(f64),
98-
Symbol(RcSymbol),
97+
Symbol(JsSymbol),
9998
Error,
10099
Ordinary,
101100
Date(Date),
@@ -431,7 +430,7 @@ impl Object {
431430
}
432431

433432
#[inline]
434-
pub fn as_symbol(&self) -> Option<RcSymbol> {
433+
pub fn as_symbol(&self) -> Option<JsSymbol> {
435434
match self.data {
436435
ObjectData::Symbol(ref symbol) => Some(symbol.clone()),
437436
_ => None,

boa/src/property/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
use crate::{
1818
gc::{Finalize, Trace},
1919
object::GcObject,
20-
symbol::RcSymbol,
2120
value::{RcString, Value},
21+
JsSymbol,
2222
};
2323
use std::{convert::TryFrom, fmt};
2424

@@ -307,7 +307,7 @@ impl PropertyDescriptor {
307307
#[derive(Trace, Finalize, Debug, Clone)]
308308
pub enum PropertyKey {
309309
String(RcString),
310-
Symbol(RcSymbol),
310+
Symbol(JsSymbol),
311311
Index(u32),
312312
}
313313

@@ -355,9 +355,9 @@ impl From<Box<str>> for PropertyKey {
355355
}
356356
}
357357

358-
impl From<RcSymbol> for PropertyKey {
358+
impl From<JsSymbol> for PropertyKey {
359359
#[inline]
360-
fn from(symbol: RcSymbol) -> PropertyKey {
360+
fn from(symbol: JsSymbol) -> PropertyKey {
361361
PropertyKey::Symbol(symbol)
362362
}
363363
}

0 commit comments

Comments
 (0)