| 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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 } | 456 } |
| 457 | 457 |
| 458 // Parses the source code represented by the compilation info and sets its | 458 // Parses the source code represented by the compilation info and sets its |
| 459 // function literal. Returns false (and deallocates any allocated AST | 459 // function literal. Returns false (and deallocates any allocated AST |
| 460 // nodes) if parsing failed. | 460 // nodes) if parsing failed. |
| 461 static bool Parse(CompilationInfo* info) { return Parser(info).Parse(); } | 461 static bool Parse(CompilationInfo* info) { return Parser(info).Parse(); } |
| 462 bool Parse(); | 462 bool Parse(); |
| 463 | 463 |
| 464 void ReportMessageAt(Scanner::Location loc, | 464 void ReportMessageAt(Scanner::Location loc, |
| 465 const char* message, | 465 const char* message, |
| 466 Vector<const char*> args); | 466 Vector<const char*> args = Vector<const char*>::empty()); |
| 467 void ReportMessageAt(Scanner::Location loc, | 467 void ReportMessageAt(Scanner::Location loc, |
| 468 const char* message, | 468 const char* message, |
| 469 Vector<Handle<String> > args); | 469 Vector<Handle<String> > args); |
| 470 | 470 |
| 471 private: | 471 private: |
| 472 static const int kMaxNumFunctionLocals = 131071; // 2^17-1 | 472 static const int kMaxNumFunctionLocals = 131071; // 2^17-1 |
| 473 | 473 |
| 474 enum Mode { | 474 enum Mode { |
| 475 PARSE_LAZILY, | 475 PARSE_LAZILY, |
| 476 PARSE_EAGERLY | 476 PARSE_EAGERLY |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 Expression* ParsePostfixExpression(bool* ok); | 664 Expression* ParsePostfixExpression(bool* ok); |
| 665 Expression* ParseLeftHandSideExpression(bool* ok); | 665 Expression* ParseLeftHandSideExpression(bool* ok); |
| 666 Expression* ParseNewExpression(bool* ok); | 666 Expression* ParseNewExpression(bool* ok); |
| 667 Expression* ParseMemberExpression(bool* ok); | 667 Expression* ParseMemberExpression(bool* ok); |
| 668 Expression* ParseNewPrefix(PositionStack* stack, bool* ok); | 668 Expression* ParseNewPrefix(PositionStack* stack, bool* ok); |
| 669 Expression* ParseMemberWithNewPrefixesExpression(PositionStack* stack, | 669 Expression* ParseMemberWithNewPrefixesExpression(PositionStack* stack, |
| 670 bool* ok); | 670 bool* ok); |
| 671 Expression* ParsePrimaryExpression(bool* ok); | 671 Expression* ParsePrimaryExpression(bool* ok); |
| 672 Expression* ParseArrayLiteral(bool* ok); | 672 Expression* ParseArrayLiteral(bool* ok); |
| 673 Expression* ParseObjectLiteral(bool* ok); | 673 Expression* ParseObjectLiteral(bool* ok); |
| 674 ObjectLiteral::Property* ParseObjectLiteralGetSet(bool is_getter, bool* ok); | |
| 675 Expression* ParseRegExpLiteral(bool seen_equal, bool* ok); | 674 Expression* ParseRegExpLiteral(bool seen_equal, bool* ok); |
| 676 | 675 |
| 677 // Populate the constant properties fixed array for a materialized object | 676 // Populate the constant properties fixed array for a materialized object |
| 678 // literal. | 677 // literal. |
| 679 void BuildObjectLiteralConstantProperties( | 678 void BuildObjectLiteralConstantProperties( |
| 680 ZoneList<ObjectLiteral::Property*>* properties, | 679 ZoneList<ObjectLiteral::Property*>* properties, |
| 681 Handle<FixedArray> constants, | 680 Handle<FixedArray> constants, |
| 682 bool* is_simple, | 681 bool* is_simple, |
| 683 bool* fast_elements, | 682 bool* fast_elements, |
| 684 int* depth, | 683 int* depth, |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 // If true, the next (and immediately following) function literal is | 871 // If true, the next (and immediately following) function literal is |
| 873 // preceded by a parenthesis. | 872 // preceded by a parenthesis. |
| 874 // Heuristically that means that the function will be called immediately, | 873 // Heuristically that means that the function will be called immediately, |
| 875 // so never lazily compile it. | 874 // so never lazily compile it. |
| 876 bool parenthesized_function_; | 875 bool parenthesized_function_; |
| 877 | 876 |
| 878 Zone* zone_; | 877 Zone* zone_; |
| 879 CompilationInfo* info_; | 878 CompilationInfo* info_; |
| 880 friend class BlockState; | 879 friend class BlockState; |
| 881 friend class FunctionState; | 880 friend class FunctionState; |
| 881 friend class ObjectLiteralChecker<Parser>; |
| 882 }; | 882 }; |
| 883 | 883 |
| 884 | 884 |
| 885 // Support for handling complex values (array and object literals) that | 885 // Support for handling complex values (array and object literals) that |
| 886 // can be fully handled at compile time. | 886 // can be fully handled at compile time. |
| 887 class CompileTimeValue: public AllStatic { | 887 class CompileTimeValue: public AllStatic { |
| 888 public: | 888 public: |
| 889 enum LiteralType { | 889 enum LiteralType { |
| 890 OBJECT_LITERAL_FAST_ELEMENTS, | 890 OBJECT_LITERAL_FAST_ELEMENTS, |
| 891 OBJECT_LITERAL_SLOW_ELEMENTS, | 891 OBJECT_LITERAL_SLOW_ELEMENTS, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 906 private: | 906 private: |
| 907 static const int kLiteralTypeSlot = 0; | 907 static const int kLiteralTypeSlot = 0; |
| 908 static const int kElementsSlot = 1; | 908 static const int kElementsSlot = 1; |
| 909 | 909 |
| 910 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 910 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
| 911 }; | 911 }; |
| 912 | 912 |
| 913 } } // namespace v8::internal | 913 } } // namespace v8::internal |
| 914 | 914 |
| 915 #endif // V8_PARSER_H_ | 915 #endif // V8_PARSER_H_ |
| OLD | NEW |