I'm a bit confused.   I put a proper TryCatch around the 
CompileFunctionInContext and print the results there and I get a much 
better error:

0
myfile.js:74: SyntaxError: Unexpected identifier
do_stuff: function(stuff){
  ^^^^^^^^^^^^

because I'm missing a comma on the preceeding line.

But what the heck was going on before?


On Saturday, September 24, 2016 at 2:41:29 AM UTC-7, Zac Hansen wrote:
>
> I'm trying to take some user-provided code and pretend it's inside of a 
> function, which is what I 
> think v8::ScriptCompiler::CompileFunctionInContext is for.
>
> However, I have a syntax error in my javascript code, but when I get an 
> error message: 
>
> myfile.js:2079: Uncaught SyntaxError: Unexpected identifier
>
> there is no line 2079.  that specific file only has 372 lines and the 
> actual failure is probably around line 85 or so.  If I look at my 
> ScriptOrigin right before I start compiling, it all seems good with the 
> right filename, line, and column offsets (1, 0 respectively).
>
> printf("%s\n", *v8::String::Utf8Value(script_origin.ResourceName()));
> printf("%d\n", script_origin.ResourceLineOffset()->Value());
> printf("%d\n", script_origin.ResourceColumnOffset()->Value());
>
>
> v8::ScriptCompiler::Source source(v8::String::NewFromUtf8(isolate, 
> module_source.c_str()), script_origin);
> v8::Local<v8::String> parameter_names[] = {
>     v8::String::NewFromUtf8(isolate, "module"),
>     v8::String::NewFromUtf8(isolate, "exports")
> };
> auto maybe_module_function =
>     v8::ScriptCompiler::CompileFunctionInContext(context, &source, 2, 
> &parameter_names[0], 0, nullptr);
>
>
> Any ideas?
>

-- 
-- 
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