 Chromium Code Reviews
 Chromium Code Reviews Issue 14422:
  Introduced a TempAssign utility because I just couldn't watch this anymore. Y...  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
    
  
    Issue 14422:
  Introduced a TempAssign utility because I just couldn't watch this anymore. Y...  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/| 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 | 365 | 
| 366 // Factory method for creating empty vectors. | 366 // Factory method for creating empty vectors. | 
| 367 static Vector<T> empty() { return Vector<T>(NULL, 0); } | 367 static Vector<T> empty() { return Vector<T>(NULL, 0); } | 
| 368 | 368 | 
| 369 private: | 369 private: | 
| 370 T* start_; | 370 T* start_; | 
| 371 int length_; | 371 int length_; | 
| 372 }; | 372 }; | 
| 373 | 373 | 
| 374 | 374 | 
| 375 // A temporary assignment sets a (non-local) variable to a value on | |
| 376 // construction and resets it the value on destruction. | |
| 
Mads Ager (chromium)
2008/12/15 08:36:30
it the -> the
 | |
| 377 template <typename T> | |
| 378 class TempAssign { | |
| 379 public: | |
| 380 TempAssign(T* var, T value): var_(var), old_value_(*var) { | |
| 381 *var = value; | |
| 382 } | |
| 383 | |
| 384 ~TempAssign() { *var_ = old_value_; } | |
| 385 | |
| 386 private: | |
| 387 T* var_; | |
| 388 T old_value_; | |
| 389 }; | |
| 390 | |
| 391 | |
| 375 template <typename T, int kSize> | 392 template <typename T, int kSize> | 
| 376 class EmbeddedVector : public Vector<T> { | 393 class EmbeddedVector : public Vector<T> { | 
| 377 public: | 394 public: | 
| 378 EmbeddedVector() : Vector<T>(buffer_, kSize) { } | 395 EmbeddedVector() : Vector<T>(buffer_, kSize) { } | 
| 379 private: | 396 private: | 
| 380 T buffer_[kSize]; | 397 T buffer_[kSize]; | 
| 381 }; | 398 }; | 
| 382 | 399 | 
| 383 | 400 | 
| 384 inline Vector<const char> CStrVector(const char* data) { | 401 inline Vector<const char> CStrVector(const char* data) { | 
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 ptr[2] = value >> 8; | 572 ptr[2] = value >> 8; | 
| 556 ptr[1] = value >> 16; | 573 ptr[1] = value >> 16; | 
| 557 ptr[0] = value >> 24; | 574 ptr[0] = value >> 24; | 
| 558 #endif | 575 #endif | 
| 559 } | 576 } | 
| 560 | 577 | 
| 561 | 578 | 
| 562 } } // namespace v8::internal | 579 } } // namespace v8::internal | 
| 563 | 580 | 
| 564 #endif // V8_UTILS_H_ | 581 #endif // V8_UTILS_H_ | 
| OLD | NEW |