| 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/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/func-name-inferrer.h" | 10 #include "src/func-name-inferrer.h" |
| (...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 static void CheckFunctionLiteralInsideTopLevelObjectLiteral( | 966 static void CheckFunctionLiteralInsideTopLevelObjectLiteral( |
| 967 PreParserScope* scope, PreParserExpression value, bool* has_function) {} | 967 PreParserScope* scope, PreParserExpression value, bool* has_function) {} |
| 968 | 968 |
| 969 static void CheckAssigningFunctionLiteralToProperty( | 969 static void CheckAssigningFunctionLiteralToProperty( |
| 970 PreParserExpression left, PreParserExpression right) {} | 970 PreParserExpression left, PreParserExpression right) {} |
| 971 | 971 |
| 972 // PreParser doesn't need to keep track of eval calls. | 972 // PreParser doesn't need to keep track of eval calls. |
| 973 static void CheckPossibleEvalCall(PreParserExpression expression, | 973 static void CheckPossibleEvalCall(PreParserExpression expression, |
| 974 PreParserScope* scope) {} | 974 PreParserScope* scope) {} |
| 975 | 975 |
| 976 static PreParserExpression MarkExpressionAsAssigned( | 976 static PreParserExpression MarkExpressionAsLValue( |
| 977 PreParserExpression expression) { | 977 PreParserExpression expression) { |
| 978 // TODO(marja): To be able to produce the same errors, the preparser needs | 978 // TODO(marja): To be able to produce the same errors, the preparser needs |
| 979 // to start tracking which expressions are variables and which are assigned. | 979 // to start tracking which expressions are variables and which are lvalues. |
| 980 return expression; | 980 return expression; |
| 981 } | 981 } |
| 982 | 982 |
| 983 bool ShortcutNumericLiteralBinaryExpression(PreParserExpression* x, | 983 bool ShortcutNumericLiteralBinaryExpression(PreParserExpression* x, |
| 984 PreParserExpression y, | 984 PreParserExpression y, |
| 985 Token::Value op, | 985 Token::Value op, |
| 986 int pos, | 986 int pos, |
| 987 PreParserFactory* factory) { | 987 PreParserFactory* factory) { |
| 988 return false; | 988 return false; |
| 989 } | 989 } |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1746 this->ParseConditionalExpression(accept_IN, CHECK_OK); | 1746 this->ParseConditionalExpression(accept_IN, CHECK_OK); |
| 1747 | 1747 |
| 1748 if (!Token::IsAssignmentOp(peek())) { | 1748 if (!Token::IsAssignmentOp(peek())) { |
| 1749 if (fni_ != NULL) fni_->Leave(); | 1749 if (fni_ != NULL) fni_->Leave(); |
| 1750 // Parsed conditional expression only (no assignment). | 1750 // Parsed conditional expression only (no assignment). |
| 1751 return expression; | 1751 return expression; |
| 1752 } | 1752 } |
| 1753 | 1753 |
| 1754 expression = this->CheckAndRewriteReferenceExpression( | 1754 expression = this->CheckAndRewriteReferenceExpression( |
| 1755 expression, lhs_location, "invalid_lhs_in_assignment", CHECK_OK); | 1755 expression, lhs_location, "invalid_lhs_in_assignment", CHECK_OK); |
| 1756 expression = this->MarkExpressionAsAssigned(expression); | 1756 expression = this->MarkExpressionAsLValue(expression); |
| 1757 | 1757 |
| 1758 Token::Value op = Next(); // Get assignment operator. | 1758 Token::Value op = Next(); // Get assignment operator. |
| 1759 int pos = position(); | 1759 int pos = position(); |
| 1760 ExpressionT right = this->ParseAssignmentExpression(accept_IN, CHECK_OK); | 1760 ExpressionT right = this->ParseAssignmentExpression(accept_IN, CHECK_OK); |
| 1761 | 1761 |
| 1762 // TODO(1231235): We try to estimate the set of properties set by | 1762 // TODO(1231235): We try to estimate the set of properties set by |
| 1763 // constructors. We define a new property whenever there is an | 1763 // constructors. We define a new property whenever there is an |
| 1764 // assignment to a property of 'this'. We should probably only add | 1764 // assignment to a property of 'this'. We should probably only add |
| 1765 // properties if we haven't seen them before. Otherwise we'll | 1765 // properties if we haven't seen them before. Otherwise we'll |
| 1766 // probably overestimate the number of properties. | 1766 // probably overestimate the number of properties. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1908 } | 1908 } |
| 1909 | 1909 |
| 1910 // Allow Traits do rewrite the expression. | 1910 // Allow Traits do rewrite the expression. |
| 1911 return this->BuildUnaryExpression(expression, op, pos, factory()); | 1911 return this->BuildUnaryExpression(expression, op, pos, factory()); |
| 1912 } else if (Token::IsCountOp(op)) { | 1912 } else if (Token::IsCountOp(op)) { |
| 1913 op = Next(); | 1913 op = Next(); |
| 1914 Scanner::Location lhs_location = scanner()->peek_location(); | 1914 Scanner::Location lhs_location = scanner()->peek_location(); |
| 1915 ExpressionT expression = this->ParseUnaryExpression(CHECK_OK); | 1915 ExpressionT expression = this->ParseUnaryExpression(CHECK_OK); |
| 1916 expression = this->CheckAndRewriteReferenceExpression( | 1916 expression = this->CheckAndRewriteReferenceExpression( |
| 1917 expression, lhs_location, "invalid_lhs_in_prefix_op", CHECK_OK); | 1917 expression, lhs_location, "invalid_lhs_in_prefix_op", CHECK_OK); |
| 1918 this->MarkExpressionAsAssigned(expression); | 1918 this->MarkExpressionAsLValue(expression); |
| 1919 | 1919 |
| 1920 return factory()->NewCountOperation(op, | 1920 return factory()->NewCountOperation(op, |
| 1921 true /* prefix */, | 1921 true /* prefix */, |
| 1922 expression, | 1922 expression, |
| 1923 position()); | 1923 position()); |
| 1924 | 1924 |
| 1925 } else { | 1925 } else { |
| 1926 return this->ParsePostfixExpression(ok); | 1926 return this->ParsePostfixExpression(ok); |
| 1927 } | 1927 } |
| 1928 } | 1928 } |
| 1929 | 1929 |
| 1930 | 1930 |
| 1931 template <class Traits> | 1931 template <class Traits> |
| 1932 typename ParserBase<Traits>::ExpressionT | 1932 typename ParserBase<Traits>::ExpressionT |
| 1933 ParserBase<Traits>::ParsePostfixExpression(bool* ok) { | 1933 ParserBase<Traits>::ParsePostfixExpression(bool* ok) { |
| 1934 // PostfixExpression :: | 1934 // PostfixExpression :: |
| 1935 // LeftHandSideExpression ('++' | '--')? | 1935 // LeftHandSideExpression ('++' | '--')? |
| 1936 | 1936 |
| 1937 Scanner::Location lhs_location = scanner()->peek_location(); | 1937 Scanner::Location lhs_location = scanner()->peek_location(); |
| 1938 ExpressionT expression = this->ParseLeftHandSideExpression(CHECK_OK); | 1938 ExpressionT expression = this->ParseLeftHandSideExpression(CHECK_OK); |
| 1939 if (!scanner()->HasAnyLineTerminatorBeforeNext() && | 1939 if (!scanner()->HasAnyLineTerminatorBeforeNext() && |
| 1940 Token::IsCountOp(peek())) { | 1940 Token::IsCountOp(peek())) { |
| 1941 expression = this->CheckAndRewriteReferenceExpression( | 1941 expression = this->CheckAndRewriteReferenceExpression( |
| 1942 expression, lhs_location, "invalid_lhs_in_postfix_op", CHECK_OK); | 1942 expression, lhs_location, "invalid_lhs_in_postfix_op", CHECK_OK); |
| 1943 expression = this->MarkExpressionAsAssigned(expression); | 1943 expression = this->MarkExpressionAsLValue(expression); |
| 1944 | 1944 |
| 1945 Token::Value next = Next(); | 1945 Token::Value next = Next(); |
| 1946 expression = | 1946 expression = |
| 1947 factory()->NewCountOperation(next, | 1947 factory()->NewCountOperation(next, |
| 1948 false /* postfix */, | 1948 false /* postfix */, |
| 1949 expression, | 1949 expression, |
| 1950 position()); | 1950 position()); |
| 1951 } | 1951 } |
| 1952 return expression; | 1952 return expression; |
| 1953 } | 1953 } |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2206 parser()->ReportMessage("accessor_get_set"); | 2206 parser()->ReportMessage("accessor_get_set"); |
| 2207 } | 2207 } |
| 2208 *ok = false; | 2208 *ok = false; |
| 2209 } | 2209 } |
| 2210 } | 2210 } |
| 2211 | 2211 |
| 2212 | 2212 |
| 2213 } } // v8::internal | 2213 } } // v8::internal |
| 2214 | 2214 |
| 2215 #endif // V8_PREPARSER_H | 2215 #endif // V8_PREPARSER_H |
| OLD | NEW |