src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeRegExp.java
Print this page
*** 76,98 ****
private NativeRegExp(final Global global) {
super(global.getRegExpPrototype(), $nasgenmap$);
this.globalObject = global;
}
! NativeRegExp(final String input, final String flagString, final Global global) {
! this(global);
try {
this.regexp = RegExpFactory.create(input, flagString);
} catch (final ParserException e) {
// translate it as SyntaxError object and throw it
e.throwAsEcmaException();
throw new AssertionError(); //guard against null warnings below
}
!
this.setLastIndex(0);
}
NativeRegExp(final String input, final String flagString) {
this(input, flagString, Global.instance());
}
NativeRegExp(final String string, final Global global) {
--- 76,102 ----
private NativeRegExp(final Global global) {
super(global.getRegExpPrototype(), $nasgenmap$);
this.globalObject = global;
}
! NativeRegExp(final String input, final String flagString, final Global global, final ScriptObject proto) {
! super(proto, $nasgenmap$);
try {
this.regexp = RegExpFactory.create(input, flagString);
} catch (final ParserException e) {
// translate it as SyntaxError object and throw it
e.throwAsEcmaException();
throw new AssertionError(); //guard against null warnings below
}
! this.globalObject = global;
this.setLastIndex(0);
}
+ NativeRegExp(final String input, final String flagString, final Global global) {
+ this(input, flagString, global, global.getRegExpPrototype());
+ }
+
NativeRegExp(final String input, final String flagString) {
this(input, flagString, Global.instance());
}
NativeRegExp(final String string, final Global global) {
*** 926,936 ****
private static NativeRegExp checkRegExp(final Object self) {
if (self instanceof NativeRegExp) {
return (NativeRegExp)self;
} else if (self != null && self == Global.instance().getRegExpPrototype()) {
! return Global.instance().DEFAULT_REGEXP;
} else {
throw typeError("not.a.regexp", ScriptRuntime.safeToString(self));
}
}
--- 930,940 ----
private static NativeRegExp checkRegExp(final Object self) {
if (self instanceof NativeRegExp) {
return (NativeRegExp)self;
} else if (self != null && self == Global.instance().getRegExpPrototype()) {
! return Global.instance().getDefaultRegExp();
} else {
throw typeError("not.a.regexp", ScriptRuntime.safeToString(self));
}
}