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

Side by Side Diff: src/parser.h

Issue 335293004: New try: Parser: Delay internalizing strings and values (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: variable renaming + passing const & 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
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 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* 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 FunctionLiteral::ArityRestriction arity_restriction, 585 FunctionLiteral::ArityRestriction arity_restriction,
582 bool* ok); 586 bool* ok);
583 587
584 private: 588 private:
585 Parser* parser_; 589 Parser* parser_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 FunctionLiteral* ParseLazy(Utf16CharacterStream* source); 641 FunctionLiteral* ParseLazy(Utf16CharacterStream* source);
638 642
639 Isolate* isolate() { return isolate_; } 643 Isolate* isolate() { return isolate_; }
640 CompilationInfo* info() const { return info_; } 644 CompilationInfo* info() const { return info_; }
641 645
642 // Called by ParseProgram after setting up the scanner. 646 // Called by ParseProgram after setting up the scanner.
643 FunctionLiteral* DoParseProgram(CompilationInfo* info, 647 FunctionLiteral* DoParseProgram(CompilationInfo* info,
644 Handle<String> source); 648 Handle<String> source);
645 649
646 // Report syntax error 650 // Report syntax error
647 void ReportInvalidCachedData(Handle<String> name, bool* ok); 651 void ReportInvalidCachedData(const AstString* name, bool* ok);
648 652
649 void SetCachedData(ScriptData** data, 653 void SetCachedData(ScriptData** data,
650 CachedDataMode cached_data_mode) { 654 CachedDataMode cached_data_mode) {
651 cached_data_mode_ = cached_data_mode; 655 cached_data_mode_ = cached_data_mode;
652 if (cached_data_mode == NO_CACHED_DATA) { 656 if (cached_data_mode == NO_CACHED_DATA) {
653 cached_data_ = NULL; 657 cached_data_ = NULL;
654 } else { 658 } else {
655 ASSERT(data != NULL); 659 ASSERT(data != NULL);
656 cached_data_ = data; 660 cached_data_ = data;
657 } 661 }
658 } 662 }
659 663
660 bool inside_with() const { return scope_->inside_with(); } 664 bool inside_with() const { return scope_->inside_with(); }
661 ScriptData** cached_data() const { return cached_data_; } 665 ScriptData** cached_data() const { return cached_data_; }
662 CachedDataMode cached_data_mode() const { return cached_data_mode_; } 666 CachedDataMode cached_data_mode() const { return cached_data_mode_; }
663 Scope* DeclarationScope(VariableMode mode) { 667 Scope* DeclarationScope(VariableMode mode) {
664 return IsLexicalVariableMode(mode) 668 return IsLexicalVariableMode(mode)
665 ? scope_ : scope_->DeclarationScope(); 669 ? scope_ : scope_->DeclarationScope();
666 } 670 }
667 671
668 // All ParseXXX functions take as the last argument an *ok parameter 672 // All ParseXXX functions take as the last argument an *ok parameter
669 // which is set to false if parsing failed; it is unchanged otherwise. 673 // which is set to false if parsing failed; it is unchanged otherwise.
670 // By making the 'exception handling' explicit, we are forced to check 674 // By making the 'exception handling' explicit, we are forced to check
671 // for failure at the call sites. 675 // for failure at the call sites.
672 void* ParseSourceElements(ZoneList<Statement*>* processor, int end_token, 676 void* ParseSourceElements(ZoneList<Statement*>* processor, int end_token,
673 bool is_eval, bool is_global, bool* ok); 677 bool is_eval, bool is_global, bool* ok);
674 Statement* ParseModuleElement(ZoneStringList* labels, bool* ok); 678 Statement* ParseModuleElement(ZoneList<const AstString*>* labels, bool* ok);
675 Statement* ParseModuleDeclaration(ZoneStringList* names, bool* ok); 679 Statement* ParseModuleDeclaration(ZoneList<const AstString*>* names,
680 bool* ok);
676 Module* ParseModule(bool* ok); 681 Module* ParseModule(bool* ok);
677 Module* ParseModuleLiteral(bool* ok); 682 Module* ParseModuleLiteral(bool* ok);
678 Module* ParseModulePath(bool* ok); 683 Module* ParseModulePath(bool* ok);
679 Module* ParseModuleVariable(bool* ok); 684 Module* ParseModuleVariable(bool* ok);
680 Module* ParseModuleUrl(bool* ok); 685 Module* ParseModuleUrl(bool* ok);
681 Module* ParseModuleSpecifier(bool* ok); 686 Module* ParseModuleSpecifier(bool* ok);
682 Block* ParseImportDeclaration(bool* ok); 687 Block* ParseImportDeclaration(bool* ok);
683 Statement* ParseExportDeclaration(bool* ok); 688 Statement* ParseExportDeclaration(bool* ok);
684 Statement* ParseBlockElement(ZoneStringList* labels, bool* ok); 689 Statement* ParseBlockElement(ZoneList<const AstString*>* labels, bool* ok);
685 Statement* ParseStatement(ZoneStringList* labels, bool* ok); 690 Statement* ParseStatement(ZoneList<const AstString*>* labels, bool* ok);
686 Statement* ParseFunctionDeclaration(ZoneStringList* names, bool* ok); 691 Statement* ParseFunctionDeclaration(ZoneList<const AstString*>* names,
692 bool* ok);
687 Statement* ParseNativeDeclaration(bool* ok); 693 Statement* ParseNativeDeclaration(bool* ok);
688 Block* ParseBlock(ZoneStringList* labels, bool* ok); 694 Block* ParseBlock(ZoneList<const AstString*>* labels, bool* ok);
689 Block* ParseVariableStatement(VariableDeclarationContext var_context, 695 Block* ParseVariableStatement(VariableDeclarationContext var_context,
690 ZoneStringList* names, 696 ZoneList<const AstString*>* names,
691 bool* ok); 697 bool* ok);
692 Block* ParseVariableDeclarations(VariableDeclarationContext var_context, 698 Block* ParseVariableDeclarations(VariableDeclarationContext var_context,
693 VariableDeclarationProperties* decl_props, 699 VariableDeclarationProperties* decl_props,
694 ZoneStringList* names, 700 ZoneList<const AstString*>* names,
695 Handle<String>* out, 701 const AstString** out,
696 bool* ok); 702 bool* ok);
697 Statement* ParseExpressionOrLabelledStatement(ZoneStringList* labels, 703 Statement* ParseExpressionOrLabelledStatement(
698 bool* ok); 704 ZoneList<const AstString*>* labels, bool* ok);
699 IfStatement* ParseIfStatement(ZoneStringList* labels, bool* ok); 705 IfStatement* ParseIfStatement(ZoneList<const AstString*>* labels, bool* ok);
700 Statement* ParseContinueStatement(bool* ok); 706 Statement* ParseContinueStatement(bool* ok);
701 Statement* ParseBreakStatement(ZoneStringList* labels, bool* ok); 707 Statement* ParseBreakStatement(ZoneList<const AstString*>* labels, bool* ok);
702 Statement* ParseReturnStatement(bool* ok); 708 Statement* ParseReturnStatement(bool* ok);
703 Statement* ParseWithStatement(ZoneStringList* labels, bool* ok); 709 Statement* ParseWithStatement(ZoneList<const AstString*>* labels, bool* ok);
704 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); 710 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok);
705 SwitchStatement* ParseSwitchStatement(ZoneStringList* labels, bool* ok); 711 SwitchStatement* ParseSwitchStatement(ZoneList<const AstString*>* labels,
706 DoWhileStatement* ParseDoWhileStatement(ZoneStringList* labels, bool* ok); 712 bool* ok);
707 WhileStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok); 713 DoWhileStatement* ParseDoWhileStatement(ZoneList<const AstString*>* labels,
708 Statement* ParseForStatement(ZoneStringList* labels, bool* ok); 714 bool* ok);
715 WhileStatement* ParseWhileStatement(ZoneList<const AstString*>* labels,
716 bool* ok);
717 Statement* ParseForStatement(ZoneList<const AstString*>* labels, bool* ok);
709 Statement* ParseThrowStatement(bool* ok); 718 Statement* ParseThrowStatement(bool* ok);
710 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); 719 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value);
711 TryStatement* ParseTryStatement(bool* ok); 720 TryStatement* ParseTryStatement(bool* ok);
712 DebuggerStatement* ParseDebuggerStatement(bool* ok); 721 DebuggerStatement* ParseDebuggerStatement(bool* ok);
713 722
714 // Support for hamony block scoped bindings. 723 // Support for hamony block scoped bindings.
715 Block* ParseScopedBlock(ZoneStringList* labels, bool* ok); 724 Block* ParseScopedBlock(ZoneList<const AstString*>* labels, bool* ok);
716 725
717 // Initialize the components of a for-in / for-of statement. 726 // Initialize the components of a for-in / for-of statement.
718 void InitializeForEachStatement(ForEachStatement* stmt, 727 void InitializeForEachStatement(ForEachStatement* stmt,
719 Expression* each, 728 Expression* each,
720 Expression* subject, 729 Expression* subject,
721 Statement* body); 730 Statement* body);
722 Statement* DesugarLetBindingsInForStatement( 731 Statement* DesugarLetBindingsInForStatement(
723 Scope* inner_scope, ZoneStringList* names, ForStatement* loop, 732 Scope* inner_scope, ZoneList<const AstString*>* names,
724 Statement* init, Expression* cond, Statement* next, Statement* body, 733 ForStatement* loop, Statement* init, Expression* cond, Statement* next,
725 bool* ok); 734 Statement* body, bool* ok);
726 735
727 FunctionLiteral* ParseFunctionLiteral( 736 FunctionLiteral* ParseFunctionLiteral(
728 Handle<String> name, 737 const AstString* name,
729 Scanner::Location function_name_location, 738 Scanner::Location function_name_location,
730 bool name_is_strict_reserved, 739 bool name_is_strict_reserved,
731 bool is_generator, 740 bool is_generator,
732 int function_token_position, 741 int function_token_position,
733 FunctionLiteral::FunctionType type, 742 FunctionLiteral::FunctionType type,
734 FunctionLiteral::ArityRestriction arity_restriction, 743 FunctionLiteral::ArityRestriction arity_restriction,
735 bool* ok); 744 bool* ok);
736 745
737 // Magical syntax support. 746 // Magical syntax support.
738 Expression* ParseV8Intrinsic(bool* ok); 747 Expression* ParseV8Intrinsic(bool* ok);
739 748
740 bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode); 749 bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode);
741 750
742 // Get odd-ball literals. 751 // Get odd-ball literals.
743 Literal* GetLiteralUndefined(int position); 752 Literal* GetLiteralUndefined(int position);
744 753
745 // For harmony block scoping mode: Check if the scope has conflicting var/let 754 // For harmony block scoping mode: Check if the scope has conflicting var/let
746 // declarations from different scopes. It covers for example 755 // declarations from different scopes. It covers for example
747 // 756 //
748 // function f() { { { var x; } let x; } } 757 // function f() { { { var x; } let x; } }
749 // function g() { { var x; let x; } } 758 // function g() { { var x; let x; } }
750 // 759 //
751 // The var declarations are hoisted to the function scope, but originate from 760 // The var declarations are hoisted to the function scope, but originate from
752 // a scope where the name has also been let bound or the var declaration is 761 // a scope where the name has also been let bound or the var declaration is
753 // hoisted over such a scope. 762 // hoisted over such a scope.
754 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); 763 void CheckConflictingVarDeclarations(Scope* scope, bool* ok);
755 764
756 // Parser support 765 // Parser support
757 VariableProxy* NewUnresolved(Handle<String> name, 766 VariableProxy* NewUnresolved(const AstString* name,
758 VariableMode mode, 767 VariableMode mode,
759 Interface* interface); 768 Interface* interface);
760 void Declare(Declaration* declaration, bool resolve, bool* ok); 769 void Declare(Declaration* declaration, bool resolve, bool* ok);
761 770
762 bool TargetStackContainsLabel(Handle<String> label); 771 bool TargetStackContainsLabel(const AstString* label);
763 BreakableStatement* LookupBreakTarget(Handle<String> label, bool* ok); 772 BreakableStatement* LookupBreakTarget(const AstString* label, bool* ok);
764 IterationStatement* LookupContinueTarget(Handle<String> label, bool* ok); 773 IterationStatement* LookupContinueTarget(const AstString* label, bool* ok);
765 774
766 void RegisterTargetUse(Label* target, Target* stop); 775 void RegisterTargetUse(Label* target, Target* stop);
767 776
768 // Factory methods. 777 // Factory methods.
769 778
770 Scope* NewScope(Scope* parent, ScopeType type); 779 Scope* NewScope(Scope* parent, ScopeType type);
771 780
772 // Skip over a lazy function, either using cached data if we have it, or 781 // Skip over a lazy function, either using cached data if we have it, or
773 // by parsing the function with PreParser. Consumes the ending }. 782 // by parsing the function with PreParser. Consumes the ending }.
774 void SkipLazyFunctionBody(Handle<String> function_name, 783 void SkipLazyFunctionBody(const AstString* function_name,
775 int* materialized_literal_count, 784 int* materialized_literal_count,
776 int* expected_property_count, 785 int* expected_property_count,
777 bool* ok); 786 bool* ok);
778 787
779 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser( 788 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser(
780 SingletonLogger* logger); 789 SingletonLogger* logger);
781 790
782 // Consumes the ending }. 791 // Consumes the ending }.
783 ZoneList<Statement*>* ParseEagerFunctionBody(Handle<String> function_name, 792 ZoneList<Statement*>* ParseEagerFunctionBody(const AstString* function_name,
784 int pos, 793 int pos,
785 Variable* fvar, 794 Variable* fvar,
786 Token::Value fvar_init_op, 795 Token::Value fvar_init_op,
787 bool is_generator, 796 bool is_generator,
788 bool* ok); 797 bool* ok);
789 798
790 void ThrowPendingError(); 799 void ThrowPendingError();
791 800
792 Isolate* isolate_; 801 Isolate* isolate_;
793 802
794 Handle<Script> script_; 803 Handle<Script> script_;
795 Scanner scanner_; 804 Scanner scanner_;
796 PreParser* reusable_preparser_; 805 PreParser* reusable_preparser_;
797 Scope* original_scope_; // for ES5 function declarations in sloppy eval 806 Scope* original_scope_; // for ES5 function declarations in sloppy eval
798 Target* target_stack_; // for break, continue statements 807 Target* target_stack_; // for break, continue statements
799 ScriptData** cached_data_; 808 ScriptData** cached_data_;
800 CachedDataMode cached_data_mode_; 809 CachedDataMode cached_data_mode_;
810 AstValueFactory* ast_value_factory_;
801 811
802 CompilationInfo* info_; 812 CompilationInfo* info_;
803 813
804 // Pending errors. 814 // Pending errors.
805 bool has_pending_error_; 815 bool has_pending_error_;
806 Scanner::Location pending_error_location_; 816 Scanner::Location pending_error_location_;
807 const char* pending_error_message_; 817 const char* pending_error_message_;
808 MaybeHandle<String> pending_error_arg_; 818 const AstString* pending_error_arg_;
809 const char* pending_error_char_arg_; 819 const char* pending_error_char_arg_;
810 bool pending_error_is_reference_error_; 820 bool pending_error_is_reference_error_;
811 }; 821 };
812 822
813 823
814 // Support for handling complex values (array and object literals) that 824 // Support for handling complex values (array and object literals) that
815 // can be fully handled at compile time. 825 // can be fully handled at compile time.
816 class CompileTimeValue: public AllStatic { 826 class CompileTimeValue: public AllStatic {
817 public: 827 public:
818 enum LiteralType { 828 enum LiteralType {
(...skipping 16 matching lines...) Expand all
835 private: 845 private:
836 static const int kLiteralTypeSlot = 0; 846 static const int kLiteralTypeSlot = 0;
837 static const int kElementsSlot = 1; 847 static const int kElementsSlot = 1;
838 848
839 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 849 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
840 }; 850 };
841 851
842 } } // namespace v8::internal 852 } } // namespace v8::internal
843 853
844 #endif // V8_PARSER_H_ 854 #endif // V8_PARSER_H_
OLDNEW
« src/ast-value-factory.h ('K') | « src/objects.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698