|
|
|
@ -100,7 +100,40 @@ impl Symbol {
|
|
|
|
|
|
|
|
|
|
/// Initialise the `Symbol` object on the global object.
|
|
|
|
|
#[inline] |
|
|
|
|
pub fn init(global: &Value) -> (&str, Value) { |
|
|
|
|
pub fn init(interpreter: &mut Interpreter) -> (&str, Value) { |
|
|
|
|
let symbol_async_iterator = Symbol( |
|
|
|
|
Some("Symbol.asyncIterator".into()), |
|
|
|
|
interpreter.generate_hash(), |
|
|
|
|
); |
|
|
|
|
let symbol_has_instance = Symbol( |
|
|
|
|
Some("Symbol.hasInstance".into()), |
|
|
|
|
interpreter.generate_hash(), |
|
|
|
|
); |
|
|
|
|
let symbol_is_concat_spreadable = Symbol( |
|
|
|
|
Some("Symbol.isConcatSpreadable".into()), |
|
|
|
|
interpreter.generate_hash(), |
|
|
|
|
); |
|
|
|
|
let symbol_iterator = Symbol(Some("Symbol.iterator".into()), interpreter.generate_hash()); |
|
|
|
|
let symbol_match = Symbol(Some("Symbol.match".into()), interpreter.generate_hash()); |
|
|
|
|
let symbol_match_all = Symbol(Some("Symbol.matchAll".into()), interpreter.generate_hash()); |
|
|
|
|
let symbol_replace = Symbol(Some("Symbol.replace".into()), interpreter.generate_hash()); |
|
|
|
|
let symbol_search = Symbol(Some("Symbol.search".into()), interpreter.generate_hash()); |
|
|
|
|
let symbol_species = Symbol(Some("Symbol.species".into()), interpreter.generate_hash()); |
|
|
|
|
let symbol_split = Symbol(Some("Symbol.split".into()), interpreter.generate_hash()); |
|
|
|
|
let symbol_to_primitive = Symbol( |
|
|
|
|
Some("Symbol.toPrimitive".into()), |
|
|
|
|
interpreter.generate_hash(), |
|
|
|
|
); |
|
|
|
|
let symbol_to_string_tag = Symbol( |
|
|
|
|
Some("Symbol.toStringTag".into()), |
|
|
|
|
interpreter.generate_hash(), |
|
|
|
|
); |
|
|
|
|
let symbol_unscopables = Symbol( |
|
|
|
|
Some("Symbol.unscopables".into()), |
|
|
|
|
interpreter.generate_hash(), |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
let global = &interpreter.realm.global_obj; |
|
|
|
|
let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); |
|
|
|
|
|
|
|
|
|
// Create prototype object
|
|
|
|
@ -118,6 +151,23 @@ impl Symbol {
|
|
|
|
|
true, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
symbol_object.set_field("asyncIterator", Value::symbol(symbol_async_iterator)); |
|
|
|
|
symbol_object.set_field("hasInstance", Value::symbol(symbol_has_instance)); |
|
|
|
|
symbol_object.set_field( |
|
|
|
|
"isConcatSpreadable", |
|
|
|
|
Value::symbol(symbol_is_concat_spreadable), |
|
|
|
|
); |
|
|
|
|
symbol_object.set_field("iterator", Value::symbol(symbol_iterator)); |
|
|
|
|
symbol_object.set_field("match", Value::symbol(symbol_match)); |
|
|
|
|
symbol_object.set_field("matchAll", Value::symbol(symbol_match_all)); |
|
|
|
|
symbol_object.set_field("replace", Value::symbol(symbol_replace)); |
|
|
|
|
symbol_object.set_field("search", Value::symbol(symbol_search)); |
|
|
|
|
symbol_object.set_field("species", Value::symbol(symbol_species)); |
|
|
|
|
symbol_object.set_field("split", Value::symbol(symbol_split)); |
|
|
|
|
symbol_object.set_field("toPrimitive", Value::symbol(symbol_to_primitive)); |
|
|
|
|
symbol_object.set_field("toStringTag", Value::symbol(symbol_to_string_tag)); |
|
|
|
|
symbol_object.set_field("unscopables", Value::symbol(symbol_unscopables)); |
|
|
|
|
|
|
|
|
|
(Self::NAME, symbol_object) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|