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

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

Issue 11308169: GVN getInterceptor and use the interceptor constant when the type is known. (Closed) Base URL: http://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/interceptors.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/lib/interceptors.dart (revision 15265)
+++ sdk/lib/_internal/compiler/implementation/lib/interceptors.dart (working copy)
@@ -24,16 +24,28 @@
* defined in an interceptor class.
*/
getInterceptor(object) {
- if (object is String) return const JSString();
- if (isJsArray(object)) return const JSArray();
- if (object is int) return const JSInt();
- if (object is double) return const JSDouble();
- if (object is bool) return const JSBool();
- if (object == null) return const JSNull();
- if (JS('String', 'typeof #', object) == 'function') return const JSFunction();
- return const ObjectInterceptor();
+ if (object is String) return stringInterceptor;
+ if (isJsArray(object)) return arrayInterceptor;
+ if (object is int) return intInterceptor;
+ if (object is double) return doubleInterceptor;
+ if (object is bool) return boolInterceptor;
+ if (object == null) return nullInterceptor;
+ if (JS('String', 'typeof #', object) == 'function') {
+ return functionInterceptor;
+ }
+ return objectInterceptor;
}
+final arrayInterceptor = const JSArray();
+final boolInterceptor = const JSBool();
+final doubleInterceptor = const JSDouble();
+final intInterceptor = const JSInt();
+final functionInterceptor = const JSFunction();
+final nullInterceptor = const JSNull();
+final numberInterceptor = const JSNumber();
+final stringInterceptor = const JSString();
+final objectInterceptor = const ObjectInterceptor();
+
/**
* The interceptor class for tear-off static methods. Unlike
* tear-off instance methods, tear-off static methods are just the JS

Powered by Google App Engine
This is Rietveld 408576698