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

Print this page




  53 import jdk.nashorn.internal.runtime.ScriptRuntime;
  54 
  55 /**
  56  * ECMA 15.10 RegExp Objects.
  57  */
  58 @ScriptClass("RegExp")
  59 public final class NativeRegExp extends ScriptObject {
  60     /** ECMA 15.10.7.5 lastIndex property */
  61     @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
  62     public Object lastIndex;
  63 
  64     /** Compiled regexp */
  65     private RegExp regexp;
  66 
  67     // Reference to global object needed to support static RegExp properties
  68     private final Global globalObject;
  69 
  70     // initialized by nasgen
  71     private static PropertyMap $nasgenmap$;
  72 
  73     static PropertyMap getInitialMap() {
  74         return $nasgenmap$;
  75     }
  76 
  77     private NativeRegExp(final Global global) {
  78         super(global.getRegExpPrototype(), getInitialMap());
  79         this.globalObject = global;
  80     }
  81 
  82     NativeRegExp(final String input, final String flagString, final Global global) {
  83         this(global);
  84         try {
  85             this.regexp = RegExpFactory.create(input, flagString);
  86         } catch (final ParserException e) {
  87             // translate it as SyntaxError object and throw it
  88             e.throwAsEcmaException();
  89             throw new AssertionError(); //guard against null warnings below
  90         }
  91 
  92         this.setLastIndex(0);
  93     }
  94 
  95     NativeRegExp(final String input, final String flagString) {
  96         this(input, flagString, Global.instance());
  97     }
  98 




  53 import jdk.nashorn.internal.runtime.ScriptRuntime;
  54 
  55 /**
  56  * ECMA 15.10 RegExp Objects.
  57  */
  58 @ScriptClass("RegExp")
  59 public final class NativeRegExp extends ScriptObject {
  60     /** ECMA 15.10.7.5 lastIndex property */
  61     @Property(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
  62     public Object lastIndex;
  63 
  64     /** Compiled regexp */
  65     private RegExp regexp;
  66 
  67     // Reference to global object needed to support static RegExp properties
  68     private final Global globalObject;
  69 
  70     // initialized by nasgen
  71     private static PropertyMap $nasgenmap$;
  72 




  73     private NativeRegExp(final Global global) {
  74         super(global.getRegExpPrototype(), $nasgenmap$);
  75         this.globalObject = global;
  76     }
  77 
  78     NativeRegExp(final String input, final String flagString, final Global global) {
  79         this(global);
  80         try {
  81             this.regexp = RegExpFactory.create(input, flagString);
  82         } catch (final ParserException e) {
  83             // translate it as SyntaxError object and throw it
  84             e.throwAsEcmaException();
  85             throw new AssertionError(); //guard against null warnings below
  86         }
  87 
  88         this.setLastIndex(0);
  89     }
  90 
  91     NativeRegExp(final String input, final String flagString) {
  92         this(input, flagString, Global.instance());
  93     }
  94