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

Side by Side Diff: src/parser.h

Issue 679943004: Remove AstConstructionVisitor/AstNullVisitor (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | « src/ast.cc ('k') | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSER_H_ 5 #ifndef V8_PARSER_H_
6 #define V8_PARSER_H_ 6 #define V8_PARSER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/compiler.h" // For CachedDataMode 10 #include "src/compiler.h" // For CachedDataMode
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 typedef Yield* YieldExpression; 366 typedef Yield* YieldExpression;
367 typedef v8::internal::FunctionLiteral* FunctionLiteral; 367 typedef v8::internal::FunctionLiteral* FunctionLiteral;
368 typedef v8::internal::ClassLiteral* ClassLiteral; 368 typedef v8::internal::ClassLiteral* ClassLiteral;
369 typedef v8::internal::Literal* Literal; 369 typedef v8::internal::Literal* Literal;
370 typedef ObjectLiteral::Property* ObjectLiteralProperty; 370 typedef ObjectLiteral::Property* ObjectLiteralProperty;
371 typedef ZoneList<v8::internal::Expression*>* ExpressionList; 371 typedef ZoneList<v8::internal::Expression*>* ExpressionList;
372 typedef ZoneList<ObjectLiteral::Property*>* PropertyList; 372 typedef ZoneList<ObjectLiteral::Property*>* PropertyList;
373 typedef ZoneList<v8::internal::Statement*>* StatementList; 373 typedef ZoneList<v8::internal::Statement*>* StatementList;
374 374
375 // For constructing objects returned by the traversing functions. 375 // For constructing objects returned by the traversing functions.
376 typedef AstNodeFactory<AstConstructionVisitor> Factory; 376 typedef AstNodeFactory Factory;
377 }; 377 };
378 378
379 explicit ParserTraits(Parser* parser) : parser_(parser) {} 379 explicit ParserTraits(Parser* parser) : parser_(parser) {}
380 380
381 // Helper functions for recursive descent. 381 // Helper functions for recursive descent.
382 bool IsEvalOrArguments(const AstRawString* identifier) const; 382 bool IsEvalOrArguments(const AstRawString* identifier) const;
383 V8_INLINE bool IsFutureStrictReserved(const AstRawString* identifier) const; 383 V8_INLINE bool IsFutureStrictReserved(const AstRawString* identifier) const;
384 384
385 // Returns true if the expression is of type "this.foo". 385 // Returns true if the expression is of type "this.foo".
386 static bool IsThisProperty(Expression* expression); 386 static bool IsThisProperty(Expression* expression);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 // forwards the information to scope. 444 // forwards the information to scope.
445 void CheckPossibleEvalCall(Expression* expression, Scope* scope); 445 void CheckPossibleEvalCall(Expression* expression, Scope* scope);
446 446
447 // Determine if the expression is a variable proxy and mark it as being used 447 // Determine if the expression is a variable proxy and mark it as being used
448 // in an assignment or with a increment/decrement operator. 448 // in an assignment or with a increment/decrement operator.
449 static Expression* MarkExpressionAsAssigned(Expression* expression); 449 static Expression* MarkExpressionAsAssigned(Expression* expression);
450 450
451 // Returns true if we have a binary expression between two numeric 451 // Returns true if we have a binary expression between two numeric
452 // literals. In that case, *x will be changed to an expression which is the 452 // literals. In that case, *x will be changed to an expression which is the
453 // computed value. 453 // computed value.
454 bool ShortcutNumericLiteralBinaryExpression( 454 bool ShortcutNumericLiteralBinaryExpression(Expression** x, Expression* y,
455 Expression** x, Expression* y, Token::Value op, int pos, 455 Token::Value op, int pos,
456 AstNodeFactory<AstConstructionVisitor>* factory); 456 AstNodeFactory* factory);
457 457
458 // Rewrites the following types of unary expressions: 458 // Rewrites the following types of unary expressions:
459 // not <literal> -> true / false 459 // not <literal> -> true / false
460 // + <numeric literal> -> <numeric literal> 460 // + <numeric literal> -> <numeric literal>
461 // - <numeric literal> -> <numeric literal with value negated> 461 // - <numeric literal> -> <numeric literal with value negated>
462 // ! <literal> -> true / false 462 // ! <literal> -> true / false
463 // The following rewriting rules enable the collection of type feedback 463 // The following rewriting rules enable the collection of type feedback
464 // without any special stub and the multiplication is removed later in 464 // without any special stub and the multiplication is removed later in
465 // Crankshaft's canonicalization pass. 465 // Crankshaft's canonicalization pass.
466 // + foo -> foo * 1 466 // + foo -> foo * 1
467 // - foo -> foo * (-1) 467 // - foo -> foo * (-1)
468 // ~ foo -> foo ^(~0) 468 // ~ foo -> foo ^(~0)
469 Expression* BuildUnaryExpression( 469 Expression* BuildUnaryExpression(Expression* expression, Token::Value op,
470 Expression* expression, Token::Value op, int pos, 470 int pos, AstNodeFactory* factory);
471 AstNodeFactory<AstConstructionVisitor>* factory);
472 471
473 // Generate AST node that throws a ReferenceError with the given type. 472 // Generate AST node that throws a ReferenceError with the given type.
474 Expression* NewThrowReferenceError(const char* type, int pos); 473 Expression* NewThrowReferenceError(const char* type, int pos);
475 474
476 // Generate AST node that throws a SyntaxError with the given 475 // Generate AST node that throws a SyntaxError with the given
477 // type. The first argument may be null (in the handle sense) in 476 // type. The first argument may be null (in the handle sense) in
478 // which case no arguments are passed to the constructor. 477 // which case no arguments are passed to the constructor.
479 Expression* NewThrowSyntaxError( 478 Expression* NewThrowSyntaxError(
480 const char* type, const AstRawString* arg, int pos); 479 const char* type, const AstRawString* arg, int pos);
481 480
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 520
522 // Used in error return values. 521 // Used in error return values.
523 static ZoneList<Expression*>* NullExpressionList() { 522 static ZoneList<Expression*>* NullExpressionList() {
524 return NULL; 523 return NULL;
525 } 524 }
526 525
527 // Non-NULL empty string. 526 // Non-NULL empty string.
528 V8_INLINE const AstRawString* EmptyIdentifierString(); 527 V8_INLINE const AstRawString* EmptyIdentifierString();
529 528
530 // Odd-ball literal creators. 529 // Odd-ball literal creators.
531 Literal* GetLiteralTheHole(int position, 530 Literal* GetLiteralTheHole(int position, AstNodeFactory* factory);
532 AstNodeFactory<AstConstructionVisitor>* factory);
533 531
534 // Producing data during the recursive descent. 532 // Producing data during the recursive descent.
535 const AstRawString* GetSymbol(Scanner* scanner); 533 const AstRawString* GetSymbol(Scanner* scanner);
536 const AstRawString* GetNextSymbol(Scanner* scanner); 534 const AstRawString* GetNextSymbol(Scanner* scanner);
537 const AstRawString* GetNumberAsSymbol(Scanner* scanner); 535 const AstRawString* GetNumberAsSymbol(Scanner* scanner);
538 536
539 Expression* ThisExpression(Scope* scope, 537 Expression* ThisExpression(Scope* scope, AstNodeFactory* factory,
540 AstNodeFactory<AstConstructionVisitor>* factory,
541 int pos = RelocInfo::kNoPosition); 538 int pos = RelocInfo::kNoPosition);
542 Expression* SuperReference(Scope* scope, 539 Expression* SuperReference(Scope* scope, AstNodeFactory* factory,
543 AstNodeFactory<AstConstructionVisitor>* factory,
544 int pos = RelocInfo::kNoPosition); 540 int pos = RelocInfo::kNoPosition);
545 Expression* ClassExpression(const AstRawString* name, Expression* extends, 541 Expression* ClassExpression(const AstRawString* name, Expression* extends,
546 Expression* constructor, 542 Expression* constructor,
547 ZoneList<ObjectLiteral::Property*>* properties, 543 ZoneList<ObjectLiteral::Property*>* properties,
548 int start_position, int end_position, 544 int start_position, int end_position,
549 AstNodeFactory<AstConstructionVisitor>* factory); 545 AstNodeFactory* factory);
550 546
551 Literal* ExpressionFromLiteral( 547 Literal* ExpressionFromLiteral(Token::Value token, int pos, Scanner* scanner,
552 Token::Value token, int pos, Scanner* scanner, 548 AstNodeFactory* factory);
553 AstNodeFactory<AstConstructionVisitor>* factory); 549 Expression* ExpressionFromIdentifier(const AstRawString* name, int pos,
554 Expression* ExpressionFromIdentifier( 550 Scope* scope, AstNodeFactory* factory);
555 const AstRawString* name, int pos, Scope* scope, 551 Expression* ExpressionFromString(int pos, Scanner* scanner,
556 AstNodeFactory<AstConstructionVisitor>* factory); 552 AstNodeFactory* factory);
557 Expression* ExpressionFromString( 553 Expression* GetIterator(Expression* iterable, AstNodeFactory* factory);
558 int pos, Scanner* scanner,
559 AstNodeFactory<AstConstructionVisitor>* factory);
560 Expression* GetIterator(Expression* iterable,
561 AstNodeFactory<AstConstructionVisitor>* factory);
562 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) { 554 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) {
563 return new(zone) ZoneList<v8::internal::Expression*>(size, zone); 555 return new(zone) ZoneList<v8::internal::Expression*>(size, zone);
564 } 556 }
565 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { 557 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) {
566 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); 558 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone);
567 } 559 }
568 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { 560 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) {
569 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); 561 return new(zone) ZoneList<v8::internal::Statement*>(size, zone);
570 } 562 }
571 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type); 563 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type);
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 private: 911 private:
920 static const int kLiteralTypeSlot = 0; 912 static const int kLiteralTypeSlot = 0;
921 static const int kElementsSlot = 1; 913 static const int kElementsSlot = 1;
922 914
923 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 915 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
924 }; 916 };
925 917
926 } } // namespace v8::internal 918 } } // namespace v8::internal
927 919
928 #endif // V8_PARSER_H_ 920 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698