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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 585643004: Add Dart_IsFuture. To be used in Dartium implementation of Promises. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.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 d354726ad32fc1ed15a940ca264be2b9e9582e1f..1f5fb044469c778d068b8e487b5aa22f2e99b720 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -71,9 +71,9 @@ static RawInstance* GetListInstance(Isolate* isolate, const Object& obj) {
const Instance& instance = Instance::Cast(obj);
const Class& obj_class = Class::Handle(isolate, obj.clazz());
Error& malformed_type_error = Error::Handle(isolate);
- if (obj_class.IsSubtypeOf(TypeArguments::Handle(isolate),
+ if (obj_class.IsSubtypeOf(Object::null_type_arguments(),
list_class,
- TypeArguments::Handle(isolate),
+ Object::null_type_arguments(),
&malformed_type_error)) {
ASSERT(malformed_type_error.IsNull()); // Type is a raw List.
return instance.raw();
@@ -91,9 +91,9 @@ static RawInstance* GetMapInstance(Isolate* isolate, const Object& obj) {
const Instance& instance = Instance::Cast(obj);
const Class& obj_class = Class::Handle(isolate, obj.clazz());
Error& malformed_type_error = Error::Handle(isolate);
- if (obj_class.IsSubtypeOf(TypeArguments::Handle(isolate),
+ if (obj_class.IsSubtypeOf(Object::null_type_arguments(),
map_class,
- TypeArguments::Handle(isolate),
+ Object::null_type_arguments(),
&malformed_type_error)) {
ASSERT(malformed_type_error.IsNull()); // Type is a raw Map.
return instance.raw();
@@ -1870,6 +1870,30 @@ DART_EXPORT bool Dart_IsByteBuffer(Dart_Handle handle) {
}
+DART_EXPORT bool Dart_IsFuture(Dart_Handle handle) {
+ TRACE_API_CALL(CURRENT_FUNC);
+ Isolate* isolate = Isolate::Current();
+ DARTSCOPE(isolate);
+ const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle));
+ if (obj.IsInstance()) {
+ const Library& async_lib =
+ Library::Handle(isolate, Library::AsyncLibrary());
+ const Class& future_class =
+ Class::Handle(isolate, async_lib.LookupClass(Symbols::Future()));
+ ASSERT(!future_class.IsNull());
+ const Class& obj_class = Class::Handle(isolate, obj.clazz());
+ Error& malformed_type_error = Error::Handle(isolate);
+ bool is_future = obj_class.IsSubtypeOf(Object::null_type_arguments(),
+ future_class,
+ Object::null_type_arguments(),
+ &malformed_type_error);
+ ASSERT(malformed_type_error.IsNull()); // Type is a raw Future.
+ return is_future;
+ }
+ return false;
+}
+
+
// --- Instances ----
DART_EXPORT Dart_Handle Dart_InstanceGetType(Dart_Handle instance) {
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698