OLD | NEW |
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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 class RegExpBuilder: public ZoneObject { | 262 class RegExpBuilder: public ZoneObject { |
263 public: | 263 public: |
264 explicit RegExpBuilder(Zone* zone); | 264 explicit RegExpBuilder(Zone* zone); |
265 void AddCharacter(uc16 character); | 265 void AddCharacter(uc16 character); |
266 // "Adds" an empty expression. Does nothing except consume a | 266 // "Adds" an empty expression. Does nothing except consume a |
267 // following quantifier | 267 // following quantifier |
268 void AddEmpty(); | 268 void AddEmpty(); |
269 void AddAtom(RegExpTree* tree); | 269 void AddAtom(RegExpTree* tree); |
270 void AddAssertion(RegExpTree* tree); | 270 void AddAssertion(RegExpTree* tree); |
271 void NewAlternative(); // '|' | 271 void NewAlternative(); // '|' |
272 void AddQuantifierToAtom(int min, int max, RegExpQuantifier::Type type); | 272 void AddQuantifierToAtom( |
| 273 int min, int max, RegExpQuantifier::QuantifierType type); |
273 RegExpTree* ToRegExp(); | 274 RegExpTree* ToRegExp(); |
274 | 275 |
275 private: | 276 private: |
276 void FlushCharacters(); | 277 void FlushCharacters(); |
277 void FlushText(); | 278 void FlushText(); |
278 void FlushTerms(); | 279 void FlushTerms(); |
279 Zone* zone() const { return zone_; } | 280 Zone* zone() const { return zone_; } |
280 | 281 |
281 Zone* zone_; | 282 Zone* zone_; |
282 bool pending_empty_; | 283 bool pending_empty_; |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 // compile time value as encoded by CompileTimeValue::GetValue(). | 684 // compile time value as encoded by CompileTimeValue::GetValue(). |
684 // Otherwise, return undefined literal as the placeholder | 685 // Otherwise, return undefined literal as the placeholder |
685 // in the object literal boilerplate. | 686 // in the object literal boilerplate. |
686 Handle<Object> GetBoilerplateValue(Expression* expression); | 687 Handle<Object> GetBoilerplateValue(Expression* expression); |
687 | 688 |
688 ZoneList<Expression*>* ParseArguments(bool* ok); | 689 ZoneList<Expression*>* ParseArguments(bool* ok); |
689 FunctionLiteral* ParseFunctionLiteral(Handle<String> var_name, | 690 FunctionLiteral* ParseFunctionLiteral(Handle<String> var_name, |
690 bool name_is_reserved, | 691 bool name_is_reserved, |
691 bool is_generator, | 692 bool is_generator, |
692 int function_token_position, | 693 int function_token_position, |
693 FunctionLiteral::Type type, | 694 FunctionLiteral::FunctionType type, |
694 bool* ok); | 695 bool* ok); |
695 | 696 |
696 | 697 |
697 // Magical syntax support. | 698 // Magical syntax support. |
698 Expression* ParseV8Intrinsic(bool* ok); | 699 Expression* ParseV8Intrinsic(bool* ok); |
699 | 700 |
700 INLINE(Token::Value peek()) { | 701 INLINE(Token::Value peek()) { |
701 if (stack_overflow_) return Token::ILLEGAL; | 702 if (stack_overflow_) return Token::ILLEGAL; |
702 return scanner().peek(); | 703 return scanner().peek(); |
703 } | 704 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 CompilationInfo* info_; | 861 CompilationInfo* info_; |
861 friend class BlockState; | 862 friend class BlockState; |
862 friend class FunctionState; | 863 friend class FunctionState; |
863 }; | 864 }; |
864 | 865 |
865 | 866 |
866 // Support for handling complex values (array and object literals) that | 867 // Support for handling complex values (array and object literals) that |
867 // can be fully handled at compile time. | 868 // can be fully handled at compile time. |
868 class CompileTimeValue: public AllStatic { | 869 class CompileTimeValue: public AllStatic { |
869 public: | 870 public: |
870 enum Type { | 871 enum LiteralType { |
871 OBJECT_LITERAL_FAST_ELEMENTS, | 872 OBJECT_LITERAL_FAST_ELEMENTS, |
872 OBJECT_LITERAL_SLOW_ELEMENTS, | 873 OBJECT_LITERAL_SLOW_ELEMENTS, |
873 ARRAY_LITERAL | 874 ARRAY_LITERAL |
874 }; | 875 }; |
875 | 876 |
876 static bool IsCompileTimeValue(Expression* expression); | 877 static bool IsCompileTimeValue(Expression* expression); |
877 | 878 |
878 static bool ArrayLiteralElementNeedsInitialization(Expression* value); | 879 static bool ArrayLiteralElementNeedsInitialization(Expression* value); |
879 | 880 |
880 // Get the value as a compile time value. | 881 // Get the value as a compile time value. |
881 static Handle<FixedArray> GetValue(Expression* expression); | 882 static Handle<FixedArray> GetValue(Expression* expression); |
882 | 883 |
883 // Get the type of a compile time value returned by GetValue(). | 884 // Get the type of a compile time value returned by GetValue(). |
884 static Type GetType(Handle<FixedArray> value); | 885 static LiteralType GetLiteralType(Handle<FixedArray> value); |
885 | 886 |
886 // Get the elements array of a compile time value returned by GetValue(). | 887 // Get the elements array of a compile time value returned by GetValue(). |
887 static Handle<FixedArray> GetElements(Handle<FixedArray> value); | 888 static Handle<FixedArray> GetElements(Handle<FixedArray> value); |
888 | 889 |
889 private: | 890 private: |
890 static const int kTypeSlot = 0; | 891 static const int kLiteralTypeSlot = 0; |
891 static const int kElementsSlot = 1; | 892 static const int kElementsSlot = 1; |
892 | 893 |
893 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 894 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
894 }; | 895 }; |
895 | 896 |
896 } } // namespace v8::internal | 897 } } // namespace v8::internal |
897 | 898 |
898 #endif // V8_PARSER_H_ | 899 #endif // V8_PARSER_H_ |
OLD | NEW |