Struct sljs::function::CallContext
source · [−]pub struct CallContext {
pub this_ref: JSRef,
pub method_name: JSString,
pub arguments: Vec<Interpreted>,
pub loc: Option<Box<Location>>,
}
Expand description
Call context information (e.g. arguments) for Heap::execute()
.
Whenever you want to call a JS function, it needs to know:
arguments
this_ref
: whatthis
is for this call
The regular usage is:
let func_ref: JSRef = heap
.lookup_var("parseInt").expect("parseInt")
.to_ref(&heap).expect("to_ref");
let arguments = vec![ Interpreted::from("42") ];
let result = heap.execute( func_ref, CallContext::from(arguments)).expect("execute");
let result = result.to_value(&heap).unwrap();
assert_eq!(result, JSValue::from(42));
Fields
this_ref: JSRef
method_name: JSString
arguments: Vec<Interpreted>
loc: Option<Box<Location>>
Implementations
Trait Implementations
sourceimpl From<Vec<Interpreted, Global>> for CallContext
impl From<Vec<Interpreted, Global>> for CallContext
sourcefn from(arguments: Vec<Interpreted>) -> CallContext
fn from(arguments: Vec<Interpreted>) -> CallContext
Converts to this type from the input type.
Auto Trait Implementations
impl RefUnwindSafe for CallContext
impl !Send for CallContext
impl !Sync for CallContext
impl Unpin for CallContext
impl UnwindSafe for CallContext
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more