Code:
http://code.google.com/p/gpsee/source/browse/gpsee_modules.c#193
Our architecture is such that we have CommonJS 1.x modules, with each
module having it's own global object, as a sort of "module scope".
We then use a resolver on these module scope objects to allow module code
to resolve references to the real global object -- the one that the program
module runs, and owns Math, Array, etc.
JSRESOLVE_DECLARING helps us to decide *not* to proxy through the to "true"
global when the programmer uses 'var' to declare a variable which is scoped
to the module.
This strange set of circumstances arose because the JIT was penalizing us
for using a scope object which was not a global object in
JS_ExecuteScript(). Other scenarios have been considered to achieve the
same goal, but they all require re-writing the JS before executing it.
Wes