Revision: 22562
Author:   [email protected]
Date:     Wed Jul 23 13:29:24 2014 UTC
Log:      Fix checks to bit flags of PreParserExpression

This fixes checks on the "code_" member of PreParserExpression, in order
to make methods IsThis(), IsThisProperty(), IsProperty(), IsCall() and
IsValidReferenceExpression() work correctly.

BUG=v8:3456
LOG=
[email protected]

Review URL: https://codereview.chromium.org/410873004
http://code.google.com/p/v8/source/detail?r=22562

Added:
 /branches/bleeding_edge/test/mjsunit/regress-3456.js
Modified:
 /branches/bleeding_edge/src/preparser.h

=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/mjsunit/regress-3456.js Wed Jul 23 13:29:24 2014 UTC
@@ -0,0 +1,13 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --min-preparse-length 1
+
+// Arrow function parsing (commit r22366) changed the flags stored in
+// PreParserExpression, and IsValidReferenceExpression() would return
+// false for certain valid expressions. This case is the minimum amount
+// of code needed to validate that IsValidReferenceExpression() works
+// properly. If it does not, a ReferenceError is thrown during parsing.
+
+function f() { ++(this.foo) }
=======================================
--- /branches/bleeding_edge/src/preparser.h     Mon Jul 21 09:58:01 2014 UTC
+++ /branches/bleeding_edge/src/preparser.h     Wed Jul 23 13:29:24 2014 UTC
@@ -676,21 +676,24 @@
     return (code_ & kTypeMask) == kTypeStringLiteral;
   }

-  bool IsUseStrictLiteral() {
+  bool IsUseStrictLiteral() const {
     return (code_ & kUseStrictString) == kUseStrictString;
   }

-  bool IsThis() { return code_ == kThisExpression; }
+ bool IsThis() const { return (code_ & kThisExpression) == kThisExpression; }

-  bool IsThisProperty() { return code_ == kThisPropertyExpression; }
+  bool IsThisProperty() const {
+    return (code_ & kThisPropertyExpression) == kThisPropertyExpression;
+  }

-  bool IsProperty() {
- return code_ == kPropertyExpression || code_ == kThisPropertyExpression;
+  bool IsProperty() const {
+    return (code_ & kPropertyExpression) == kPropertyExpression ||
+           (code_ & kThisPropertyExpression) == kThisPropertyExpression;
   }

-  bool IsCall() { return code_ == kCallExpression; }
+ bool IsCall() const { return (code_ & kCallExpression) == kCallExpression; }

-  bool IsValidReferenceExpression() {
+  bool IsValidReferenceExpression() const {
     return IsIdentifier() || IsProperty();
   }

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to