Skip to content

Commit

Permalink
Added .construct_object() to interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Aug 5, 2020
1 parent 645c5b5 commit 532a22e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
26 changes: 13 additions & 13 deletions boa/src/builtins/symbol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,55 +152,55 @@ impl Symbol {
{
let mut symbol_object = symbol_object.as_object_mut().unwrap();
let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT;
symbol_object.define_own_property(
symbol_object.insert_property(
"asyncIterator",
Property::data_descriptor(symbol_async_iterator.into(), attribute),
);
symbol_object.define_own_property(
symbol_object.insert_property(
"hasInstance",
Property::data_descriptor(symbol_has_instance.into(), attribute),
);
symbol_object.define_own_property(
symbol_object.insert_property(
"isConcatSpreadable",
Property::data_descriptor(symbol_is_concat_spreadable.into(), attribute),
);
symbol_object.define_own_property(
symbol_object.insert_property(
"iterator",
Property::data_descriptor(symbol_iterator.into(), attribute),
);
symbol_object.define_own_property(
symbol_object.insert_property(
"match",
Property::data_descriptor(symbol_match.into(), attribute),
);
symbol_object.define_own_property(
symbol_object.insert_property(
"matchAll",
Property::data_descriptor(symbol_match_all.into(), attribute),
);
symbol_object.define_own_property(
symbol_object.insert_property(
"replace",
Property::data_descriptor(symbol_replace.into(), attribute),
);
symbol_object.define_own_property(
symbol_object.insert_property(
"search",
Property::data_descriptor(symbol_search.into(), attribute),
);
symbol_object.define_own_property(
symbol_object.insert_property(
"species",
Property::data_descriptor(symbol_species.into(), attribute),
);
symbol_object.define_own_property(
symbol_object.insert_property(
"split",
Property::data_descriptor(symbol_split.into(), attribute),
);
symbol_object.define_own_property(
symbol_object.insert_property(
"toPrimitive",
Property::data_descriptor(symbol_to_primitive.into(), attribute),
);
symbol_object.define_own_property(
symbol_object.insert_property(
"toStringTag",
Property::data_descriptor(symbol_to_string_tag.into(), attribute),
);
symbol_object.define_own_property(
symbol_object.insert_property(
"unscopables",
Property::data_descriptor(symbol_unscopables.into(), attribute),
);
Expand Down
8 changes: 7 additions & 1 deletion boa/src/exec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{
builtins::{
function::{Function as FunctionObject, FunctionBody, ThisMode},
number::{f64_to_int32, f64_to_uint32},
object::{Object, ObjectData, PROTOTYPE},
object::{GcObject, Object, ObjectData, PROTOTYPE},
property::PropertyKey,
value::{RcBigInt, RcString, RcSymbol, ResultValue, Type, Value},
BigInt, Console, Number, Symbol,
Expand Down Expand Up @@ -680,6 +680,12 @@ impl Interpreter {
pub fn construct_symbol(&mut self, description: Option<RcString>) -> RcSymbol {
RcSymbol::from(Symbol::new(self.generate_hash(), description))
}

/// Construct an empty object.
pub fn construct_object(&self) -> GcObject {
let object_prototype = self.global().get_field("Object").get_field(PROTOTYPE);
GcObject::new(Object::create(object_prototype))
}
}

impl Executable for Node {
Expand Down

0 comments on commit 532a22e

Please sign in to comment.