| 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 const AstString* Identifier; | 392 typedef Handle<String> 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(const AstString* identifier) const; | 424 bool IsEvalOrArguments(Handle<String> 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 const AstString* AsIdentifier(Expression* expression) { | 431 static Handle<String> AsIdentifier(Expression* expression) { |
| 432 ASSERT(IsIdentifier(expression)); | 432 ASSERT(IsIdentifier(expression)); |
| 433 return expression->AsVariableProxy()->raw_name(); | 433 return expression->AsVariableProxy()->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(const AstString* string, uint32_t* index) { | 440 static bool IsArrayIndex(Handle<String> string, uint32_t* index) { |
| 441 return string->AsArrayIndex(index); | 441 return !string.is_null() && 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, const AstString* id) { | 446 static void PushLiteralName(FuncNameInferrer* fni, Handle<String> 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, const AstString* arg, int pos); | 504 const char* type, Handle<Object> 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, const AstString* arg, | 508 Expression* NewThrowTypeError(const char* type, Handle<Object> arg, int pos); |
| 509 int pos); | |
| 510 | 509 |
| 511 // Generic AST generator for throwing errors from compiled code. | 510 // Generic AST generator for throwing errors from compiled code. |
| 512 Expression* NewThrowError( | 511 Expression* NewThrowError( |
| 513 const AstString* constructor, const char* type, | 512 Handle<String> constructor, const char* type, |
| 514 const AstString* arg, int pos); | 513 Vector<Handle<Object> > arguments, int pos); |
| 515 | 514 |
| 516 // Reporting errors. | 515 // Reporting errors. |
| 517 void ReportMessageAt(Scanner::Location source_location, | 516 void ReportMessageAt(Scanner::Location source_location, |
| 518 const char* message, | 517 const char* message, |
| 519 const char* arg, | 518 const char* arg, |
| 520 bool is_reference_error = false); | 519 bool is_reference_error = false); |
| 521 void ReportMessage(const char* message, | 520 void ReportMessage(const char* message, |
| 522 const char* arg = NULL, | 521 MaybeHandle<String> arg, |
| 523 bool is_reference_error = false); | |
| 524 void ReportMessage(const char* message, | |
| 525 const AstString* arg, | |
| 526 bool is_reference_error = false); | 522 bool is_reference_error = false); |
| 527 void ReportMessageAt(Scanner::Location source_location, | 523 void ReportMessageAt(Scanner::Location source_location, |
| 528 const char* message, | 524 const char* message, |
| 529 const AstString* arg, | 525 MaybeHandle<String> arg, |
| 530 bool is_reference_error = false); | 526 bool is_reference_error = false); |
| 531 | 527 |
| 532 // "null" return type creators. | 528 // "null" return type creators. |
| 533 static const AstString* EmptyIdentifier() { | 529 static Handle<String> EmptyIdentifier() { |
| 534 return NULL; | 530 return Handle<String>(); |
| 535 } | 531 } |
| 536 static Expression* EmptyExpression() { | 532 static Expression* EmptyExpression() { |
| 537 return NULL; | 533 return NULL; |
| 538 } | 534 } |
| 539 static Literal* EmptyLiteral() { | 535 static Literal* EmptyLiteral() { |
| 540 return NULL; | 536 return NULL; |
| 541 } | 537 } |
| 542 // Used in error return values. | 538 // Used in error return values. |
| 543 static ZoneList<Expression*>* NullExpressionList() { | 539 static ZoneList<Expression*>* NullExpressionList() { |
| 544 return NULL; | 540 return NULL; |
| 545 } | 541 } |
| 546 | 542 |
| 547 // Odd-ball literal creators. | 543 // Odd-ball literal creators. |
| 548 Literal* GetLiteralTheHole(int position, | 544 Literal* GetLiteralTheHole(int position, |
| 549 AstNodeFactory<AstConstructionVisitor>* factory); | 545 AstNodeFactory<AstConstructionVisitor>* factory); |
| 550 | 546 |
| 551 // Producing data during the recursive descent. | 547 // Producing data during the recursive descent. |
| 552 const AstString* GetSymbol(Scanner* scanner); | 548 Handle<String> GetSymbol(Scanner* scanner = NULL); |
| 553 const AstString* GetNextSymbol(Scanner* scanner); | 549 Handle<String> NextLiteralString(Scanner* scanner, |
| 554 | 550 PretenureFlag tenured); |
| 555 Expression* ThisExpression(Scope* scope, | 551 Expression* ThisExpression(Scope* scope, |
| 556 AstNodeFactory<AstConstructionVisitor>* factory); | 552 AstNodeFactory<AstConstructionVisitor>* factory); |
| 557 Literal* ExpressionFromLiteral( | 553 Literal* ExpressionFromLiteral( |
| 558 Token::Value token, int pos, Scanner* scanner, | 554 Token::Value token, int pos, Scanner* scanner, |
| 559 AstNodeFactory<AstConstructionVisitor>* factory); | 555 AstNodeFactory<AstConstructionVisitor>* factory); |
| 560 Expression* ExpressionFromIdentifier( | 556 Expression* ExpressionFromIdentifier( |
| 561 const AstString* name, int pos, Scope* scope, | 557 Handle<String> name, int pos, Scope* scope, |
| 562 AstNodeFactory<AstConstructionVisitor>* factory); | 558 AstNodeFactory<AstConstructionVisitor>* factory); |
| 563 Expression* ExpressionFromString( | 559 Expression* ExpressionFromString( |
| 564 int pos, Scanner* scanner, | 560 int pos, Scanner* scanner, |
| 565 AstNodeFactory<AstConstructionVisitor>* factory); | 561 AstNodeFactory<AstConstructionVisitor>* factory); |
| 566 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) { | 562 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) { |
| 567 return new(zone) ZoneList<v8::internal::Expression*>(size, zone); | 563 return new(zone) ZoneList<v8::internal::Expression*>(size, zone); |
| 568 } | 564 } |
| 569 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { | 565 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { |
| 570 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); | 566 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); |
| 571 } | 567 } |
| 572 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { | 568 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { |
| 573 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); | 569 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); |
| 574 } | 570 } |
| 575 | 571 |
| 576 // Temporary glue; these functions will move to ParserBase. | 572 // Temporary glue; these functions will move to ParserBase. |
| 577 Expression* ParseV8Intrinsic(bool* ok); | 573 Expression* ParseV8Intrinsic(bool* ok); |
| 578 FunctionLiteral* ParseFunctionLiteral( | 574 FunctionLiteral* ParseFunctionLiteral( |
| 579 const AstString* name, | 575 Handle<String> name, |
| 580 Scanner::Location function_name_location, | 576 Scanner::Location function_name_location, |
| 581 bool name_is_strict_reserved, | 577 bool name_is_strict_reserved, |
| 582 bool is_generator, | 578 bool is_generator, |
| 583 int function_token_position, | 579 int function_token_position, |
| 584 FunctionLiteral::FunctionType type, | 580 FunctionLiteral::FunctionType type, |
| 585 FunctionLiteral::ArityRestriction arity_restriction, | 581 FunctionLiteral::ArityRestriction arity_restriction, |
| 586 bool* ok); | 582 bool* ok); |
| 587 | 583 |
| 588 private: | 584 private: |
| 589 Parser* parser_; | 585 Parser* parser_; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 FunctionLiteral* ParseLazy(Utf16CharacterStream* source); | 637 FunctionLiteral* ParseLazy(Utf16CharacterStream* source); |
| 642 | 638 |
| 643 Isolate* isolate() { return isolate_; } | 639 Isolate* isolate() { return isolate_; } |
| 644 CompilationInfo* info() const { return info_; } | 640 CompilationInfo* info() const { return info_; } |
| 645 | 641 |
| 646 // Called by ParseProgram after setting up the scanner. | 642 // Called by ParseProgram after setting up the scanner. |
| 647 FunctionLiteral* DoParseProgram(CompilationInfo* info, | 643 FunctionLiteral* DoParseProgram(CompilationInfo* info, |
| 648 Handle<String> source); | 644 Handle<String> source); |
| 649 | 645 |
| 650 // Report syntax error | 646 // Report syntax error |
| 651 void ReportInvalidCachedData(const AstString* name, bool* ok); | 647 void ReportInvalidCachedData(Handle<String> name, bool* ok); |
| 652 | 648 |
| 653 void SetCachedData(ScriptData** data, | 649 void SetCachedData(ScriptData** data, |
| 654 CachedDataMode cached_data_mode) { | 650 CachedDataMode cached_data_mode) { |
| 655 cached_data_mode_ = cached_data_mode; | 651 cached_data_mode_ = cached_data_mode; |
| 656 if (cached_data_mode == NO_CACHED_DATA) { | 652 if (cached_data_mode == NO_CACHED_DATA) { |
| 657 cached_data_ = NULL; | 653 cached_data_ = NULL; |
| 658 } else { | 654 } else { |
| 659 ASSERT(data != NULL); | 655 ASSERT(data != NULL); |
| 660 cached_data_ = data; | 656 cached_data_ = data; |
| 661 } | 657 } |
| 662 } | 658 } |
| 663 | 659 |
| 664 bool inside_with() const { return scope_->inside_with(); } | 660 bool inside_with() const { return scope_->inside_with(); } |
| 665 ScriptData** cached_data() const { return cached_data_; } | 661 ScriptData** cached_data() const { return cached_data_; } |
| 666 CachedDataMode cached_data_mode() const { return cached_data_mode_; } | 662 CachedDataMode cached_data_mode() const { return cached_data_mode_; } |
| 667 Scope* DeclarationScope(VariableMode mode) { | 663 Scope* DeclarationScope(VariableMode mode) { |
| 668 return IsLexicalVariableMode(mode) | 664 return IsLexicalVariableMode(mode) |
| 669 ? scope_ : scope_->DeclarationScope(); | 665 ? scope_ : scope_->DeclarationScope(); |
| 670 } | 666 } |
| 671 | 667 |
| 672 // All ParseXXX functions take as the last argument an *ok parameter | 668 // All ParseXXX functions take as the last argument an *ok parameter |
| 673 // which is set to false if parsing failed; it is unchanged otherwise. | 669 // which is set to false if parsing failed; it is unchanged otherwise. |
| 674 // By making the 'exception handling' explicit, we are forced to check | 670 // By making the 'exception handling' explicit, we are forced to check |
| 675 // for failure at the call sites. | 671 // for failure at the call sites. |
| 676 void* ParseSourceElements(ZoneList<Statement*>* processor, int end_token, | 672 void* ParseSourceElements(ZoneList<Statement*>* processor, int end_token, |
| 677 bool is_eval, bool is_global, bool* ok); | 673 bool is_eval, bool is_global, bool* ok); |
| 678 Statement* ParseModuleElement(ZoneList<const AstString*>* labels, bool* ok); | 674 Statement* ParseModuleElement(ZoneStringList* labels, bool* ok); |
| 679 Statement* ParseModuleDeclaration(ZoneList<const AstString*>* names, | 675 Statement* ParseModuleDeclaration(ZoneStringList* names, bool* ok); |
| 680 bool* ok); | |
| 681 Module* ParseModule(bool* ok); | 676 Module* ParseModule(bool* ok); |
| 682 Module* ParseModuleLiteral(bool* ok); | 677 Module* ParseModuleLiteral(bool* ok); |
| 683 Module* ParseModulePath(bool* ok); | 678 Module* ParseModulePath(bool* ok); |
| 684 Module* ParseModuleVariable(bool* ok); | 679 Module* ParseModuleVariable(bool* ok); |
| 685 Module* ParseModuleUrl(bool* ok); | 680 Module* ParseModuleUrl(bool* ok); |
| 686 Module* ParseModuleSpecifier(bool* ok); | 681 Module* ParseModuleSpecifier(bool* ok); |
| 687 Block* ParseImportDeclaration(bool* ok); | 682 Block* ParseImportDeclaration(bool* ok); |
| 688 Statement* ParseExportDeclaration(bool* ok); | 683 Statement* ParseExportDeclaration(bool* ok); |
| 689 Statement* ParseBlockElement(ZoneList<const AstString*>* labels, bool* ok); | 684 Statement* ParseBlockElement(ZoneStringList* labels, bool* ok); |
| 690 Statement* ParseStatement(ZoneList<const AstString*>* labels, bool* ok); | 685 Statement* ParseStatement(ZoneStringList* labels, bool* ok); |
| 691 Statement* ParseFunctionDeclaration(ZoneList<const AstString*>* names, | 686 Statement* ParseFunctionDeclaration(ZoneStringList* names, bool* ok); |
| 692 bool* ok); | |
| 693 Statement* ParseNativeDeclaration(bool* ok); | 687 Statement* ParseNativeDeclaration(bool* ok); |
| 694 Block* ParseBlock(ZoneList<const AstString*>* labels, bool* ok); | 688 Block* ParseBlock(ZoneStringList* labels, bool* ok); |
| 695 Block* ParseVariableStatement(VariableDeclarationContext var_context, | 689 Block* ParseVariableStatement(VariableDeclarationContext var_context, |
| 696 ZoneList<const AstString*>* names, | 690 ZoneStringList* names, |
| 697 bool* ok); | 691 bool* ok); |
| 698 Block* ParseVariableDeclarations(VariableDeclarationContext var_context, | 692 Block* ParseVariableDeclarations(VariableDeclarationContext var_context, |
| 699 VariableDeclarationProperties* decl_props, | 693 VariableDeclarationProperties* decl_props, |
| 700 ZoneList<const AstString*>* names, | 694 ZoneStringList* names, |
| 701 const AstString** out, | 695 Handle<String>* out, |
| 702 bool* ok); | 696 bool* ok); |
| 703 Statement* ParseExpressionOrLabelledStatement( | 697 Statement* ParseExpressionOrLabelledStatement(ZoneStringList* labels, |
| 704 ZoneList<const AstString*>* labels, bool* ok); | 698 bool* ok); |
| 705 IfStatement* ParseIfStatement(ZoneList<const AstString*>* labels, bool* ok); | 699 IfStatement* ParseIfStatement(ZoneStringList* labels, bool* ok); |
| 706 Statement* ParseContinueStatement(bool* ok); | 700 Statement* ParseContinueStatement(bool* ok); |
| 707 Statement* ParseBreakStatement(ZoneList<const AstString*>* labels, bool* ok); | 701 Statement* ParseBreakStatement(ZoneStringList* labels, bool* ok); |
| 708 Statement* ParseReturnStatement(bool* ok); | 702 Statement* ParseReturnStatement(bool* ok); |
| 709 Statement* ParseWithStatement(ZoneList<const AstString*>* labels, bool* ok); | 703 Statement* ParseWithStatement(ZoneStringList* labels, bool* ok); |
| 710 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); | 704 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); |
| 711 SwitchStatement* ParseSwitchStatement(ZoneList<const AstString*>* labels, | 705 SwitchStatement* ParseSwitchStatement(ZoneStringList* labels, bool* ok); |
| 712 bool* ok); | 706 DoWhileStatement* ParseDoWhileStatement(ZoneStringList* labels, bool* ok); |
| 713 DoWhileStatement* ParseDoWhileStatement(ZoneList<const AstString*>* labels, | 707 WhileStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok); |
| 714 bool* ok); | 708 Statement* ParseForStatement(ZoneStringList* labels, bool* ok); |
| 715 WhileStatement* ParseWhileStatement(ZoneList<const AstString*>* labels, | |
| 716 bool* ok); | |
| 717 Statement* ParseForStatement(ZoneList<const AstString*>* labels, bool* ok); | |
| 718 Statement* ParseThrowStatement(bool* ok); | 709 Statement* ParseThrowStatement(bool* ok); |
| 719 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); | 710 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); |
| 720 TryStatement* ParseTryStatement(bool* ok); | 711 TryStatement* ParseTryStatement(bool* ok); |
| 721 DebuggerStatement* ParseDebuggerStatement(bool* ok); | 712 DebuggerStatement* ParseDebuggerStatement(bool* ok); |
| 722 | 713 |
| 723 // Support for hamony block scoped bindings. | 714 // Support for hamony block scoped bindings. |
| 724 Block* ParseScopedBlock(ZoneList<const AstString*>* labels, bool* ok); | 715 Block* ParseScopedBlock(ZoneStringList* labels, bool* ok); |
| 725 | 716 |
| 726 // Initialize the components of a for-in / for-of statement. | 717 // Initialize the components of a for-in / for-of statement. |
| 727 void InitializeForEachStatement(ForEachStatement* stmt, | 718 void InitializeForEachStatement(ForEachStatement* stmt, |
| 728 Expression* each, | 719 Expression* each, |
| 729 Expression* subject, | 720 Expression* subject, |
| 730 Statement* body); | 721 Statement* body); |
| 731 Statement* DesugarLetBindingsInForStatement( | 722 Statement* DesugarLetBindingsInForStatement( |
| 732 Scope* inner_scope, ZoneList<const AstString*>* names, | 723 Scope* inner_scope, ZoneStringList* names, ForStatement* loop, |
| 733 ForStatement* loop, Statement* init, Expression* cond, Statement* next, | 724 Statement* init, Expression* cond, Statement* next, Statement* body, |
| 734 Statement* body, bool* ok); | 725 bool* ok); |
| 735 | 726 |
| 736 FunctionLiteral* ParseFunctionLiteral( | 727 FunctionLiteral* ParseFunctionLiteral( |
| 737 const AstString* name, | 728 Handle<String> name, |
| 738 Scanner::Location function_name_location, | 729 Scanner::Location function_name_location, |
| 739 bool name_is_strict_reserved, | 730 bool name_is_strict_reserved, |
| 740 bool is_generator, | 731 bool is_generator, |
| 741 int function_token_position, | 732 int function_token_position, |
| 742 FunctionLiteral::FunctionType type, | 733 FunctionLiteral::FunctionType type, |
| 743 FunctionLiteral::ArityRestriction arity_restriction, | 734 FunctionLiteral::ArityRestriction arity_restriction, |
| 744 bool* ok); | 735 bool* ok); |
| 745 | 736 |
| 746 // Magical syntax support. | 737 // Magical syntax support. |
| 747 Expression* ParseV8Intrinsic(bool* ok); | 738 Expression* ParseV8Intrinsic(bool* ok); |
| 748 | 739 |
| 749 bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode); | 740 bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode); |
| 750 | 741 |
| 751 // Get odd-ball literals. | 742 // Get odd-ball literals. |
| 752 Literal* GetLiteralUndefined(int position); | 743 Literal* GetLiteralUndefined(int position); |
| 753 | 744 |
| 754 // For harmony block scoping mode: Check if the scope has conflicting var/let | 745 // For harmony block scoping mode: Check if the scope has conflicting var/let |
| 755 // declarations from different scopes. It covers for example | 746 // declarations from different scopes. It covers for example |
| 756 // | 747 // |
| 757 // function f() { { { var x; } let x; } } | 748 // function f() { { { var x; } let x; } } |
| 758 // function g() { { var x; let x; } } | 749 // function g() { { var x; let x; } } |
| 759 // | 750 // |
| 760 // The var declarations are hoisted to the function scope, but originate from | 751 // The var declarations are hoisted to the function scope, but originate from |
| 761 // a scope where the name has also been let bound or the var declaration is | 752 // a scope where the name has also been let bound or the var declaration is |
| 762 // hoisted over such a scope. | 753 // hoisted over such a scope. |
| 763 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); | 754 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); |
| 764 | 755 |
| 765 // Parser support | 756 // Parser support |
| 766 VariableProxy* NewUnresolved(const AstString* name, | 757 VariableProxy* NewUnresolved(Handle<String> name, |
| 767 VariableMode mode, | 758 VariableMode mode, |
| 768 Interface* interface); | 759 Interface* interface); |
| 769 void Declare(Declaration* declaration, bool resolve, bool* ok); | 760 void Declare(Declaration* declaration, bool resolve, bool* ok); |
| 770 | 761 |
| 771 bool TargetStackContainsLabel(const AstString* label); | 762 bool TargetStackContainsLabel(Handle<String> label); |
| 772 BreakableStatement* LookupBreakTarget(const AstString* label, bool* ok); | 763 BreakableStatement* LookupBreakTarget(Handle<String> label, bool* ok); |
| 773 IterationStatement* LookupContinueTarget(const AstString* label, bool* ok); | 764 IterationStatement* LookupContinueTarget(Handle<String> label, bool* ok); |
| 774 | 765 |
| 775 void RegisterTargetUse(Label* target, Target* stop); | 766 void RegisterTargetUse(Label* target, Target* stop); |
| 776 | 767 |
| 777 // Factory methods. | 768 // Factory methods. |
| 778 | 769 |
| 779 Scope* NewScope(Scope* parent, ScopeType type); | 770 Scope* NewScope(Scope* parent, ScopeType type); |
| 780 | 771 |
| 781 // Skip over a lazy function, either using cached data if we have it, or | 772 // Skip over a lazy function, either using cached data if we have it, or |
| 782 // by parsing the function with PreParser. Consumes the ending }. | 773 // by parsing the function with PreParser. Consumes the ending }. |
| 783 void SkipLazyFunctionBody(const AstString* function_name, | 774 void SkipLazyFunctionBody(Handle<String> function_name, |
| 784 int* materialized_literal_count, | 775 int* materialized_literal_count, |
| 785 int* expected_property_count, | 776 int* expected_property_count, |
| 786 bool* ok); | 777 bool* ok); |
| 787 | 778 |
| 788 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser( | 779 PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser( |
| 789 SingletonLogger* logger); | 780 SingletonLogger* logger); |
| 790 | 781 |
| 791 // Consumes the ending }. | 782 // Consumes the ending }. |
| 792 ZoneList<Statement*>* ParseEagerFunctionBody(const AstString* function_name, | 783 ZoneList<Statement*>* ParseEagerFunctionBody(Handle<String> function_name, |
| 793 int pos, | 784 int pos, |
| 794 Variable* fvar, | 785 Variable* fvar, |
| 795 Token::Value fvar_init_op, | 786 Token::Value fvar_init_op, |
| 796 bool is_generator, | 787 bool is_generator, |
| 797 bool* ok); | 788 bool* ok); |
| 798 | 789 |
| 799 void ThrowPendingError(); | 790 void ThrowPendingError(); |
| 800 | 791 |
| 801 Isolate* isolate_; | 792 Isolate* isolate_; |
| 802 | 793 |
| 803 Handle<Script> script_; | 794 Handle<Script> script_; |
| 804 Scanner scanner_; | 795 Scanner scanner_; |
| 805 PreParser* reusable_preparser_; | 796 PreParser* reusable_preparser_; |
| 806 Scope* original_scope_; // for ES5 function declarations in sloppy eval | 797 Scope* original_scope_; // for ES5 function declarations in sloppy eval |
| 807 Target* target_stack_; // for break, continue statements | 798 Target* target_stack_; // for break, continue statements |
| 808 ScriptData** cached_data_; | 799 ScriptData** cached_data_; |
| 809 CachedDataMode cached_data_mode_; | 800 CachedDataMode cached_data_mode_; |
| 810 AstValueFactory* ast_value_factory_; | |
| 811 | 801 |
| 812 CompilationInfo* info_; | 802 CompilationInfo* info_; |
| 813 | 803 |
| 814 // Pending errors. | 804 // Pending errors. |
| 815 bool has_pending_error_; | 805 bool has_pending_error_; |
| 816 Scanner::Location pending_error_location_; | 806 Scanner::Location pending_error_location_; |
| 817 const char* pending_error_message_; | 807 const char* pending_error_message_; |
| 818 const AstString* pending_error_arg_; | 808 MaybeHandle<String> pending_error_arg_; |
| 819 const char* pending_error_char_arg_; | 809 const char* pending_error_char_arg_; |
| 820 bool pending_error_is_reference_error_; | 810 bool pending_error_is_reference_error_; |
| 821 }; | 811 }; |
| 822 | 812 |
| 823 | 813 |
| 824 // Support for handling complex values (array and object literals) that | 814 // Support for handling complex values (array and object literals) that |
| 825 // can be fully handled at compile time. | 815 // can be fully handled at compile time. |
| 826 class CompileTimeValue: public AllStatic { | 816 class CompileTimeValue: public AllStatic { |
| 827 public: | 817 public: |
| 828 enum LiteralType { | 818 enum LiteralType { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 845 private: | 835 private: |
| 846 static const int kLiteralTypeSlot = 0; | 836 static const int kLiteralTypeSlot = 0; |
| 847 static const int kElementsSlot = 1; | 837 static const int kElementsSlot = 1; |
| 848 | 838 |
| 849 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 839 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
| 850 }; | 840 }; |
| 851 | 841 |
| 852 } } // namespace v8::internal | 842 } } // namespace v8::internal |
| 853 | 843 |
| 854 #endif // V8_PARSER_H_ | 844 #endif // V8_PARSER_H_ |
| OLD | NEW |