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

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

Issue 103913005: Introduce class TypeRef in the VM to fully support recursive types. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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/type_patch.dart » ('j') | runtime/vm/object.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/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
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 339
rmacnak 2013/12/11 19:32:07 ASSERT(!type.IsTypeRef());
regis 2013/12/11 22:47:46 Done.
340 if (cls.IsSignatureClass()) { 340 if (cls.IsSignatureClass()) {
341 if (cls.IsCanonicalSignatureClass()) { 341 if (cls.IsCanonicalSignatureClass()) {
342 // We represent function types as canonical signature classes. 342 // We represent function types as canonical signature classes.
343 return CreateFunctionTypeMirror(cls, type); 343 return CreateFunctionTypeMirror(cls, type);
344 } else { 344 } else {
345 // We represent typedefs as non-canonical signature classes. 345 // We represent typedefs as non-canonical signature classes.
346 return CreateTypedefMirror(cls, type, is_declaration, owner_mirror); 346 return CreateTypedefMirror(cls, type, is_declaration, owner_mirror);
347 } 347 }
348 } 348 }
349 349
(...skipping 25 matching lines...) Expand all
375 args.SetAt(1, str); 375 args.SetAt(1, str);
376 str = lib.url(); 376 str = lib.url();
377 args.SetAt(2, str); 377 args.SetAt(2, str);
378 return CreateMirror(Symbols::_LocalLibraryMirror(), args); 378 return CreateMirror(Symbols::_LocalLibraryMirror(), args);
379 } 379 }
380 380
381 381
382 static RawInstance* CreateTypeMirror(const AbstractType& type) { 382 static RawInstance* CreateTypeMirror(const AbstractType& type) {
383 ASSERT(type.IsFinalized()); 383 ASSERT(type.IsFinalized());
384 ASSERT(!type.IsMalformed()); 384 ASSERT(!type.IsMalformed());
385 if (type.HasResolvedTypeClass()) { 385 if (type.HasResolvedTypeClass()) {
rmacnak 2013/12/11 19:32:07 ASSERT(!type.IsTypeRef());
regis 2013/12/11 22:47:46 Done.
386 const Class& cls = Class::Handle(type.type_class()); 386 const Class& cls = Class::Handle(type.type_class());
387 // Handle void and dynamic types. 387 // Handle void and dynamic types.
388 if (cls.IsVoidClass()) { 388 if (cls.IsVoidClass()) {
389 Array& args = Array::Handle(Array::New(1)); 389 Array& args = Array::Handle(Array::New(1));
390 args.SetAt(0, Symbols::Void()); 390 args.SetAt(0, Symbols::Void());
391 // TODO(mlippautz): Create once in the VM isolate and retrieve from there. 391 // TODO(mlippautz): Create once in the VM isolate and retrieve from there.
392 return CreateMirror(Symbols::_SpecialTypeMirror(), args); 392 return CreateMirror(Symbols::_SpecialTypeMirror(), args);
393 } else if (cls.IsDynamicClass()) { 393 } else if (cls.IsDynamicClass()) {
394 Array& args = Array::Handle(Array::New(1)); 394 Array& args = Array::Handle(Array::New(1));
395 args.SetAt(0, Symbols::Dynamic()); 395 args.SetAt(0, Symbols::Dynamic());
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 for (intptr_t i = 0; i < num_params; i++) { 1267 for (intptr_t i = 0; i < num_params; i++) {
1268 result.SetAt(i, type_mirror); 1268 result.SetAt(i, type_mirror);
1269 } 1269 }
1270 return result.raw(); 1270 return result.raw();
1271 } 1271 }
1272 1272
1273 ASSERT(args.Length() >= num_params); 1273 ASSERT(args.Length() >= num_params);
1274 const intptr_t num_inherited_args = args.Length() - num_params; 1274 const intptr_t num_inherited_args = args.Length() - num_params;
1275 for (intptr_t i = 0; i < num_params; i++) { 1275 for (intptr_t i = 0; i < num_params; i++) {
1276 arg_type ^= args.TypeAt(i + num_inherited_args); 1276 arg_type ^= args.TypeAt(i + num_inherited_args);
1277 arg_type = arg_type.Canonicalize(); // Necessary for recursive types.
1277 type_mirror = CreateTypeMirror(arg_type); 1278 type_mirror = CreateTypeMirror(arg_type);
1278 result.SetAt(i, type_mirror); 1279 result.SetAt(i, type_mirror);
1279 } 1280 }
1280 return result.raw(); 1281 return result.raw();
1281 } 1282 }
1282 1283
1283 1284
1284 DEFINE_NATIVE_ENTRY(TypeVariableMirror_owner, 1) { 1285 DEFINE_NATIVE_ENTRY(TypeVariableMirror_owner, 1) {
1285 GET_NON_NULL_NATIVE_ARGUMENT(TypeParameter, param, arguments->NativeArgAt(0)); 1286 GET_NON_NULL_NATIVE_ARGUMENT(TypeParameter, param, arguments->NativeArgAt(0));
1286 const Class& owner = Class::Handle(param.parameterized_class()); 1287 const Class& owner = Class::Handle(param.parameterized_class());
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 1946
1946 DEFINE_NATIVE_ENTRY(VariableMirror_type, 2) { 1947 DEFINE_NATIVE_ENTRY(VariableMirror_type, 2) {
1947 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1948 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1948 const Field& field = Field::Handle(ref.GetFieldReferent()); 1949 const Field& field = Field::Handle(ref.GetFieldReferent());
1949 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1)); 1950 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1));
1950 const AbstractType& type = AbstractType::Handle(field.type()); 1951 const AbstractType& type = AbstractType::Handle(field.type());
1951 return InstantiateType(type, instantiator); 1952 return InstantiateType(type, instantiator);
1952 } 1953 }
1953 1954
1954 } // namespace dart 1955 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/type_patch.dart » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698