code: @SuppressWarnings("static-access")
  	public static Object scope(Context cx, Scriptable thisObj, Object[] args,
              Function funObj) {
          if (args.length == 1) {
              Object arg = args[0];
              if (arg instanceof Wrapper) {
                  arg = ((Wrapper)arg).unwrap();
              }
              if (arg instanceof Bindings) {
                  ScriptContext ctx = new SimpleScriptContext();
                  ctx.setBindings((Bindings)arg, ScriptContext.ENGINE_SCOPE);
                  Scriptable res = new ExternalScriptable(ctx);
                  res.setPrototype(ScriptableObject.getObjectPrototype(thisObj));
                  res.setParentScope(ScriptableObject.getTopLevelScope(thisObj));
                  return res;
              }
          }
          return cx.getUndefinedValue();
      }
docs: The scope function creates a new JavaScript scope object
  with given Bindings object as backing store. This can be used
  to create a script scope based on arbitrary Bindings instance.
  For example, in webapp scenario, a 'page' level Bindings instance
  may be wrapped as a scope and code can be run in JavaScripe 'with'
  statement:
  
  var page = scope(pageBindings);
  with (page) {
  // code that uses page scope
  }