mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
![Daco Harkes](/assets/img/avatar_default.png)
Change-Id: I03efbbf4340de1c8f23c60854ed991671ca2b647 Reviewed-on: https://dart-review.googlesource.com/c/87077 Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Samir Jindel <sjindel@google.com>
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "vm/bootstrap_natives.h"
|
|
|
|
#include "include/dart_api.h"
|
|
#include "vm/dart_api_impl.h"
|
|
#include "vm/dart_entry.h"
|
|
#include "vm/exceptions.h"
|
|
#include "vm/isolate.h"
|
|
#include "vm/native_entry.h"
|
|
#include "vm/object.h"
|
|
#include "vm/object_store.h"
|
|
#include "vm/symbols.h"
|
|
|
|
namespace dart {
|
|
|
|
DEFINE_NATIVE_ENTRY(Bool_fromEnvironment, 0, 3) {
|
|
GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(1));
|
|
GET_NATIVE_ARGUMENT(Bool, default_value, arguments->NativeArgAt(2));
|
|
// Call the embedder to supply us with the environment.
|
|
const String& env_value =
|
|
String::Handle(Api::GetEnvironmentValue(thread, name));
|
|
if (!env_value.IsNull()) {
|
|
if (Symbols::True().Equals(env_value)) {
|
|
return Bool::True().raw();
|
|
}
|
|
if (Symbols::False().Equals(env_value)) {
|
|
return Bool::False().raw();
|
|
}
|
|
}
|
|
return default_value.raw();
|
|
}
|
|
|
|
} // namespace dart
|