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/mirrors.h" | 5 #include "lib/mirrors.h" |
6 | 6 |
7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
8 #include "vm/bootstrap_natives.h" | 8 #include "vm/bootstrap_natives.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 const Array& args = Array::Handle(Array::New(2)); | 374 const Array& args = Array::Handle(Array::New(2)); |
375 args.SetAt(0, identifiers); | 375 args.SetAt(0, identifiers); |
376 args.SetAt(1, Bool::Get(is_show)); | 376 args.SetAt(1, Bool::Get(is_show)); |
377 return CreateMirror(Symbols::_LocalCombinatorMirror(), args); | 377 return CreateMirror(Symbols::_LocalCombinatorMirror(), args); |
378 } | 378 } |
379 | 379 |
380 | 380 |
381 static RawInstance* CreateLibraryDependencyMirror(const Instance& importer, | 381 static RawInstance* CreateLibraryDependencyMirror(const Instance& importer, |
382 const Namespace& ns, | 382 const Namespace& ns, |
383 const String& prefix, | 383 const String& prefix, |
384 bool is_import) { | 384 const bool is_import, |
| 385 const bool is_deferred) { |
385 const Library& importee = Library::Handle(ns.library()); | 386 const Library& importee = Library::Handle(ns.library()); |
386 const Instance& importee_mirror = | 387 const Instance& importee_mirror = |
387 Instance::Handle(CreateLibraryMirror(importee)); | 388 Instance::Handle(CreateLibraryMirror(importee)); |
388 if (importee_mirror.IsNull()) { | 389 if (importee_mirror.IsNull()) { |
389 // Imported library is censored: censor the import. | 390 // Imported library is censored: censor the import. |
390 return Instance::null(); | 391 return Instance::null(); |
391 } | 392 } |
392 | 393 |
393 const Array& show_names = Array::Handle(ns.show_names()); | 394 const Array& show_names = Array::Handle(ns.show_names()); |
394 const Array& hide_names = Array::Handle(ns.hide_names()); | 395 const Array& hide_names = Array::Handle(ns.hide_names()); |
(...skipping 12 matching lines...) Expand all Loading... |
407 t = CreateCombinatorMirror(t, false); | 408 t = CreateCombinatorMirror(t, false); |
408 combinators.SetAt(i++, t); | 409 combinators.SetAt(i++, t); |
409 } | 410 } |
410 | 411 |
411 Object& metadata = Object::Handle(ns.GetMetadata()); | 412 Object& metadata = Object::Handle(ns.GetMetadata()); |
412 if (metadata.IsError()) { | 413 if (metadata.IsError()) { |
413 Exceptions::PropagateError(Error::Cast(metadata)); | 414 Exceptions::PropagateError(Error::Cast(metadata)); |
414 UNREACHABLE(); | 415 UNREACHABLE(); |
415 } | 416 } |
416 | 417 |
417 const Array& args = Array::Handle(Array::New(6)); | 418 const Array& args = Array::Handle(Array::New(7)); |
418 args.SetAt(0, importer); | 419 args.SetAt(0, importer); |
419 args.SetAt(1, importee_mirror); | 420 args.SetAt(1, importee_mirror); |
420 args.SetAt(2, combinators); | 421 args.SetAt(2, combinators); |
421 args.SetAt(3, prefix); | 422 args.SetAt(3, prefix); |
422 args.SetAt(4, Bool::Get(is_import)); | 423 args.SetAt(4, Bool::Get(is_import)); |
423 args.SetAt(5, metadata); | 424 args.SetAt(5, Bool::Get(is_deferred)); |
424 // is_deferred? | 425 args.SetAt(6, metadata); |
425 return CreateMirror(Symbols::_LocalLibraryDependencyMirror(), args); | 426 return CreateMirror(Symbols::_LocalLibraryDependencyMirror(), args); |
426 } | 427 } |
427 | 428 |
428 | 429 |
429 DEFINE_NATIVE_ENTRY(LibraryMirror_libraryDependencies, 2) { | 430 DEFINE_NATIVE_ENTRY(LibraryMirror_libraryDependencies, 2) { |
430 GET_NON_NULL_NATIVE_ARGUMENT(Instance, lib_mirror, arguments->NativeArgAt(0)); | 431 GET_NON_NULL_NATIVE_ARGUMENT(Instance, lib_mirror, arguments->NativeArgAt(0)); |
431 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); | 432 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); |
432 const Library& lib = Library::Handle(ref.GetLibraryReferent()); | 433 const Library& lib = Library::Handle(ref.GetLibraryReferent()); |
433 | 434 |
434 Array& ports = Array::Handle(); | 435 Array& ports = Array::Handle(); |
435 Namespace& ns = Namespace::Handle(); | 436 Namespace& ns = Namespace::Handle(); |
436 Instance& dep = Instance::Handle(); | 437 Instance& dep = Instance::Handle(); |
437 String& prefix = String::Handle(); | 438 String& prefix = String::Handle(); |
438 GrowableObjectArray& deps = | 439 GrowableObjectArray& deps = |
439 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 440 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
440 | 441 |
441 // Unprefixed imports. | 442 // Unprefixed imports. |
442 ports = lib.imports(); | 443 ports = lib.imports(); |
443 for (intptr_t i = 0; i < ports.Length(); i++) { | 444 for (intptr_t i = 0; i < ports.Length(); i++) { |
444 ns ^= ports.At(i); | 445 ns ^= ports.At(i); |
445 if (!ns.IsNull()) { | 446 if (!ns.IsNull()) { |
446 dep = CreateLibraryDependencyMirror(lib_mirror, ns, prefix, true); | 447 dep = CreateLibraryDependencyMirror(lib_mirror, ns, prefix, true, false); |
447 if (!dep.IsNull()) { | 448 if (!dep.IsNull()) { |
448 deps.Add(dep); | 449 deps.Add(dep); |
449 } | 450 } |
450 } | 451 } |
451 } | 452 } |
452 | 453 |
453 // Exports. | 454 // Exports. |
454 ports = lib.exports(); | 455 ports = lib.exports(); |
455 for (intptr_t i = 0; i < ports.Length(); i++) { | 456 for (intptr_t i = 0; i < ports.Length(); i++) { |
456 ns ^= ports.At(i); | 457 ns ^= ports.At(i); |
457 dep = CreateLibraryDependencyMirror(lib_mirror, ns, prefix, false); | 458 dep = CreateLibraryDependencyMirror(lib_mirror, ns, prefix, false, false); |
458 if (!dep.IsNull()) { | 459 if (!dep.IsNull()) { |
459 deps.Add(dep); | 460 deps.Add(dep); |
460 } | 461 } |
461 } | 462 } |
462 | 463 |
463 // Prefixed imports. | 464 // Prefixed imports. |
464 DictionaryIterator entries(lib); | 465 DictionaryIterator entries(lib); |
465 Object& entry = Object::Handle(); | 466 Object& entry = Object::Handle(); |
466 while (entries.HasNext()) { | 467 while (entries.HasNext()) { |
467 entry = entries.GetNext(); | 468 entry = entries.GetNext(); |
468 if (entry.IsLibraryPrefix()) { | 469 if (entry.IsLibraryPrefix()) { |
469 const LibraryPrefix& lib_prefix = LibraryPrefix::Cast(entry); | 470 const LibraryPrefix& lib_prefix = LibraryPrefix::Cast(entry); |
470 prefix = lib_prefix.name(); | 471 prefix = lib_prefix.name(); |
471 ports = lib_prefix.imports(); | 472 ports = lib_prefix.imports(); |
472 for (intptr_t i = 0; i < ports.Length(); i++) { | 473 for (intptr_t i = 0; i < ports.Length(); i++) { |
473 ns ^= ports.At(i); | 474 ns ^= ports.At(i); |
474 if (!ns.IsNull()) { | 475 if (!ns.IsNull()) { |
475 dep = CreateLibraryDependencyMirror(lib_mirror, ns, prefix, true); | 476 dep = CreateLibraryDependencyMirror(lib_mirror, ns, prefix, true, |
| 477 lib_prefix.is_deferred_load()); |
476 if (!dep.IsNull()) { | 478 if (!dep.IsNull()) { |
477 deps.Add(dep); | 479 deps.Add(dep); |
478 } | 480 } |
479 } | 481 } |
480 } | 482 } |
481 } | 483 } |
482 } | 484 } |
483 | 485 |
484 return deps.raw(); | 486 return deps.raw(); |
485 } | 487 } |
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2028 } | 2030 } |
2029 | 2031 |
2030 DEFINE_NATIVE_ENTRY(TypeMirror_moreSpecificTest, 2) { | 2032 DEFINE_NATIVE_ENTRY(TypeMirror_moreSpecificTest, 2) { |
2031 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); | 2033 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); |
2032 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); | 2034 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); |
2033 return Bool::Get(a.IsMoreSpecificThan(b, NULL)).raw(); | 2035 return Bool::Get(a.IsMoreSpecificThan(b, NULL)).raw(); |
2034 } | 2036 } |
2035 | 2037 |
2036 | 2038 |
2037 } // namespace dart | 2039 } // namespace dart |
OLD | NEW |