[−][src]Struct boa::Context
Javascript context. It is the primary way to interact with the runtime.
For each Context
instance a new instance of runtime is created.
It means that it is safe to use different contexts in different threads,
but each Context
instance must be used only from a single thread.
Implementations
impl Context
[src]
pub fn new() -> Self
[src]
Create a new Context
.
pub fn realm(&self) -> &Realm
[src]
pub fn realm_mut(&mut self) -> &mut Realm
[src]
pub fn executor(&mut self) -> &mut Interpreter
[src]
pub fn construct_symbol(&mut self, description: Option<RcString>) -> RcSymbol
[src]
Construct a new Symbol
with an optional description.
pub fn construct_object(&self) -> GcObject
[src]
Construct an empty object.
pub fn global_object(&self) -> &Value
[src]
Return the global object.
pub fn construct_range_error<M>(&mut self, message: M) -> Value where
M: Into<String>,
[src]
M: Into<String>,
Constructs a RangeError
with the specified message.
pub fn throw_range_error<M>(&mut self, message: M) -> Result<Value> where
M: Into<String>,
[src]
M: Into<String>,
Throws a RangeError
with the specified message.
pub fn construct_type_error<M>(&mut self, message: M) -> Value where
M: Into<String>,
[src]
M: Into<String>,
Constructs a TypeError
with the specified message.
pub fn throw_type_error<M>(&mut self, message: M) -> Result<Value> where
M: Into<String>,
[src]
M: Into<String>,
Throws a TypeError
with the specified message.
pub fn construct_reference_error<M>(&mut self, message: M) -> Value where
M: Into<String>,
[src]
M: Into<String>,
Constructs a ReferenceError
with the specified message.
pub fn throw_reference_error<M>(&mut self, message: M) -> Result<Value> where
M: Into<String>,
[src]
M: Into<String>,
Throws a ReferenceError
with the specified message.
pub fn construct_syntax_error<M>(&mut self, message: M) -> Value where
M: Into<String>,
[src]
M: Into<String>,
Constructs a SyntaxError
with the specified message.
pub fn throw_syntax_error<M>(&mut self, message: M) -> Result<Value> where
M: Into<String>,
[src]
M: Into<String>,
Throws a SyntaxError
with the specified message.
pub fn create_builtin_function(
&mut self,
name: &str,
length: usize,
body: NativeFunction
) -> Result<GcObject>
[src]
&mut self,
name: &str,
length: usize,
body: NativeFunction
) -> Result<GcObject>
Create a new builin function.
pub fn register_global_function(
&mut self,
name: &str,
length: usize,
body: NativeFunction
) -> Result<()>
[src]
&mut self,
name: &str,
length: usize,
body: NativeFunction
) -> Result<()>
Register a global function.
pub fn register_global_class<T>(&mut self) -> Result<()> where
T: Class,
[src]
T: Class,
Register a global class of type T
, where T
implemets Class
.
Example
#[derive(Debug, Trace, Finalize)] struct MyClass; impl Class for MyClass { // ... } context.register_global_class::<MyClass>();
pub fn eval(&mut self, src: &str) -> Result<Value>
[src]
Evaluates the given code.
Examples
let mut context = Context::new(); let value = context.eval("1 + 3").unwrap(); assert!(value.is_number()); assert_eq!(value.as_number().unwrap(), 4.0);
pub fn well_known_symbols(&self) -> &WellKnownSymbols
[src]
Returns a structure that contains the JavaScript well known symbols.
Examples
let mut context = Context::new(); let iterator = context.well_known_symbols().iterator_symbol(); assert_eq!(iterator.description(), Some("Symbol.iterator"));
This is equivalent to let iterator = Symbol.iterator
in JavaScript.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,