Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
| 6 | 6 |
| 7 #include "vm/exceptions.h" | 7 #include "vm/exceptions.h" |
| 8 #include "vm/native_entry.h" | 8 #include "vm/native_entry.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 } | 56 } |
| 57 | 57 |
| 58 | 58 |
| 59 DEFINE_NATIVE_ENTRY(Object_runtimeType, 1) { | 59 DEFINE_NATIVE_ENTRY(Object_runtimeType, 1) { |
| 60 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); | 60 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); |
| 61 const Type& type = Type::Handle(instance.GetType()); | 61 const Type& type = Type::Handle(instance.GetType()); |
| 62 return type.Canonicalize(); | 62 return type.Canonicalize(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 | 65 |
| 66 DEFINE_NATIVE_ENTRY(Object_instanceOf, 5) { | |
| 67 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); | |
| 68 // Instantiator at pos 1 is not used. | |
|
regis
2012/12/28 19:46:49
Do you need it for type feedback? Also, a comment
srdjan
2013/01/02 20:38:46
Added comment:
// Instantiator at position 1 is
| |
| 69 const AbstractTypeArguments& instantiator_type_arguments = | |
| 70 AbstractTypeArguments::CheckedHandle(arguments->NativeArgAt(2)); | |
| 71 const AbstractType& type = | |
| 72 AbstractType::CheckedHandle(arguments->NativeArgAt(3)); | |
| 73 const Bool& negate = Bool::CheckedHandle(arguments->NativeArgAt(4)); | |
| 74 ASSERT(type.IsFinalized()); | |
| 75 Error& malformed_error = Error::Handle(); | |
| 76 const bool is_instance_of = instance.IsInstanceOf(type, | |
| 77 instantiator_type_arguments, | |
| 78 &malformed_error); | |
| 79 ASSERT(malformed_error.IsNull()); | |
|
regis
2012/12/28 19:46:49
Instantiating a type with a type argument that is
srdjan
2013/01/02 20:38:46
Fixed.
| |
| 80 if (negate.value()) { | |
| 81 return is_instance_of ? Bool::False() : Bool::True(); | |
| 82 } else { | |
| 83 return is_instance_of ? Bool::True() : Bool::False(); | |
| 84 } | |
| 85 } | |
| 86 | |
| 87 | |
| 66 DEFINE_NATIVE_ENTRY(AbstractType_toString, 1) { | 88 DEFINE_NATIVE_ENTRY(AbstractType_toString, 1) { |
| 67 const AbstractType& type = | 89 const AbstractType& type = |
| 68 AbstractType::CheckedHandle(arguments->NativeArgAt(0)); | 90 AbstractType::CheckedHandle(arguments->NativeArgAt(0)); |
| 69 return type.UserVisibleName(); | 91 return type.UserVisibleName(); |
| 70 } | 92 } |
| 71 | 93 |
| 72 } // namespace dart | 94 } // namespace dart |
| OLD | NEW |