OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 | 177 |
178 template <typename T> | 178 template <typename T> |
179 class ScopedPointer { | 179 class ScopedPointer { |
180 public: | 180 public: |
181 explicit ScopedPointer() : pointer_(NULL) {} | 181 explicit ScopedPointer() : pointer_(NULL) {} |
182 explicit ScopedPointer(T* pointer) : pointer_(pointer) {} | 182 explicit ScopedPointer(T* pointer) : pointer_(pointer) {} |
183 ~ScopedPointer() { if (pointer_ != NULL) delete[] pointer_; } | 183 ~ScopedPointer() { if (pointer_ != NULL) delete[] pointer_; } |
184 T& operator[](int index) { return pointer_[index]; } | 184 T& operator[](int index) { return pointer_[index]; } |
185 T* operator*() { return pointer_ ;} | 185 T* operator*() { return pointer_ ;} |
186 T*& operator=(T* new_value) { | 186 T* operator=(T* new_value) { |
187 if (pointer_ != NULL) delete[] pointer_; | 187 if (pointer_ != NULL) delete[] pointer_; |
188 pointer_ = new_value; | 188 pointer_ = new_value; |
| 189 return new_value; |
189 } | 190 } |
190 private: | 191 private: |
191 T* pointer_; | 192 T* pointer_; |
192 }; | 193 }; |
193 | 194 |
194 | 195 |
195 | 196 |
196 void fail(v8::PreParserData* data, const char* message, ...) { | 197 void fail(v8::PreParserData* data, const char* message, ...) { |
197 va_list args; | 198 va_list args; |
198 va_start(args, message); | 199 va_start(args, message); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 if (data.stack_overflow()) { | 370 if (data.stack_overflow()) { |
370 fail(&data, "ERROR: Stack overflow\n"); | 371 fail(&data, "ERROR: Stack overflow\n"); |
371 } | 372 } |
372 | 373 |
373 // Check that the expected exception is thrown, if an exception is | 374 // Check that the expected exception is thrown, if an exception is |
374 // expected. | 375 // expected. |
375 CheckException(&data, &expects); | 376 CheckException(&data, &expects); |
376 | 377 |
377 return EXIT_SUCCESS; | 378 return EXIT_SUCCESS; |
378 } | 379 } |
OLD | NEW |