| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 kHasInitializers, | 481 kHasInitializers, |
| 482 kHasNoInitializers | 482 kHasNoInitializers |
| 483 }; | 483 }; |
| 484 | 484 |
| 485 class BlockState; | 485 class BlockState; |
| 486 | 486 |
| 487 class FunctionState BASE_EMBEDDED { | 487 class FunctionState BASE_EMBEDDED { |
| 488 public: | 488 public: |
| 489 FunctionState(Parser* parser, | 489 FunctionState(Parser* parser, |
| 490 Scope* scope, | 490 Scope* scope, |
| 491 bool is_generator, | |
| 492 Isolate* isolate); | 491 Isolate* isolate); |
| 493 ~FunctionState(); | 492 ~FunctionState(); |
| 494 | 493 |
| 495 int NextMaterializedLiteralIndex() { | 494 int NextMaterializedLiteralIndex() { |
| 496 return next_materialized_literal_index_++; | 495 return next_materialized_literal_index_++; |
| 497 } | 496 } |
| 498 int materialized_literal_count() { | 497 int materialized_literal_count() { |
| 499 return next_materialized_literal_index_ - JSFunction::kLiteralsPrefixSize; | 498 return next_materialized_literal_index_ - JSFunction::kLiteralsPrefixSize; |
| 500 } | 499 } |
| 501 | 500 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 512 bool only_simple_this_property_assignments() { | 511 bool only_simple_this_property_assignments() { |
| 513 return only_simple_this_property_assignments_; | 512 return only_simple_this_property_assignments_; |
| 514 } | 513 } |
| 515 Handle<FixedArray> this_property_assignments() { | 514 Handle<FixedArray> this_property_assignments() { |
| 516 return this_property_assignments_; | 515 return this_property_assignments_; |
| 517 } | 516 } |
| 518 | 517 |
| 519 void AddProperty() { expected_property_count_++; } | 518 void AddProperty() { expected_property_count_++; } |
| 520 int expected_property_count() { return expected_property_count_; } | 519 int expected_property_count() { return expected_property_count_; } |
| 521 | 520 |
| 522 bool is_generator() const { return is_generator_; } | 521 void set_generator_object_variable(Variable *variable) { |
| 522 ASSERT(variable != NULL); |
| 523 ASSERT(!is_generator()); |
| 524 generator_object_variable_ = variable; |
| 525 } |
| 526 Variable* generator_object_variable() const { |
| 527 return generator_object_variable_; |
| 528 } |
| 529 bool is_generator() const { |
| 530 return generator_object_variable_ != NULL; |
| 531 } |
| 523 | 532 |
| 524 AstNodeFactory<AstConstructionVisitor>* factory() { return &factory_; } | 533 AstNodeFactory<AstConstructionVisitor>* factory() { return &factory_; } |
| 525 | 534 |
| 526 private: | 535 private: |
| 527 // Used to assign an index to each literal that needs materialization in | 536 // Used to assign an index to each literal that needs materialization in |
| 528 // the function. Includes regexp literals, and boilerplate for object and | 537 // the function. Includes regexp literals, and boilerplate for object and |
| 529 // array literals. | 538 // array literals. |
| 530 int next_materialized_literal_index_; | 539 int next_materialized_literal_index_; |
| 531 | 540 |
| 532 // Used to assign a per-function index to try and catch handlers. | 541 // Used to assign a per-function index to try and catch handlers. |
| 533 int next_handler_index_; | 542 int next_handler_index_; |
| 534 | 543 |
| 535 // Properties count estimation. | 544 // Properties count estimation. |
| 536 int expected_property_count_; | 545 int expected_property_count_; |
| 537 | 546 |
| 538 // Indicates that this function is a generator. | |
| 539 bool is_generator_; | |
| 540 | |
| 541 // Keeps track of assignments to properties of this. Used for | 547 // Keeps track of assignments to properties of this. Used for |
| 542 // optimizing constructors. | 548 // optimizing constructors. |
| 543 bool only_simple_this_property_assignments_; | 549 bool only_simple_this_property_assignments_; |
| 544 Handle<FixedArray> this_property_assignments_; | 550 Handle<FixedArray> this_property_assignments_; |
| 545 | 551 |
| 552 // For generators, the variable that holds the generator object. This |
| 553 // variable is used by yield expressions and return statements. NULL |
| 554 // indicates that this function is not a generator. |
| 555 Variable* generator_object_variable_; |
| 556 |
| 546 Parser* parser_; | 557 Parser* parser_; |
| 547 FunctionState* outer_function_state_; | 558 FunctionState* outer_function_state_; |
| 548 Scope* outer_scope_; | 559 Scope* outer_scope_; |
| 549 int saved_ast_node_id_; | 560 int saved_ast_node_id_; |
| 550 AstNodeFactory<AstConstructionVisitor> factory_; | 561 AstNodeFactory<AstConstructionVisitor> factory_; |
| 551 }; | 562 }; |
| 552 | 563 |
| 553 class ParsingModeScope BASE_EMBEDDED { | 564 class ParsingModeScope BASE_EMBEDDED { |
| 554 public: | 565 public: |
| 555 ParsingModeScope(Parser* parser, Mode mode) | 566 ParsingModeScope(Parser* parser, Mode mode) |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 702 |
| 692 // Decide if a property should be in the object boilerplate. | 703 // Decide if a property should be in the object boilerplate. |
| 693 bool IsBoilerplateProperty(ObjectLiteral::Property* property); | 704 bool IsBoilerplateProperty(ObjectLiteral::Property* property); |
| 694 // If the expression is a literal, return the literal value; | 705 // If the expression is a literal, return the literal value; |
| 695 // if the expression is a materialized literal and is simple return a | 706 // if the expression is a materialized literal and is simple return a |
| 696 // compile time value as encoded by CompileTimeValue::GetValue(). | 707 // compile time value as encoded by CompileTimeValue::GetValue(). |
| 697 // Otherwise, return undefined literal as the placeholder | 708 // Otherwise, return undefined literal as the placeholder |
| 698 // in the object literal boilerplate. | 709 // in the object literal boilerplate. |
| 699 Handle<Object> GetBoilerplateValue(Expression* expression); | 710 Handle<Object> GetBoilerplateValue(Expression* expression); |
| 700 | 711 |
| 712 Statement* BuildGeneratorObjectInitialization(); |
| 713 |
| 701 ZoneList<Expression*>* ParseArguments(bool* ok); | 714 ZoneList<Expression*>* ParseArguments(bool* ok); |
| 702 FunctionLiteral* ParseFunctionLiteral(Handle<String> var_name, | 715 FunctionLiteral* ParseFunctionLiteral(Handle<String> var_name, |
| 703 bool name_is_reserved, | 716 bool name_is_reserved, |
| 704 bool is_generator, | 717 bool is_generator, |
| 705 int function_token_position, | 718 int function_token_position, |
| 706 FunctionLiteral::Type type, | 719 FunctionLiteral::Type type, |
| 707 bool* ok); | 720 bool* ok); |
| 708 | 721 |
| 709 | 722 |
| 710 // Magical syntax support. | 723 // Magical syntax support. |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 private: | 915 private: |
| 903 static const int kTypeSlot = 0; | 916 static const int kTypeSlot = 0; |
| 904 static const int kElementsSlot = 1; | 917 static const int kElementsSlot = 1; |
| 905 | 918 |
| 906 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 919 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
| 907 }; | 920 }; |
| 908 | 921 |
| 909 } } // namespace v8::internal | 922 } } // namespace v8::internal |
| 910 | 923 |
| 911 #endif // V8_PARSER_H_ | 924 #endif // V8_PARSER_H_ |
| OLD | NEW |