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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Used by FunctionState and BlockState. | 361 // Used by FunctionState and BlockState. |
362 typedef v8::internal::Scope Scope; | 362 typedef v8::internal::Scope Scope; |
363 typedef v8::internal::Scope* ScopePtr; | 363 typedef v8::internal::Scope* ScopePtr; |
364 inline static Scope* ptr_to_scope(ScopePtr scope) { return scope; } | 364 inline static Scope* ptr_to_scope(ScopePtr scope) { return scope; } |
365 | 365 |
366 typedef Variable GeneratorVariable; | 366 typedef Variable GeneratorVariable; |
367 typedef v8::internal::Zone Zone; | |
368 | 367 |
369 typedef v8::internal::AstProperties AstProperties; | 368 typedef v8::internal::AstProperties AstProperties; |
370 typedef Vector<VariableProxy*> ParameterIdentifierVector; | 369 typedef Vector<VariableProxy*> ParameterIdentifierVector; |
371 | 370 |
372 // Return types for traversing functions. | 371 // Return types for traversing functions. |
373 typedef const AstRawString* Identifier; | 372 typedef const AstRawString* Identifier; |
374 typedef v8::internal::Expression* Expression; | 373 typedef v8::internal::Expression* Expression; |
375 typedef Yield* YieldExpression; | 374 typedef Yield* YieldExpression; |
376 typedef v8::internal::FunctionLiteral* FunctionLiteral; | 375 typedef v8::internal::FunctionLiteral* FunctionLiteral; |
377 typedef v8::internal::ClassLiteral* ClassLiteral; | 376 typedef v8::internal::ClassLiteral* ClassLiteral; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { | 561 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { |
563 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); | 562 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); |
564 } | 563 } |
565 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, | 564 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, |
566 FunctionKind kind = kNormalFunction); | 565 FunctionKind kind = kNormalFunction); |
567 | 566 |
568 // Utility functions | 567 // Utility functions |
569 int DeclareArrowParametersFromExpression(Expression* expression, Scope* scope, | 568 int DeclareArrowParametersFromExpression(Expression* expression, Scope* scope, |
570 Scanner::Location* dupe_loc, | 569 Scanner::Location* dupe_loc, |
571 bool* ok); | 570 bool* ok); |
572 V8_INLINE AstValueFactory* ast_value_factory(); | |
573 | 571 |
574 // Temporary glue; these functions will move to ParserBase. | 572 // Temporary glue; these functions will move to ParserBase. |
575 Expression* ParseV8Intrinsic(bool* ok); | 573 Expression* ParseV8Intrinsic(bool* ok); |
576 FunctionLiteral* ParseFunctionLiteral( | 574 FunctionLiteral* ParseFunctionLiteral( |
577 const AstRawString* name, Scanner::Location function_name_location, | 575 const AstRawString* name, Scanner::Location function_name_location, |
578 bool name_is_strict_reserved, FunctionKind kind, | 576 bool name_is_strict_reserved, FunctionKind kind, |
579 int function_token_position, FunctionLiteral::FunctionType type, | 577 int function_token_position, FunctionLiteral::FunctionType type, |
580 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 578 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
581 V8_INLINE void SkipLazyFunctionBody(const AstRawString* name, | 579 V8_INLINE void SkipLazyFunctionBody(const AstRawString* name, |
582 int* materialized_literal_count, | 580 int* materialized_literal_count, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 | 707 |
710 // Returns NULL if parsing failed. | 708 // Returns NULL if parsing failed. |
711 FunctionLiteral* ParseProgram(); | 709 FunctionLiteral* ParseProgram(); |
712 | 710 |
713 FunctionLiteral* ParseLazy(); | 711 FunctionLiteral* ParseLazy(); |
714 FunctionLiteral* ParseLazy(Utf16CharacterStream* source); | 712 FunctionLiteral* ParseLazy(Utf16CharacterStream* source); |
715 | 713 |
716 Isolate* isolate() { return info_->isolate(); } | 714 Isolate* isolate() { return info_->isolate(); } |
717 CompilationInfo* info() const { return info_; } | 715 CompilationInfo* info() const { return info_; } |
718 Handle<Script> script() const { return info_->script(); } | 716 Handle<Script> script() const { return info_->script(); } |
719 AstValueFactory* ast_value_factory() const { | |
720 return info_->ast_value_factory(); | |
721 } | |
722 | 717 |
723 // Called by ParseProgram after setting up the scanner. | 718 // Called by ParseProgram after setting up the scanner. |
724 FunctionLiteral* DoParseProgram(CompilationInfo* info, Scope** scope, | 719 FunctionLiteral* DoParseProgram(CompilationInfo* info, Scope** scope, |
725 Scope** ad_hoc_eval_scope); | 720 Scope** ad_hoc_eval_scope); |
726 | 721 |
727 void SetCachedData(); | 722 void SetCachedData(); |
728 | 723 |
729 bool inside_with() const { return scope_->inside_with(); } | 724 bool inside_with() const { return scope_->inside_with(); } |
730 ScriptCompiler::CompileOptions compile_options() const { | 725 ScriptCompiler::CompileOptions compile_options() const { |
731 return info_->compile_options(); | 726 return info_->compile_options(); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 return parser_->ParseEagerFunctionBody(name, pos, fvar, fvar_init_op, | 935 return parser_->ParseEagerFunctionBody(name, pos, fvar, fvar_init_op, |
941 is_generator, ok); | 936 is_generator, ok); |
942 } | 937 } |
943 | 938 |
944 void ParserTraits::CheckConflictingVarDeclarations(v8::internal::Scope* scope, | 939 void ParserTraits::CheckConflictingVarDeclarations(v8::internal::Scope* scope, |
945 bool* ok) { | 940 bool* ok) { |
946 parser_->CheckConflictingVarDeclarations(scope, ok); | 941 parser_->CheckConflictingVarDeclarations(scope, ok); |
947 } | 942 } |
948 | 943 |
949 | 944 |
950 AstValueFactory* ParserTraits::ast_value_factory() { | |
951 return parser_->ast_value_factory(); | |
952 } | |
953 | |
954 | |
955 // Support for handling complex values (array and object literals) that | 945 // Support for handling complex values (array and object literals) that |
956 // can be fully handled at compile time. | 946 // can be fully handled at compile time. |
957 class CompileTimeValue: public AllStatic { | 947 class CompileTimeValue: public AllStatic { |
958 public: | 948 public: |
959 enum LiteralType { | 949 enum LiteralType { |
960 OBJECT_LITERAL_FAST_ELEMENTS, | 950 OBJECT_LITERAL_FAST_ELEMENTS, |
961 OBJECT_LITERAL_SLOW_ELEMENTS, | 951 OBJECT_LITERAL_SLOW_ELEMENTS, |
962 ARRAY_LITERAL | 952 ARRAY_LITERAL |
963 }; | 953 }; |
964 | 954 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 } | 987 } |
998 | 988 |
999 | 989 |
1000 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, | 990 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, |
1001 int start, Expression* tag) { | 991 int start, Expression* tag) { |
1002 return parser_->CloseTemplateLiteral(state, start, tag); | 992 return parser_->CloseTemplateLiteral(state, start, tag); |
1003 } | 993 } |
1004 } } // namespace v8::internal | 994 } } // namespace v8::internal |
1005 | 995 |
1006 #endif // V8_PARSER_H_ | 996 #endif // V8_PARSER_H_ |
OLD | NEW |