javascript - V8: create new variable scope -
in javascript, when enter new function, new local variable scope. e.g. this:
function f() { var x = 42; // in our local variable scope // other code } i want same in v8. have other code string , compile via script::compile , run via script::run.
right now, create new context think total overkill. means have reinit globals in new context.
if understand correctly, want c++ side script run in new isolated context, assume because don't want accidentally aliasing or modifying global environment. in case, before execute code, this:
std::string sscopedcode = "(function(){" + syourcode + "})();" that ensure code in syourcode kept isolated other invocations might make.
Comments
Post a Comment