MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / eval

Function eval

crates/fuzzing/src/oracles/diff_v8.rs:273–292  ·  view source on GitHub ↗

Evaluates the JS `code` within `scope`, returning either the result of the computation or the stringified exception if one happened.

(scope: &mut v8::HandleScope<'s>, code: &str)

Source from the content-addressed store, hash-verified

271/// Evaluates the JS `code` within `scope`, returning either the result of the
272/// computation or the stringified exception if one happened.
273fn eval<'s>(scope: &mut v8::HandleScope<'s>, code: &str) -> Result<v8::Local<'s, v8::Value>> {
274 let mut tc = v8::TryCatch::new(scope);
275 let mut scope = v8::EscapableHandleScope::new(&mut tc);
276 let source = v8::String::new(&mut scope, code).unwrap();
277 let script = v8::Script::compile(&mut scope, source, None).unwrap();
278 match script.run(&mut scope) {
279 Some(val) => Ok(scope.escape(val)),
280 None => {
281 drop(scope);
282 assert!(tc.has_caught());
283 bail!(
284 "{}",
285 tc.message()
286 .unwrap()
287 .get(&mut tc)
288 .to_rust_string_lossy(&mut tc)
289 )
290 }
291 }
292}
293
294fn get_diff_value(
295 val: &v8::Local<'_, v8::Value>,

Callers 4

instantiateMethod · 0.85
evaluateMethod · 0.85
get_globalMethod · 0.85
get_memoryMethod · 0.85

Calls 6

OkFunction · 0.85
newFunction · 0.50
compileFunction · 0.50
dropFunction · 0.50
unwrapMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected