You can use v8::Compiler::CompileFunctionInContext. That way, you can pass 
in context extension objects.

Yang

On Friday, January 22, 2010 at 9:15:54 AM UTC+1, Andrey Semashev wrote:
>
> Hi,
>
> I'm trying to port my application (a VoiceXML interpreter) from
> Mozilla SpiderMonkey to v8. For ones not familiar with VoiceXML, the
> application allows to run JS scripts in one of the several nested
> scopes, which are represented as objects. The scopes are session,
> application, document and dialog, in order from outer to inner scopes.
> Now, if a script is run in document scope, it can access variables and
> functions from outer scopes unqualified, and all variables and
> functions it defines are created as subobjects of the document scope.
> When the scope is left, all its subobjects are deleted.
>
> In SpiderMonkey, I can specify parent objects on their creation, so I
> can create scope objects hierarchy with the API calls. Also, I can
> specify an object, on which to execute the script, which allows to
> execute it in the given scope. How can I achieve similar functionality
> in v8?
>
> A few words on what I have tried so far. I managed to construct the
> scopes hierarchy by creating properties in the Object interface.
> However, I could not figure out the way to specify these objects for
> Script to execute on. I tried to wrap scripts in a "with" construct,
> but although it solves the scopes visibility problem, it doesn't allow
> to create variables in the current scope. For example, if I run this
> script:
>
>   var a = new Object();
>   function foo() { return "hello"; }
>
> in the document scope, I want document.a and document.foo objects to
> be created. Wrapping it in a "with (document)" block doesn't give
> that.
>
> I'm sorry if I'm missing something obvious, I'm relatively new to v8
> and JavaScript in general. Any suggestions would be welcome.
>
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
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 v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to