let isolate = &mut v8::Isolate::new(Default::default());
let mut client = InspectorClient::new();
let mut inspector = V8Inspector::create(isolate, &mut client);
let scope = &mut v8::HandleScope::new(isolate);
let context = v8::Context::new(scope);
let scope = &mut v8::ContextScope::new(scope, context);
inspector.context_created(context, 1, StringView::empty());
let mut result_strings: Vec<String> = Vec::new();
v8::String::new(scope, &code)
.map(|code| {
println!("code: {}", code.to_rust_string_lossy(scope));
code
})
.and_then(|code| v8::Script::compile(scope, code, None))
.and_then(|script| script.run(scope))
.and_then(|value| value.to_string(scope))
.iter()
.for_each(|value| {
result_strings.push(value.to_rust_string_lossy(scope));
});
let result = result_strings.join("\n");
println!("{}", result);