| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 | 110 |
| 111 // Typedef only introduced to avoid unreadable code. | 111 // Typedef only introduced to avoid unreadable code. |
| 112 // Please do appreciate the required space in "> >". | 112 // Please do appreciate the required space in "> >". |
| 113 typedef ZoneList<Handle<String> > ZoneStringList; | 113 typedef ZoneList<Handle<String> > ZoneStringList; |
| 114 typedef ZoneList<Handle<Object> > ZoneObjectList; | 114 typedef ZoneList<Handle<Object> > ZoneObjectList; |
| 115 | 115 |
| 116 | 116 |
| 117 class AstNode: public ZoneObject { | 117 class AstNode: public ZoneObject { |
| 118 public: | 118 public: |
| 119 AstNode(): statement_pos_(RelocInfo::kNoPosition) { } | |
| 120 virtual ~AstNode() { } | 119 virtual ~AstNode() { } |
| 121 virtual void Accept(AstVisitor* v) = 0; | 120 virtual void Accept(AstVisitor* v) = 0; |
| 122 | 121 |
| 123 // Type testing & conversion. | 122 // Type testing & conversion. |
| 124 virtual Statement* AsStatement() { return NULL; } | 123 virtual Statement* AsStatement() { return NULL; } |
| 125 virtual ExpressionStatement* AsExpressionStatement() { return NULL; } | 124 virtual ExpressionStatement* AsExpressionStatement() { return NULL; } |
| 126 virtual EmptyStatement* AsEmptyStatement() { return NULL; } | 125 virtual EmptyStatement* AsEmptyStatement() { return NULL; } |
| 127 virtual Expression* AsExpression() { return NULL; } | 126 virtual Expression* AsExpression() { return NULL; } |
| 128 virtual Literal* AsLiteral() { return NULL; } | 127 virtual Literal* AsLiteral() { return NULL; } |
| 129 virtual Slot* AsSlot() { return NULL; } | 128 virtual Slot* AsSlot() { return NULL; } |
| 130 virtual VariableProxy* AsVariableProxy() { return NULL; } | 129 virtual VariableProxy* AsVariableProxy() { return NULL; } |
| 131 virtual Property* AsProperty() { return NULL; } | 130 virtual Property* AsProperty() { return NULL; } |
| 132 virtual Call* AsCall() { return NULL; } | 131 virtual Call* AsCall() { return NULL; } |
| 133 virtual TargetCollector* AsTargetCollector() { return NULL; } | 132 virtual TargetCollector* AsTargetCollector() { return NULL; } |
| 134 virtual BreakableStatement* AsBreakableStatement() { return NULL; } | 133 virtual BreakableStatement* AsBreakableStatement() { return NULL; } |
| 135 virtual IterationStatement* AsIterationStatement() { return NULL; } | 134 virtual IterationStatement* AsIterationStatement() { return NULL; } |
| 136 virtual UnaryOperation* AsUnaryOperation() { return NULL; } | 135 virtual UnaryOperation* AsUnaryOperation() { return NULL; } |
| 137 virtual BinaryOperation* AsBinaryOperation() { return NULL; } | 136 virtual BinaryOperation* AsBinaryOperation() { return NULL; } |
| 138 virtual Assignment* AsAssignment() { return NULL; } | 137 virtual Assignment* AsAssignment() { return NULL; } |
| 139 virtual FunctionLiteral* AsFunctionLiteral() { return NULL; } | 138 virtual FunctionLiteral* AsFunctionLiteral() { return NULL; } |
| 140 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } | 139 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } |
| 141 virtual ObjectLiteral* AsObjectLiteral() { return NULL; } | 140 virtual ObjectLiteral* AsObjectLiteral() { return NULL; } |
| 142 virtual ArrayLiteral* AsArrayLiteral() { return NULL; } | 141 virtual ArrayLiteral* AsArrayLiteral() { return NULL; } |
| 142 }; |
| 143 |
| 144 |
| 145 class Statement: public AstNode { |
| 146 public: |
| 147 Statement() : statement_pos_(RelocInfo::kNoPosition) {} |
| 148 |
| 149 virtual Statement* AsStatement() { return this; } |
| 150 virtual ReturnStatement* AsReturnStatement() { return NULL; } |
| 151 |
| 152 bool IsEmpty() { return AsEmptyStatement() != NULL; } |
| 143 | 153 |
| 144 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } | 154 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } |
| 145 int statement_pos() const { return statement_pos_; } | 155 int statement_pos() const { return statement_pos_; } |
| 146 | 156 |
| 147 private: | 157 private: |
| 148 int statement_pos_; | 158 int statement_pos_; |
| 149 }; | 159 }; |
| 150 | 160 |
| 151 | 161 |
| 152 class Statement: public AstNode { | |
| 153 public: | |
| 154 virtual Statement* AsStatement() { return this; } | |
| 155 virtual ReturnStatement* AsReturnStatement() { return NULL; } | |
| 156 | |
| 157 bool IsEmpty() { return AsEmptyStatement() != NULL; } | |
| 158 }; | |
| 159 | |
| 160 | |
| 161 class Expression: public AstNode { | 162 class Expression: public AstNode { |
| 162 public: | 163 public: |
| 163 virtual Expression* AsExpression() { return this; } | 164 virtual Expression* AsExpression() { return this; } |
| 164 | 165 |
| 165 virtual bool IsValidJSON() { return false; } | 166 virtual bool IsValidJSON() { return false; } |
| 166 virtual bool IsValidLeftHandSide() { return false; } | 167 virtual bool IsValidLeftHandSide() { return false; } |
| 167 | 168 |
| 168 // Mark the expression as being compiled as an expression | 169 // Mark the expression as being compiled as an expression |
| 169 // statement. This is used to transform postfix increments to | 170 // statement. This is used to transform postfix increments to |
| 170 // (faster) prefix increments. | 171 // (faster) prefix increments. |
| (...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 #undef DEF_VISIT | 1729 #undef DEF_VISIT |
| 1729 | 1730 |
| 1730 private: | 1731 private: |
| 1731 bool stack_overflow_; | 1732 bool stack_overflow_; |
| 1732 }; | 1733 }; |
| 1733 | 1734 |
| 1734 | 1735 |
| 1735 } } // namespace v8::internal | 1736 } } // namespace v8::internal |
| 1736 | 1737 |
| 1737 #endif // V8_AST_H_ | 1738 #endif // V8_AST_H_ |
| OLD | NEW |