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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } else { | 52 } else { |
53 StubMethod method = | 53 StubMethod method = |
54 generator.generateStubForNoSuchMethod(jsName, selector); | 54 generator.generateStubForNoSuchMethod(jsName, selector); |
55 addProperty(method.name, method.code); | 55 addProperty(method.name, method.code); |
56 if (reflectionName != null) { | 56 if (reflectionName != null) { |
57 bool accessible = | 57 bool accessible = compiler.world.allFunctions.filter(selector).any( |
58 compiler.world.allFunctions.filter(selector, null).any( | |
59 (Element e) => backend.isAccessibleByReflection(e)); | 58 (Element e) => backend.isAccessibleByReflection(e)); |
60 addProperty('+$reflectionName', js(accessible ? '2' : '0')); | 59 addProperty('+$reflectionName', js(accessible ? '2' : '0')); |
61 } | 60 } |
62 } | 61 } |
63 } | 62 } |
64 } | 63 } |
65 | 64 |
66 // Identify the noSuchMethod handlers that are so simple that we can | 65 // Identify the noSuchMethod handlers that are so simple that we can |
67 // generate them programatically. | 66 // generate them programatically. |
68 bool isTrivialNsmHandler( | 67 bool isTrivialNsmHandler( |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 }''', { | 316 }''', { |
318 'sliceOffsetParams': sliceOffsetParams, | 317 'sliceOffsetParams': sliceOffsetParams, |
319 'noSuchMethodName': namer.noSuchMethodName, | 318 'noSuchMethodName': namer.noSuchMethodName, |
320 'createInvocationMirror': createInvocationMirror, | 319 'createInvocationMirror': createInvocationMirror, |
321 'names': minify ? 'shortNames' : 'longNames', | 320 'names': minify ? 'shortNames' : 'longNames', |
322 'sliceOffsetArguments': sliceOffsetArguments})); | 321 'sliceOffsetArguments': sliceOffsetArguments})); |
323 | 322 |
324 return statements; | 323 return statements; |
325 } | 324 } |
326 } | 325 } |
OLD | NEW |