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

Side by Side Diff: runtime/lib/double.cc

Issue 10850034: Rename BadNumberFormatException -> FormatException. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 8 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 | « runtime/bin/http_utils.dart ('k') | runtime/lib/double.dart » ('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 (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <math.h> 5 #include <math.h>
6 6
7 #include "vm/bootstrap_natives.h" 7 #include "vm/bootstrap_natives.h"
8 8
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/double_conversion.h" 10 #include "vm/double_conversion.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // MAC OSX math library produces old style cast warning. 164 // MAC OSX math library produces old style cast warning.
165 #pragma GCC diagnostic ignored "-Wold-style-cast" 165 #pragma GCC diagnostic ignored "-Wold-style-cast"
166 #endif 166 #endif
167 167
168 DEFINE_NATIVE_ENTRY(Double_toInt, 1) { 168 DEFINE_NATIVE_ENTRY(Double_toInt, 1) {
169 const Double& arg = Double::CheckedHandle(arguments->At(0)); 169 const Double& arg = Double::CheckedHandle(arguments->At(0));
170 if (isinf(arg.value()) || isnan(arg.value())) { 170 if (isinf(arg.value()) || isnan(arg.value())) {
171 GrowableArray<const Object*> args; 171 GrowableArray<const Object*> args;
172 args.Add(&String::ZoneHandle(String::New( 172 args.Add(&String::ZoneHandle(String::New(
173 "Infinity or NaN toInt"))); 173 "Infinity or NaN toInt")));
174 Exceptions::ThrowByType(Exceptions::kBadNumberFormat, args); 174 Exceptions::ThrowByType(Exceptions::kFormat, args);
175 } 175 }
176 double result = trunc(arg.value()); 176 double result = trunc(arg.value());
177 if ((Smi::kMinValue <= result) && (result <= Smi::kMaxValue)) { 177 if ((Smi::kMinValue <= result) && (result <= Smi::kMaxValue)) {
178 arguments->SetReturn(Smi::Handle(Smi::New(static_cast<intptr_t>(result)))); 178 arguments->SetReturn(Smi::Handle(Smi::New(static_cast<intptr_t>(result))));
179 } else if ((Mint::kMinValue <= result) && (result <= Mint::kMaxValue)) { 179 } else if ((Mint::kMinValue <= result) && (result <= Mint::kMaxValue)) {
180 arguments->SetReturn(Mint::Handle(Mint::New(static_cast<int64_t>(result)))); 180 arguments->SetReturn(Mint::Handle(Mint::New(static_cast<int64_t>(result))));
181 } else { 181 } else {
182 arguments->SetReturn( 182 arguments->SetReturn(
183 Bigint::Handle(BigintOperations::NewFromDouble(result))); 183 Bigint::Handle(BigintOperations::NewFromDouble(result)));
184 } 184 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 if (signbit(arg.value()) && !isnan(arg.value())) { 271 if (signbit(arg.value()) && !isnan(arg.value())) {
272 arguments->SetReturn(Bool::Handle(Bool::True())); 272 arguments->SetReturn(Bool::Handle(Bool::True()));
273 } else { 273 } else {
274 arguments->SetReturn(Bool::Handle(Bool::False())); 274 arguments->SetReturn(Bool::Handle(Bool::False()));
275 } 275 }
276 } 276 }
277 277
278 // Add here only functions using/referring to old-style casts. 278 // Add here only functions using/referring to old-style casts.
279 279
280 } // namespace dart 280 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/http_utils.dart ('k') | runtime/lib/double.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698