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

Unified Diff: pkg/checked_mirrors/lib/src/utils.dart

Issue 111643015: Preliminary checked mirrors (not ready for review yet) (Closed) Base URL: https://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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/checked_mirrors/lib/src/checker.dart ('k') | pkg/checked_mirrors/lib/src/wrappers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/checked_mirrors/lib/src/utils.dart
diff --git a/pkg/checked_mirrors/lib/src/utils.dart b/pkg/checked_mirrors/lib/src/utils.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b7cd6169670d2f208bbd396bd5b79868cf5e82e3
--- /dev/null
+++ b/pkg/checked_mirrors/lib/src/utils.dart
@@ -0,0 +1,23 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/// Holds some common functions that manipulate mirror objects.
+library checked_mirrors.src.utils;
+
+import 'dart:mirrors';
+
+/// Helper to retrieve the library uri where [object] is defined.
+Uri getLibraryUriOf(Mirror object) {
+ var declaration = getDeclarationOf(object);
+ if (declaration == null) return null;
+ if (declaration is LibraryMirror) return declaration.uri;
+ return getLibraryUriOf(declaration.owner);
+}
+
+/// Helper to retrieve the declaration of [object].
+DeclarationMirror getDeclarationOf(Mirror object) {
+ if (object is DeclarationMirror) return object;
+ if (object is InstanceMirror) return object.type;
+ return null;
+}
« no previous file with comments | « pkg/checked_mirrors/lib/src/checker.dart ('k') | pkg/checked_mirrors/lib/src/wrappers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698