| 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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 }; | 427 }; |
| 428 | 428 |
| 429 // ---------------------------------------------------------------------------- | 429 // ---------------------------------------------------------------------------- |
| 430 // JAVASCRIPT PARSING | 430 // JAVASCRIPT PARSING |
| 431 | 431 |
| 432 // Forward declaration. | 432 // Forward declaration. |
| 433 class SingletonLogger; | 433 class SingletonLogger; |
| 434 | 434 |
| 435 class Parser { | 435 class Parser { |
| 436 public: | 436 public: |
| 437 Parser(Handle<Script> script, | 437 Parser(CompilationInfo* info, |
| 438 int parsing_flags, // Combination of ParsingFlags | 438 int parsing_flags, // Combination of ParsingFlags |
| 439 v8::Extension* extension, | 439 v8::Extension* extension, |
| 440 ScriptDataImpl* pre_data, | 440 ScriptDataImpl* pre_data); |
| 441 Zone* zone); | |
| 442 virtual ~Parser() { | 441 virtual ~Parser() { |
| 443 delete reusable_preparser_; | 442 delete reusable_preparser_; |
| 444 reusable_preparser_ = NULL; | 443 reusable_preparser_ = NULL; |
| 445 } | 444 } |
| 446 | 445 |
| 447 // Returns NULL if parsing failed. | 446 // Returns NULL if parsing failed. |
| 448 FunctionLiteral* ParseProgram(CompilationInfo* info); | 447 FunctionLiteral* ParseProgram(); |
| 449 FunctionLiteral* ParseLazy(CompilationInfo* info); | 448 FunctionLiteral* ParseLazy(); |
| 450 | 449 |
| 451 void ReportMessageAt(Scanner::Location loc, | 450 void ReportMessageAt(Scanner::Location loc, |
| 452 const char* message, | 451 const char* message, |
| 453 Vector<const char*> args); | 452 Vector<const char*> args); |
| 454 void ReportMessageAt(Scanner::Location loc, | 453 void ReportMessageAt(Scanner::Location loc, |
| 455 const char* message, | 454 const char* message, |
| 456 Vector<Handle<String> > args); | 455 Vector<Handle<String> > args); |
| 457 | 456 |
| 458 private: | 457 private: |
| 459 // Limit on number of function parameters is chosen arbitrarily. | 458 // Limit on number of function parameters is chosen arbitrarily. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 Parser* parser_; | 538 Parser* parser_; |
| 540 FunctionState* outer_function_state_; | 539 FunctionState* outer_function_state_; |
| 541 Scope* outer_scope_; | 540 Scope* outer_scope_; |
| 542 int saved_ast_node_id_; | 541 int saved_ast_node_id_; |
| 543 AstNodeFactory<AstConstructionVisitor> factory_; | 542 AstNodeFactory<AstConstructionVisitor> factory_; |
| 544 }; | 543 }; |
| 545 | 544 |
| 546 | 545 |
| 547 | 546 |
| 548 | 547 |
| 549 FunctionLiteral* ParseLazy(CompilationInfo* info, | 548 FunctionLiteral* ParseLazy(Utf16CharacterStream* source, |
| 550 Utf16CharacterStream* source, | |
| 551 ZoneScope* zone_scope); | 549 ZoneScope* zone_scope); |
| 552 | 550 |
| 553 Isolate* isolate() { return isolate_; } | 551 Isolate* isolate() { return isolate_; } |
| 554 Zone* zone() const { return zone_; } | 552 Zone* zone() const { return zone_; } |
| 553 CompilationInfo* info() const { return info_; } |
| 555 | 554 |
| 556 // Called by ParseProgram after setting up the scanner. | 555 // Called by ParseProgram after setting up the scanner. |
| 557 FunctionLiteral* DoParseProgram(CompilationInfo* info, | 556 FunctionLiteral* DoParseProgram(CompilationInfo* info, |
| 558 Handle<String> source, | 557 Handle<String> source, |
| 559 ZoneScope* zone_scope); | 558 ZoneScope* zone_scope); |
| 560 | 559 |
| 561 // Report syntax error | 560 // Report syntax error |
| 562 void ReportUnexpectedToken(Token::Value token); | 561 void ReportUnexpectedToken(Token::Value token); |
| 563 void ReportInvalidPreparseData(Handle<String> name, bool* ok); | 562 void ReportInvalidPreparseData(Handle<String> name, bool* ok); |
| 564 void ReportMessage(const char* message, Vector<const char*> args); | 563 void ReportMessage(const char* message, Vector<const char*> args); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 bool allow_lazy_; | 832 bool allow_lazy_; |
| 834 bool allow_modules_; | 833 bool allow_modules_; |
| 835 bool stack_overflow_; | 834 bool stack_overflow_; |
| 836 // If true, the next (and immediately following) function literal is | 835 // If true, the next (and immediately following) function literal is |
| 837 // preceded by a parenthesis. | 836 // preceded by a parenthesis. |
| 838 // Heuristically that means that the function will be called immediately, | 837 // Heuristically that means that the function will be called immediately, |
| 839 // so never lazily compile it. | 838 // so never lazily compile it. |
| 840 bool parenthesized_function_; | 839 bool parenthesized_function_; |
| 841 | 840 |
| 842 Zone* zone_; | 841 Zone* zone_; |
| 842 CompilationInfo* info_; |
| 843 friend class BlockState; | 843 friend class BlockState; |
| 844 friend class FunctionState; | 844 friend class FunctionState; |
| 845 }; | 845 }; |
| 846 | 846 |
| 847 | 847 |
| 848 // Support for handling complex values (array and object literals) that | 848 // Support for handling complex values (array and object literals) that |
| 849 // can be fully handled at compile time. | 849 // can be fully handled at compile time. |
| 850 class CompileTimeValue: public AllStatic { | 850 class CompileTimeValue: public AllStatic { |
| 851 public: | 851 public: |
| 852 enum Type { | 852 enum Type { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 871 private: | 871 private: |
| 872 static const int kTypeSlot = 0; | 872 static const int kTypeSlot = 0; |
| 873 static const int kElementsSlot = 1; | 873 static const int kElementsSlot = 1; |
| 874 | 874 |
| 875 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 875 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
| 876 }; | 876 }; |
| 877 | 877 |
| 878 } } // namespace v8::internal | 878 } } // namespace v8::internal |
| 879 | 879 |
| 880 #endif // V8_PARSER_H_ | 880 #endif // V8_PARSER_H_ |
| OLD | NEW |