| 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // Evaluated for control flow (and side effects). | 189 // Evaluated for control flow (and side effects). |
| 190 kTest, | 190 kTest, |
| 191 // Evaluated for control flow and side effects. Value is also | 191 // Evaluated for control flow and side effects. Value is also |
| 192 // needed if true. | 192 // needed if true. |
| 193 kValueTest, | 193 kValueTest, |
| 194 // Evaluated for control flow and side effects. Value is also | 194 // Evaluated for control flow and side effects. Value is also |
| 195 // needed if false. | 195 // needed if false. |
| 196 kTestValue | 196 kTestValue |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 Expression() | 199 Expression() : bitfields_(0) {} |
| 200 : bitfields_(0), | |
| 201 def_(NULL), | |
| 202 defined_vars_(NULL) {} | |
| 203 | 200 |
| 204 virtual Expression* AsExpression() { return this; } | 201 virtual Expression* AsExpression() { return this; } |
| 205 | 202 |
| 206 virtual bool IsValidLeftHandSide() { return false; } | 203 virtual bool IsValidLeftHandSide() { return false; } |
| 207 | 204 |
| 208 virtual Variable* AssignedVar() { return NULL; } | 205 virtual Variable* AssignedVar() { return NULL; } |
| 209 | 206 |
| 210 // Symbols that cannot be parsed as array indices are considered property | 207 // Symbols that cannot be parsed as array indices are considered property |
| 211 // names. We do not treat symbols that can be array indexes as property | 208 // names. We do not treat symbols that can be array indexes as property |
| 212 // names because [] for string objects is handled only by keyed ICs. | 209 // names because [] for string objects is handled only by keyed ICs. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 226 virtual bool IsPrimitive() = 0; | 223 virtual bool IsPrimitive() = 0; |
| 227 | 224 |
| 228 // Mark the expression as being compiled as an expression | 225 // Mark the expression as being compiled as an expression |
| 229 // statement. This is used to transform postfix increments to | 226 // statement. This is used to transform postfix increments to |
| 230 // (faster) prefix increments. | 227 // (faster) prefix increments. |
| 231 virtual void MarkAsStatement() { /* do nothing */ } | 228 virtual void MarkAsStatement() { /* do nothing */ } |
| 232 | 229 |
| 233 // Static type information for this expression. | 230 // Static type information for this expression. |
| 234 StaticType* type() { return &type_; } | 231 StaticType* type() { return &type_; } |
| 235 | 232 |
| 236 // Data flow information. | |
| 237 DefinitionInfo* var_def() { return def_; } | |
| 238 void set_var_def(DefinitionInfo* def) { def_ = def; } | |
| 239 | |
| 240 ZoneList<DefinitionInfo*>* defined_vars() { return defined_vars_; } | |
| 241 void set_defined_vars(ZoneList<DefinitionInfo*>* defined_vars) { | |
| 242 defined_vars_ = defined_vars; | |
| 243 } | |
| 244 | |
| 245 // AST analysis results | 233 // AST analysis results |
| 246 | 234 |
| 247 // True if the expression rooted at this node can be compiled by the | 235 // True if the expression rooted at this node can be compiled by the |
| 248 // side-effect free compiler. | 236 // side-effect free compiler. |
| 249 bool side_effect_free() { return SideEffectFreeField::decode(bitfields_); } | 237 bool side_effect_free() { return SideEffectFreeField::decode(bitfields_); } |
| 250 void set_side_effect_free(bool is_side_effect_free) { | 238 void set_side_effect_free(bool is_side_effect_free) { |
| 251 bitfields_ &= ~SideEffectFreeField::mask(); | 239 bitfields_ &= ~SideEffectFreeField::mask(); |
| 252 bitfields_ |= SideEffectFreeField::encode(is_side_effect_free); | 240 bitfields_ |= SideEffectFreeField::encode(is_side_effect_free); |
| 253 } | 241 } |
| 254 | 242 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 277 bitfields_ |= NumBitOpsField::encode(num_bit_ops); | 265 bitfields_ |= NumBitOpsField::encode(num_bit_ops); |
| 278 } | 266 } |
| 279 | 267 |
| 280 | 268 |
| 281 private: | 269 private: |
| 282 static const int kMaxNumBitOps = (1 << 5) - 1; | 270 static const int kMaxNumBitOps = (1 << 5) - 1; |
| 283 | 271 |
| 284 uint32_t bitfields_; | 272 uint32_t bitfields_; |
| 285 StaticType type_; | 273 StaticType type_; |
| 286 | 274 |
| 287 DefinitionInfo* def_; | |
| 288 ZoneList<DefinitionInfo*>* defined_vars_; | |
| 289 | |
| 290 // Using template BitField<type, start, size>. | 275 // Using template BitField<type, start, size>. |
| 291 class SideEffectFreeField : public BitField<bool, 0, 1> {}; | 276 class SideEffectFreeField : public BitField<bool, 0, 1> {}; |
| 292 class NoNegativeZeroField : public BitField<bool, 1, 1> {}; | 277 class NoNegativeZeroField : public BitField<bool, 1, 1> {}; |
| 293 class ToInt32Field : public BitField<bool, 2, 1> {}; | 278 class ToInt32Field : public BitField<bool, 2, 1> {}; |
| 294 class NumBitOpsField : public BitField<int, 3, 5> {}; | 279 class NumBitOpsField : public BitField<int, 3, 5> {}; |
| 295 }; | 280 }; |
| 296 | 281 |
| 297 | 282 |
| 298 /** | 283 /** |
| 299 * A sentinel used during pre parsing that represents some expression | 284 * A sentinel used during pre parsing that represents some expression |
| (...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2004 #undef DEF_VISIT | 1989 #undef DEF_VISIT |
| 2005 | 1990 |
| 2006 private: | 1991 private: |
| 2007 bool stack_overflow_; | 1992 bool stack_overflow_; |
| 2008 }; | 1993 }; |
| 2009 | 1994 |
| 2010 | 1995 |
| 2011 } } // namespace v8::internal | 1996 } } // namespace v8::internal |
| 2012 | 1997 |
| 2013 #endif // V8_AST_H_ | 1998 #endif // V8_AST_H_ |
| OLD | NEW |