src/jdk/nashorn/tools/Shell.java
Print this page
*** 40,49 ****
--- 40,50 ----
import jdk.nashorn.api.scripting.NashornException;
import jdk.nashorn.internal.codegen.Compiler;
import jdk.nashorn.internal.ir.FunctionNode;
import jdk.nashorn.internal.ir.debug.ASTWriter;
import jdk.nashorn.internal.ir.debug.PrintVisitor;
+ import jdk.nashorn.internal.objects.Global;
import jdk.nashorn.internal.parser.Parser;
import jdk.nashorn.internal.runtime.Context;
import jdk.nashorn.internal.runtime.ErrorManager;
import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.Property;
*** 146,156 ****
final Context context = makeContext(in, out, err, args);
if (context == null) {
return COMMANDLINE_ERROR;
}
! final ScriptObject global = context.createGlobal();
final ScriptEnvironment env = context.getEnv();
final List<String> files = env.getFiles();
if (files.isEmpty()) {
return readEvalPrint(context, global);
}
--- 147,157 ----
final Context context = makeContext(in, out, err, args);
if (context == null) {
return COMMANDLINE_ERROR;
}
! final Global global = context.createGlobal();
final ScriptEnvironment env = context.getEnv();
final List<String> files = env.getFiles();
if (files.isEmpty()) {
return readEvalPrint(context, global);
}
*** 229,240 ****
* @param files the list of script files to compile
*
* @return error code
* @throws IOException when any script file read results in I/O error
*/
! private static int compileScripts(final Context context, final ScriptObject global, final List<String> files) throws IOException {
! final ScriptObject oldGlobal = Context.getGlobal();
final boolean globalChanged = (oldGlobal != global);
final ScriptEnvironment env = context.getEnv();
try {
if (globalChanged) {
Context.setGlobal(global);
--- 230,241 ----
* @param files the list of script files to compile
*
* @return error code
* @throws IOException when any script file read results in I/O error
*/
! private static int compileScripts(final Context context, final Global global, final List<String> files) throws IOException {
! final Global oldGlobal = Context.getGlobal();
final boolean globalChanged = (oldGlobal != global);
final ScriptEnvironment env = context.getEnv();
try {
if (globalChanged) {
Context.setGlobal(global);
*** 279,290 ****
* @param files the list of script files to run
*
* @return error code
* @throws IOException when any script file read results in I/O error
*/
! private int runScripts(final Context context, final ScriptObject global, final List<String> files) throws IOException {
! final ScriptObject oldGlobal = Context.getGlobal();
final boolean globalChanged = (oldGlobal != global);
try {
if (globalChanged) {
Context.setGlobal(global);
}
--- 280,291 ----
* @param files the list of script files to run
*
* @return error code
* @throws IOException when any script file read results in I/O error
*/
! private int runScripts(final Context context, final Global global, final List<String> files) throws IOException {
! final Global oldGlobal = Context.getGlobal();
final boolean globalChanged = (oldGlobal != global);
try {
if (globalChanged) {
Context.setGlobal(global);
}
*** 337,348 ****
* @param files the list of script files to provide
*
* @return error code
* @throws IOException when any script file read results in I/O error
*/
! private static int runFXScripts(final Context context, final ScriptObject global, final List<String> files) throws IOException {
! final ScriptObject oldGlobal = Context.getGlobal();
final boolean globalChanged = (oldGlobal != global);
try {
if (globalChanged) {
Context.setGlobal(global);
}
--- 338,349 ----
* @param files the list of script files to provide
*
* @return error code
* @throws IOException when any script file read results in I/O error
*/
! private static int runFXScripts(final Context context, final Global global, final List<String> files) throws IOException {
! final Global oldGlobal = Context.getGlobal();
final boolean globalChanged = (oldGlobal != global);
try {
if (globalChanged) {
Context.setGlobal(global);
}
*** 387,401 ****
* @param context the nashorn context
* @param global global scope object to use
* @return return code
*/
@SuppressWarnings("resource")
! private static int readEvalPrint(final Context context, final ScriptObject global) {
final String prompt = bundle.getString("shell.prompt");
final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
final PrintWriter err = context.getErr();
! final ScriptObject oldGlobal = Context.getGlobal();
final boolean globalChanged = (oldGlobal != global);
final ScriptEnvironment env = context.getEnv();
try {
if (globalChanged) {
--- 388,402 ----
* @param context the nashorn context
* @param global global scope object to use
* @return return code
*/
@SuppressWarnings("resource")
! private static int readEvalPrint(final Context context, final Global global) {
final String prompt = bundle.getString("shell.prompt");
final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
final PrintWriter err = context.getErr();
! final Global oldGlobal = Context.getGlobal();
final boolean globalChanged = (oldGlobal != global);
final ScriptEnvironment env = context.getEnv();
try {
if (globalChanged) {