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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 } | 747 } |
748 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { | 748 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { |
749 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); | 749 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); |
750 } | 750 } |
751 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { | 751 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { |
752 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); | 752 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); |
753 } | 753 } |
754 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, | 754 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, |
755 FunctionKind kind = kNormalFunction); | 755 FunctionKind kind = kNormalFunction); |
756 | 756 |
757 V8_INLINE void DeclareFormalParameter(Scope* scope, const AstRawString* name, | 757 V8_INLINE void DeclareFormalParameter(Scope* scope, Expression* name, |
758 ExpressionClassifier* classifier, | 758 ExpressionClassifier* classifier, |
759 bool is_rest); | 759 bool is_rest); |
760 void ParseArrowFunctionFormalParameters(Scope* scope, Expression* params, | 760 void ParseArrowFunctionFormalParameters(Scope* scope, Expression* params, |
761 const Scanner::Location& params_loc, | 761 const Scanner::Location& params_loc, |
762 bool* has_rest, | 762 bool* has_rest, |
763 Scanner::Location* duplicate_loc, | 763 Scanner::Location* duplicate_loc, |
764 bool* ok); | 764 bool* ok); |
765 | 765 |
766 // Temporary glue; these functions will move to ParserBase. | 766 // Temporary glue; these functions will move to ParserBase. |
767 Expression* ParseV8Intrinsic(bool* ok); | 767 Expression* ParseV8Intrinsic(bool* ok); |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 return parser_->SpreadCall(function, args, pos); | 1263 return parser_->SpreadCall(function, args, pos); |
1264 } | 1264 } |
1265 | 1265 |
1266 | 1266 |
1267 Expression* ParserTraits::SpreadCallNew( | 1267 Expression* ParserTraits::SpreadCallNew( |
1268 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { | 1268 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { |
1269 return parser_->SpreadCallNew(function, args, pos); | 1269 return parser_->SpreadCallNew(function, args, pos); |
1270 } | 1270 } |
1271 | 1271 |
1272 | 1272 |
1273 void ParserTraits::DeclareFormalParameter(Scope* scope, | 1273 void ParserTraits::DeclareFormalParameter(Scope* scope, Expression* pattern, |
1274 const AstRawString* name, | |
1275 ExpressionClassifier* classifier, | 1274 ExpressionClassifier* classifier, |
1276 bool is_rest) { | 1275 bool is_rest) { |
1277 bool is_duplicate = false; | 1276 bool is_duplicate = false; |
| 1277 if (!pattern->IsVariableProxy()) { |
| 1278 // TODO(dslomov): implement. |
| 1279 DCHECK(parser_->allow_harmony_destructuring()); |
| 1280 return; |
| 1281 } |
| 1282 auto name = pattern->AsVariableProxy()->raw_name(); |
1278 Variable* var = scope->DeclareParameter(name, VAR, is_rest, &is_duplicate); | 1283 Variable* var = scope->DeclareParameter(name, VAR, is_rest, &is_duplicate); |
1279 if (is_sloppy(scope->language_mode())) { | 1284 if (is_sloppy(scope->language_mode())) { |
1280 // TODO(sigurds) Mark every parameter as maybe assigned. This is a | 1285 // TODO(sigurds) Mark every parameter as maybe assigned. This is a |
1281 // conservative approximation necessary to account for parameters | 1286 // conservative approximation necessary to account for parameters |
1282 // that are assigned via the arguments array. | 1287 // that are assigned via the arguments array. |
1283 var->set_maybe_assigned(); | 1288 var->set_maybe_assigned(); |
1284 } | 1289 } |
1285 if (is_duplicate) { | 1290 if (is_duplicate) { |
1286 classifier->RecordDuplicateFormalParameterError( | 1291 classifier->RecordDuplicateFormalParameterError( |
1287 parser_->scanner()->location()); | 1292 parser_->scanner()->location()); |
1288 } | 1293 } |
1289 } | 1294 } |
1290 } } // namespace v8::internal | 1295 } } // namespace v8::internal |
1291 | 1296 |
1292 #endif // V8_PARSER_H_ | 1297 #endif // V8_PARSER_H_ |
OLD | NEW |