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

Side by Side Diff: runtime/vm/code_generator.cc

Issue 11570042: Implement InvocationMirror.invokeOn method in the vm (issue 7227). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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) 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/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 static bool ResolveCallThroughGetter(const Instance& receiver, 1232 static bool ResolveCallThroughGetter(const Instance& receiver,
1233 const Class& receiver_class, 1233 const Class& receiver_class,
1234 const String& target_name, 1234 const String& target_name,
1235 const Array& arguments_descriptor, 1235 const Array& arguments_descriptor,
1236 const Array& arguments, 1236 const Array& arguments,
1237 Object* result) { 1237 Object* result) {
1238 // 1. Check if there is a getter with the same name. 1238 // 1. Check if there is a getter with the same name.
1239 const String& getter_name = String::Handle(Field::GetterName(target_name)); 1239 const String& getter_name = String::Handle(Field::GetterName(target_name));
1240 const int kNumArguments = 1; 1240 const int kNumArguments = 1;
1241 const int kNumNamedArguments = 0; 1241 const int kNumNamedArguments = 0;
1242 const Function& getter = Function::ZoneHandle( 1242 const Function& getter = Function::Handle(
1243 Resolver::ResolveDynamicForReceiverClass(receiver_class, 1243 Resolver::ResolveDynamicForReceiverClass(receiver_class,
1244 getter_name, 1244 getter_name,
1245 kNumArguments, 1245 kNumArguments,
1246 kNumNamedArguments)); 1246 kNumNamedArguments));
1247 if (getter.IsNull()) return false; 1247 if (getter.IsNull()) return false;
1248 1248
1249 // 2. Invoke the getter. 1249 // 2. Invoke the getter.
1250 GrowableArray<const Object*> invoke_arguments(0); 1250 GrowableArray<const Object*> invoke_arguments(0);
1251 const Array& kNoArgumentNames = Array::Handle(); 1251 const Array& kNoArgumentNames = Array::Handle();
1252 const Object& value = 1252 const Object& value =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 const Array& arguments) { 1288 const Array& arguments) {
1289 // Allocate an InvocationMirror object. 1289 // Allocate an InvocationMirror object.
1290 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 1290 const Library& core_lib = Library::Handle(Library::CoreLibrary());
1291 const String& invocation_mirror_name = 1291 const String& invocation_mirror_name =
1292 String::Handle(Symbols::InvocationMirror()); 1292 String::Handle(Symbols::InvocationMirror());
1293 Class& invocation_mirror_class = 1293 Class& invocation_mirror_class =
1294 Class::Handle(core_lib.LookupClassAllowPrivate(invocation_mirror_name)); 1294 Class::Handle(core_lib.LookupClassAllowPrivate(invocation_mirror_name));
1295 ASSERT(!invocation_mirror_class.IsNull()); 1295 ASSERT(!invocation_mirror_class.IsNull());
1296 const String& allocation_function_name = 1296 const String& allocation_function_name =
1297 String::Handle(Symbols::AllocateInvocationMirror()); 1297 String::Handle(Symbols::AllocateInvocationMirror());
1298 const Function& allocation_function = Function::ZoneHandle( 1298 const Function& allocation_function = Function::Handle(
1299 Resolver::ResolveStaticByName(invocation_mirror_class, 1299 Resolver::ResolveStaticByName(invocation_mirror_class,
1300 allocation_function_name, 1300 allocation_function_name,
1301 Resolver::kIsQualified)); 1301 Resolver::kIsQualified));
1302 ASSERT(!allocation_function.IsNull()); 1302 ASSERT(!allocation_function.IsNull());
1303 GrowableArray<const Object*> allocation_arguments(3); 1303 GrowableArray<const Object*> allocation_arguments(3);
1304 allocation_arguments.Add(&target_name); 1304 allocation_arguments.Add(&target_name);
1305 allocation_arguments.Add(&arguments_descriptor); 1305 allocation_arguments.Add(&arguments_descriptor);
1306 allocation_arguments.Add(&arguments); 1306 allocation_arguments.Add(&arguments);
1307 const Array& kNoArgumentNames = Array::Handle(); 1307 const Array& kNoArgumentNames = Array::Handle();
1308 const Object& invocation_mirror = 1308 const Object& invocation_mirror =
1309 Object::Handle(DartEntry::InvokeStatic(allocation_function, 1309 Object::Handle(DartEntry::InvokeStatic(allocation_function,
1310 allocation_arguments, 1310 allocation_arguments,
1311 kNoArgumentNames)); 1311 kNoArgumentNames));
1312 1312
1313 const String& function_name = String::Handle(Symbols::NoSuchMethod()); 1313 const String& function_name = String::Handle(Symbols::NoSuchMethod());
1314 const int kNumArguments = 2; 1314 const int kNumArguments = 2;
1315 const int kNumNamedArguments = 0; 1315 const int kNumNamedArguments = 0;
1316 const Function& function = 1316 const Function& function = Function::Handle(
1317 Function::ZoneHandle(Resolver::ResolveDynamic(receiver, 1317 Resolver::ResolveDynamic(receiver,
1318 function_name, 1318 function_name,
1319 kNumArguments, 1319 kNumArguments,
1320 kNumNamedArguments)); 1320 kNumNamedArguments));
1321 ASSERT(!function.IsNull()); 1321 ASSERT(!function.IsNull());
1322 GrowableArray<const Object*> invoke_arguments(1); 1322 GrowableArray<const Object*> invoke_arguments(1);
1323 invoke_arguments.Add(&invocation_mirror); 1323 invoke_arguments.Add(&invocation_mirror);
1324 const Object& result = 1324 const Object& result =
1325 Object::Handle(DartEntry::InvokeDynamic(receiver, 1325 Object::Handle(DartEntry::InvokeDynamic(receiver,
1326 function, 1326 function,
1327 invoke_arguments, 1327 invoke_arguments,
1328 kNoArgumentNames)); 1328 kNoArgumentNames));
1329 CheckResultError(result); 1329 CheckResultError(result);
1330 return result.raw(); 1330 return result.raw();
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
1939 Isolate* isolate = Isolate::Current(); 1939 Isolate* isolate = Isolate::Current();
1940 StackZone zone(isolate); 1940 StackZone zone(isolate);
1941 HANDLESCOPE(isolate); 1941 HANDLESCOPE(isolate);
1942 const Bigint& big_left = Bigint::Handle(left); 1942 const Bigint& big_left = Bigint::Handle(left);
1943 const Bigint& big_right = Bigint::Handle(right); 1943 const Bigint& big_right = Bigint::Handle(right);
1944 return BigintOperations::Compare(big_left, big_right); 1944 return BigintOperations::Compare(big_left, big_right);
1945 } 1945 }
1946 END_LEAF_RUNTIME_ENTRY 1946 END_LEAF_RUNTIME_ENTRY
1947 1947
1948 } // namespace dart 1948 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698