| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 bool is_generator, | 733 bool is_generator, |
| 734 int function_token_position, | 734 int function_token_position, |
| 735 FunctionLiteral::FunctionType type, | 735 FunctionLiteral::FunctionType type, |
| 736 bool* ok) { | 736 bool* ok) { |
| 737 return parser_->ParseFunctionLiteral(name, function_name_location, | 737 return parser_->ParseFunctionLiteral(name, function_name_location, |
| 738 name_is_strict_reserved, is_generator, | 738 name_is_strict_reserved, is_generator, |
| 739 function_token_position, type, ok); | 739 function_token_position, type, ok); |
| 740 } | 740 } |
| 741 | 741 |
| 742 | 742 |
| 743 Expression* ParserTraits::ParsePostfixExpression(bool* ok) { | 743 Expression* ParserTraits::ParseLeftHandSideExpression(bool* ok) { |
| 744 return parser_->ParsePostfixExpression(ok); | 744 return parser_->ParseLeftHandSideExpression(ok); |
| 745 } | 745 } |
| 746 | 746 |
| 747 | 747 |
| 748 Parser::Parser(CompilationInfo* info) | 748 Parser::Parser(CompilationInfo* info) |
| 749 : ParserBase<ParserTraits>(&scanner_, | 749 : ParserBase<ParserTraits>(&scanner_, |
| 750 info->isolate()->stack_guard()->real_climit(), | 750 info->isolate()->stack_guard()->real_climit(), |
| 751 info->extension(), | 751 info->extension(), |
| 752 NULL, | 752 NULL, |
| 753 info->zone(), | 753 info->zone(), |
| 754 this), | 754 this), |
| (...skipping 2281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3036 result->set_scope(for_scope); | 3036 result->set_scope(for_scope); |
| 3037 loop->Initialize(NULL, cond, next, body); | 3037 loop->Initialize(NULL, cond, next, body); |
| 3038 return result; | 3038 return result; |
| 3039 } else { | 3039 } else { |
| 3040 loop->Initialize(init, cond, next, body); | 3040 loop->Initialize(init, cond, next, body); |
| 3041 return loop; | 3041 return loop; |
| 3042 } | 3042 } |
| 3043 } | 3043 } |
| 3044 | 3044 |
| 3045 | 3045 |
| 3046 Expression* Parser::ParsePostfixExpression(bool* ok) { | |
| 3047 // PostfixExpression :: | |
| 3048 // LeftHandSideExpression ('++' | '--')? | |
| 3049 | |
| 3050 Scanner::Location lhs_location = scanner()->peek_location(); | |
| 3051 Expression* expression = ParseLeftHandSideExpression(CHECK_OK); | |
| 3052 if (!scanner()->HasAnyLineTerminatorBeforeNext() && | |
| 3053 Token::IsCountOp(peek())) { | |
| 3054 if (expression == NULL || !expression->IsValidLeftHandSide()) { | |
| 3055 ReportMessageAt(lhs_location, "invalid_lhs_in_postfix_op", true); | |
| 3056 *ok = false; | |
| 3057 return NULL; | |
| 3058 } | |
| 3059 | |
| 3060 if (strict_mode() == STRICT) { | |
| 3061 // Postfix expression operand in strict mode may not be eval or arguments. | |
| 3062 CheckStrictModeLValue(expression, CHECK_OK); | |
| 3063 } | |
| 3064 MarkExpressionAsLValue(expression); | |
| 3065 | |
| 3066 Token::Value next = Next(); | |
| 3067 expression = | |
| 3068 factory()->NewCountOperation(next, | |
| 3069 false /* postfix */, | |
| 3070 expression, | |
| 3071 position()); | |
| 3072 } | |
| 3073 return expression; | |
| 3074 } | |
| 3075 | |
| 3076 | |
| 3077 Expression* Parser::ParseLeftHandSideExpression(bool* ok) { | 3046 Expression* Parser::ParseLeftHandSideExpression(bool* ok) { |
| 3078 // LeftHandSideExpression :: | 3047 // LeftHandSideExpression :: |
| 3079 // (NewExpression | MemberExpression) ... | 3048 // (NewExpression | MemberExpression) ... |
| 3080 | 3049 |
| 3081 Expression* result = ParseMemberWithNewPrefixesExpression(CHECK_OK); | 3050 Expression* result = ParseMemberWithNewPrefixesExpression(CHECK_OK); |
| 3082 | 3051 |
| 3083 while (true) { | 3052 while (true) { |
| 3084 switch (peek()) { | 3053 switch (peek()) { |
| 3085 case Token::LBRACK: { | 3054 case Token::LBRACK: { |
| 3086 Consume(Token::LBRACK); | 3055 Consume(Token::LBRACK); |
| (...skipping 1812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4899 ASSERT(info()->isolate()->has_pending_exception()); | 4868 ASSERT(info()->isolate()->has_pending_exception()); |
| 4900 } else { | 4869 } else { |
| 4901 result = ParseProgram(); | 4870 result = ParseProgram(); |
| 4902 } | 4871 } |
| 4903 } | 4872 } |
| 4904 info()->SetFunction(result); | 4873 info()->SetFunction(result); |
| 4905 return (result != NULL); | 4874 return (result != NULL); |
| 4906 } | 4875 } |
| 4907 | 4876 |
| 4908 } } // namespace v8::internal | 4877 } } // namespace v8::internal |
| OLD | NEW |