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

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

Issue 2468093007: clang-format runtime/lib (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « runtime/lib/developer.cc ('k') | runtime/lib/errors.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 (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 "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "platform/math.h" 7 #include "platform/math.h"
8 8
9 #include "vm/code_generator.h" // DartModulo. 9 #include "vm/code_generator.h" // DartModulo.
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 double right = right_object.value(); 137 double right = right_object.value();
138 return Double::New(fmod_ieee(left, right)); 138 return Double::New(fmod_ieee(left, right));
139 } 139 }
140 140
141 141
142 DEFINE_NATIVE_ENTRY(Double_greaterThan, 2) { 142 DEFINE_NATIVE_ENTRY(Double_greaterThan, 2) {
143 const Double& left = Double::CheckedHandle(arguments->NativeArgAt(0)); 143 const Double& left = Double::CheckedHandle(arguments->NativeArgAt(0));
144 GET_NON_NULL_NATIVE_ARGUMENT(Double, right, arguments->NativeArgAt(1)); 144 GET_NON_NULL_NATIVE_ARGUMENT(Double, right, arguments->NativeArgAt(1));
145 bool result = right.IsNull() ? false : (left.value() > right.value()); 145 bool result = right.IsNull() ? false : (left.value() > right.value());
146 if (FLAG_trace_intrinsified_natives) { 146 if (FLAG_trace_intrinsified_natives) {
147 OS::Print("Double_greaterThan %s > %s\n", 147 OS::Print("Double_greaterThan %s > %s\n", left.ToCString(),
148 left.ToCString(), right.ToCString()); 148 right.ToCString());
149 } 149 }
150 return Bool::Get(result).raw(); 150 return Bool::Get(result).raw();
151 } 151 }
152 152
153 153
154 DEFINE_NATIVE_ENTRY(Double_greaterThanFromInteger, 2) { 154 DEFINE_NATIVE_ENTRY(Double_greaterThanFromInteger, 2) {
155 const Double& right = Double::CheckedHandle(arguments->NativeArgAt(0)); 155 const Double& right = Double::CheckedHandle(arguments->NativeArgAt(0));
156 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left, arguments->NativeArgAt(1)); 156 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left, arguments->NativeArgAt(1));
157 return Bool::Get(left.AsDoubleValue() > right.value()).raw(); 157 return Bool::Get(left.AsDoubleValue() > right.value()).raw();
158 } 158 }
159 159
160 160
161 DEFINE_NATIVE_ENTRY(Double_equal, 2) { 161 DEFINE_NATIVE_ENTRY(Double_equal, 2) {
162 const Double& left = Double::CheckedHandle(arguments->NativeArgAt(0)); 162 const Double& left = Double::CheckedHandle(arguments->NativeArgAt(0));
163 GET_NON_NULL_NATIVE_ARGUMENT(Double, right, arguments->NativeArgAt(1)); 163 GET_NON_NULL_NATIVE_ARGUMENT(Double, right, arguments->NativeArgAt(1));
164 bool result = right.IsNull() ? false : (left.value() == right.value()); 164 bool result = right.IsNull() ? false : (left.value() == right.value());
165 if (FLAG_trace_intrinsified_natives) { 165 if (FLAG_trace_intrinsified_natives) {
166 OS::Print("Double_equal %s == %s\n", 166 OS::Print("Double_equal %s == %s\n", left.ToCString(), right.ToCString());
167 left.ToCString(), right.ToCString());
168 } 167 }
169 return Bool::Get(result).raw(); 168 return Bool::Get(result).raw();
170 } 169 }
171 170
172 171
173 DEFINE_NATIVE_ENTRY(Double_equalToInteger, 2) { 172 DEFINE_NATIVE_ENTRY(Double_equalToInteger, 2) {
174 const Double& left = Double::CheckedHandle(arguments->NativeArgAt(0)); 173 const Double& left = Double::CheckedHandle(arguments->NativeArgAt(0));
175 GET_NON_NULL_NATIVE_ARGUMENT(Integer, right, arguments->NativeArgAt(1)); 174 GET_NON_NULL_NATIVE_ARGUMENT(Integer, right, arguments->NativeArgAt(1));
176 return Bool::Get(left.value() == right.AsDoubleValue()).raw(); 175 return Bool::Get(left.value() == right.AsDoubleValue()).raw();
177 } 176 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 237
239 DEFINE_NATIVE_ENTRY(Double_toStringAsFixed, 2) { 238 DEFINE_NATIVE_ENTRY(Double_toStringAsFixed, 2) {
240 // The boundaries are exclusive. 239 // The boundaries are exclusive.
241 static const double kLowerBoundary = -1e21; 240 static const double kLowerBoundary = -1e21;
242 static const double kUpperBoundary = 1e21; 241 static const double kUpperBoundary = 1e21;
243 242
244 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0)); 243 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0));
245 GET_NON_NULL_NATIVE_ARGUMENT(Smi, fraction_digits, arguments->NativeArgAt(1)); 244 GET_NON_NULL_NATIVE_ARGUMENT(Smi, fraction_digits, arguments->NativeArgAt(1));
246 double d = arg.value(); 245 double d = arg.value();
247 intptr_t fraction_digits_value = fraction_digits.Value(); 246 intptr_t fraction_digits_value = fraction_digits.Value();
248 if (0 <= fraction_digits_value && fraction_digits_value <= 20 247 if (0 <= fraction_digits_value && fraction_digits_value <= 20 &&
249 && kLowerBoundary < d && d < kUpperBoundary) { 248 kLowerBoundary < d && d < kUpperBoundary) {
250 return DoubleToStringAsFixed(d, static_cast<int>(fraction_digits_value)); 249 return DoubleToStringAsFixed(d, static_cast<int>(fraction_digits_value));
251 } else { 250 } else {
252 Exceptions::ThrowArgumentError(String::Handle( 251 Exceptions::ThrowArgumentError(String::Handle(
253 String::New("Illegal arguments to double.toStringAsFixed"))); 252 String::New("Illegal arguments to double.toStringAsFixed")));
254 return Object::null(); 253 return Object::null();
255 } 254 }
256 } 255 }
257 256
258 257
259 DEFINE_NATIVE_ENTRY(Double_toStringAsExponential, 2) { 258 DEFINE_NATIVE_ENTRY(Double_toStringAsExponential, 2) {
260 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0)); 259 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0));
261 GET_NON_NULL_NATIVE_ARGUMENT(Smi, fraction_digits, arguments->NativeArgAt(1)); 260 GET_NON_NULL_NATIVE_ARGUMENT(Smi, fraction_digits, arguments->NativeArgAt(1));
262 double d = arg.value(); 261 double d = arg.value();
263 intptr_t fraction_digits_value = fraction_digits.Value(); 262 intptr_t fraction_digits_value = fraction_digits.Value();
264 if (-1 <= fraction_digits_value && fraction_digits_value <= 20) { 263 if (-1 <= fraction_digits_value && fraction_digits_value <= 20) {
265 return DoubleToStringAsExponential( 264 return DoubleToStringAsExponential(d,
266 d, static_cast<int>(fraction_digits_value)); 265 static_cast<int>(fraction_digits_value));
267 } else { 266 } else {
268 Exceptions::ThrowArgumentError(String::Handle( 267 Exceptions::ThrowArgumentError(String::Handle(
269 String::New("Illegal arguments to double.toStringAsExponential"))); 268 String::New("Illegal arguments to double.toStringAsExponential")));
270 return Object::null(); 269 return Object::null();
271 } 270 }
272 } 271 }
273 272
274 273
275 DEFINE_NATIVE_ENTRY(Double_toStringAsPrecision, 2) { 274 DEFINE_NATIVE_ENTRY(Double_toStringAsPrecision, 2) {
276 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0)); 275 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 DEFINE_NATIVE_ENTRY(Double_flipSignBit, 1) { 309 DEFINE_NATIVE_ENTRY(Double_flipSignBit, 1) {
311 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0)); 310 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0));
312 const double in_val = arg.value(); 311 const double in_val = arg.value();
313 const int64_t bits = bit_cast<int64_t, double>(in_val) ^ kSignBitDouble; 312 const int64_t bits = bit_cast<int64_t, double>(in_val) ^ kSignBitDouble;
314 return Double::New(bit_cast<double, int64_t>(bits)); 313 return Double::New(bit_cast<double, int64_t>(bits));
315 } 314 }
316 315
317 // Add here only functions using/referring to old-style casts. 316 // Add here only functions using/referring to old-style casts.
318 317
319 } // namespace dart 318 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/developer.cc ('k') | runtime/lib/errors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698