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

Unified Diff: runtime/lib/mirrors.cc

Issue 19983003: Create ParameterMirror.type lazily. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors.cc
diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc
index 4180f29f71638307fe8e7c6b3799a35a176fc542..790705a11158304af0057734caf38f472c3b9573 100644
--- a/runtime/lib/mirrors.cc
+++ b/runtime/lib/mirrors.cc
@@ -236,6 +236,7 @@ static Dart_Handle CreateLazyMirror(Dart_Handle target);
static Dart_Handle CreateParameterMirrorList(Dart_Handle func) {
+ ASSERT(Dart_IsFunction(func));
int64_t fixed_param_count;
int64_t opt_param_count;
Dart_Handle result = Dart_FunctionParameterCounts(func,
@@ -257,14 +258,12 @@ static Dart_Handle CreateParameterMirrorList(Dart_Handle func) {
return param_type;
}
+ Dart_Handle reflectee = CreateMirrorReference(func);
for (int64_t i = 0; i < param_count; i++) {
- Dart_Handle arg_type = Dart_FunctionParameterType(func, i);
- if (Dart_IsError(arg_type)) {
- return arg_type;
- }
Dart_Handle args[] = {
- CreateLazyMirror(arg_type),
- Dart_NewBoolean(i >= fixed_param_count), // optional param?
+ reflectee,
+ Dart_NewInteger(i),
+ (i >= fixed_param_count) ? Api::True() : Api::False(),
};
Dart_Handle param =
Dart_New(param_type, Dart_Null(), ARRAY_SIZE(args), args);
@@ -1864,6 +1863,16 @@ DEFINE_NATIVE_ENTRY(MethodMirror_return_type, 1) {
}
+DEFINE_NATIVE_ENTRY(ParameterMirror_type, 2) {
+ GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
+ GET_NON_NULL_NATIVE_ARGUMENT(Smi, pos, arguments->NativeArgAt(1));
+ const Function& func = Function::Handle(ref.GetFunctionReferent());
+ const AbstractType& param_type = AbstractType::Handle(func.ParameterTypeAt(
+ func.NumImplicitParameters() + pos.Value()));
+ return CreateTypeMirror(param_type);
+}
+
+
DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) {
GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
const Field& field = Field::Handle(ref.GetFieldReferent());
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698