src/jdk/nashorn/internal/objects/Global.java
Print this page
*** 410,419 ****
--- 410,427 ----
private static final MethodHandle EXIT = findOwnMH("exit", Object.class, Object.class, Object.class);
// initialized by nasgen
private static PropertyMap $nasgenmap$;
+ // context to which this global belongs to
+ private final Context context;
+
+ @Override
+ protected Context getContext() {
+ return context;
+ }
+
// performs initialization checks for Global constructor and returns the
// PropertyMap, if everything is fine.
private static PropertyMap checkAndGetMap(final Context context) {
// security check first
final SecurityManager sm = System.getSecurityManager();
*** 437,447 ****
*
* @param context the context
*/
public Global(final Context context) {
super(checkAndGetMap(context));
! this.setContext(context);
this.setIsScope();
final int cacheSize = context.getEnv()._class_cache_size;
if (cacheSize > 0) {
classCache = new ClassCache(cacheSize);
--- 445,455 ----
*
* @param context the context
*/
public Global(final Context context) {
super(checkAndGetMap(context));
! this.context = context;
this.setIsScope();
final int cacheSize = context.getEnv()._class_cache_size;
if (cacheSize > 0) {
classCache = new ClassCache(cacheSize);
*** 480,489 ****
--- 488,507 ----
}
// GlobalObject interface implementation
@Override
+ public boolean isOfContext(final Context context) {
+ return this.context == context;
+ }
+
+ @Override
+ public boolean isStrictContext() {
+ return context.getEnv()._strict;
+ }
+
+ @Override
public void initBuiltinObjects() {
if (this.builtinObject != null) {
// already initialized, just return
return;
}
*** 1763,1773 ****
// Nashorn extension: global.$ENV (scripting-mode-only)
if (System.getSecurityManager() == null) {
// do not fill $ENV if we have a security manager around
// Retrieve current state of ENV variables.
final ScriptObject env = newObject();
! env.putAll(System.getenv());
addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, env);
} else {
addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED);
}
--- 1781,1791 ----
// Nashorn extension: global.$ENV (scripting-mode-only)
if (System.getSecurityManager() == null) {
// do not fill $ENV if we have a security manager around
// Retrieve current state of ENV variables.
final ScriptObject env = newObject();
! env.putAll(System.getenv(), scriptEnv._strict);
addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, env);
} else {
addOwnProperty(ScriptingFunctions.ENV_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED);
}