Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Side by Side Diff: src/parser.h

Issue 203193004: Move ParseUnaryExpression into ParserBase and add tests. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: clang build fixes Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
463 static bool IsBoilerplateProperty(ObjectLiteral::Property* property) { 465 static bool IsBoilerplateProperty(ObjectLiteral::Property* property) {
464 return ObjectLiteral::IsBoilerplateProperty(property); 466 return ObjectLiteral::IsBoilerplateProperty(property);
465 } 467 }
466 468
467 static bool IsArrayIndex(Handle<String> string, uint32_t* index) { 469 static bool IsArrayIndex(Handle<String> string, uint32_t* index) {
468 return !string.is_null() && string->AsArrayIndex(index); 470 return !string.is_null() && string->AsArrayIndex(index);
469 } 471 }
470 472
471 // Functions for encapsulating the differences between parsing and preparsing; 473 // Functions for encapsulating the differences between parsing and preparsing;
472 // operations interleaved with the recursive descent. 474 // operations interleaved with the recursive descent.
(...skipping 29 matching lines...) Expand all
502 // in strict mode. 504 // in strict mode.
503 void CheckStrictModeLValue(Expression*expression, bool* ok); 505 void CheckStrictModeLValue(Expression*expression, bool* ok);
504 506
505 // Returns true if we have a binary expression between two numeric 507 // Returns true if we have a binary expression between two numeric
506 // literals. In that case, *x will be changed to an expression which is the 508 // literals. In that case, *x will be changed to an expression which is the
507 // computed value. 509 // computed value.
508 bool ShortcutNumericLiteralBinaryExpression( 510 bool ShortcutNumericLiteralBinaryExpression(
509 Expression** x, Expression* y, Token::Value op, int pos, 511 Expression** x, Expression* y, Token::Value op, int pos,
510 AstNodeFactory<AstConstructionVisitor>* factory); 512 AstNodeFactory<AstConstructionVisitor>* factory);
511 513
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
512 // Reporting errors. 529 // Reporting errors.
513 void ReportMessageAt(Scanner::Location source_location, 530 void ReportMessageAt(Scanner::Location source_location,
514 const char* message, 531 const char* message,
515 Vector<const char*> args, 532 Vector<const char*> args,
516 bool is_reference_error = false); 533 bool is_reference_error = false);
517 void ReportMessage(const char* message, 534 void ReportMessage(const char* message,
518 Vector<Handle<String> > args, 535 Vector<Handle<String> > args,
519 bool is_reference_error = false); 536 bool is_reference_error = false);
520 void ReportMessageAt(Scanner::Location source_location, 537 void ReportMessageAt(Scanner::Location source_location,
521 const char* message, 538 const char* message,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 // Temporary glue; these functions will move to ParserBase. 582 // Temporary glue; these functions will move to ParserBase.
566 Expression* ParseV8Intrinsic(bool* ok); 583 Expression* ParseV8Intrinsic(bool* ok);
567 FunctionLiteral* ParseFunctionLiteral( 584 FunctionLiteral* ParseFunctionLiteral(
568 Handle<String> name, 585 Handle<String> name,
569 Scanner::Location function_name_location, 586 Scanner::Location function_name_location,
570 bool name_is_strict_reserved, 587 bool name_is_strict_reserved,
571 bool is_generator, 588 bool is_generator,
572 int function_token_position, 589 int function_token_position,
573 FunctionLiteral::FunctionType type, 590 FunctionLiteral::FunctionType type,
574 bool* ok); 591 bool* ok);
575 Expression* ParseUnaryExpression(bool* ok); 592 Expression* ParsePostfixExpression(bool* ok);
576 593
577 private: 594 private:
578 Parser* parser_; 595 Parser* parser_;
579 }; 596 };
580 597
581 598
582 class Parser : public ParserBase<ParserTraits> { 599 class Parser : public ParserBase<ParserTraits> {
583 public: 600 public:
584 explicit Parser(CompilationInfo* info); 601 explicit Parser(CompilationInfo* info);
585 ~Parser() { 602 ~Parser() {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 private: 864 private:
848 static const int kLiteralTypeSlot = 0; 865 static const int kLiteralTypeSlot = 0;
849 static const int kElementsSlot = 1; 866 static const int kElementsSlot = 1;
850 867
851 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 868 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
852 }; 869 };
853 870
854 } } // namespace v8::internal 871 } } // namespace v8::internal
855 872
856 #endif // V8_PARSER_H_ 873 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698