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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 | 263 |
264 private: | 264 private: |
265 ZoneList<T*>* list_; | 265 ZoneList<T*>* list_; |
266 T* last_; | 266 T* last_; |
267 }; | 267 }; |
268 | 268 |
269 | 269 |
270 // Accumulates RegExp atoms and assertions into lists of terms and alternatives. | 270 // Accumulates RegExp atoms and assertions into lists of terms and alternatives. |
271 class RegExpBuilder: public ZoneObject { | 271 class RegExpBuilder: public ZoneObject { |
272 public: | 272 public: |
273 RegExpBuilder(); | 273 explicit RegExpBuilder(Zone* zone); |
274 void AddCharacter(uc16 character); | 274 void AddCharacter(uc16 character); |
275 // "Adds" an empty expression. Does nothing except consume a | 275 // "Adds" an empty expression. Does nothing except consume a |
276 // following quantifier | 276 // following quantifier |
277 void AddEmpty(); | 277 void AddEmpty(); |
278 void AddAtom(RegExpTree* tree); | 278 void AddAtom(RegExpTree* tree); |
279 void AddAssertion(RegExpTree* tree); | 279 void AddAssertion(RegExpTree* tree); |
280 void NewAlternative(); // '|' | 280 void NewAlternative(); // '|' |
281 void AddQuantifierToAtom(int min, int max, RegExpQuantifier::Type type); | 281 void AddQuantifierToAtom(int min, int max, RegExpQuantifier::Type type); |
282 RegExpTree* ToRegExp(); | 282 RegExpTree* ToRegExp(); |
283 | 283 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 CAPTURE, // All positive values represent captures. | 361 CAPTURE, // All positive values represent captures. |
362 POSITIVE_LOOKAHEAD, | 362 POSITIVE_LOOKAHEAD, |
363 NEGATIVE_LOOKAHEAD, | 363 NEGATIVE_LOOKAHEAD, |
364 GROUPING | 364 GROUPING |
365 }; | 365 }; |
366 | 366 |
367 class RegExpParserState : public ZoneObject { | 367 class RegExpParserState : public ZoneObject { |
368 public: | 368 public: |
369 RegExpParserState(RegExpParserState* previous_state, | 369 RegExpParserState(RegExpParserState* previous_state, |
370 SubexpressionType group_type, | 370 SubexpressionType group_type, |
371 int disjunction_capture_index) | 371 int disjunction_capture_index, |
372 Zone* zone) | |
372 : previous_state_(previous_state), | 373 : previous_state_(previous_state), |
373 builder_(new RegExpBuilder()), | 374 builder_(new RegExpBuilder(zone)), |
374 group_type_(group_type), | 375 group_type_(group_type), |
375 disjunction_capture_index_(disjunction_capture_index) {} | 376 disjunction_capture_index_(disjunction_capture_index) {} |
376 // Parser state of containing expression, if any. | 377 // Parser state of containing expression, if any. |
377 RegExpParserState* previous_state() { return previous_state_; } | 378 RegExpParserState* previous_state() { return previous_state_; } |
378 bool IsSubexpression() { return previous_state_ != NULL; } | 379 bool IsSubexpression() { return previous_state_ != NULL; } |
379 // RegExpBuilder building this regexp's AST. | 380 // RegExpBuilder building this regexp's AST. |
380 RegExpBuilder* builder() { return builder_; } | 381 RegExpBuilder* builder() { return builder_; } |
381 // Type of regexp being parsed (parenthesized group or entire regexp). | 382 // Type of regexp being parsed (parenthesized group or entire regexp). |
382 SubexpressionType group_type() { return group_type_; } | 383 SubexpressionType group_type() { return group_type_; } |
383 // Index in captures array of first capture in this sub-expression, if any. | 384 // Index in captures array of first capture in this sub-expression, if any. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 // JAVASCRIPT PARSING | 427 // JAVASCRIPT PARSING |
427 | 428 |
428 // Forward declaration. | 429 // Forward declaration. |
429 class SingletonLogger; | 430 class SingletonLogger; |
430 | 431 |
431 class Parser { | 432 class Parser { |
432 public: | 433 public: |
433 Parser(Handle<Script> script, | 434 Parser(Handle<Script> script, |
434 int parsing_flags, // Combination of ParsingFlags | 435 int parsing_flags, // Combination of ParsingFlags |
435 v8::Extension* extension, | 436 v8::Extension* extension, |
436 ScriptDataImpl* pre_data); | 437 ScriptDataImpl* pre_data, |
438 Zone* zone); | |
437 virtual ~Parser() { | 439 virtual ~Parser() { |
438 delete reusable_preparser_; | 440 delete reusable_preparser_; |
439 reusable_preparser_ = NULL; | 441 reusable_preparser_ = NULL; |
440 } | 442 } |
441 | 443 |
442 // Returns NULL if parsing failed. | 444 // Returns NULL if parsing failed. |
443 FunctionLiteral* ParseProgram(CompilationInfo* info); | 445 FunctionLiteral* ParseProgram(CompilationInfo* info); |
444 FunctionLiteral* ParseLazy(CompilationInfo* info); | 446 FunctionLiteral* ParseLazy(CompilationInfo* info); |
445 | 447 |
446 void ReportMessageAt(Scanner::Location loc, | 448 void ReportMessageAt(Scanner::Location loc, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 }; | 541 }; |
540 | 542 |
541 | 543 |
542 | 544 |
543 | 545 |
544 FunctionLiteral* ParseLazy(CompilationInfo* info, | 546 FunctionLiteral* ParseLazy(CompilationInfo* info, |
545 Utf16CharacterStream* source, | 547 Utf16CharacterStream* source, |
546 ZoneScope* zone_scope); | 548 ZoneScope* zone_scope); |
547 | 549 |
548 Isolate* isolate() { return isolate_; } | 550 Isolate* isolate() { return isolate_; } |
549 Zone* zone() { return isolate_->zone(); } | 551 Zone* zone() { return zone_; } |
550 | 552 |
551 // Called by ParseProgram after setting up the scanner. | 553 // Called by ParseProgram after setting up the scanner. |
552 FunctionLiteral* DoParseProgram(CompilationInfo* info, | 554 FunctionLiteral* DoParseProgram(CompilationInfo* info, |
553 Handle<String> source, | 555 Handle<String> source, |
554 ZoneScope* zone_scope); | 556 ZoneScope* zone_scope); |
555 | 557 |
556 // Report syntax error | 558 // Report syntax error |
557 void ReportUnexpectedToken(Token::Value token); | 559 void ReportUnexpectedToken(Token::Value token); |
558 void ReportInvalidPreparseData(Handle<String> name, bool* ok); | 560 void ReportInvalidPreparseData(Handle<String> name, bool* ok); |
559 void ReportMessage(const char* message, Vector<const char*> args); | 561 void ReportMessage(const char* message, Vector<const char*> args); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
826 Mode mode_; | 828 Mode mode_; |
827 bool allow_natives_syntax_; | 829 bool allow_natives_syntax_; |
828 bool allow_lazy_; | 830 bool allow_lazy_; |
829 bool allow_modules_; | 831 bool allow_modules_; |
830 bool stack_overflow_; | 832 bool stack_overflow_; |
831 // If true, the next (and immediately following) function literal is | 833 // If true, the next (and immediately following) function literal is |
832 // preceded by a parenthesis. | 834 // preceded by a parenthesis. |
833 // Heuristically that means that the function will be called immediately, | 835 // Heuristically that means that the function will be called immediately, |
834 // so never lazily compile it. | 836 // so never lazily compile it. |
835 bool parenthesized_function_; | 837 bool parenthesized_function_; |
836 | 838 |
danno
2012/06/04 10:46:46
No extra space here to match surrounding code.
sanjoy
2012/06/04 11:05:42
Done.
| |
839 Zone* zone_; | |
840 | |
837 friend class BlockState; | 841 friend class BlockState; |
838 friend class FunctionState; | 842 friend class FunctionState; |
839 }; | 843 }; |
840 | 844 |
841 | 845 |
842 // Support for handling complex values (array and object literals) that | 846 // Support for handling complex values (array and object literals) that |
843 // can be fully handled at compile time. | 847 // can be fully handled at compile time. |
844 class CompileTimeValue: public AllStatic { | 848 class CompileTimeValue: public AllStatic { |
845 public: | 849 public: |
846 enum Type { | 850 enum Type { |
(...skipping 18 matching lines...) Expand all Loading... | |
865 private: | 869 private: |
866 static const int kTypeSlot = 0; | 870 static const int kTypeSlot = 0; |
867 static const int kElementsSlot = 1; | 871 static const int kElementsSlot = 1; |
868 | 872 |
869 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 873 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
870 }; | 874 }; |
871 | 875 |
872 } } // namespace v8::internal | 876 } } // namespace v8::internal |
873 | 877 |
874 #endif // V8_PARSER_H_ | 878 #endif // V8_PARSER_H_ |
OLD | NEW |