Skip to main content

numeric_hook

Function numeric_hook 

Source
pub fn numeric_hook(op: NumOp, a: &Value, b: &Value) -> Result<Value, String>
Expand description

Host callback for arithmetic fusevm cannot complete natively (a non-Int/ non-Float operand). Supplies JavaScript + concatenation and coercion.

Every operand is run through ToPrimitive FIRST (ECMA-262 13.15.3 for +, 13.6.3 for the other arithmetic ops, 13.10.1 for the relational ones), which is what invokes a user valueOf/Symbol.toPrimitive. It has to happen here rather than inside JsHost::arith, because calling back into JS re-enters the VM and arith runs under the host’s RefCell borrow.