Hi Toon,
the second solution worked perfectly, thanks!
While with the first in the few quick tests I've made it looks that the
nested scope can see only a clone of the parent global and any subsequent
change happened to the parent global was not seed by the child.
Alberto
Il giorno mercoledì 6 maggio 2015 15:25:05 UTC+2, Toon Verwaest ha scritto:
>
> I'd say either install the parent global as prototype of the child global,
> or install a non-masking interceptor.
>
> In the first case you probably want to swap Object.prototype in the
> global's chain with the parent, but that means that the methods will come
> from the parent context.
>
> If you don't want that, you'll have to install a non-masking
> (PropertyHandlerFlags::kNonMasking) interceptor ("Property Handler") on
> your child global which accesses the "missing" local variable on the parent
> global.
> (see
> https://code.google.com/p/chromium/codesearch#chromium/src/v8/test/cctest/test-api-interceptors.cc&q=kNonMasking&sq=package:chromium&type=cs&l=3135).
>
> This matches your second idea as far as I can tell.
>
> Regards,
> Toon
>
> On Wed, May 6, 2015 at 3:17 PM Alberto Navatta <[email protected]
> <javascript:>> wrote:
>
>> 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] <javascript:>
>> 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] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
--
--
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.