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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 Map<jsAst.Name, jsAst.Expression> generatedStubs = | 86 Map<jsAst.Name, jsAst.Expression> generatedStubs = |
87 <jsAst.Name, jsAst.Expression>{}; | 87 <jsAst.Name, jsAst.Expression>{}; |
88 | 88 |
89 // Two selectors may match but differ only in type. To avoid generating | 89 // Two selectors may match but differ only in type. To avoid generating |
90 // identical stubs for each we track untyped selectors which already have | 90 // identical stubs for each we track untyped selectors which already have |
91 // stubs. | 91 // stubs. |
92 Set<Selector> generatedSelectors = new Set<Selector>(); | 92 Set<Selector> generatedSelectors = new Set<Selector>(); |
93 for (Selector selector in selectors.keys) { | 93 for (Selector selector in selectors.keys) { |
94 if (generatedSelectors.contains(selector)) continue; | 94 if (generatedSelectors.contains(selector)) continue; |
95 if (!selector.appliesUnnamed(member, backend)) continue; | 95 if (!selector.appliesUnnamed(member)) continue; |
96 if (selectors[selector].applies(member, selector, compiler.closedWorld)) { | 96 if (selectors[selector].applies(member, selector, compiler.closedWorld)) { |
97 generatedSelectors.add(selector); | 97 generatedSelectors.add(selector); |
98 | 98 |
99 jsAst.Name invocationName = namer.invocationName(selector); | 99 jsAst.Name invocationName = namer.invocationName(selector); |
100 Selector callSelector = new Selector.callClosureFrom(selector); | 100 Selector callSelector = new Selector.callClosureFrom(selector); |
101 jsAst.Name closureCallName = namer.invocationName(callSelector); | 101 jsAst.Name closureCallName = namer.invocationName(callSelector); |
102 | 102 |
103 List<jsAst.Parameter> parameters = <jsAst.Parameter>[]; | 103 List<jsAst.Parameter> parameters = <jsAst.Parameter>[]; |
104 List<jsAst.Expression> arguments = <jsAst.Expression>[]; | 104 List<jsAst.Expression> arguments = <jsAst.Expression>[]; |
105 if (isInterceptedMethod) { | 105 if (isInterceptedMethod) { |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 if (cache === void 0) cache = #tearOff( | 290 if (cache === void 0) cache = #tearOff( |
291 this, funcs, reflectionInfo, true, [], name).prototype; | 291 this, funcs, reflectionInfo, true, [], name).prototype; |
292 return cache; | 292 return cache; |
293 } | 293 } |
294 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); | 294 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); |
295 }''', | 295 }''', |
296 {'tearOff': tearOffAccessExpression}); | 296 {'tearOff': tearOffAccessExpression}); |
297 | 297 |
298 return <jsAst.Statement>[tearOffGetter, tearOff]; | 298 return <jsAst.Statement>[tearOffGetter, tearOff]; |
299 } | 299 } |
OLD | NEW |