OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/exceptions.h" |
10 #include "vm/native_entry.h" | 10 #include "vm/native_entry.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 return Bool::Get(left.CompareWith(right) == 0); | 171 return Bool::Get(left.CompareWith(right) == 0); |
172 } | 172 } |
173 | 173 |
174 | 174 |
175 static RawInteger* ShiftOperationHelper(Token::Kind kind, | 175 static RawInteger* ShiftOperationHelper(Token::Kind kind, |
176 const Integer& value, | 176 const Integer& value, |
177 const Smi& amount) { | 177 const Smi& amount) { |
178 if (amount.Value() < 0) { | 178 if (amount.Value() < 0) { |
179 GrowableArray<const Object*> args; | 179 GrowableArray<const Object*> args; |
180 args.Add(&amount); | 180 args.Add(&amount); |
181 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); | 181 Exceptions::ThrowByType(Exceptions::kArgument, args); |
182 } | 182 } |
183 if (value.IsSmi()) { | 183 if (value.IsSmi()) { |
184 Smi& smi_value = Smi::Handle(); | 184 Smi& smi_value = Smi::Handle(); |
185 smi_value ^= value.raw(); | 185 smi_value ^= value.raw(); |
186 return smi_value.ShiftOp(kind, amount); | 186 return smi_value.ShiftOp(kind, amount); |
187 } | 187 } |
188 Bigint& big_value = Bigint::Handle(); | 188 Bigint& big_value = Bigint::Handle(); |
189 if (value.IsMint()) { | 189 if (value.IsMint()) { |
190 const int64_t mint_value = value.AsInt64Value(); | 190 const int64_t mint_value = value.AsInt64Value(); |
191 const int count = Utils::HighestBit(mint_value); | 191 const int count = Utils::HighestBit(mint_value); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 271 |
272 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { | 272 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { |
273 const Bigint& value = Bigint::CheckedHandle(arguments->At(0)); | 273 const Bigint& value = Bigint::CheckedHandle(arguments->At(0)); |
274 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); | 274 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); |
275 ASSERT(CheckInteger(value)); | 275 ASSERT(CheckInteger(value)); |
276 ASSERT(CheckInteger(result)); | 276 ASSERT(CheckInteger(result)); |
277 return result.AsInteger(); | 277 return result.AsInteger(); |
278 } | 278 } |
279 | 279 |
280 } // namespace dart | 280 } // namespace dart |
OLD | NEW |