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

Unified Diff: sdk/lib/_internal/compiler/implementation/mirrors/dart2js_type_mirrors.dart

Issue 126823004: Add TypeMirror.isSubtypeOf, TypeMirror.isAssignableTo, ClassMirror.isSubclassOf (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: mark source mirrors as failing Created 6 years, 10 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
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/mirrors/dart2js_type_mirrors.dart
diff --git a/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_type_mirrors.dart b/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_type_mirrors.dart
index 64c54c4e306437081712b03633042d64e5285563..3f5bfddffac18ba3a947c8ac4ad12b81746ae734 100644
--- a/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_type_mirrors.dart
+++ b/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_type_mirrors.dart
@@ -54,6 +54,14 @@ abstract class Dart2JsTypeMirror
bool get isDynamic => false;
+ bool isSubtypeOf(TypeMirror other) {
+ return mirrorSystem.compiler.types.isSubtype(this._type, other._type);
+ }
+
+ bool isAssignableTo(TypeMirror other) {
+ return mirrorSystem.compiler.types.isAssignable(this._type, other._type);
+ }
+
String toString() => _type.toString();
}
@@ -226,6 +234,18 @@ class Dart2JsClassDeclarationMirror
InterfaceType type)
: super(system, type);
+ bool isSubclassOf(ClassMirror other) {
+ if (other is! ClassMirror) throw new ArgumentError(other);
+ ClassMirror otherDeclaration = other.originalDeclaration;
+ ClassMirror c = this;
+ while (c != null) {
+ c = c.originalDeclaration;
+ if (c == otherDeclaration) return true;
+ c = c.superclass;
+ }
+ return false;
+ }
+
String toString() => 'Mirror on class ${_type.name}';
}
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698