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

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

Issue 14690017: Version 0.5.7.2 . (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/VERSION » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import 'dart:_collection-dev'; 8 import 'dart:_collection-dev';
9 import 'dart:_js_helper' show allMatchesInStringUnchecked, 9 import 'dart:_js_helper' show allMatchesInStringUnchecked,
10 Null, 10 Null,
11 JSSyntaxRegExp, 11 JSSyntaxRegExp,
12 Primitives, 12 Primitives,
13 checkGrowable, 13 checkGrowable,
14 checkMutable, 14 checkMutable,
15 checkNull, 15 checkNull,
16 checkNum, 16 checkNum,
17 checkString, 17 checkString,
18 defineProperty,
18 getRuntimeType, 19 getRuntimeType,
19 regExpGetNative, 20 regExpGetNative,
20 stringContainsUnchecked, 21 stringContainsUnchecked,
21 stringLastIndexOfUnchecked, 22 stringLastIndexOfUnchecked,
22 stringReplaceAllFuncUnchecked, 23 stringReplaceAllFuncUnchecked,
23 stringReplaceAllUnchecked, 24 stringReplaceAllUnchecked,
24 stringReplaceFirstUnchecked, 25 stringReplaceFirstUnchecked,
25 lookupDispatchRecord; 26 lookupDispatchRecord;
26 import 'dart:_foreign_helper' show JS; 27 import 'dart:_foreign_helper' show JS;
27 28
28 part 'js_array.dart'; 29 part 'js_array.dart';
29 part 'js_number.dart'; 30 part 'js_number.dart';
30 part 'js_string.dart'; 31 part 'js_string.dart';
31 32
32 /** 33 /**
33 * Get the interceptor for [object]. Called by the compiler when it needs 34 * Get the interceptor for [object]. Called by the compiler when it needs
34 * to emit a call to an intercepted method, that is a method that is 35 * to emit a call to an intercepted method, that is a method that is
35 * defined in an interceptor class. 36 * defined in an interceptor class.
36 */ 37 */
37 getInterceptor(object) { 38 getInterceptor(object) {
38 // This is a magic method: the compiler does specialization of it 39 // This is a magic method: the compiler does specialization of it
39 // depending on the uses of intercepted methods and instantiated 40 // depending on the uses of intercepted methods and instantiated
40 // primitive types. 41 // primitive types.
41 } 42 }
42 43
43 /** 44 /**
44 * The name of the property used on native classes and `Object.prototype` to get 45 * The name of the property used on native classes and `Object.prototype` to get
45 * the interceptor for a native class instance. The value is initialized on 46 * the interceptor for a native class instance. The value is initialized on
46 * isolate startup. 47 * isolate startup to ensure no two Dart programs in the same page use the same
48 * property.
47 */ 49 */
48 var dispatchPropertyName = null; 50 var dispatchPropertyName = null;
49 51
50 getDispatchProperty(object) { 52 getDispatchProperty(object) {
51 // TODO(sra): Implement the magic.
52 // This is a magic method: the compiler replaces it with a runtime generated 53 // This is a magic method: the compiler replaces it with a runtime generated
53 // function 54 // function
54 // 55 //
55 // function(object){return object._zzyzx;} 56 // function(object){return object._zzyzx;}
56 // 57 //
57 // where _zzyzx is replaced with the actual [dispatchPropertyName]. 58 // where `_zzyzx` is replaced with the actual [dispatchPropertyName].
58 // 59 //
59 // The body is the CSP compliant version. 60 // The CSP compliant version replaces this function with one of a few
61 // pre-compiled accessors, unless the pre-compiled versions are all in use,
62 // when it falls back on this code.
60 return JS('', '#[#]', object, dispatchPropertyName); 63 return JS('', '#[#]', object, dispatchPropertyName);
61 } 64 }
62 65
63 setDispatchProperty(object, value) { 66 setDispatchProperty(object, value) {
64 // TODO(sra): Implement the magic. 67 defineProperty(object, dispatchPropertyName, value);
65 // This is a magic method: the compiler replaces it with a runtime generated
66 // function
67 //
68 // function(object, value){object._zzyzx = value;}
69 //
70 // where _zzyzx is replaced with the actual [dispatchPropertyName].
71 //
72 // The body is the CSP compliant version.
73 JS('void', '#[#] = #', object, dispatchPropertyName, value);
74 } 68 }
75 69
76 makeDispatchRecord(interceptor, proto, extension) { 70 makeDispatchRecord(interceptor, proto, extension) {
77 // Dispatch records are stored in the prototype chain, and in some cases, on 71 // Dispatch records are stored in the prototype chain, and in some cases, on
78 // instances. 72 // instances.
79 // 73 //
80 // The record layout and field usage is designed to minimize the number of 74 // The record layout and field usage is designed to minimize the number of
81 // operations on the common paths. 75 // operations on the common paths.
82 // 76 //
83 // [interceptor] is the interceptor - a holder of methods for the object, 77 // [interceptor] is the interceptor - a holder of methods for the object,
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 } 345 }
352 346
353 /** 347 /**
354 * The supertype for JSMutableArray and 348 * The supertype for JSMutableArray and
355 * JavaScriptIndexingBehavior. Used by the backend to have a type mask 349 * JavaScriptIndexingBehavior. Used by the backend to have a type mask
356 * that contains the objects we can use the JS []= operator on. 350 * that contains the objects we can use the JS []= operator on.
357 */ 351 */
358 abstract class JSMutableIndexable extends JSIndexable { 352 abstract class JSMutableIndexable extends JSIndexable {
359 operator[]=(int index, var value); 353 operator[]=(int index, var value);
360 } 354 }
OLDNEW
« no previous file with comments | « no previous file | tools/VERSION » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698