| 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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 class ClassStubGenerator { | 7 class ClassStubGenerator { |
| 8 final Namer namer; | 8 final Namer namer; |
| 9 final Compiler compiler; | 9 final Compiler compiler; |
| 10 final JavaScriptBackend backend; | 10 final JavaScriptBackend backend; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 return js('function(#, v) { return #.# = v; }', | 41 return js('function(#, v) { return #.# = v; }', |
| 42 [args, receiver, fieldName]); | 42 [args, receiver, fieldName]); |
| 43 } | 43 } |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * Documentation wanted -- johnniwinther | 46 * Documentation wanted -- johnniwinther |
| 47 * | 47 * |
| 48 * Invariant: [member] must be a declaration element. | 48 * Invariant: [member] must be a declaration element. |
| 49 */ | 49 */ |
| 50 Map<jsAst.Name, jsAst.Expression> generateCallStubsForGetter( | 50 Map<jsAst.Name, jsAst.Expression> generateCallStubsForGetter( |
| 51 Element member, Map<Selector, ReceiverMaskSet> selectors) { | 51 Element member, Map<Selector, SelectorConstraints> selectors) { |
| 52 assert(invariant(member, member.isDeclaration)); | 52 assert(invariant(member, member.isDeclaration)); |
| 53 | 53 |
| 54 // If the method is intercepted, the stub gets the | 54 // If the method is intercepted, the stub gets the |
| 55 // receiver explicitely and we need to pass it to the getter call. | 55 // receiver explicitely and we need to pass it to the getter call. |
| 56 bool isInterceptedMethod = backend.isInterceptedMethod(member); | 56 bool isInterceptedMethod = backend.isInterceptedMethod(member); |
| 57 bool isInterceptorClass = | 57 bool isInterceptorClass = |
| 58 backend.isInterceptorClass(member.enclosingClass); | 58 backend.isInterceptorClass(member.enclosingClass); |
| 59 | 59 |
| 60 const String receiverArgumentName = r'$receiver'; | 60 const String receiverArgumentName = r'$receiver'; |
| 61 | 61 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 Map<jsAst.Name, Selector> computeSelectorsForNsmHandlers() { | 117 Map<jsAst.Name, Selector> computeSelectorsForNsmHandlers() { |
| 118 | 118 |
| 119 Map<jsAst.Name, Selector> jsNames = <jsAst.Name, Selector>{}; | 119 Map<jsAst.Name, Selector> jsNames = <jsAst.Name, Selector>{}; |
| 120 | 120 |
| 121 // Do not generate no such method handlers if there is no class. | 121 // Do not generate no such method handlers if there is no class. |
| 122 if (compiler.codegenWorld.directlyInstantiatedClasses.isEmpty) { | 122 if (compiler.codegenWorld.directlyInstantiatedClasses.isEmpty) { |
| 123 return jsNames; | 123 return jsNames; |
| 124 } | 124 } |
| 125 | 125 |
| 126 void addNoSuchMethodHandlers(String ignore, | 126 void addNoSuchMethodHandlers(String ignore, |
| 127 Map<Selector, ReceiverMaskSet> selectors) { | 127 Map<Selector, SelectorConstraints> selectors) { |
| 128 for (Selector selector in selectors.keys) { | 128 for (Selector selector in selectors.keys) { |
| 129 ReceiverMaskSet maskSet = selectors[selector]; | 129 SelectorConstraints maskSet = selectors[selector]; |
| 130 if (maskSet.needsNoSuchMethodHandling(selector, compiler.world)) { | 130 if (maskSet.needsNoSuchMethodHandling(selector, compiler.world)) { |
| 131 jsAst.Name jsName = namer.invocationMirrorInternalName(selector); | 131 jsAst.Name jsName = namer.invocationMirrorInternalName(selector); |
| 132 jsNames[jsName] = selector; | 132 jsNames[jsName] = selector; |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 compiler.codegenWorld.forEachInvokedName(addNoSuchMethodHandlers); | 137 compiler.codegenWorld.forEachInvokedName(addNoSuchMethodHandlers); |
| 138 compiler.codegenWorld.forEachInvokedGetter(addNoSuchMethodHandlers); | 138 compiler.codegenWorld.forEachInvokedGetter(addNoSuchMethodHandlers); |
| 139 compiler.codegenWorld.forEachInvokedSetter(addNoSuchMethodHandlers); | 139 compiler.codegenWorld.forEachInvokedSetter(addNoSuchMethodHandlers); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 ? function() { | 275 ? function() { |
| 276 if (cache === void 0) cache = #tearOff( | 276 if (cache === void 0) cache = #tearOff( |
| 277 this, funcs, reflectionInfo, true, [], name).prototype; | 277 this, funcs, reflectionInfo, true, [], name).prototype; |
| 278 return cache; | 278 return cache; |
| 279 } | 279 } |
| 280 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); | 280 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); |
| 281 }''', {'tearOff': tearOffAccessExpression}); | 281 }''', {'tearOff': tearOffAccessExpression}); |
| 282 | 282 |
| 283 return <jsAst.Statement>[tearOffGetter, tearOff]; | 283 return <jsAst.Statement>[tearOffGetter, tearOff]; |
| 284 } | 284 } |
| OLD | NEW |