| OLD | NEW |
| 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 Loading... |
| 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 AstRawString* 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 Loading... |
| 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 AstRawString* 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 AstRawString* 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 AstRawString* 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 AstRawString* 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 Loading... |
| 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 AstRawString* 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 AstRawString* 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 AstRawString* constructor, const char* type, |
| 513 Vector<Handle<Object> > arguments, int pos); | 514 const AstRawString* 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 = NULL, | 519 const char* arg = NULL, |
| 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 AstRawString* 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 AstRawString* 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 AstRawString* 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 AstRawString* GetSymbol(Scanner* scanner); |
| 549 Handle<String> NextLiteralString(Scanner* scanner, | 553 const AstRawString* 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 AstRawString* 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 AstRawString* 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 Loading... |
| 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 AstRawString* 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 AstRawString*>* labels, |
| 675 Statement* ParseModuleDeclaration(ZoneStringList* names, bool* ok); | 679 bool* ok); |
| 680 Statement* ParseModuleDeclaration(ZoneList<const AstRawString*>* names, |
| 681 bool* ok); |
| 676 Module* ParseModule(bool* ok); | 682 Module* ParseModule(bool* ok); |
| 677 Module* ParseModuleLiteral(bool* ok); | 683 Module* ParseModuleLiteral(bool* ok); |
| 678 Module* ParseModulePath(bool* ok); | 684 Module* ParseModulePath(bool* ok); |
| 679 Module* ParseModuleVariable(bool* ok); | 685 Module* ParseModuleVariable(bool* ok); |
| 680 Module* ParseModuleUrl(bool* ok); | 686 Module* ParseModuleUrl(bool* ok); |
| 681 Module* ParseModuleSpecifier(bool* ok); | 687 Module* ParseModuleSpecifier(bool* ok); |
| 682 Block* ParseImportDeclaration(bool* ok); | 688 Block* ParseImportDeclaration(bool* ok); |
| 683 Statement* ParseExportDeclaration(bool* ok); | 689 Statement* ParseExportDeclaration(bool* ok); |
| 684 Statement* ParseBlockElement(ZoneStringList* labels, bool* ok); | 690 Statement* ParseBlockElement(ZoneList<const AstRawString*>* labels, bool* ok); |
| 685 Statement* ParseStatement(ZoneStringList* labels, bool* ok); | 691 Statement* ParseStatement(ZoneList<const AstRawString*>* labels, bool* ok); |
| 686 Statement* ParseFunctionDeclaration(ZoneStringList* names, bool* ok); | 692 Statement* ParseFunctionDeclaration(ZoneList<const AstRawString*>* names, |
| 693 bool* ok); |
| 687 Statement* ParseNativeDeclaration(bool* ok); | 694 Statement* ParseNativeDeclaration(bool* ok); |
| 688 Block* ParseBlock(ZoneStringList* labels, bool* ok); | 695 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); |
| 689 Block* ParseVariableStatement(VariableDeclarationContext var_context, | 696 Block* ParseVariableStatement(VariableDeclarationContext var_context, |
| 690 ZoneStringList* names, | 697 ZoneList<const AstRawString*>* names, |
| 691 bool* ok); | 698 bool* ok); |
| 692 Block* ParseVariableDeclarations(VariableDeclarationContext var_context, | 699 Block* ParseVariableDeclarations(VariableDeclarationContext var_context, |
| 693 VariableDeclarationProperties* decl_props, | 700 VariableDeclarationProperties* decl_props, |
| 694 ZoneStringList* names, | 701 ZoneList<const AstRawString*>* names, |
| 695 Handle<String>* out, | 702 const AstRawString** out, |
| 696 bool* ok); | 703 bool* ok); |
| 697 Statement* ParseExpressionOrLabelledStatement(ZoneStringList* labels, | 704 Statement* ParseExpressionOrLabelledStatement( |
| 698 bool* ok); | 705 ZoneList<const AstRawString*>* labels, bool* ok); |
| 699 IfStatement* ParseIfStatement(ZoneStringList* labels, bool* ok); | 706 IfStatement* ParseIfStatement(ZoneList<const AstRawString*>* labels, |
| 707 bool* ok); |
| 700 Statement* ParseContinueStatement(bool* ok); | 708 Statement* ParseContinueStatement(bool* ok); |
| 701 Statement* ParseBreakStatement(ZoneStringList* labels, bool* ok); | 709 Statement* ParseBreakStatement(ZoneList<const AstRawString*>* labels, |
| 710 bool* ok); |
| 702 Statement* ParseReturnStatement(bool* ok); | 711 Statement* ParseReturnStatement(bool* ok); |
| 703 Statement* ParseWithStatement(ZoneStringList* labels, bool* ok); | 712 Statement* ParseWithStatement(ZoneList<const AstRawString*>* labels, |
| 713 bool* ok); |
| 704 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); | 714 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); |
| 705 SwitchStatement* ParseSwitchStatement(ZoneStringList* labels, bool* ok); | 715 SwitchStatement* ParseSwitchStatement(ZoneList<const AstRawString*>* labels, |
| 706 DoWhileStatement* ParseDoWhileStatement(ZoneStringList* labels, bool* ok); | 716 bool* ok); |
| 707 WhileStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok); | 717 DoWhileStatement* ParseDoWhileStatement(ZoneList<const AstRawString*>* labels, |
| 708 Statement* ParseForStatement(ZoneStringList* labels, bool* ok); | 718 bool* ok); |
| 719 WhileStatement* ParseWhileStatement(ZoneList<const AstRawString*>* labels, |
| 720 bool* ok); |
| 721 Statement* ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok); |
| 709 Statement* ParseThrowStatement(bool* ok); | 722 Statement* ParseThrowStatement(bool* ok); |
| 710 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); | 723 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); |
| 711 TryStatement* ParseTryStatement(bool* ok); | 724 TryStatement* ParseTryStatement(bool* ok); |
| 712 DebuggerStatement* ParseDebuggerStatement(bool* ok); | 725 DebuggerStatement* ParseDebuggerStatement(bool* ok); |
| 713 | 726 |
| 714 // Support for hamony block scoped bindings. | 727 // Support for hamony block scoped bindings. |
| 715 Block* ParseScopedBlock(ZoneStringList* labels, bool* ok); | 728 Block* ParseScopedBlock(ZoneList<const AstRawString*>* labels, bool* ok); |
| 716 | 729 |
| 717 // Initialize the components of a for-in / for-of statement. | 730 // Initialize the components of a for-in / for-of statement. |
| 718 void InitializeForEachStatement(ForEachStatement* stmt, | 731 void InitializeForEachStatement(ForEachStatement* stmt, |
| 719 Expression* each, | 732 Expression* each, |
| 720 Expression* subject, | 733 Expression* subject, |
| 721 Statement* body); | 734 Statement* body); |
| 722 Statement* DesugarLetBindingsInForStatement( | 735 Statement* DesugarLetBindingsInForStatement( |
| 723 Scope* inner_scope, ZoneStringList* names, ForStatement* loop, | 736 Scope* inner_scope, ZoneList<const AstRawString*>* names, |
| 724 Statement* init, Expression* cond, Statement* next, Statement* body, | 737 ForStatement* loop, Statement* init, Expression* cond, Statement* next, |
| 725 bool* ok); | 738 Statement* body, bool* ok); |
| 726 | 739 |
| 727 FunctionLiteral* ParseFunctionLiteral( | 740 FunctionLiteral* ParseFunctionLiteral( |
| 728 Handle<String> name, | 741 const AstRawString* name, |
| 729 Scanner::Location function_name_location, | 742 Scanner::Location function_name_location, |
| 730 bool name_is_strict_reserved, | 743 bool name_is_strict_reserved, |
| 731 bool is_generator, | 744 bool is_generator, |
| 732 int function_token_position, | 745 int function_token_position, |
| 733 FunctionLiteral::FunctionType type, | 746 FunctionLiteral::FunctionType type, |
| 734 FunctionLiteral::ArityRestriction arity_restriction, | 747 FunctionLiteral::ArityRestriction arity_restriction, |
| 735 bool* ok); | 748 bool* ok); |
| 736 | 749 |
| 737 // Magical syntax support. | 750 // Magical syntax support. |
| 738 Expression* ParseV8Intrinsic(bool* ok); | 751 Expression* ParseV8Intrinsic(bool* ok); |
| 739 | 752 |
| 740 bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode); | 753 bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode); |
| 741 | 754 |
| 742 // Get odd-ball literals. | 755 // Get odd-ball literals. |
| 743 Literal* GetLiteralUndefined(int position); | 756 Literal* GetLiteralUndefined(int position); |
| 744 | 757 |
| 745 // For harmony block scoping mode: Check if the scope has conflicting var/let | 758 // For harmony block scoping mode: Check if the scope has conflicting var/let |
| 746 // declarations from different scopes. It covers for example | 759 // declarations from different scopes. It covers for example |
| 747 // | 760 // |
| 748 // function f() { { { var x; } let x; } } | 761 // function f() { { { var x; } let x; } } |
| 749 // function g() { { var x; let x; } } | 762 // function g() { { var x; let x; } } |
| 750 // | 763 // |
| 751 // The var declarations are hoisted to the function scope, but originate from | 764 // 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 | 765 // a scope where the name has also been let bound or the var declaration is |
| 753 // hoisted over such a scope. | 766 // hoisted over such a scope. |
| 754 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); | 767 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); |
| 755 | 768 |
| 756 // Parser support | 769 // Parser support |
| 757 VariableProxy* NewUnresolved(Handle<String> name, | 770 VariableProxy* NewUnresolved(const AstRawString* name, |
| 758 VariableMode mode, | 771 VariableMode mode, |
| 759 Interface* interface); | 772 Interface* interface); |
| 760 void Declare(Declaration* declaration, bool resolve, bool* ok); | 773 void Declare(Declaration* declaration, bool resolve, bool* ok); |
| 761 | 774 |
| 762 bool TargetStackContainsLabel(Handle<String> label); | 775 bool TargetStackContainsLabel(const AstRawString* label); |
| 763 BreakableStatement* LookupBreakTarget(Handle<String> label, bool* ok); | 776 BreakableStatement* LookupBreakTarget(const AstRawString* label, bool* ok); |
| 764 IterationStatement* LookupContinueTarget(Handle<String> label, bool* ok); | 777 IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok); |
| 765 | 778 |
| 766 void RegisterTargetUse(Label* target, Target* stop); | 779 void RegisterTargetUse(Label* target, Target* stop); |
| 767 | 780 |
| 768 // Factory methods. | 781 // Factory methods. |
| 769 | 782 |
| 770 Scope* NewScope(Scope* parent, ScopeType type); | 783 Scope* NewScope(Scope* parent, ScopeType type); |
| 771 | 784 |
| 772 // Skip over a lazy function, either using cached data if we have it, or | 785 // Skip over a lazy function, either using cached data if we have it, or |
| 773 // by parsing the function with PreParser. Consumes the ending }. | 786 // by parsing the function with PreParser. Consumes the ending }. |
| 774 void SkipLazyFunctionBody(Handle<String> function_name, | 787 void SkipLazyFunctionBody(const AstRawString* function_name, |
| 775 int* materialized_literal_count, | 788 int* materialized_literal_count, |
| 776 int* expected_property_count, | 789 int* expected_property_count, |
| 777 bool* ok); | 790 bool* ok); |
| 778 | 791 |
| 779 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser( | 792 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser( |
| 780 SingletonLogger* logger); | 793 SingletonLogger* logger); |
| 781 | 794 |
| 782 // Consumes the ending }. | 795 // Consumes the ending }. |
| 783 ZoneList<Statement*>* ParseEagerFunctionBody(Handle<String> function_name, | 796 ZoneList<Statement*>* ParseEagerFunctionBody( |
| 784 int pos, | 797 const AstRawString* function_name, int pos, Variable* fvar, |
| 785 Variable* fvar, | 798 Token::Value fvar_init_op, bool is_generator, bool* ok); |
| 786 Token::Value fvar_init_op, | |
| 787 bool is_generator, | |
| 788 bool* ok); | |
| 789 | 799 |
| 790 void ThrowPendingError(); | 800 void ThrowPendingError(); |
| 791 | 801 |
| 792 Isolate* isolate_; | 802 Isolate* isolate_; |
| 793 | 803 |
| 794 Handle<Script> script_; | 804 Handle<Script> script_; |
| 795 Scanner scanner_; | 805 Scanner scanner_; |
| 796 PreParser* reusable_preparser_; | 806 PreParser* reusable_preparser_; |
| 797 Scope* original_scope_; // for ES5 function declarations in sloppy eval | 807 Scope* original_scope_; // for ES5 function declarations in sloppy eval |
| 798 Target* target_stack_; // for break, continue statements | 808 Target* target_stack_; // for break, continue statements |
| 799 ScriptData** cached_data_; | 809 ScriptData** cached_data_; |
| 800 CachedDataMode cached_data_mode_; | 810 CachedDataMode cached_data_mode_; |
| 811 AstValueFactory* ast_value_factory_; |
| 801 | 812 |
| 802 CompilationInfo* info_; | 813 CompilationInfo* info_; |
| 803 | 814 |
| 804 // Pending errors. | 815 // Pending errors. |
| 805 bool has_pending_error_; | 816 bool has_pending_error_; |
| 806 Scanner::Location pending_error_location_; | 817 Scanner::Location pending_error_location_; |
| 807 const char* pending_error_message_; | 818 const char* pending_error_message_; |
| 808 MaybeHandle<String> pending_error_arg_; | 819 const AstRawString* pending_error_arg_; |
| 809 const char* pending_error_char_arg_; | 820 const char* pending_error_char_arg_; |
| 810 bool pending_error_is_reference_error_; | 821 bool pending_error_is_reference_error_; |
| 811 }; | 822 }; |
| 812 | 823 |
| 813 | 824 |
| 814 // Support for handling complex values (array and object literals) that | 825 // Support for handling complex values (array and object literals) that |
| 815 // can be fully handled at compile time. | 826 // can be fully handled at compile time. |
| 816 class CompileTimeValue: public AllStatic { | 827 class CompileTimeValue: public AllStatic { |
| 817 public: | 828 public: |
| 818 enum LiteralType { | 829 enum LiteralType { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 835 private: | 846 private: |
| 836 static const int kLiteralTypeSlot = 0; | 847 static const int kLiteralTypeSlot = 0; |
| 837 static const int kElementsSlot = 1; | 848 static const int kElementsSlot = 1; |
| 838 | 849 |
| 839 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 850 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
| 840 }; | 851 }; |
| 841 | 852 |
| 842 } } // namespace v8::internal | 853 } } // namespace v8::internal |
| 843 | 854 |
| 844 #endif // V8_PARSER_H_ | 855 #endif // V8_PARSER_H_ |
| OLD | NEW |