| OLD | NEW |
| 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 "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/exceptions.h" |
| 9 #include "vm/native_entry.h" | 10 #include "vm/native_entry.h" |
| 10 #include "vm/object.h" | 11 #include "vm/object.h" |
| 11 | 12 |
| 12 namespace dart { | 13 namespace dart { |
| 13 | 14 |
| 14 DEFINE_FLAG(bool, trace_intrinsified_natives, false, | 15 DEFINE_FLAG(bool, trace_intrinsified_natives, false, |
| 15 "Report if any of the intrinsified natives are called"); | 16 "Report if any of the intrinsified natives are called"); |
| 16 | 17 |
| 17 // Smi natives. | 18 // Smi natives. |
| 18 | 19 |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 } | 477 } |
| 477 ASSERT(Smi::IsValid(result)); | 478 ASSERT(Smi::IsValid(result)); |
| 478 return Smi::New(result); | 479 return Smi::New(result); |
| 479 } | 480 } |
| 480 | 481 |
| 481 | 482 |
| 482 static RawInteger* ShiftOperationHelper(Token::Kind kind, | 483 static RawInteger* ShiftOperationHelper(Token::Kind kind, |
| 483 const Integer& value, | 484 const Integer& value, |
| 484 const Smi& amount) { | 485 const Smi& amount) { |
| 485 if (amount.Value() < 0) { | 486 if (amount.Value() < 0) { |
| 486 // TODO(srdjan): Throw exception maybe. | 487 GrowableArray<const Object*> args; |
| 487 UNIMPLEMENTED(); | 488 args.Add(&amount); |
| 489 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); |
| 488 } | 490 } |
| 489 if (value.IsSmi()) { | 491 if (value.IsSmi()) { |
| 490 Smi& smi_value = Smi::Handle(); | 492 Smi& smi_value = Smi::Handle(); |
| 491 smi_value ^= value.raw(); | 493 smi_value ^= value.raw(); |
| 492 return SmiShiftOperation(kind, smi_value, amount); | 494 return SmiShiftOperation(kind, smi_value, amount); |
| 493 } | 495 } |
| 494 Bigint& big_value = Bigint::Handle(); | 496 Bigint& big_value = Bigint::Handle(); |
| 495 if (value.IsMint()) { | 497 if (value.IsMint()) { |
| 496 const int64_t mint_value = value.AsInt64Value(); | 498 const int64_t mint_value = value.AsInt64Value(); |
| 497 const int count = HighestBit(mint_value); | 499 const int count = HighestBit(mint_value); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 | 579 |
| 578 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { | 580 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { |
| 579 const Bigint& value = Bigint::CheckedHandle(arguments->At(0)); | 581 const Bigint& value = Bigint::CheckedHandle(arguments->At(0)); |
| 580 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); | 582 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); |
| 581 ASSERT(CheckInteger(value)); | 583 ASSERT(CheckInteger(value)); |
| 582 ASSERT(CheckInteger(result)); | 584 ASSERT(CheckInteger(result)); |
| 583 arguments->SetReturn(Integer::Handle(AsInteger(result))); | 585 arguments->SetReturn(Integer::Handle(AsInteger(result))); |
| 584 } | 586 } |
| 585 | 587 |
| 586 } // namespace dart | 588 } // namespace dart |
| OLD | NEW |