Index: runtime/lib/string.cc |
=================================================================== |
--- runtime/lib/string.cc (revision 28841) |
+++ runtime/lib/string.cc (working copy) |
@@ -4,7 +4,10 @@ |
#include "vm/bootstrap_natives.h" |
+#include "include/dart_api.h" |
#include "vm/exceptions.h" |
+#include "vm/dart_api_impl.h" |
+#include "vm/isolate.h" |
#include "vm/native_entry.h" |
#include "vm/object.h" |
#include "vm/symbols.h" |
@@ -12,6 +15,25 @@ |
namespace dart { |
+DEFINE_NATIVE_ENTRY(String_fromEnvironment, 3) { |
+ GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(1)); |
+ GET_NATIVE_ARGUMENT(String, 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(kStringEnvironment, |
+ Api::NewHandle(isolate, name.raw())); |
+ if (!Dart_IsError(result)) { |
+ const Object& value = Object::Handle(isolate, Api::UnwrapHandle(result)); |
+ if (value.IsString()) { |
+ return Symbols::New(String::Cast(value)); |
+ } |
+ } |
+ } |
+ return default_value.raw(); |
+} |
+ |
+ |
DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) { |
GET_NON_NULL_NATIVE_ARGUMENT(Instance, list, arguments->NativeArgAt(0)); |
if (!list.IsGrowableObjectArray() && !list.IsArray()) { |