| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // allocated. | 193 // allocated. |
| 194 // Elements must not be NULL pointers. | 194 // Elements must not be NULL pointers. |
| 195 template <typename T, int initial_size> | 195 template <typename T, int initial_size> |
| 196 class BufferedZoneList { | 196 class BufferedZoneList { |
| 197 public: | 197 public: |
| 198 BufferedZoneList() : list_(NULL), last_(NULL) {} | 198 BufferedZoneList() : list_(NULL), last_(NULL) {} |
| 199 | 199 |
| 200 // Adds element at end of list. This element is buffered and can | 200 // Adds element at end of list. This element is buffered and can |
| 201 // be read using last() or removed using RemoveLast until a new Add or until | 201 // be read using last() or removed using RemoveLast until a new Add or until |
| 202 // RemoveLast or GetList has been called. | 202 // RemoveLast or GetList has been called. |
| 203 void Add(T* value) { | 203 void Add(T* value, Zone* zone) { |
| 204 if (last_ != NULL) { | 204 if (last_ != NULL) { |
| 205 if (list_ == NULL) { | 205 if (list_ == NULL) { |
| 206 list_ = new ZoneList<T*>(initial_size); | 206 list_ = new(zone) ZoneList<T*>(initial_size, zone); |
| 207 } | 207 } |
| 208 list_->Add(last_); | 208 list_->Add(last_, zone); |
| 209 } | 209 } |
| 210 last_ = value; | 210 last_ = value; |
| 211 } | 211 } |
| 212 | 212 |
| 213 T* last() { | 213 T* last() { |
| 214 ASSERT(last_ != NULL); | 214 ASSERT(last_ != NULL); |
| 215 return last_; | 215 return last_; |
| 216 } | 216 } |
| 217 | 217 |
| 218 T* RemoveLast() { | 218 T* RemoveLast() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 243 void Clear() { | 243 void Clear() { |
| 244 list_ = NULL; | 244 list_ = NULL; |
| 245 last_ = NULL; | 245 last_ = NULL; |
| 246 } | 246 } |
| 247 | 247 |
| 248 int length() { | 248 int length() { |
| 249 int length = (list_ == NULL) ? 0 : list_->length(); | 249 int length = (list_ == NULL) ? 0 : list_->length(); |
| 250 return length + ((last_ == NULL) ? 0 : 1); | 250 return length + ((last_ == NULL) ? 0 : 1); |
| 251 } | 251 } |
| 252 | 252 |
| 253 ZoneList<T*>* GetList() { | 253 ZoneList<T*>* GetList(Zone* zone) { |
| 254 if (list_ == NULL) { | 254 if (list_ == NULL) { |
| 255 list_ = new ZoneList<T*>(initial_size); | 255 list_ = new(zone) ZoneList<T*>(initial_size, zone); |
| 256 } | 256 } |
| 257 if (last_ != NULL) { | 257 if (last_ != NULL) { |
| 258 list_->Add(last_); | 258 list_->Add(last_, zone); |
| 259 last_ = NULL; | 259 last_ = NULL; |
| 260 } | 260 } |
| 261 return list_; | 261 return list_; |
| 262 } | 262 } |
| 263 | 263 |
| 264 private: | 264 private: |
| 265 ZoneList<T*>* list_; | 265 ZoneList<T*>* list_; |
| 266 T* last_; | 266 T* last_; |
| 267 }; | 267 }; |
| 268 | 268 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 GROUPING | 364 GROUPING |
| 365 }; | 365 }; |
| 366 | 366 |
| 367 class RegExpParserState : public ZoneObject { | 367 class RegExpParserState : public ZoneObject { |
| 368 public: | 368 public: |
| 369 RegExpParserState(RegExpParserState* previous_state, | 369 RegExpParserState(RegExpParserState* previous_state, |
| 370 SubexpressionType group_type, | 370 SubexpressionType group_type, |
| 371 int disjunction_capture_index, | 371 int disjunction_capture_index, |
| 372 Zone* zone) | 372 Zone* zone) |
| 373 : previous_state_(previous_state), | 373 : previous_state_(previous_state), |
| 374 builder_(new RegExpBuilder(zone)), | 374 builder_(new(zone) RegExpBuilder(zone)), |
| 375 group_type_(group_type), | 375 group_type_(group_type), |
| 376 disjunction_capture_index_(disjunction_capture_index) {} | 376 disjunction_capture_index_(disjunction_capture_index) {} |
| 377 // Parser state of containing expression, if any. | 377 // Parser state of containing expression, if any. |
| 378 RegExpParserState* previous_state() { return previous_state_; } | 378 RegExpParserState* previous_state() { return previous_state_; } |
| 379 bool IsSubexpression() { return previous_state_ != NULL; } | 379 bool IsSubexpression() { return previous_state_ != NULL; } |
| 380 // RegExpBuilder building this regexp's AST. | 380 // RegExpBuilder building this regexp's AST. |
| 381 RegExpBuilder* builder() { return builder_; } | 381 RegExpBuilder* builder() { return builder_; } |
| 382 // Type of regexp being parsed (parenthesized group or entire regexp). | 382 // Type of regexp being parsed (parenthesized group or entire regexp). |
| 383 SubexpressionType group_type() { return group_type_; } | 383 SubexpressionType group_type() { return group_type_; } |
| 384 // Index in captures array of first capture in this sub-expression, if any. | 384 // Index in captures array of first capture in this sub-expression, if any. |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 private: | 868 private: |
| 869 static const int kTypeSlot = 0; | 869 static const int kTypeSlot = 0; |
| 870 static const int kElementsSlot = 1; | 870 static const int kElementsSlot = 1; |
| 871 | 871 |
| 872 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); | 872 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); |
| 873 }; | 873 }; |
| 874 | 874 |
| 875 } } // namespace v8::internal | 875 } } // namespace v8::internal |
| 876 | 876 |
| 877 #endif // V8_PARSER_H_ | 877 #endif // V8_PARSER_H_ |
| OLD | NEW |