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

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: split test to maintain coverage Created 7 years, 4 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') | runtime/vm/parser.cc » ('J')
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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // We represent function types as canonical signature classes. 192 // We represent function types as canonical signature classes.
193 return CreateFunctionTypeMirror(cls, type); 193 return CreateFunctionTypeMirror(cls, type);
194 } else { 194 } else {
195 // We represent typedefs as non-canonical signature classes. 195 // We represent typedefs as non-canonical signature classes.
196 return CreateTypedefMirror(cls, owner_mirror); 196 return CreateTypedefMirror(cls, owner_mirror);
197 } 197 }
198 } 198 }
199 199
200 const Bool& is_generic = 200 const Bool& is_generic =
201 (cls.NumTypeParameters() == 0) ? Bool::False() : Bool::True(); 201 (cls.NumTypeParameters() == 0) ? Bool::False() : Bool::True();
202 const Bool& is_mixin_typedef =
203 cls.is_mixin_typedef() ? Bool::True() : Bool::False();
202 204
203 const Array& args = Array::Handle(Array::New(4)); 205 const Array& args = Array::Handle(Array::New(5));
204 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls))); 206 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls)));
205 args.SetAt(1, type); 207 args.SetAt(1, type);
206 args.SetAt(2, String::Handle(cls.UserVisibleName())); 208 // We do not set the names of anonymous mixin applications because the mirrors
209 // use a different naming convention than the VM (lib.S with lib.M and S&M
210 // respectively).
211 if (Type::Handle(cls.mixin()).IsNull() || cls.is_mixin_typedef()) {
212 args.SetAt(2, String::Handle(cls.UserVisibleName()));
213 }
207 args.SetAt(3, is_generic); 214 args.SetAt(3, is_generic);
215 args.SetAt(4, is_mixin_typedef);
208 return CreateMirror(Symbols::_LocalClassMirrorImpl(), args); 216 return CreateMirror(Symbols::_LocalClassMirrorImpl(), args);
209 } 217 }
210 218
211 219
212 // Note a "raw type" is not the same as a RawType. 220 // Note a "raw type" is not the same as a RawType.
213 static RawAbstractType* RawTypeOfClass(const Class& cls) { 221 static RawAbstractType* RawTypeOfClass(const Class& cls) {
214 Type& type = Type::Handle(Type::New(cls, 222 Type& type = Type::Handle(Type::New(cls,
215 Object::null_abstract_type_arguments(), 223 Object::null_abstract_type_arguments(),
216 Scanner::kDummyTokenIndex)); 224 Scanner::kDummyTokenIndex));
217 return ClassFinalizer::FinalizeType(cls, type, ClassFinalizer::kCanonicalize); 225 return ClassFinalizer::FinalizeType(cls, type, ClassFinalizer::kCanonicalize);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 467
460 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate)); 468 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate));
461 if (!error.IsNull()) { 469 if (!error.IsNull()) {
462 ThrowInvokeError(error); 470 ThrowInvokeError(error);
463 } 471 }
464 472
465 return klass.interfaces(); 473 return klass.interfaces();
466 } 474 }
467 475
468 476
477 DEFINE_NATIVE_ENTRY(ClassMirror_mixin, 1) {
478 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
479 const Class& klass = Class::Handle(ref.GetClassReferent());
480 return klass.mixin();
481 }
482
483
469 DEFINE_NATIVE_ENTRY(ClassMirror_members, 2) { 484 DEFINE_NATIVE_ENTRY(ClassMirror_members, 2) {
470 GET_NON_NULL_NATIVE_ARGUMENT(Instance, 485 GET_NON_NULL_NATIVE_ARGUMENT(Instance,
471 owner_mirror, 486 owner_mirror,
472 arguments->NativeArgAt(0)); 487 arguments->NativeArgAt(0));
473 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); 488 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1));
474 const Class& klass = Class::Handle(ref.GetClassReferent()); 489 const Class& klass = Class::Handle(ref.GetClassReferent());
475 490
476 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate)); 491 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate));
477 if (!error.IsNull()) { 492 if (!error.IsNull()) {
478 ThrowInvokeError(error); 493 ThrowInvokeError(error);
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 } 1316 }
1302 1317
1303 1318
1304 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { 1319 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) {
1305 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1320 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1306 const Field& field = Field::Handle(ref.GetFieldReferent()); 1321 const Field& field = Field::Handle(ref.GetFieldReferent());
1307 return field.type(); 1322 return field.type();
1308 } 1323 }
1309 1324
1310 } // namespace dart 1325 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698