Chromium Code Reviews| 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); |