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

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: internalizing better Created 6 years, 7 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 "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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 void Initialize(); 82 void Initialize();
83 void ReadNextSymbolPosition(); 83 void ReadNextSymbolPosition();
84 84
85 FunctionEntry GetFunctionEntry(int start); 85 FunctionEntry GetFunctionEntry(int start);
86 int GetSymbolIdentifier(); 86 int GetSymbolIdentifier();
87 bool SanityCheck(); 87 bool SanityCheck();
88 88
89 Scanner::Location MessageLocation() const; 89 Scanner::Location MessageLocation() const;
90 bool IsReferenceError() const; 90 bool IsReferenceError() const;
91 const char* BuildMessage() const; 91 const char* BuildMessage() const;
92 Vector<const char*> BuildArgs() const; 92 const char* BuildArg() const;
93 93
94 int function_count() { 94 int function_count() {
95 int functions_size = 95 int functions_size =
96 static_cast<int>(store_[PreparseDataConstants::kFunctionsSizeOffset]); 96 static_cast<int>(store_[PreparseDataConstants::kFunctionsSizeOffset]);
97 if (functions_size < 0) return 0; 97 if (functions_size < 0) return 0;
98 if (functions_size % FunctionEntry::kSize != 0) return 0; 98 if (functions_size % FunctionEntry::kSize != 0) return 0;
99 return functions_size / FunctionEntry::kSize; 99 return functions_size / FunctionEntry::kSize;
100 } 100 }
101 // The following functions should only be called if SanityCheck has 101 // The following functions should only be called if SanityCheck has
102 // returned true. 102 // returned true.
(...skipping 279 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 ParserSymbolTable::Symbol* 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(ParserSymbolTable::Symbol* 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 ParserSymbolTable::Symbol* 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(ParserSymbolTable::Symbol* string, uint32_t* index) {
441 return !string.is_null() && string->AsArrayIndex(index); 441 return string != NULL && ParserSymbolTable::IsArrayIndexSlow(string, 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,
447 ParserSymbolTable::Symbol* id) {
447 fni->PushLiteralName(id); 448 fni->PushLiteralName(id);
448 } 449 }
449 void PushPropertyName(FuncNameInferrer* fni, Expression* expression); 450 void PushPropertyName(FuncNameInferrer* fni, Expression* expression);
450 451
451 static void CheckFunctionLiteralInsideTopLevelObjectLiteral( 452 static void CheckFunctionLiteralInsideTopLevelObjectLiteral(
452 Scope* scope, Expression* value, bool* has_function) { 453 Scope* scope, Expression* value, bool* has_function) {
453 if (scope->DeclarationScope()->is_global_scope() && 454 if (scope->DeclarationScope()->is_global_scope() &&
454 value->AsFunctionLiteral() != NULL) { 455 value->AsFunctionLiteral() != NULL) {
455 *has_function = true; 456 *has_function = true;
456 value->AsFunctionLiteral()->set_pretenure(); 457 value->AsFunctionLiteral()->set_pretenure();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 Expression* expression, Token::Value op, int pos, 495 Expression* expression, Token::Value op, int pos,
495 AstNodeFactory<AstConstructionVisitor>* factory); 496 AstNodeFactory<AstConstructionVisitor>* factory);
496 497
497 // Generate AST node that throws a ReferenceError with the given type. 498 // Generate AST node that throws a ReferenceError with the given type.
498 Expression* NewThrowReferenceError(const char* type, int pos); 499 Expression* NewThrowReferenceError(const char* type, int pos);
499 500
500 // Generate AST node that throws a SyntaxError with the given 501 // Generate AST node that throws a SyntaxError with the given
501 // type. The first argument may be null (in the handle sense) in 502 // type. The first argument may be null (in the handle sense) in
502 // which case no arguments are passed to the constructor. 503 // which case no arguments are passed to the constructor.
503 Expression* NewThrowSyntaxError( 504 Expression* NewThrowSyntaxError(
504 const char* type, Handle<Object> arg, int pos); 505 const char* type, ParserSymbolTable::Symbol* arg, int pos);
505 506
506 // Generate AST node that throws a TypeError with the given 507 // Generate AST node that throws a TypeError with the given
507 // type. Both arguments must be non-null (in the handle sense). 508 // type. Both arguments must be non-null (in the handle sense).
508 Expression* NewThrowTypeError(const char* type, Handle<Object> arg, int pos); 509 Expression* NewThrowTypeError(const char* type,
510 ParserSymbolTable::Symbol* arg, int pos);
509 511
510 // Generic AST generator for throwing errors from compiled code. 512 // Generic AST generator for throwing errors from compiled code.
511 Expression* NewThrowError( 513 Expression* NewThrowError(
512 Handle<String> constructor, const char* type, 514 ParserSymbolTable::Symbol* constructor, const char* type,
513 Vector<Handle<Object> > arguments, int pos); 515 ParserSymbolTable::Symbol* arg, int pos);
514 516
515 // Reporting errors. 517 // Reporting errors.
516 void ReportMessageAt(Scanner::Location source_location, 518 void ReportMessageAt(Scanner::Location source_location,
517 const char* message, 519 const char* message,
518 Vector<const char*> args, 520 const char* arg = NULL,
519 bool is_reference_error = false); 521 bool is_reference_error = false);
520 void ReportMessage(const char* message, 522 void ReportMessage(const char* message,
521 Vector<Handle<String> > args, 523 const char* arg = NULL,
522 bool is_reference_error = false); 524 bool is_reference_error = false);
523 void ReportMessageAt(Scanner::Location source_location, 525 void ReportMessageAt(Scanner::Location source_location,
524 const char* message, 526 const char* message,
525 Vector<Handle<String> > args, 527 ParserSymbolTable::Symbol* arg,
526 bool is_reference_error = false); 528 bool is_reference_error = false);
529 void ReportMessage(const char* message,
530 ParserSymbolTable::Symbol* arg,
531 bool is_reference_error = false);
527 532
528 // "null" return type creators. 533 // "null" return type creators.
529 static Handle<String> EmptyIdentifier() { 534 static ParserSymbolTable::Symbol* EmptyIdentifier() {
530 return Handle<String>(); 535 return NULL;
531 } 536 }
532 static Expression* EmptyExpression() { 537 static Expression* EmptyExpression() {
533 return NULL; 538 return NULL;
534 } 539 }
535 static Literal* EmptyLiteral() { 540 static Literal* EmptyLiteral() {
536 return NULL; 541 return NULL;
537 } 542 }
538 // Used in error return values. 543 // Used in error return values.
539 static ZoneList<Expression*>* NullExpressionList() { 544 static ZoneList<Expression*>* NullExpressionList() {
540 return NULL; 545 return NULL;
541 } 546 }
542 547
543 // Odd-ball literal creators. 548 // Odd-ball literal creators.
544 Literal* GetLiteralTheHole(int position, 549 Literal* GetLiteralTheHole(int position,
545 AstNodeFactory<AstConstructionVisitor>* factory); 550 AstNodeFactory<AstConstructionVisitor>* factory);
546 551
547 // Producing data during the recursive descent. 552 // Producing data during the recursive descent.
548 Handle<String> GetSymbol(Scanner* scanner = NULL); 553 ParserSymbolTable::Symbol* GetSymbol(Scanner* scanner);
549 Handle<String> NextLiteralString(Scanner* scanner, 554 ParserSymbolTable::Symbol* GetNextSymbol(Scanner* scanner);
550 PretenureFlag tenured); 555
551 Expression* ThisExpression(Scope* scope, 556 Expression* ThisExpression(Scope* scope,
552 AstNodeFactory<AstConstructionVisitor>* factory); 557 AstNodeFactory<AstConstructionVisitor>* factory);
553 Literal* ExpressionFromLiteral( 558 Literal* ExpressionFromLiteral(
554 Token::Value token, int pos, Scanner* scanner, 559 Token::Value token, int pos, Scanner* scanner,
555 AstNodeFactory<AstConstructionVisitor>* factory); 560 AstNodeFactory<AstConstructionVisitor>* factory);
556 Expression* ExpressionFromIdentifier( 561 Expression* ExpressionFromIdentifier(
557 Handle<String> name, int pos, Scope* scope, 562 ParserSymbolTable::Symbol* name, int pos, Scope* scope,
558 AstNodeFactory<AstConstructionVisitor>* factory); 563 AstNodeFactory<AstConstructionVisitor>* factory);
559 Expression* ExpressionFromString( 564 Expression* ExpressionFromString(
560 int pos, Scanner* scanner, 565 int pos, Scanner* scanner,
561 AstNodeFactory<AstConstructionVisitor>* factory); 566 AstNodeFactory<AstConstructionVisitor>* factory);
562 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) { 567 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) {
563 return new(zone) ZoneList<v8::internal::Expression*>(size, zone); 568 return new(zone) ZoneList<v8::internal::Expression*>(size, zone);
564 } 569 }
565 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { 570 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) {
566 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); 571 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone);
567 } 572 }
568 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { 573 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) {
569 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); 574 return new(zone) ZoneList<v8::internal::Statement*>(size, zone);
570 } 575 }
571 576
572 // Temporary glue; these functions will move to ParserBase. 577 // Temporary glue; these functions will move to ParserBase.
573 Expression* ParseV8Intrinsic(bool* ok); 578 Expression* ParseV8Intrinsic(bool* ok);
574 FunctionLiteral* ParseFunctionLiteral( 579 FunctionLiteral* ParseFunctionLiteral(
575 Handle<String> name, 580 ParserSymbolTable::Symbol* name,
576 Scanner::Location function_name_location, 581 Scanner::Location function_name_location,
577 bool name_is_strict_reserved, 582 bool name_is_strict_reserved,
578 bool is_generator, 583 bool is_generator,
579 int function_token_position, 584 int function_token_position,
580 FunctionLiteral::FunctionType type, 585 FunctionLiteral::FunctionType type,
581 bool* ok); 586 bool* ok);
582 587
583 private: 588 private:
584 Parser* parser_; 589 Parser* parser_;
585 }; 590 };
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 FunctionLiteral* ParseLazy(Utf16CharacterStream* source); 641 FunctionLiteral* ParseLazy(Utf16CharacterStream* source);
637 642
638 Isolate* isolate() { return isolate_; } 643 Isolate* isolate() { return isolate_; }
639 CompilationInfo* info() const { return info_; } 644 CompilationInfo* info() const { return info_; }
640 645
641 // Called by ParseProgram after setting up the scanner. 646 // Called by ParseProgram after setting up the scanner.
642 FunctionLiteral* DoParseProgram(CompilationInfo* info, 647 FunctionLiteral* DoParseProgram(CompilationInfo* info,
643 Handle<String> source); 648 Handle<String> source);
644 649
645 // Report syntax error 650 // Report syntax error
646 void ReportInvalidCachedData(Handle<String> name, bool* ok); 651 void ReportInvalidCachedData(ParserSymbolTable::Symbol* name, bool* ok);
647 652
648 void SetCachedData(ScriptData** data, 653 void SetCachedData(ScriptData** data,
649 CachedDataMode cached_data_mode) { 654 CachedDataMode cached_data_mode) {
650 cached_data_mode_ = cached_data_mode; 655 cached_data_mode_ = cached_data_mode;
651 if (cached_data_mode == NO_CACHED_DATA) { 656 if (cached_data_mode == NO_CACHED_DATA) {
652 cached_data_ = NULL; 657 cached_data_ = NULL;
653 } else { 658 } else {
654 ASSERT(data != NULL); 659 ASSERT(data != NULL);
655 cached_data_ = data; 660 cached_data_ = data;
656 } 661 }
657 } 662 }
658 663
659 bool inside_with() const { return scope_->inside_with(); } 664 bool inside_with() const { return scope_->inside_with(); }
660 ScriptData** cached_data() const { return cached_data_; } 665 ScriptData** cached_data() const { return cached_data_; }
661 CachedDataMode cached_data_mode() const { return cached_data_mode_; } 666 CachedDataMode cached_data_mode() const { return cached_data_mode_; }
662 Scope* DeclarationScope(VariableMode mode) { 667 Scope* DeclarationScope(VariableMode mode) {
663 return IsLexicalVariableMode(mode) 668 return IsLexicalVariableMode(mode)
664 ? scope_ : scope_->DeclarationScope(); 669 ? scope_ : scope_->DeclarationScope();
665 } 670 }
666 671
667 // All ParseXXX functions take as the last argument an *ok parameter 672 // All ParseXXX functions take as the last argument an *ok parameter
668 // 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.
669 // By making the 'exception handling' explicit, we are forced to check 674 // By making the 'exception handling' explicit, we are forced to check
670 // for failure at the call sites. 675 // for failure at the call sites.
671 void* ParseSourceElements(ZoneList<Statement*>* processor, int end_token, 676 void* ParseSourceElements(ZoneList<Statement*>* processor, int end_token,
672 bool is_eval, bool is_global, bool* ok); 677 bool is_eval, bool is_global, bool* ok);
673 Statement* ParseModuleElement(ZoneStringList* labels, bool* ok); 678 Statement* ParseModuleElement(ZoneList<ParserSymbolTable::Symbol*>* labels,
674 Statement* ParseModuleDeclaration(ZoneStringList* names, bool* ok); 679 bool* ok);
680 Statement* ParseModuleDeclaration(ZoneList<ParserSymbolTable::Symbol*>* names,
681 bool* ok);
675 Module* ParseModule(bool* ok); 682 Module* ParseModule(bool* ok);
676 Module* ParseModuleLiteral(bool* ok); 683 Module* ParseModuleLiteral(bool* ok);
677 Module* ParseModulePath(bool* ok); 684 Module* ParseModulePath(bool* ok);
678 Module* ParseModuleVariable(bool* ok); 685 Module* ParseModuleVariable(bool* ok);
679 Module* ParseModuleUrl(bool* ok); 686 Module* ParseModuleUrl(bool* ok);
680 Module* ParseModuleSpecifier(bool* ok); 687 Module* ParseModuleSpecifier(bool* ok);
681 Block* ParseImportDeclaration(bool* ok); 688 Block* ParseImportDeclaration(bool* ok);
682 Statement* ParseExportDeclaration(bool* ok); 689 Statement* ParseExportDeclaration(bool* ok);
683 Statement* ParseBlockElement(ZoneStringList* labels, bool* ok); 690 Statement* ParseBlockElement(ZoneList<ParserSymbolTable::Symbol*>* labels,
684 Statement* ParseStatement(ZoneStringList* labels, bool* ok); 691 bool* ok);
685 Statement* ParseFunctionDeclaration(ZoneStringList* names, bool* ok); 692 Statement* ParseStatement(ZoneList<ParserSymbolTable::Symbol*>* labels,
693 bool* ok);
694 Statement* ParseFunctionDeclaration(
695 ZoneList<ParserSymbolTable::Symbol*>* names, bool* ok);
686 Statement* ParseNativeDeclaration(bool* ok); 696 Statement* ParseNativeDeclaration(bool* ok);
687 Block* ParseBlock(ZoneStringList* labels, bool* ok); 697 Block* ParseBlock(ZoneList<ParserSymbolTable::Symbol*>* labels, bool* ok);
688 Block* ParseVariableStatement(VariableDeclarationContext var_context, 698 Block* ParseVariableStatement(VariableDeclarationContext var_context,
689 ZoneStringList* names, 699 ZoneList<ParserSymbolTable::Symbol*>* names,
690 bool* ok); 700 bool* ok);
691 Block* ParseVariableDeclarations(VariableDeclarationContext var_context, 701 Block* ParseVariableDeclarations(VariableDeclarationContext var_context,
692 VariableDeclarationProperties* decl_props, 702 VariableDeclarationProperties* decl_props,
693 ZoneStringList* names, 703 ZoneList<ParserSymbolTable::Symbol*>* names,
694 Handle<String>* out, 704 ParserSymbolTable::Symbol** out,
695 bool* ok); 705 bool* ok);
696 Statement* ParseExpressionOrLabelledStatement(ZoneStringList* labels, 706 Statement* ParseExpressionOrLabelledStatement(
697 bool* ok); 707 ZoneList<ParserSymbolTable::Symbol*>* labels, bool* ok);
698 IfStatement* ParseIfStatement(ZoneStringList* labels, bool* ok); 708 IfStatement* ParseIfStatement(ZoneList<ParserSymbolTable::Symbol*>* labels,
709 bool* ok);
699 Statement* ParseContinueStatement(bool* ok); 710 Statement* ParseContinueStatement(bool* ok);
700 Statement* ParseBreakStatement(ZoneStringList* labels, bool* ok); 711 Statement* ParseBreakStatement(ZoneList<ParserSymbolTable::Symbol*>* labels,
712 bool* ok);
701 Statement* ParseReturnStatement(bool* ok); 713 Statement* ParseReturnStatement(bool* ok);
702 Statement* ParseWithStatement(ZoneStringList* labels, bool* ok); 714 Statement* ParseWithStatement(ZoneList<ParserSymbolTable::Symbol*>* labels,
715 bool* ok);
703 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); 716 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok);
704 SwitchStatement* ParseSwitchStatement(ZoneStringList* labels, bool* ok); 717 SwitchStatement* ParseSwitchStatement(
705 DoWhileStatement* ParseDoWhileStatement(ZoneStringList* labels, bool* ok); 718 ZoneList<ParserSymbolTable::Symbol*>* labels, bool* ok);
706 WhileStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok); 719 DoWhileStatement* ParseDoWhileStatement(
707 Statement* ParseForStatement(ZoneStringList* labels, bool* ok); 720 ZoneList<ParserSymbolTable::Symbol*>* labels, bool* ok);
721 WhileStatement* ParseWhileStatement(
722 ZoneList<ParserSymbolTable::Symbol*>* labels, bool* ok);
723 Statement* ParseForStatement(ZoneList<ParserSymbolTable::Symbol*>* labels,
724 bool* ok);
708 Statement* ParseThrowStatement(bool* ok); 725 Statement* ParseThrowStatement(bool* ok);
709 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); 726 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value);
710 TryStatement* ParseTryStatement(bool* ok); 727 TryStatement* ParseTryStatement(bool* ok);
711 DebuggerStatement* ParseDebuggerStatement(bool* ok); 728 DebuggerStatement* ParseDebuggerStatement(bool* ok);
712 729
713 // Support for hamony block scoped bindings. 730 // Support for hamony block scoped bindings.
714 Block* ParseScopedBlock(ZoneStringList* labels, bool* ok); 731 Block* ParseScopedBlock(ZoneList<ParserSymbolTable::Symbol*>* labels,
732 bool* ok);
715 733
716 // Initialize the components of a for-in / for-of statement. 734 // Initialize the components of a for-in / for-of statement.
717 void InitializeForEachStatement(ForEachStatement* stmt, 735 void InitializeForEachStatement(ForEachStatement* stmt,
718 Expression* each, 736 Expression* each,
719 Expression* subject, 737 Expression* subject,
720 Statement* body); 738 Statement* body);
721 739
722 FunctionLiteral* ParseFunctionLiteral( 740 FunctionLiteral* ParseFunctionLiteral(
723 Handle<String> name, 741 ParserSymbolTable::Symbol* name,
724 Scanner::Location function_name_location, 742 Scanner::Location function_name_location,
725 bool name_is_strict_reserved, 743 bool name_is_strict_reserved,
726 bool is_generator, 744 bool is_generator,
727 int function_token_position, 745 int function_token_position,
728 FunctionLiteral::FunctionType type, 746 FunctionLiteral::FunctionType type,
729 bool* ok); 747 bool* ok);
730 748
731 // Magical syntax support. 749 // Magical syntax support.
732 Expression* ParseV8Intrinsic(bool* ok); 750 Expression* ParseV8Intrinsic(bool* ok);
733 751
734 bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode); 752 bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode);
735 753
736 // Get odd-ball literals. 754 // Get odd-ball literals.
737 Literal* GetLiteralUndefined(int position); 755 Literal* GetLiteralUndefined(int position);
738 756
739 // For harmony block scoping mode: Check if the scope has conflicting var/let 757 // For harmony block scoping mode: Check if the scope has conflicting var/let
740 // declarations from different scopes. It covers for example 758 // declarations from different scopes. It covers for example
741 // 759 //
742 // function f() { { { var x; } let x; } } 760 // function f() { { { var x; } let x; } }
743 // function g() { { var x; let x; } } 761 // function g() { { var x; let x; } }
744 // 762 //
745 // The var declarations are hoisted to the function scope, but originate from 763 // The var declarations are hoisted to the function scope, but originate from
746 // a scope where the name has also been let bound or the var declaration is 764 // a scope where the name has also been let bound or the var declaration is
747 // hoisted over such a scope. 765 // hoisted over such a scope.
748 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); 766 void CheckConflictingVarDeclarations(Scope* scope, bool* ok);
749 767
750 // Parser support 768 // Parser support
751 VariableProxy* NewUnresolved(Handle<String> name, 769 template<class SymbolType>
770 VariableProxy* NewUnresolved(SymbolType name,
752 VariableMode mode, 771 VariableMode mode,
753 Interface* interface); 772 Interface* interface);
754 void Declare(Declaration* declaration, bool resolve, bool* ok); 773 void Declare(Declaration* declaration, bool resolve, bool* ok);
755 774
756 bool TargetStackContainsLabel(Handle<String> label); 775 bool TargetStackContainsLabel(ParserSymbolTable::Symbol* label);
757 BreakableStatement* LookupBreakTarget(Handle<String> label, bool* ok); 776 BreakableStatement* LookupBreakTarget(ParserSymbolTable::Symbol* label,
758 IterationStatement* LookupContinueTarget(Handle<String> label, bool* ok); 777 bool* ok);
778 IterationStatement* LookupContinueTarget(ParserSymbolTable::Symbol* label,
779 bool* ok);
759 780
760 void RegisterTargetUse(Label* target, Target* stop); 781 void RegisterTargetUse(Label* target, Target* stop);
761 782
762 // Factory methods. 783 // Factory methods.
763 784
764 Scope* NewScope(Scope* parent, ScopeType type); 785 Scope* NewScope(Scope* parent, ScopeType type);
765 786
766 // Skip over a lazy function, either using cached data if we have it, or 787 // Skip over a lazy function, either using cached data if we have it, or
767 // by parsing the function with PreParser. Consumes the ending }. 788 // by parsing the function with PreParser. Consumes the ending }.
768 void SkipLazyFunctionBody(Handle<String> function_name, 789 void SkipLazyFunctionBody(ParserSymbolTable::Symbol* function_name,
769 int* materialized_literal_count, 790 int* materialized_literal_count,
770 int* expected_property_count, 791 int* expected_property_count,
771 bool* ok); 792 bool* ok);
772 793
773 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser( 794 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser(
774 SingletonLogger* logger); 795 SingletonLogger* logger);
775 796
776 // Consumes the ending }. 797 // Consumes the ending }.
777 ZoneList<Statement*>* ParseEagerFunctionBody(Handle<String> function_name, 798 ZoneList<Statement*>* ParseEagerFunctionBody(
778 int pos, 799 ParserSymbolTable::Symbol* function_name, int pos, Variable* fvar,
779 Variable* fvar, 800 Token::Value fvar_init_op, bool is_generator, bool* ok);
780 Token::Value fvar_init_op, 801
781 bool is_generator, 802 void CheckPendingError();
782 bool* ok);
783 803
784 Isolate* isolate_; 804 Isolate* isolate_;
785 805
786 Handle<Script> script_; 806 Handle<Script> script_;
787 Scanner scanner_; 807 Scanner scanner_;
788 PreParser* reusable_preparser_; 808 PreParser* reusable_preparser_;
789 Scope* original_scope_; // for ES5 function declarations in sloppy eval 809 Scope* original_scope_; // for ES5 function declarations in sloppy eval
790 Target* target_stack_; // for break, continue statements 810 Target* target_stack_; // for break, continue statements
791 ScriptData** cached_data_; 811 ScriptData** cached_data_;
792 CachedDataMode cached_data_mode_; 812 CachedDataMode cached_data_mode_;
813 ParserSymbolTable* symbol_table_;
793 814
794 CompilationInfo* info_; 815 CompilationInfo* info_;
816
817 // Pending error
818 bool has_pending_error_;
819 Scanner::Location pending_location_;
820 const char* pending_message_;
821 ParserSymbolTable::Symbol* pending_arg_;
822 const char* pending_char_arg_;
823 bool pending_is_reference_error_;
795 }; 824 };
796 825
797 826
798 // Support for handling complex values (array and object literals) that 827 // Support for handling complex values (array and object literals) that
799 // can be fully handled at compile time. 828 // can be fully handled at compile time.
800 class CompileTimeValue: public AllStatic { 829 class CompileTimeValue: public AllStatic {
801 public: 830 public:
802 enum LiteralType { 831 enum LiteralType {
803 OBJECT_LITERAL_FAST_ELEMENTS, 832 OBJECT_LITERAL_FAST_ELEMENTS,
804 OBJECT_LITERAL_SLOW_ELEMENTS, 833 OBJECT_LITERAL_SLOW_ELEMENTS,
(...skipping 14 matching lines...) Expand all
819 private: 848 private:
820 static const int kLiteralTypeSlot = 0; 849 static const int kLiteralTypeSlot = 0;
821 static const int kElementsSlot = 1; 850 static const int kElementsSlot = 1;
822 851
823 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 852 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
824 }; 853 };
825 854
826 } } // namespace v8::internal 855 } } // namespace v8::internal
827 856
828 #endif // V8_PARSER_H_ 857 #endif // V8_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698