Chromium Code Reviews| 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_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
| 6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
| 7 | 7 |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 } | 453 } |
| 454 | 454 |
| 455 ZoneList<ExpressionT>* non_patterns_to_rewrite() { | 455 ZoneList<ExpressionT>* non_patterns_to_rewrite() { |
| 456 return &non_patterns_to_rewrite_; | 456 return &non_patterns_to_rewrite_; |
| 457 } | 457 } |
| 458 | 458 |
| 459 bool next_function_is_parenthesized() const { | 459 bool next_function_is_parenthesized() const { |
| 460 return next_function_is_parenthesized_; | 460 return next_function_is_parenthesized_; |
| 461 } | 461 } |
| 462 | 462 |
| 463 bool this_function_is_parenthesized() const { | |
| 464 return this_function_is_parenthesized_; | |
| 465 } | |
| 466 | |
| 463 void set_next_function_is_parenthesized(bool parenthesized) { | 467 void set_next_function_is_parenthesized(bool parenthesized) { |
| 464 next_function_is_parenthesized_ = parenthesized; | 468 next_function_is_parenthesized_ = parenthesized; |
| 465 } | 469 } |
| 466 | 470 |
| 467 bool this_function_is_parenthesized() const { | 471 bool next_function_is_exclaimed() const { |
| 468 return this_function_is_parenthesized_; | 472 return next_function_is_exclaimed_; |
| 473 } | |
| 474 | |
| 475 bool this_function_is_exclaimed() const { | |
| 476 return this_function_is_exclaimed_; | |
| 477 } | |
| 478 | |
| 479 void set_next_function_is_exclaimed(bool exclaimed) { | |
| 480 next_function_is_exclaimed_ = exclaimed; | |
| 469 } | 481 } |
| 470 | 482 |
| 471 private: | 483 private: |
| 472 void AddDestructuringAssignment(DestructuringAssignment pair) { | 484 void AddDestructuringAssignment(DestructuringAssignment pair) { |
| 473 destructuring_assignments_to_rewrite_.Add(pair, this->zone()); | 485 destructuring_assignments_to_rewrite_.Add(pair, this->zone()); |
| 474 } | 486 } |
| 475 | 487 |
| 476 void AddNonPatternForRewriting(ExpressionT expr, bool* ok) { | 488 void AddNonPatternForRewriting(ExpressionT expr, bool* ok) { |
| 477 non_patterns_to_rewrite_.Add(expr, this->zone()); | 489 non_patterns_to_rewrite_.Add(expr, this->zone()); |
| 478 if (non_patterns_to_rewrite_.length() >= | 490 if (non_patterns_to_rewrite_.length() >= |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 500 FunctionState* outer_function_state_; | 512 FunctionState* outer_function_state_; |
| 501 | 513 |
| 502 ZoneList<DestructuringAssignment> destructuring_assignments_to_rewrite_; | 514 ZoneList<DestructuringAssignment> destructuring_assignments_to_rewrite_; |
| 503 TailCallExpressionList tail_call_expressions_; | 515 TailCallExpressionList tail_call_expressions_; |
| 504 ReturnExprContext return_expr_context_; | 516 ReturnExprContext return_expr_context_; |
| 505 ZoneList<ExpressionT> non_patterns_to_rewrite_; | 517 ZoneList<ExpressionT> non_patterns_to_rewrite_; |
| 506 | 518 |
| 507 ZoneList<typename ExpressionClassifier::Error> reported_errors_; | 519 ZoneList<typename ExpressionClassifier::Error> reported_errors_; |
| 508 | 520 |
| 509 // If true, the next (and immediately following) function literal is | 521 // If true, the next (and immediately following) function literal is |
| 510 // preceded by a parenthesis. | 522 // preceded by a parenthesis / exclamation mark. |
| 511 bool next_function_is_parenthesized_; | 523 bool next_function_is_parenthesized_; |
| 524 bool next_function_is_exclaimed_; | |
| 512 | 525 |
| 513 // The value of the parents' next_function_is_parenthesized_, as it applies | 526 // The value of the parents' next_function_is_*_, as it applies |
| 514 // to this function. Filled in by constructor. | 527 // to this function. Filled in by constructor. |
| 515 bool this_function_is_parenthesized_; | 528 bool this_function_is_parenthesized_; |
| 529 bool this_function_is_exclaimed_; | |
| 516 | 530 |
| 517 friend Impl; | 531 friend Impl; |
| 518 friend class Checkpoint; | 532 friend class Checkpoint; |
| 519 }; | 533 }; |
| 520 | 534 |
| 521 // This scope sets current ReturnExprContext to given value. | 535 // This scope sets current ReturnExprContext to given value. |
| 522 class ReturnExprScope { | 536 class ReturnExprScope { |
| 523 public: | 537 public: |
| 524 explicit ReturnExprScope(FunctionState* function_state, | 538 explicit ReturnExprScope(FunctionState* function_state, |
| 525 ReturnExprContext return_expr_context) | 539 ReturnExprContext return_expr_context) |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1457 generator_object_variable_(nullptr), | 1471 generator_object_variable_(nullptr), |
| 1458 promise_variable_(nullptr), | 1472 promise_variable_(nullptr), |
| 1459 function_state_stack_(function_state_stack), | 1473 function_state_stack_(function_state_stack), |
| 1460 outer_function_state_(*function_state_stack), | 1474 outer_function_state_(*function_state_stack), |
| 1461 destructuring_assignments_to_rewrite_(16, scope->zone()), | 1475 destructuring_assignments_to_rewrite_(16, scope->zone()), |
| 1462 tail_call_expressions_(scope->zone()), | 1476 tail_call_expressions_(scope->zone()), |
| 1463 return_expr_context_(ReturnExprContext::kInsideValidBlock), | 1477 return_expr_context_(ReturnExprContext::kInsideValidBlock), |
| 1464 non_patterns_to_rewrite_(0, scope->zone()), | 1478 non_patterns_to_rewrite_(0, scope->zone()), |
| 1465 reported_errors_(16, scope->zone()), | 1479 reported_errors_(16, scope->zone()), |
| 1466 next_function_is_parenthesized_(false), | 1480 next_function_is_parenthesized_(false), |
| 1467 this_function_is_parenthesized_(false) { | 1481 next_function_is_exclaimed_(false), |
| 1482 this_function_is_parenthesized_(false), | |
| 1483 this_function_is_exclaimed_(false) { | |
| 1468 *function_state_stack = this; | 1484 *function_state_stack = this; |
| 1469 if (outer_function_state_) { | 1485 if (outer_function_state_) { |
| 1470 this_function_is_parenthesized_ = | 1486 this_function_is_parenthesized_ = |
| 1471 outer_function_state_->next_function_is_parenthesized_; | 1487 outer_function_state_->next_function_is_parenthesized_; |
| 1472 outer_function_state_->next_function_is_parenthesized_ = false; | 1488 outer_function_state_->next_function_is_parenthesized_ = false; |
| 1489 this_function_is_exclaimed_ = | |
| 1490 outer_function_state_->next_function_is_exclaimed_; | |
| 1491 outer_function_state_->next_function_is_exclaimed_ = false; | |
|
vogelheim
2016/11/17 12:09:48
self-nitpick: :) All this flag handling is rather
| |
| 1473 } | 1492 } |
| 1474 } | 1493 } |
| 1475 | 1494 |
| 1476 template <typename Impl> | 1495 template <typename Impl> |
| 1477 ParserBase<Impl>::FunctionState::~FunctionState() { | 1496 ParserBase<Impl>::FunctionState::~FunctionState() { |
| 1478 *function_state_stack_ = outer_function_state_; | 1497 *function_state_stack_ = outer_function_state_; |
| 1479 } | 1498 } |
| 1480 | 1499 |
| 1481 template <typename Impl> | 1500 template <typename Impl> |
| 1482 void ParserBase<Impl>::GetUnexpectedTokenMessage( | 1501 void ParserBase<Impl>::GetUnexpectedTokenMessage( |
| (...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2934 // '!' UnaryExpression | 2953 // '!' UnaryExpression |
| 2935 // [+Await] AwaitExpression[?Yield] | 2954 // [+Await] AwaitExpression[?Yield] |
| 2936 | 2955 |
| 2937 Token::Value op = peek(); | 2956 Token::Value op = peek(); |
| 2938 if (Token::IsUnaryOp(op)) { | 2957 if (Token::IsUnaryOp(op)) { |
| 2939 BindingPatternUnexpectedToken(); | 2958 BindingPatternUnexpectedToken(); |
| 2940 ArrowFormalParametersUnexpectedToken(); | 2959 ArrowFormalParametersUnexpectedToken(); |
| 2941 | 2960 |
| 2942 op = Next(); | 2961 op = Next(); |
| 2943 int pos = position(); | 2962 int pos = position(); |
| 2963 | |
| 2964 // Record occurrence of "! function ..." | |
| 2965 function_state_->set_next_function_is_exclaimed(op == Token::NOT && | |
| 2966 peek() == Token::FUNCTION); | |
| 2967 | |
| 2944 ExpressionT expression = ParseUnaryExpression(CHECK_OK); | 2968 ExpressionT expression = ParseUnaryExpression(CHECK_OK); |
| 2945 impl()->RewriteNonPattern(CHECK_OK); | 2969 impl()->RewriteNonPattern(CHECK_OK); |
| 2946 | 2970 |
| 2947 if (op == Token::DELETE && is_strict(language_mode())) { | 2971 if (op == Token::DELETE && is_strict(language_mode())) { |
| 2948 if (impl()->IsIdentifier(expression)) { | 2972 if (impl()->IsIdentifier(expression)) { |
| 2949 // "delete identifier" is a syntax error in strict mode. | 2973 // "delete identifier" is a syntax error in strict mode. |
| 2950 ReportMessage(MessageTemplate::kStrictDelete); | 2974 ReportMessage(MessageTemplate::kStrictDelete); |
| 2951 *ok = false; | 2975 *ok = false; |
| 2952 return impl()->EmptyExpression(); | 2976 return impl()->EmptyExpression(); |
| 2953 } | 2977 } |
| (...skipping 2497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5451 has_seen_constructor_ = true; | 5475 has_seen_constructor_ = true; |
| 5452 return; | 5476 return; |
| 5453 } | 5477 } |
| 5454 } | 5478 } |
| 5455 | 5479 |
| 5456 | 5480 |
| 5457 } // namespace internal | 5481 } // namespace internal |
| 5458 } // namespace v8 | 5482 } // namespace v8 |
| 5459 | 5483 |
| 5460 #endif // V8_PARSING_PARSER_BASE_H | 5484 #endif // V8_PARSING_PARSER_BASE_H |
| OLD | NEW |