|
|
@ -6,7 +6,6 @@ use crate::{ |
|
|
|
function::{Function, FunctionFlags, NativeFunction}, |
|
|
|
function::{Function, FunctionFlags, NativeFunction}, |
|
|
|
iterable::IteratorPrototypes, |
|
|
|
iterable::IteratorPrototypes, |
|
|
|
symbol::{Symbol, WellKnownSymbols}, |
|
|
|
symbol::{Symbol, WellKnownSymbols}, |
|
|
|
Console, |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
class::{Class, ClassBuilder}, |
|
|
|
class::{Class, ClassBuilder}, |
|
|
|
exec::Interpreter, |
|
|
|
exec::Interpreter, |
|
|
@ -28,6 +27,9 @@ use crate::{ |
|
|
|
}; |
|
|
|
}; |
|
|
|
use std::result::Result as StdResult; |
|
|
|
use std::result::Result as StdResult; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "console")] |
|
|
|
|
|
|
|
use crate::builtins::console::Console; |
|
|
|
|
|
|
|
|
|
|
|
/// Store a builtin constructor (such as `Object`) and its corresponding prototype.
|
|
|
|
/// Store a builtin constructor (such as `Object`) and its corresponding prototype.
|
|
|
|
#[derive(Debug, Clone)] |
|
|
|
#[derive(Debug, Clone)] |
|
|
|
pub struct StandardConstructor { |
|
|
|
pub struct StandardConstructor { |
|
|
@ -172,6 +174,7 @@ pub struct Context { |
|
|
|
symbol_count: u32, |
|
|
|
symbol_count: u32, |
|
|
|
|
|
|
|
|
|
|
|
/// console object state.
|
|
|
|
/// console object state.
|
|
|
|
|
|
|
|
#[cfg(feature = "console")] |
|
|
|
console: Console, |
|
|
|
console: Console, |
|
|
|
|
|
|
|
|
|
|
|
/// Cached well known symbols
|
|
|
|
/// Cached well known symbols
|
|
|
@ -193,6 +196,7 @@ impl Default for Context { |
|
|
|
realm, |
|
|
|
realm, |
|
|
|
executor, |
|
|
|
executor, |
|
|
|
symbol_count, |
|
|
|
symbol_count, |
|
|
|
|
|
|
|
#[cfg(feature = "console")] |
|
|
|
console: Console::default(), |
|
|
|
console: Console::default(), |
|
|
|
well_known_symbols, |
|
|
|
well_known_symbols, |
|
|
|
iterator_prototypes: IteratorPrototypes::default(), |
|
|
|
iterator_prototypes: IteratorPrototypes::default(), |
|
|
@ -227,11 +231,13 @@ impl Context { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// A helper function for getting a immutable reference to the `console` object.
|
|
|
|
/// A helper function for getting a immutable reference to the `console` object.
|
|
|
|
|
|
|
|
#[cfg(feature = "console")] |
|
|
|
pub(crate) fn console(&self) -> &Console { |
|
|
|
pub(crate) fn console(&self) -> &Console { |
|
|
|
&self.console |
|
|
|
&self.console |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// A helper function for getting a mutable reference to the `console` object.
|
|
|
|
/// A helper function for getting a mutable reference to the `console` object.
|
|
|
|
|
|
|
|
#[cfg(feature = "console")] |
|
|
|
pub(crate) fn console_mut(&mut self) -> &mut Console { |
|
|
|
pub(crate) fn console_mut(&mut self) -> &mut Console { |
|
|
|
&mut self.console |
|
|
|
&mut self.console |
|
|
|
} |
|
|
|
} |
|
|
|