Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 NsmEmitter extends CodeEmitterHelper { | 7 class NsmEmitter extends CodeEmitterHelper { |
| 8 final List<Selector> trivialNsmHandlers = <Selector>[]; | 8 final List<Selector> trivialNsmHandlers = <Selector>[]; |
| 9 | 9 |
| 10 /// If this is true then we can generate the noSuchMethod handlers at startup | 10 /// If this is true then we can generate the noSuchMethod handlers at startup |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 } | 42 } |
| 43 | 43 |
| 44 List<jsAst.Expression> argNames = | 44 List<jsAst.Expression> argNames = |
| 45 selector.getOrderedNamedArguments().map((String name) => | 45 selector.getOrderedNamedArguments().map((String name) => |
| 46 js.string(name)).toList(); | 46 js.string(name)).toList(); |
| 47 int type = selector.invocationMirrorKind; | 47 int type = selector.invocationMirrorKind; |
| 48 if (!haveVeryFewNoSuchMemberHandlers && | 48 if (!haveVeryFewNoSuchMemberHandlers && |
| 49 isTrivialNsmHandler(type, argNames, selector, jsName) && | 49 isTrivialNsmHandler(type, argNames, selector, jsName) && |
| 50 reflectionName == null) { | 50 reflectionName == null) { |
| 51 trivialNsmHandlers.add(selector); | 51 trivialNsmHandlers.add(selector); |
| 52 } | 52 } else { |
| 53 | 53 StubMethod method = generator.generateStubForNoSuchMethod(selector); |
| 54 jsAst.Expression method = generator.generateStubForNoSuchMethod(selector); | 54 addProperty(jsName, method.code); |
|
floitsch
2015/02/03 13:07:08
addProperty(method.name, method.code) ?
assert tha
zarah
2015/02/03 14:07:10
Passing it to the generator now.
| |
| 55 if (method != null) { | |
| 56 addProperty(jsName, method); | |
| 57 if (reflectionName != null) { | 55 if (reflectionName != null) { |
| 58 bool accessible = compiler.world.allFunctions.filter(selector).any( | 56 bool accessible = compiler.world.allFunctions.filter(selector).any( |
| 59 (Element e) => backend.isAccessibleByReflection(e)); | 57 (Element e) => backend.isAccessibleByReflection(e)); |
| 60 addProperty('+$reflectionName', js(accessible ? '2' : '0')); | 58 addProperty('+$reflectionName', js(accessible ? '2' : '0')); |
| 61 } | 59 } |
| 62 } | 60 } |
| 63 } | 61 } |
| 64 } | 62 } |
| 65 | 63 |
| 66 // Identify the noSuchMethod handlers that are so simple that we can | 64 // Identify the noSuchMethod handlers that are so simple that we can |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 }''', { | 322 }''', { |
| 325 'sliceOffsetParams': sliceOffsetParams, | 323 'sliceOffsetParams': sliceOffsetParams, |
| 326 'noSuchMethodName': namer.noSuchMethodName, | 324 'noSuchMethodName': namer.noSuchMethodName, |
| 327 'createInvocationMirror': createInvocationMirror, | 325 'createInvocationMirror': createInvocationMirror, |
| 328 'names': minify ? 'shortNames' : 'longNames', | 326 'names': minify ? 'shortNames' : 'longNames', |
| 329 'sliceOffsetArguments': sliceOffsetArguments})); | 327 'sliceOffsetArguments': sliceOffsetArguments})); |
| 330 | 328 |
| 331 return statements; | 329 return statements; |
| 332 } | 330 } |
| 333 } | 331 } |
| OLD | NEW |