src/jdk/nashorn/internal/runtime/ScriptEnvironment.java

Print this page




  39 import jdk.nashorn.internal.runtime.options.Option;
  40 import jdk.nashorn.internal.runtime.options.Options;
  41 
  42 /**
  43  * Script environment consists of command line options, arguments, script files
  44  * and output and error writers, top level Namespace etc.
  45  */
  46 public final class ScriptEnvironment {
  47     /** Output writer for this environment */
  48     private final PrintWriter out;
  49 
  50     /** Error writer for this environment */
  51     private final PrintWriter err;
  52 
  53     /** Top level namespace. */
  54     private final Namespace namespace;
  55 
  56     /** Current Options object. */
  57     private final Options options;
  58 
  59     /** Always allow functions as statements */
  60     public final boolean _anon_functions;
  61 
  62     /** Size of the per-global Class cache size */
  63     public final int     _class_cache_size;
  64 
  65     /** Only compile script, do not run it or generate other ScriptObjects */
  66     public final boolean _compile_only;
  67 
  68     /** Accumulated callsite flags that will be used when bootstrapping script callsites */
  69     public final int     _callsite_flags;
  70 
  71     /** Generate line number table in class files */
  72     public final boolean _debug_lines;
  73 
  74     /** Package to which generated class files are added */
  75     public final String  _dest_dir;
  76 
  77     /** Display stack trace upon error, default is false */
  78     public final boolean _dump_on_error;
  79 
  80     /** Invalid lvalue expressions should be reported as early errors */
  81     public final boolean _early_lvalue_error;


 175 
 176     /** time zone for this environment */
 177     public final TimeZone _timezone;
 178 
 179     /** Local for error messages */
 180     public final Locale _locale;
 181 
 182     /**
 183      * Constructor
 184      *
 185      * @param options a Options object
 186      * @param out output print writer
 187      * @param err error print writer
 188      */
 189     public ScriptEnvironment(final Options options, final PrintWriter out, final PrintWriter err) {
 190         this.out = out;
 191         this.err = err;
 192         this.namespace = new Namespace();
 193         this.options = options;
 194 
 195         _anon_functions       = options.getBoolean("anon.functions");
 196         _class_cache_size     = options.getInteger("class.cache.size");
 197         _compile_only         = options.getBoolean("compile.only");
 198         _debug_lines          = options.getBoolean("debug.lines");
 199         _dest_dir             = options.getString("d");
 200         _dump_on_error        = options.getBoolean("doe");
 201         _early_lvalue_error   = options.getBoolean("early.lvalue.error");
 202         _empty_statements     = options.getBoolean("empty.statements");
 203         _fullversion          = options.getBoolean("fullversion");
 204         if(options.getBoolean("function.statement.error")) {
 205             _function_statement = FunctionStatementBehavior.ERROR;
 206         } else if(options.getBoolean("function.statement.warning")) {
 207             _function_statement = FunctionStatementBehavior.WARNING;
 208         } else {
 209             _function_statement = FunctionStatementBehavior.ACCEPT;
 210         }
 211         _fx                   = options.getBoolean("fx");
 212         _lazy_compilation     = options.getBoolean("lazy.compilation");
 213         _loader_per_compile   = options.getBoolean("loader.per.compile");
 214         _no_syntax_extensions = options.getBoolean("no.syntax.extensions");
 215         _package              = options.getString("package");




  39 import jdk.nashorn.internal.runtime.options.Option;
  40 import jdk.nashorn.internal.runtime.options.Options;
  41 
  42 /**
  43  * Script environment consists of command line options, arguments, script files
  44  * and output and error writers, top level Namespace etc.
  45  */
  46 public final class ScriptEnvironment {
  47     /** Output writer for this environment */
  48     private final PrintWriter out;
  49 
  50     /** Error writer for this environment */
  51     private final PrintWriter err;
  52 
  53     /** Top level namespace. */
  54     private final Namespace namespace;
  55 
  56     /** Current Options object. */
  57     private final Options options;
  58 



  59     /** Size of the per-global Class cache size */
  60     public final int     _class_cache_size;
  61 
  62     /** Only compile script, do not run it or generate other ScriptObjects */
  63     public final boolean _compile_only;
  64 
  65     /** Accumulated callsite flags that will be used when bootstrapping script callsites */
  66     public final int     _callsite_flags;
  67 
  68     /** Generate line number table in class files */
  69     public final boolean _debug_lines;
  70 
  71     /** Package to which generated class files are added */
  72     public final String  _dest_dir;
  73 
  74     /** Display stack trace upon error, default is false */
  75     public final boolean _dump_on_error;
  76 
  77     /** Invalid lvalue expressions should be reported as early errors */
  78     public final boolean _early_lvalue_error;


 172 
 173     /** time zone for this environment */
 174     public final TimeZone _timezone;
 175 
 176     /** Local for error messages */
 177     public final Locale _locale;
 178 
 179     /**
 180      * Constructor
 181      *
 182      * @param options a Options object
 183      * @param out output print writer
 184      * @param err error print writer
 185      */
 186     public ScriptEnvironment(final Options options, final PrintWriter out, final PrintWriter err) {
 187         this.out = out;
 188         this.err = err;
 189         this.namespace = new Namespace();
 190         this.options = options;
 191 

 192         _class_cache_size     = options.getInteger("class.cache.size");
 193         _compile_only         = options.getBoolean("compile.only");
 194         _debug_lines          = options.getBoolean("debug.lines");
 195         _dest_dir             = options.getString("d");
 196         _dump_on_error        = options.getBoolean("doe");
 197         _early_lvalue_error   = options.getBoolean("early.lvalue.error");
 198         _empty_statements     = options.getBoolean("empty.statements");
 199         _fullversion          = options.getBoolean("fullversion");
 200         if(options.getBoolean("function.statement.error")) {
 201             _function_statement = FunctionStatementBehavior.ERROR;
 202         } else if(options.getBoolean("function.statement.warning")) {
 203             _function_statement = FunctionStatementBehavior.WARNING;
 204         } else {
 205             _function_statement = FunctionStatementBehavior.ACCEPT;
 206         }
 207         _fx                   = options.getBoolean("fx");
 208         _lazy_compilation     = options.getBoolean("lazy.compilation");
 209         _loader_per_compile   = options.getBoolean("loader.per.compile");
 210         _no_syntax_extensions = options.getBoolean("no.syntax.extensions");
 211         _package              = options.getString("package");