Skip to main content

JS_EvalThis

Function JS_EvalThis 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn JS_EvalThis( ctx: *mut JsContext, this_obj: JsValue, input: *const c_char, input_len: usize, filename: *const c_char, eval_flags: c_int, ) -> JsValue
Expand description

JS_EvalThis: evaluate with an explicit this.

The reference’s JS_EvalThis is JS_Eval with a receiver: inside the script, this is the object the host named instead of the global object. Everything else — which globals a var creates, whether a strict body starts strict, the pending-exception protocol — is JS_Eval’s, so this hands the value to the same evaluation path with one extra parameter rather than duplicating it.

A module evaluation ignores this_obj, as it must: a module has no receiver. That path answers JS_Eval’s own error for a module, which is the same message a host would get from JS_Eval with JS_EVAL_TYPE_MODULE.

§Safety

As crate::runtime::JS_Eval; this_obj must be a live JSValue, whose reference this call does not consume.