| 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() { |
| 284 code_ = ParenthesizedField::update(code_, true); |
| 285 } |
| 286 bool is_parenthesized() const { return ParenthesizedField::decode(code_); } |
| 287 |
| 282 private: | 288 private: |
| 283 enum Type { | 289 enum Type { |
| 284 kExpression, | 290 kExpression, |
| 285 kIdentifierExpression, | 291 kIdentifierExpression, |
| 286 kStringLiteralExpression, | 292 kStringLiteralExpression, |
| 287 kBinaryOperationExpression, | 293 kBinaryOperationExpression, |
| 288 kSpreadExpression, | 294 kSpreadExpression, |
| 289 kObjectLiteralExpression, | 295 kObjectLiteralExpression, |
| 290 kArrayLiteralExpression | 296 kArrayLiteralExpression |
| 291 }; | 297 }; |
| 292 | 298 |
| 293 enum ExpressionType { | 299 enum ExpressionType { |
| 294 kThisExpression, | 300 kThisExpression, |
| 295 kThisPropertyExpression, | 301 kThisPropertyExpression, |
| 296 kPropertyExpression, | 302 kPropertyExpression, |
| 297 kCallExpression, | 303 kCallExpression, |
| 298 kSuperCallReference, | 304 kSuperCallReference, |
| 299 kNoTemplateTagExpression, | 305 kNoTemplateTagExpression, |
| 300 kAssignment | 306 kAssignment |
| 301 }; | 307 }; |
| 302 | 308 |
| 303 explicit PreParserExpression(uint32_t expression_code) | 309 explicit PreParserExpression(uint32_t expression_code) |
| 304 : code_(expression_code) {} | 310 : code_(expression_code) {} |
| 305 | 311 |
| 306 // The first three bits are for the Type. | 312 // The first three bits are for the Type. |
| 307 typedef BitField<Type, 0, 3> TypeField; | 313 typedef BitField<Type, 0, 3> TypeField; |
| 308 | 314 |
| 315 // The high order bit applies only to nodes which would inherit from the |
| 316 // Expression ASTNode --- This is by necessity, due to the fact that |
| 317 // Expression nodes may be represented as multiple Types, not exclusively |
| 318 // through kExpression. |
| 319 // TODO(caitp, adamk): clean up PreParserExpression bitfields. |
| 320 typedef BitField<bool, 31, 1> ParenthesizedField; |
| 321 |
| 309 // The rest of the bits are interpreted depending on the value | 322 // The rest of the bits are interpreted depending on the value |
| 310 // of the Type field, so they can share the storage. | 323 // of the Type field, so they can share the storage. |
| 311 typedef BitField<ExpressionType, TypeField::kNext, 3> ExpressionTypeField; | 324 typedef BitField<ExpressionType, TypeField::kNext, 3> ExpressionTypeField; |
| 312 typedef BitField<bool, TypeField::kNext, 1> IsUseStrictField; | 325 typedef BitField<bool, TypeField::kNext, 1> IsUseStrictField; |
| 313 typedef BitField<bool, IsUseStrictField::kNext, 1> IsUseStrongField; | 326 typedef BitField<bool, IsUseStrictField::kNext, 1> IsUseStrongField; |
| 314 typedef BitField<PreParserIdentifier::Type, TypeField::kNext, 10> | 327 typedef BitField<PreParserIdentifier::Type, TypeField::kNext, 10> |
| 315 IdentifierTypeField; | 328 IdentifierTypeField; |
| 316 typedef BitField<bool, TypeField::kNext, 1> HasCoverInitializedNameField; | 329 typedef BitField<bool, TypeField::kNext, 1> HasCoverInitializedNameField; |
| 317 | 330 |
| 318 uint32_t code_; | 331 uint32_t code_; |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 const PreParserFormalParameters& parameters, FunctionKind kind, | 1139 const PreParserFormalParameters& parameters, FunctionKind kind, |
| 1127 FunctionLiteral::FunctionType function_type, bool* ok) { | 1140 FunctionLiteral::FunctionType function_type, bool* ok) { |
| 1128 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, | 1141 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, |
| 1129 kind, function_type, ok); | 1142 kind, function_type, ok); |
| 1130 } | 1143 } |
| 1131 | 1144 |
| 1132 } // namespace internal | 1145 } // namespace internal |
| 1133 } // namespace v8 | 1146 } // namespace v8 |
| 1134 | 1147 |
| 1135 #endif // V8_PARSING_PREPARSER_H | 1148 #endif // V8_PARSING_PREPARSER_H |
| OLD | NEW |