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

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

Issue 11365170: Start new design for interceptors and implement String.charCodeAt with it. (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 14732)
+++ sdk/lib/_internal/compiler/implementation/lib/interceptors.dart (working copy)
@@ -6,6 +6,25 @@
#import('dart:collection');
+class JSString implements String {
ahe 2012/11/12 13:24:11 Consider moving this to its own file.
ahe 2012/11/12 13:24:11 Document this class.
ngeoffray 2012/11/13 11:45:16 In the long run, this file will only contain inter
ngeoffray 2012/11/13 11:45:16 Done.
+ const JSString();
+ int charCodeAt(index) {
ahe 2012/11/12 13:24:11 Add a newline between declarations.
ngeoffray 2012/11/13 11:45:16 Done.
+ if (index is !num) throw new ArgumentError(index);
+ if (index < 0) throw new RangeError.value(index);
+ if (index >= length) throw new RangeError.value(index);
+ return JS('int', r'#.charCodeAt(#)', this, index);
+ }
+}
+
+class ObjectInterceptor {
ahe 2012/11/12 13:24:11 Document this class. Explain that all its members
ngeoffray 2012/11/13 11:45:16 Done.
+ const ObjectInterceptor();
+}
+
+getInterceptor(obj) {
ahe 2012/11/12 13:24:11 Document as well.
ngeoffray 2012/11/13 11:45:16 Done.
+ if (obj is String) return const JSString();
+ return const ObjectInterceptor();
+}
+
add$1(var receiver, var value) {
if (isJsArray(receiver)) {
checkGrowable(receiver, 'add');
@@ -90,17 +109,6 @@
return UNINTERCEPTED(receiver.iterator());
}
-charCodeAt(var receiver, int index) {
- if (receiver is String) {
- if (index is !num) throw new ArgumentError(index);
- if (index < 0) throw new RangeError.value(index);
- if (index >= receiver.length) throw new RangeError.value(index);
- return JS('int', r'#.charCodeAt(#)', receiver, index);
- } else {
- return UNINTERCEPTED(receiver.charCodeAt(index));
- }
-}
-
get$isEmpty(receiver) {
if (receiver is String || isJsArray(receiver)) {
return JS('bool', r'#.length === 0', receiver);

Powered by Google App Engine
This is Rietveld 408576698