| 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/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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 PreParserExpression* operator->() { return this; } | 315 PreParserExpression* operator->() { return this; } |
| 316 | 316 |
| 317 // More dummy implementations of things PreParser doesn't need to track: | 317 // More dummy implementations of things PreParser doesn't need to track: |
| 318 void set_index(int index) {} // For YieldExpressions | 318 void set_index(int index) {} // For YieldExpressions |
| 319 void SetShouldEagerCompile() {} | 319 void SetShouldEagerCompile() {} |
| 320 void set_should_be_used_once_hint() {} | 320 void set_should_be_used_once_hint() {} |
| 321 | 321 |
| 322 int position() const { return kNoSourcePosition; } | 322 int position() const { return kNoSourcePosition; } |
| 323 void set_function_token_position(int position) {} | 323 void set_function_token_position(int position) {} |
| 324 | 324 |
| 325 void set_is_class_field_initializer(bool is_class_field_initializer) {} | |
| 326 | |
| 327 private: | 325 private: |
| 328 enum Type { | 326 enum Type { |
| 329 kEmpty, | 327 kEmpty, |
| 330 kExpression, | 328 kExpression, |
| 331 kIdentifierExpression, | 329 kIdentifierExpression, |
| 332 kStringLiteralExpression, | 330 kStringLiteralExpression, |
| 333 kSpreadExpression, | 331 kSpreadExpression, |
| 334 kObjectLiteralExpression, | 332 kObjectLiteralExpression, |
| 335 kArrayLiteralExpression | 333 kArrayLiteralExpression |
| 336 }; | 334 }; |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 V8_INLINE void MarkCollectedTailCallExpressions() {} | 965 V8_INLINE void MarkCollectedTailCallExpressions() {} |
| 968 V8_INLINE void MarkTailPosition(PreParserExpression expression) {} | 966 V8_INLINE void MarkTailPosition(PreParserExpression expression) {} |
| 969 | 967 |
| 970 V8_INLINE PreParserExpression SpreadCall(PreParserExpression function, | 968 V8_INLINE PreParserExpression SpreadCall(PreParserExpression function, |
| 971 PreParserExpressionList args, | 969 PreParserExpressionList args, |
| 972 int pos); | 970 int pos); |
| 973 V8_INLINE PreParserExpression SpreadCallNew(PreParserExpression function, | 971 V8_INLINE PreParserExpression SpreadCallNew(PreParserExpression function, |
| 974 PreParserExpressionList args, | 972 PreParserExpressionList args, |
| 975 int pos); | 973 int pos); |
| 976 | 974 |
| 977 V8_INLINE PreParserExpression | |
| 978 RewriteSuperCall(PreParserExpression call_expression) { | |
| 979 return call_expression; | |
| 980 } | |
| 981 | |
| 982 V8_INLINE void RewriteDestructuringAssignments() {} | 975 V8_INLINE void RewriteDestructuringAssignments() {} |
| 983 | 976 |
| 984 V8_INLINE PreParserExpression RewriteExponentiation(PreParserExpression left, | 977 V8_INLINE PreParserExpression RewriteExponentiation(PreParserExpression left, |
| 985 PreParserExpression right, | 978 PreParserExpression right, |
| 986 int pos) { | 979 int pos) { |
| 987 return left; | 980 return left; |
| 988 } | 981 } |
| 989 V8_INLINE PreParserExpression RewriteAssignExponentiation( | 982 V8_INLINE PreParserExpression RewriteAssignExponentiation( |
| 990 PreParserExpression left, PreParserExpression right, int pos) { | 983 PreParserExpression left, PreParserExpression right, int pos) { |
| 991 return left; | 984 return left; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1076 return PreParserStatement::Default(); | 1069 return PreParserStatement::Default(); |
| 1077 } | 1070 } |
| 1078 V8_INLINE void DeclareClassVariable(PreParserIdentifier name, | 1071 V8_INLINE void DeclareClassVariable(PreParserIdentifier name, |
| 1079 Scope* block_scope, ClassInfo* class_info, | 1072 Scope* block_scope, ClassInfo* class_info, |
| 1080 int class_token_pos, bool* ok) {} | 1073 int class_token_pos, bool* ok) {} |
| 1081 V8_INLINE void DeclareClassProperty(PreParserIdentifier class_name, | 1074 V8_INLINE void DeclareClassProperty(PreParserIdentifier class_name, |
| 1082 PreParserExpression property, | 1075 PreParserExpression property, |
| 1083 ClassLiteralProperty::Kind kind, | 1076 ClassLiteralProperty::Kind kind, |
| 1084 bool is_static, bool is_constructor, | 1077 bool is_static, bool is_constructor, |
| 1085 ClassInfo* class_info, bool* ok) { | 1078 ClassInfo* class_info, bool* ok) { |
| 1086 if (kind == ClassLiteralProperty::FIELD && !is_static && !is_constructor) { | |
| 1087 class_info->instance_field_initializers->Add( | |
| 1088 PreParserExpression::Default(), zone()); | |
| 1089 } | |
| 1090 } | 1079 } |
| 1091 V8_INLINE PreParserExpression RewriteClassLiteral(PreParserIdentifier name, | 1080 V8_INLINE PreParserExpression RewriteClassLiteral(PreParserIdentifier name, |
| 1092 ClassInfo* class_info, | 1081 ClassInfo* class_info, |
| 1093 int pos, bool* ok) { | 1082 int pos, bool* ok) { |
| 1094 bool has_default_constructor = !class_info->has_seen_constructor; | 1083 bool has_default_constructor = !class_info->has_seen_constructor; |
| 1095 bool has_instance_fields = | |
| 1096 class_info->instance_field_initializers->length() > 0; | |
| 1097 // Account for the default constructor. | 1084 // Account for the default constructor. |
| 1098 if (has_default_constructor) GetNextFunctionLiteralId(); | 1085 if (has_default_constructor) GetNextFunctionLiteralId(); |
| 1099 if (allow_harmony_class_fields() && has_instance_fields) { | |
| 1100 // Account for initializer function. | |
| 1101 GetNextFunctionLiteralId(); | |
| 1102 } | |
| 1103 return PreParserExpression::Default(); | 1086 return PreParserExpression::Default(); |
| 1104 } | 1087 } |
| 1105 | 1088 |
| 1106 V8_INLINE PreParserStatement DeclareNative(PreParserIdentifier name, int pos, | 1089 V8_INLINE PreParserStatement DeclareNative(PreParserIdentifier name, int pos, |
| 1107 bool* ok) { | 1090 bool* ok) { |
| 1108 return PreParserStatement::Default(); | 1091 return PreParserStatement::Default(); |
| 1109 } | 1092 } |
| 1110 | 1093 |
| 1111 V8_INLINE void QueueDestructuringAssignmentForRewriting( | 1094 V8_INLINE void QueueDestructuringAssignmentForRewriting( |
| 1112 PreParserExpression assignment) {} | 1095 PreParserExpression assignment) {} |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1596 function_state_->NextMaterializedLiteralIndex(); | 1579 function_state_->NextMaterializedLiteralIndex(); |
| 1597 function_state_->NextMaterializedLiteralIndex(); | 1580 function_state_->NextMaterializedLiteralIndex(); |
| 1598 } | 1581 } |
| 1599 return EmptyExpression(); | 1582 return EmptyExpression(); |
| 1600 } | 1583 } |
| 1601 | 1584 |
| 1602 } // namespace internal | 1585 } // namespace internal |
| 1603 } // namespace v8 | 1586 } // namespace v8 |
| 1604 | 1587 |
| 1605 #endif // V8_PARSING_PREPARSER_H | 1588 #endif // V8_PARSING_PREPARSER_H |
| OLD | NEW |