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

Side by Side Diff: src/parser.h

Issue 169853002: (Pre)Parser: Move ParseExpression and ParseArrayLiteral to ParserBase. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: old chunk schmold chunk Created 6 years, 10 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 414
415 // Types used by FunctionState and BlockState. 415 // Types used by FunctionState and BlockState.
416 typedef v8::internal::Scope Scope; 416 typedef v8::internal::Scope Scope;
417 typedef AstNodeFactory<AstConstructionVisitor> Factory; 417 typedef AstNodeFactory<AstConstructionVisitor> Factory;
418 typedef Variable GeneratorVariable; 418 typedef Variable GeneratorVariable;
419 typedef v8::internal::Zone Zone; 419 typedef v8::internal::Zone Zone;
420 420
421 // Return types for traversing functions. 421 // Return types for traversing functions.
422 typedef Handle<String> Identifier; 422 typedef Handle<String> Identifier;
423 typedef v8::internal::Expression* Expression; 423 typedef v8::internal::Expression* Expression;
424 typedef ZoneList<v8::internal::Expression*>* ExpressionList;
424 }; 425 };
425 426
426 explicit ParserTraits(Parser* parser) : parser_(parser) {} 427 explicit ParserTraits(Parser* parser) : parser_(parser) {}
427 428
428 // Custom operations executed when FunctionStates are created and destructed. 429 // Custom operations executed when FunctionStates are created and destructed.
429 template<typename FS> 430 template<typename FS>
430 static void SetUpFunctionState(FS* function_state, Zone* zone) { 431 static void SetUpFunctionState(FS* function_state, Zone* zone) {
431 Isolate* isolate = zone->isolate(); 432 Isolate* isolate = zone->isolate();
432 function_state->isolate_ = isolate; 433 function_state->isolate_ = isolate;
433 function_state->saved_ast_node_id_ = isolate->ast_node_id(); 434 function_state->saved_ast_node_id_ = isolate->ast_node_id();
(...skipping 21 matching lines...) Expand all
455 Vector<Handle<String> > args); 456 Vector<Handle<String> > args);
456 457
457 // "null" return type creators. 458 // "null" return type creators.
458 static Handle<String> EmptyIdentifier() { 459 static Handle<String> EmptyIdentifier() {
459 return Handle<String>(); 460 return Handle<String>();
460 } 461 }
461 static Expression* EmptyExpression() { 462 static Expression* EmptyExpression() {
462 return NULL; 463 return NULL;
463 } 464 }
464 465
466 // Odd-ball literal creators.
467 Literal* GetLiteralTheHole(int position,
468 AstNodeFactory<AstConstructionVisitor>* factory);
469
465 // Producing data during the recursive descent. 470 // Producing data during the recursive descent.
466 Handle<String> GetSymbol(Scanner* scanner = NULL); 471 Handle<String> GetSymbol(Scanner* scanner = NULL);
467 Handle<String> NextLiteralString(Scanner* scanner, 472 Handle<String> NextLiteralString(Scanner* scanner,
468 PretenureFlag tenured); 473 PretenureFlag tenured);
469 Expression* ThisExpression(Scope* scope, 474 Expression* ThisExpression(Scope* scope,
470 AstNodeFactory<AstConstructionVisitor>* factory); 475 AstNodeFactory<AstConstructionVisitor>* factory);
471 Expression* ExpressionFromLiteral( 476 Expression* ExpressionFromLiteral(
472 Token::Value token, int pos, Scanner* scanner, 477 Token::Value token, int pos, Scanner* scanner,
473 AstNodeFactory<AstConstructionVisitor>* factory); 478 AstNodeFactory<AstConstructionVisitor>* factory);
474 Expression* ExpressionFromIdentifier( 479 Expression* ExpressionFromIdentifier(
475 Handle<String> name, int pos, Scope* scope, 480 Handle<String> name, int pos, Scope* scope,
476 AstNodeFactory<AstConstructionVisitor>* factory); 481 AstNodeFactory<AstConstructionVisitor>* factory);
477 Expression* ExpressionFromString( 482 Expression* ExpressionFromString(
478 int pos, Scanner* scanner, 483 int pos, Scanner* scanner,
479 AstNodeFactory<AstConstructionVisitor>* factory); 484 AstNodeFactory<AstConstructionVisitor>* factory);
485 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) {
486 return new(zone) ZoneList<v8::internal::Expression*>(size, zone);
487 }
480 488
481 // Temporary glue; these functions will move to ParserBase. 489 // Temporary glue; these functions will move to ParserBase.
482 Expression* ParseArrayLiteral(bool* ok);
483 Expression* ParseObjectLiteral(bool* ok); 490 Expression* ParseObjectLiteral(bool* ok);
484 Expression* ParseExpression(bool accept_IN, bool* ok); 491 Expression* ParseAssignmentExpression(bool accept_IN, bool* ok);
485 Expression* ParseV8Intrinsic(bool* ok); 492 Expression* ParseV8Intrinsic(bool* ok);
486 493
487 private: 494 private:
488 Parser* parser_; 495 Parser* parser_;
489 }; 496 };
490 497
491 498
492 class Parser : public ParserBase<ParserTraits> { 499 class Parser : public ParserBase<ParserTraits> {
493 public: 500 public:
494 explicit Parser(CompilationInfo* info); 501 explicit Parser(CompilationInfo* info);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 Mode old_mode_; 554 Mode old_mode_;
548 }; 555 };
549 556
550 // Returns NULL if parsing failed. 557 // Returns NULL if parsing failed.
551 FunctionLiteral* ParseProgram(); 558 FunctionLiteral* ParseProgram();
552 559
553 FunctionLiteral* ParseLazy(); 560 FunctionLiteral* ParseLazy();
554 FunctionLiteral* ParseLazy(Utf16CharacterStream* source); 561 FunctionLiteral* ParseLazy(Utf16CharacterStream* source);
555 562
556 Isolate* isolate() { return isolate_; } 563 Isolate* isolate() { return isolate_; }
557 Zone* zone() const { return zone_; }
558 CompilationInfo* info() const { return info_; } 564 CompilationInfo* info() const { return info_; }
559 565
560 // Called by ParseProgram after setting up the scanner. 566 // Called by ParseProgram after setting up the scanner.
561 FunctionLiteral* DoParseProgram(CompilationInfo* info, 567 FunctionLiteral* DoParseProgram(CompilationInfo* info,
562 Handle<String> source); 568 Handle<String> source);
563 569
564 // Report syntax error 570 // Report syntax error
565 void ReportInvalidPreparseData(Handle<String> name, bool* ok); 571 void ReportInvalidPreparseData(Handle<String> name, bool* ok);
566 572
567 void set_pre_parse_data(ScriptDataImpl *data) { 573 void set_pre_parse_data(ScriptDataImpl *data) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 WhileStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok); 629 WhileStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok);
624 Statement* ParseForStatement(ZoneStringList* labels, bool* ok); 630 Statement* ParseForStatement(ZoneStringList* labels, bool* ok);
625 Statement* ParseThrowStatement(bool* ok); 631 Statement* ParseThrowStatement(bool* ok);
626 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); 632 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value);
627 TryStatement* ParseTryStatement(bool* ok); 633 TryStatement* ParseTryStatement(bool* ok);
628 DebuggerStatement* ParseDebuggerStatement(bool* ok); 634 DebuggerStatement* ParseDebuggerStatement(bool* ok);
629 635
630 // Support for hamony block scoped bindings. 636 // Support for hamony block scoped bindings.
631 Block* ParseScopedBlock(ZoneStringList* labels, bool* ok); 637 Block* ParseScopedBlock(ZoneStringList* labels, bool* ok);
632 638
633 Expression* ParseExpression(bool accept_IN, bool* ok);
634 Expression* ParseAssignmentExpression(bool accept_IN, bool* ok); 639 Expression* ParseAssignmentExpression(bool accept_IN, bool* ok);
635 Expression* ParseYieldExpression(bool* ok); 640 Expression* ParseYieldExpression(bool* ok);
636 Expression* ParseConditionalExpression(bool accept_IN, bool* ok); 641 Expression* ParseConditionalExpression(bool accept_IN, bool* ok);
637 Expression* ParseBinaryExpression(int prec, bool accept_IN, bool* ok); 642 Expression* ParseBinaryExpression(int prec, bool accept_IN, bool* ok);
638 Expression* ParseUnaryExpression(bool* ok); 643 Expression* ParseUnaryExpression(bool* ok);
639 Expression* ParsePostfixExpression(bool* ok); 644 Expression* ParsePostfixExpression(bool* ok);
640 Expression* ParseLeftHandSideExpression(bool* ok); 645 Expression* ParseLeftHandSideExpression(bool* ok);
641 Expression* ParseMemberWithNewPrefixesExpression(bool* ok); 646 Expression* ParseMemberWithNewPrefixesExpression(bool* ok);
642 Expression* ParseMemberExpression(bool* ok); 647 Expression* ParseMemberExpression(bool* ok);
643 Expression* ParseMemberExpressionContinuation(Expression* expression, 648 Expression* ParseMemberExpressionContinuation(Expression* expression,
644 bool* ok); 649 bool* ok);
645 Expression* ParseArrayLiteral(bool* ok);
646 Expression* ParseObjectLiteral(bool* ok); 650 Expression* ParseObjectLiteral(bool* ok);
647 651
648 // Initialize the components of a for-in / for-of statement. 652 // Initialize the components of a for-in / for-of statement.
649 void InitializeForEachStatement(ForEachStatement* stmt, 653 void InitializeForEachStatement(ForEachStatement* stmt,
650 Expression* each, 654 Expression* each,
651 Expression* subject, 655 Expression* subject,
652 Statement* body); 656 Statement* body);
653 657
654 ZoneList<Expression*>* ParseArguments(bool* ok); 658 ZoneList<Expression*>* ParseArguments(bool* ok);
655 FunctionLiteral* ParseFunctionLiteral( 659 FunctionLiteral* ParseFunctionLiteral(
(...skipping 15 matching lines...) Expand all
671 return isolate_->factory()->NewStringFromAscii( 675 return isolate_->factory()->NewStringFromAscii(
672 scanner()->literal_ascii_string(), tenured); 676 scanner()->literal_ascii_string(), tenured);
673 } else { 677 } else {
674 return isolate_->factory()->NewStringFromTwoByte( 678 return isolate_->factory()->NewStringFromTwoByte(
675 scanner()->literal_utf16_string(), tenured); 679 scanner()->literal_utf16_string(), tenured);
676 } 680 }
677 } 681 }
678 682
679 // Get odd-ball literals. 683 // Get odd-ball literals.
680 Literal* GetLiteralUndefined(int position); 684 Literal* GetLiteralUndefined(int position);
681 Literal* GetLiteralTheHole(int position);
682 685
683 // Determine if the expression is a variable proxy and mark it as being used 686 // Determine if the expression is a variable proxy and mark it as being used
684 // in an assignment or with a increment/decrement operator. This is currently 687 // in an assignment or with a increment/decrement operator. This is currently
685 // used on for the statically checking assignments to harmony const bindings. 688 // used on for the statically checking assignments to harmony const bindings.
686 void MarkAsLValue(Expression* expression); 689 void MarkAsLValue(Expression* expression);
687 690
688 // Strict mode validation of LValue expressions 691 // Strict mode validation of LValue expressions
689 void CheckStrictModeLValue(Expression* expression, 692 void CheckStrictModeLValue(Expression* expression,
690 bool* ok); 693 bool* ok);
691 694
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 Handle<Script> script_; 751 Handle<Script> script_;
749 Scanner scanner_; 752 Scanner scanner_;
750 PreParser* reusable_preparser_; 753 PreParser* reusable_preparser_;
751 Scope* original_scope_; // for ES5 function declarations in sloppy eval 754 Scope* original_scope_; // for ES5 function declarations in sloppy eval
752 Target* target_stack_; // for break, continue statements 755 Target* target_stack_; // for break, continue statements
753 ScriptDataImpl* pre_parse_data_; 756 ScriptDataImpl* pre_parse_data_;
754 FuncNameInferrer* fni_; 757 FuncNameInferrer* fni_;
755 758
756 Mode mode_; 759 Mode mode_;
757 760
758 Zone* zone_;
759 CompilationInfo* info_; 761 CompilationInfo* info_;
760 }; 762 };
761 763
762 764
763 // Support for handling complex values (array and object literals) that 765 // Support for handling complex values (array and object literals) that
764 // can be fully handled at compile time. 766 // can be fully handled at compile time.
765 class CompileTimeValue: public AllStatic { 767 class CompileTimeValue: public AllStatic {
766 public: 768 public:
767 enum LiteralType { 769 enum LiteralType {
768 OBJECT_LITERAL_FAST_ELEMENTS, 770 OBJECT_LITERAL_FAST_ELEMENTS,
(...skipping 15 matching lines...) Expand all
784 private: 786 private:
785 static const int kLiteralTypeSlot = 0; 787 static const int kLiteralTypeSlot = 0;
786 static const int kElementsSlot = 1; 788 static const int kElementsSlot = 1;
787 789
788 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 790 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
789 }; 791 };
790 792
791 } } // namespace v8::internal 793 } } // namespace v8::internal
792 794
793 #endif // V8_PARSER_H_ 795 #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