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

Unified Diff: lib/src/mirrors.dart

Issue 17553018: Initial stream support (Closed) Base URL: https://github.com/dart-lang/fancy-syntax.git@master
Patch Set: Created 7 years, 6 months 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
Index: lib/src/mirrors.dart
diff --git a/lib/src/mirrors.dart b/lib/src/mirrors.dart
new file mode 100644
index 0000000000000000000000000000000000000000..52c3e56c10001a77c0fce1159e2a92aaca2cee04
--- /dev/null
+++ b/lib/src/mirrors.dart
@@ -0,0 +1,42 @@
+// 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.
+
+library fancy_syntax.mirrors;
+
+import 'dart:mirrors';
+
+/**
+ * Walks up the class hierarchy to find a method declaration with the given
+ * [name].
+ *
+ * Note that it's not possible to tell if there's an implementation via
+ * noSuchMethod().
+ */
+Mirror getMemberMirror(ClassMirror classMirror, Symbol name) {
+ if (classMirror.members.containsKey(name)) {
+ return classMirror.members[name];
+ }
+ if (hasSuperclass(classMirror)) {
+ var mirror = getMemberMirror(classMirror.superclass, name);
+ if (mirror != null) {
+ return mirror;
+ }
+ }
+ for (ClassMirror supe in classMirror.superinterfaces) {
+ var mirror = getMemberMirror(supe, name);
+ if (mirror != null) {
+ return mirror;
+ }
+ }
+ return null;
+}
+
+/**
+ * Work-around for http://dartbug.com/5794
+ */
+bool hasSuperclass(ClassMirror classMirror) {
+ ClassMirror superclass = classMirror.superclass;
+ return (superclass != null)
+ && (superclass.qualifiedName != new Symbol("dart.core.Object"));
Jennifer Messerly 2013/06/24 18:30:35 perhaps: var obj = reflectClass(Object); return s
justinfagnani 2013/06/25 03:45:36 Done.
+}
« example/streams/count_clicks.html ('K') | « lib/eval.dart ('k') | lib/syntax.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698