Index: runtime/lib/object.cc |
diff --git a/runtime/lib/object.cc b/runtime/lib/object.cc |
index 723bf69eced37e87d2b9851d8aad625324c9ac28..e1b7a71c8eb53bfc7acd3a25760dcfbd6a5940a6 100644 |
--- a/runtime/lib/object.cc |
+++ b/runtime/lib/object.cc |
@@ -166,6 +166,37 @@ DEFINE_NATIVE_ENTRY(Object_instanceOf, 4) { |
return Bool::Get(negate.value() ? !is_instance_of : is_instance_of).raw(); |
} |
+DEFINE_NATIVE_ENTRY(Object_simpleInstanceOf, 2) { |
+ // This native is only called when the right hand side passes |
+ // simpleInstanceOfType and it is a non-negative test. |
+ const Instance& instance = |
+ Instance::CheckedHandle(zone, arguments->NativeArgAt(0)); |
+ const AbstractType& type = |
+ AbstractType::CheckedHandle(zone, arguments->NativeArgAt(1)); |
+ const TypeArguments& instantiator_type_arguments = |
+ TypeArguments::Handle(TypeArguments::null()); |
+ ASSERT(type.IsFinalized()); |
+ ASSERT(!type.IsMalformed()); |
+ ASSERT(!type.IsMalbounded()); |
+ Error& bound_error = Error::Handle(zone, Error::null()); |
+ const bool is_instance_of = instance.IsInstanceOf(type, |
+ instantiator_type_arguments, |
+ &bound_error); |
+ if (!is_instance_of && !bound_error.IsNull()) { |
+ // Throw a dynamic type error only if the instanceof test fails. |
+ DartFrameIterator iterator; |
+ StackFrame* caller_frame = iterator.NextFrame(); |
+ ASSERT(caller_frame != NULL); |
+ const TokenPosition location = caller_frame->GetTokenPos(); |
+ String& bound_error_message = String::Handle( |
+ zone, String::New(bound_error.ToErrorCString())); |
+ Exceptions::CreateAndThrowTypeError( |
+ location, AbstractType::Handle(zone), AbstractType::Handle(zone), |
+ Symbols::Empty(), bound_error_message); |
+ UNREACHABLE(); |
+ } |
+ return Bool::Get(is_instance_of).raw(); |
+} |
DEFINE_NATIVE_ENTRY(Object_instanceOfNum, 2) { |
const Instance& instance = |