return "global";
}
public static void exec(String includes[], String mainScript, Object[] args, Map<String, Object> globalVariables, ErrorReporter reporter) {
// Associate a new Context with this thread
Context cx = Context.enter();
cx.setErrorReporter(reporter);
try {
// Initialize the standard objects (Object, Function, etc.)
// This must be done before scripts can be executed.
RhinoRunner runner = new RhinoRunner();
cx.initStandardObjects(runner);
// Define some global functions particular to the BasicRhinoShell.
// Note
// that these functions are not part of ECMA.
String[] names = { "print", "load", "readFile", "warn", "getResourceAsStream" };
runner.defineFunctionProperties(names, RhinoRunner.class, ScriptableObject.DONTENUM);
for(String include : includes) {
runner.processSource(cx, include);
}
// Set up "arguments" in the global scope to contain the command
// line arguments after the name of the script to execute
Object[] array;
if (args.length == 0) {
array = new Object[0];
} else {
int length = args.length;
array = new Object[length];
System.arraycopy(args, 0, array, 0, length);
}
Scriptable argsObj = cx.newArray(runner, array);
runner.defineProperty("arguments", argsObj, ScriptableObject.DONTENUM);
for(String key : globalVariables.keySet()) {
runner.defineProperty(key, globalVariables.get( key ), ScriptableObject.DONTENUM);