Fix minifier to distinguish regexps from divisions (to some extent).

Rrraaa, I have to say, doing program rewriting via regexp rules is an inherently broken idea...

R=mstarzinger@chromium.org
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/9644001

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10969 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
rossberg@chromium.org 2012-03-08 16:38:44 +00:00
parent 068c6e5014
commit dbb95bc5f0
3 changed files with 5 additions and 3 deletions

View File

@ -1261,7 +1261,7 @@ function ObjectIsExtensible(obj) {
// Harmony egal.
function ObjectIs(obj1, obj2) {
if (obj1 === obj2) {
return (obj1 !== 0) || ((1 / obj1) === (1 / obj2));
return (obj1 !== 0) || (1 / obj1 === 1 / obj2);
} else {
return (obj1 !== obj1) && (obj2 !== obj2);
}

View File

@ -32,7 +32,7 @@ function TestEgal(expected, x, y) {
assertSame(expected, Object.is(x, y));
}
var test_set = [ {}, [], 1/0, -1/0, "s", 0, 1/(-1/0), null, undefined ];
var test_set = [ {}, [], 1/0, -1/0, "s", 0, 0/-1, null, undefined ];
print(test_set);
for (var i = 0; i < test_set.length; i++) {
for (var j = 0; j < test_set.length; j++) {

View File

@ -232,7 +232,9 @@ class JavaScriptMinifier(object):
# A regexp that matches a regexp literal surrounded by /slashes/.
# Don't allow a regexp to have a ) before the first ( since that's a
# syntax error and it's probably just two unrelated slashes.
slash_quoted_regexp = r"/(?:(?=\()|(?:[^()/\\]|\\.)+)(?:\([^/\\]|\\.)*/"
# Also don't allow it to come after anything that can only be the
# end of a primary expression.
slash_quoted_regexp = r"(?<![\w$'\")\]])/(?:(?=\()|(?:[^()/\\]|\\.)+)(?:\([^/\\]|\\.)*/"
# Replace multiple spaces with a single space.
line = re.sub("|".join([double_quoted_string,
single_quoted_string,