| 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/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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 return Function::null(); | 329 return Function::null(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 static RawInstance* CreateClassMirror(const Class& cls, | 332 static RawInstance* CreateClassMirror(const Class& cls, |
| 333 const AbstractType& type, | 333 const AbstractType& type, |
| 334 const Bool& is_declaration, | 334 const Bool& is_declaration, |
| 335 const Instance& owner_mirror) { | 335 const Instance& owner_mirror) { |
| 336 ASSERT(!cls.IsDynamicClass() && !cls.IsVoidClass()); | 336 ASSERT(!cls.IsDynamicClass() && !cls.IsVoidClass()); |
| 337 ASSERT(!type.IsNull()); | 337 ASSERT(!type.IsNull()); |
| 338 ASSERT(type.IsFinalized()); | 338 ASSERT(type.IsFinalized()); |
| 339 ASSERT(!type.IsTypeRef()); |
| 339 | 340 |
| 340 if (cls.IsSignatureClass()) { | 341 if (cls.IsSignatureClass()) { |
| 341 if (cls.IsCanonicalSignatureClass()) { | 342 if (cls.IsCanonicalSignatureClass()) { |
| 342 // We represent function types as canonical signature classes. | 343 // We represent function types as canonical signature classes. |
| 343 return CreateFunctionTypeMirror(cls, type); | 344 return CreateFunctionTypeMirror(cls, type); |
| 344 } else { | 345 } else { |
| 345 // We represent typedefs as non-canonical signature classes. | 346 // We represent typedefs as non-canonical signature classes. |
| 346 return CreateTypedefMirror(cls, type, is_declaration, owner_mirror); | 347 return CreateTypedefMirror(cls, type, is_declaration, owner_mirror); |
| 347 } | 348 } |
| 348 } | 349 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 375 args.SetAt(1, str); | 376 args.SetAt(1, str); |
| 376 str = lib.url(); | 377 str = lib.url(); |
| 377 args.SetAt(2, str); | 378 args.SetAt(2, str); |
| 378 return CreateMirror(Symbols::_LocalLibraryMirror(), args); | 379 return CreateMirror(Symbols::_LocalLibraryMirror(), args); |
| 379 } | 380 } |
| 380 | 381 |
| 381 | 382 |
| 382 static RawInstance* CreateTypeMirror(const AbstractType& type) { | 383 static RawInstance* CreateTypeMirror(const AbstractType& type) { |
| 383 ASSERT(type.IsFinalized()); | 384 ASSERT(type.IsFinalized()); |
| 384 ASSERT(!type.IsMalformed()); | 385 ASSERT(!type.IsMalformed()); |
| 386 ASSERT(!type.IsTypeRef()); |
| 385 if (type.HasResolvedTypeClass()) { | 387 if (type.HasResolvedTypeClass()) { |
| 386 const Class& cls = Class::Handle(type.type_class()); | 388 const Class& cls = Class::Handle(type.type_class()); |
| 387 // Handle void and dynamic types. | 389 // Handle void and dynamic types. |
| 388 if (cls.IsVoidClass()) { | 390 if (cls.IsVoidClass()) { |
| 389 Array& args = Array::Handle(Array::New(1)); | 391 Array& args = Array::Handle(Array::New(1)); |
| 390 args.SetAt(0, Symbols::Void()); | 392 args.SetAt(0, Symbols::Void()); |
| 391 // TODO(mlippautz): Create once in the VM isolate and retrieve from there. | 393 // TODO(mlippautz): Create once in the VM isolate and retrieve from there. |
| 392 return CreateMirror(Symbols::_SpecialTypeMirror(), args); | 394 return CreateMirror(Symbols::_SpecialTypeMirror(), args); |
| 393 } else if (cls.IsDynamicClass()) { | 395 } else if (cls.IsDynamicClass()) { |
| 394 Array& args = Array::Handle(Array::New(1)); | 396 Array& args = Array::Handle(Array::New(1)); |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1267 for (intptr_t i = 0; i < num_params; i++) { | 1269 for (intptr_t i = 0; i < num_params; i++) { |
| 1268 result.SetAt(i, type_mirror); | 1270 result.SetAt(i, type_mirror); |
| 1269 } | 1271 } |
| 1270 return result.raw(); | 1272 return result.raw(); |
| 1271 } | 1273 } |
| 1272 | 1274 |
| 1273 ASSERT(args.Length() >= num_params); | 1275 ASSERT(args.Length() >= num_params); |
| 1274 const intptr_t num_inherited_args = args.Length() - num_params; | 1276 const intptr_t num_inherited_args = args.Length() - num_params; |
| 1275 for (intptr_t i = 0; i < num_params; i++) { | 1277 for (intptr_t i = 0; i < num_params; i++) { |
| 1276 arg_type ^= args.TypeAt(i + num_inherited_args); | 1278 arg_type ^= args.TypeAt(i + num_inherited_args); |
| 1279 arg_type = arg_type.Canonicalize(); // Necessary for recursive types. |
| 1277 type_mirror = CreateTypeMirror(arg_type); | 1280 type_mirror = CreateTypeMirror(arg_type); |
| 1278 result.SetAt(i, type_mirror); | 1281 result.SetAt(i, type_mirror); |
| 1279 } | 1282 } |
| 1280 return result.raw(); | 1283 return result.raw(); |
| 1281 } | 1284 } |
| 1282 | 1285 |
| 1283 | 1286 |
| 1284 DEFINE_NATIVE_ENTRY(TypeVariableMirror_owner, 1) { | 1287 DEFINE_NATIVE_ENTRY(TypeVariableMirror_owner, 1) { |
| 1285 GET_NON_NULL_NATIVE_ARGUMENT(TypeParameter, param, arguments->NativeArgAt(0)); | 1288 GET_NON_NULL_NATIVE_ARGUMENT(TypeParameter, param, arguments->NativeArgAt(0)); |
| 1286 const Class& owner = Class::Handle(param.parameterized_class()); | 1289 const Class& owner = Class::Handle(param.parameterized_class()); |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2049 | 2052 |
| 2050 DEFINE_NATIVE_ENTRY(VariableMirror_type, 2) { | 2053 DEFINE_NATIVE_ENTRY(VariableMirror_type, 2) { |
| 2051 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 2054 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
| 2052 const Field& field = Field::Handle(ref.GetFieldReferent()); | 2055 const Field& field = Field::Handle(ref.GetFieldReferent()); |
| 2053 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1)); | 2056 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1)); |
| 2054 const AbstractType& type = AbstractType::Handle(field.type()); | 2057 const AbstractType& type = AbstractType::Handle(field.type()); |
| 2055 return InstantiateType(type, instantiator); | 2058 return InstantiateType(type, instantiator); |
| 2056 } | 2059 } |
| 2057 | 2060 |
| 2058 } // namespace dart | 2061 } // namespace dart |
| OLD | NEW |