Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: src/utils.cc

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/utils.h ('k') | src/v8.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdarg.h> 5 #include <stdarg.h>
6 #include <sys/stat.h> 6 #include <sys/stat.h>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/base/logging.h" 10 #include "src/base/logging.h"
11 #include "src/base/platform/platform.h" 11 #include "src/base/platform/platform.h"
12 #include "src/utils.h" 12 #include "src/utils.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 16
17 17
18 SimpleStringBuilder::SimpleStringBuilder(int size) { 18 SimpleStringBuilder::SimpleStringBuilder(int size) {
19 buffer_ = Vector<char>::New(size); 19 buffer_ = Vector<char>::New(size);
20 position_ = 0; 20 position_ = 0;
21 } 21 }
22 22
23 23
24 void SimpleStringBuilder::AddString(const char* s) { 24 void SimpleStringBuilder::AddString(const char* s) {
25 AddSubstring(s, StrLength(s)); 25 AddSubstring(s, StrLength(s));
26 } 26 }
27 27
28 28
29 void SimpleStringBuilder::AddSubstring(const char* s, int n) { 29 void SimpleStringBuilder::AddSubstring(const char* s, int n) {
30 ASSERT(!is_finalized() && position_ + n <= buffer_.length()); 30 DCHECK(!is_finalized() && position_ + n <= buffer_.length());
31 ASSERT(static_cast<size_t>(n) <= strlen(s)); 31 DCHECK(static_cast<size_t>(n) <= strlen(s));
32 MemCopy(&buffer_[position_], s, n * kCharSize); 32 MemCopy(&buffer_[position_], s, n * kCharSize);
33 position_ += n; 33 position_ += n;
34 } 34 }
35 35
36 36
37 void SimpleStringBuilder::AddPadding(char c, int count) { 37 void SimpleStringBuilder::AddPadding(char c, int count) {
38 for (int i = 0; i < count; i++) { 38 for (int i = 0; i < count; i++) {
39 AddCharacter(c); 39 AddCharacter(c);
40 } 40 }
41 } 41 }
(...skipping 11 matching lines...) Expand all
53 } 53 }
54 position_ += digits; 54 position_ += digits;
55 for (int i = 1; i <= digits; i++) { 55 for (int i = 1; i <= digits; i++) {
56 buffer_[position_ - i] = '0' + static_cast<char>(number % 10); 56 buffer_[position_ - i] = '0' + static_cast<char>(number % 10);
57 number /= 10; 57 number /= 10;
58 } 58 }
59 } 59 }
60 60
61 61
62 char* SimpleStringBuilder::Finalize() { 62 char* SimpleStringBuilder::Finalize() {
63 ASSERT(!is_finalized() && position_ <= buffer_.length()); 63 DCHECK(!is_finalized() && position_ <= buffer_.length());
64 // If there is no space for null termination, overwrite last character. 64 // If there is no space for null termination, overwrite last character.
65 if (position_ == buffer_.length()) { 65 if (position_ == buffer_.length()) {
66 position_--; 66 position_--;
67 // Print ellipsis. 67 // Print ellipsis.
68 for (int i = 3; i > 0 && position_ > i; --i) buffer_[position_ - i] = '.'; 68 for (int i = 3; i > 0 && position_ > i; --i) buffer_[position_ - i] = '.';
69 } 69 }
70 buffer_[position_] = '\0'; 70 buffer_[position_] = '\0';
71 // Make sure nobody managed to add a 0-character to the 71 // Make sure nobody managed to add a 0-character to the
72 // buffer while building the string. 72 // buffer while building the string.
73 ASSERT(strlen(buffer_.start()) == static_cast<size_t>(position_)); 73 DCHECK(strlen(buffer_.start()) == static_cast<size_t>(position_));
74 position_ = -1; 74 position_ = -1;
75 ASSERT(is_finalized()); 75 DCHECK(is_finalized());
76 return buffer_.start(); 76 return buffer_.start();
77 } 77 }
78 78
79 79
80 void PrintF(const char* format, ...) { 80 void PrintF(const char* format, ...) {
81 va_list arguments; 81 va_list arguments;
82 va_start(arguments, format); 82 va_start(arguments, format);
83 base::OS::VPrint(format, arguments); 83 base::OS::VPrint(format, arguments);
84 va_end(arguments); 84 va_end(arguments);
85 } 85 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Copy the existing input into the new array and set the new 165 // Copy the existing input into the new array and set the new
166 // array as the result. 166 // array as the result.
167 MemCopy(new_result, result, offset * kCharSize); 167 MemCopy(new_result, result, offset * kCharSize);
168 DeleteArray(result); 168 DeleteArray(result);
169 result = new_result; 169 result = new_result;
170 } 170 }
171 // Copy the newly read line into the result. 171 // Copy the newly read line into the result.
172 MemCopy(result + offset, line_buf, len * kCharSize); 172 MemCopy(result + offset, line_buf, len * kCharSize);
173 offset += len; 173 offset += len;
174 } 174 }
175 ASSERT(result != NULL); 175 DCHECK(result != NULL);
176 result[offset] = '\0'; 176 result[offset] = '\0';
177 return result; 177 return result;
178 } 178 }
179 179
180 180
181 char* ReadCharsFromFile(FILE* file, 181 char* ReadCharsFromFile(FILE* file,
182 int* size, 182 int* size,
183 int extra_space, 183 int extra_space,
184 bool verbose, 184 bool verbose,
185 const char* filename) { 185 const char* filename) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 316
317 void StringBuilder::AddFormatted(const char* format, ...) { 317 void StringBuilder::AddFormatted(const char* format, ...) {
318 va_list arguments; 318 va_list arguments;
319 va_start(arguments, format); 319 va_start(arguments, format);
320 AddFormattedList(format, arguments); 320 AddFormattedList(format, arguments);
321 va_end(arguments); 321 va_end(arguments);
322 } 322 }
323 323
324 324
325 void StringBuilder::AddFormattedList(const char* format, va_list list) { 325 void StringBuilder::AddFormattedList(const char* format, va_list list) {
326 ASSERT(!is_finalized() && position_ <= buffer_.length()); 326 DCHECK(!is_finalized() && position_ <= buffer_.length());
327 int n = VSNPrintF(buffer_ + position_, format, list); 327 int n = VSNPrintF(buffer_ + position_, format, list);
328 if (n < 0 || n >= (buffer_.length() - position_)) { 328 if (n < 0 || n >= (buffer_.length() - position_)) {
329 position_ = buffer_.length(); 329 position_ = buffer_.length();
330 } else { 330 } else {
331 position_ += n; 331 position_ += n;
332 } 332 }
333 } 333 }
334 334
335 335
336 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 336 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 } 408 }
409 if (u.bits.exp == 0) { 409 if (u.bits.exp == 0) {
410 // Detect +0, and -0 for IEEE double precision floating point. 410 // Detect +0, and -0 for IEEE double precision floating point.
411 if ((u.bits.man_low | u.bits.man_high) == 0) return false; 411 if ((u.bits.man_low | u.bits.man_high) == 0) return false;
412 } 412 }
413 return true; 413 return true;
414 } 414 }
415 415
416 416
417 } } // namespace v8::internal 417 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/utils.h ('k') | src/v8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698