| 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 class ParserTraits { | 354 class ParserTraits { |
| 355 public: | 355 public: |
| 356 struct Type { | 356 struct Type { |
| 357 // TODO(marja): To be removed. The Traits object should contain all the data | 357 // TODO(marja): To be removed. The Traits object should contain all the data |
| 358 // it needs. | 358 // it needs. |
| 359 typedef v8::internal::Parser* Parser; | 359 typedef v8::internal::Parser* Parser; |
| 360 | 360 |
| 361 typedef Variable GeneratorVariable; | 361 typedef Variable GeneratorVariable; |
| 362 | 362 |
| 363 typedef v8::internal::AstProperties AstProperties; | 363 typedef v8::internal::AstProperties AstProperties; |
| 364 typedef Vector<VariableProxy*> ParameterIdentifierVector; | |
| 365 | 364 |
| 366 // Return types for traversing functions. | 365 // Return types for traversing functions. |
| 367 typedef const AstRawString* Identifier; | 366 typedef const AstRawString* Identifier; |
| 368 typedef v8::internal::Expression* Expression; | 367 typedef v8::internal::Expression* Expression; |
| 369 typedef Yield* YieldExpression; | 368 typedef Yield* YieldExpression; |
| 370 typedef v8::internal::FunctionLiteral* FunctionLiteral; | 369 typedef v8::internal::FunctionLiteral* FunctionLiteral; |
| 371 typedef v8::internal::ClassLiteral* ClassLiteral; | 370 typedef v8::internal::ClassLiteral* ClassLiteral; |
| 372 typedef v8::internal::Literal* Literal; | 371 typedef v8::internal::Literal* Literal; |
| 373 typedef ObjectLiteral::Property* ObjectLiteralProperty; | 372 typedef ObjectLiteral::Property* ObjectLiteralProperty; |
| 374 typedef ZoneList<v8::internal::Expression*>* ExpressionList; | 373 typedef ZoneList<v8::internal::Expression*>* ExpressionList; |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 | 660 |
| 662 // Limit the allowed number of local variables in a function. The hard limit | 661 // Limit the allowed number of local variables in a function. The hard limit |
| 663 // is that offsets computed by FullCodeGenerator::StackOperand and similar | 662 // is that offsets computed by FullCodeGenerator::StackOperand and similar |
| 664 // functions are ints, and they should not overflow. In addition, accessing | 663 // functions are ints, and they should not overflow. In addition, accessing |
| 665 // local variables creates user-controlled constants in the generated code, | 664 // local variables creates user-controlled constants in the generated code, |
| 666 // and we don't want too much user-controlled memory inside the code (this was | 665 // and we don't want too much user-controlled memory inside the code (this was |
| 667 // the reason why this limit was introduced in the first place; see | 666 // the reason why this limit was introduced in the first place; see |
| 668 // https://codereview.chromium.org/7003030/ ). | 667 // https://codereview.chromium.org/7003030/ ). |
| 669 static const int kMaxNumFunctionLocals = 4194303; // 2^22-1 | 668 static const int kMaxNumFunctionLocals = 4194303; // 2^22-1 |
| 670 | 669 |
| 671 enum VariableDeclarationContext { | |
| 672 kStatementListItem, | |
| 673 kStatement, | |
| 674 kForStatement | |
| 675 }; | |
| 676 | |
| 677 // If a list of variable declarations includes any initializers. | |
| 678 enum VariableDeclarationProperties { | |
| 679 kHasInitializers, | |
| 680 kHasNoInitializers | |
| 681 }; | |
| 682 | |
| 683 // Returns NULL if parsing failed. | 670 // Returns NULL if parsing failed. |
| 684 FunctionLiteral* ParseProgram(); | 671 FunctionLiteral* ParseProgram(); |
| 685 | 672 |
| 686 FunctionLiteral* ParseLazy(); | 673 FunctionLiteral* ParseLazy(); |
| 687 FunctionLiteral* ParseLazy(Utf16CharacterStream* source); | 674 FunctionLiteral* ParseLazy(Utf16CharacterStream* source); |
| 688 | 675 |
| 689 Isolate* isolate() { return info_->isolate(); } | 676 Isolate* isolate() { return info_->isolate(); } |
| 690 CompilationInfo* info() const { return info_; } | 677 CompilationInfo* info() const { return info_; } |
| 691 Handle<Script> script() const { return info_->script(); } | 678 Handle<Script> script() const { return info_->script(); } |
| 692 | 679 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 } | 947 } |
| 961 | 948 |
| 962 | 949 |
| 963 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, | 950 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, |
| 964 int start, Expression* tag) { | 951 int start, Expression* tag) { |
| 965 return parser_->CloseTemplateLiteral(state, start, tag); | 952 return parser_->CloseTemplateLiteral(state, start, tag); |
| 966 } | 953 } |
| 967 } } // namespace v8::internal | 954 } } // namespace v8::internal |
| 968 | 955 |
| 969 #endif // V8_PARSER_H_ | 956 #endif // V8_PARSER_H_ |
| OLD | NEW |