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 "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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 return ParseInteger(value); | 234 return ParseInteger(value); |
235 } | 235 } |
236 | 236 |
237 | 237 |
238 DEFINE_NATIVE_ENTRY(Integer_fromEnvironment, 3) { | 238 DEFINE_NATIVE_ENTRY(Integer_fromEnvironment, 3) { |
239 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(1)); | 239 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(1)); |
240 GET_NATIVE_ARGUMENT(Integer, default_value, arguments->NativeArgAt(2)); | 240 GET_NATIVE_ARGUMENT(Integer, default_value, arguments->NativeArgAt(2)); |
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 VmToNativeTimerScope timer(isolate); |
244 Dart_Handle response = callback(Api::NewHandle(isolate, name.raw())); | 245 Dart_Handle response = callback(Api::NewHandle(isolate, name.raw())); |
245 if (Dart_IsString(response)) { | 246 if (Dart_IsString(response)) { |
246 const String& value = String::Cast( | 247 const String& value = String::Cast( |
247 Object::Handle(isolate, Api::UnwrapHandle(response))); | 248 Object::Handle(isolate, Api::UnwrapHandle(response))); |
248 const Integer& result = Integer::Handle(ParseInteger(value)); | 249 const Integer& result = Integer::Handle(ParseInteger(value)); |
249 if (!result.IsNull()) { | 250 if (!result.IsNull()) { |
250 if (result.IsSmi()) return result.raw(); | 251 if (result.IsSmi()) return result.raw(); |
251 return result.CheckAndCanonicalize(NULL); | 252 return result.CheckAndCanonicalize(NULL); |
252 } | 253 } |
253 } else if (Dart_IsError(response)) { | 254 } else if (Dart_IsError(response)) { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 // Use the preallocated out of memory exception to avoid calling | 441 // Use the preallocated out of memory exception to avoid calling |
441 // into dart code or allocating any code. | 442 // into dart code or allocating any code. |
442 const Instance& exception = | 443 const Instance& exception = |
443 Instance::Handle(isolate->object_store()->out_of_memory()); | 444 Instance::Handle(isolate->object_store()->out_of_memory()); |
444 Exceptions::Throw(exception); | 445 Exceptions::Throw(exception); |
445 UNREACHABLE(); | 446 UNREACHABLE(); |
446 return 0; | 447 return 0; |
447 } | 448 } |
448 | 449 |
449 } // namespace dart | 450 } // namespace dart |
OLD | NEW |