| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 class AstNode: public ZoneObject { | 127 class AstNode: public ZoneObject { |
| 128 public: | 128 public: |
| 129 #define DECLARE_TYPE_ENUM(type) k##type, | 129 #define DECLARE_TYPE_ENUM(type) k##type, |
| 130 enum Type { | 130 enum Type { |
| 131 AST_NODE_LIST(DECLARE_TYPE_ENUM) | 131 AST_NODE_LIST(DECLARE_TYPE_ENUM) |
| 132 kInvalid = -1 | 132 kInvalid = -1 |
| 133 }; | 133 }; |
| 134 #undef DECLARE_TYPE_ENUM | 134 #undef DECLARE_TYPE_ENUM |
| 135 | 135 |
| 136 static const int kNoNumber = -1; | |
| 137 | |
| 138 AstNode() : id_(GetNextId()) { count_++; } | 136 AstNode() : id_(GetNextId()) { count_++; } |
| 139 | 137 |
| 140 virtual ~AstNode() { } | 138 virtual ~AstNode() { } |
| 141 | 139 |
| 142 virtual void Accept(AstVisitor* v) = 0; | 140 virtual void Accept(AstVisitor* v) = 0; |
| 143 virtual Type node_type() const { return kInvalid; } | 141 virtual Type node_type() const { return kInvalid; } |
| 144 | 142 |
| 145 // Type testing & conversion functions overridden by concrete subclasses. | 143 // Type testing & conversion functions overridden by concrete subclasses. |
| 146 #define DECLARE_NODE_FUNCTIONS(type) \ | 144 #define DECLARE_NODE_FUNCTIONS(type) \ |
| 147 virtual type* As##type() { return NULL; } | 145 virtual type* As##type() { return NULL; } |
| 148 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 146 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 149 #undef DECLARE_NODE_FUNCTIONS | 147 #undef DECLARE_NODE_FUNCTIONS |
| 150 | 148 |
| 151 virtual Statement* AsStatement() { return NULL; } | 149 virtual Statement* AsStatement() { return NULL; } |
| 152 virtual Expression* AsExpression() { return NULL; } | 150 virtual Expression* AsExpression() { return NULL; } |
| 153 virtual TargetCollector* AsTargetCollector() { return NULL; } | 151 virtual TargetCollector* AsTargetCollector() { return NULL; } |
| 154 virtual BreakableStatement* AsBreakableStatement() { return NULL; } | 152 virtual BreakableStatement* AsBreakableStatement() { return NULL; } |
| 155 virtual IterationStatement* AsIterationStatement() { return NULL; } | 153 virtual IterationStatement* AsIterationStatement() { return NULL; } |
| 156 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } | 154 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } |
| 157 virtual Slot* AsSlot() { return NULL; } | 155 virtual Slot* AsSlot() { return NULL; } |
| 158 | 156 |
| 159 // True if the node is simple enough for us to inline calls containing it. | 157 // True if the node is simple enough for us to inline calls containing it. |
| 160 virtual bool IsInlineable() const { return false; } | 158 virtual bool IsInlineable() const { return false; } |
| 161 | 159 |
| 162 static int Count() { return count_; } | 160 static int Count() { return count_; } |
| 163 static void ResetIds() { current_id_ = 0; } | 161 static void ResetIds() { current_id_ = 0; } |
| 164 unsigned id() const { return id_; } | 162 AstId id() const { return id_; } |
| 165 | 163 |
| 166 protected: | 164 protected: |
| 167 static unsigned GetNextId() { return current_id_++; } | 165 static AstId GetNextId() { return current_id_++; } |
| 168 static unsigned ReserveIdRange(int n) { | 166 static AstId ReserveIdRange(int n) { |
| 169 unsigned tmp = current_id_; | 167 AstId tmp = current_id_; |
| 170 current_id_ += n; | 168 current_id_ += n; |
| 171 return tmp; | 169 return tmp; |
| 172 } | 170 } |
| 173 | 171 |
| 174 private: | 172 private: |
| 175 static unsigned current_id_; | 173 static AstId current_id_; |
| 176 static unsigned count_; | 174 static AstId count_; |
| 177 unsigned id_; | 175 AstId id_; |
| 178 }; | 176 }; |
| 179 | 177 |
| 180 | 178 |
| 181 class Statement: public AstNode { | 179 class Statement: public AstNode { |
| 182 public: | 180 public: |
| 183 Statement() : statement_pos_(RelocInfo::kNoPosition) {} | 181 Statement() : statement_pos_(RelocInfo::kNoPosition) {} |
| 184 | 182 |
| 185 virtual Statement* AsStatement() { return this; } | 183 virtual Statement* AsStatement() { return this; } |
| 186 | 184 |
| 187 virtual Assignment* StatementAsSimpleAssignment() { return NULL; } | 185 virtual Assignment* StatementAsSimpleAssignment() { return NULL; } |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 429 |
| 432 class IterationStatement: public BreakableStatement { | 430 class IterationStatement: public BreakableStatement { |
| 433 public: | 431 public: |
| 434 // Type testing & conversion. | 432 // Type testing & conversion. |
| 435 virtual IterationStatement* AsIterationStatement() { return this; } | 433 virtual IterationStatement* AsIterationStatement() { return this; } |
| 436 | 434 |
| 437 Statement* body() const { return body_; } | 435 Statement* body() const { return body_; } |
| 438 void set_body(Statement* stmt) { body_ = stmt; } | 436 void set_body(Statement* stmt) { body_ = stmt; } |
| 439 | 437 |
| 440 // Bailout support. | 438 // Bailout support. |
| 441 int OsrEntryId() const { return osr_entry_id_; } | 439 AstId OsrEntryId() const { return osr_entry_id_; } |
| 442 virtual int ContinueId() const = 0; | 440 virtual int ContinueId() const = 0; |
| 443 | 441 |
| 444 // Code generation | 442 // Code generation |
| 445 BreakTarget* continue_target() { return &continue_target_; } | 443 BreakTarget* continue_target() { return &continue_target_; } |
| 446 | 444 |
| 447 protected: | 445 protected: |
| 448 explicit inline IterationStatement(ZoneStringList* labels); | 446 explicit inline IterationStatement(ZoneStringList* labels); |
| 449 | 447 |
| 450 void Initialize(Statement* body) { | 448 void Initialize(Statement* body) { |
| 451 body_ = body; | 449 body_ = body; |
| 452 } | 450 } |
| 453 | 451 |
| 454 private: | 452 private: |
| 455 Statement* body_; | 453 Statement* body_; |
| 456 BreakTarget continue_target_; | 454 BreakTarget continue_target_; |
| 457 int osr_entry_id_; | 455 AstId osr_entry_id_; |
| 458 }; | 456 }; |
| 459 | 457 |
| 460 | 458 |
| 461 class DoWhileStatement: public IterationStatement { | 459 class DoWhileStatement: public IterationStatement { |
| 462 public: | 460 public: |
| 463 explicit inline DoWhileStatement(ZoneStringList* labels); | 461 explicit inline DoWhileStatement(ZoneStringList* labels); |
| 464 | 462 |
| 465 DECLARE_NODE_TYPE(DoWhileStatement) | 463 DECLARE_NODE_TYPE(DoWhileStatement) |
| 466 | 464 |
| 467 void Initialize(Expression* cond, Statement* body) { | 465 void Initialize(Expression* cond, Statement* body) { |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1578 | 1576 |
| 1579 // Type feedback information. | 1577 // Type feedback information. |
| 1580 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1578 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1581 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1579 virtual bool IsMonomorphic() { return is_monomorphic_; } |
| 1582 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } | 1580 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } |
| 1583 virtual Handle<Map> GetMonomorphicReceiverType() { | 1581 virtual Handle<Map> GetMonomorphicReceiverType() { |
| 1584 return monomorphic_receiver_type_; | 1582 return monomorphic_receiver_type_; |
| 1585 } | 1583 } |
| 1586 | 1584 |
| 1587 // Bailout support. | 1585 // Bailout support. |
| 1588 int compound_bailout_id() const { return compound_bailout_id_; } | 1586 AstId compound_bailout_id() const { return compound_bailout_id_; } |
| 1589 | 1587 |
| 1590 private: | 1588 private: |
| 1591 Token::Value op_; | 1589 Token::Value op_; |
| 1592 Expression* target_; | 1590 Expression* target_; |
| 1593 Expression* value_; | 1591 Expression* value_; |
| 1594 int pos_; | 1592 int pos_; |
| 1595 BinaryOperation* binary_operation_; | 1593 BinaryOperation* binary_operation_; |
| 1596 int compound_bailout_id_; | 1594 AstId compound_bailout_id_; |
| 1597 | 1595 |
| 1598 bool block_start_; | 1596 bool block_start_; |
| 1599 bool block_end_; | 1597 bool block_end_; |
| 1600 | 1598 |
| 1601 bool is_monomorphic_; | 1599 bool is_monomorphic_; |
| 1602 ZoneMapList* receiver_types_; | 1600 ZoneMapList* receiver_types_; |
| 1603 Handle<Map> monomorphic_receiver_type_; | 1601 Handle<Map> monomorphic_receiver_type_; |
| 1604 }; | 1602 }; |
| 1605 | 1603 |
| 1606 | 1604 |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2125 AST_NODE_LIST(DEF_VISIT) | 2123 AST_NODE_LIST(DEF_VISIT) |
| 2126 #undef DEF_VISIT | 2124 #undef DEF_VISIT |
| 2127 | 2125 |
| 2128 private: | 2126 private: |
| 2129 bool stack_overflow_; | 2127 bool stack_overflow_; |
| 2130 }; | 2128 }; |
| 2131 | 2129 |
| 2132 } } // namespace v8::internal | 2130 } } // namespace v8::internal |
| 2133 | 2131 |
| 2134 #endif // V8_AST_H_ | 2132 #endif // V8_AST_H_ |
| OLD | NEW |