Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 // We represent function types as canonical signature classes. | 194 // We represent function types as canonical signature classes. |
| 195 return CreateFunctionTypeMirror(cls, type); | 195 return CreateFunctionTypeMirror(cls, type); |
| 196 } else { | 196 } else { |
| 197 // We represent typedefs as non-canonical signature classes. | 197 // We represent typedefs as non-canonical signature classes. |
| 198 return CreateTypedefMirror(cls, owner_mirror); | 198 return CreateTypedefMirror(cls, owner_mirror); |
| 199 } | 199 } |
| 200 } | 200 } |
| 201 | 201 |
| 202 const Bool& is_generic = | 202 const Bool& is_generic = |
| 203 (cls.NumTypeParameters() == 0) ? Bool::False() : Bool::True(); | 203 (cls.NumTypeParameters() == 0) ? Bool::False() : Bool::True(); |
| 204 const Bool& is_mixin_typedef = | |
| 205 cls.is_mixin_typedef() ? Bool::True() : Bool::False(); | |
| 204 | 206 |
| 205 const Array& args = Array::Handle(Array::New(4)); | 207 const Array& args = Array::Handle(Array::New(5)); |
| 206 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls))); | 208 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls))); |
| 207 args.SetAt(1, type); | 209 args.SetAt(1, type); |
| 208 args.SetAt(2, String::Handle(cls.UserVisibleName())); | 210 // We do not set the names of anonymous mixin applications because the mirrors |
| 211 // use a different naming convention than the VM (lib.S with lib.M and S&M | |
| 212 // respectively). | |
| 213 if (Type::Handle(cls.mixin()).IsNull() || cls.is_mixin_typedef()) { | |
|
siva
2013/08/26 04:30:27
if ((cls.mixin() == Type::null()) || cls.is_mixin_
rmacnak
2013/08/26 18:24:37
Done.
| |
| 214 args.SetAt(2, String::Handle(cls.UserVisibleName())); | |
| 215 } | |
| 209 args.SetAt(3, is_generic); | 216 args.SetAt(3, is_generic); |
| 217 args.SetAt(4, is_mixin_typedef); | |
| 210 return CreateMirror(Symbols::_LocalClassMirrorImpl(), args); | 218 return CreateMirror(Symbols::_LocalClassMirrorImpl(), args); |
| 211 } | 219 } |
| 212 | 220 |
| 213 | 221 |
| 214 // Note a "raw type" is not the same as a RawType. | 222 // Note a "raw type" is not the same as a RawType. |
| 215 static RawAbstractType* RawTypeOfClass(const Class& cls) { | 223 static RawAbstractType* RawTypeOfClass(const Class& cls) { |
| 216 Type& type = Type::Handle(Type::New(cls, | 224 Type& type = Type::Handle(Type::New(cls, |
| 217 Object::null_abstract_type_arguments(), | 225 Object::null_abstract_type_arguments(), |
| 218 Scanner::kDummyTokenIndex)); | 226 Scanner::kDummyTokenIndex)); |
| 219 return ClassFinalizer::FinalizeType(cls, type, ClassFinalizer::kCanonicalize); | 227 return ClassFinalizer::FinalizeType(cls, type, ClassFinalizer::kCanonicalize); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 467 | 475 |
| 468 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate)); | 476 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate)); |
| 469 if (!error.IsNull()) { | 477 if (!error.IsNull()) { |
| 470 ThrowInvokeError(error); | 478 ThrowInvokeError(error); |
| 471 } | 479 } |
| 472 | 480 |
| 473 return klass.interfaces(); | 481 return klass.interfaces(); |
| 474 } | 482 } |
| 475 | 483 |
| 476 | 484 |
| 485 DEFINE_NATIVE_ENTRY(ClassMirror_mixin, 1) { | |
| 486 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | |
| 487 const Class& klass = Class::Handle(ref.GetClassReferent()); | |
| 488 return klass.mixin(); | |
| 489 } | |
| 490 | |
| 491 | |
| 477 DEFINE_NATIVE_ENTRY(ClassMirror_members, 2) { | 492 DEFINE_NATIVE_ENTRY(ClassMirror_members, 2) { |
| 478 GET_NON_NULL_NATIVE_ARGUMENT(Instance, | 493 GET_NON_NULL_NATIVE_ARGUMENT(Instance, |
| 479 owner_mirror, | 494 owner_mirror, |
| 480 arguments->NativeArgAt(0)); | 495 arguments->NativeArgAt(0)); |
| 481 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); | 496 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); |
| 482 const Class& klass = Class::Handle(ref.GetClassReferent()); | 497 const Class& klass = Class::Handle(ref.GetClassReferent()); |
| 483 | 498 |
| 484 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate)); | 499 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate)); |
| 485 if (!error.IsNull()) { | 500 if (!error.IsNull()) { |
| 486 ThrowInvokeError(error); | 501 ThrowInvokeError(error); |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1309 } | 1324 } |
| 1310 | 1325 |
| 1311 | 1326 |
| 1312 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { | 1327 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { |
| 1313 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 1328 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
| 1314 const Field& field = Field::Handle(ref.GetFieldReferent()); | 1329 const Field& field = Field::Handle(ref.GetFieldReferent()); |
| 1315 return field.type(); | 1330 return field.type(); |
| 1316 } | 1331 } |
| 1317 | 1332 |
| 1318 } // namespace dart | 1333 } // namespace dart |
| OLD | NEW |