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_PARSER_H_ | 5 #ifndef V8_PARSER_H_ |
6 #define V8_PARSER_H_ | 6 #define V8_PARSER_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/ast.h" | 9 #include "src/ast.h" |
10 #include "src/compiler.h" // TODO(titzer): remove this include dependency | 10 #include "src/compiler.h" // TODO(titzer): remove this include dependency |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 V8_INLINE ZoneList<v8::internal::Expression*>* PrepareSpreadArguments( | 834 V8_INLINE ZoneList<v8::internal::Expression*>* PrepareSpreadArguments( |
835 ZoneList<v8::internal::Expression*>* list); | 835 ZoneList<v8::internal::Expression*>* list); |
836 V8_INLINE void MaterializeUnspreadArgumentsLiterals(int count) {} | 836 V8_INLINE void MaterializeUnspreadArgumentsLiterals(int count) {} |
837 V8_INLINE Expression* SpreadCall(Expression* function, | 837 V8_INLINE Expression* SpreadCall(Expression* function, |
838 ZoneList<v8::internal::Expression*>* args, | 838 ZoneList<v8::internal::Expression*>* args, |
839 int pos); | 839 int pos); |
840 V8_INLINE Expression* SpreadCallNew(Expression* function, | 840 V8_INLINE Expression* SpreadCallNew(Expression* function, |
841 ZoneList<v8::internal::Expression*>* args, | 841 ZoneList<v8::internal::Expression*>* args, |
842 int pos); | 842 int pos); |
843 | 843 |
| 844 inline Expression* RewriteDestructuringAssignment(Expression* expr, bool* ok); |
| 845 |
844 private: | 846 private: |
845 Parser* parser_; | 847 Parser* parser_; |
846 }; | 848 }; |
847 | 849 |
848 | 850 |
849 class Parser : public ParserBase<ParserTraits> { | 851 class Parser : public ParserBase<ParserTraits> { |
850 public: | 852 public: |
851 explicit Parser(ParseInfo* info); | 853 explicit Parser(ParseInfo* info); |
852 ~Parser() { | 854 ~Parser() { |
853 delete reusable_preparser_; | 855 delete reusable_preparser_; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 // Initialize the components of a for-in / for-of statement. | 1063 // Initialize the components of a for-in / for-of statement. |
1062 void InitializeForEachStatement(ForEachStatement* stmt, | 1064 void InitializeForEachStatement(ForEachStatement* stmt, |
1063 Expression* each, | 1065 Expression* each, |
1064 Expression* subject, | 1066 Expression* subject, |
1065 Statement* body); | 1067 Statement* body); |
1066 Statement* DesugarLexicalBindingsInForStatement( | 1068 Statement* DesugarLexicalBindingsInForStatement( |
1067 Scope* inner_scope, bool is_const, ZoneList<const AstRawString*>* names, | 1069 Scope* inner_scope, bool is_const, ZoneList<const AstRawString*>* names, |
1068 ForStatement* loop, Statement* init, Expression* cond, Statement* next, | 1070 ForStatement* loop, Statement* init, Expression* cond, Statement* next, |
1069 Statement* body, bool* ok); | 1071 Statement* body, bool* ok); |
1070 | 1072 |
| 1073 Expression* DesugarDestructuringAssignment(Expression* expr, bool* ok); |
| 1074 |
1071 FunctionLiteral* ParseFunctionLiteral( | 1075 FunctionLiteral* ParseFunctionLiteral( |
1072 const AstRawString* name, Scanner::Location function_name_location, | 1076 const AstRawString* name, Scanner::Location function_name_location, |
1073 bool name_is_strict_reserved, FunctionKind kind, | 1077 bool name_is_strict_reserved, FunctionKind kind, |
1074 int function_token_position, FunctionLiteral::FunctionType type, | 1078 int function_token_position, FunctionLiteral::FunctionType type, |
1075 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 1079 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
1076 | 1080 |
1077 | 1081 |
1078 ClassLiteral* ParseClassLiteral(const AstRawString* name, | 1082 ClassLiteral* ParseClassLiteral(const AstRawString* name, |
1079 Scanner::Location class_name_location, | 1083 Scanner::Location class_name_location, |
1080 bool name_is_strict_reserved, int pos, | 1084 bool name_is_strict_reserved, int pos, |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 // TODO(sigurds) Mark every parameter as maybe assigned. This is a | 1288 // TODO(sigurds) Mark every parameter as maybe assigned. This is a |
1285 // conservative approximation necessary to account for parameters | 1289 // conservative approximation necessary to account for parameters |
1286 // that are assigned via the arguments array. | 1290 // that are assigned via the arguments array. |
1287 var->set_maybe_assigned(); | 1291 var->set_maybe_assigned(); |
1288 } | 1292 } |
1289 if (is_duplicate) { | 1293 if (is_duplicate) { |
1290 classifier->RecordDuplicateFormalParameterError( | 1294 classifier->RecordDuplicateFormalParameterError( |
1291 parser_->scanner()->location()); | 1295 parser_->scanner()->location()); |
1292 } | 1296 } |
1293 } | 1297 } |
| 1298 |
| 1299 |
| 1300 inline Expression* ParserTraits::RewriteDestructuringAssignment( |
| 1301 Expression* expr, bool* ok) { |
| 1302 return parser_->DesugarDestructuringAssignment(expr, ok); |
| 1303 } |
1294 } } // namespace v8::internal | 1304 } } // namespace v8::internal |
1295 | 1305 |
1296 #endif // V8_PARSER_H_ | 1306 #endif // V8_PARSER_H_ |
OLD | NEW |