OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 namespace v8 { | 37 namespace v8 { |
38 namespace internal { | 38 namespace internal { |
39 | 39 |
40 class CompilationInfo; | 40 class CompilationInfo; |
41 class FuncNameInferrer; | 41 class FuncNameInferrer; |
42 class ParserLog; | 42 class ParserLog; |
43 class PositionStack; | 43 class PositionStack; |
44 class Target; | 44 class Target; |
45 class LexicalScope; | 45 class LexicalScope; |
| 46 class SaveScope; |
46 | 47 |
47 template <typename T> class ZoneListWrapper; | 48 template <typename T> class ZoneListWrapper; |
48 | 49 |
49 | 50 |
50 class ParserMessage : public Malloced { | 51 class ParserMessage : public Malloced { |
51 public: | 52 public: |
52 ParserMessage(Scanner::Location loc, const char* message, | 53 ParserMessage(Scanner::Location loc, const char* message, |
53 Vector<const char*> args) | 54 Vector<const char*> args) |
54 : loc_(loc), | 55 : loc_(loc), |
55 message_(message), | 56 message_(message), |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 FunctionLiteral* DoParseProgram(Handle<String> source, | 467 FunctionLiteral* DoParseProgram(Handle<String> source, |
467 bool in_global_context, | 468 bool in_global_context, |
468 StrictModeFlag strict_mode, | 469 StrictModeFlag strict_mode, |
469 ZoneScope* zone_scope); | 470 ZoneScope* zone_scope); |
470 | 471 |
471 // Report syntax error | 472 // Report syntax error |
472 void ReportUnexpectedToken(Token::Value token); | 473 void ReportUnexpectedToken(Token::Value token); |
473 void ReportInvalidPreparseData(Handle<String> name, bool* ok); | 474 void ReportInvalidPreparseData(Handle<String> name, bool* ok); |
474 void ReportMessage(const char* message, Vector<const char*> args); | 475 void ReportMessage(const char* message, Vector<const char*> args); |
475 | 476 |
476 bool inside_with() const { return with_nesting_level_ > 0; } | 477 bool inside_with() const { return top_scope_->inside_with(); } |
477 JavaScriptScanner& scanner() { return scanner_; } | 478 JavaScriptScanner& scanner() { return scanner_; } |
478 Mode mode() const { return mode_; } | 479 Mode mode() const { return mode_; } |
479 ScriptDataImpl* pre_data() const { return pre_data_; } | 480 ScriptDataImpl* pre_data() const { return pre_data_; } |
480 | 481 |
481 // Check if the given string is 'eval' or 'arguments'. | 482 // Check if the given string is 'eval' or 'arguments'. |
482 bool IsEvalOrArguments(Handle<String> string); | 483 bool IsEvalOrArguments(Handle<String> string); |
483 | 484 |
484 // All ParseXXX functions take as the last argument an *ok parameter | 485 // All ParseXXX functions take as the last argument an *ok parameter |
485 // which is set to false if parsing failed; it is unchanged otherwise. | 486 // which is set to false if parsing failed; it is unchanged otherwise. |
486 // By making the 'exception handling' explicit, we are forced to check | 487 // By making the 'exception handling' explicit, we are forced to check |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 | 668 |
668 void RegisterTargetUse(Label* target, Target* stop); | 669 void RegisterTargetUse(Label* target, Target* stop); |
669 | 670 |
670 // Factory methods. | 671 // Factory methods. |
671 | 672 |
672 Statement* EmptyStatement() { | 673 Statement* EmptyStatement() { |
673 static v8::internal::EmptyStatement empty; | 674 static v8::internal::EmptyStatement empty; |
674 return ∅ | 675 return ∅ |
675 } | 676 } |
676 | 677 |
677 Scope* NewScope(Scope* parent, Scope::Type type, bool inside_with); | 678 Scope* NewScope(Scope* parent, Scope::Type type); |
678 | 679 |
679 Handle<String> LookupSymbol(int symbol_id); | 680 Handle<String> LookupSymbol(int symbol_id); |
680 | 681 |
681 Handle<String> LookupCachedSymbol(int symbol_id); | 682 Handle<String> LookupCachedSymbol(int symbol_id); |
682 | 683 |
683 Expression* NewCall(Expression* expression, | 684 Expression* NewCall(Expression* expression, |
684 ZoneList<Expression*>* arguments, | 685 ZoneList<Expression*>* arguments, |
685 int pos) { | 686 int pos) { |
686 return new(zone()) Call(isolate(), expression, arguments, pos); | 687 return new(zone()) Call(isolate(), expression, arguments, pos); |
687 } | 688 } |
(...skipping 24 matching lines...) Expand all Loading... |
712 Handle<String> type, | 713 Handle<String> type, |
713 Vector< Handle<Object> > arguments); | 714 Vector< Handle<Object> > arguments); |
714 | 715 |
715 Isolate* isolate_; | 716 Isolate* isolate_; |
716 ZoneList<Handle<String> > symbol_cache_; | 717 ZoneList<Handle<String> > symbol_cache_; |
717 | 718 |
718 Handle<Script> script_; | 719 Handle<Script> script_; |
719 JavaScriptScanner scanner_; | 720 JavaScriptScanner scanner_; |
720 | 721 |
721 Scope* top_scope_; | 722 Scope* top_scope_; |
722 int with_nesting_level_; | |
723 | 723 |
724 LexicalScope* lexical_scope_; | 724 LexicalScope* lexical_scope_; |
725 Mode mode_; | 725 Mode mode_; |
726 | 726 |
727 Target* target_stack_; // for break, continue statements | 727 Target* target_stack_; // for break, continue statements |
728 bool allow_natives_syntax_; | 728 bool allow_natives_syntax_; |
729 v8::Extension* extension_; | 729 v8::Extension* extension_; |
730 bool is_pre_parsing_; | 730 bool is_pre_parsing_; |
731 ScriptDataImpl* pre_data_; | 731 ScriptDataImpl* pre_data_; |
732 FuncNameInferrer* fni_; | 732 FuncNameInferrer* fni_; |
733 bool stack_overflow_; | 733 bool stack_overflow_; |
734 // If true, the next (and immediately following) function literal is | 734 // If true, the next (and immediately following) function literal is |
735 // preceded by a parenthesis. | 735 // preceded by a parenthesis. |
736 // Heuristically that means that the function will be called immediately, | 736 // Heuristically that means that the function will be called immediately, |
737 // so never lazily compile it. | 737 // so never lazily compile it. |
738 bool parenthesized_function_; | 738 bool parenthesized_function_; |
739 bool harmony_block_scoping_; | 739 bool harmony_block_scoping_; |
740 | 740 |
741 friend class LexicalScope; | 741 friend class LexicalScope; |
| 742 friend class SaveScope; |
742 }; | 743 }; |
743 | 744 |
744 | 745 |
745 // Support for handling complex values (array and object literals) that | 746 // Support for handling complex values (array and object literals) that |
746 // can be fully handled at compile time. | 747 // can be fully handled at compile time. |
747 class CompileTimeValue: public AllStatic { | 748 class CompileTimeValue: public AllStatic { |
748 public: | 749 public: |
749 enum Type { | 750 enum Type { |
750 OBJECT_LITERAL_FAST_ELEMENTS, | 751 OBJECT_LITERAL_FAST_ELEMENTS, |
751 OBJECT_LITERAL_SLOW_ELEMENTS, | 752 OBJECT_LITERAL_SLOW_ELEMENTS, |
(...skipping 16 matching lines...) Expand all Loading... |
768 private: | 769 private: |
769 static const int kTypeSlot = 0; | 770 static const int kTypeSlot = 0; |
770 static const int kElementsSlot = 1; | 771 static const int kElementsSlot = 1; |
771 | 772 |
772 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 773 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
773 }; | 774 }; |
774 | 775 |
775 } } // namespace v8::internal | 776 } } // namespace v8::internal |
776 | 777 |
777 #endif // V8_PARSER_H_ | 778 #endif // V8_PARSER_H_ |
OLD | NEW |