My apologies for posting this topic twice. The feedback in the v8 users 
group was that this is the way it is and I have to work around this 
limitation in the v8:

https://groups.google.com/d/msg/v8-users/iEfceRohiy8/di9yyoUPAgAJ

I'm still hoping that either there's a way to make this functionality work 
or may be it would be flagged as a bug because now I'm just using this 
magic number 10 to locate additional scripts and I would like a more robust 
way to identify scripts that wouldn't be affected when new internal v8 
scripts are added and this magic number jumps to some other offset. 

Thanks!

-- Original Post --

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

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" 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