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 6dae54a419aa7bc9389316cf0fd57520654e820c..0cf9c4f1a1f43b62449a1ed769d09487dc5d8477 100644 |
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart |
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart |
@@ -1131,8 +1131,6 @@ getRuntimeTypeInfo(target) { |
var res = JS('var', r'#.builtin$typeInfo', target); |
// If the object does not have runtime type information, return an |
// empty literal, to avoid null checks. |
- // TODO(ngeoffray): Make the object a top-level field to avoid |
- // allocating a new object every single time. |
ngeoffray
2012/11/15 08:58:09
Why removing this?
karlklose
2012/11/16 13:37:19
That was an accident. Restored.
|
return (res == null) ? JS('var', '{}') : res; |
} |
@@ -1479,7 +1477,25 @@ Type getOrCreateCachedRuntimeType(String key) { |
return result; |
} |
+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('Object', r'#.builtin$typeInfo', object); |
ngeoffray
2012/11/15 08:58:09
'Object' -> 'var'. I know this is not documented,
karlklose
2012/11/16 13:37:19
Done.
|
- return JS('String', r'#.runtimeType', typeInfo); |
+ if (typeInfo == null) return className; |
+ StringBuffer arguments = new StringBuffer(); |
+ int length = JS('int', r'#.length', typeInfo); |
ngeoffray
2012/11/15 08:58:09
Looks to me that you don't really need all these J
karlklose
2012/11/16 13:37:19
Done.
|
+ for (var i = 0; i < length; i++) { |
+ if (i > 0) { |
+ arguments.add(', '); |
+ } |
+ var argument = JS('String', r'#[#]', typeInfo, i); |
ngeoffray
2012/11/15 08:58:09
typeInfo[i]
karlklose
2012/11/16 13:37:19
Done.
|
+ if (JS('bool', r'# == (void 0)', argument)) { |
ngeoffray
2012/11/15 08:58:09
argument == null
karlklose
2012/11/16 13:37:19
Done.
|
+ argument = 'dynamic'; |
+ } |
+ arguments.add(argument != null ? argument : 'dynamic'); |
ngeoffray
2012/11/15 08:58:09
This is weird. builtin$typeInfo should have one ki
karlklose
2012/11/16 13:37:19
This was a merge conflict, removed.
|
+ } |
+ return '$className<$arguments>'; |
} |