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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 kHasInitializers, | 467 kHasInitializers, |
468 kHasNoInitializers | 468 kHasNoInitializers |
469 }; | 469 }; |
470 | 470 |
471 class BlockState; | 471 class BlockState; |
472 | 472 |
473 class FunctionState BASE_EMBEDDED { | 473 class FunctionState BASE_EMBEDDED { |
474 public: | 474 public: |
475 FunctionState(Parser* parser, | 475 FunctionState(Parser* parser, |
476 Scope* scope, | 476 Scope* scope, |
477 bool is_generator, | |
478 Isolate* isolate); | 477 Isolate* isolate); |
479 ~FunctionState(); | 478 ~FunctionState(); |
480 | 479 |
481 int NextMaterializedLiteralIndex() { | 480 int NextMaterializedLiteralIndex() { |
482 return next_materialized_literal_index_++; | 481 return next_materialized_literal_index_++; |
483 } | 482 } |
484 int materialized_literal_count() { | 483 int materialized_literal_count() { |
485 return next_materialized_literal_index_ - JSFunction::kLiteralsPrefixSize; | 484 return next_materialized_literal_index_ - JSFunction::kLiteralsPrefixSize; |
486 } | 485 } |
487 | 486 |
(...skipping 10 matching lines...) Expand all Loading... |
498 bool only_simple_this_property_assignments() { | 497 bool only_simple_this_property_assignments() { |
499 return only_simple_this_property_assignments_; | 498 return only_simple_this_property_assignments_; |
500 } | 499 } |
501 Handle<FixedArray> this_property_assignments() { | 500 Handle<FixedArray> this_property_assignments() { |
502 return this_property_assignments_; | 501 return this_property_assignments_; |
503 } | 502 } |
504 | 503 |
505 void AddProperty() { expected_property_count_++; } | 504 void AddProperty() { expected_property_count_++; } |
506 int expected_property_count() { return expected_property_count_; } | 505 int expected_property_count() { return expected_property_count_; } |
507 | 506 |
508 bool is_generator() const { return is_generator_; } | 507 void set_generator_iterator_variable(Variable *variable) { |
| 508 ASSERT(variable != NULL); |
| 509 ASSERT(!is_generator()); |
| 510 generator_iterator_variable_ = variable; |
| 511 } |
| 512 Variable* generator_iterator_variable() const { |
| 513 return generator_iterator_variable_; |
| 514 } |
| 515 bool is_generator() const { |
| 516 return generator_iterator_variable_ != NULL; |
| 517 } |
509 | 518 |
510 AstNodeFactory<AstConstructionVisitor>* factory() { return &factory_; } | 519 AstNodeFactory<AstConstructionVisitor>* factory() { return &factory_; } |
511 | 520 |
512 private: | 521 private: |
513 // Used to assign an index to each literal that needs materialization in | 522 // Used to assign an index to each literal that needs materialization in |
514 // the function. Includes regexp literals, and boilerplate for object and | 523 // the function. Includes regexp literals, and boilerplate for object and |
515 // array literals. | 524 // array literals. |
516 int next_materialized_literal_index_; | 525 int next_materialized_literal_index_; |
517 | 526 |
518 // Used to assign a per-function index to try and catch handlers. | 527 // Used to assign a per-function index to try and catch handlers. |
519 int next_handler_index_; | 528 int next_handler_index_; |
520 | 529 |
521 // Properties count estimation. | 530 // Properties count estimation. |
522 int expected_property_count_; | 531 int expected_property_count_; |
523 | 532 |
524 // Indicates that this function is a generator. | |
525 bool is_generator_; | |
526 | |
527 // Keeps track of assignments to properties of this. Used for | 533 // Keeps track of assignments to properties of this. Used for |
528 // optimizing constructors. | 534 // optimizing constructors. |
529 bool only_simple_this_property_assignments_; | 535 bool only_simple_this_property_assignments_; |
530 Handle<FixedArray> this_property_assignments_; | 536 Handle<FixedArray> this_property_assignments_; |
531 | 537 |
532 Parser* parser_; | 538 Parser* parser_; |
533 FunctionState* outer_function_state_; | 539 FunctionState* outer_function_state_; |
534 Scope* outer_scope_; | 540 Scope* outer_scope_; |
| 541 Variable* generator_iterator_variable_; |
535 int saved_ast_node_id_; | 542 int saved_ast_node_id_; |
536 AstNodeFactory<AstConstructionVisitor> factory_; | 543 AstNodeFactory<AstConstructionVisitor> factory_; |
537 }; | 544 }; |
538 | 545 |
539 class ParsingModeScope BASE_EMBEDDED { | 546 class ParsingModeScope BASE_EMBEDDED { |
540 public: | 547 public: |
541 ParsingModeScope(Parser* parser, Mode mode) | 548 ParsingModeScope(Parser* parser, Mode mode) |
542 : parser_(parser), | 549 : parser_(parser), |
543 old_mode_(parser->mode()) { | 550 old_mode_(parser->mode()) { |
544 parser_->mode_ = mode; | 551 parser_->mode_ = mode; |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 private: | 889 private: |
883 static const int kTypeSlot = 0; | 890 static const int kTypeSlot = 0; |
884 static const int kElementsSlot = 1; | 891 static const int kElementsSlot = 1; |
885 | 892 |
886 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 893 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
887 }; | 894 }; |
888 | 895 |
889 } } // namespace v8::internal | 896 } } // namespace v8::internal |
890 | 897 |
891 #endif // V8_PARSER_H_ | 898 #endif // V8_PARSER_H_ |
OLD | NEW |