| 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 "allocation.h" | 8 #include "allocation.h" |
| 9 #include "ast.h" | 9 #include "ast.h" |
| 10 #include "compiler.h" // For CachedDataMode | 10 #include "compiler.h" // For CachedDataMode |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 FunctionEntry GetFunctionEntry(int start); | 85 FunctionEntry GetFunctionEntry(int start); |
| 86 int GetSymbolIdentifier(); | 86 int GetSymbolIdentifier(); |
| 87 bool SanityCheck(); | 87 bool SanityCheck(); |
| 88 | 88 |
| 89 Scanner::Location MessageLocation() const; | 89 Scanner::Location MessageLocation() const; |
| 90 bool IsReferenceError() const; | 90 bool IsReferenceError() const; |
| 91 const char* BuildMessage() const; | 91 const char* BuildMessage() const; |
| 92 Vector<const char*> BuildArgs() const; | 92 Vector<const char*> BuildArgs() const; |
| 93 | 93 |
| 94 int symbol_count() { | |
| 95 return (store_.length() > PreparseDataConstants::kHeaderSize) | |
| 96 ? store_[PreparseDataConstants::kSymbolCountOffset] | |
| 97 : 0; | |
| 98 } | |
| 99 int function_count() { | 94 int function_count() { |
| 100 int functions_size = | 95 int functions_size = |
| 101 static_cast<int>(store_[PreparseDataConstants::kFunctionsSizeOffset]); | 96 static_cast<int>(store_[PreparseDataConstants::kFunctionsSizeOffset]); |
| 102 if (functions_size < 0) return 0; | 97 if (functions_size < 0) return 0; |
| 103 if (functions_size % FunctionEntry::kSize != 0) return 0; | 98 if (functions_size % FunctionEntry::kSize != 0) return 0; |
| 104 return functions_size / FunctionEntry::kSize; | 99 return functions_size / FunctionEntry::kSize; |
| 105 } | 100 } |
| 106 // The following functions should only be called if SanityCheck has | 101 // The following functions should only be called if SanityCheck has |
| 107 // returned true. | 102 // returned true. |
| 108 bool has_error() { return store_[PreparseDataConstants::kHasErrorOffset]; } | 103 bool has_error() { return store_[PreparseDataConstants::kHasErrorOffset]; } |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 void ReportInvalidCachedData(Handle<String> name, bool* ok); | 646 void ReportInvalidCachedData(Handle<String> name, bool* ok); |
| 652 | 647 |
| 653 void SetCachedData(ScriptData** data, | 648 void SetCachedData(ScriptData** data, |
| 654 CachedDataMode cached_data_mode) { | 649 CachedDataMode cached_data_mode) { |
| 655 cached_data_mode_ = cached_data_mode; | 650 cached_data_mode_ = cached_data_mode; |
| 656 if (cached_data_mode == NO_CACHED_DATA) { | 651 if (cached_data_mode == NO_CACHED_DATA) { |
| 657 cached_data_ = NULL; | 652 cached_data_ = NULL; |
| 658 } else { | 653 } else { |
| 659 ASSERT(data != NULL); | 654 ASSERT(data != NULL); |
| 660 cached_data_ = data; | 655 cached_data_ = data; |
| 661 symbol_cache_.Initialize(*data ? (*data)->symbol_count() : 0, zone()); | |
| 662 } | 656 } |
| 663 } | 657 } |
| 664 | 658 |
| 665 bool inside_with() const { return scope_->inside_with(); } | 659 bool inside_with() const { return scope_->inside_with(); } |
| 666 ScriptData** cached_data() const { return cached_data_; } | 660 ScriptData** cached_data() const { return cached_data_; } |
| 667 CachedDataMode cached_data_mode() const { return cached_data_mode_; } | 661 CachedDataMode cached_data_mode() const { return cached_data_mode_; } |
| 668 Scope* DeclarationScope(VariableMode mode) { | 662 Scope* DeclarationScope(VariableMode mode) { |
| 669 return IsLexicalVariableMode(mode) | 663 return IsLexicalVariableMode(mode) |
| 670 ? scope_ : scope_->DeclarationScope(); | 664 ? scope_ : scope_->DeclarationScope(); |
| 671 } | 665 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 bool TargetStackContainsLabel(Handle<String> label); | 756 bool TargetStackContainsLabel(Handle<String> label); |
| 763 BreakableStatement* LookupBreakTarget(Handle<String> label, bool* ok); | 757 BreakableStatement* LookupBreakTarget(Handle<String> label, bool* ok); |
| 764 IterationStatement* LookupContinueTarget(Handle<String> label, bool* ok); | 758 IterationStatement* LookupContinueTarget(Handle<String> label, bool* ok); |
| 765 | 759 |
| 766 void RegisterTargetUse(Label* target, Target* stop); | 760 void RegisterTargetUse(Label* target, Target* stop); |
| 767 | 761 |
| 768 // Factory methods. | 762 // Factory methods. |
| 769 | 763 |
| 770 Scope* NewScope(Scope* parent, ScopeType type); | 764 Scope* NewScope(Scope* parent, ScopeType type); |
| 771 | 765 |
| 772 Handle<String> LookupCachedSymbol(int symbol_id); | |
| 773 | |
| 774 // Skip over a lazy function, either using cached data if we have it, or | 766 // Skip over a lazy function, either using cached data if we have it, or |
| 775 // by parsing the function with PreParser. Consumes the ending }. | 767 // by parsing the function with PreParser. Consumes the ending }. |
| 776 void SkipLazyFunctionBody(Handle<String> function_name, | 768 void SkipLazyFunctionBody(Handle<String> function_name, |
| 777 int* materialized_literal_count, | 769 int* materialized_literal_count, |
| 778 int* expected_property_count, | 770 int* expected_property_count, |
| 779 bool* ok); | 771 bool* ok); |
| 780 | 772 |
| 781 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser( | 773 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser( |
| 782 SingletonLogger* logger); | 774 SingletonLogger* logger); |
| 783 | 775 |
| 784 // Consumes the ending }. | 776 // Consumes the ending }. |
| 785 ZoneList<Statement*>* ParseEagerFunctionBody(Handle<String> function_name, | 777 ZoneList<Statement*>* ParseEagerFunctionBody(Handle<String> function_name, |
| 786 int pos, | 778 int pos, |
| 787 Variable* fvar, | 779 Variable* fvar, |
| 788 Token::Value fvar_init_op, | 780 Token::Value fvar_init_op, |
| 789 bool is_generator, | 781 bool is_generator, |
| 790 bool* ok); | 782 bool* ok); |
| 791 | 783 |
| 792 Isolate* isolate_; | 784 Isolate* isolate_; |
| 793 ZoneList<Handle<String> > symbol_cache_; | |
| 794 | 785 |
| 795 Handle<Script> script_; | 786 Handle<Script> script_; |
| 796 Scanner scanner_; | 787 Scanner scanner_; |
| 797 PreParser* reusable_preparser_; | 788 PreParser* reusable_preparser_; |
| 798 Scope* original_scope_; // for ES5 function declarations in sloppy eval | 789 Scope* original_scope_; // for ES5 function declarations in sloppy eval |
| 799 Target* target_stack_; // for break, continue statements | 790 Target* target_stack_; // for break, continue statements |
| 800 ScriptData** cached_data_; | 791 ScriptData** cached_data_; |
| 801 CachedDataMode cached_data_mode_; | 792 CachedDataMode cached_data_mode_; |
| 802 | 793 |
| 803 CompilationInfo* info_; | 794 CompilationInfo* info_; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 828 private: | 819 private: |
| 829 static const int kLiteralTypeSlot = 0; | 820 static const int kLiteralTypeSlot = 0; |
| 830 static const int kElementsSlot = 1; | 821 static const int kElementsSlot = 1; |
| 831 | 822 |
| 832 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 823 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
| 833 }; | 824 }; |
| 834 | 825 |
| 835 } } // namespace v8::internal | 826 } } // namespace v8::internal |
| 836 | 827 |
| 837 #endif // V8_PARSER_H_ | 828 #endif // V8_PARSER_H_ |
| OLD | NEW |