OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart2js.js_emitter.class_stub_generator; | 5 library dart2js.js_emitter.class_stub_generator; |
6 | 6 |
7 import '../common/names.dart' show Identifiers; | 7 import '../common/names.dart' show Identifiers; |
8 import '../common_elements.dart' show CommonElements; | 8 import '../common_elements.dart' show CommonElements; |
9 import '../elements/entities.dart'; | 9 import '../elements/entities.dart'; |
10 import '../js/js.dart' as jsAst; | 10 import '../js/js.dart' as jsAst; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 | 81 |
82 /** | 82 /** |
83 * Documentation wanted -- johnniwinther | 83 * Documentation wanted -- johnniwinther |
84 * | 84 * |
85 * Invariant: [member] must be a declaration element. | 85 * Invariant: [member] must be a declaration element. |
86 */ | 86 */ |
87 Map<jsAst.Name, jsAst.Expression> generateCallStubsForGetter( | 87 Map<jsAst.Name, jsAst.Expression> generateCallStubsForGetter( |
88 MemberEntity member, Map<Selector, SelectorConstraints> selectors) { | 88 MemberEntity member, Map<Selector, SelectorConstraints> selectors) { |
89 // If the method is intercepted, the stub gets the | 89 // If the method is intercepted, the stub gets the |
90 // receiver explicitely and we need to pass it to the getter call. | 90 // receiver explicitly and we need to pass it to the getter call. |
91 bool isInterceptedMethod = _interceptorData.isInterceptedMethod(member); | 91 bool isInterceptedMethod = _interceptorData.isInterceptedMethod(member); |
92 bool isInterceptedClass = | 92 bool isInterceptedClass = |
93 _interceptorData.isInterceptedClass(member.enclosingClass); | 93 _interceptorData.isInterceptedClass(member.enclosingClass); |
94 | 94 |
95 const String receiverArgumentName = r'$receiver'; | 95 const String receiverArgumentName = r'$receiver'; |
96 | 96 |
97 jsAst.Expression buildGetter() { | 97 jsAst.Expression buildGetter() { |
98 jsAst.Expression receiver = | 98 jsAst.Expression receiver = |
99 js(isInterceptedClass ? receiverArgumentName : 'this'); | 99 js(isInterceptedClass ? receiverArgumentName : 'this'); |
100 if (member.isGetter) { | 100 if (member.isGetter) { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 if (cache === void 0) cache = #tearOff( | 313 if (cache === void 0) cache = #tearOff( |
314 this, funcs, reflectionInfo, true, [], name).prototype; | 314 this, funcs, reflectionInfo, true, [], name).prototype; |
315 return cache; | 315 return cache; |
316 } | 316 } |
317 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); | 317 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); |
318 }''', | 318 }''', |
319 {'tearOff': tearOffAccessExpression}); | 319 {'tearOff': tearOffAccessExpression}); |
320 | 320 |
321 return <jsAst.Statement>[tearOffGetter, tearOff]; | 321 return <jsAst.Statement>[tearOffGetter, tearOff]; |
322 } | 322 } |
OLD | NEW |