< prev index next >

src/jdk/nashorn/internal/objects/Global.java

Print this page




 988     }
 989 
 990     /**
 991      * Constructor
 992      *
 993      * @param context the context
 994      */
 995     public Global(final Context context) {
 996         super(checkAndGetMap(context));
 997         this.context = context;
 998         this.setIsScope();
 999         this.lexicalScope = context.getEnv()._es6 ? new LexicalScope(this) : null;
1000     }
1001 
1002     /**
1003      * Script access to "current" Global instance
1004      *
1005      * @return the global singleton
1006      */
1007     public static Global instance() {
1008         final Global global = Context.getGlobal();
1009         Objects.requireNonNull(global);
1010         return global;
1011     }
1012 
1013     private static Global instanceFrom(final Object self) {
1014         return self instanceof Global? (Global)self : instance();
1015     }
1016 
1017     /**
1018      * Check if we have a Global instance
1019      * @return true if one exists
1020      */
1021     public static boolean hasInstance() {
1022         return Context.getGlobal() != null;
1023     }
1024 
1025     /**
1026      * Script access to {@link ScriptEnvironment}
1027      *
1028      * @return the script environment
1029      */
1030     static ScriptEnvironment getEnv() {




 988     }
 989 
 990     /**
 991      * Constructor
 992      *
 993      * @param context the context
 994      */
 995     public Global(final Context context) {
 996         super(checkAndGetMap(context));
 997         this.context = context;
 998         this.setIsScope();
 999         this.lexicalScope = context.getEnv()._es6 ? new LexicalScope(this) : null;
1000     }
1001 
1002     /**
1003      * Script access to "current" Global instance
1004      *
1005      * @return the global singleton
1006      */
1007     public static Global instance() {
1008         return Objects.requireNonNull(Context.getGlobal());


1009     }
1010 
1011     private static Global instanceFrom(final Object self) {
1012         return self instanceof Global? (Global)self : instance();
1013     }
1014 
1015     /**
1016      * Check if we have a Global instance
1017      * @return true if one exists
1018      */
1019     public static boolean hasInstance() {
1020         return Context.getGlobal() != null;
1021     }
1022 
1023     /**
1024      * Script access to {@link ScriptEnvironment}
1025      *
1026      * @return the script environment
1027      */
1028     static ScriptEnvironment getEnv() {


< prev index next >