| Index: runtime/lib/integers.cc
|
| ===================================================================
|
| --- runtime/lib/integers.cc (revision 28841)
|
| +++ runtime/lib/integers.cc (working copy)
|
| @@ -4,9 +4,12 @@
|
|
|
| #include "vm/bootstrap_natives.h"
|
|
|
| +#include "include/dart_api.h"
|
| #include "vm/bigint_operations.h"
|
| #include "vm/dart_entry.h"
|
| +#include "vm/dart_api_impl.h"
|
| #include "vm/exceptions.h"
|
| +#include "vm/isolate.h"
|
| #include "vm/native_entry.h"
|
| #include "vm/object.h"
|
| #include "vm/object_store.h"
|
| @@ -226,6 +229,26 @@
|
| }
|
|
|
|
|
| +DEFINE_NATIVE_ENTRY(Integer_fromEnvironment, 3) {
|
| + GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(1));
|
| + GET_NATIVE_ARGUMENT(Integer, default_value, arguments->NativeArgAt(2));
|
| + // Call the embedder to supply us with the environment.
|
| + Dart_EnvironmentCallback callback = isolate->environment_callback();
|
| + if (callback != NULL) {
|
| + Dart_Handle result = callback(kIntegerEnvironment,
|
| + Api::NewHandle(isolate, name.raw()));
|
| + if (!Dart_IsError(result)) {
|
| + const Object& value = Object::Handle(isolate, Api::UnwrapHandle(result));
|
| + if (value.IsString()) {
|
| + // TODO(iposva): Handle errors such as malformed integers.
|
| + return Integer::NewCanonical(String::Cast(value));
|
| + }
|
| + }
|
| + }
|
| + return default_value.raw();
|
| +}
|
| +
|
| +
|
| // Passing true for 'silent' prevents throwing JavascriptIntegerOverflow.
|
| static RawInteger* ShiftOperationHelper(Token::Kind kind,
|
| const Integer& value,
|
|
|