Before compilation of user supplied JS code(assuming you’re storing it as 
std::string), append the helper functions to it(which you might be reading from 
a file sitting in some predefined location) and finally compile the resultant 
std::string(in below snippet assuming “src” stores the resultant final string). 

Local<String> source = String::NewFromUtf8(isolate, src.c_str(), 
NewStringType::kNormal).ToLocalChecked();
Local<Script> script = Script::Compile(context, source).ToLocalChecked();
Local<Value> result = script->Run(context).ToLocalChecked();

You could refer to process.cc within V8 src, which does something similar 
amount various other things.


> On 06-Sep-2016, at 7:15 PM, Renier <[email protected]> wrote:
> 
> Are you saying I should compile each script in the context of where I will 
> run the user's js?
> 
> -- 
> -- 
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users 
> <http://groups.google.com/group/v8-users>
> --- 
> You received this message because you are subscribed to the Google Groups 
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to