| 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 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 // When PreParser is in use, lazy compilation is already being done, | 958 // When PreParser is in use, lazy compilation is already being done, |
| 959 // things cannot get lazier than that. | 959 // things cannot get lazier than that. |
| 960 bool AllowsLazyCompilation() const { return false; } | 960 bool AllowsLazyCompilation() const { return false; } |
| 961 | 961 |
| 962 void set_start_position(int position) {} | 962 void set_start_position(int position) {} |
| 963 void set_end_position(int position) {} | 963 void set_end_position(int position) {} |
| 964 | 964 |
| 965 bool IsDeclared(const PreParserIdentifier& identifier) const { return false; } | 965 bool IsDeclared(const PreParserIdentifier& identifier) const { return false; } |
| 966 void DeclareParameter(const PreParserIdentifier& identifier, VariableMode) {} | 966 void DeclareParameter(const PreParserIdentifier& identifier, VariableMode) {} |
| 967 void RecordArgumentsUsage() {} | 967 void RecordArgumentsUsage() {} |
| 968 void RecordSuperUsage() {} |
| 968 void RecordThisUsage() {} | 969 void RecordThisUsage() {} |
| 969 | 970 |
| 970 // Allow scope->Foo() to work. | 971 // Allow scope->Foo() to work. |
| 971 PreParserScope* operator->() { return this; } | 972 PreParserScope* operator->() { return this; } |
| 972 | 973 |
| 973 private: | 974 private: |
| 974 ScopeType scope_type_; | 975 ScopeType scope_type_; |
| 975 StrictMode strict_mode_; | 976 StrictMode strict_mode_; |
| 976 }; | 977 }; |
| 977 | 978 |
| (...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2501 // new new foo()() means (new (new foo())()) | 2502 // new new foo()() means (new (new foo())()) |
| 2502 // new new foo means new (new foo) | 2503 // new new foo means new (new foo) |
| 2503 // new new foo() means new (new foo()) | 2504 // new new foo() means new (new foo()) |
| 2504 // new new foo().bar().baz means (new (new foo()).bar()).baz | 2505 // new new foo().bar().baz means (new (new foo()).bar()).baz |
| 2505 | 2506 |
| 2506 if (peek() == Token::NEW) { | 2507 if (peek() == Token::NEW) { |
| 2507 Consume(Token::NEW); | 2508 Consume(Token::NEW); |
| 2508 int new_pos = position(); | 2509 int new_pos = position(); |
| 2509 ExpressionT result = this->EmptyExpression(); | 2510 ExpressionT result = this->EmptyExpression(); |
| 2510 if (Check(Token::SUPER)) { | 2511 if (Check(Token::SUPER)) { |
| 2512 scope_->RecordSuperUsage(); |
| 2511 result = this->SuperReference(scope_, factory()); | 2513 result = this->SuperReference(scope_, factory()); |
| 2512 } else { | 2514 } else { |
| 2513 result = this->ParseMemberWithNewPrefixesExpression(CHECK_OK); | 2515 result = this->ParseMemberWithNewPrefixesExpression(CHECK_OK); |
| 2514 } | 2516 } |
| 2515 if (peek() == Token::LPAREN) { | 2517 if (peek() == Token::LPAREN) { |
| 2516 // NewExpression with arguments. | 2518 // NewExpression with arguments. |
| 2517 typename Traits::Type::ExpressionList args = | 2519 typename Traits::Type::ExpressionList args = |
| 2518 this->ParseArguments(CHECK_OK); | 2520 this->ParseArguments(CHECK_OK); |
| 2519 result = factory()->NewCallNew(result, args, new_pos); | 2521 result = factory()->NewCallNew(result, args, new_pos); |
| 2520 // The expression can still continue with . or [ after the arguments. | 2522 // The expression can still continue with . or [ after the arguments. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2560 } | 2562 } |
| 2561 result = this->ParseFunctionLiteral( | 2563 result = this->ParseFunctionLiteral( |
| 2562 name, function_name_location, is_strict_reserved_name, | 2564 name, function_name_location, is_strict_reserved_name, |
| 2563 is_generator ? FunctionKind::kGeneratorFunction | 2565 is_generator ? FunctionKind::kGeneratorFunction |
| 2564 : FunctionKind::kNormalFunction, | 2566 : FunctionKind::kNormalFunction, |
| 2565 function_token_position, function_type, FunctionLiteral::NORMAL_ARITY, | 2567 function_token_position, function_type, FunctionLiteral::NORMAL_ARITY, |
| 2566 CHECK_OK); | 2568 CHECK_OK); |
| 2567 } else if (peek() == Token::SUPER) { | 2569 } else if (peek() == Token::SUPER) { |
| 2568 int beg_pos = position(); | 2570 int beg_pos = position(); |
| 2569 Consume(Token::SUPER); | 2571 Consume(Token::SUPER); |
| 2572 scope_->RecordSuperUsage(); |
| 2570 Token::Value next = peek(); | 2573 Token::Value next = peek(); |
| 2571 if (next == Token::PERIOD || next == Token::LBRACK || | 2574 if (next == Token::PERIOD || next == Token::LBRACK || |
| 2572 next == Token::LPAREN) { | 2575 next == Token::LPAREN) { |
| 2573 result = this->SuperReference(scope_, factory()); | 2576 result = this->SuperReference(scope_, factory()); |
| 2574 } else { | 2577 } else { |
| 2575 ReportMessageAt(Scanner::Location(beg_pos, position()), | 2578 ReportMessageAt(Scanner::Location(beg_pos, position()), |
| 2576 "unexpected_super"); | 2579 "unexpected_super"); |
| 2577 *ok = false; | 2580 *ok = false; |
| 2578 return this->EmptyExpression(); | 2581 return this->EmptyExpression(); |
| 2579 } | 2582 } |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2861 DCHECK(IsAccessorAccessorConflict(old_type, type)); | 2864 DCHECK(IsAccessorAccessorConflict(old_type, type)); |
| 2862 // Both accessors of the same type. | 2865 // Both accessors of the same type. |
| 2863 parser()->ReportMessage("accessor_get_set"); | 2866 parser()->ReportMessage("accessor_get_set"); |
| 2864 } | 2867 } |
| 2865 *ok = false; | 2868 *ok = false; |
| 2866 } | 2869 } |
| 2867 } | 2870 } |
| 2868 } } // v8::internal | 2871 } } // v8::internal |
| 2869 | 2872 |
| 2870 #endif // V8_PREPARSER_H | 2873 #endif // V8_PREPARSER_H |
| OLD | NEW |