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

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: Use subtyping instead of enumerated value Created 7 years, 7 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
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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 ~Parser() { 429 ~Parser() {
430 delete reusable_preparser_; 430 delete reusable_preparser_;
431 reusable_preparser_ = NULL; 431 reusable_preparser_ = NULL;
432 } 432 }
433 433
434 bool allow_natives_syntax() const { return allow_natives_syntax_; } 434 bool allow_natives_syntax() const { return allow_natives_syntax_; }
435 bool allow_lazy() const { return allow_lazy_; } 435 bool allow_lazy() const { return allow_lazy_; }
436 bool allow_modules() { return scanner().HarmonyModules(); } 436 bool allow_modules() { return scanner().HarmonyModules(); }
437 bool allow_harmony_scoping() { return scanner().HarmonyScoping(); } 437 bool allow_harmony_scoping() { return scanner().HarmonyScoping(); }
438 bool allow_generators() const { return allow_generators_; } 438 bool allow_generators() const { return allow_generators_; }
439 bool allow_for_of() const { return allow_for_of_; }
439 440
440 void set_allow_natives_syntax(bool allow) { allow_natives_syntax_ = allow; } 441 void set_allow_natives_syntax(bool allow) { allow_natives_syntax_ = allow; }
441 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } 442 void set_allow_lazy(bool allow) { allow_lazy_ = allow; }
442 void set_allow_modules(bool allow) { scanner().SetHarmonyModules(allow); } 443 void set_allow_modules(bool allow) { scanner().SetHarmonyModules(allow); }
443 void set_allow_harmony_scoping(bool allow) { 444 void set_allow_harmony_scoping(bool allow) {
444 scanner().SetHarmonyScoping(allow); 445 scanner().SetHarmonyScoping(allow);
445 } 446 }
446 void set_allow_generators(bool allow) { allow_generators_ = allow; } 447 void set_allow_generators(bool allow) { allow_generators_ = allow; }
448 void set_allow_for_of(bool allow) { allow_for_of_ = allow; }
447 449
448 // Parses the source code represented by the compilation info and sets its 450 // Parses the source code represented by the compilation info and sets its
449 // function literal. Returns false (and deallocates any allocated AST 451 // function literal. Returns false (and deallocates any allocated AST
450 // nodes) if parsing failed. 452 // nodes) if parsing failed.
451 static bool Parse(CompilationInfo* info) { return Parser(info).Parse(); } 453 static bool Parse(CompilationInfo* info) { return Parser(info).Parse(); }
452 bool Parse(); 454 bool Parse();
453 455
454 // Returns NULL if parsing failed. 456 // Returns NULL if parsing failed.
455 FunctionLiteral* ParseProgram(); 457 FunctionLiteral* ParseProgram();
456 458
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 // Any further calls to Next or peek will return the illegal token. 734 // Any further calls to Next or peek will return the illegal token.
733 // The current call must return the next token, which might already 735 // The current call must return the next token, which might already
734 // have been peek'ed. 736 // have been peek'ed.
735 stack_overflow_ = true; 737 stack_overflow_ = true;
736 } 738 }
737 return scanner().Next(); 739 return scanner().Next();
738 } 740 }
739 741
740 bool is_generator() const { return current_function_state_->is_generator(); } 742 bool is_generator() const { return current_function_state_->is_generator(); }
741 743
744 bool CheckInOrOf(ForEachStatement::VisitMode* visit_mode);
745
742 bool peek_any_identifier(); 746 bool peek_any_identifier();
743 747
744 INLINE(void Consume(Token::Value token)); 748 INLINE(void Consume(Token::Value token));
745 void Expect(Token::Value token, bool* ok); 749 void Expect(Token::Value token, bool* ok);
746 bool Check(Token::Value token); 750 bool Check(Token::Value token);
747 void ExpectSemicolon(bool* ok); 751 void ExpectSemicolon(bool* ok);
748 void ExpectContextualKeyword(const char* keyword, bool* ok); 752 bool CheckContextualKeyword(Vector<const char> keyword);
753 void ExpectContextualKeyword(Vector<const char> keyword, bool* ok);
749 754
750 Handle<String> LiteralString(PretenureFlag tenured) { 755 Handle<String> LiteralString(PretenureFlag tenured) {
751 if (scanner().is_literal_ascii()) { 756 if (scanner().is_literal_ascii()) {
752 return isolate_->factory()->NewStringFromAscii( 757 return isolate_->factory()->NewStringFromAscii(
753 scanner().literal_ascii_string(), tenured); 758 scanner().literal_ascii_string(), tenured);
754 } else { 759 } else {
755 return isolate_->factory()->NewStringFromTwoByte( 760 return isolate_->factory()->NewStringFromTwoByte(
756 scanner().literal_utf16_string(), tenured); 761 scanner().literal_utf16_string(), tenured);
757 } 762 }
758 } 763 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 FunctionState* current_function_state_; 866 FunctionState* current_function_state_;
862 Target* target_stack_; // for break, continue statements 867 Target* target_stack_; // for break, continue statements
863 v8::Extension* extension_; 868 v8::Extension* extension_;
864 ScriptDataImpl* pre_parse_data_; 869 ScriptDataImpl* pre_parse_data_;
865 FuncNameInferrer* fni_; 870 FuncNameInferrer* fni_;
866 871
867 Mode mode_; 872 Mode mode_;
868 bool allow_natives_syntax_; 873 bool allow_natives_syntax_;
869 bool allow_lazy_; 874 bool allow_lazy_;
870 bool allow_generators_; 875 bool allow_generators_;
876 bool allow_for_of_;
871 bool stack_overflow_; 877 bool stack_overflow_;
872 // If true, the next (and immediately following) function literal is 878 // If true, the next (and immediately following) function literal is
873 // preceded by a parenthesis. 879 // preceded by a parenthesis.
874 // Heuristically that means that the function will be called immediately, 880 // Heuristically that means that the function will be called immediately,
875 // so never lazily compile it. 881 // so never lazily compile it.
876 bool parenthesized_function_; 882 bool parenthesized_function_;
877 883
878 Zone* zone_; 884 Zone* zone_;
879 CompilationInfo* info_; 885 CompilationInfo* info_;
880 friend class BlockState; 886 friend class BlockState;
(...skipping 27 matching lines...) Expand all
908 private: 914 private:
909 static const int kTypeSlot = 0; 915 static const int kTypeSlot = 0;
910 static const int kElementsSlot = 1; 916 static const int kElementsSlot = 1;
911 917
912 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 918 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
913 }; 919 };
914 920
915 } } // namespace v8::internal 921 } } // namespace v8::internal
916 922
917 #endif // V8_PARSER_H_ 923 #endif // V8_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698