| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_debugger_api.h" | 6 #include "include/dart_debugger_api.h" |
| 7 #include "include/dart_mirrors_api.h" | 7 #include "include/dart_mirrors_api.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_api_state.h" // TODO(11742): Remove with CreateMirrorRef. | 9 #include "vm/dart_api_state.h" // TODO(11742): Remove with CreateMirrorRef. |
| 10 #include "vm/bootstrap_natives.h" | 10 #include "vm/bootstrap_natives.h" |
| (...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 const Instance& reflectee = | 1303 const Instance& reflectee = |
| 1304 Instance::CheckedHandle(arguments->NativeArgAt(1)); | 1304 Instance::CheckedHandle(arguments->NativeArgAt(1)); |
| 1305 | 1305 |
| 1306 const String& function_name = | 1306 const String& function_name = |
| 1307 String::CheckedHandle(arguments->NativeArgAt(2)); | 1307 String::CheckedHandle(arguments->NativeArgAt(2)); |
| 1308 | 1308 |
| 1309 const Array& positional_args = | 1309 const Array& positional_args = |
| 1310 Array::CheckedHandle(arguments->NativeArgAt(3)); | 1310 Array::CheckedHandle(arguments->NativeArgAt(3)); |
| 1311 intptr_t number_of_arguments = positional_args.Length(); | 1311 intptr_t number_of_arguments = positional_args.Length(); |
| 1312 | 1312 |
| 1313 | |
| 1314 const intptr_t num_receiver = 1; // 1 for instance methods | |
| 1315 const Array& args = | 1313 const Array& args = |
| 1316 Array::Handle(Array::New(number_of_arguments + num_receiver)); | 1314 Array::Handle(Array::New(number_of_arguments + 1)); // Plus receiver. |
| 1317 Object& arg = Object::Handle(); | 1315 Object& arg = Object::Handle(); |
| 1318 args.SetAt(0, reflectee); | 1316 args.SetAt(0, reflectee); |
| 1319 for (int i = 0; i < number_of_arguments; i++) { | 1317 for (int i = 0; i < number_of_arguments; i++) { |
| 1320 arg = positional_args.At(i); | 1318 arg = positional_args.At(i); |
| 1321 args.SetAt((i + num_receiver), arg); | 1319 args.SetAt(i + 1, arg); // Plus receiver. |
| 1322 } | 1320 } |
| 1323 | 1321 |
| 1322 ArgumentsDescriptor args_desc( |
| 1323 Array::Handle(ArgumentsDescriptor::New(args.Length()))); |
| 1324 // TODO(11771): This won't find private members. | 1324 // TODO(11771): This won't find private members. |
| 1325 const Function& function = Function::Handle( | 1325 const Function& function = Function::Handle( |
| 1326 Resolver::ResolveDynamic(reflectee, | 1326 Resolver::ResolveDynamic(reflectee, |
| 1327 function_name, | 1327 function_name, |
| 1328 (number_of_arguments + 1), | 1328 args_desc)); |
| 1329 Resolver::kIsQualified)); | |
| 1330 | 1329 |
| 1331 return ReflectivelyInvokeDynamicFunction(reflectee, | 1330 return ReflectivelyInvokeDynamicFunction(reflectee, |
| 1332 function, | 1331 function, |
| 1333 function_name, | 1332 function_name, |
| 1334 args); | 1333 args); |
| 1335 } | 1334 } |
| 1336 | 1335 |
| 1337 | 1336 |
| 1338 DEFINE_NATIVE_ENTRY(InstanceMirror_invokeGetter, 3) { | 1337 DEFINE_NATIVE_ENTRY(InstanceMirror_invokeGetter, 3) { |
| 1339 // Argument 0 is the mirror, which is unused by the native. It exists | 1338 // Argument 0 is the mirror, which is unused by the native. It exists |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1818 | 1817 |
| 1819 DEFINE_NATIVE_ENTRY(MethodMirror_name, 1) { | 1818 DEFINE_NATIVE_ENTRY(MethodMirror_name, 1) { |
| 1820 const MirrorReference& func_ref = | 1819 const MirrorReference& func_ref = |
| 1821 MirrorReference::CheckedHandle(arguments->NativeArgAt(0)); | 1820 MirrorReference::CheckedHandle(arguments->NativeArgAt(0)); |
| 1822 Function& func = Function::Handle(); | 1821 Function& func = Function::Handle(); |
| 1823 func ^= func_ref.referent(); | 1822 func ^= func_ref.referent(); |
| 1824 return func.UserVisibleName(); | 1823 return func.UserVisibleName(); |
| 1825 } | 1824 } |
| 1826 | 1825 |
| 1827 } // namespace dart | 1826 } // namespace dart |
| OLD | NEW |