| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 virtual VariableProxy* AsVariableProxy() { return NULL; } | 122 virtual VariableProxy* AsVariableProxy() { return NULL; } |
| 123 virtual Property* AsProperty() { return NULL; } | 123 virtual Property* AsProperty() { return NULL; } |
| 124 virtual Call* AsCall() { return NULL; } | 124 virtual Call* AsCall() { return NULL; } |
| 125 virtual TargetCollector* AsTargetCollector() { return NULL; } | 125 virtual TargetCollector* AsTargetCollector() { return NULL; } |
| 126 virtual BreakableStatement* AsBreakableStatement() { return NULL; } | 126 virtual BreakableStatement* AsBreakableStatement() { return NULL; } |
| 127 virtual IterationStatement* AsIterationStatement() { return NULL; } | 127 virtual IterationStatement* AsIterationStatement() { return NULL; } |
| 128 virtual UnaryOperation* AsUnaryOperation() { return NULL; } | 128 virtual UnaryOperation* AsUnaryOperation() { return NULL; } |
| 129 virtual BinaryOperation* AsBinaryOperation() { return NULL; } | 129 virtual BinaryOperation* AsBinaryOperation() { return NULL; } |
| 130 virtual Assignment* AsAssignment() { return NULL; } | 130 virtual Assignment* AsAssignment() { return NULL; } |
| 131 virtual FunctionLiteral* AsFunctionLiteral() { return NULL; } | 131 virtual FunctionLiteral* AsFunctionLiteral() { return NULL; } |
| 132 virtual ObjectLiteral* AsObjectLiteral() { return NULL; } |
| 132 | 133 |
| 133 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } | 134 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } |
| 134 int statement_pos() const { return statement_pos_; } | 135 int statement_pos() const { return statement_pos_; } |
| 135 | 136 |
| 136 private: | 137 private: |
| 137 int statement_pos_; | 138 int statement_pos_; |
| 138 }; | 139 }; |
| 139 | 140 |
| 140 | 141 |
| 141 class Statement: public Node { | 142 class Statement: public Node { |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 class CaseClause: public ZoneObject { | 441 class CaseClause: public ZoneObject { |
| 441 public: | 442 public: |
| 442 CaseClause(Expression* label, ZoneList<Statement*>* statements) | 443 CaseClause(Expression* label, ZoneList<Statement*>* statements) |
| 443 : label_(label), statements_(statements) { } | 444 : label_(label), statements_(statements) { } |
| 444 | 445 |
| 445 bool is_default() const { return label_ == NULL; } | 446 bool is_default() const { return label_ == NULL; } |
| 446 Expression* label() const { | 447 Expression* label() const { |
| 447 CHECK(!is_default()); | 448 CHECK(!is_default()); |
| 448 return label_; | 449 return label_; |
| 449 } | 450 } |
| 451 JumpTarget* body_target() { return &body_target_; } |
| 450 ZoneList<Statement*>* statements() const { return statements_; } | 452 ZoneList<Statement*>* statements() const { return statements_; } |
| 451 | 453 |
| 452 private: | 454 private: |
| 453 Expression* label_; | 455 Expression* label_; |
| 456 JumpTarget body_target_; |
| 454 ZoneList<Statement*>* statements_; | 457 ZoneList<Statement*>* statements_; |
| 455 }; | 458 }; |
| 456 | 459 |
| 457 | 460 |
| 458 class SwitchStatement: public BreakableStatement { | 461 class SwitchStatement: public BreakableStatement { |
| 459 public: | 462 public: |
| 460 explicit SwitchStatement(ZoneStringList* labels) | 463 explicit SwitchStatement(ZoneStringList* labels) |
| 461 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS), | 464 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS), |
| 462 tag_(NULL), cases_(NULL) { } | 465 tag_(NULL), cases_(NULL) { } |
| 463 | 466 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 // for minimizing the work when constructing it at runtime. | 645 // for minimizing the work when constructing it at runtime. |
| 643 class ObjectLiteral: public MaterializedLiteral { | 646 class ObjectLiteral: public MaterializedLiteral { |
| 644 public: | 647 public: |
| 645 // Property is used for passing information | 648 // Property is used for passing information |
| 646 // about an object literal's properties from the parser | 649 // about an object literal's properties from the parser |
| 647 // to the code generator. | 650 // to the code generator. |
| 648 class Property: public ZoneObject { | 651 class Property: public ZoneObject { |
| 649 public: | 652 public: |
| 650 | 653 |
| 651 enum Kind { | 654 enum Kind { |
| 652 CONSTANT, // Property with constant value (at compile time). | 655 CONSTANT, // Property with constant value (at compile time). |
| 653 COMPUTED, // Property with computed value (at execution time). | 656 COMPUTED, // Property with computed value (at execution time). |
| 657 OBJECT_LITERAL, // Property value is an object literal. |
| 654 GETTER, SETTER, // Property is an accessor function. | 658 GETTER, SETTER, // Property is an accessor function. |
| 655 PROTOTYPE // Property is __proto__. | 659 PROTOTYPE // Property is __proto__. |
| 656 }; | 660 }; |
| 657 | 661 |
| 658 Property(Literal* key, Expression* value); | 662 Property(Literal* key, Expression* value); |
| 659 Property(bool is_getter, FunctionLiteral* value); | 663 Property(bool is_getter, FunctionLiteral* value); |
| 660 | 664 |
| 661 Literal* key() { return key_; } | 665 Literal* key() { return key_; } |
| 662 Expression* value() { return value_; } | 666 Expression* value() { return value_; } |
| 663 Kind kind() { return kind_; } | 667 Kind kind() { return kind_; } |
| 664 | 668 |
| 665 private: | 669 private: |
| 666 Literal* key_; | 670 Literal* key_; |
| 667 Expression* value_; | 671 Expression* value_; |
| 668 Kind kind_; | 672 Kind kind_; |
| 669 }; | 673 }; |
| 670 | 674 |
| 671 ObjectLiteral(Handle<FixedArray> constant_properties, | 675 ObjectLiteral(Handle<FixedArray> constant_properties, |
| 672 ZoneList<Property*>* properties, | 676 ZoneList<Property*>* properties, |
| 673 int literal_index) | 677 int literal_index, |
| 678 bool is_simple) |
| 674 : MaterializedLiteral(literal_index), | 679 : MaterializedLiteral(literal_index), |
| 675 constant_properties_(constant_properties), | 680 constant_properties_(constant_properties), |
| 676 properties_(properties) { | 681 properties_(properties), |
| 682 is_simple_(is_simple) { |
| 677 } | 683 } |
| 678 | 684 |
| 685 virtual ObjectLiteral* AsObjectLiteral() { return this; } |
| 679 virtual void Accept(AstVisitor* v); | 686 virtual void Accept(AstVisitor* v); |
| 680 | 687 |
| 681 Handle<FixedArray> constant_properties() const { | 688 Handle<FixedArray> constant_properties() const { |
| 682 return constant_properties_; | 689 return constant_properties_; |
| 683 } | 690 } |
| 684 ZoneList<Property*>* properties() const { return properties_; } | 691 ZoneList<Property*>* properties() const { return properties_; } |
| 685 | 692 |
| 693 // An object literal is simple if the values consist of only |
| 694 // constants and simple object literals. |
| 695 bool is_simple() const { return is_simple_; } |
| 696 |
| 686 private: | 697 private: |
| 687 Handle<FixedArray> constant_properties_; | 698 Handle<FixedArray> constant_properties_; |
| 688 ZoneList<Property*>* properties_; | 699 ZoneList<Property*>* properties_; |
| 700 bool is_simple_; |
| 689 }; | 701 }; |
| 690 | 702 |
| 691 | 703 |
| 692 // Node for capturing a regexp literal. | 704 // Node for capturing a regexp literal. |
| 693 class RegExpLiteral: public MaterializedLiteral { | 705 class RegExpLiteral: public MaterializedLiteral { |
| 694 public: | 706 public: |
| 695 RegExpLiteral(Handle<String> pattern, | 707 RegExpLiteral(Handle<String> pattern, |
| 696 Handle<String> flags, | 708 Handle<String> flags, |
| 697 int literal_index) | 709 int literal_index) |
| 698 : MaterializedLiteral(literal_index), | 710 : MaterializedLiteral(literal_index), |
| (...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 #undef DEF_VISIT | 1654 #undef DEF_VISIT |
| 1643 | 1655 |
| 1644 private: | 1656 private: |
| 1645 bool stack_overflow_; | 1657 bool stack_overflow_; |
| 1646 }; | 1658 }; |
| 1647 | 1659 |
| 1648 | 1660 |
| 1649 } } // namespace v8::internal | 1661 } } // namespace v8::internal |
| 1650 | 1662 |
| 1651 #endif // V8_AST_H_ | 1663 #endif // V8_AST_H_ |
| OLD | NEW |