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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 1640853004: Support 'dart.library.X' env variables in the VM. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Two new lines between functions. Created 4 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index d316138f93480972c01f8e758d06017b63ab859e..d8ecfb16bc044faf70505f4a0dc9a2b8d6e6aa31 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -4817,6 +4817,37 @@ DART_EXPORT void Dart_SetWeakHandleReturnValue(Dart_NativeArguments args,
// --- Environment ---
+RawString* Api::GetEnvironmentValue(Thread* thread, const String& name) {
+ String& result = String::Handle(CallEnvironmentCallback(thread, name));
+ if (result.IsNull()) {
+ // Every 'dart:X' library introduces an environment variable
+ // 'dart.library.X' that is set to 'true'.
+ const String& prefix = Symbols::DartLibrary();
+ if (name.StartsWith(prefix)) {
+ const String& library_name =
+ String::Handle(String::SubString(name, prefix.Length()));
+ if (!library_name.IsNull()) {
+ const String& dart_library_name =
+ String::Handle(String::Concat(Symbols::DartScheme(), library_name));
+ const Library& library =
+ Library::Handle(Library::LookupLibrary(dart_library_name));
+ if (!library.IsNull()) {
+ return Symbols::True().raw();
+ }
+ }
+ }
+ // TODO(iposva): Determine whether builtin values can be overriden by the
Ivan Posva 2016/01/29 21:29:49 Please remove this TODO as obviously above you are
floitsch 2016/02/01 16:56:34 Done.
+ // embedder.
+ // Check for default VM provided values. If it was not overriden on the
+ // command line.
+ if (Symbols::DartIsVM().Equals(name)) {
+ return Symbols::True().raw();
+ }
+ }
+ return result.raw();
+}
+
+
RawString* Api::CallEnvironmentCallback(Thread* thread, const String& name) {
Isolate* isolate = thread->isolate();
Scope api_scope(thread);
@@ -4837,15 +4868,6 @@ RawString* Api::CallEnvironmentCallback(Thread* thread, const String& name) {
String::Handle(String::New("Illegal environment value")));
}
}
- if (result.IsNull()) {
- // TODO(iposva): Determine whether builtin values can be overriden by the
- // embedder.
- // Check for default VM provided values. If it was not overriden on the
- // command line.
- if (Symbols::DartIsVM().Equals(name)) {
- return Symbols::True().raw();
- }
- }
return result.raw();
}
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698