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)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_templates)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy)
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_rest_parameters)
......@@ -1627,6 +1628,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tostring)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_templates)
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_rest_parameters)
......@@ -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<HeapObject> flag(FLAG_harmony_unicode ? heap()->true_value()
Handle<HeapObject> flag(FLAG_harmony_unicode_regexps ? heap()->true_value()
: heap()->false_value());
PropertyAttributes attributes =
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();
}
......@@ -2209,6 +2212,7 @@ bool Genesis::InstallExperimentalNatives() {
"native harmony-templates.js", NULL};
static const char* harmony_sloppy_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_rest_parameters_natives[] = {NULL};
......
......@@ -186,6 +186,7 @@ DEFINE_IMPLICATION(es_staging, harmony)
V(harmony_proxies, "harmony proxies") \
V(harmony_sloppy, "harmony features in sloppy mode") \
V(harmony_unicode, "harmony unicode escapes") \
V(harmony_unicode_regexps, "harmony unicode regexps") \
V(harmony_computed_property_names, "harmony computed property names") \
V(harmony_rest_parameters, "harmony rest parameters")
......@@ -231,6 +232,7 @@ HARMONY_SHIPPING(FLAG_SHIPPING_FEATURES)
DEFINE_IMPLICATION(harmony_modules, harmony_scoping)
DEFINE_IMPLICATION(harmony_classes, harmony_scoping)
DEFINE_IMPLICATION(harmony_classes, harmony_object_literals)
DEFINE_IMPLICATION(harmony_unicode_regexps, harmony_unicode)
// Flags for experimental implementation features.
......
......@@ -231,7 +231,7 @@ namespace internal {
V(sticky_string, "sticky") \
V(unicode_string, "unicode") \
V(harmony_regexps_string, "harmony_regexps") \
V(harmony_unicode_string, "harmony_unicode") \
V(harmony_unicode_regexps_string, "harmony_unicode_regexps") \
V(input_string, "input") \
V(index_string, "index") \
V(last_index_string, "lastIndex") \
......
......@@ -4631,7 +4631,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
// 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 identity escapes are allowed.
if (!FLAG_harmony_unicode || !unicode_) {
if (!FLAG_harmony_unicode_regexps || !unicode_) {
builder->AddCharacter(first_digit);
Advance(2);
} else {
......@@ -4692,7 +4692,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
uc32 value;
if (ParseHexEscape(2, &value)) {
builder->AddCharacter(value);
} else if (!FLAG_harmony_unicode || !unicode_) {
} else if (!FLAG_harmony_unicode_regexps || !unicode_) {
builder->AddCharacter('x');
} else {
// If the 'u' flag is present, invalid escapes are not treated as
......@@ -4706,7 +4706,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
uc32 value;
if (ParseUnicodeEscape(&value)) {
builder->AddCharacter(value);
} else if (!FLAG_harmony_unicode || !unicode_) {
} else if (!FLAG_harmony_unicode_regexps || !unicode_) {
builder->AddCharacter('u');
} else {
// If the 'u' flag is present, invalid escapes are not treated as
......@@ -4720,7 +4720,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
// 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 identity escapes are allowed.
if (!FLAG_harmony_unicode || !unicode_ ||
if (!FLAG_harmony_unicode_regexps || !unicode_ ||
IsSyntaxCharacter(current())) {
builder->AddCharacter(current());
Advance();
......@@ -4991,7 +4991,7 @@ bool RegExpParser::ParseUnicodeEscape(uc32* value) {
// Accept both \uxxxx and \u{xxxxxx} (if harmony unicode escapes are
// allowed). In the latter case, the number of hex digits between { } is
// arbitrary. \ and u have already been read.
if (current() == '{' && FLAG_harmony_unicode && unicode_) {
if (current() == '{' && FLAG_harmony_unicode_regexps && unicode_) {
int start = position();
Advance();
if (ParseUnlimitedLengthHexNumber(0x10ffff, value)) {
......@@ -5081,7 +5081,7 @@ uc32 RegExpParser::ParseClassCharacterEscape() {
if (ParseHexEscape(2, &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
// as an identity escape.
return 'x';
......@@ -5097,7 +5097,7 @@ uc32 RegExpParser::ParseClassCharacterEscape() {
if (ParseUnicodeEscape(&value)) {
return value;
}
if (!FLAG_harmony_unicode || !unicode_) {
if (!FLAG_harmony_unicode_regexps || !unicode_) {
return 'u';
}
// If the 'u' flag is present, invalid escapes are not treated as
......@@ -5110,7 +5110,8 @@ uc32 RegExpParser::ParseClassCharacterEscape() {
// 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
// identity escapes are allowed.
if (!FLAG_harmony_unicode || !unicode_ || IsSyntaxCharacter(result)) {
if (!FLAG_harmony_unicode_regexps || !unicode_ ||
IsSyntaxCharacter(result)) {
Advance();
return result;
}
......
......@@ -22,7 +22,7 @@ function DoConstructRegExp(object, pattern, flags) {
flags = (pattern.global ? 'g' : '')
+ (pattern.ignoreCase ? 'i' : '')
+ (pattern.multiline ? 'm' : '');
if (harmony_unicode)
if (harmony_unicode_regexps)
flags += (pattern.unicode ? 'u' : '');
if (harmony_regexps)
flags += (pattern.sticky ? 'y' : '');
......@@ -237,7 +237,7 @@ function RegExpToString() {
if (this.global) result += 'g';
if (this.ignoreCase) result += 'i';
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';
return result;
}
......
......@@ -819,7 +819,7 @@ static JSRegExp::Flags RegExpFlagsFromString(Handle<String> flags,
flag = JSRegExp::MULTILINE;
break;
case 'u':
if (!FLAG_harmony_unicode) return JSRegExp::Flags(0);
if (!FLAG_harmony_unicode_regexps) return JSRegExp::Flags(0);
flag = JSRegExp::UNICODE_ESCAPES;
break;
case 'y':
......@@ -867,7 +867,7 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeAndCompile) {
Map* map = regexp->map();
Object* constructor = map->constructor();
if (!FLAG_harmony_regexps && !FLAG_harmony_unicode &&
if (!FLAG_harmony_regexps && !FLAG_harmony_unicode_regexps &&
constructor->IsJSFunction() &&
JSFunction::cast(constructor)->initial_map() == map) {
// If we still have the original map, set in-object properties directly.
......@@ -902,7 +902,7 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeAndCompile) {
JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->sticky_string(),
sticky, final).Check();
}
if (FLAG_harmony_unicode) {
if (FLAG_harmony_unicode_regexps) {
JSObject::SetOwnPropertyIgnoreAttributes(
regexp, factory->unicode_string(), unicode, final).Check();
}
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-regexps --harmony-unicode
// Flags: --harmony-regexps --harmony-unicode-regexps
RegExp.prototype.flags = 'setter should be undefined';
......
......@@ -4,7 +4,7 @@
// ES6 extends the \uxxxx escape and also allows \u{xxxxx}.
// Flags: --harmony-unicode --harmony-regexps
// Flags: --harmony-unicode-regexps --harmony-regexps
function testRegexpHelper(r) {
assertTrue(r.test("foo"));
......
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// 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
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