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

changeset 1267
e597c5975dac
parent 1028
d79265f2fa92
child 1490
d85f981c8cf8
child 1530
fd307cc5f58c
     1.1 --- a/src/jdk/nashorn/internal/objects/NativeRegExp.java	Tue Mar 24 13:59:31 2015 +0530
     1.2 +++ b/src/jdk/nashorn/internal/objects/NativeRegExp.java	Wed Mar 25 14:36:22 2015 +0530
     1.3 @@ -78,8 +78,8 @@
     1.4          this.globalObject = global;
     1.5      }
     1.6  
     1.7 -    NativeRegExp(final String input, final String flagString, final Global global) {
     1.8 -        this(global);
     1.9 +    NativeRegExp(final String input, final String flagString, final Global global, final ScriptObject proto) {
    1.10 +        super(proto, $nasgenmap$);
    1.11          try {
    1.12              this.regexp = RegExpFactory.create(input, flagString);
    1.13          } catch (final ParserException e) {
    1.14 @@ -87,8 +87,12 @@
    1.15              e.throwAsEcmaException();
    1.16              throw new AssertionError(); //guard against null warnings below
    1.17          }
    1.18 +        this.globalObject = global;
    1.19 +        this.setLastIndex(0);
    1.20 +    }
    1.21  
    1.22 -        this.setLastIndex(0);
    1.23 +    NativeRegExp(final String input, final String flagString, final Global global) {
    1.24 +        this(input, flagString, global, global.getRegExpPrototype());
    1.25      }
    1.26  
    1.27      NativeRegExp(final String input, final String flagString) {
    1.28 @@ -928,7 +932,7 @@
    1.29          if (self instanceof NativeRegExp) {
    1.30              return (NativeRegExp)self;
    1.31          } else if (self != null && self == Global.instance().getRegExpPrototype()) {
    1.32 -            return Global.instance().DEFAULT_REGEXP;
    1.33 +            return Global.instance().getDefaultRegExp();
    1.34          } else {
    1.35              throw typeError("not.a.regexp", ScriptRuntime.safeToString(self));
    1.36          }

mercurial