| 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 function_state->saved_ast_node_id_); | 453 function_state->saved_ast_node_id_); |
| 454 } | 454 } |
| 455 } | 455 } |
| 456 | 456 |
| 457 // Helper functions for recursive descent. | 457 // Helper functions for recursive descent. |
| 458 bool IsEvalOrArguments(Handle<String> identifier) const; | 458 bool IsEvalOrArguments(Handle<String> identifier) const; |
| 459 | 459 |
| 460 // Returns true if the expression is of type "this.foo". | 460 // Returns true if the expression is of type "this.foo". |
| 461 static bool IsThisProperty(Expression* expression); | 461 static bool IsThisProperty(Expression* expression); |
| 462 | 462 |
| 463 static bool IsIdentifier(Expression* expression); | |
| 464 | |
| 465 static bool IsBoilerplateProperty(ObjectLiteral::Property* property) { | 463 static bool IsBoilerplateProperty(ObjectLiteral::Property* property) { |
| 466 return ObjectLiteral::IsBoilerplateProperty(property); | 464 return ObjectLiteral::IsBoilerplateProperty(property); |
| 467 } | 465 } |
| 468 | 466 |
| 469 static bool IsArrayIndex(Handle<String> string, uint32_t* index) { | 467 static bool IsArrayIndex(Handle<String> string, uint32_t* index) { |
| 470 return !string.is_null() && string->AsArrayIndex(index); | 468 return !string.is_null() && string->AsArrayIndex(index); |
| 471 } | 469 } |
| 472 | 470 |
| 473 // Functions for encapsulating the differences between parsing and preparsing; | 471 // Functions for encapsulating the differences between parsing and preparsing; |
| 474 // operations interleaved with the recursive descent. | 472 // operations interleaved with the recursive descent. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 504 // in strict mode. | 502 // in strict mode. |
| 505 void CheckStrictModeLValue(Expression*expression, bool* ok); | 503 void CheckStrictModeLValue(Expression*expression, bool* ok); |
| 506 | 504 |
| 507 // Returns true if we have a binary expression between two numeric | 505 // Returns true if we have a binary expression between two numeric |
| 508 // literals. In that case, *x will be changed to an expression which is the | 506 // literals. In that case, *x will be changed to an expression which is the |
| 509 // computed value. | 507 // computed value. |
| 510 bool ShortcutNumericLiteralBinaryExpression( | 508 bool ShortcutNumericLiteralBinaryExpression( |
| 511 Expression** x, Expression* y, Token::Value op, int pos, | 509 Expression** x, Expression* y, Token::Value op, int pos, |
| 512 AstNodeFactory<AstConstructionVisitor>* factory); | 510 AstNodeFactory<AstConstructionVisitor>* factory); |
| 513 | 511 |
| 514 // Rewrites the following types of unary expressions: | |
| 515 // not <literal> -> true / false | |
| 516 // + <numeric literal> -> <numeric literal> | |
| 517 // - <numeric literal> -> <numeric literal with value negated> | |
| 518 // ! <literal> -> true / false | |
| 519 // The following rewriting rules enable the collection of type feedback | |
| 520 // without any special stub and the multiplication is removed later in | |
| 521 // Crankshaft's canonicalization pass. | |
| 522 // + foo -> foo * 1 | |
| 523 // - foo -> foo * (-1) | |
| 524 // ~ foo -> foo ^(~0) | |
| 525 Expression* BuildUnaryExpression( | |
| 526 Expression* expression, Token::Value op, int pos, | |
| 527 AstNodeFactory<AstConstructionVisitor>* factory); | |
| 528 | |
| 529 // Reporting errors. | 512 // Reporting errors. |
| 530 void ReportMessageAt(Scanner::Location source_location, | 513 void ReportMessageAt(Scanner::Location source_location, |
| 531 const char* message, | 514 const char* message, |
| 532 Vector<const char*> args, | 515 Vector<const char*> args, |
| 533 bool is_reference_error = false); | 516 bool is_reference_error = false); |
| 534 void ReportMessage(const char* message, | 517 void ReportMessage(const char* message, |
| 535 Vector<Handle<String> > args, | 518 Vector<Handle<String> > args, |
| 536 bool is_reference_error = false); | 519 bool is_reference_error = false); |
| 537 void ReportMessageAt(Scanner::Location source_location, | 520 void ReportMessageAt(Scanner::Location source_location, |
| 538 const char* message, | 521 const char* message, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 // Temporary glue; these functions will move to ParserBase. | 565 // Temporary glue; these functions will move to ParserBase. |
| 583 Expression* ParseV8Intrinsic(bool* ok); | 566 Expression* ParseV8Intrinsic(bool* ok); |
| 584 FunctionLiteral* ParseFunctionLiteral( | 567 FunctionLiteral* ParseFunctionLiteral( |
| 585 Handle<String> name, | 568 Handle<String> name, |
| 586 Scanner::Location function_name_location, | 569 Scanner::Location function_name_location, |
| 587 bool name_is_strict_reserved, | 570 bool name_is_strict_reserved, |
| 588 bool is_generator, | 571 bool is_generator, |
| 589 int function_token_position, | 572 int function_token_position, |
| 590 FunctionLiteral::FunctionType type, | 573 FunctionLiteral::FunctionType type, |
| 591 bool* ok); | 574 bool* ok); |
| 592 Expression* ParsePostfixExpression(bool* ok); | 575 Expression* ParseUnaryExpression(bool* ok); |
| 593 | 576 |
| 594 private: | 577 private: |
| 595 Parser* parser_; | 578 Parser* parser_; |
| 596 }; | 579 }; |
| 597 | 580 |
| 598 | 581 |
| 599 class Parser : public ParserBase<ParserTraits> { | 582 class Parser : public ParserBase<ParserTraits> { |
| 600 public: | 583 public: |
| 601 explicit Parser(CompilationInfo* info); | 584 explicit Parser(CompilationInfo* info); |
| 602 ~Parser() { | 585 ~Parser() { |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 private: | 847 private: |
| 865 static const int kLiteralTypeSlot = 0; | 848 static const int kLiteralTypeSlot = 0; |
| 866 static const int kElementsSlot = 1; | 849 static const int kElementsSlot = 1; |
| 867 | 850 |
| 868 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 851 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
| 869 }; | 852 }; |
| 870 | 853 |
| 871 } } // namespace v8::internal | 854 } } // namespace v8::internal |
| 872 | 855 |
| 873 #endif // V8_PARSER_H_ | 856 #endif // V8_PARSER_H_ |
| OLD | NEW |