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

Side by Side Diff: src/parser.h

Issue 231073002: WIP: Parser: delay string internalization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: more cleanup Created 6 years, 6 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 | « src/objects.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 "allocation.h" 8 #include "allocation.h"
9 #include "ast.h" 9 #include "ast.h"
10 #include "compiler.h" // For CachedDataMode 10 #include "compiler.h" // For CachedDataMode
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // TODO(marja): To be removed. The Traits object should contain all the data 382 // TODO(marja): To be removed. The Traits object should contain all the data
383 // it needs. 383 // it needs.
384 typedef v8::internal::Parser* Parser; 384 typedef v8::internal::Parser* Parser;
385 385
386 // Used by FunctionState and BlockState. 386 // Used by FunctionState and BlockState.
387 typedef v8::internal::Scope Scope; 387 typedef v8::internal::Scope Scope;
388 typedef Variable GeneratorVariable; 388 typedef Variable GeneratorVariable;
389 typedef v8::internal::Zone Zone; 389 typedef v8::internal::Zone Zone;
390 390
391 // Return types for traversing functions. 391 // Return types for traversing functions.
392 typedef Handle<String> Identifier; 392 typedef const AstString* Identifier;
393 typedef v8::internal::Expression* Expression; 393 typedef v8::internal::Expression* Expression;
394 typedef Yield* YieldExpression; 394 typedef Yield* YieldExpression;
395 typedef v8::internal::FunctionLiteral* FunctionLiteral; 395 typedef v8::internal::FunctionLiteral* FunctionLiteral;
396 typedef v8::internal::Literal* Literal; 396 typedef v8::internal::Literal* Literal;
397 typedef ObjectLiteral::Property* ObjectLiteralProperty; 397 typedef ObjectLiteral::Property* ObjectLiteralProperty;
398 typedef ZoneList<v8::internal::Expression*>* ExpressionList; 398 typedef ZoneList<v8::internal::Expression*>* ExpressionList;
399 typedef ZoneList<ObjectLiteral::Property*>* PropertyList; 399 typedef ZoneList<ObjectLiteral::Property*>* PropertyList;
400 typedef ZoneList<v8::internal::Statement*>* StatementList; 400 typedef ZoneList<v8::internal::Statement*>* StatementList;
401 401
402 // For constructing objects returned by the traversing functions. 402 // For constructing objects returned by the traversing functions.
(...skipping 11 matching lines...) Expand all
414 } 414 }
415 415
416 template<typename FunctionState> 416 template<typename FunctionState>
417 static void TearDownFunctionState(FunctionState* function_state, Zone* zone) { 417 static void TearDownFunctionState(FunctionState* function_state, Zone* zone) {
418 if (function_state->outer_function_state_ != NULL) { 418 if (function_state->outer_function_state_ != NULL) {
419 zone->isolate()->set_ast_node_id(function_state->saved_ast_node_id_); 419 zone->isolate()->set_ast_node_id(function_state->saved_ast_node_id_);
420 } 420 }
421 } 421 }
422 422
423 // Helper functions for recursive descent. 423 // Helper functions for recursive descent.
424 bool IsEvalOrArguments(Handle<String> identifier) const; 424 bool IsEvalOrArguments(const AstString* identifier) const;
425 425
426 // Returns true if the expression is of type "this.foo". 426 // Returns true if the expression is of type "this.foo".
427 static bool IsThisProperty(Expression* expression); 427 static bool IsThisProperty(Expression* expression);
428 428
429 static bool IsIdentifier(Expression* expression); 429 static bool IsIdentifier(Expression* expression);
430 430
431 static Handle<String> AsIdentifier(Expression* expression) { 431 static const AstString* AsIdentifier(Expression* expression) {
432 ASSERT(IsIdentifier(expression)); 432 ASSERT(IsIdentifier(expression));
433 return expression->AsVariableProxy()->name(); 433 return expression->AsVariableProxy()->raw_name();
434 } 434 }
435 435
436 static bool IsBoilerplateProperty(ObjectLiteral::Property* property) { 436 static bool IsBoilerplateProperty(ObjectLiteral::Property* property) {
437 return ObjectLiteral::IsBoilerplateProperty(property); 437 return ObjectLiteral::IsBoilerplateProperty(property);
438 } 438 }
439 439
440 static bool IsArrayIndex(Handle<String> string, uint32_t* index) { 440 static bool IsArrayIndex(const AstString* string, uint32_t* index) {
441 return !string.is_null() && string->AsArrayIndex(index); 441 return string->AsArrayIndex(index);
442 } 442 }
443 443
444 // Functions for encapsulating the differences between parsing and preparsing; 444 // Functions for encapsulating the differences between parsing and preparsing;
445 // operations interleaved with the recursive descent. 445 // operations interleaved with the recursive descent.
446 static void PushLiteralName(FuncNameInferrer* fni, Handle<String> id) { 446 static void PushLiteralName(FuncNameInferrer* fni, const AstString* id) {
447 fni->PushLiteralName(id); 447 fni->PushLiteralName(id);
448 } 448 }
449 void PushPropertyName(FuncNameInferrer* fni, Expression* expression); 449 void PushPropertyName(FuncNameInferrer* fni, Expression* expression);
450 450
451 static void CheckFunctionLiteralInsideTopLevelObjectLiteral( 451 static void CheckFunctionLiteralInsideTopLevelObjectLiteral(
452 Scope* scope, Expression* value, bool* has_function) { 452 Scope* scope, Expression* value, bool* has_function) {
453 if (scope->DeclarationScope()->is_global_scope() && 453 if (scope->DeclarationScope()->is_global_scope() &&
454 value->AsFunctionLiteral() != NULL) { 454 value->AsFunctionLiteral() != NULL) {
455 *has_function = true; 455 *has_function = true;
456 value->AsFunctionLiteral()->set_pretenure(); 456 value->AsFunctionLiteral()->set_pretenure();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 Expression* expression, Token::Value op, int pos, 494 Expression* expression, Token::Value op, int pos,
495 AstNodeFactory<AstConstructionVisitor>* factory); 495 AstNodeFactory<AstConstructionVisitor>* factory);
496 496
497 // Generate AST node that throws a ReferenceError with the given type. 497 // Generate AST node that throws a ReferenceError with the given type.
498 Expression* NewThrowReferenceError(const char* type, int pos); 498 Expression* NewThrowReferenceError(const char* type, int pos);
499 499
500 // Generate AST node that throws a SyntaxError with the given 500 // Generate AST node that throws a SyntaxError with the given
501 // type. The first argument may be null (in the handle sense) in 501 // type. The first argument may be null (in the handle sense) in
502 // which case no arguments are passed to the constructor. 502 // which case no arguments are passed to the constructor.
503 Expression* NewThrowSyntaxError( 503 Expression* NewThrowSyntaxError(
504 const char* type, Handle<Object> arg, int pos); 504 const char* type, const AstString* arg, int pos);
505 505
506 // Generate AST node that throws a TypeError with the given 506 // Generate AST node that throws a TypeError with the given
507 // type. Both arguments must be non-null (in the handle sense). 507 // type. Both arguments must be non-null (in the handle sense).
508 Expression* NewThrowTypeError(const char* type, Handle<Object> arg, int pos); 508 Expression* NewThrowTypeError(const char* type, const AstString* arg,
509 int pos);
509 510
510 // Generic AST generator for throwing errors from compiled code. 511 // Generic AST generator for throwing errors from compiled code.
511 Expression* NewThrowError( 512 Expression* NewThrowError(
512 Handle<String> constructor, const char* type, 513 const AstString* constructor, const char* type,
513 Vector<Handle<Object> > arguments, int pos); 514 const AstString* arg, int pos);
514 515
515 // Reporting errors. 516 // Reporting errors.
516 void ReportMessageAt(Scanner::Location source_location, 517 void ReportMessageAt(Scanner::Location source_location,
517 const char* message, 518 const char* message,
518 const char* arg, 519 const char* arg,
519 bool is_reference_error = false); 520 bool is_reference_error = false);
520 void ReportMessage(const char* message, 521 void ReportMessage(const char* message,
521 MaybeHandle<String> arg, 522 const char* char_arg = NULL,
523 bool is_reference_error = false);
524 void ReportMessage(const char* message,
525 const AstString* arg,
522 bool is_reference_error = false); 526 bool is_reference_error = false);
523 void ReportMessageAt(Scanner::Location source_location, 527 void ReportMessageAt(Scanner::Location source_location,
524 const char* message, 528 const char* message,
525 MaybeHandle<String> arg, 529 const AstString* arg,
526 bool is_reference_error = false); 530 bool is_reference_error = false);
527 531
528 // "null" return type creators. 532 // "null" return type creators.
529 static Handle<String> EmptyIdentifier() { 533 static const AstString* EmptyIdentifier() {
530 return Handle<String>(); 534 return NULL;
531 } 535 }
532 static Expression* EmptyExpression() { 536 static Expression* EmptyExpression() {
533 return NULL; 537 return NULL;
534 } 538 }
535 static Literal* EmptyLiteral() { 539 static Literal* EmptyLiteral() {
536 return NULL; 540 return NULL;
537 } 541 }
538 // Used in error return values. 542 // Used in error return values.
539 static ZoneList<Expression*>* NullExpressionList() { 543 static ZoneList<Expression*>* NullExpressionList() {
540 return NULL; 544 return NULL;
541 } 545 }
542 546
543 // Odd-ball literal creators. 547 // Odd-ball literal creators.
544 Literal* GetLiteralTheHole(int position, 548 Literal* GetLiteralTheHole(int position,
545 AstNodeFactory<AstConstructionVisitor>* factory); 549 AstNodeFactory<AstConstructionVisitor>* factory);
546 550
547 // Producing data during the recursive descent. 551 // Producing data during the recursive descent.
548 Handle<String> GetSymbol(Scanner* scanner = NULL); 552 const AstString* GetSymbol(Scanner* scanner);
549 Handle<String> NextLiteralString(Scanner* scanner, 553 const AstString* GetNextSymbol(Scanner* scanner);
550 PretenureFlag tenured); 554
551 Expression* ThisExpression(Scope* scope, 555 Expression* ThisExpression(Scope* scope,
552 AstNodeFactory<AstConstructionVisitor>* factory); 556 AstNodeFactory<AstConstructionVisitor>* factory);
553 Literal* ExpressionFromLiteral( 557 Literal* ExpressionFromLiteral(
554 Token::Value token, int pos, Scanner* scanner, 558 Token::Value token, int pos, Scanner* scanner,
555 AstNodeFactory<AstConstructionVisitor>* factory); 559 AstNodeFactory<AstConstructionVisitor>* factory);
556 Expression* ExpressionFromIdentifier( 560 Expression* ExpressionFromIdentifier(
557 Handle<String> name, int pos, Scope* scope, 561 const AstString* name, int pos, Scope* scope,
558 AstNodeFactory<AstConstructionVisitor>* factory); 562 AstNodeFactory<AstConstructionVisitor>* factory);
559 Expression* ExpressionFromString( 563 Expression* ExpressionFromString(
560 int pos, Scanner* scanner, 564 int pos, Scanner* scanner,
561 AstNodeFactory<AstConstructionVisitor>* factory); 565 AstNodeFactory<AstConstructionVisitor>* factory);
562 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) { 566 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) {
563 return new(zone) ZoneList<v8::internal::Expression*>(size, zone); 567 return new(zone) ZoneList<v8::internal::Expression*>(size, zone);
564 } 568 }
565 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { 569 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) {
566 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); 570 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone);
567 } 571 }
568 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { 572 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) {
569 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); 573 return new(zone) ZoneList<v8::internal::Statement*>(size, zone);
570 } 574 }
571 575
572 // Temporary glue; these functions will move to ParserBase. 576 // Temporary glue; these functions will move to ParserBase.
573 Expression* ParseV8Intrinsic(bool* ok); 577 Expression* ParseV8Intrinsic(bool* ok);
574 FunctionLiteral* ParseFunctionLiteral( 578 FunctionLiteral* ParseFunctionLiteral(
575 Handle<String> name, 579 const AstString* name,
576 Scanner::Location function_name_location, 580 Scanner::Location function_name_location,
577 bool name_is_strict_reserved, 581 bool name_is_strict_reserved,
578 bool is_generator, 582 bool is_generator,
579 int function_token_position, 583 int function_token_position,
580 FunctionLiteral::FunctionType type, 584 FunctionLiteral::FunctionType type,
581 bool* ok); 585 bool* ok);
582 586
583 private: 587 private:
584 Parser* parser_; 588 Parser* parser_;
585 }; 589 };
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 FunctionLiteral* ParseLazy(Utf16CharacterStream* source); 640 FunctionLiteral* ParseLazy(Utf16CharacterStream* source);
637 641
638 Isolate* isolate() { return isolate_; } 642 Isolate* isolate() { return isolate_; }
639 CompilationInfo* info() const { return info_; } 643 CompilationInfo* info() const { return info_; }
640 644
641 // Called by ParseProgram after setting up the scanner. 645 // Called by ParseProgram after setting up the scanner.
642 FunctionLiteral* DoParseProgram(CompilationInfo* info, 646 FunctionLiteral* DoParseProgram(CompilationInfo* info,
643 Handle<String> source); 647 Handle<String> source);
644 648
645 // Report syntax error 649 // Report syntax error
646 void ReportInvalidCachedData(Handle<String> name, bool* ok); 650 void ReportInvalidCachedData(const AstString* name, bool* ok);
647 651
648 void SetCachedData(ScriptData** data, 652 void SetCachedData(ScriptData** data,
649 CachedDataMode cached_data_mode) { 653 CachedDataMode cached_data_mode) {
650 cached_data_mode_ = cached_data_mode; 654 cached_data_mode_ = cached_data_mode;
651 if (cached_data_mode == NO_CACHED_DATA) { 655 if (cached_data_mode == NO_CACHED_DATA) {
652 cached_data_ = NULL; 656 cached_data_ = NULL;
653 } else { 657 } else {
654 ASSERT(data != NULL); 658 ASSERT(data != NULL);
655 cached_data_ = data; 659 cached_data_ = data;
656 } 660 }
657 } 661 }
658 662
659 bool inside_with() const { return scope_->inside_with(); } 663 bool inside_with() const { return scope_->inside_with(); }
660 ScriptData** cached_data() const { return cached_data_; } 664 ScriptData** cached_data() const { return cached_data_; }
661 CachedDataMode cached_data_mode() const { return cached_data_mode_; } 665 CachedDataMode cached_data_mode() const { return cached_data_mode_; }
662 Scope* DeclarationScope(VariableMode mode) { 666 Scope* DeclarationScope(VariableMode mode) {
663 return IsLexicalVariableMode(mode) 667 return IsLexicalVariableMode(mode)
664 ? scope_ : scope_->DeclarationScope(); 668 ? scope_ : scope_->DeclarationScope();
665 } 669 }
666 670
667 // All ParseXXX functions take as the last argument an *ok parameter 671 // All ParseXXX functions take as the last argument an *ok parameter
668 // which is set to false if parsing failed; it is unchanged otherwise. 672 // which is set to false if parsing failed; it is unchanged otherwise.
669 // By making the 'exception handling' explicit, we are forced to check 673 // By making the 'exception handling' explicit, we are forced to check
670 // for failure at the call sites. 674 // for failure at the call sites.
671 void* ParseSourceElements(ZoneList<Statement*>* processor, int end_token, 675 void* ParseSourceElements(ZoneList<Statement*>* processor, int end_token,
672 bool is_eval, bool is_global, bool* ok); 676 bool is_eval, bool is_global, bool* ok);
673 Statement* ParseModuleElement(ZoneStringList* labels, bool* ok); 677 Statement* ParseModuleElement(ZoneList<const AstString*>* labels, bool* ok);
674 Statement* ParseModuleDeclaration(ZoneStringList* names, bool* ok); 678 Statement* ParseModuleDeclaration(ZoneList<const AstString*>* names,
679 bool* ok);
675 Module* ParseModule(bool* ok); 680 Module* ParseModule(bool* ok);
676 Module* ParseModuleLiteral(bool* ok); 681 Module* ParseModuleLiteral(bool* ok);
677 Module* ParseModulePath(bool* ok); 682 Module* ParseModulePath(bool* ok);
678 Module* ParseModuleVariable(bool* ok); 683 Module* ParseModuleVariable(bool* ok);
679 Module* ParseModuleUrl(bool* ok); 684 Module* ParseModuleUrl(bool* ok);
680 Module* ParseModuleSpecifier(bool* ok); 685 Module* ParseModuleSpecifier(bool* ok);
681 Block* ParseImportDeclaration(bool* ok); 686 Block* ParseImportDeclaration(bool* ok);
682 Statement* ParseExportDeclaration(bool* ok); 687 Statement* ParseExportDeclaration(bool* ok);
683 Statement* ParseBlockElement(ZoneStringList* labels, bool* ok); 688 Statement* ParseBlockElement(ZoneList<const AstString*>* labels, bool* ok);
684 Statement* ParseStatement(ZoneStringList* labels, bool* ok); 689 Statement* ParseStatement(ZoneList<const AstString*>* labels, bool* ok);
685 Statement* ParseFunctionDeclaration(ZoneStringList* names, bool* ok); 690 Statement* ParseFunctionDeclaration(ZoneList<const AstString*>* names,
691 bool* ok);
686 Statement* ParseNativeDeclaration(bool* ok); 692 Statement* ParseNativeDeclaration(bool* ok);
687 Block* ParseBlock(ZoneStringList* labels, bool* ok); 693 Block* ParseBlock(ZoneList<const AstString*>* labels, bool* ok);
688 Block* ParseVariableStatement(VariableDeclarationContext var_context, 694 Block* ParseVariableStatement(VariableDeclarationContext var_context,
689 ZoneStringList* names, 695 ZoneList<const AstString*>* names,
690 bool* ok); 696 bool* ok);
691 Block* ParseVariableDeclarations(VariableDeclarationContext var_context, 697 Block* ParseVariableDeclarations(VariableDeclarationContext var_context,
692 VariableDeclarationProperties* decl_props, 698 VariableDeclarationProperties* decl_props,
693 ZoneStringList* names, 699 ZoneList<const AstString*>* names,
694 Handle<String>* out, 700 const AstString** out,
695 bool* ok); 701 bool* ok);
696 Statement* ParseExpressionOrLabelledStatement(ZoneStringList* labels, 702 Statement* ParseExpressionOrLabelledStatement(
697 bool* ok); 703 ZoneList<const AstString*>* labels, bool* ok);
698 IfStatement* ParseIfStatement(ZoneStringList* labels, bool* ok); 704 IfStatement* ParseIfStatement(ZoneList<const AstString*>* labels, bool* ok);
699 Statement* ParseContinueStatement(bool* ok); 705 Statement* ParseContinueStatement(bool* ok);
700 Statement* ParseBreakStatement(ZoneStringList* labels, bool* ok); 706 Statement* ParseBreakStatement(ZoneList<const AstString*>* labels, bool* ok);
701 Statement* ParseReturnStatement(bool* ok); 707 Statement* ParseReturnStatement(bool* ok);
702 Statement* ParseWithStatement(ZoneStringList* labels, bool* ok); 708 Statement* ParseWithStatement(ZoneList<const AstString*>* labels, bool* ok);
703 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); 709 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok);
704 SwitchStatement* ParseSwitchStatement(ZoneStringList* labels, bool* ok); 710 SwitchStatement* ParseSwitchStatement(ZoneList<const AstString*>* labels,
705 DoWhileStatement* ParseDoWhileStatement(ZoneStringList* labels, bool* ok); 711 bool* ok);
706 WhileStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok); 712 DoWhileStatement* ParseDoWhileStatement(ZoneList<const AstString*>* labels,
707 Statement* ParseForStatement(ZoneStringList* labels, bool* ok); 713 bool* ok);
714 WhileStatement* ParseWhileStatement(ZoneList<const AstString*>* labels,
715 bool* ok);
716 Statement* ParseForStatement(ZoneList<const AstString*>* labels, bool* ok);
708 Statement* ParseThrowStatement(bool* ok); 717 Statement* ParseThrowStatement(bool* ok);
709 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); 718 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value);
710 TryStatement* ParseTryStatement(bool* ok); 719 TryStatement* ParseTryStatement(bool* ok);
711 DebuggerStatement* ParseDebuggerStatement(bool* ok); 720 DebuggerStatement* ParseDebuggerStatement(bool* ok);
712 721
713 // Support for hamony block scoped bindings. 722 // Support for hamony block scoped bindings.
714 Block* ParseScopedBlock(ZoneStringList* labels, bool* ok); 723 Block* ParseScopedBlock(ZoneList<const AstString*>* labels, bool* ok);
715 724
716 // Initialize the components of a for-in / for-of statement. 725 // Initialize the components of a for-in / for-of statement.
717 void InitializeForEachStatement(ForEachStatement* stmt, 726 void InitializeForEachStatement(ForEachStatement* stmt,
718 Expression* each, 727 Expression* each,
719 Expression* subject, 728 Expression* subject,
720 Statement* body); 729 Statement* body);
721 Statement* DesugarLetBindingsInForStatement( 730 Statement* DesugarLetBindingsInForStatement(
722 Scope* inner_scope, ZoneStringList* names, ForStatement* loop, 731 Scope* inner_scope, ZoneList<const AstString*>* names,
723 Statement* init, Expression* cond, Statement* next, Statement* body, 732 ForStatement* loop, Statement* init, Expression* cond, Statement* next,
724 bool* ok); 733 Statement* body, bool* ok);
725 734
726 FunctionLiteral* ParseFunctionLiteral( 735 FunctionLiteral* ParseFunctionLiteral(
727 Handle<String> name, 736 const AstString* name,
728 Scanner::Location function_name_location, 737 Scanner::Location function_name_location,
729 bool name_is_strict_reserved, 738 bool name_is_strict_reserved,
730 bool is_generator, 739 bool is_generator,
731 int function_token_position, 740 int function_token_position,
732 FunctionLiteral::FunctionType type, 741 FunctionLiteral::FunctionType type,
733 bool* ok); 742 bool* ok);
734 743
735 // Magical syntax support. 744 // Magical syntax support.
736 Expression* ParseV8Intrinsic(bool* ok); 745 Expression* ParseV8Intrinsic(bool* ok);
737 746
738 bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode); 747 bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode);
739 748
740 // Get odd-ball literals. 749 // Get odd-ball literals.
741 Literal* GetLiteralUndefined(int position); 750 Literal* GetLiteralUndefined(int position);
742 751
743 // For harmony block scoping mode: Check if the scope has conflicting var/let 752 // For harmony block scoping mode: Check if the scope has conflicting var/let
744 // declarations from different scopes. It covers for example 753 // declarations from different scopes. It covers for example
745 // 754 //
746 // function f() { { { var x; } let x; } } 755 // function f() { { { var x; } let x; } }
747 // function g() { { var x; let x; } } 756 // function g() { { var x; let x; } }
748 // 757 //
749 // The var declarations are hoisted to the function scope, but originate from 758 // The var declarations are hoisted to the function scope, but originate from
750 // a scope where the name has also been let bound or the var declaration is 759 // a scope where the name has also been let bound or the var declaration is
751 // hoisted over such a scope. 760 // hoisted over such a scope.
752 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); 761 void CheckConflictingVarDeclarations(Scope* scope, bool* ok);
753 762
754 // Parser support 763 // Parser support
755 VariableProxy* NewUnresolved(Handle<String> name, 764 VariableProxy* NewUnresolved(const AstString* name,
756 VariableMode mode, 765 VariableMode mode,
757 Interface* interface); 766 Interface* interface);
758 void Declare(Declaration* declaration, bool resolve, bool* ok); 767 void Declare(Declaration* declaration, bool resolve, bool* ok);
759 768
760 bool TargetStackContainsLabel(Handle<String> label); 769 bool TargetStackContainsLabel(const AstString* label);
761 BreakableStatement* LookupBreakTarget(Handle<String> label, bool* ok); 770 BreakableStatement* LookupBreakTarget(const AstString* label, bool* ok);
762 IterationStatement* LookupContinueTarget(Handle<String> label, bool* ok); 771 IterationStatement* LookupContinueTarget(const AstString* label, bool* ok);
763 772
764 void RegisterTargetUse(Label* target, Target* stop); 773 void RegisterTargetUse(Label* target, Target* stop);
765 774
766 // Factory methods. 775 // Factory methods.
767 776
768 Scope* NewScope(Scope* parent, ScopeType type); 777 Scope* NewScope(Scope* parent, ScopeType type);
769 778
770 // Skip over a lazy function, either using cached data if we have it, or 779 // Skip over a lazy function, either using cached data if we have it, or
771 // by parsing the function with PreParser. Consumes the ending }. 780 // by parsing the function with PreParser. Consumes the ending }.
772 void SkipLazyFunctionBody(Handle<String> function_name, 781 void SkipLazyFunctionBody(const AstString* function_name,
773 int* materialized_literal_count, 782 int* materialized_literal_count,
774 int* expected_property_count, 783 int* expected_property_count,
775 bool* ok); 784 bool* ok);
776 785
777 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser( 786 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser(
778 SingletonLogger* logger); 787 SingletonLogger* logger);
779 788
780 // Consumes the ending }. 789 // Consumes the ending }.
781 ZoneList<Statement*>* ParseEagerFunctionBody(Handle<String> function_name, 790 ZoneList<Statement*>* ParseEagerFunctionBody(const AstString* function_name,
782 int pos, 791 int pos,
783 Variable* fvar, 792 Variable* fvar,
784 Token::Value fvar_init_op, 793 Token::Value fvar_init_op,
785 bool is_generator, 794 bool is_generator,
786 bool* ok); 795 bool* ok);
787 796
788 void ThrowPendingError(); 797 void ThrowPendingError();
789 798
790 Isolate* isolate_; 799 Isolate* isolate_;
791 800
792 Handle<Script> script_; 801 Handle<Script> script_;
793 Scanner scanner_; 802 Scanner scanner_;
794 PreParser* reusable_preparser_; 803 PreParser* reusable_preparser_;
795 Scope* original_scope_; // for ES5 function declarations in sloppy eval 804 Scope* original_scope_; // for ES5 function declarations in sloppy eval
796 Target* target_stack_; // for break, continue statements 805 Target* target_stack_; // for break, continue statements
797 ScriptData** cached_data_; 806 ScriptData** cached_data_;
798 CachedDataMode cached_data_mode_; 807 CachedDataMode cached_data_mode_;
808 AstStringTable* string_table_;
799 809
800 CompilationInfo* info_; 810 CompilationInfo* info_;
801 811
802 // Pending errors. 812 // Pending errors.
803 bool has_pending_error_; 813 bool has_pending_error_;
804 Scanner::Location pending_error_location_; 814 Scanner::Location pending_error_location_;
805 const char* pending_error_message_; 815 const char* pending_error_message_;
806 MaybeHandle<String> pending_error_arg_; 816 const AstString* pending_error_arg_;
807 const char* pending_error_char_arg_; 817 const char* pending_error_char_arg_;
808 bool pending_error_is_reference_error_; 818 bool pending_error_is_reference_error_;
809 }; 819 };
810 820
811 821
812 // Support for handling complex values (array and object literals) that 822 // Support for handling complex values (array and object literals) that
813 // can be fully handled at compile time. 823 // can be fully handled at compile time.
814 class CompileTimeValue: public AllStatic { 824 class CompileTimeValue: public AllStatic {
815 public: 825 public:
816 enum LiteralType { 826 enum LiteralType {
(...skipping 16 matching lines...) Expand all
833 private: 843 private:
834 static const int kLiteralTypeSlot = 0; 844 static const int kLiteralTypeSlot = 0;
835 static const int kElementsSlot = 1; 845 static const int kElementsSlot = 1;
836 846
837 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 847 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
838 }; 848 };
839 849
840 } } // namespace v8::internal 850 } } // namespace v8::internal
841 851
842 #endif // V8_PARSER_H_ 852 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698