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

Side by Side Diff: src/conversions.h

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/contexts.cc ('k') | src/conversions.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 #ifndef V8_CONVERSIONS_H_ 5 #ifndef V8_CONVERSIONS_H_
6 #define V8_CONVERSIONS_H_ 6 #define V8_CONVERSIONS_H_
7 7
8 #include <limits> 8 #include <limits>
9 9
10 #include "src/base/logging.h" 10 #include "src/base/logging.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 String* string, 192 String* string,
193 int flags, 193 int flags,
194 double empty_string_val = 0.0); 194 double empty_string_val = 0.0);
195 195
196 196
197 inline bool TryNumberToSize(Isolate* isolate, 197 inline bool TryNumberToSize(Isolate* isolate,
198 Object* number, size_t* result) { 198 Object* number, size_t* result) {
199 SealHandleScope shs(isolate); 199 SealHandleScope shs(isolate);
200 if (number->IsSmi()) { 200 if (number->IsSmi()) {
201 int value = Smi::cast(number)->value(); 201 int value = Smi::cast(number)->value();
202 ASSERT(static_cast<unsigned>(Smi::kMaxValue) 202 DCHECK(static_cast<unsigned>(Smi::kMaxValue)
203 <= std::numeric_limits<size_t>::max()); 203 <= std::numeric_limits<size_t>::max());
204 if (value >= 0) { 204 if (value >= 0) {
205 *result = static_cast<size_t>(value); 205 *result = static_cast<size_t>(value);
206 return true; 206 return true;
207 } 207 }
208 return false; 208 return false;
209 } else { 209 } else {
210 ASSERT(number->IsHeapNumber()); 210 DCHECK(number->IsHeapNumber());
211 double value = HeapNumber::cast(number)->value(); 211 double value = HeapNumber::cast(number)->value();
212 if (value >= 0 && 212 if (value >= 0 &&
213 value <= std::numeric_limits<size_t>::max()) { 213 value <= std::numeric_limits<size_t>::max()) {
214 *result = static_cast<size_t>(value); 214 *result = static_cast<size_t>(value);
215 return true; 215 return true;
216 } else { 216 } else {
217 return false; 217 return false;
218 } 218 }
219 } 219 }
220 } 220 }
221 221
222 // Converts a number into size_t. 222 // Converts a number into size_t.
223 inline size_t NumberToSize(Isolate* isolate, 223 inline size_t NumberToSize(Isolate* isolate,
224 Object* number) { 224 Object* number) {
225 size_t result = 0; 225 size_t result = 0;
226 bool is_valid = TryNumberToSize(isolate, number, &result); 226 bool is_valid = TryNumberToSize(isolate, number, &result);
227 CHECK(is_valid); 227 CHECK(is_valid);
228 return result; 228 return result;
229 } 229 }
230 230
231 } } // namespace v8::internal 231 } } // namespace v8::internal
232 232
233 #endif // V8_CONVERSIONS_H_ 233 #endif // V8_CONVERSIONS_H_
OLDNEW
« no previous file with comments | « src/contexts.cc ('k') | src/conversions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698