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 // TODO(regis): The signature of the "noSuchMethod" method has to change from | 1285 // Allocate an InvocationMirror object. |
1286 // noSuchMethod(String name, Array arguments) to something like | 1286 // TODO(regis): Fill in the InvocationMirror object correctly at |
1287 // noSuchMethod(InvocationMirror call). | 1287 // this point we do not deal with named arguments and treat them |
1288 const int kNumArguments = 3; | 1288 // all as positional. |
| 1289 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 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(); |
| 1306 const Object& invocation_mirror = Object::Handle( |
| 1307 DartEntry::InvokeStatic(allocation_function, |
| 1308 allocation_arguments, |
| 1309 kNoArgumentNames)); |
| 1310 |
| 1311 const int kNumArguments = 2; |
1289 const int kNumNamedArguments = 0; | 1312 const int kNumNamedArguments = 0; |
1290 const Array& kNoArgumentNames = Array::Handle(); | 1313 const String& function_name = String::Handle(Symbols::NoSuchMethod()); |
1291 const String& function_name = | |
1292 String::Handle(Symbols::NoSuchMethod()); | |
1293 const Function& function = Function::ZoneHandle( | 1314 const Function& function = Function::ZoneHandle( |
1294 Resolver::ResolveDynamic(receiver, | 1315 Resolver::ResolveDynamic(receiver, |
1295 function_name, | 1316 function_name, |
1296 kNumArguments, | 1317 kNumArguments, |
1297 kNumNamedArguments)); | 1318 kNumNamedArguments)); |
1298 ASSERT(!function.IsNull()); | 1319 ASSERT(!function.IsNull()); |
1299 GrowableArray<const Object*> invoke_arguments(2); | 1320 GrowableArray<const Object*> invoke_arguments(1); |
1300 invoke_arguments.Add(&original_function_name); | 1321 invoke_arguments.Add(&invocation_mirror); |
1301 invoke_arguments.Add(&orig_arguments); | |
1302 const Object& result = Object::Handle( | 1322 const Object& result = Object::Handle( |
1303 DartEntry::InvokeDynamic(receiver, | 1323 DartEntry::InvokeDynamic(receiver, |
1304 function, | 1324 function, |
1305 invoke_arguments, | 1325 invoke_arguments, |
1306 kNoArgumentNames)); | 1326 kNoArgumentNames)); |
1307 CheckResultError(result); | 1327 CheckResultError(result); |
1308 arguments.SetReturn(result); | 1328 arguments.SetReturn(result); |
1309 } | 1329 } |
1310 | 1330 |
1311 | 1331 |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1803 intptr_t line, column; | 1823 intptr_t line, column; |
1804 script.GetTokenLocation(token_pos, &line, &column); | 1824 script.GetTokenLocation(token_pos, &line, &column); |
1805 String& line_string = String::Handle(script.GetLine(line)); | 1825 String& line_string = String::Handle(script.GetLine(line)); |
1806 OS::Print(" Function: %s\n", top_function.ToFullyQualifiedCString()); | 1826 OS::Print(" Function: %s\n", top_function.ToFullyQualifiedCString()); |
1807 OS::Print(" Line %"Pd": '%s'\n", line, line_string.ToCString()); | 1827 OS::Print(" Line %"Pd": '%s'\n", line, line_string.ToCString()); |
1808 } | 1828 } |
1809 } | 1829 } |
1810 | 1830 |
1811 | 1831 |
1812 } // namespace dart | 1832 } // namespace dart |
OLD | NEW |