We are evaluating the possibility to change the Javascript engine in our
application, switching from Mozilla Spidermonkey to Google V8.
We have some doubt about how to achieve on V8 one of the functionalities
required by our application using the JS Engine.
In our javascript domain we have several sessions each with multiple
javascript variable/object declared in nested scopes and we need to move
between session and scopes during application processing (so basically
under some circumstances we must evaluate variables at one level, under
other at a difference scope level in a specific session).
Scopes are nested, that means that in case one variable is not found in the
current scope the search continues in containing scope, if any.
To simplify let's say we have just a root scope and a child scope and that
we have a *console.log* function that just prints information.
// code executed in root scope
var rootVariable = 'this is root';
var simpleVar ='I am in root scope';
// code executed in child scope
var childVariable = 'this is child';
var simpleVar ='I am in child scope';
The expected behavior would be the following:
// code executed in root scope
console.log('Root = ' + rootVariable); // OUTPUT --> "Root = this is root"
console.log('Simple = ' + simpleVar); // OUTPUT --> "Simple = I am in root
scope"
console.log('CHILD = ' + childVariable); // OUTPUT --> triggers an
exception, childVariable is not defined in root scope
// code executed in child scope
console.log('ROOT = ' + rootVariable); // OUTPUT --> "ROOT = this is root"
console.log('Simple = ' + simpleVar); // OUTPUT --> "Simple = I am in child
scope"
console.log('CHILD = ' + childVariable); // OUTPUT --> "CHILD = this is
child"
We were unsuccessful to find an implementation model using V8 basic
functionalities (such as contextes and handle scopes) to satisfy our needs.
The subsequent idea we've worked on was to create some kind of relationship
among the two global objects of the two contextes corresponding to our
scopes (root and child). In theory what would be needed is:
1) to find a way to handle locally in the "child context global object" any
property/variable lookup
2) if the property lookup fails, to proxy the request to the parent (root
context global object)
Anyway we have a very little knowledge of V8 environment, any suggestion or
feedback about possible solutions would be very appreciated.
Alberto
--
--
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.