Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: src/parser.h

Issue 87783004: DO NOT COMMIT: Trying to use ExperimentalScanner instead of Scanner; doesn't work. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: This doesn't work either Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 virtual const char* Data(); 97 virtual const char* Data();
98 virtual bool HasError(); 98 virtual bool HasError();
99 99
100 void Initialize(); 100 void Initialize();
101 void ReadNextSymbolPosition(); 101 void ReadNextSymbolPosition();
102 102
103 FunctionEntry GetFunctionEntry(int start); 103 FunctionEntry GetFunctionEntry(int start);
104 int GetSymbolIdentifier(); 104 int GetSymbolIdentifier();
105 bool SanityCheck(); 105 bool SanityCheck();
106 106
107 Scanner::Location MessageLocation(); 107 ScannerBase::Location MessageLocation();
108 const char* BuildMessage(); 108 const char* BuildMessage();
109 Vector<const char*> BuildArgs(); 109 Vector<const char*> BuildArgs();
110 110
111 int symbol_count() { 111 int symbol_count() {
112 return (store_.length() > PreparseDataConstants::kHeaderSize) 112 return (store_.length() > PreparseDataConstants::kHeaderSize)
113 ? store_[PreparseDataConstants::kSymbolCountOffset] 113 ? store_[PreparseDataConstants::kSymbolCountOffset]
114 : 0; 114 : 0;
115 } 115 }
116 // The following functions should only be called if SanityCheck has 116 // The following functions should only be called if SanityCheck has
117 // returned true. 117 // returned true.
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 407
408 // Forward declaration. 408 // Forward declaration.
409 class SingletonLogger; 409 class SingletonLogger;
410 410
411 class Parser : public ParserBase { 411 class Parser : public ParserBase {
412 public: 412 public:
413 explicit Parser(CompilationInfo* info); 413 explicit Parser(CompilationInfo* info);
414 ~Parser() { 414 ~Parser() {
415 delete reusable_preparser_; 415 delete reusable_preparser_;
416 reusable_preparser_ = NULL; 416 reusable_preparser_ = NULL;
417 delete scanner_;
418 scanner_ = NULL;
417 } 419 }
418 420
419 // Parses the source code represented by the compilation info and sets its 421 // Parses the source code represented by the compilation info and sets its
420 // function literal. Returns false (and deallocates any allocated AST 422 // function literal. Returns false (and deallocates any allocated AST
421 // nodes) if parsing failed. 423 // nodes) if parsing failed.
422 static bool Parse(CompilationInfo* info) { return Parser(info).Parse(); } 424 static bool Parse(CompilationInfo* info) { return Parser(info).Parse(); }
423 bool Parse(); 425 bool Parse();
424 426
425 private: 427 private:
426 static const int kMaxNumFunctionLocals = 131071; // 2^17-1 428 static const int kMaxNumFunctionLocals = 131071; // 2^17-1
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 518
517 private: 519 private:
518 Parser* parser_; 520 Parser* parser_;
519 Mode old_mode_; 521 Mode old_mode_;
520 }; 522 };
521 523
522 // Returns NULL if parsing failed. 524 // Returns NULL if parsing failed.
523 FunctionLiteral* ParseProgram(); 525 FunctionLiteral* ParseProgram();
524 526
525 FunctionLiteral* ParseLazy(); 527 FunctionLiteral* ParseLazy();
526 FunctionLiteral* ParseLazy(Utf16CharacterStream* source); 528 FunctionLiteral* ParseLazy(Handle<String> source);
527 529
528 Isolate* isolate() { return isolate_; } 530 Isolate* isolate() { return isolate_; }
529 Zone* zone() const { return zone_; } 531 Zone* zone() const { return zone_; }
530 CompilationInfo* info() const { return info_; } 532 CompilationInfo* info() const { return info_; }
531 533
532 // Called by ParseProgram after setting up the scanner. 534 // Called by ParseProgram after setting up the scanner.
533 FunctionLiteral* DoParseProgram(CompilationInfo* info, 535 FunctionLiteral* DoParseProgram(CompilationInfo* info,
534 Handle<String> source); 536 Handle<String> source);
535 537
536 // Report syntax error 538 // Report syntax error
537 void ReportUnexpectedToken(Token::Value token); 539 void ReportUnexpectedToken(Token::Value token);
538 void ReportInvalidPreparseData(Handle<String> name, bool* ok); 540 void ReportInvalidPreparseData(Handle<String> name, bool* ok);
539 void ReportMessage(const char* message, Vector<const char*> args); 541 void ReportMessage(const char* message, Vector<const char*> args);
540 void ReportMessage(const char* message, Vector<Handle<String> > args); 542 void ReportMessage(const char* message, Vector<Handle<String> > args);
541 void ReportMessageAt(Scanner::Location location, const char* type) { 543 void ReportMessageAt(ScannerBase::Location location, const char* type) {
542 ReportMessageAt(location, type, Vector<const char*>::empty()); 544 ReportMessageAt(location, type, Vector<const char*>::empty());
543 } 545 }
544 void ReportMessageAt(Scanner::Location loc, 546 void ReportMessageAt(ScannerBase::Location loc,
545 const char* message, 547 const char* message,
546 Vector<const char*> args); 548 Vector<const char*> args);
547 void ReportMessageAt(Scanner::Location loc, 549 void ReportMessageAt(ScannerBase::Location loc,
548 const char* message, 550 const char* message,
549 Vector<Handle<String> > args); 551 Vector<Handle<String> > args);
550 552
551 void set_pre_parse_data(ScriptDataImpl *data) { 553 void set_pre_parse_data(ScriptDataImpl *data) {
552 pre_parse_data_ = data; 554 pre_parse_data_ = data;
553 symbol_cache_.Initialize(data ? data->symbol_count() : 0, zone()); 555 symbol_cache_.Initialize(data ? data->symbol_count() : 0, zone());
554 } 556 }
555 557
556 bool inside_with() const { return top_scope_->inside_with(); } 558 bool inside_with() const { return top_scope_->inside_with(); }
557 Scanner& scanner() { return scanner_; } 559 ScannerBase& scanner() { return *scanner_; }
558 Mode mode() const { return mode_; } 560 Mode mode() const { return mode_; }
559 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } 561 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; }
560 bool is_extended_mode() { 562 bool is_extended_mode() {
561 ASSERT(top_scope_ != NULL); 563 ASSERT(top_scope_ != NULL);
562 return top_scope_->is_extended_mode(); 564 return top_scope_->is_extended_mode();
563 } 565 }
564 Scope* DeclarationScope(VariableMode mode) { 566 Scope* DeclarationScope(VariableMode mode) {
565 return IsLexicalVariableMode(mode) 567 return IsLexicalVariableMode(mode)
566 ? top_scope_ : top_scope_->DeclarationScope(); 568 ? top_scope_ : top_scope_->DeclarationScope();
567 } 569 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 SingletonLogger* logger); 758 SingletonLogger* logger);
757 759
758 AstNodeFactory<AstConstructionVisitor>* factory() { 760 AstNodeFactory<AstConstructionVisitor>* factory() {
759 return current_function_state_->factory(); 761 return current_function_state_->factory();
760 } 762 }
761 763
762 Isolate* isolate_; 764 Isolate* isolate_;
763 ZoneList<Handle<String> > symbol_cache_; 765 ZoneList<Handle<String> > symbol_cache_;
764 766
765 Handle<Script> script_; 767 Handle<Script> script_;
766 Scanner scanner_;
767 PreParser* reusable_preparser_; 768 PreParser* reusable_preparser_;
768 Scope* top_scope_; 769 Scope* top_scope_;
769 Scope* original_scope_; // for ES5 function declarations in sloppy eval 770 Scope* original_scope_; // for ES5 function declarations in sloppy eval
770 FunctionState* current_function_state_; 771 FunctionState* current_function_state_;
771 Target* target_stack_; // for break, continue statements 772 Target* target_stack_; // for break, continue statements
772 v8::Extension* extension_; 773 v8::Extension* extension_;
773 ScriptDataImpl* pre_parse_data_; 774 ScriptDataImpl* pre_parse_data_;
774 FuncNameInferrer* fni_; 775 FuncNameInferrer* fni_;
775 776
776 Mode mode_; 777 Mode mode_;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 private: 812 private:
812 static const int kLiteralTypeSlot = 0; 813 static const int kLiteralTypeSlot = 0;
813 static const int kElementsSlot = 1; 814 static const int kElementsSlot = 1;
814 815
815 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 816 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
816 }; 817 };
817 818
818 } } // namespace v8::internal 819 } } // namespace v8::internal
819 820
820 #endif // V8_PARSER_H_ 821 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698