| 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_PARSER_H_ | 5 #ifndef V8_PARSING_PARSER_H_ |
| 6 #define V8_PARSING_PARSER_H_ | 6 #define V8_PARSING_PARSER_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
| 10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 // Generate AST node that throws a TypeError with the given | 449 // Generate AST node that throws a TypeError with the given |
| 450 // type. Both arguments must be non-null (in the handle sense). | 450 // type. Both arguments must be non-null (in the handle sense). |
| 451 Expression* NewThrowTypeError(MessageTemplate::Template message, | 451 Expression* NewThrowTypeError(MessageTemplate::Template message, |
| 452 const AstRawString* arg, int pos); | 452 const AstRawString* arg, int pos); |
| 453 | 453 |
| 454 // Generic AST generator for throwing errors from compiled code. | 454 // Generic AST generator for throwing errors from compiled code. |
| 455 Expression* NewThrowError(Runtime::FunctionId function_id, | 455 Expression* NewThrowError(Runtime::FunctionId function_id, |
| 456 MessageTemplate::Template message, | 456 MessageTemplate::Template message, |
| 457 const AstRawString* arg, int pos); | 457 const AstRawString* arg, int pos); |
| 458 | 458 |
| 459 void FinalizeIteratorUse(Variable* completion, Expression* condition, |
| 460 Variable* iter, Block* iterator_use, Block* result); |
| 461 |
| 459 Statement* FinalizeForOfStatement(ForOfStatement* loop, int pos); | 462 Statement* FinalizeForOfStatement(ForOfStatement* loop, int pos); |
| 460 | 463 |
| 461 // Reporting errors. | 464 // Reporting errors. |
| 462 void ReportMessageAt(Scanner::Location source_location, | 465 void ReportMessageAt(Scanner::Location source_location, |
| 463 MessageTemplate::Template message, | 466 MessageTemplate::Template message, |
| 464 const char* arg = NULL, | 467 const char* arg = NULL, |
| 465 ParseErrorType error_type = kSyntaxError); | 468 ParseErrorType error_type = kSyntaxError); |
| 466 void ReportMessage(MessageTemplate::Template message, const char* arg = NULL, | 469 void ReportMessage(MessageTemplate::Template message, const char* arg = NULL, |
| 467 ParseErrorType error_type = kSyntaxError); | 470 ParseErrorType error_type = kSyntaxError); |
| 468 void ReportMessage(MessageTemplate::Template message, const AstRawString* arg, | 471 void ReportMessage(MessageTemplate::Template message, const AstRawString* arg, |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 void ParseOnBackground(ParseInfo* info); | 692 void ParseOnBackground(ParseInfo* info); |
| 690 | 693 |
| 691 // Handle errors detected during parsing, move statistics to Isolate, | 694 // Handle errors detected during parsing, move statistics to Isolate, |
| 692 // internalize strings (move them to the heap). | 695 // internalize strings (move them to the heap). |
| 693 void Internalize(Isolate* isolate, Handle<Script> script, bool error); | 696 void Internalize(Isolate* isolate, Handle<Script> script, bool error); |
| 694 void HandleSourceURLComments(Isolate* isolate, Handle<Script> script); | 697 void HandleSourceURLComments(Isolate* isolate, Handle<Script> script); |
| 695 | 698 |
| 696 private: | 699 private: |
| 697 friend class ParserTraits; | 700 friend class ParserTraits; |
| 698 | 701 |
| 702 // Runtime encoding of different completion modes. |
| 703 enum CompletionKind { |
| 704 kNormalCompletion, |
| 705 kThrowCompletion, |
| 706 kAbruptCompletion |
| 707 }; |
| 708 |
| 699 // Limit the allowed number of local variables in a function. The hard limit | 709 // Limit the allowed number of local variables in a function. The hard limit |
| 700 // is that offsets computed by FullCodeGenerator::StackOperand and similar | 710 // is that offsets computed by FullCodeGenerator::StackOperand and similar |
| 701 // functions are ints, and they should not overflow. In addition, accessing | 711 // functions are ints, and they should not overflow. In addition, accessing |
| 702 // local variables creates user-controlled constants in the generated code, | 712 // local variables creates user-controlled constants in the generated code, |
| 703 // and we don't want too much user-controlled memory inside the code (this was | 713 // and we don't want too much user-controlled memory inside the code (this was |
| 704 // the reason why this limit was introduced in the first place; see | 714 // the reason why this limit was introduced in the first place; see |
| 705 // https://codereview.chromium.org/7003030/ ). | 715 // https://codereview.chromium.org/7003030/ ). |
| 706 static const int kMaxNumFunctionLocals = 4194303; // 2^22-1 | 716 static const int kMaxNumFunctionLocals = 4194303; // 2^22-1 |
| 707 | 717 |
| 708 // Returns NULL if parsing failed. | 718 // Returns NULL if parsing failed. |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 | 1240 |
| 1231 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { | 1241 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { |
| 1232 return parser_->ParseDoExpression(ok); | 1242 return parser_->ParseDoExpression(ok); |
| 1233 } | 1243 } |
| 1234 | 1244 |
| 1235 | 1245 |
| 1236 } // namespace internal | 1246 } // namespace internal |
| 1237 } // namespace v8 | 1247 } // namespace v8 |
| 1238 | 1248 |
| 1239 #endif // V8_PARSING_PARSER_H_ | 1249 #endif // V8_PARSING_PARSER_H_ |
| OLD | NEW |