Changeset 9206

Show
Ignore:
Timestamp:
09/05/08 16:03:42 (3 months ago)
Author:
hannes
Message:

Use main script scope as prototype for shel scope if started with -i <script> so we can access the
script file's scope from the shell. Remove empty helma.cache module.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • helma-ng/trunk/src/org/helma/javascript/RhinoEngine.java

    r9194 r9206  
    5252    HelmaWrapFactory                   wrapFactory        = new HelmaWrapFactory(); 
    5353    HelmaContextFactory                contextFactory     = new HelmaContextFactory(this); 
     54    ModuleScope                        mainScope          = null; 
    5455 
    5556    public static final Object[]       EMPTY_ARGS         = new Object[0]; 
     
    183184            ReloadableScript script = new ReloadableScript(resource, this); 
    184185            scripts.put(resource, script); 
    185             Scriptable scope = new ModuleScope("__main__", resource, topLevelScope); 
    186             retval = script.evaluate(scope, cx); 
     186            mainScope = new ModuleScope("__main__", resource, topLevelScope); 
     187            retval = script.evaluate(mainScope, cx); 
    187188                if (retval instanceof Wrapper) { 
    188189                        return ((Wrapper) retval).unwrap(); 
     
    251252            Repository repository = repositories.get(0); 
    252253            Resource resource = repository.getResource("<shell>"); 
    253             ModuleScope scope = new ModuleScope("<shell>", resource, topLevelScope); 
     254            Scriptable parentScope = mainScope != null ? mainScope : topLevelScope; 
     255            ModuleScope scope = new ModuleScope("<shell>", resource, parentScope); 
    254256            try { 
    255257                getScript("helma.shell").evaluate(scope, cx);