| 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/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/exceptions.h" | 9 #include "vm/exceptions.h" |
| 10 #include "vm/heap.h" | 10 #include "vm/heap.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 dart_arguments.SetAt(3, func_args); | 81 dart_arguments.SetAt(3, func_args); |
| 82 dart_arguments.SetAt(4, func_named_args); | 82 dart_arguments.SetAt(4, func_named_args); |
| 83 | 83 |
| 84 if (is_method.value() && | 84 if (is_method.value() && |
| 85 (((invocation_type.Value() >> InvocationMirror::kCallShift) & | 85 (((invocation_type.Value() >> InvocationMirror::kCallShift) & |
| 86 InvocationMirror::kCallMask) != InvocationMirror::kSuper)) { | 86 InvocationMirror::kCallMask) != InvocationMirror::kSuper)) { |
| 87 // Report if a function with same name (but different arguments) has been | 87 // Report if a function with same name (but different arguments) has been |
| 88 // found. | 88 // found. |
| 89 Function& function = Function::Handle(); | 89 Function& function = Function::Handle(); |
| 90 if (instance.IsClosure()) { | 90 if (instance.IsClosure()) { |
| 91 function = Closure::function(instance); | 91 function = Closure::Cast(instance).function(); |
| 92 } else { | 92 } else { |
| 93 Class& instance_class = Class::Handle(instance.clazz()); | 93 Class& instance_class = Class::Handle(instance.clazz()); |
| 94 function = instance_class.LookupDynamicFunction(member_name); | 94 function = instance_class.LookupDynamicFunction(member_name); |
| 95 while (function.IsNull()) { | 95 while (function.IsNull()) { |
| 96 instance_class = instance_class.SuperClass(); | 96 instance_class = instance_class.SuperClass(); |
| 97 if (instance_class.IsNull()) break; | 97 if (instance_class.IsNull()) break; |
| 98 function = instance_class.LookupDynamicFunction(member_name); | 98 function = instance_class.LookupDynamicFunction(member_name); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 if (!function.IsNull()) { | 101 if (!function.IsNull()) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 WarnOnJSIntegralNumTypeTest(instance, instantiator_type_arguments, type); | 172 WarnOnJSIntegralNumTypeTest(instance, instantiator_type_arguments, type); |
| 173 } | 173 } |
| 174 | 174 |
| 175 Error& bound_error = Error::Handle(zone, Error::null()); | 175 Error& bound_error = Error::Handle(zone, Error::null()); |
| 176 const bool is_instance_of = instance.IsInstanceOf(type, | 176 const bool is_instance_of = instance.IsInstanceOf(type, |
| 177 instantiator_type_arguments, | 177 instantiator_type_arguments, |
| 178 &bound_error); | 178 &bound_error); |
| 179 if (FLAG_trace_type_checks) { | 179 if (FLAG_trace_type_checks) { |
| 180 const char* result_str = is_instance_of ? "true" : "false"; | 180 const char* result_str = is_instance_of ? "true" : "false"; |
| 181 OS::Print("Native Object.instanceOf: result %s\n", result_str); | 181 OS::Print("Native Object.instanceOf: result %s\n", result_str); |
| 182 const Type& instance_type = Type::Handle(instance.GetType()); | 182 const AbstractType& instance_type = |
| 183 AbstractType::Handle(instance.GetType()); |
| 183 OS::Print(" instance type: %s\n", | 184 OS::Print(" instance type: %s\n", |
| 184 String::Handle(instance_type.Name()).ToCString()); | 185 String::Handle(instance_type.Name()).ToCString()); |
| 185 OS::Print(" test type: %s\n", String::Handle(type.Name()).ToCString()); | 186 OS::Print(" test type: %s\n", String::Handle(type.Name()).ToCString()); |
| 186 if (!bound_error.IsNull()) { | 187 if (!bound_error.IsNull()) { |
| 187 OS::Print(" bound error: %s\n", bound_error.ToErrorCString()); | 188 OS::Print(" bound error: %s\n", bound_error.ToErrorCString()); |
| 188 } | 189 } |
| 189 } | 190 } |
| 190 if (!is_instance_of && !bound_error.IsNull()) { | 191 if (!is_instance_of && !bound_error.IsNull()) { |
| 191 // Throw a dynamic type error only if the instanceof test fails. | 192 // Throw a dynamic type error only if the instanceof test fails. |
| 192 DartFrameIterator iterator; | 193 DartFrameIterator iterator; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 if (FLAG_warn_on_javascript_compatibility) { | 283 if (FLAG_warn_on_javascript_compatibility) { |
| 283 WarnOnJSIntegralNumTypeTest(instance, instantiator_type_arguments, type); | 284 WarnOnJSIntegralNumTypeTest(instance, instantiator_type_arguments, type); |
| 284 } | 285 } |
| 285 | 286 |
| 286 const bool is_instance_of = instance.IsInstanceOf(type, | 287 const bool is_instance_of = instance.IsInstanceOf(type, |
| 287 instantiator_type_arguments, | 288 instantiator_type_arguments, |
| 288 &bound_error); | 289 &bound_error); |
| 289 if (FLAG_trace_type_checks) { | 290 if (FLAG_trace_type_checks) { |
| 290 const char* result_str = is_instance_of ? "true" : "false"; | 291 const char* result_str = is_instance_of ? "true" : "false"; |
| 291 OS::Print("Object.as: result %s\n", result_str); | 292 OS::Print("Object.as: result %s\n", result_str); |
| 292 const Type& instance_type = Type::Handle(instance.GetType()); | 293 const AbstractType& instance_type = |
| 294 AbstractType::Handle(instance.GetType()); |
| 293 OS::Print(" instance type: %s\n", | 295 OS::Print(" instance type: %s\n", |
| 294 String::Handle(instance_type.Name()).ToCString()); | 296 String::Handle(instance_type.Name()).ToCString()); |
| 295 OS::Print(" cast type: %s\n", String::Handle(type.Name()).ToCString()); | 297 OS::Print(" cast type: %s\n", String::Handle(type.Name()).ToCString()); |
| 296 if (!bound_error.IsNull()) { | 298 if (!bound_error.IsNull()) { |
| 297 OS::Print(" bound error: %s\n", bound_error.ToErrorCString()); | 299 OS::Print(" bound error: %s\n", bound_error.ToErrorCString()); |
| 298 } | 300 } |
| 299 } | 301 } |
| 300 if (!is_instance_of) { | 302 if (!is_instance_of) { |
| 301 DartFrameIterator iterator; | 303 DartFrameIterator iterator; |
| 302 StackFrame* caller_frame = iterator.NextFrame(); | 304 StackFrame* caller_frame = iterator.NextFrame(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 383 |
| 382 DEFINE_NATIVE_ENTRY(Internal_inquireIs64Bit, 0) { | 384 DEFINE_NATIVE_ENTRY(Internal_inquireIs64Bit, 0) { |
| 383 #if defined(ARCH_IS_64_BIT) | 385 #if defined(ARCH_IS_64_BIT) |
| 384 return Bool::True().raw(); | 386 return Bool::True().raw(); |
| 385 #else | 387 #else |
| 386 return Bool::False().raw(); | 388 return Bool::False().raw(); |
| 387 #endif // defined(ARCH_IS_64_BIT) | 389 #endif // defined(ARCH_IS_64_BIT) |
| 388 } | 390 } |
| 389 | 391 |
| 390 } // namespace dart | 392 } // namespace dart |
| OLD | NEW |