| 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 11 matching lines...) Expand all Loading... |
| 22 if (instance.IsNull()) { | 22 if (instance.IsNull()) { |
| 23 GrowableArray<const Object*> args; | 23 GrowableArray<const Object*> args; |
| 24 Exceptions::ThrowByType(Exceptions::kNullPointer, args); | 24 Exceptions::ThrowByType(Exceptions::kNullPointer, args); |
| 25 } | 25 } |
| 26 GET_NATIVE_ARGUMENT(String, function_name, arguments->At(1)); | 26 GET_NATIVE_ARGUMENT(String, function_name, arguments->At(1)); |
| 27 GET_NATIVE_ARGUMENT(Array, func_args, arguments->At(2)); | 27 GET_NATIVE_ARGUMENT(Array, func_args, arguments->At(2)); |
| 28 GrowableArray<const Object*> dart_arguments(3); | 28 GrowableArray<const Object*> dart_arguments(3); |
| 29 dart_arguments.Add(&instance); | 29 dart_arguments.Add(&instance); |
| 30 dart_arguments.Add(&function_name); | 30 dart_arguments.Add(&function_name); |
| 31 dart_arguments.Add(&func_args); | 31 dart_arguments.Add(&func_args); |
| 32 // Report if a function with same name (but different arguments) has been |
| 33 // found. |
| 34 Class& instance_class = Class::Handle(instance.clazz()); |
| 35 Function& function = |
| 36 Function::Handle(instance_class.LookupDynamicFunction(function_name)); |
| 37 while (function.IsNull()) { |
| 38 instance_class = instance_class.SuperClass(); |
| 39 if (instance_class.IsNull()) break; |
| 40 function = instance_class.LookupDynamicFunction(function_name); |
| 41 } |
| 42 if (!function.IsNull()) { |
| 43 String& tmp = String::Handle(); |
| 44 String& extra_message = String::Handle(); |
| 45 tmp = String::NewSymbol("\nFound '"); |
| 46 extra_message = String::Concat(tmp, function_name); |
| 47 tmp = String::NewSymbol("("); |
| 48 extra_message = String::Concat(extra_message, tmp); |
| 49 const int total_num_paramaters = |
| 50 function.num_fixed_parameters() + function.num_optional_parameters(); |
| 51 // 0 is the receiver ('this'), skip it. |
| 52 for (int i = 1; i < total_num_paramaters; i++) { |
| 53 if (i > 1) { |
| 54 tmp = String::NewSymbol(", "); |
| 55 extra_message = String::Concat(extra_message, tmp); |
| 56 } |
| 57 tmp = function.ParameterNameAt(i); |
| 58 extra_message = String::Concat(extra_message, tmp); |
| 59 } |
| 60 tmp = String::NewSymbol(")'"); |
| 61 extra_message = String::Concat(extra_message, tmp); |
| 62 dart_arguments.Add(&extra_message); |
| 63 } |
| 32 Exceptions::ThrowByType(Exceptions::kNoSuchMethod, dart_arguments); | 64 Exceptions::ThrowByType(Exceptions::kNoSuchMethod, dart_arguments); |
| 33 } | 65 } |
| 34 | 66 |
| 35 } // namespace dart | 67 } // namespace dart |
| OLD | NEW |