| 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_H_ | 5 #ifndef V8_PARSING_PARSER_H_ |
| 6 #define V8_PARSING_PARSER_H_ | 6 #define V8_PARSING_PARSER_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/parsing/parser-base.h" | 10 #include "src/parsing/parser-base.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 bool is_rest; | 127 bool is_rest; |
| 128 bool is_simple() const { | 128 bool is_simple() const { |
| 129 return pattern->IsVariableProxy() && initializer == nullptr && !is_rest; | 129 return pattern->IsVariableProxy() && initializer == nullptr && !is_rest; |
| 130 } | 130 } |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 explicit ParserFormalParameters(DeclarationScope* scope) | 133 explicit ParserFormalParameters(DeclarationScope* scope) |
| 134 : FormalParametersBase(scope), params(4, scope->zone()) {} | 134 : FormalParametersBase(scope), params(4, scope->zone()) {} |
| 135 ZoneList<Parameter> params; | 135 ZoneList<Parameter> params; |
| 136 | 136 |
| 137 int Arity() const { return params.length(); } | |
| 138 const Parameter& at(int i) const { return params[i]; } | 137 const Parameter& at(int i) const { return params[i]; } |
| 139 }; | 138 }; |
| 140 | 139 |
| 141 template <> | 140 template <> |
| 142 struct ParserTypes<Parser> { | 141 struct ParserTypes<Parser> { |
| 143 typedef ParserBase<Parser> Base; | 142 typedef ParserBase<Parser> Base; |
| 144 typedef Parser Impl; | 143 typedef Parser Impl; |
| 145 | 144 |
| 146 typedef v8::internal::Variable Variable; | 145 typedef v8::internal::Variable Variable; |
| 147 | 146 |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 if (!*ok) return; | 986 if (!*ok) return; |
| 988 } | 987 } |
| 989 if (init_block != nullptr) body->Add(init_block, zone()); | 988 if (init_block != nullptr) body->Add(init_block, zone()); |
| 990 } | 989 } |
| 991 | 990 |
| 992 V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters, | 991 V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters, |
| 993 Expression* pattern, | 992 Expression* pattern, |
| 994 Expression* initializer, | 993 Expression* initializer, |
| 995 int initializer_end_position, | 994 int initializer_end_position, |
| 996 bool is_rest) { | 995 bool is_rest) { |
| 996 parameters->UpdateArityAndFunctionLength(initializer != nullptr, is_rest); |
| 997 bool is_simple = pattern->IsVariableProxy() && initializer == nullptr; | 997 bool is_simple = pattern->IsVariableProxy() && initializer == nullptr; |
| 998 const AstRawString* name = is_simple | 998 const AstRawString* name = is_simple |
| 999 ? pattern->AsVariableProxy()->raw_name() | 999 ? pattern->AsVariableProxy()->raw_name() |
| 1000 : ast_value_factory()->empty_string(); | 1000 : ast_value_factory()->empty_string(); |
| 1001 parameters->params.Add( | 1001 parameters->params.Add( |
| 1002 ParserFormalParameters::Parameter(name, pattern, initializer, | 1002 ParserFormalParameters::Parameter(name, pattern, initializer, |
| 1003 initializer_end_position, is_rest), | 1003 initializer_end_position, is_rest), |
| 1004 parameters->scope->zone()); | 1004 parameters->scope->zone()); |
| 1005 } | 1005 } |
| 1006 | 1006 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 int total_preparse_skipped_; | 1092 int total_preparse_skipped_; |
| 1093 HistogramTimer* pre_parse_timer_; | 1093 HistogramTimer* pre_parse_timer_; |
| 1094 | 1094 |
| 1095 bool parsing_on_main_thread_; | 1095 bool parsing_on_main_thread_; |
| 1096 }; | 1096 }; |
| 1097 | 1097 |
| 1098 } // namespace internal | 1098 } // namespace internal |
| 1099 } // namespace v8 | 1099 } // namespace v8 |
| 1100 | 1100 |
| 1101 #endif // V8_PARSING_PARSER_H_ | 1101 #endif // V8_PARSING_PARSER_H_ |
| OLD | NEW |