Browse Source

Implement and use Interpreter::global()

pull/587/head
joshwd36 4 years ago
parent
commit
b437c9ff46
  1. 2
      boa/src/builtins/array/mod.rs
  2. 2
      boa/src/builtins/bigint/mod.rs
  3. 2
      boa/src/builtins/boolean/mod.rs
  4. 2
      boa/src/builtins/console/mod.rs
  5. 2
      boa/src/builtins/error/mod.rs
  6. 2
      boa/src/builtins/error/range.rs
  7. 2
      boa/src/builtins/error/reference.rs
  8. 2
      boa/src/builtins/error/syntax.rs
  9. 2
      boa/src/builtins/error/type.rs
  10. 2
      boa/src/builtins/function/mod.rs
  11. 2
      boa/src/builtins/global_this/mod.rs
  12. 2
      boa/src/builtins/json/mod.rs
  13. 2
      boa/src/builtins/map/mod.rs
  14. 2
      boa/src/builtins/math/mod.rs
  15. 2
      boa/src/builtins/mod.rs
  16. 2
      boa/src/builtins/number/mod.rs
  17. 2
      boa/src/builtins/object/mod.rs
  18. 2
      boa/src/builtins/regexp/mod.rs
  19. 2
      boa/src/builtins/string/mod.rs
  20. 2
      boa/src/builtins/symbol/mod.rs
  21. 2
      boa/src/builtins/value/mod.rs
  22. 5
      boa/src/exec/mod.rs

2
boa/src/builtins/array/mod.rs

@ -1115,7 +1115,7 @@ impl Array {
/// Initialise the `Array` object on the global object.
#[inline]
pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
// Create prototype

2
boa/src/builtins/bigint/mod.rs

@ -201,7 +201,7 @@ impl BigInt {
/// Initialise the `BigInt` object on the global object.
#[inline]
pub fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
let prototype = Value::new_object(Some(global));

2
boa/src/builtins/boolean/mod.rs

@ -99,7 +99,7 @@ impl Boolean {
/// Initialise the `Boolean` object on the global object.
#[inline]
pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
// Create Prototype

2
boa/src/builtins/console/mod.rs

@ -490,7 +490,7 @@ impl Console {
/// Initialise the `console` object on the global object.
#[inline]
pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
let console = Value::new_object(Some(global));

2
boa/src/builtins/error/mod.rs

@ -77,7 +77,7 @@ impl Error {
/// Initialise the global object with the `Error` object.
#[inline]
pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
let prototype = Value::new_object(Some(global));

2
boa/src/builtins/error/range.rs

@ -63,7 +63,7 @@ impl RangeError {
/// Initialise the global object with the `RangeError` object.
#[inline]
pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
let prototype = Value::new_object(Some(global));

2
boa/src/builtins/error/reference.rs

@ -61,7 +61,7 @@ impl ReferenceError {
/// Initialise the global object with the `ReferenceError` object.
pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
let prototype = Value::new_object(Some(global));

2
boa/src/builtins/error/syntax.rs

@ -65,7 +65,7 @@ impl SyntaxError {
/// Initialise the global object with the `SyntaxError` object.
#[inline]
pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
let prototype = Value::new_object(Some(global));

2
boa/src/builtins/error/type.rs

@ -69,7 +69,7 @@ impl TypeError {
/// Initialise the global object with the `RangeError` object.
#[inline]
pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
let prototype = Value::new_object(Some(global));

2
boa/src/builtins/function/mod.rs

@ -534,7 +534,7 @@ where
/// Initialise the `Function` object on the global object.
#[inline]
pub fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event("function", "init");
let prototype = Value::new_object(Some(global));

2
boa/src/builtins/global_this/mod.rs

@ -25,7 +25,7 @@ impl GlobalThis {
/// Initialize the `globalThis` property on the global object.
#[inline]
pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
(Self::NAME, global.clone())

2
boa/src/builtins/json/mod.rs

@ -173,7 +173,7 @@ impl Json {
/// Initialise the `JSON` object on the global object.
#[inline]
pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
let json = Value::new_object(Some(global));

2
boa/src/builtins/map/mod.rs

@ -285,7 +285,7 @@ impl Map {
/// Initialise the `Map` object on the global object.
pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
// Create prototype

2
boa/src/builtins/math/mod.rs

@ -698,7 +698,7 @@ impl Math {
/// Initialise the `Math` object on the global object.
#[inline]
pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
(Self::NAME, Self::create(global))

2
boa/src/builtins/mod.rs

@ -75,7 +75,7 @@ pub fn init(interpreter: &mut Interpreter) {
for init in &globals {
let (name, value) = init(interpreter);
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
match global {
Value::Object(ref global_object) => {
global_object.borrow_mut().insert_field(name, value);

2
boa/src/builtins/number/mod.rs

@ -728,7 +728,7 @@ impl Number {
/// Initialise the `Number` object on the global object.
#[inline]
pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
let prototype = Value::new_object(Some(global));

2
boa/src/builtins/object/mod.rs

@ -578,7 +578,7 @@ pub fn property_is_enumerable(this: &Value, args: &[Value], ctx: &mut Interprete
/// Initialise the `Object` object on the global object.
#[inline]
pub fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event("object", "init");
let prototype = Value::new_object(None);

2
boa/src/builtins/regexp/mod.rs

@ -493,7 +493,7 @@ impl RegExp {
/// Initialise the `RegExp` object on the global object.
#[inline]
pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
(Self::NAME, Self::create(global))

2
boa/src/builtins/string/mod.rs

@ -1024,7 +1024,7 @@ impl String {
/// Initialise the `String` object on the global object.
#[inline]
pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) {
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
// Create `String` `prototype`

2
boa/src/builtins/symbol/mod.rs

@ -133,7 +133,7 @@ impl Symbol {
interpreter.generate_hash(),
);
let global = &interpreter.realm.global_obj;
let global = interpreter.global();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
// Create prototype object

2
boa/src/builtins/value/mod.rs

@ -214,7 +214,7 @@ impl Value {
new_obj
}
JSONValue::Object(obj) => {
let new_obj = Value::new_object(Some(&interpreter.realm.global_obj));
let new_obj = Value::new_object(Some(interpreter.global()));
for (key, json) in obj.into_iter() {
let value = Self::from_json(json, interpreter);
new_obj.set_property(

5
boa/src/exec/mod.rs

@ -113,6 +113,11 @@ impl Interpreter {
&mut self.realm
}
#[inline]
pub(crate) fn global(&self) -> &Value {
&self.realm.global_obj
}
/// Generates a new `Symbol` internal hash.
///
/// This currently is an incremented value.

Loading…
Cancel
Save