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_PREPARSER_H | 5 #ifndef V8_PARSING_PREPARSER_H |
6 #define V8_PARSING_PREPARSER_H | 6 #define V8_PARSING_PREPARSER_H |
7 | 7 |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/hashmap.h" | 10 #include "src/hashmap.h" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 // and PreParser. | 272 // and PreParser. |
273 PreParserExpression* operator->() { return this; } | 273 PreParserExpression* operator->() { return this; } |
274 | 274 |
275 // More dummy implementations of things PreParser doesn't need to track: | 275 // More dummy implementations of things PreParser doesn't need to track: |
276 void set_index(int index) {} // For YieldExpressions | 276 void set_index(int index) {} // For YieldExpressions |
277 void set_should_eager_compile() {} | 277 void set_should_eager_compile() {} |
278 | 278 |
279 int position() const { return RelocInfo::kNoPosition; } | 279 int position() const { return RelocInfo::kNoPosition; } |
280 void set_function_token_position(int position) {} | 280 void set_function_token_position(int position) {} |
281 | 281 |
282 // Parenthesized expressions in the form `( Expression )`. | |
283 void set_is_parenthesized() { code_ |= ParenthesizedField::encode(true); } | |
284 bool is_parenthesized() const { return ParenthesizedField::decode(code_); } | |
285 | |
282 private: | 286 private: |
283 enum Type { | 287 enum Type { |
284 kExpression, | 288 kExpression, |
285 kIdentifierExpression, | 289 kIdentifierExpression, |
286 kStringLiteralExpression, | 290 kStringLiteralExpression, |
287 kBinaryOperationExpression, | 291 kBinaryOperationExpression, |
288 kSpreadExpression, | 292 kSpreadExpression, |
289 kObjectLiteralExpression, | 293 kObjectLiteralExpression, |
290 kArrayLiteralExpression | 294 kArrayLiteralExpression |
291 }; | 295 }; |
292 | 296 |
293 enum ExpressionType { | 297 enum ExpressionType { |
294 kThisExpression, | 298 kThisExpression, |
295 kThisPropertyExpression, | 299 kThisPropertyExpression, |
296 kPropertyExpression, | 300 kPropertyExpression, |
297 kCallExpression, | 301 kCallExpression, |
298 kSuperCallReference, | 302 kSuperCallReference, |
299 kNoTemplateTagExpression, | 303 kNoTemplateTagExpression, |
300 kAssignment | 304 kAssignment |
301 }; | 305 }; |
302 | 306 |
303 explicit PreParserExpression(uint32_t expression_code) | 307 explicit PreParserExpression(uint32_t expression_code) |
304 : code_(expression_code) {} | 308 : code_(expression_code) {} |
305 | 309 |
306 // The first three bits are for the Type. | 310 // The first three bits are for the Type. |
307 typedef BitField<Type, 0, 3> TypeField; | 311 typedef BitField<Type, 0, 3> TypeField; |
308 | 312 |
309 // The rest of the bits are interpreted depending on the value | 313 // The rest of the bits are interpreted depending on the value |
310 // of the Type field, so they can share the storage. | 314 // of the Type field, so they can share the storage. |
adamk
2016/01/08 16:24:23
This comment is weird and out of date (some of the
caitp (gmail)
2016/01/08 16:36:01
Are you saying "We don't need to have both Express
adamk
2016/01/08 16:52:53
No, it's not a general comment, since you've seemi
caitp (gmail)
2016/01/08 16:58:37
Alright, done
| |
311 typedef BitField<ExpressionType, TypeField::kNext, 3> ExpressionTypeField; | 315 typedef BitField<ExpressionType, TypeField::kNext, 3> ExpressionTypeField; |
312 typedef BitField<bool, TypeField::kNext, 1> IsUseStrictField; | 316 typedef BitField<bool, TypeField::kNext, 1> IsUseStrictField; |
313 typedef BitField<bool, IsUseStrictField::kNext, 1> IsUseStrongField; | 317 typedef BitField<bool, IsUseStrictField::kNext, 1> IsUseStrongField; |
314 typedef BitField<PreParserIdentifier::Type, TypeField::kNext, 10> | 318 typedef BitField<PreParserIdentifier::Type, TypeField::kNext, 10> |
315 IdentifierTypeField; | 319 IdentifierTypeField; |
316 typedef BitField<bool, TypeField::kNext, 1> HasCoverInitializedNameField; | 320 typedef BitField<bool, TypeField::kNext, 1> HasCoverInitializedNameField; |
321 typedef BitField<bool, 31, 1> ParenthesizedField; | |
317 | 322 |
318 uint32_t code_; | 323 uint32_t code_; |
319 }; | 324 }; |
320 | 325 |
321 | 326 |
322 // The pre-parser doesn't need to build lists of expressions, identifiers, or | 327 // The pre-parser doesn't need to build lists of expressions, identifiers, or |
323 // the like. | 328 // the like. |
324 template <typename T> | 329 template <typename T> |
325 class PreParserList { | 330 class PreParserList { |
326 public: | 331 public: |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1126 const PreParserFormalParameters& parameters, FunctionKind kind, | 1131 const PreParserFormalParameters& parameters, FunctionKind kind, |
1127 FunctionLiteral::FunctionType function_type, bool* ok) { | 1132 FunctionLiteral::FunctionType function_type, bool* ok) { |
1128 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, | 1133 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, |
1129 kind, function_type, ok); | 1134 kind, function_type, ok); |
1130 } | 1135 } |
1131 | 1136 |
1132 } // namespace internal | 1137 } // namespace internal |
1133 } // namespace v8 | 1138 } // namespace v8 |
1134 | 1139 |
1135 #endif // V8_PARSING_PREPARSER_H | 1140 #endif // V8_PARSING_PREPARSER_H |
OLD | NEW |