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 library dart2js.js_emitter.class_stub_generator; | 5 library dart2js.js_emitter.class_stub_generator; |
6 | 6 |
7 import '../common/names.dart' show Identifiers; | 7 import '../common/names.dart' show Identifiers; |
8 import '../compiler.dart' show Compiler; | 8 import '../compiler.dart' show Compiler; |
9 import '../elements/entities.dart'; | 9 import '../elements/entities.dart'; |
10 import '../js/js.dart' as jsAst; | 10 import '../js/js.dart' as jsAst; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 jsAst.Expression expression = js( | 189 jsAst.Expression expression = js( |
190 '''this.#noSuchMethodName(#receiver, | 190 '''this.#noSuchMethodName(#receiver, |
191 #createInvocationMirror(#methodName, | 191 #createInvocationMirror(#methodName, |
192 #internalName, | 192 #internalName, |
193 #type, | 193 #type, |
194 #arguments, | 194 #arguments, |
195 #namedArguments))''', | 195 #namedArguments))''', |
196 { | 196 { |
197 'receiver': isIntercepted ? r'$receiver' : 'this', | 197 'receiver': isIntercepted ? r'$receiver' : 'this', |
198 'noSuchMethodName': namer.noSuchMethodName, | 198 'noSuchMethodName': namer.noSuchMethodName, |
199 'createInvocationMirror': backend.emitter | 199 'createInvocationMirror': backend.emitter.staticFunctionAccess( |
200 .staticFunctionAccess(backend.helpers.createInvocationMirror), | 200 backend.commonElements.createInvocationMirror), |
201 'methodName': | 201 'methodName': |
202 js.quoteName(enableMinification ? internalName : methodName), | 202 js.quoteName(enableMinification ? internalName : methodName), |
203 'internalName': js.quoteName(internalName), | 203 'internalName': js.quoteName(internalName), |
204 'type': js.number(type), | 204 'type': js.number(type), |
205 'arguments': | 205 'arguments': |
206 new jsAst.ArrayInitializer(parameterNames.map(js).toList()), | 206 new jsAst.ArrayInitializer(parameterNames.map(js).toList()), |
207 'namedArguments': new jsAst.ArrayInitializer(argNames) | 207 'namedArguments': new jsAst.ArrayInitializer(argNames) |
208 }); | 208 }); |
209 | 209 |
210 jsAst.Expression function; | 210 jsAst.Expression function; |
(...skipping 18 matching lines...) Expand all Loading... |
229 /// Each function must have the `$callName` property set. | 229 /// Each function must have the `$callName` property set. |
230 /// * `reflectionInfo`: contains reflective information, and the function | 230 /// * `reflectionInfo`: contains reflective information, and the function |
231 /// type. TODO(floitsch): point to where this is specified. | 231 /// type. TODO(floitsch): point to where this is specified. |
232 /// * `isStatic`. | 232 /// * `isStatic`. |
233 /// * `name`. | 233 /// * `name`. |
234 /// * `isIntercepted. | 234 /// * `isIntercepted. |
235 List<jsAst.Statement> buildTearOffCode(JavaScriptBackend backend) { | 235 List<jsAst.Statement> buildTearOffCode(JavaScriptBackend backend) { |
236 Namer namer = backend.namer; | 236 Namer namer = backend.namer; |
237 Compiler compiler = backend.compiler; | 237 Compiler compiler = backend.compiler; |
238 | 238 |
239 FunctionEntity closureFromTearOff = backend.helpers.closureFromTearOff; | 239 FunctionEntity closureFromTearOff = backend.commonElements.closureFromTearOff; |
240 jsAst.Expression tearOffAccessExpression; | 240 jsAst.Expression tearOffAccessExpression; |
241 jsAst.Expression tearOffGlobalObjectString; | 241 jsAst.Expression tearOffGlobalObjectString; |
242 jsAst.Expression tearOffGlobalObject; | 242 jsAst.Expression tearOffGlobalObject; |
243 if (closureFromTearOff != null) { | 243 if (closureFromTearOff != null) { |
244 tearOffAccessExpression = | 244 tearOffAccessExpression = |
245 backend.emitter.staticFunctionAccess(closureFromTearOff); | 245 backend.emitter.staticFunctionAccess(closureFromTearOff); |
246 tearOffGlobalObject = | 246 tearOffGlobalObject = |
247 js.stringPart(namer.globalObjectForMethod(closureFromTearOff)); | 247 js.stringPart(namer.globalObjectForMethod(closureFromTearOff)); |
248 tearOffGlobalObjectString = | 248 tearOffGlobalObjectString = |
249 js.string(namer.globalObjectForMethod(closureFromTearOff)); | 249 js.string(namer.globalObjectForMethod(closureFromTearOff)); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 if (cache === void 0) cache = #tearOff( | 313 if (cache === void 0) cache = #tearOff( |
314 this, funcs, reflectionInfo, true, [], name).prototype; | 314 this, funcs, reflectionInfo, true, [], name).prototype; |
315 return cache; | 315 return cache; |
316 } | 316 } |
317 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); | 317 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); |
318 }''', | 318 }''', |
319 {'tearOff': tearOffAccessExpression}); | 319 {'tearOff': tearOffAccessExpression}); |
320 | 320 |
321 return <jsAst.Statement>[tearOffGetter, tearOff]; | 321 return <jsAst.Statement>[tearOffGetter, tearOff]; |
322 } | 322 } |
OLD | NEW |