| 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" // For CachedDataMode | 10 #include "src/compiler.h" // For CachedDataMode |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 // Limit the allowed number of local variables in a function. The hard limit | 689 // Limit the allowed number of local variables in a function. The hard limit |
| 690 // is that offsets computed by FullCodeGenerator::StackOperand and similar | 690 // is that offsets computed by FullCodeGenerator::StackOperand and similar |
| 691 // functions are ints, and they should not overflow. In addition, accessing | 691 // functions are ints, and they should not overflow. In addition, accessing |
| 692 // local variables creates user-controlled constants in the generated code, | 692 // local variables creates user-controlled constants in the generated code, |
| 693 // and we don't want too much user-controlled memory inside the code (this was | 693 // and we don't want too much user-controlled memory inside the code (this was |
| 694 // the reason why this limit was introduced in the first place; see | 694 // the reason why this limit was introduced in the first place; see |
| 695 // https://codereview.chromium.org/7003030/ ). | 695 // https://codereview.chromium.org/7003030/ ). |
| 696 static const int kMaxNumFunctionLocals = 4194303; // 2^22-1 | 696 static const int kMaxNumFunctionLocals = 4194303; // 2^22-1 |
| 697 | 697 |
| 698 enum VariableDeclarationContext { | 698 enum VariableDeclarationContext { |
| 699 kModuleElement, | 699 kStatementListItem, |
| 700 kStatement, | 700 kStatement, |
| 701 kForStatement | 701 kForStatement |
| 702 }; | 702 }; |
| 703 | 703 |
| 704 // If a list of variable declarations includes any initializers. | 704 // If a list of variable declarations includes any initializers. |
| 705 enum VariableDeclarationProperties { | 705 enum VariableDeclarationProperties { |
| 706 kHasInitializers, | 706 kHasInitializers, |
| 707 kHasNoInitializers | 707 kHasNoInitializers |
| 708 }; | 708 }; |
| 709 | 709 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 739 } | 739 } |
| 740 Scope* DeclarationScope(VariableMode mode) { | 740 Scope* DeclarationScope(VariableMode mode) { |
| 741 return IsLexicalVariableMode(mode) | 741 return IsLexicalVariableMode(mode) |
| 742 ? scope_ : scope_->DeclarationScope(); | 742 ? scope_ : scope_->DeclarationScope(); |
| 743 } | 743 } |
| 744 | 744 |
| 745 // All ParseXXX functions take as the last argument an *ok parameter | 745 // All ParseXXX functions take as the last argument an *ok parameter |
| 746 // which is set to false if parsing failed; it is unchanged otherwise. | 746 // which is set to false if parsing failed; it is unchanged otherwise. |
| 747 // By making the 'exception handling' explicit, we are forced to check | 747 // By making the 'exception handling' explicit, we are forced to check |
| 748 // for failure at the call sites. | 748 // for failure at the call sites. |
| 749 void* ParseSourceElements(ZoneList<Statement*>* processor, int end_token, | 749 void* ParseStatementList(ZoneList<Statement*>* processor, int end_token, |
| 750 bool is_eval, bool is_global, | 750 bool is_eval, Scope** ad_hoc_eval_scope, bool* ok); |
| 751 Scope** ad_hoc_eval_scope, bool* ok); | 751 Statement* ParseStatementListItem(bool* ok); |
| 752 Statement* ParseModuleElement(ZoneList<const AstRawString*>* labels, | |
| 753 bool* ok); | |
| 754 Statement* ParseModuleDeclaration(ZoneList<const AstRawString*>* names, | |
| 755 bool* ok); | |
| 756 Module* ParseModule(bool* ok); | 752 Module* ParseModule(bool* ok); |
| 757 Module* ParseModuleLiteral(bool* ok); | 753 Statement* ParseModuleItem(bool* ok); |
| 758 Module* ParseModulePath(bool* ok); | |
| 759 Module* ParseModuleVariable(bool* ok); | |
| 760 Module* ParseModuleUrl(bool* ok); | 754 Module* ParseModuleUrl(bool* ok); |
| 761 Module* ParseModuleSpecifier(bool* ok); | 755 Statement* ParseImportDeclaration(bool* ok); |
| 762 Block* ParseImportDeclaration(bool* ok); | |
| 763 Statement* ParseExportDeclaration(bool* ok); | 756 Statement* ParseExportDeclaration(bool* ok); |
| 764 Statement* ParseBlockElement(ZoneList<const AstRawString*>* labels, bool* ok); | |
| 765 Statement* ParseStatement(ZoneList<const AstRawString*>* labels, bool* ok); | 757 Statement* ParseStatement(ZoneList<const AstRawString*>* labels, bool* ok); |
| 766 Statement* ParseFunctionDeclaration(ZoneList<const AstRawString*>* names, | 758 Statement* ParseFunctionDeclaration(ZoneList<const AstRawString*>* names, |
| 767 bool* ok); | 759 bool* ok); |
| 768 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names, | 760 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names, |
| 769 bool* ok); | 761 bool* ok); |
| 770 Statement* ParseNativeDeclaration(bool* ok); | 762 Statement* ParseNativeDeclaration(bool* ok); |
| 771 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); | 763 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); |
| 772 Block* ParseVariableStatement(VariableDeclarationContext var_context, | 764 Block* ParseVariableStatement(VariableDeclarationContext var_context, |
| 773 ZoneList<const AstRawString*>* names, | 765 ZoneList<const AstRawString*>* names, |
| 774 bool* ok); | 766 bool* ok); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 } | 990 } |
| 999 | 991 |
| 1000 | 992 |
| 1001 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, | 993 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, |
| 1002 int start, Expression* tag) { | 994 int start, Expression* tag) { |
| 1003 return parser_->CloseTemplateLiteral(state, start, tag); | 995 return parser_->CloseTemplateLiteral(state, start, tag); |
| 1004 } | 996 } |
| 1005 } } // namespace v8::internal | 997 } } // namespace v8::internal |
| 1006 | 998 |
| 1007 #endif // V8_PARSER_H_ | 999 #endif // V8_PARSER_H_ |
| OLD | NEW |