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

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

Issue 11360228: Simplify runtime type support. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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/compiler/implementation/lib/js_helper.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
index 279ee270849d8dd3f34dc94de87ee8f05a6af0d6..40d0652618e9b0ea17819d822fb4de2eb9056310 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
@@ -1186,6 +1186,7 @@ class Null {
}
setRuntimeTypeInfo(target, typeInfo) {
+ assert(typeInfo == null || isJsArray(typeInfo));
// We have to check for null because factories may return null.
if (target != null) JS('var', r'#.builtin$typeInfo = #', target, typeInfo);
}
@@ -1537,9 +1538,26 @@ class TypeImpl implements Type {
}
}
+String getClassName(var object) {
+ return JS('String', r'#.constructor.builtin$cls', object);
+}
+
String getRuntimeTypeString(var object) {
+ String className = isJsArray(object) ? 'List' : getClassName(object);
var typeInfo = JS('var', r'#.builtin$typeInfo', object);
- return JS('String', r'#.runtimeType', typeInfo);
+ if (typeInfo == null) return className;
+ StringBuffer arguments = new StringBuffer();
+ for (var i = 0; i < typeInfo.length; i++) {
+ if (i > 0) {
+ arguments.add(', ');
+ }
+ var argument = typeInfo[i];
+ if (argument == null) {
+ argument = 'dynamic';
+ }
+ arguments.add(argument);
+ }
+ return '$className<$arguments>';
}
createRuntimeType(String name) => new TypeImpl(name);

Powered by Google App Engine
This is Rietveld 408576698