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

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

Issue 169893003: Another round of cleanups for http://www.dartbug.com/15922 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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) 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 "lib/invocation_mirror.h" 5 #include "lib/invocation_mirror.h"
6 #include "vm/bootstrap_natives.h" 6 #include "vm/bootstrap_natives.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 const Array& args = Array::Handle(Array::New(6)); 76 const Array& args = Array::Handle(Array::New(6));
77 args.SetAt(0, receiver); 77 args.SetAt(0, receiver);
78 args.SetAt(1, function_name); 78 args.SetAt(1, function_name);
79 args.SetAt(2, invocation_type); 79 args.SetAt(2, invocation_type);
80 // Parameter 3 (actual arguments): We omit this parameter to get the same 80 // Parameter 3 (actual arguments): We omit this parameter to get the same
81 // error message as one would get by invoking the function non-reflectively. 81 // error message as one would get by invoking the function non-reflectively.
82 // Parameter 4 (named arguments): We omit this parameters since we cannot 82 // Parameter 4 (named arguments): We omit this parameters since we cannot
83 // invoke functions with named parameters reflectively (using mirrors). 83 // invoke functions with named parameters reflectively (using mirrors).
84 if (!function.IsNull()) { 84 if (!function.IsNull()) {
85 const int total_num_parameters = function.NumParameters(); 85 const intptr_t total_num_parameters = function.NumParameters();
86 const Array& array = Array::Handle(Array::New(total_num_parameters)); 86 const Array& array = Array::Handle(Array::New(total_num_parameters));
87 String& param_name = String::Handle(); 87 String& param_name = String::Handle();
88 for (int i = 0; i < total_num_parameters; i++) { 88 for (int i = 0; i < total_num_parameters; i++) {
89 param_name = function.ParameterNameAt(i); 89 param_name = function.ParameterNameAt(i);
90 array.SetAt(i, param_name); 90 array.SetAt(i, param_name);
91 } 91 }
92 args.SetAt(5, array); 92 args.SetAt(5, array);
93 } 93 }
94 94
95 Exceptions::ThrowByType(Exceptions::kNoSuchMethod, args); 95 Exceptions::ThrowByType(Exceptions::kNoSuchMethod, args);
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 args.SetAt(1, root_library_mirror); 426 args.SetAt(1, root_library_mirror);
427 return CreateMirror(Symbols::_LocalIsolateMirror(), args); 427 return CreateMirror(Symbols::_LocalIsolateMirror(), args);
428 } 428 }
429 429
430 430
431 static RawInstance* CreateMirrorSystem() { 431 static RawInstance* CreateMirrorSystem() {
432 Isolate* isolate = Isolate::Current(); 432 Isolate* isolate = Isolate::Current();
433 const GrowableObjectArray& libraries = 433 const GrowableObjectArray& libraries =
434 GrowableObjectArray::Handle(isolate->object_store()->libraries()); 434 GrowableObjectArray::Handle(isolate->object_store()->libraries());
435 435
436 const int num_libraries = libraries.Length(); 436 const intptr_t num_libraries = libraries.Length();
437 const Array& library_mirrors = Array::Handle(Array::New(num_libraries)); 437 const Array& library_mirrors = Array::Handle(Array::New(num_libraries));
438 Library& library = Library::Handle(); 438 Library& library = Library::Handle();
439 Instance& library_mirror = Instance::Handle(); 439 Instance& library_mirror = Instance::Handle();
440 440
441 for (int i = 0; i < num_libraries; i++) { 441 for (int i = 0; i < num_libraries; i++) {
442 library ^= libraries.At(i); 442 library ^= libraries.At(i);
443 library_mirror = CreateLibraryMirror(library); 443 library_mirror = CreateLibraryMirror(library);
444 library_mirrors.SetAt(i, library_mirror); 444 library_mirrors.SetAt(i, library_mirror);
445 } 445 }
446 446
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 if (!closure.IsClosure()) { 1474 if (!closure.IsClosure()) {
1475 const Array& result_tuple = Array::Handle(Array::New(2)); 1475 const Array& result_tuple = Array::Handle(Array::New(2));
1476 result_tuple.SetAt(0, Bool::False()); 1476 result_tuple.SetAt(0, Bool::False());
1477 return result_tuple.raw(); 1477 return result_tuple.raw();
1478 } 1478 }
1479 1479
1480 Function& function = Function::Handle(); 1480 Function& function = Function::Handle();
1481 const bool callable = closure.IsCallable(&function, NULL); 1481 const bool callable = closure.IsCallable(&function, NULL);
1482 ASSERT(callable); 1482 ASSERT(callable);
1483 1483
1484 const int parts_len = lookup_parts.Length(); 1484 const intptr_t parts_len = lookup_parts.Length();
1485 // Lookup name is always the last part. 1485 // Lookup name is always the last part.
1486 const String& lookup_name = String::Handle(String::RawCast( 1486 const String& lookup_name = String::Handle(String::RawCast(
1487 lookup_parts.At(parts_len - 1))); 1487 lookup_parts.At(parts_len - 1)));
1488 1488
1489 String& part_name = String::Handle(); 1489 String& part_name = String::Handle();
1490 Class& owner = Class::Handle(function.Owner()); 1490 Class& owner = Class::Handle(function.Owner());
1491 LibraryPrefix& prefix = LibraryPrefix::Handle(); 1491 LibraryPrefix& prefix = LibraryPrefix::Handle();
1492 Library& this_library = Library::Handle(owner.library()); 1492 Library& this_library = Library::Handle(owner.library());
1493 Instance& result = Instance::Handle(Object::sentinel().raw()); 1493 Instance& result = Instance::Handle(Object::sentinel().raw());
1494 if (parts_len == 1) { 1494 if (parts_len == 1) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 function = klass.LookupStaticFunction(getter_name); 1580 function = klass.LookupStaticFunction(getter_name);
1581 if (!function.IsNull()) { 1581 if (!function.IsNull()) {
1582 // Invoke the getter. 1582 // Invoke the getter.
1583 const Object& getter_result = Object::Handle( 1583 const Object& getter_result = Object::Handle(
1584 DartEntry::InvokeFunction(function, Object::empty_array())); 1584 DartEntry::InvokeFunction(function, Object::empty_array()));
1585 if (getter_result.IsError()) { 1585 if (getter_result.IsError()) {
1586 ThrowInvokeError(Error::Cast(getter_result)); 1586 ThrowInvokeError(Error::Cast(getter_result));
1587 UNREACHABLE(); 1587 UNREACHABLE();
1588 } 1588 }
1589 // Make room for the closure (receiver) in the argument list. 1589 // Make room for the closure (receiver) in the argument list.
1590 int numArgs = args.Length(); 1590 intptr_t numArgs = args.Length();
1591 const Array& call_args = Array::Handle(Array::New(numArgs + 1)); 1591 const Array& call_args = Array::Handle(Array::New(numArgs + 1));
1592 Object& temp = Object::Handle(); 1592 Object& temp = Object::Handle();
1593 for (int i = 0; i < numArgs; i++) { 1593 for (int i = 0; i < numArgs; i++) {
1594 temp = args.At(i); 1594 temp = args.At(i);
1595 call_args.SetAt(i + 1, temp); 1595 call_args.SetAt(i + 1, temp);
1596 } 1596 }
1597 call_args.SetAt(0, getter_result); 1597 call_args.SetAt(0, getter_result);
1598 const Array& call_args_descriptor_array = 1598 const Array& call_args_descriptor_array =
1599 Array::Handle(ArgumentsDescriptor::New(call_args.Length(), arg_names)); 1599 Array::Handle(ArgumentsDescriptor::New(call_args.Length(), arg_names));
1600 // Call the closure. 1600 // Call the closure.
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 function = library.LookupLocalFunction(getter_name); 1876 function = library.LookupLocalFunction(getter_name);
1877 if (!function.IsNull()) { 1877 if (!function.IsNull()) {
1878 // Invoke getter. 1878 // Invoke getter.
1879 const Object& getter_result = Object::Handle( 1879 const Object& getter_result = Object::Handle(
1880 DartEntry::InvokeFunction(function, Object::empty_array())); 1880 DartEntry::InvokeFunction(function, Object::empty_array()));
1881 if (getter_result.IsError()) { 1881 if (getter_result.IsError()) {
1882 ThrowInvokeError(Error::Cast(getter_result)); 1882 ThrowInvokeError(Error::Cast(getter_result));
1883 UNREACHABLE(); 1883 UNREACHABLE();
1884 } 1884 }
1885 // Make room for the closure (receiver) in arguments. 1885 // Make room for the closure (receiver) in arguments.
1886 int numArgs = args.Length(); 1886 intptr_t numArgs = args.Length();
1887 const Array& call_args = Array::Handle(Array::New(numArgs + 1)); 1887 const Array& call_args = Array::Handle(Array::New(numArgs + 1));
1888 Object& temp = Object::Handle(); 1888 Object& temp = Object::Handle();
1889 for (int i = 0; i < numArgs; i++) { 1889 for (int i = 0; i < numArgs; i++) {
1890 temp = args.At(i); 1890 temp = args.At(i);
1891 call_args.SetAt(i + 1, temp); 1891 call_args.SetAt(i + 1, temp);
1892 } 1892 }
1893 call_args.SetAt(0, getter_result); 1893 call_args.SetAt(0, getter_result);
1894 const Array& call_args_descriptor_array = 1894 const Array& call_args_descriptor_array =
1895 Array::Handle(ArgumentsDescriptor::New(call_args.Length(), arg_names)); 1895 Array::Handle(ArgumentsDescriptor::New(call_args.Length(), arg_names));
1896 // Call closure. 1896 // Call closure.
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 } 2117 }
2118 2118
2119 DEFINE_NATIVE_ENTRY(TypeMirror_moreSpecificTest, 2) { 2119 DEFINE_NATIVE_ENTRY(TypeMirror_moreSpecificTest, 2) {
2120 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); 2120 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0));
2121 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); 2121 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1));
2122 return Bool::Get(a.IsMoreSpecificThan(b, NULL)).raw(); 2122 return Bool::Get(a.IsMoreSpecificThan(b, NULL)).raw();
2123 } 2123 }
2124 2124
2125 2125
2126 } // namespace dart 2126 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698