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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/lib/interceptors.dart

Issue 11412105: - Move length getter and setter interceptors to the new interceptor scheme. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library _interceptors; 5 library _interceptors;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 part 'js_array.dart'; 9 part 'js_array.dart';
10 part 'js_number.dart'; 10 part 'js_number.dart';
(...skipping 16 matching lines...) Expand all
27 if (object is String) return const JSString(); 27 if (object is String) return const JSString();
28 if (isJsArray(object)) return const JSArray(); 28 if (isJsArray(object)) return const JSArray();
29 if (object is int) return const JSInt(); 29 if (object is int) return const JSInt();
30 if (object is double) return const JSDouble(); 30 if (object is double) return const JSDouble();
31 if (object is bool) return const JSBool(); 31 if (object is bool) return const JSBool();
32 if (object == null) return const JSNull(); 32 if (object == null) return const JSNull();
33 if (JS('String', 'typeof #', object) == 'function') return const JSFunction(); 33 if (JS('String', 'typeof #', object) == 'function') return const JSFunction();
34 return const ObjectInterceptor(); 34 return const ObjectInterceptor();
35 } 35 }
36 36
37 get$length(var receiver) {
38 if (receiver is String || isJsArray(receiver)) {
39 return JS('num', r'#.length', receiver); // TODO(sra): Use 'int'?
40 } else {
41 return UNINTERCEPTED(receiver.length);
42 }
43 }
44
45 set$length(receiver, newLength) {
46 if (isJsArray(receiver)) {
47 if (newLength is !int) throw new ArgumentError(newLength);
48 if (newLength < 0) throw new RangeError.value(newLength);
49 checkGrowable(receiver, 'set length');
50 JS('void', r'#.length = #', receiver, newLength);
51 } else {
52 UNINTERCEPTED(receiver.length = newLength);
53 }
54 return newLength;
55 }
56
57 /** 37 /**
58 * The interceptor class for tear-off static methods. Unlike 38 * The interceptor class for tear-off static methods. Unlike
59 * tear-off instance methods, tear-off static methods are just the JS 39 * tear-off instance methods, tear-off static methods are just the JS
60 * function, and methods inherited from Object must therefore be 40 * function, and methods inherited from Object must therefore be
61 * intercepted. 41 * intercepted.
62 */ 42 */
63 class JSFunction implements Function { 43 class JSFunction implements Function {
64 const JSFunction(); 44 const JSFunction();
65 String toString() => 'Closure'; 45 String toString() => 'Closure';
66 } 46 }
(...skipping 10 matching lines...) Expand all
77 57
78 /** 58 /**
79 * The interceptor class for [Null]. 59 * The interceptor class for [Null].
80 */ 60 */
81 class JSNull implements Null { 61 class JSNull implements Null {
82 const JSNull(); 62 const JSNull();
83 String toString() => 'null'; 63 String toString() => 'null';
84 int get hashCode => 0; 64 int get hashCode => 0;
85 Type get runtimeType => createRuntimeType('Null'); 65 Type get runtimeType => createRuntimeType('Null');
86 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698