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