| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 private: | 913 private: |
| 903 static const int kTypeSlot = 0; | 914 static const int kTypeSlot = 0; |
| 904 static const int kElementsSlot = 1; | 915 static const int kElementsSlot = 1; |
| 905 | 916 |
| 906 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 917 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
| 907 }; | 918 }; |
| 908 | 919 |
| 909 } } // namespace v8::internal | 920 } } // namespace v8::internal |
| 910 | 921 |
| 911 #endif // V8_PARSER_H_ | 922 #endif // V8_PARSER_H_ |
| OLD | NEW |