Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Side by Side Diff: runtime/lib/object.cc

Issue 14652008: Fix error reporting when calling static methods and closures withh mismatched arguments. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "vm/stack_frame.h" 10 #include "vm/stack_frame.h"
(...skipping 22 matching lines...) Expand all
33 const Array& dart_arguments = Array::Handle(Array::New(6)); 33 const Array& dart_arguments = Array::Handle(Array::New(6));
34 dart_arguments.SetAt(0, instance); 34 dart_arguments.SetAt(0, instance);
35 dart_arguments.SetAt(1, member_name); 35 dart_arguments.SetAt(1, member_name);
36 dart_arguments.SetAt(2, invocation_type); 36 dart_arguments.SetAt(2, invocation_type);
37 dart_arguments.SetAt(3, func_args); 37 dart_arguments.SetAt(3, func_args);
38 dart_arguments.SetAt(4, func_named_args); 38 dart_arguments.SetAt(4, func_named_args);
39 39
40 if (is_method.value()) { 40 if (is_method.value()) {
41 // Report if a function with same name (but different arguments) has been 41 // Report if a function with same name (but different arguments) has been
42 // found. 42 // found.
43 Class& instance_class = Class::Handle(instance.clazz()); 43 Function& function = Function::Handle();
44 Function& function = 44 if (instance.IsClosure()) {
45 Function::Handle(instance_class.LookupDynamicFunction(member_name)); 45 function = Closure::function(instance);
46 while (function.IsNull()) { 46 } else {
47 instance_class = instance_class.SuperClass(); 47 Class& instance_class = Class::Handle(instance.clazz());
48 if (instance_class.IsNull()) break;
49 function = instance_class.LookupDynamicFunction(member_name); 48 function = instance_class.LookupDynamicFunction(member_name);
49 while (function.IsNull()) {
50 instance_class = instance_class.SuperClass();
51 if (instance_class.IsNull()) break;
52 function = instance_class.LookupDynamicFunction(member_name);
53 }
50 } 54 }
51 if (!function.IsNull()) { 55 if (!function.IsNull()) {
52 const int total_num_parameters = function.NumParameters(); 56 const int total_num_parameters = function.NumParameters();
53 const Array& array = Array::Handle(Array::New(total_num_parameters - 1)); 57 const Array& array = Array::Handle(Array::New(total_num_parameters - 1));
54 // Skip receiver. 58 // Skip receiver.
55 for (int i = 1; i < total_num_parameters; i++) { 59 for (int i = 1; i < total_num_parameters; i++) {
56 array.SetAt(i - 1, String::Handle(function.ParameterNameAt(i))); 60 array.SetAt(i - 1, String::Handle(function.ParameterNameAt(i)));
57 } 61 }
58 dart_arguments.SetAt(5, array); 62 dart_arguments.SetAt(5, array);
59 } 63 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 166 }
163 167
164 168
165 DEFINE_NATIVE_ENTRY(AbstractType_toString, 1) { 169 DEFINE_NATIVE_ENTRY(AbstractType_toString, 1) {
166 const AbstractType& type = 170 const AbstractType& type =
167 AbstractType::CheckedHandle(arguments->NativeArgAt(0)); 171 AbstractType::CheckedHandle(arguments->NativeArgAt(0));
168 return type.UserVisibleName(); 172 return type.UserVisibleName();
169 } 173 }
170 174
171 } // namespace dart 175 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698