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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 class LoopStatement: public IterationStatement { | 289 class LoopStatement: public IterationStatement { |
290 public: | 290 public: |
291 enum Type { DO_LOOP, FOR_LOOP, WHILE_LOOP }; | 291 enum Type { DO_LOOP, FOR_LOOP, WHILE_LOOP }; |
292 | 292 |
293 LoopStatement(ZoneStringList* labels, Type type) | 293 LoopStatement(ZoneStringList* labels, Type type) |
294 : IterationStatement(labels), | 294 : IterationStatement(labels), |
295 type_(type), | 295 type_(type), |
296 init_(NULL), | 296 init_(NULL), |
297 cond_(NULL), | 297 cond_(NULL), |
298 next_(NULL), | 298 next_(NULL), |
299 has_function_literal_(false) { | 299 may_have_function_literal_(true) { |
300 } | 300 } |
301 | 301 |
302 void Initialize(Statement* init, | 302 void Initialize(Statement* init, |
303 Expression* cond, | 303 Expression* cond, |
304 Statement* next, | 304 Statement* next, |
305 Statement* body) { | 305 Statement* body) { |
306 ASSERT(init == NULL || type_ == FOR_LOOP); | 306 ASSERT(init == NULL || type_ == FOR_LOOP); |
307 ASSERT(next == NULL || type_ == FOR_LOOP); | 307 ASSERT(next == NULL || type_ == FOR_LOOP); |
308 IterationStatement::Initialize(body); | 308 IterationStatement::Initialize(body); |
309 init_ = init; | 309 init_ = init; |
310 cond_ = cond; | 310 cond_ = cond; |
311 next_ = next; | 311 next_ = next; |
312 } | 312 } |
313 | 313 |
314 virtual void Accept(AstVisitor* v); | 314 virtual void Accept(AstVisitor* v); |
315 | 315 |
316 Type type() const { return type_; } | 316 Type type() const { return type_; } |
317 Statement* init() const { return init_; } | 317 Statement* init() const { return init_; } |
318 Expression* cond() const { return cond_; } | 318 Expression* cond() const { return cond_; } |
319 Statement* next() const { return next_; } | 319 Statement* next() const { return next_; } |
320 bool has_function_literal() const { return has_function_literal_; } | 320 bool may_have_function_literal() const { |
| 321 return may_have_function_literal_; |
| 322 } |
321 | 323 |
322 #ifdef DEBUG | 324 #ifdef DEBUG |
323 const char* OperatorString() const; | 325 const char* OperatorString() const; |
324 #endif | 326 #endif |
325 | 327 |
326 private: | 328 private: |
327 Type type_; | 329 Type type_; |
328 Statement* init_; | 330 Statement* init_; |
329 Expression* cond_; | 331 Expression* cond_; |
330 Statement* next_; | 332 Statement* next_; |
331 // True if there is a function literal subexpression in the condition. | 333 // True if there is a function literal subexpression in the condition. |
332 bool has_function_literal_; | 334 bool may_have_function_literal_; |
333 | 335 |
334 friend class AstOptimizer; | 336 friend class AstOptimizer; |
335 }; | 337 }; |
336 | 338 |
337 | 339 |
338 class ForInStatement: public IterationStatement { | 340 class ForInStatement: public IterationStatement { |
339 public: | 341 public: |
340 explicit ForInStatement(ZoneStringList* labels) | 342 explicit ForInStatement(ZoneStringList* labels) |
341 : IterationStatement(labels), each_(NULL), enumerable_(NULL) { } | 343 : IterationStatement(labels), each_(NULL), enumerable_(NULL) { } |
342 | 344 |
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1692 #undef DEF_VISIT | 1694 #undef DEF_VISIT |
1693 | 1695 |
1694 private: | 1696 private: |
1695 bool stack_overflow_; | 1697 bool stack_overflow_; |
1696 }; | 1698 }; |
1697 | 1699 |
1698 | 1700 |
1699 } } // namespace v8::internal | 1701 } } // namespace v8::internal |
1700 | 1702 |
1701 #endif // V8_AST_H_ | 1703 #endif // V8_AST_H_ |
OLD | NEW |