Chromium Code Reviews| 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 449 function_state->saved_ast_node_id_); | 449 function_state->saved_ast_node_id_); |
| 450 } | 450 } |
| 451 } | 451 } |
| 452 | 452 |
| 453 // Helper functions for recursive descent. | 453 // Helper functions for recursive descent. |
| 454 bool IsEvalOrArguments(Handle<String> identifier) const; | 454 bool IsEvalOrArguments(Handle<String> identifier) const; |
| 455 | 455 |
| 456 // Returns true if the expression is of type "this.foo". | 456 // Returns true if the expression is of type "this.foo". |
| 457 static bool IsThisProperty(Expression* expression); | 457 static bool IsThisProperty(Expression* expression); |
| 458 | 458 |
| 459 static bool IsIdentifier(Expression* expression); | |
| 460 | |
| 459 static bool IsBoilerplateProperty(ObjectLiteral::Property* property) { | 461 static bool IsBoilerplateProperty(ObjectLiteral::Property* property) { |
| 460 return ObjectLiteral::IsBoilerplateProperty(property); | 462 return ObjectLiteral::IsBoilerplateProperty(property); |
| 461 } | 463 } |
| 462 | 464 |
| 463 static bool IsArrayIndex(Handle<String> string, uint32_t* index) { | 465 static bool IsArrayIndex(Handle<String> string, uint32_t* index) { |
| 464 return !string.is_null() && string->AsArrayIndex(index); | 466 return !string.is_null() && string->AsArrayIndex(index); |
| 465 } | 467 } |
| 466 | 468 |
| 467 // Functions for encapsulating the differences between parsing and preparsing; | 469 // Functions for encapsulating the differences between parsing and preparsing; |
| 468 // operations interleaved with the recursive descent. | 470 // operations interleaved with the recursive descent. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 498 // in strict mode. | 500 // in strict mode. |
| 499 void CheckStrictModeLValue(Expression*expression, bool* ok); | 501 void CheckStrictModeLValue(Expression*expression, bool* ok); |
| 500 | 502 |
| 501 // Returns true if we have a binary expression between two numeric | 503 // Returns true if we have a binary expression between two numeric |
| 502 // literals. In that case, *x will be changed to an expression which is the | 504 // literals. In that case, *x will be changed to an expression which is the |
| 503 // computed value. | 505 // computed value. |
| 504 bool ShortcutNumericLiteralBinaryExpression( | 506 bool ShortcutNumericLiteralBinaryExpression( |
| 505 Expression** x, Expression* y, Token::Value op, int pos, | 507 Expression** x, Expression* y, Token::Value op, int pos, |
| 506 AstNodeFactory<AstConstructionVisitor>* factory); | 508 AstNodeFactory<AstConstructionVisitor>* factory); |
| 507 | 509 |
| 510 // Returns true if we can shortcut the unary expression ("not <literal>" or | |
| 511 // "+/- <numeric literal>"). In that case, *expression will be changed to the | |
| 512 // shortcut. | |
| 513 bool ShortcutLiteralUnaryExpression( | |
|
rossberg
2014/03/19 11:41:46
Nit: not sure I like the name. This is doing const
| |
| 514 Expression** expression, Token::Value op, int pos, | |
| 515 AstNodeFactory<AstConstructionVisitor>* factory); | |
| 516 | |
| 517 // Returns true if we can desugar '+foo' into 'foo*1' (plus other similar | |
| 518 // constructs). This enables the collection of type feedback without any | |
| 519 // special stub and the multiplication is removed later in Crankshaft's | |
| 520 // canonicalization pass. | |
| 521 bool AddUnaryExpressionTypeFeedback( | |
|
rossberg
2014/03/19 11:41:46
Similarly here. I'd perhaps call this RewriteUnary
marja
2014/03/19 12:12:43
Done.
| |
| 522 Expression** expression, Token::Value op, int pos, | |
| 523 AstNodeFactory<AstConstructionVisitor>* factory); | |
| 524 | |
| 508 // Reporting errors. | 525 // Reporting errors. |
| 509 void ReportMessageAt(Scanner::Location source_location, | 526 void ReportMessageAt(Scanner::Location source_location, |
| 510 const char* message, | 527 const char* message, |
| 511 Vector<const char*> args, | 528 Vector<const char*> args, |
| 512 bool is_reference_error = false); | 529 bool is_reference_error = false); |
| 513 void ReportMessage(const char* message, | 530 void ReportMessage(const char* message, |
| 514 Vector<Handle<String> > args, | 531 Vector<Handle<String> > args, |
| 515 bool is_reference_error = false); | 532 bool is_reference_error = false); |
| 516 void ReportMessageAt(Scanner::Location source_location, | 533 void ReportMessageAt(Scanner::Location source_location, |
| 517 const char* message, | 534 const char* message, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 561 // Temporary glue; these functions will move to ParserBase. | 578 // Temporary glue; these functions will move to ParserBase. |
| 562 Expression* ParseV8Intrinsic(bool* ok); | 579 Expression* ParseV8Intrinsic(bool* ok); |
| 563 FunctionLiteral* ParseFunctionLiteral( | 580 FunctionLiteral* ParseFunctionLiteral( |
| 564 Handle<String> name, | 581 Handle<String> name, |
| 565 Scanner::Location function_name_location, | 582 Scanner::Location function_name_location, |
| 566 bool name_is_strict_reserved, | 583 bool name_is_strict_reserved, |
| 567 bool is_generator, | 584 bool is_generator, |
| 568 int function_token_position, | 585 int function_token_position, |
| 569 FunctionLiteral::FunctionType type, | 586 FunctionLiteral::FunctionType type, |
| 570 bool* ok); | 587 bool* ok); |
| 571 Expression* ParseUnaryExpression(bool* ok); | 588 Expression* ParsePostfixExpression(bool* ok); |
| 572 | 589 |
| 573 private: | 590 private: |
| 574 Parser* parser_; | 591 Parser* parser_; |
| 575 }; | 592 }; |
| 576 | 593 |
| 577 | 594 |
| 578 class Parser : public ParserBase<ParserTraits> { | 595 class Parser : public ParserBase<ParserTraits> { |
| 579 public: | 596 public: |
| 580 explicit Parser(CompilationInfo* info); | 597 explicit Parser(CompilationInfo* info); |
| 581 ~Parser() { | 598 ~Parser() { |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 836 private: | 853 private: |
| 837 static const int kLiteralTypeSlot = 0; | 854 static const int kLiteralTypeSlot = 0; |
| 838 static const int kElementsSlot = 1; | 855 static const int kElementsSlot = 1; |
| 839 | 856 |
| 840 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 857 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
| 841 }; | 858 }; |
| 842 | 859 |
| 843 } } // namespace v8::internal | 860 } } // namespace v8::internal |
| 844 | 861 |
| 845 #endif // V8_PARSER_H_ | 862 #endif // V8_PARSER_H_ |
| OLD | NEW |