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

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

Issue 360493002: Emit declarations for typedefs that are needed by reflection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 years, 4 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: sdk/lib/_internal/lib/js_mirrors.dart
diff --git a/sdk/lib/_internal/lib/js_mirrors.dart b/sdk/lib/_internal/lib/js_mirrors.dart
index 912af14a257dfcc692e14c9b283ab7f93312b26d..c322846f94b1e3723cebeee027417d7aed3e5a8e 100644
--- a/sdk/lib/_internal/lib/js_mirrors.dart
+++ b/sdk/lib/_internal/lib/js_mirrors.dart
@@ -4,7 +4,7 @@
library dart._js_mirrors;
-import 'dart:async';
+import '../compiler/implementation/runtime_data.dart' as encoding;
import 'dart:collection' show
UnmodifiableListView,
@@ -334,10 +334,12 @@ class JsLibraryMirror extends JsDeclarationMirror with JsObjectMirror
var cls = reflectClassByMangledName(className);
if (cls is ClassMirror) {
cls = cls.originalDeclaration;
- if (cls is JsClassMirror) {
- result[cls.simpleName] = cls;
- cls._owner = this;
- }
+ }
+ if (cls is JsClassMirror) {
+ result[cls.simpleName] = cls;
+ cls._owner = this;
+ } else if (cls is JsTypedefMirror) {
+ result[cls.simpleName] = cls;
}
}
return _cachedClasses =
@@ -572,12 +574,6 @@ TypeMirror reflectClassByName(Symbol symbol, String mangledName) {
}
var constructor = JS('var', 'init.allClasses[#]', mangledName);
if (constructor == null) {
- int index = JS('int|Null', 'init.functionAliases[#]', mangledName);
- if (index != null) {
- mirror = new JsTypedefMirror(symbol, mangledName, getMetadata(index));
- JsCache.update(classMirrors, mangledName, mirror);
- return mirror;
- }
// Probably an intercepted class.
// TODO(ahe): How to handle intercepted classes?
throw new UnsupportedError('Cannot find class for: ${n(symbol)}');
@@ -602,23 +598,28 @@ TypeMirror reflectClassByName(Symbol symbol, String mangledName) {
}
}
- var superclassName = fields.split(';')[0];
- var mixins = superclassName.split('+');
- if (mixins.length > 1 && mangledGlobalNames[mangledName] == null) {
- mirror = reflectMixinApplication(mixins, mangledName);
+ if (encoding.isTypedefDescriptor(fields)) {
+ int index = encoding.getTypeFromTypedef(fields);
+ mirror = new JsTypedefMirror(symbol, mangledName, getMetadata(index));
} else {
- ClassMirror classMirror = new JsClassMirror(
- symbol, mangledName, constructor, fields, fieldsMetadata);
- List typeVariables =
- JS('JSExtendableArray|Null', '#.prototype["<>"]', constructor);
- if (typeVariables == null || typeVariables.length == 0) {
- mirror = classMirror;
+ var superclassName = fields.split(';')[0];
+ var mixins = superclassName.split('+');
+ if (mixins.length > 1 && mangledGlobalNames[mangledName] == null) {
+ mirror = reflectMixinApplication(mixins, mangledName);
} else {
- String typeArguments = 'dynamic';
- for (int i = 1; i < typeVariables.length; i++) {
- typeArguments += ',dynamic';
+ ClassMirror classMirror = new JsClassMirror(
+ symbol, mangledName, constructor, fields, fieldsMetadata);
+ List typeVariables =
+ JS('JSExtendableArray|Null', '#.prototype["<>"]', constructor);
+ if (typeVariables == null || typeVariables.length == 0) {
+ mirror = classMirror;
+ } else {
+ String typeArguments = 'dynamic';
+ for (int i = 1; i < typeVariables.length; i++) {
+ typeArguments += ',dynamic';
+ }
+ mirror = new JsTypeBoundClassMirror(classMirror, typeArguments);
}
- mirror = new JsTypeBoundClassMirror(classMirror, typeArguments);
}
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/world.dart ('k') | tests/compiler/dart2js/analyze_unused_dart2js_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698