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 "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
8 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/dart_api_impl.h" |
9 #include "vm/exceptions.h" | 11 #include "vm/exceptions.h" |
| 12 #include "vm/isolate.h" |
10 #include "vm/native_entry.h" | 13 #include "vm/native_entry.h" |
11 #include "vm/object.h" | 14 #include "vm/object.h" |
12 #include "vm/object_store.h" | 15 #include "vm/object_store.h" |
13 #include "vm/symbols.h" | 16 #include "vm/symbols.h" |
14 | 17 |
15 namespace dart { | 18 namespace dart { |
16 | 19 |
17 DEFINE_FLAG(bool, trace_intrinsified_natives, false, | 20 DEFINE_FLAG(bool, trace_intrinsified_natives, false, |
18 "Report if any of the intrinsified natives are called"); | 21 "Report if any of the intrinsified natives are called"); |
19 | 22 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 } | 222 } |
220 String& temp = String::Handle(); | 223 String& temp = String::Handle(); |
221 temp = String::Concat(Symbols::Dash(), *int_string); | 224 temp = String::Concat(Symbols::Dash(), *int_string); |
222 return Integer::New(temp); | 225 return Integer::New(temp); |
223 } | 226 } |
224 | 227 |
225 return Object::null(); | 228 return Object::null(); |
226 } | 229 } |
227 | 230 |
228 | 231 |
| 232 DEFINE_NATIVE_ENTRY(Integer_env, 3) { |
| 233 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(1)); |
| 234 GET_NATIVE_ARGUMENT(Integer, default_value, arguments->NativeArgAt(2)); |
| 235 // Call the embedder to supply us with the environment. |
| 236 Dart_ConfigCallback callback = isolate->config_callback(); |
| 237 if (callback != NULL) { |
| 238 Dart_Handle result = callback(kIntegerConfig, |
| 239 Api::NewHandle(isolate, name.raw())); |
| 240 if (!Dart_IsError(result)) { |
| 241 const Object& value = Object::Handle(isolate, Api::UnwrapHandle(result)); |
| 242 if (value.IsString()) { |
| 243 return Symbols::New(String::Cast(value)); |
| 244 } |
| 245 } |
| 246 } |
| 247 return default_value.raw(); |
| 248 } |
| 249 |
| 250 |
229 // Passing true for 'silent' prevents throwing JavascriptIntegerOverflow. | 251 // Passing true for 'silent' prevents throwing JavascriptIntegerOverflow. |
230 static RawInteger* ShiftOperationHelper(Token::Kind kind, | 252 static RawInteger* ShiftOperationHelper(Token::Kind kind, |
231 const Integer& value, | 253 const Integer& value, |
232 const Smi& amount, | 254 const Smi& amount, |
233 const bool silent = false) { | 255 const bool silent = false) { |
234 if (amount.Value() < 0) { | 256 if (amount.Value() < 0) { |
235 const Array& args = Array::Handle(Array::New(1)); | 257 const Array& args = Array::Handle(Array::New(1)); |
236 args.SetAt(0, amount); | 258 args.SetAt(0, amount); |
237 Exceptions::ThrowByType(Exceptions::kArgument, args); | 259 Exceptions::ThrowByType(Exceptions::kArgument, args); |
238 } | 260 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 // Use the preallocated out of memory exception to avoid calling | 425 // Use the preallocated out of memory exception to avoid calling |
404 // into dart code or allocating any code. | 426 // into dart code or allocating any code. |
405 const Instance& exception = | 427 const Instance& exception = |
406 Instance::Handle(isolate->object_store()->out_of_memory()); | 428 Instance::Handle(isolate->object_store()->out_of_memory()); |
407 Exceptions::Throw(exception); | 429 Exceptions::Throw(exception); |
408 UNREACHABLE(); | 430 UNREACHABLE(); |
409 return 0; | 431 return 0; |
410 } | 432 } |
411 | 433 |
412 } // namespace dart | 434 } // namespace dart |
OLD | NEW |