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

Side by Side Diff: src/parser.h

Issue 15300018: Add initial parser support for harmony iteration (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase onto current master Created 7 years, 6 months 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 | « src/hydrogen.cc ('k') | 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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 ~Parser() { 430 ~Parser() {
431 delete reusable_preparser_; 431 delete reusable_preparser_;
432 reusable_preparser_ = NULL; 432 reusable_preparser_ = NULL;
433 } 433 }
434 434
435 bool allow_natives_syntax() const { return allow_natives_syntax_; } 435 bool allow_natives_syntax() const { return allow_natives_syntax_; }
436 bool allow_lazy() const { return allow_lazy_; } 436 bool allow_lazy() const { return allow_lazy_; }
437 bool allow_modules() { return scanner().HarmonyModules(); } 437 bool allow_modules() { return scanner().HarmonyModules(); }
438 bool allow_harmony_scoping() { return scanner().HarmonyScoping(); } 438 bool allow_harmony_scoping() { return scanner().HarmonyScoping(); }
439 bool allow_generators() const { return allow_generators_; } 439 bool allow_generators() const { return allow_generators_; }
440 bool allow_for_of() const { return allow_for_of_; }
440 441
441 void set_allow_natives_syntax(bool allow) { allow_natives_syntax_ = allow; } 442 void set_allow_natives_syntax(bool allow) { allow_natives_syntax_ = allow; }
442 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } 443 void set_allow_lazy(bool allow) { allow_lazy_ = allow; }
443 void set_allow_modules(bool allow) { scanner().SetHarmonyModules(allow); } 444 void set_allow_modules(bool allow) { scanner().SetHarmonyModules(allow); }
444 void set_allow_harmony_scoping(bool allow) { 445 void set_allow_harmony_scoping(bool allow) {
445 scanner().SetHarmonyScoping(allow); 446 scanner().SetHarmonyScoping(allow);
446 } 447 }
447 void set_allow_generators(bool allow) { allow_generators_ = allow; } 448 void set_allow_generators(bool allow) { allow_generators_ = allow; }
449 void set_allow_for_of(bool allow) { allow_for_of_ = allow; }
448 450
449 // Parses the source code represented by the compilation info and sets its 451 // Parses the source code represented by the compilation info and sets its
450 // function literal. Returns false (and deallocates any allocated AST 452 // function literal. Returns false (and deallocates any allocated AST
451 // nodes) if parsing failed. 453 // nodes) if parsing failed.
452 static bool Parse(CompilationInfo* info) { return Parser(info).Parse(); } 454 static bool Parse(CompilationInfo* info) { return Parser(info).Parse(); }
453 bool Parse(); 455 bool Parse();
454 456
455 // Returns NULL if parsing failed. 457 // Returns NULL if parsing failed.
456 FunctionLiteral* ParseProgram(); 458 FunctionLiteral* ParseProgram();
457 459
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 // Any further calls to Next or peek will return the illegal token. 716 // Any further calls to Next or peek will return the illegal token.
715 // The current call must return the next token, which might already 717 // The current call must return the next token, which might already
716 // have been peek'ed. 718 // have been peek'ed.
717 stack_overflow_ = true; 719 stack_overflow_ = true;
718 } 720 }
719 return scanner().Next(); 721 return scanner().Next();
720 } 722 }
721 723
722 bool is_generator() const { return current_function_state_->is_generator(); } 724 bool is_generator() const { return current_function_state_->is_generator(); }
723 725
726 bool CheckInOrOf(ForEachStatement::VisitMode* visit_mode);
727
724 bool peek_any_identifier(); 728 bool peek_any_identifier();
725 729
726 INLINE(void Consume(Token::Value token)); 730 INLINE(void Consume(Token::Value token));
727 void Expect(Token::Value token, bool* ok); 731 void Expect(Token::Value token, bool* ok);
728 bool Check(Token::Value token); 732 bool Check(Token::Value token);
729 void ExpectSemicolon(bool* ok); 733 void ExpectSemicolon(bool* ok);
730 void ExpectContextualKeyword(const char* keyword, bool* ok); 734 bool CheckContextualKeyword(Vector<const char> keyword);
735 void ExpectContextualKeyword(Vector<const char> keyword, bool* ok);
731 736
732 Handle<String> LiteralString(PretenureFlag tenured) { 737 Handle<String> LiteralString(PretenureFlag tenured) {
733 if (scanner().is_literal_ascii()) { 738 if (scanner().is_literal_ascii()) {
734 return isolate_->factory()->NewStringFromAscii( 739 return isolate_->factory()->NewStringFromAscii(
735 scanner().literal_ascii_string(), tenured); 740 scanner().literal_ascii_string(), tenured);
736 } else { 741 } else {
737 return isolate_->factory()->NewStringFromTwoByte( 742 return isolate_->factory()->NewStringFromTwoByte(
738 scanner().literal_utf16_string(), tenured); 743 scanner().literal_utf16_string(), tenured);
739 } 744 }
740 } 745 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 FunctionState* current_function_state_; 848 FunctionState* current_function_state_;
844 Target* target_stack_; // for break, continue statements 849 Target* target_stack_; // for break, continue statements
845 v8::Extension* extension_; 850 v8::Extension* extension_;
846 ScriptDataImpl* pre_parse_data_; 851 ScriptDataImpl* pre_parse_data_;
847 FuncNameInferrer* fni_; 852 FuncNameInferrer* fni_;
848 853
849 Mode mode_; 854 Mode mode_;
850 bool allow_natives_syntax_; 855 bool allow_natives_syntax_;
851 bool allow_lazy_; 856 bool allow_lazy_;
852 bool allow_generators_; 857 bool allow_generators_;
858 bool allow_for_of_;
853 bool stack_overflow_; 859 bool stack_overflow_;
854 // If true, the next (and immediately following) function literal is 860 // If true, the next (and immediately following) function literal is
855 // preceded by a parenthesis. 861 // preceded by a parenthesis.
856 // Heuristically that means that the function will be called immediately, 862 // Heuristically that means that the function will be called immediately,
857 // so never lazily compile it. 863 // so never lazily compile it.
858 bool parenthesized_function_; 864 bool parenthesized_function_;
859 865
860 Zone* zone_; 866 Zone* zone_;
861 CompilationInfo* info_; 867 CompilationInfo* info_;
862 friend class BlockState; 868 friend class BlockState;
(...skipping 27 matching lines...) Expand all
890 private: 896 private:
891 static const int kLiteralTypeSlot = 0; 897 static const int kLiteralTypeSlot = 0;
892 static const int kElementsSlot = 1; 898 static const int kElementsSlot = 1;
893 899
894 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 900 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
895 }; 901 };
896 902
897 } } // namespace v8::internal 903 } } // namespace v8::internal
898 904
899 #endif // V8_PARSER_H_ 905 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698