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

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart

Issue 16644002: Implement ClassMirror.superclass. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
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
« no previous file with comments | « no previous file | dart/tests/lib/lib.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart b/dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart
index c06e25150f0d8e269fa69d5f5cfa776a9d980401..202b255d7f94d068a47d20316bb091d15a6c89f8 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart
@@ -316,6 +316,8 @@ class JsClassMirror extends JsObjectMirror implements ClassMirror {
final String _fields;
final List _fieldsMetadata;
List _metadata;
+ JsClassMirror _superclass;
+
// Set as side-effect of accessing JsLibraryMirror.classes.
JsLibraryMirror _owner;
@@ -346,8 +348,8 @@ class JsClassMirror extends JsObjectMirror implements ClassMirror {
Map<Symbol, VariableMirror> get variables {
var result = new Map<Symbol, VariableMirror>();
- var s = _fields.split(";");
- var fields = s[1] == "" ? [] : s[1].split(",");
+ var s = _fields.split(';');
+ var fields = s[1] == '' ? [] : s[1].split(',');
int fieldNumber = 0;
for (String field in fields) {
var metadata;
@@ -439,6 +441,16 @@ class JsClassMirror extends JsObjectMirror implements ClassMirror {
return _metadata.map(reflect).toList();
}
+ ClassMirror get superclass {
+ if (_superclass == null) {
+ var superclassName = _fields.split(';')[0];
+ // Use _superclass == this to represent class with no superclass (Object).
+ _superclass =
+ (superclassName == '') ? this : reflectClassByName(s(superclassName));
+ }
+ return _superclass == this ? null : _superclass;
+ }
+
String toString() => 'ClassMirror(${n(simpleName)})';
}
@@ -473,7 +485,7 @@ class JsVariableMirror implements VariableMirror {
}
String jsName;
String accessorName = jsName = descriptor.substring(0, length);
- int divider = descriptor.indexOf(":");
+ int divider = descriptor.indexOf(':');
if (divider > 0) {
accessorName = accessorName.substring(0, divider);
jsName = accessorName.substring(divider + 1);
« no previous file with comments | « no previous file | dart/tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698