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

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

Issue 23190003: ClassMirror.mixin (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 7 years, 3 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
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 static RawInstance* CreateMethodMirror(const Function& func, 231 static RawInstance* CreateMethodMirror(const Function& func,
232 const Instance& owner_mirror) { 232 const Instance& owner_mirror) {
233 const Array& args = Array::Handle(Array::New(12)); 233 const Array& args = Array::Handle(Array::New(12));
234 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(func))); 234 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(func)));
235 args.SetAt(1, String::Handle(func.UserVisibleName())); 235 args.SetAt(1, String::Handle(func.UserVisibleName()));
236 args.SetAt(2, owner_mirror); 236 args.SetAt(2, owner_mirror);
237 args.SetAt(3, Bool::Get(func.is_static())); 237 args.SetAt(3, Bool::Get(func.is_static()));
238 args.SetAt(4, Bool::Get(func.is_abstract())); 238 args.SetAt(4, Bool::Get(func.is_abstract()));
239 args.SetAt(5, Bool::Get(func.IsGetterFunction())); 239 args.SetAt(5, Bool::Get(func.IsGetterFunction()));
240 args.SetAt(6, Bool::Get(func.IsSetterFunction())); 240 args.SetAt(6, Bool::Get(func.IsSetterFunction()));
241 args.SetAt(7, Bool::Get(func.IsConstructor())); 241 args.SetAt(7, Bool::Get(func.kind() == RawFunction::kConstructor));
242 // TODO(mlippautz): Implement different constructor kinds. 242 // TODO(mlippautz): Implement different constructor kinds.
243 args.SetAt(8, Bool::False()); 243 args.SetAt(8, Bool::False());
244 args.SetAt(9, Bool::False()); 244 args.SetAt(9, Bool::False());
245 args.SetAt(10, Bool::False()); 245 args.SetAt(10, Bool::False());
246 args.SetAt(11, Bool::False()); 246 args.SetAt(11, Bool::False());
247 return CreateMirror(Symbols::_LocalMethodMirrorImpl(), args); 247 return CreateMirror(Symbols::_LocalMethodMirrorImpl(), args);
248 } 248 }
249 249
250 250
251 static RawInstance* CreateVariableMirror(const Field& field, 251 static RawInstance* CreateVariableMirror(const Field& field,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 if (cls.IsCanonicalSignatureClass()) { 292 if (cls.IsCanonicalSignatureClass()) {
293 // We represent function types as canonical signature classes. 293 // We represent function types as canonical signature classes.
294 return CreateFunctionTypeMirror(cls, type); 294 return CreateFunctionTypeMirror(cls, type);
295 } else { 295 } else {
296 // We represent typedefs as non-canonical signature classes. 296 // We represent typedefs as non-canonical signature classes.
297 return CreateTypedefMirror(cls, owner_mirror); 297 return CreateTypedefMirror(cls, owner_mirror);
298 } 298 }
299 } 299 }
300 300
301 const Bool& is_generic = Bool::Get(cls.NumTypeParameters() != 0); 301 const Bool& is_generic = Bool::Get(cls.NumTypeParameters() != 0);
302 const Bool& is_mixin_typedef = Bool::Get(cls.is_mixin_typedef());
302 303
303 const Array& args = Array::Handle(Array::New(4)); 304 const Array& args = Array::Handle(Array::New(5));
304 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls))); 305 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls)));
305 args.SetAt(1, type); 306 args.SetAt(1, type);
306 args.SetAt(2, String::Handle(cls.UserVisibleName())); 307 // We do not set the names of anonymous mixin applications because the mirrors
308 // use a different naming convention than the VM (lib.S with lib.M and S&M
309 // respectively).
310 if ((cls.mixin() == Type::null()) || cls.is_mixin_typedef()) {
311 args.SetAt(2, String::Handle(cls.UserVisibleName()));
312 }
307 args.SetAt(3, is_generic); 313 args.SetAt(3, is_generic);
314 args.SetAt(4, is_mixin_typedef);
308 return CreateMirror(Symbols::_LocalClassMirrorImpl(), args); 315 return CreateMirror(Symbols::_LocalClassMirrorImpl(), args);
309 } 316 }
310 317
311 318
312 static RawInstance* CreateLibraryMirror(const Library& lib) { 319 static RawInstance* CreateLibraryMirror(const Library& lib) {
313 const Array& args = Array::Handle(Array::New(3)); 320 const Array& args = Array::Handle(Array::New(3));
314 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(lib))); 321 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(lib)));
315 String& str = String::Handle(); 322 String& str = String::Handle();
316 str = lib.name(); 323 str = lib.name();
317 args.SetAt(1, str); 324 args.SetAt(1, str);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 541
535 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate)); 542 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate));
536 if (!error.IsNull()) { 543 if (!error.IsNull()) {
537 ThrowInvokeError(error); 544 ThrowInvokeError(error);
538 } 545 }
539 546
540 return klass.interfaces(); 547 return klass.interfaces();
541 } 548 }
542 549
543 550
551 DEFINE_NATIVE_ENTRY(ClassMirror_mixin, 1) {
552 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
553 const Class& klass = Class::Handle(ref.GetClassReferent());
554 return klass.mixin();
555 }
556
557
544 DEFINE_NATIVE_ENTRY(ClassMirror_members, 2) { 558 DEFINE_NATIVE_ENTRY(ClassMirror_members, 2) {
545 GET_NON_NULL_NATIVE_ARGUMENT(Instance, 559 GET_NON_NULL_NATIVE_ARGUMENT(Instance,
546 owner_mirror, 560 owner_mirror,
547 arguments->NativeArgAt(0)); 561 arguments->NativeArgAt(0));
548 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); 562 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1));
549 const Class& klass = Class::Handle(ref.GetClassReferent()); 563 const Class& klass = Class::Handle(ref.GetClassReferent());
550 564
551 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate)); 565 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate));
552 if (!error.IsNull()) { 566 if (!error.IsNull()) {
553 ThrowInvokeError(error); 567 ThrowInvokeError(error);
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 } 1361 }
1348 1362
1349 1363
1350 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { 1364 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) {
1351 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1365 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1352 const Field& field = Field::Handle(ref.GetFieldReferent()); 1366 const Field& field = Field::Handle(ref.GetFieldReferent());
1353 return field.type(); 1367 return field.type();
1354 } 1368 }
1355 1369
1356 } // namespace dart 1370 } // namespace dart
OLDNEW
« 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