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

Side by Side Diff: lib/integers.cc

Issue 11639007: Cleanup the exceptions create code to use Arrays instead GrowableArrays so (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years 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 | « lib/growable_array.cc ('k') | lib/isolate.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) 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 &is_positive, 195 &is_positive,
196 &int_string)) { 196 &int_string)) {
197 if (is_positive) { 197 if (is_positive) {
198 return Integer::New(*int_string); 198 return Integer::New(*int_string);
199 } 199 }
200 String& temp = String::Handle(); 200 String& temp = String::Handle();
201 temp = String::Concat(String::Handle(Symbols::New("-")), *int_string); 201 temp = String::Concat(String::Handle(Symbols::New("-")), *int_string);
202 return Integer::New(temp); 202 return Integer::New(temp);
203 } 203 }
204 204
205 GrowableArray<const Object*> args; 205 const Array& args = Array::Handle(Array::New(1));
206 args.Add(&value); 206 args.SetAt(0, value);
207 Exceptions::ThrowByType(Exceptions::kFormat, args); 207 Exceptions::ThrowByType(Exceptions::kFormat, args);
208 return Object::null(); 208 return Object::null();
209 } 209 }
210 210
211 211
212 static RawInteger* ShiftOperationHelper(Token::Kind kind, 212 static RawInteger* ShiftOperationHelper(Token::Kind kind,
213 const Integer& value, 213 const Integer& value,
214 const Smi& amount) { 214 const Smi& amount) {
215 if (amount.Value() < 0) { 215 if (amount.Value() < 0) {
216 GrowableArray<const Object*> args; 216 const Array& args = Array::Handle(Array::New(1));
217 args.Add(&amount); 217 args.SetAt(0, amount);
218 Exceptions::ThrowByType(Exceptions::kArgument, args); 218 Exceptions::ThrowByType(Exceptions::kArgument, args);
219 } 219 }
220 if (value.IsSmi()) { 220 if (value.IsSmi()) {
221 Smi& smi_value = Smi::Handle(); 221 Smi& smi_value = Smi::Handle();
222 smi_value ^= value.raw(); 222 smi_value ^= value.raw();
223 return smi_value.ShiftOp(kind, amount); 223 return smi_value.ShiftOp(kind, amount);
224 } 224 }
225 Bigint& big_value = Bigint::Handle(); 225 Bigint& big_value = Bigint::Handle();
226 if (value.IsMint()) { 226 if (value.IsMint()) {
227 const int64_t mint_value = value.AsInt64Value(); 227 const int64_t mint_value = value.AsInt64Value();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 308
309 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { 309 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) {
310 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0)); 310 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0));
311 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); 311 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value));
312 ASSERT(CheckInteger(value)); 312 ASSERT(CheckInteger(value));
313 ASSERT(CheckInteger(result)); 313 ASSERT(CheckInteger(result));
314 return result.AsValidInteger(); 314 return result.AsValidInteger();
315 } 315 }
316 316
317 } // namespace dart 317 } // namespace dart
OLDNEW
« no previous file with comments | « lib/growable_array.cc ('k') | lib/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698