| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 jsNames[jsName] = selector; | 136 jsNames[jsName] = selector; |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 compiler.codegenWorld.invokedNames.forEach(addNoSuchMethodHandlers); | 140 compiler.codegenWorld.invokedNames.forEach(addNoSuchMethodHandlers); |
| 141 compiler.codegenWorld.invokedGetters.forEach(addNoSuchMethodHandlers); | 141 compiler.codegenWorld.invokedGetters.forEach(addNoSuchMethodHandlers); |
| 142 compiler.codegenWorld.invokedSetters.forEach(addNoSuchMethodHandlers); | 142 compiler.codegenWorld.invokedSetters.forEach(addNoSuchMethodHandlers); |
| 143 return jsNames; | 143 return jsNames; |
| 144 } | 144 } |
| 145 | 145 |
| 146 jsAst.Expression generateStubForNoSuchMethod(Selector selector) { | 146 StubMethod generateStubForNoSuchMethod(Selector selector) { |
| 147 // Values match JSInvocationMirror in js-helper library. | 147 // Values match JSInvocationMirror in js-helper library. |
| 148 int type = selector.invocationMirrorKind; | 148 int type = selector.invocationMirrorKind; |
| 149 List<String> parameterNames = | 149 List<String> parameterNames = |
| 150 new List.generate(selector.argumentCount, (i) => '\$$i'); | 150 new List.generate(selector.argumentCount, (i) => '\$$i'); |
| 151 | 151 |
| 152 List<jsAst.Expression> argNames = | 152 List<jsAst.Expression> argNames = |
| 153 selector.getOrderedNamedArguments().map((String name) => | 153 selector.getOrderedNamedArguments().map((String name) => |
| 154 js.string(name)).toList(); | 154 js.string(name)).toList(); |
| 155 | 155 |
| 156 String methodName = selector.invocationMirrorMemberName; | 156 String methodName = selector.invocationMirrorMemberName; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 170 backend.getCreateInvocationMirror()), | 170 backend.getCreateInvocationMirror()), |
| 171 'methodName': | 171 'methodName': |
| 172 js.string(compiler.enableMinification | 172 js.string(compiler.enableMinification |
| 173 ? internalName : methodName), | 173 ? internalName : methodName), |
| 174 'internalName': js.string(internalName), | 174 'internalName': js.string(internalName), |
| 175 'type': js.number(type), | 175 'type': js.number(type), |
| 176 'arguments': | 176 'arguments': |
| 177 new jsAst.ArrayInitializer(parameterNames.map(js).toList()), | 177 new jsAst.ArrayInitializer(parameterNames.map(js).toList()), |
| 178 'namedArguments': new jsAst.ArrayInitializer(argNames)}); | 178 'namedArguments': new jsAst.ArrayInitializer(argNames)}); |
| 179 | 179 |
| 180 jsAst.Expression function; |
| 180 if (backend.isInterceptedName(selector.name)) { | 181 if (backend.isInterceptedName(selector.name)) { |
| 181 return js(r'function($receiver, #) { return # }', | 182 function = js(r'function($receiver, #) { return # }', |
| 182 [parameterNames, expression]); | 183 [parameterNames, expression]); |
| 183 } else { | 184 } else { |
| 184 return js(r'function(#) { return # }', [parameterNames, expression]); | 185 function = js(r'function(#) { return # }', [parameterNames, expression]); |
| 185 } | 186 } |
| 187 String name = namer.invocationName(selector); |
| 188 return new StubMethod(name, function); |
| 186 } | 189 } |
| 187 } | 190 } |
| OLD | NEW |