| 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 15 matching lines...) Expand all Loading... |
| 26 kFunctionNameValidityUnknown | 26 kFunctionNameValidityUnknown |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 | 29 |
| 30 struct FormalParametersBase { | 30 struct FormalParametersBase { |
| 31 explicit FormalParametersBase(Scope* scope) : scope(scope) {} | 31 explicit FormalParametersBase(Scope* scope) : scope(scope) {} |
| 32 Scope* scope; | 32 Scope* scope; |
| 33 bool has_rest = false; | 33 bool has_rest = false; |
| 34 bool is_simple = true; | 34 bool is_simple = true; |
| 35 int materialized_literals_count = 0; | 35 int materialized_literals_count = 0; |
| 36 int rest_array_literal_index = 0; |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 | 39 |
| 39 // Common base class shared between parser and pre-parser. Traits encapsulate | 40 // Common base class shared between parser and pre-parser. Traits encapsulate |
| 40 // the differences between Parser and PreParser: | 41 // the differences between Parser and PreParser: |
| 41 | 42 |
| 42 // - Return types: For example, Parser functions return Expression* and | 43 // - Return types: For example, Parser functions return Expression* and |
| 43 // PreParser functions return PreParserExpression. | 44 // PreParser functions return PreParserExpression. |
| 44 | 45 |
| 45 // - Creating parse tree nodes: Parser generates an AST during the recursive | 46 // - Creating parse tree nodes: Parser generates an AST during the recursive |
| (...skipping 3601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3647 if (!allow_harmony_destructuring() && !Traits::IsIdentifier(pattern)) { | 3648 if (!allow_harmony_destructuring() && !Traits::IsIdentifier(pattern)) { |
| 3648 ReportUnexpectedToken(next); | 3649 ReportUnexpectedToken(next); |
| 3649 *ok = false; | 3650 *ok = false; |
| 3650 return; | 3651 return; |
| 3651 } | 3652 } |
| 3652 | 3653 |
| 3653 if (parameters->is_simple) { | 3654 if (parameters->is_simple) { |
| 3654 parameters->is_simple = !is_rest && Traits::IsIdentifier(pattern); | 3655 parameters->is_simple = !is_rest && Traits::IsIdentifier(pattern); |
| 3655 } | 3656 } |
| 3656 parameters->has_rest = is_rest; | 3657 parameters->has_rest = is_rest; |
| 3657 if (is_rest && !Traits::IsIdentifier(pattern)) { | 3658 if (is_rest) { |
| 3658 ReportUnexpectedToken(next); | 3659 if (!Traits::IsIdentifier(pattern)) { |
| 3659 *ok = false; | 3660 ReportUnexpectedToken(next); |
| 3660 return; | 3661 *ok = false; |
| 3662 return; |
| 3663 } |
| 3664 parameters->rest_array_literal_index = |
| 3665 function_state_->NextMaterializedLiteralIndex(); |
| 3661 } | 3666 } |
| 3662 Traits::AddFormalParameter(parameters, pattern, is_rest); | 3667 Traits::AddFormalParameter(parameters, pattern, is_rest); |
| 3663 } | 3668 } |
| 3664 | 3669 |
| 3665 | 3670 |
| 3666 template <class Traits> | 3671 template <class Traits> |
| 3667 void ParserBase<Traits>::ParseFormalParameterList( | 3672 void ParserBase<Traits>::ParseFormalParameterList( |
| 3668 FormalParametersT* parameters, ExpressionClassifier* classifier, bool* ok) { | 3673 FormalParametersT* parameters, ExpressionClassifier* classifier, bool* ok) { |
| 3669 // FormalParameters[Yield,GeneratorParameter] : | 3674 // FormalParameters[Yield,GeneratorParameter] : |
| 3670 // [empty] | 3675 // [empty] |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4030 *ok = false; | 4035 *ok = false; |
| 4031 return; | 4036 return; |
| 4032 } | 4037 } |
| 4033 has_seen_constructor_ = true; | 4038 has_seen_constructor_ = true; |
| 4034 return; | 4039 return; |
| 4035 } | 4040 } |
| 4036 } | 4041 } |
| 4037 } } // v8::internal | 4042 } } // v8::internal |
| 4038 | 4043 |
| 4039 #endif // V8_PREPARSER_H | 4044 #endif // V8_PREPARSER_H |
| OLD | NEW |