Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 | 8 |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/exceptions.h" | 10 #include "vm/exceptions.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 } else { \ | 251 } else { \ |
| 252 const String& error = String::Handle(String::NewFormatted( \ | 252 const String& error = String::Handle(String::NewFormatted( \ |
| 253 "Expected a TypedData object but found %s", instance.ToCString())); \ | 253 "Expected a TypedData object but found %s", instance.ToCString())); \ |
| 254 const Array& args = Array::Handle(Array::New(1)); \ | 254 const Array& args = Array::Handle(Array::New(1)); \ |
| 255 args.SetAt(0, error); \ | 255 args.SetAt(0, error); \ |
| 256 Exceptions::ThrowByType(Exceptions::kArgument, args); \ | 256 Exceptions::ThrowByType(Exceptions::kArgument, args); \ |
| 257 } \ | 257 } \ |
| 258 Integer& result = Integer::Handle(); \ | 258 Integer& result = Integer::Handle(); \ |
| 259 if (value > static_cast<uint64_t>(Mint::kMaxValue)) { \ | 259 if (value > static_cast<uint64_t>(Mint::kMaxValue)) { \ |
| 260 result = BigintOperations::NewFromUint64(value); \ | 260 result = BigintOperations::NewFromUint64(value); \ |
| 261 } else if (value > static_cast<uint64_t>(Smi::kMaxValue)) { \ | 261 } else if (value > static_cast<uint64_t>(Smi::kMaxValue)) { \ |
|
siva
2013/05/16 19:52:50
Ditto comment here.
This could just be:
} else {
srdjan
2013/05/16 20:03:31
Done.
| |
| 262 result = Mint::New(value); \ | 262 result = Integer::New(value); \ |
| 263 } else { \ | 263 } else { \ |
| 264 result = Smi::New(value); \ | 264 result = Smi::New(value); \ |
| 265 } \ | 265 } \ |
| 266 return result.raw(); \ | 266 return result.raw(); \ |
| 267 } \ | 267 } \ |
| 268 | 268 |
| 269 | 269 |
| 270 // TODO(asiva): Consider truncating the bigint value if it does not fit into | 270 // TODO(asiva): Consider truncating the bigint value if it does not fit into |
| 271 // a uint64_t value (see ASSERT(BigintOperations::FitsIntoUint64(bigint))). | 271 // a uint64_t value (see ASSERT(BigintOperations::FitsIntoUint64(bigint))). |
| 272 #define TYPED_DATA_UINT64_SETTER(setter, object) \ | 272 #define TYPED_DATA_UINT64_SETTER(setter, object) \ |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 value = host_value.AsInt64Value(); | 403 value = host_value.AsInt64Value(); |
| 404 } | 404 } |
| 405 if (little_endian.value()) { | 405 if (little_endian.value()) { |
| 406 value = Utils::HostToLittleEndian64(value); | 406 value = Utils::HostToLittleEndian64(value); |
| 407 } else { | 407 } else { |
| 408 value = Utils::HostToBigEndian64(value); | 408 value = Utils::HostToBigEndian64(value); |
| 409 } | 409 } |
| 410 if (value > static_cast<uint64_t>(Mint::kMaxValue)) { | 410 if (value > static_cast<uint64_t>(Mint::kMaxValue)) { |
| 411 return BigintOperations::NewFromUint64(value); | 411 return BigintOperations::NewFromUint64(value); |
| 412 } else if (value > static_cast<uint64_t>(Smi::kMaxValue)) { | 412 } else if (value > static_cast<uint64_t>(Smi::kMaxValue)) { |
| 413 return Mint::New(value); | 413 return Integer::New(value); |
|
siva
2013/05/16 19:52:50
Ditto here too.
it could just be:
return Integer:
srdjan
2013/05/16 20:03:31
Done.
| |
| 414 } | 414 } |
| 415 return Smi::New(value); | 415 return Smi::New(value); |
| 416 } | 416 } |
| 417 | 417 |
| 418 | 418 |
| 419 DEFINE_NATIVE_ENTRY(ByteData_ToEndianFloat32, 2) { | 419 DEFINE_NATIVE_ENTRY(ByteData_ToEndianFloat32, 2) { |
| 420 GET_NON_NULL_NATIVE_ARGUMENT(Double, host_value, arguments->NativeArgAt(0)); | 420 GET_NON_NULL_NATIVE_ARGUMENT(Double, host_value, arguments->NativeArgAt(0)); |
| 421 GET_NON_NULL_NATIVE_ARGUMENT(Bool, little_endian, arguments->NativeArgAt(1)); | 421 GET_NON_NULL_NATIVE_ARGUMENT(Bool, little_endian, arguments->NativeArgAt(1)); |
| 422 float value = host_value.value(); | 422 float value = host_value.value(); |
| 423 if (little_endian.value()) { | 423 if (little_endian.value()) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 439 value = bit_cast<double>( | 439 value = bit_cast<double>( |
| 440 Utils::HostToLittleEndian64(bit_cast<uint64_t>(value))); | 440 Utils::HostToLittleEndian64(bit_cast<uint64_t>(value))); |
| 441 } else { | 441 } else { |
| 442 value = bit_cast<double>( | 442 value = bit_cast<double>( |
| 443 Utils::HostToBigEndian64(bit_cast<uint64_t>(value))); | 443 Utils::HostToBigEndian64(bit_cast<uint64_t>(value))); |
| 444 } | 444 } |
| 445 return Double::New(value); | 445 return Double::New(value); |
| 446 } | 446 } |
| 447 | 447 |
| 448 } // namespace dart | 448 } // namespace dart |
| OLD | NEW |