Bug 887016 - Part 12: Implement RegExp[@@species] getter. r=evilpie
☠☠ backed out by 0bfefec1be82 ☠ ☠
authorTooru Fujisawa <arai_a@mac.com>
Sun, 25 Oct 2015 02:19:03 +0900
changeset 290630 716a5a6539d73d8d3fb70a354333b713beb1acdb
parent 290629 f373233a8c82941b6ca1dfca5fd62edb3ceae81a
child 290631 01da4d30fd114f532009a77acfc663fd54699502
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersevilpie
bugs887016
milestone48.0a1
Bug 887016 - Part 12: Implement RegExp[@@species] getter. r=evilpie
js/src/builtin/RegExp.cpp
js/src/builtin/RegExp.js
js/src/tests/ecma_6/Symbol/species.js
--- a/js/src/builtin/RegExp.cpp
+++ b/js/src/builtin/RegExp.cpp
@@ -742,16 +742,17 @@ const JSPropertySpec js::regexp_static_p
     JS_PSG("$7", static_paren7_getter, JSPROP_PERMANENT | JSPROP_ENUMERATE),
     JS_PSG("$8", static_paren8_getter, JSPROP_PERMANENT | JSPROP_ENUMERATE),
     JS_PSG("$9", static_paren9_getter, JSPROP_PERMANENT | JSPROP_ENUMERATE),
     JS_PSGS("$_", static_input_getter, static_input_setter, JSPROP_PERMANENT),
     JS_PSG("$&", static_lastMatch_getter, JSPROP_PERMANENT),
     JS_PSG("$+", static_lastParen_getter, JSPROP_PERMANENT),
     JS_PSG("$`", static_leftContext_getter, JSPROP_PERMANENT),
     JS_PSG("$'", static_rightContext_getter, JSPROP_PERMANENT),
+    JS_SELF_HOSTED_SYM_GET(species, "RegExpSpecies", 0),
     JS_PS_END
 };
 
 JSObject*
 js::CreateRegExpPrototype(JSContext* cx, JSProtoKey key)
 {
     MOZ_ASSERT(key == JSProto_RegExp);
 
--- a/js/src/builtin/RegExp.js
+++ b/js/src/builtin/RegExp.js
@@ -597,8 +597,14 @@ function RegExpTest(string) {
         ThrowTypeError(JSMSG_NOT_NONNULL_OBJECT, R === null ? "null" : typeof R);
 
     // Steps 3-4.
     var S = ToString(string);
 
     // Steps 5-6.
     return RegExpExec(R, S, true);
 }
+
+// ES 2016 draft Mar 25, 2016 21.2.4.2.
+function RegExpSpecies() {
+    // Step 1.
+    return this;
+}
--- a/js/src/tests/ecma_6/Symbol/species.js
+++ b/js/src/tests/ecma_6/Symbol/species.js
@@ -1,24 +1,24 @@
 var BUGNUMBER = 1131043;
 var summary = "Implement @@species getter for builtin types";
 
 print(BUGNUMBER + ": " + summary);
 
 var TypedArray = Object.getPrototypeOf(Int8Array);
 
-for (var C of [Array, Map, Set,
+for (var C of [Array, Map, Set, RegExp,
                Int8Array, Uint8Array, Uint8ClampedArray,
                Int16Array, Uint16Array, Int32Array, Uint32Array,
                Float32Array, Float64Array,
                ArrayBuffer]) {
   assertEq(C[Symbol.species], C);
 }
 
-for (C of [Array, Map, Set,
+for (C of [Array, Map, Set, RegExp,
            TypedArray,
            ArrayBuffer]) {
   var desc = Object.getOwnPropertyDescriptor(C, Symbol.species);
   assertDeepEq(Object.keys(desc).sort(), ["configurable", "enumerable", "get", "set"]);
   assertEq(desc.set, undefined);
   assertEq(desc.enumerable, false);
   assertEq(desc.configurable, true);
   assertEq(desc.get.apply(null), null);