| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_PREPARSER_H | 5 #ifndef V8_PREPARSER_H |
| 6 #define V8_PREPARSER_H | 6 #define V8_PREPARSER_H |
| 7 | 7 |
| 8 #include "src/func-name-inferrer.h" | 8 #include "src/func-name-inferrer.h" |
| 9 #include "src/hashmap.h" | 9 #include "src/hashmap.h" |
| 10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
| (...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 static void CheckFunctionLiteralInsideTopLevelObjectLiteral( | 924 static void CheckFunctionLiteralInsideTopLevelObjectLiteral( |
| 925 PreParserScope* scope, PreParserExpression value, bool* has_function) {} | 925 PreParserScope* scope, PreParserExpression value, bool* has_function) {} |
| 926 | 926 |
| 927 static void CheckAssigningFunctionLiteralToProperty( | 927 static void CheckAssigningFunctionLiteralToProperty( |
| 928 PreParserExpression left, PreParserExpression right) {} | 928 PreParserExpression left, PreParserExpression right) {} |
| 929 | 929 |
| 930 // PreParser doesn't need to keep track of eval calls. | 930 // PreParser doesn't need to keep track of eval calls. |
| 931 static void CheckPossibleEvalCall(PreParserExpression expression, | 931 static void CheckPossibleEvalCall(PreParserExpression expression, |
| 932 PreParserScope* scope) {} | 932 PreParserScope* scope) {} |
| 933 | 933 |
| 934 static PreParserExpression MarkExpressionAsLValue( | 934 static PreParserExpression MarkExpressionAsAssigned( |
| 935 PreParserExpression expression) { | 935 PreParserExpression expression) { |
| 936 // TODO(marja): To be able to produce the same errors, the preparser needs | 936 // TODO(marja): To be able to produce the same errors, the preparser needs |
| 937 // to start tracking which expressions are variables and which are lvalues. | 937 // to start tracking which expressions are variables and which are assigned. |
| 938 return expression; | 938 return expression; |
| 939 } | 939 } |
| 940 | 940 |
| 941 bool ShortcutNumericLiteralBinaryExpression(PreParserExpression* x, | 941 bool ShortcutNumericLiteralBinaryExpression(PreParserExpression* x, |
| 942 PreParserExpression y, | 942 PreParserExpression y, |
| 943 Token::Value op, | 943 Token::Value op, |
| 944 int pos, | 944 int pos, |
| 945 PreParserFactory* factory) { | 945 PreParserFactory* factory) { |
| 946 return false; | 946 return false; |
| 947 } | 947 } |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1704 this->ParseConditionalExpression(accept_IN, CHECK_OK); | 1704 this->ParseConditionalExpression(accept_IN, CHECK_OK); |
| 1705 | 1705 |
| 1706 if (!Token::IsAssignmentOp(peek())) { | 1706 if (!Token::IsAssignmentOp(peek())) { |
| 1707 if (fni_ != NULL) fni_->Leave(); | 1707 if (fni_ != NULL) fni_->Leave(); |
| 1708 // Parsed conditional expression only (no assignment). | 1708 // Parsed conditional expression only (no assignment). |
| 1709 return expression; | 1709 return expression; |
| 1710 } | 1710 } |
| 1711 | 1711 |
| 1712 expression = this->CheckAndRewriteReferenceExpression( | 1712 expression = this->CheckAndRewriteReferenceExpression( |
| 1713 expression, lhs_location, "invalid_lhs_in_assignment", CHECK_OK); | 1713 expression, lhs_location, "invalid_lhs_in_assignment", CHECK_OK); |
| 1714 expression = this->MarkExpressionAsLValue(expression); | 1714 expression = this->MarkExpressionAsAssigned(expression); |
| 1715 | 1715 |
| 1716 Token::Value op = Next(); // Get assignment operator. | 1716 Token::Value op = Next(); // Get assignment operator. |
| 1717 int pos = position(); | 1717 int pos = position(); |
| 1718 ExpressionT right = this->ParseAssignmentExpression(accept_IN, CHECK_OK); | 1718 ExpressionT right = this->ParseAssignmentExpression(accept_IN, CHECK_OK); |
| 1719 | 1719 |
| 1720 // TODO(1231235): We try to estimate the set of properties set by | 1720 // TODO(1231235): We try to estimate the set of properties set by |
| 1721 // constructors. We define a new property whenever there is an | 1721 // constructors. We define a new property whenever there is an |
| 1722 // assignment to a property of 'this'. We should probably only add | 1722 // assignment to a property of 'this'. We should probably only add |
| 1723 // properties if we haven't seen them before. Otherwise we'll | 1723 // properties if we haven't seen them before. Otherwise we'll |
| 1724 // probably overestimate the number of properties. | 1724 // probably overestimate the number of properties. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1866 } | 1866 } |
| 1867 | 1867 |
| 1868 // Allow Traits do rewrite the expression. | 1868 // Allow Traits do rewrite the expression. |
| 1869 return this->BuildUnaryExpression(expression, op, pos, factory()); | 1869 return this->BuildUnaryExpression(expression, op, pos, factory()); |
| 1870 } else if (Token::IsCountOp(op)) { | 1870 } else if (Token::IsCountOp(op)) { |
| 1871 op = Next(); | 1871 op = Next(); |
| 1872 Scanner::Location lhs_location = scanner()->peek_location(); | 1872 Scanner::Location lhs_location = scanner()->peek_location(); |
| 1873 ExpressionT expression = this->ParseUnaryExpression(CHECK_OK); | 1873 ExpressionT expression = this->ParseUnaryExpression(CHECK_OK); |
| 1874 expression = this->CheckAndRewriteReferenceExpression( | 1874 expression = this->CheckAndRewriteReferenceExpression( |
| 1875 expression, lhs_location, "invalid_lhs_in_prefix_op", CHECK_OK); | 1875 expression, lhs_location, "invalid_lhs_in_prefix_op", CHECK_OK); |
| 1876 this->MarkExpressionAsLValue(expression); | 1876 this->MarkExpressionAsAssigned(expression); |
| 1877 | 1877 |
| 1878 return factory()->NewCountOperation(op, | 1878 return factory()->NewCountOperation(op, |
| 1879 true /* prefix */, | 1879 true /* prefix */, |
| 1880 expression, | 1880 expression, |
| 1881 position()); | 1881 position()); |
| 1882 | 1882 |
| 1883 } else { | 1883 } else { |
| 1884 return this->ParsePostfixExpression(ok); | 1884 return this->ParsePostfixExpression(ok); |
| 1885 } | 1885 } |
| 1886 } | 1886 } |
| 1887 | 1887 |
| 1888 | 1888 |
| 1889 template <class Traits> | 1889 template <class Traits> |
| 1890 typename ParserBase<Traits>::ExpressionT | 1890 typename ParserBase<Traits>::ExpressionT |
| 1891 ParserBase<Traits>::ParsePostfixExpression(bool* ok) { | 1891 ParserBase<Traits>::ParsePostfixExpression(bool* ok) { |
| 1892 // PostfixExpression :: | 1892 // PostfixExpression :: |
| 1893 // LeftHandSideExpression ('++' | '--')? | 1893 // LeftHandSideExpression ('++' | '--')? |
| 1894 | 1894 |
| 1895 Scanner::Location lhs_location = scanner()->peek_location(); | 1895 Scanner::Location lhs_location = scanner()->peek_location(); |
| 1896 ExpressionT expression = this->ParseLeftHandSideExpression(CHECK_OK); | 1896 ExpressionT expression = this->ParseLeftHandSideExpression(CHECK_OK); |
| 1897 if (!scanner()->HasAnyLineTerminatorBeforeNext() && | 1897 if (!scanner()->HasAnyLineTerminatorBeforeNext() && |
| 1898 Token::IsCountOp(peek())) { | 1898 Token::IsCountOp(peek())) { |
| 1899 expression = this->CheckAndRewriteReferenceExpression( | 1899 expression = this->CheckAndRewriteReferenceExpression( |
| 1900 expression, lhs_location, "invalid_lhs_in_postfix_op", CHECK_OK); | 1900 expression, lhs_location, "invalid_lhs_in_postfix_op", CHECK_OK); |
| 1901 expression = this->MarkExpressionAsLValue(expression); | 1901 expression = this->MarkExpressionAsAssigned(expression); |
| 1902 | 1902 |
| 1903 Token::Value next = Next(); | 1903 Token::Value next = Next(); |
| 1904 expression = | 1904 expression = |
| 1905 factory()->NewCountOperation(next, | 1905 factory()->NewCountOperation(next, |
| 1906 false /* postfix */, | 1906 false /* postfix */, |
| 1907 expression, | 1907 expression, |
| 1908 position()); | 1908 position()); |
| 1909 } | 1909 } |
| 1910 return expression; | 1910 return expression; |
| 1911 } | 1911 } |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2164 parser()->ReportMessage("accessor_get_set"); | 2164 parser()->ReportMessage("accessor_get_set"); |
| 2165 } | 2165 } |
| 2166 *ok = false; | 2166 *ok = false; |
| 2167 } | 2167 } |
| 2168 } | 2168 } |
| 2169 | 2169 |
| 2170 | 2170 |
| 2171 } } // v8::internal | 2171 } } // v8::internal |
| 2172 | 2172 |
| 2173 #endif // V8_PREPARSER_H | 2173 #endif // V8_PREPARSER_H |
| OLD | NEW |