Commit 299b369c authored by marja's avatar marja Committed by Commit bot

Split --harmony-unicode and --harmony-unicode-regexps.

This way we can ship \u{..} escapes in strings / identifiers before shipping /u
regexps.

BUG=

Review URL: https://codereview.chromium.org/903703002

Cr-Commit-Position: refs/heads/master@{#26461}
parent d21b9a14
...@@ -1596,6 +1596,7 @@ EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring) ...@@ -1596,6 +1596,7 @@ EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_templates) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_templates)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters)
...@@ -1627,6 +1628,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tostring) ...@@ -1627,6 +1628,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tostring)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_templates) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_templates)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters)
...@@ -1642,14 +1644,15 @@ void Genesis::InitializeGlobal_harmony_regexps() { ...@@ -1642,14 +1644,15 @@ void Genesis::InitializeGlobal_harmony_regexps() {
} }
void Genesis::InitializeGlobal_harmony_unicode() { void Genesis::InitializeGlobal_harmony_unicode_regexps() {
Handle<JSObject> builtins(native_context()->builtins()); Handle<JSObject> builtins(native_context()->builtins());
Handle<HeapObject> flag(FLAG_harmony_unicode ? heap()->true_value() Handle<HeapObject> flag(FLAG_harmony_unicode_regexps ? heap()->true_value()
: heap()->false_value()); : heap()->false_value());
PropertyAttributes attributes = PropertyAttributes attributes =
static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
Runtime::DefineObjectProperty(builtins, factory()->harmony_unicode_string(), Runtime::DefineObjectProperty(builtins,
factory()->harmony_unicode_regexps_string(),
flag, attributes).Assert(); flag, attributes).Assert();
} }
...@@ -2209,6 +2212,7 @@ bool Genesis::InstallExperimentalNatives() { ...@@ -2209,6 +2212,7 @@ bool Genesis::InstallExperimentalNatives() {
"native harmony-templates.js", NULL}; "native harmony-templates.js", NULL};
static const char* harmony_sloppy_natives[] = {NULL}; static const char* harmony_sloppy_natives[] = {NULL};
static const char* harmony_unicode_natives[] = {NULL}; static const char* harmony_unicode_natives[] = {NULL};
static const char* harmony_unicode_regexps_natives[] = {NULL};
static const char* harmony_computed_property_names_natives[] = {NULL}; static const char* harmony_computed_property_names_natives[] = {NULL};
static const char* harmony_rest_parameters_natives[] = {NULL}; static const char* harmony_rest_parameters_natives[] = {NULL};
......
...@@ -177,15 +177,16 @@ DEFINE_IMPLICATION(harmony, es_staging) ...@@ -177,15 +177,16 @@ DEFINE_IMPLICATION(harmony, es_staging)
DEFINE_IMPLICATION(es_staging, harmony) DEFINE_IMPLICATION(es_staging, harmony)
// Features that are still work in progress (behind individual flags). // Features that are still work in progress (behind individual flags).
#define HARMONY_INPROGRESS(V) \ #define HARMONY_INPROGRESS(V) \
V(harmony_modules, "harmony modules (implies block scoping)") \ V(harmony_modules, "harmony modules (implies block scoping)") \
V(harmony_arrays, "harmony array methods") \ V(harmony_arrays, "harmony array methods") \
V(harmony_array_includes, "harmony Array.prototype.includes") \ V(harmony_array_includes, "harmony Array.prototype.includes") \
V(harmony_regexps, "harmony regular expression extensions") \ V(harmony_regexps, "harmony regular expression extensions") \
V(harmony_arrow_functions, "harmony arrow functions") \ V(harmony_arrow_functions, "harmony arrow functions") \
V(harmony_proxies, "harmony proxies") \ V(harmony_proxies, "harmony proxies") \
V(harmony_sloppy, "harmony features in sloppy mode") \ V(harmony_sloppy, "harmony features in sloppy mode") \
V(harmony_unicode, "harmony unicode escapes") \ V(harmony_unicode, "harmony unicode escapes") \
V(harmony_unicode_regexps, "harmony unicode regexps") \
V(harmony_computed_property_names, "harmony computed property names") \ V(harmony_computed_property_names, "harmony computed property names") \
V(harmony_rest_parameters, "harmony rest parameters") V(harmony_rest_parameters, "harmony rest parameters")
...@@ -231,6 +232,7 @@ HARMONY_SHIPPING(FLAG_SHIPPING_FEATURES) ...@@ -231,6 +232,7 @@ HARMONY_SHIPPING(FLAG_SHIPPING_FEATURES)
DEFINE_IMPLICATION(harmony_modules, harmony_scoping) DEFINE_IMPLICATION(harmony_modules, harmony_scoping)
DEFINE_IMPLICATION(harmony_classes, harmony_scoping) DEFINE_IMPLICATION(harmony_classes, harmony_scoping)
DEFINE_IMPLICATION(harmony_classes, harmony_object_literals) DEFINE_IMPLICATION(harmony_classes, harmony_object_literals)
DEFINE_IMPLICATION(harmony_unicode_regexps, harmony_unicode)
// Flags for experimental implementation features. // Flags for experimental implementation features.
......
This diff is collapsed.
...@@ -4631,7 +4631,7 @@ RegExpTree* RegExpParser::ParseDisjunction() { ...@@ -4631,7 +4631,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
// If the 'u' flag is present, only syntax characters can be escaped, // If the 'u' flag is present, only syntax characters can be escaped,
// no other identity escapes are allowed. If the 'u' flag is not // no other identity escapes are allowed. If the 'u' flag is not
// present, all identity escapes are allowed. // present, all identity escapes are allowed.
if (!FLAG_harmony_unicode || !unicode_) { if (!FLAG_harmony_unicode_regexps || !unicode_) {
builder->AddCharacter(first_digit); builder->AddCharacter(first_digit);
Advance(2); Advance(2);
} else { } else {
...@@ -4692,7 +4692,7 @@ RegExpTree* RegExpParser::ParseDisjunction() { ...@@ -4692,7 +4692,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
uc32 value; uc32 value;
if (ParseHexEscape(2, &value)) { if (ParseHexEscape(2, &value)) {
builder->AddCharacter(value); builder->AddCharacter(value);
} else if (!FLAG_harmony_unicode || !unicode_) { } else if (!FLAG_harmony_unicode_regexps || !unicode_) {
builder->AddCharacter('x'); builder->AddCharacter('x');
} else { } else {
// If the 'u' flag is present, invalid escapes are not treated as // If the 'u' flag is present, invalid escapes are not treated as
...@@ -4706,7 +4706,7 @@ RegExpTree* RegExpParser::ParseDisjunction() { ...@@ -4706,7 +4706,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
uc32 value; uc32 value;
if (ParseUnicodeEscape(&value)) { if (ParseUnicodeEscape(&value)) {
builder->AddCharacter(value); builder->AddCharacter(value);
} else if (!FLAG_harmony_unicode || !unicode_) { } else if (!FLAG_harmony_unicode_regexps || !unicode_) {
builder->AddCharacter('u'); builder->AddCharacter('u');
} else { } else {
// If the 'u' flag is present, invalid escapes are not treated as // If the 'u' flag is present, invalid escapes are not treated as
...@@ -4720,7 +4720,7 @@ RegExpTree* RegExpParser::ParseDisjunction() { ...@@ -4720,7 +4720,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
// If the 'u' flag is present, only syntax characters can be escaped, no // If the 'u' flag is present, only syntax characters can be escaped, no
// other identity escapes are allowed. If the 'u' flag is not present, // other identity escapes are allowed. If the 'u' flag is not present,
// all identity escapes are allowed. // all identity escapes are allowed.
if (!FLAG_harmony_unicode || !unicode_ || if (!FLAG_harmony_unicode_regexps || !unicode_ ||
IsSyntaxCharacter(current())) { IsSyntaxCharacter(current())) {
builder->AddCharacter(current()); builder->AddCharacter(current());
Advance(); Advance();
...@@ -4991,7 +4991,7 @@ bool RegExpParser::ParseUnicodeEscape(uc32* value) { ...@@ -4991,7 +4991,7 @@ bool RegExpParser::ParseUnicodeEscape(uc32* value) {
// Accept both \uxxxx and \u{xxxxxx} (if harmony unicode escapes are // Accept both \uxxxx and \u{xxxxxx} (if harmony unicode escapes are
// allowed). In the latter case, the number of hex digits between { } is // allowed). In the latter case, the number of hex digits between { } is
// arbitrary. \ and u have already been read. // arbitrary. \ and u have already been read.
if (current() == '{' && FLAG_harmony_unicode && unicode_) { if (current() == '{' && FLAG_harmony_unicode_regexps && unicode_) {
int start = position(); int start = position();
Advance(); Advance();
if (ParseUnlimitedLengthHexNumber(0x10ffff, value)) { if (ParseUnlimitedLengthHexNumber(0x10ffff, value)) {
...@@ -5081,7 +5081,7 @@ uc32 RegExpParser::ParseClassCharacterEscape() { ...@@ -5081,7 +5081,7 @@ uc32 RegExpParser::ParseClassCharacterEscape() {
if (ParseHexEscape(2, &value)) { if (ParseHexEscape(2, &value)) {
return value; return value;
} }
if (!FLAG_harmony_unicode || !unicode_) { if (!FLAG_harmony_unicode_regexps || !unicode_) {
// If \x is not followed by a two-digit hexadecimal, treat it // If \x is not followed by a two-digit hexadecimal, treat it
// as an identity escape. // as an identity escape.
return 'x'; return 'x';
...@@ -5097,7 +5097,7 @@ uc32 RegExpParser::ParseClassCharacterEscape() { ...@@ -5097,7 +5097,7 @@ uc32 RegExpParser::ParseClassCharacterEscape() {
if (ParseUnicodeEscape(&value)) { if (ParseUnicodeEscape(&value)) {
return value; return value;
} }
if (!FLAG_harmony_unicode || !unicode_) { if (!FLAG_harmony_unicode_regexps || !unicode_) {
return 'u'; return 'u';
} }
// If the 'u' flag is present, invalid escapes are not treated as // If the 'u' flag is present, invalid escapes are not treated as
...@@ -5110,7 +5110,8 @@ uc32 RegExpParser::ParseClassCharacterEscape() { ...@@ -5110,7 +5110,8 @@ uc32 RegExpParser::ParseClassCharacterEscape() {
// If the 'u' flag is present, only syntax characters can be escaped, no // If the 'u' flag is present, only syntax characters can be escaped, no
// other identity escapes are allowed. If the 'u' flag is not present, all // other identity escapes are allowed. If the 'u' flag is not present, all
// identity escapes are allowed. // identity escapes are allowed.
if (!FLAG_harmony_unicode || !unicode_ || IsSyntaxCharacter(result)) { if (!FLAG_harmony_unicode_regexps || !unicode_ ||
IsSyntaxCharacter(result)) {
Advance(); Advance();
return result; return result;
} }
......
...@@ -22,7 +22,7 @@ function DoConstructRegExp(object, pattern, flags) { ...@@ -22,7 +22,7 @@ function DoConstructRegExp(object, pattern, flags) {
flags = (pattern.global ? 'g' : '') flags = (pattern.global ? 'g' : '')
+ (pattern.ignoreCase ? 'i' : '') + (pattern.ignoreCase ? 'i' : '')
+ (pattern.multiline ? 'm' : ''); + (pattern.multiline ? 'm' : '');
if (harmony_unicode) if (harmony_unicode_regexps)
flags += (pattern.unicode ? 'u' : ''); flags += (pattern.unicode ? 'u' : '');
if (harmony_regexps) if (harmony_regexps)
flags += (pattern.sticky ? 'y' : ''); flags += (pattern.sticky ? 'y' : '');
...@@ -237,7 +237,7 @@ function RegExpToString() { ...@@ -237,7 +237,7 @@ function RegExpToString() {
if (this.global) result += 'g'; if (this.global) result += 'g';
if (this.ignoreCase) result += 'i'; if (this.ignoreCase) result += 'i';
if (this.multiline) result += 'm'; if (this.multiline) result += 'm';
if (harmony_unicode && this.unicode) result += 'u'; if (harmony_unicode_regexps && this.unicode) result += 'u';
if (harmony_regexps && this.sticky) result += 'y'; if (harmony_regexps && this.sticky) result += 'y';
return result; return result;
} }
......
...@@ -819,7 +819,7 @@ static JSRegExp::Flags RegExpFlagsFromString(Handle<String> flags, ...@@ -819,7 +819,7 @@ static JSRegExp::Flags RegExpFlagsFromString(Handle<String> flags,
flag = JSRegExp::MULTILINE; flag = JSRegExp::MULTILINE;
break; break;
case 'u': case 'u':
if (!FLAG_harmony_unicode) return JSRegExp::Flags(0); if (!FLAG_harmony_unicode_regexps) return JSRegExp::Flags(0);
flag = JSRegExp::UNICODE_ESCAPES; flag = JSRegExp::UNICODE_ESCAPES;
break; break;
case 'y': case 'y':
...@@ -867,7 +867,7 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeAndCompile) { ...@@ -867,7 +867,7 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeAndCompile) {
Map* map = regexp->map(); Map* map = regexp->map();
Object* constructor = map->constructor(); Object* constructor = map->constructor();
if (!FLAG_harmony_regexps && !FLAG_harmony_unicode && if (!FLAG_harmony_regexps && !FLAG_harmony_unicode_regexps &&
constructor->IsJSFunction() && constructor->IsJSFunction() &&
JSFunction::cast(constructor)->initial_map() == map) { JSFunction::cast(constructor)->initial_map() == map) {
// If we still have the original map, set in-object properties directly. // If we still have the original map, set in-object properties directly.
...@@ -902,7 +902,7 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeAndCompile) { ...@@ -902,7 +902,7 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeAndCompile) {
JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->sticky_string(), JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->sticky_string(),
sticky, final).Check(); sticky, final).Check();
} }
if (FLAG_harmony_unicode) { if (FLAG_harmony_unicode_regexps) {
JSObject::SetOwnPropertyIgnoreAttributes( JSObject::SetOwnPropertyIgnoreAttributes(
regexp, factory->unicode_string(), unicode, final).Check(); regexp, factory->unicode_string(), unicode, final).Check();
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --harmony-regexps --harmony-unicode // Flags: --harmony-regexps --harmony-unicode-regexps
RegExp.prototype.flags = 'setter should be undefined'; RegExp.prototype.flags = 'setter should be undefined';
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// ES6 extends the \uxxxx escape and also allows \u{xxxxx}. // ES6 extends the \uxxxx escape and also allows \u{xxxxx}.
// Flags: --harmony-unicode --harmony-regexps // Flags: --harmony-unicode-regexps --harmony-regexps
function testRegexpHelper(r) { function testRegexpHelper(r) {
assertTrue(r.test("foo")); assertTrue(r.test("foo"));
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug --harmony-unicode // Flags: --expose-debug-as debug --harmony-unicode-regexps
// Test the mirror object for regular expression values // Test the mirror object for regular expression values
var all_attributes = debug.PropertyAttribute.ReadOnly | var all_attributes = debug.PropertyAttribute.ReadOnly |
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment