On Thu, May 31, 2018 at 1:00 AM, A.M. <[email protected]> wrote: > It seems that `ScriptCompiler::Source` ignores script ID when initialized > with the origin. For example, if I compile a script this way: > > v8::ScriptOrigin origin(scriptName, v8::Local<v8::Integer>(), > v8::Local<v8::Integer>(), v8::Local<v8::Boolean>(), > v8::Integer::New(isolate, scriptID)); > v8::ScriptCompiler::Source source(scriptText, origin, cached_data); > compiledScript = v8::ScriptCompiler::Compile(context, &source, > compile_options, no_cache_reason); > > When I catch an exception when running the compiled script, the script ID in > the message is always 10: > > if(try_catch.HasCaught()) { > v8::Local<v8::Integer> script_id = > try_catch.Message()->GetScriptOrigin().ScriptID(); > if(!script_id.IsEmpty()) { > scriptID = script_id->Int32Value(); // <-- always returns 10 for the > first script > > } > > Compiling multiple scripts increments the script ID for each subsequent > script and completely ignores the actual script ID in the origin. > > Looking at `ScriptCompiler::Source`, it appears that only some origin data > is kept and script ID is not tracked in `ScriptCompiler::Source`. Anybody > knows if it's a bug or there is a way to set script ID for compiled scripts? > > Thanks! > > Andre
Not a bug, as far as I'm aware. The GetScriptID() method exists because you can retrieve the ScriptOrigin of functions and exceptions* but newly compiled code is always assigned a new id. * Respectively v8::Function::GetScriptOrigin() and v8::Message::GetScriptOrigin(). -- -- 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.
