| 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 "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/exceptions.h" | 8 #include "vm/exceptions.h" |
| 9 #include "vm/heap.h" | 9 #include "vm/heap.h" |
| 10 #include "vm/native_entry.h" | 10 #include "vm/native_entry.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 ASSERT(!instance.IsString() && !instance.IsInteger() && !instance.IsDouble()); | 107 ASSERT(!instance.IsString() && !instance.IsInteger() && !instance.IsDouble()); |
| 108 return instance.GetType(); | 108 return instance.GetType(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 | 111 |
| 112 DEFINE_NATIVE_ENTRY(Object_instanceOf, 5) { | 112 DEFINE_NATIVE_ENTRY(Object_instanceOf, 5) { |
| 113 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); | 113 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); |
| 114 // Instantiator at position 1 is not used. It is passed along so that the call | 114 // Instantiator at position 1 is not used. It is passed along so that the call |
| 115 // can be easily converted to an optimized implementation. Instantiator is | 115 // can be easily converted to an optimized implementation. Instantiator is |
| 116 // used to populate the subtype cache. | 116 // used to populate the subtype cache. |
| 117 const AbstractTypeArguments& instantiator_type_arguments = | 117 const TypeArguments& instantiator_type_arguments = |
| 118 AbstractTypeArguments::CheckedHandle(arguments->NativeArgAt(2)); | 118 TypeArguments::CheckedHandle(arguments->NativeArgAt(2)); |
| 119 const AbstractType& type = | 119 const AbstractType& type = |
| 120 AbstractType::CheckedHandle(arguments->NativeArgAt(3)); | 120 AbstractType::CheckedHandle(arguments->NativeArgAt(3)); |
| 121 const Bool& negate = Bool::CheckedHandle(arguments->NativeArgAt(4)); | 121 const Bool& negate = Bool::CheckedHandle(arguments->NativeArgAt(4)); |
| 122 ASSERT(type.IsFinalized()); | 122 ASSERT(type.IsFinalized()); |
| 123 ASSERT(!type.IsMalformed()); | 123 ASSERT(!type.IsMalformed()); |
| 124 ASSERT(!type.IsMalbounded()); | 124 ASSERT(!type.IsMalbounded()); |
| 125 Error& bound_error = Error::Handle(); | 125 Error& bound_error = Error::Handle(); |
| 126 const bool is_instance_of = instance.IsInstanceOf(type, | 126 const bool is_instance_of = instance.IsInstanceOf(type, |
| 127 instantiator_type_arguments, | 127 instantiator_type_arguments, |
| 128 &bound_error); | 128 &bound_error); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 152 } | 152 } |
| 153 return Bool::Get(negate.value() ? !is_instance_of : is_instance_of).raw(); | 153 return Bool::Get(negate.value() ? !is_instance_of : is_instance_of).raw(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 | 156 |
| 157 DEFINE_NATIVE_ENTRY(Object_as, 4) { | 157 DEFINE_NATIVE_ENTRY(Object_as, 4) { |
| 158 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); | 158 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); |
| 159 // Instantiator at position 1 is not used. It is passed along so that the call | 159 // Instantiator at position 1 is not used. It is passed along so that the call |
| 160 // can be easily converted to an optimized implementation. Instantiator is | 160 // can be easily converted to an optimized implementation. Instantiator is |
| 161 // used to populate the subtype cache. | 161 // used to populate the subtype cache. |
| 162 const AbstractTypeArguments& instantiator_type_arguments = | 162 const TypeArguments& instantiator_type_arguments = |
| 163 AbstractTypeArguments::CheckedHandle(arguments->NativeArgAt(2)); | 163 TypeArguments::CheckedHandle(arguments->NativeArgAt(2)); |
| 164 const AbstractType& type = | 164 const AbstractType& type = |
| 165 AbstractType::CheckedHandle(arguments->NativeArgAt(3)); | 165 AbstractType::CheckedHandle(arguments->NativeArgAt(3)); |
| 166 ASSERT(type.IsFinalized()); | 166 ASSERT(type.IsFinalized()); |
| 167 ASSERT(!type.IsMalformed()); | 167 ASSERT(!type.IsMalformed()); |
| 168 ASSERT(!type.IsMalbounded()); | 168 ASSERT(!type.IsMalbounded()); |
| 169 Error& bound_error = Error::Handle(); | 169 Error& bound_error = Error::Handle(); |
| 170 if (instance.IsNull()) { | 170 if (instance.IsNull()) { |
| 171 return instance.raw(); | 171 return instance.raw(); |
| 172 } | 172 } |
| 173 const bool is_instance_of = instance.IsInstanceOf(type, | 173 const bool is_instance_of = instance.IsInstanceOf(type, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 224 } |
| 225 | 225 |
| 226 | 226 |
| 227 DEFINE_NATIVE_ENTRY(AbstractType_toString, 1) { | 227 DEFINE_NATIVE_ENTRY(AbstractType_toString, 1) { |
| 228 const AbstractType& type = | 228 const AbstractType& type = |
| 229 AbstractType::CheckedHandle(arguments->NativeArgAt(0)); | 229 AbstractType::CheckedHandle(arguments->NativeArgAt(0)); |
| 230 return type.UserVisibleName(); | 230 return type.UserVisibleName(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace dart | 233 } // namespace dart |
| OLD | NEW |