| 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 "vm/code_generator.h" | 5 #include "vm/code_generator.h" |
| 6 | 6 |
| 7 #include "vm/assembler_macros.h" | 7 #include "vm/assembler_macros.h" |
| 8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
| 9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 // Arg2: original arguments descriptor array. | 1275 // Arg2: original arguments descriptor array. |
| 1276 // Arg3: original arguments array. | 1276 // Arg3: original arguments array. |
| 1277 DEFINE_RUNTIME_ENTRY(InvokeNoSuchMethodFunction, 4) { | 1277 DEFINE_RUNTIME_ENTRY(InvokeNoSuchMethodFunction, 4) { |
| 1278 ASSERT(arguments.Count() == | 1278 ASSERT(arguments.Count() == |
| 1279 kInvokeNoSuchMethodFunctionRuntimeEntry.argument_count()); | 1279 kInvokeNoSuchMethodFunctionRuntimeEntry.argument_count()); |
| 1280 const Instance& receiver = Instance::CheckedHandle(arguments.At(0)); | 1280 const Instance& receiver = Instance::CheckedHandle(arguments.At(0)); |
| 1281 const ICData& ic_data = ICData::CheckedHandle(arguments.At(1)); | 1281 const ICData& ic_data = ICData::CheckedHandle(arguments.At(1)); |
| 1282 const String& original_function_name = String::Handle(ic_data.target_name()); | 1282 const String& original_function_name = String::Handle(ic_data.target_name()); |
| 1283 ASSERT(!Array::CheckedHandle(arguments.At(2)).IsNull()); | 1283 ASSERT(!Array::CheckedHandle(arguments.At(2)).IsNull()); |
| 1284 const Array& orig_arguments = Array::CheckedHandle(arguments.At(3)); | 1284 const Array& orig_arguments = Array::CheckedHandle(arguments.At(3)); |
| 1285 // Allocate an InvocationMirror object. | 1285 // TODO(regis): The signature of the "noSuchMethod" method has to change from |
| 1286 // TODO(regis): Fill in the InvocationMirror object correctly at | 1286 // noSuchMethod(String name, Array arguments) to something like |
| 1287 // this point we do not deal with named arguments and treat them | 1287 // noSuchMethod(InvocationMirror call). |
| 1288 // all as positional. | 1288 const int kNumArguments = 3; |
| 1289 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 1289 const int kNumNamedArguments = 0; |
| 1290 const String& invocation_mirror_name = String::Handle( | |
| 1291 Symbols::InvocationMirror()); | |
| 1292 Class& invocation_mirror_class = Class::Handle( | |
| 1293 core_lib.LookupClassAllowPrivate(invocation_mirror_name)); | |
| 1294 ASSERT(!invocation_mirror_class.IsNull()); | |
| 1295 const String& allocation_function_name = String::Handle( | |
| 1296 Symbols::AllocateInvocationMirror()); | |
| 1297 const Function& allocation_function = Function::ZoneHandle( | |
| 1298 Resolver::ResolveStaticByName(invocation_mirror_class, | |
| 1299 allocation_function_name, | |
| 1300 Resolver::kIsQualified)); | |
| 1301 ASSERT(!allocation_function.IsNull()); | |
| 1302 GrowableArray<const Object*> allocation_arguments(2); | |
| 1303 allocation_arguments.Add(&original_function_name); | |
| 1304 allocation_arguments.Add(&orig_arguments); | |
| 1305 const Array& kNoArgumentNames = Array::Handle(); | 1290 const Array& kNoArgumentNames = Array::Handle(); |
| 1306 const Object& invocation_mirror = Object::Handle( | 1291 const String& function_name = |
| 1307 DartEntry::InvokeStatic(allocation_function, | 1292 String::Handle(Symbols::NoSuchMethod()); |
| 1308 allocation_arguments, | |
| 1309 kNoArgumentNames)); | |
| 1310 | |
| 1311 const int kNumArguments = 2; | |
| 1312 const int kNumNamedArguments = 0; | |
| 1313 const String& function_name = String::Handle(Symbols::NoSuchMethod()); | |
| 1314 const Function& function = Function::ZoneHandle( | 1293 const Function& function = Function::ZoneHandle( |
| 1315 Resolver::ResolveDynamic(receiver, | 1294 Resolver::ResolveDynamic(receiver, |
| 1316 function_name, | 1295 function_name, |
| 1317 kNumArguments, | 1296 kNumArguments, |
| 1318 kNumNamedArguments)); | 1297 kNumNamedArguments)); |
| 1319 ASSERT(!function.IsNull()); | 1298 ASSERT(!function.IsNull()); |
| 1320 GrowableArray<const Object*> invoke_arguments(1); | 1299 GrowableArray<const Object*> invoke_arguments(2); |
| 1321 invoke_arguments.Add(&invocation_mirror); | 1300 invoke_arguments.Add(&original_function_name); |
| 1301 invoke_arguments.Add(&orig_arguments); |
| 1322 const Object& result = Object::Handle( | 1302 const Object& result = Object::Handle( |
| 1323 DartEntry::InvokeDynamic(receiver, | 1303 DartEntry::InvokeDynamic(receiver, |
| 1324 function, | 1304 function, |
| 1325 invoke_arguments, | 1305 invoke_arguments, |
| 1326 kNoArgumentNames)); | 1306 kNoArgumentNames)); |
| 1327 CheckResultError(result); | 1307 CheckResultError(result); |
| 1328 arguments.SetReturn(result); | 1308 arguments.SetReturn(result); |
| 1329 } | 1309 } |
| 1330 | 1310 |
| 1331 | 1311 |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1824 intptr_t line, column; | 1804 intptr_t line, column; |
| 1825 script.GetTokenLocation(token_pos, &line, &column); | 1805 script.GetTokenLocation(token_pos, &line, &column); |
| 1826 String& line_string = String::Handle(script.GetLine(line)); | 1806 String& line_string = String::Handle(script.GetLine(line)); |
| 1827 OS::Print(" Function: %s\n", top_function.ToFullyQualifiedCString()); | 1807 OS::Print(" Function: %s\n", top_function.ToFullyQualifiedCString()); |
| 1828 OS::Print(" Line %"Pd": '%s'\n", line, line_string.ToCString()); | 1808 OS::Print(" Line %"Pd": '%s'\n", line, line_string.ToCString()); |
| 1829 } | 1809 } |
| 1830 } | 1810 } |
| 1831 | 1811 |
| 1832 | 1812 |
| 1833 } // namespace dart | 1813 } // namespace dart |
| OLD | NEW |