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/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 // When PreParser is in use, lazy compilation is already being done, | 972 // When PreParser is in use, lazy compilation is already being done, |
973 // things cannot get lazier than that. | 973 // things cannot get lazier than that. |
974 bool AllowsLazyCompilation() const { return false; } | 974 bool AllowsLazyCompilation() const { return false; } |
975 | 975 |
976 void set_start_position(int position) {} | 976 void set_start_position(int position) {} |
977 void set_end_position(int position) {} | 977 void set_end_position(int position) {} |
978 | 978 |
979 bool IsDeclared(const PreParserIdentifier& identifier) const { return false; } | 979 bool IsDeclared(const PreParserIdentifier& identifier) const { return false; } |
980 void DeclareParameter(const PreParserIdentifier& identifier, VariableMode) {} | 980 void DeclareParameter(const PreParserIdentifier& identifier, VariableMode) {} |
981 void RecordArgumentsUsage() {} | 981 void RecordArgumentsUsage() {} |
982 void RecordSuperUsage() {} | 982 void RecordSuperPropertyUsage() {} |
| 983 void RecordSuperConstructorCallUsage() {} |
983 void RecordThisUsage() {} | 984 void RecordThisUsage() {} |
984 | 985 |
985 // Allow scope->Foo() to work. | 986 // Allow scope->Foo() to work. |
986 PreParserScope* operator->() { return this; } | 987 PreParserScope* operator->() { return this; } |
987 | 988 |
988 private: | 989 private: |
989 ScopeType scope_type_; | 990 ScopeType scope_type_; |
990 StrictMode strict_mode_; | 991 StrictMode strict_mode_; |
991 }; | 992 }; |
992 | 993 |
(...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2556 // new new foo()() means (new (new foo())()) | 2557 // new new foo()() means (new (new foo())()) |
2557 // new new foo means new (new foo) | 2558 // new new foo means new (new foo) |
2558 // new new foo() means new (new foo()) | 2559 // new new foo() means new (new foo()) |
2559 // new new foo().bar().baz means (new (new foo()).bar()).baz | 2560 // new new foo().bar().baz means (new (new foo()).bar()).baz |
2560 | 2561 |
2561 if (peek() == Token::NEW) { | 2562 if (peek() == Token::NEW) { |
2562 Consume(Token::NEW); | 2563 Consume(Token::NEW); |
2563 int new_pos = position(); | 2564 int new_pos = position(); |
2564 ExpressionT result = this->EmptyExpression(); | 2565 ExpressionT result = this->EmptyExpression(); |
2565 if (Check(Token::SUPER)) { | 2566 if (Check(Token::SUPER)) { |
2566 scope_->RecordSuperUsage(); | |
2567 result = this->SuperReference(scope_, factory()); | 2567 result = this->SuperReference(scope_, factory()); |
2568 } else { | 2568 } else { |
2569 result = this->ParseMemberWithNewPrefixesExpression(CHECK_OK); | 2569 result = this->ParseMemberWithNewPrefixesExpression(CHECK_OK); |
2570 } | 2570 } |
2571 if (peek() == Token::LPAREN) { | 2571 if (peek() == Token::LPAREN) { |
2572 // NewExpression with arguments. | 2572 // NewExpression with arguments. |
2573 typename Traits::Type::ExpressionList args = | 2573 typename Traits::Type::ExpressionList args = |
2574 this->ParseArguments(CHECK_OK); | 2574 this->ParseArguments(CHECK_OK); |
2575 result = factory()->NewCallNew(result, args, new_pos); | 2575 result = factory()->NewCallNew(result, args, new_pos); |
2576 // The expression can still continue with . or [ after the arguments. | 2576 // The expression can still continue with . or [ after the arguments. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2616 } | 2616 } |
2617 result = this->ParseFunctionLiteral( | 2617 result = this->ParseFunctionLiteral( |
2618 name, function_name_location, is_strict_reserved_name, | 2618 name, function_name_location, is_strict_reserved_name, |
2619 is_generator ? FunctionKind::kGeneratorFunction | 2619 is_generator ? FunctionKind::kGeneratorFunction |
2620 : FunctionKind::kNormalFunction, | 2620 : FunctionKind::kNormalFunction, |
2621 function_token_position, function_type, FunctionLiteral::NORMAL_ARITY, | 2621 function_token_position, function_type, FunctionLiteral::NORMAL_ARITY, |
2622 CHECK_OK); | 2622 CHECK_OK); |
2623 } else if (peek() == Token::SUPER) { | 2623 } else if (peek() == Token::SUPER) { |
2624 int beg_pos = position(); | 2624 int beg_pos = position(); |
2625 Consume(Token::SUPER); | 2625 Consume(Token::SUPER); |
2626 scope_->RecordSuperUsage(); | |
2627 Token::Value next = peek(); | 2626 Token::Value next = peek(); |
2628 if (next == Token::PERIOD || next == Token::LBRACK || | 2627 if (next == Token::PERIOD || next == Token::LBRACK) { |
2629 next == Token::LPAREN) { | 2628 scope_->RecordSuperPropertyUsage(); |
| 2629 result = this->SuperReference(scope_, factory()); |
| 2630 } else if (next == Token::LPAREN) { |
| 2631 scope_->RecordSuperConstructorCallUsage(); |
2630 result = this->SuperReference(scope_, factory()); | 2632 result = this->SuperReference(scope_, factory()); |
2631 } else { | 2633 } else { |
2632 ReportMessageAt(Scanner::Location(beg_pos, position()), | 2634 ReportMessageAt(Scanner::Location(beg_pos, position()), |
2633 "unexpected_super"); | 2635 "unexpected_super"); |
2634 *ok = false; | 2636 *ok = false; |
2635 return this->EmptyExpression(); | 2637 return this->EmptyExpression(); |
2636 } | 2638 } |
2637 } else { | 2639 } else { |
2638 result = ParsePrimaryExpression(CHECK_OK); | 2640 result = ParsePrimaryExpression(CHECK_OK); |
2639 } | 2641 } |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2916 DCHECK(IsAccessorAccessorConflict(old_type, type)); | 2918 DCHECK(IsAccessorAccessorConflict(old_type, type)); |
2917 // Both accessors of the same type. | 2919 // Both accessors of the same type. |
2918 parser()->ReportMessage("accessor_get_set"); | 2920 parser()->ReportMessage("accessor_get_set"); |
2919 } | 2921 } |
2920 *ok = false; | 2922 *ok = false; |
2921 } | 2923 } |
2922 } | 2924 } |
2923 } } // v8::internal | 2925 } } // v8::internal |
2924 | 2926 |
2925 #endif // V8_PREPARSER_H | 2927 #endif // V8_PREPARSER_H |
OLD | NEW |