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
[email protected]
http://groups.google.com/group/v8-users

Reply via email to