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

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

Issue 53993004: Change integer canonicalization to use CheckAndCanonicalize (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // Call the embedder to supply us with the environment. 241 // Call the embedder to supply us with the environment.
242 Dart_EnvironmentCallback callback = isolate->environment_callback(); 242 Dart_EnvironmentCallback callback = isolate->environment_callback();
243 if (callback != NULL) { 243 if (callback != NULL) {
244 Dart_Handle response = callback(Api::NewHandle(isolate, name.raw())); 244 Dart_Handle response = callback(Api::NewHandle(isolate, name.raw()));
245 if (Dart_IsString(response)) { 245 if (Dart_IsString(response)) {
246 const String& value = String::Cast( 246 const String& value = String::Cast(
247 Object::Handle(isolate, Api::UnwrapHandle(response))); 247 Object::Handle(isolate, Api::UnwrapHandle(response)));
248 const Integer& result = Integer::Handle(ParseInteger(value)); 248 const Integer& result = Integer::Handle(ParseInteger(value));
249 if (!result.IsNull()) { 249 if (!result.IsNull()) {
250 if (result.IsSmi()) return result.raw(); 250 if (result.IsSmi()) return result.raw();
251 return Integer::NewCanonical(String::Handle( 251 return result.CheckAndCanonicalize(NULL);
252 String::New(result.ToCString())));
253 } 252 }
254 } else if (Dart_IsError(response)) { 253 } else if (Dart_IsError(response)) {
255 const Object& error = 254 const Object& error =
256 Object::Handle(isolate, Api::UnwrapHandle(response)); 255 Object::Handle(isolate, Api::UnwrapHandle(response));
257 Exceptions::ThrowArgumentError( 256 Exceptions::ThrowArgumentError(
258 String::Handle( 257 String::Handle(
259 String::New(Error::Cast(error).ToErrorCString()))); 258 String::New(Error::Cast(error).ToErrorCString())));
260 } else if (!Dart_IsNull(response)) { 259 } else if (!Dart_IsNull(response)) {
261 Exceptions::ThrowArgumentError( 260 Exceptions::ThrowArgumentError(
262 String::Handle(String::New("Illegal environment value"))); 261 String::Handle(String::New("Illegal environment value")));
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // Use the preallocated out of memory exception to avoid calling 440 // Use the preallocated out of memory exception to avoid calling
442 // into dart code or allocating any code. 441 // into dart code or allocating any code.
443 const Instance& exception = 442 const Instance& exception =
444 Instance::Handle(isolate->object_store()->out_of_memory()); 443 Instance::Handle(isolate->object_store()->out_of_memory());
445 Exceptions::Throw(exception); 444 Exceptions::Throw(exception);
446 UNREACHABLE(); 445 UNREACHABLE();
447 return 0; 446 return 0;
448 } 447 }
449 448
450 } // namespace dart 449 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698