| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 V(ThisFunction) | 95 V(ThisFunction) |
| 96 | 96 |
| 97 #define AST_NODE_LIST(V) \ | 97 #define AST_NODE_LIST(V) \ |
| 98 V(Declaration) \ | 98 V(Declaration) \ |
| 99 STATEMENT_NODE_LIST(V) \ | 99 STATEMENT_NODE_LIST(V) \ |
| 100 EXPRESSION_NODE_LIST(V) | 100 EXPRESSION_NODE_LIST(V) |
| 101 | 101 |
| 102 // Forward declarations | 102 // Forward declarations |
| 103 class TargetCollector; | 103 class TargetCollector; |
| 104 class MaterializedLiteral; | 104 class MaterializedLiteral; |
| 105 class DefinitionInfo; |
| 105 | 106 |
| 106 #define DEF_FORWARD_DECLARATION(type) class type; | 107 #define DEF_FORWARD_DECLARATION(type) class type; |
| 107 AST_NODE_LIST(DEF_FORWARD_DECLARATION) | 108 AST_NODE_LIST(DEF_FORWARD_DECLARATION) |
| 108 #undef DEF_FORWARD_DECLARATION | 109 #undef DEF_FORWARD_DECLARATION |
| 109 | 110 |
| 110 | 111 |
| 111 // Typedef only introduced to avoid unreadable code. | 112 // Typedef only introduced to avoid unreadable code. |
| 112 // Please do appreciate the required space in "> >". | 113 // Please do appreciate the required space in "> >". |
| 113 typedef ZoneList<Handle<String> > ZoneStringList; | 114 typedef ZoneList<Handle<String> > ZoneStringList; |
| 114 typedef ZoneList<Handle<Object> > ZoneObjectList; | 115 typedef ZoneList<Handle<Object> > ZoneObjectList; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // Evaluated for control flow and side effects. Value is also | 176 // Evaluated for control flow and side effects. Value is also |
| 176 // needed if true. | 177 // needed if true. |
| 177 kValueTest, | 178 kValueTest, |
| 178 // Evaluated for control flow and side effects. Value is also | 179 // Evaluated for control flow and side effects. Value is also |
| 179 // needed if false. | 180 // needed if false. |
| 180 kTestValue | 181 kTestValue |
| 181 }; | 182 }; |
| 182 | 183 |
| 183 static const int kNoLabel = -1; | 184 static const int kNoLabel = -1; |
| 184 | 185 |
| 185 Expression() : num_(kNoLabel) {} | 186 Expression() : num_(kNoLabel), def_(NULL), defined_vars_(NULL) {} |
| 186 | 187 |
| 187 virtual Expression* AsExpression() { return this; } | 188 virtual Expression* AsExpression() { return this; } |
| 188 | 189 |
| 189 virtual bool IsValidLeftHandSide() { return false; } | 190 virtual bool IsValidLeftHandSide() { return false; } |
| 190 | 191 |
| 191 // Symbols that cannot be parsed as array indices are considered property | 192 // Symbols that cannot be parsed as array indices are considered property |
| 192 // names. We do not treat symbols that can be array indexes as property | 193 // names. We do not treat symbols that can be array indexes as property |
| 193 // names because [] for string objects is handled only by keyed ICs. | 194 // names because [] for string objects is handled only by keyed ICs. |
| 194 virtual bool IsPropertyName() { return false; } | 195 virtual bool IsPropertyName() { return false; } |
| 195 | 196 |
| 196 // True if the expression does not have (evaluated) subexpressions. | 197 // True if the expression does not have (evaluated) subexpressions. |
| 197 // Function literals are leaves because their subexpressions are not | 198 // Function literals are leaves because their subexpressions are not |
| 198 // evaluated. | 199 // evaluated. |
| 199 virtual bool IsLeaf() { return false; } | 200 virtual bool IsLeaf() { return false; } |
| 200 | 201 |
| 201 // Mark the expression as being compiled as an expression | 202 // Mark the expression as being compiled as an expression |
| 202 // statement. This is used to transform postfix increments to | 203 // statement. This is used to transform postfix increments to |
| 203 // (faster) prefix increments. | 204 // (faster) prefix increments. |
| 204 virtual void MarkAsStatement() { /* do nothing */ } | 205 virtual void MarkAsStatement() { /* do nothing */ } |
| 205 | 206 |
| 206 // Static type information for this expression. | 207 // Static type information for this expression. |
| 207 StaticType* type() { return &type_; } | 208 StaticType* type() { return &type_; } |
| 208 | 209 |
| 209 int num() { return num_; } | 210 int num() { return num_; } |
| 210 | 211 |
| 211 // AST node numbering ordered by evaluation order. | 212 // AST node numbering ordered by evaluation order. |
| 212 void set_num(int n) { num_ = n; } | 213 void set_num(int n) { num_ = n; } |
| 213 | 214 |
| 215 // Data flow information. |
| 216 DefinitionInfo* var_def() { return def_; } |
| 217 void set_var_def(DefinitionInfo* def) { def_ = def; } |
| 218 |
| 219 ZoneList<DefinitionInfo*>* defined_vars() { return defined_vars_; } |
| 220 void set_defined_vars(ZoneList<DefinitionInfo*>* defined_vars) { |
| 221 defined_vars_ = defined_vars; |
| 222 } |
| 223 |
| 214 private: | 224 private: |
| 215 StaticType type_; | 225 StaticType type_; |
| 216 int num_; | 226 int num_; |
| 227 DefinitionInfo* def_; |
| 228 ZoneList<DefinitionInfo*>* defined_vars_; |
| 217 }; | 229 }; |
| 218 | 230 |
| 219 | 231 |
| 220 /** | 232 /** |
| 221 * A sentinel used during pre parsing that represents some expression | 233 * A sentinel used during pre parsing that represents some expression |
| 222 * that is a valid left hand side without having to actually build | 234 * that is a valid left hand side without having to actually build |
| 223 * the expression. | 235 * the expression. |
| 224 */ | 236 */ |
| 225 class ValidLeftHandSideSentinel: public Expression { | 237 class ValidLeftHandSideSentinel: public Expression { |
| 226 public: | 238 public: |
| (...skipping 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1828 #undef DEF_VISIT | 1840 #undef DEF_VISIT |
| 1829 | 1841 |
| 1830 private: | 1842 private: |
| 1831 bool stack_overflow_; | 1843 bool stack_overflow_; |
| 1832 }; | 1844 }; |
| 1833 | 1845 |
| 1834 | 1846 |
| 1835 } } // namespace v8::internal | 1847 } } // namespace v8::internal |
| 1836 | 1848 |
| 1837 #endif // V8_AST_H_ | 1849 #endif // V8_AST_H_ |
| OLD | NEW |