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

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: Address review comments. 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 2dccf1c79f892854b97258516c45618e69cf4195..36f86abc3d66139b1e30d3bbc1aa8a2f639d58de 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
@@ -1139,6 +1139,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);
}
@@ -1489,9 +1490,26 @@ class TypeImpl implements Type {
}
}
+String getClassName(var object) {
ngeoffray 2012/11/16 13:47:35 Duplicating Primitives.objectTypeName?
karlklose 2012/11/20 10:35:26 Only in some cases: if constructorNameFallback can
+ 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