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

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

Issue 22859004: Improve type literals in minified mode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added a test, and changed how names are unmangled. Created 7 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
« no previous file with comments | « dart/sdk/lib/_internal/lib/js_names.dart ('k') | dart/tests/lib/mirrors/unmangled_type_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/sdk/lib/_internal/lib/js_rti.dart
diff --git a/dart/sdk/lib/_internal/lib/js_rti.dart b/dart/sdk/lib/_internal/lib/js_rti.dart
index 4441214b8e9de4386f3a08042c4de780eca502f0..c32038296fa7fc46d845bb1c47ea97c2047c9e40 100644
--- a/dart/sdk/lib/_internal/lib/js_rti.dart
+++ b/dart/sdk/lib/_internal/lib/js_rti.dart
@@ -46,10 +46,17 @@ Type createRuntimeType(String name) => new TypeImpl(name);
class TypeImpl implements Type {
final String _typeName;
+ String _unmangledName;
TypeImpl(this._typeName);
- String toString() => _typeName;
+ String toString() {
+ if (_unmangledName != null) return _unmangledName;
+ String unmangledName = unmangleGlobalNameIfPreservedAnyways(_typeName);
+ // TODO(ahe): Handle type arguments.
+ if (unmangledName == null) unmangledName = _typeName;
+ return _unmangledName = unmangledName;
+ }
// TODO(ahe): This is a poor hashCode as it collides with its name.
int get hashCode => _typeName.hashCode;
@@ -59,6 +66,8 @@ class TypeImpl implements Type {
}
}
+getMangledTypeName(TypeImpl type) => type._typeName;
+
/**
* Sets the runtime type information on [target]. [typeInfo] is a type
* representation of type 4 or 5, that is, either a JavaScript array or
@@ -677,9 +686,9 @@ bool isJsArray(var value) {
return value is JSArray;
}
-hasField(var object, var name) => JS('bool', r'#[#] != null', object, name);
+hasField(var object, var name) => JS('bool', r'# in #', name, object);
-hasNoField(var object, var name) => JS('bool', r'#[#] == null', object, name);
+hasNoField(var object, var name) => !hasField(object, name);
/// Returns [:true:] if [o] is a JavaScript function.
bool isJsFunction(var o) => JS('bool', r'typeof # == "function"', o);
« no previous file with comments | « dart/sdk/lib/_internal/lib/js_names.dart ('k') | dart/tests/lib/mirrors/unmangled_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698