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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 if (!haveVeryFewNoSuchMemberHandlers && | 76 if (!haveVeryFewNoSuchMemberHandlers && |
| 77 isTrivialNsmHandler(type, argNames, selector, internalName) && | 77 isTrivialNsmHandler(type, argNames, selector, internalName) && |
| 78 reflectionName == null) { | 78 reflectionName == null) { |
| 79 trivialNsmHandlers.add(selector); | 79 trivialNsmHandlers.add(selector); |
| 80 return null; | 80 return null; |
| 81 } | 81 } |
| 82 | 82 |
| 83 assert(backend.isInterceptedName(Compiler.NO_SUCH_METHOD)); | 83 assert(backend.isInterceptedName(Compiler.NO_SUCH_METHOD)); |
| 84 jsAst.Expression expression = js('this.#(this, #(#, #, #, #, #))', [ | 84 jsAst.Expression expression = js('this.#(this, #(#, #, #, #, #))', [ |
| 85 noSuchMethodName, | 85 noSuchMethodName, |
| 86 namer.elementAccess(backend.getCreateInvocationMirror()), | 86 backend.emitter.globalPropertyAccess( |
|
floitsch
2014/12/03 17:02:25
I think staticFunctionAccess.
zarah
2014/12/05 08:22:51
Done.
| |
| 87 backend.getCreateInvocationMirror()), | |
| 87 js.string(compiler.enableMinification ? | 88 js.string(compiler.enableMinification ? |
| 88 internalName : methodName), | 89 internalName : methodName), |
| 89 js.string(internalName), | 90 js.string(internalName), |
| 90 js.number(type), | 91 js.number(type), |
| 91 new jsAst.ArrayInitializer(parameterNames.map(js).toList()), | 92 new jsAst.ArrayInitializer(parameterNames.map(js).toList()), |
| 92 new jsAst.ArrayInitializer(argNames)]); | 93 new jsAst.ArrayInitializer(argNames)]); |
| 93 | 94 |
| 94 if (backend.isInterceptedName(selector.name)) { | 95 if (backend.isInterceptedName(selector.name)) { |
| 95 return js(r'function($receiver, #) { return # }', | 96 return js(r'function($receiver, #) { return # }', |
| 96 [parameterNames, expression]); | 97 [parameterNames, expression]); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 diffEncoding.write(","); | 263 diffEncoding.write(","); |
| 263 } | 264 } |
| 264 diffEncoding.write(short); | 265 diffEncoding.write(short); |
| 265 } | 266 } |
| 266 nameCounter++; | 267 nameCounter++; |
| 267 } | 268 } |
| 268 | 269 |
| 269 // Startup code that loops over the method names and puts handlers on the | 270 // Startup code that loops over the method names and puts handlers on the |
| 270 // Object class to catch noSuchMethod invocations. | 271 // Object class to catch noSuchMethod invocations. |
| 271 ClassElement objectClass = compiler.objectClass; | 272 ClassElement objectClass = compiler.objectClass; |
| 272 jsAst.Expression createInvocationMirror = namer.elementAccess( | 273 jsAst.Expression createInvocationMirror = backend.emitter. |
| 273 backend.getCreateInvocationMirror()); | 274 globalPropertyAccess(backend.getCreateInvocationMirror()); |
|
floitsch
2014/12/03 17:02:25
I prefer to put the "." on the second line:
.glob
zarah
2014/12/05 08:22:51
Done.
| |
| 274 String noSuchMethodName = namer.publicInstanceMethodNameByArity( | 275 String noSuchMethodName = namer.publicInstanceMethodNameByArity( |
| 275 Compiler.NO_SUCH_METHOD, Compiler.NO_SUCH_METHOD_ARG_COUNT); | 276 Compiler.NO_SUCH_METHOD, Compiler.NO_SUCH_METHOD_ARG_COUNT); |
| 276 var type = 0; | 277 var type = 0; |
| 277 if (useDiffEncoding) { | 278 if (useDiffEncoding) { |
| 278 statements.add(js.statement('''{ | 279 statements.add(js.statement('''{ |
| 279 var objectClassObject = | 280 var objectClassObject = |
| 280 collectedClasses[#], // # is name of class Object. | 281 collectedClasses[#], // # is name of class Object. |
| 281 shortNames = #.split(","), // # is diffEncoding. | 282 shortNames = #.split(","), // # is diffEncoding. |
| 282 nameNumber = 0, | 283 nameNumber = 0, |
| 283 diffEncodedString = shortNames[0], | 284 diffEncodedString = shortNames[0], |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 noSuchMethodName, | 380 noSuchMethodName, |
| 380 createInvocationMirror, | 381 createInvocationMirror, |
| 381 sliceOffsetParams, // argument to slice | 382 sliceOffsetParams, // argument to slice |
| 382 minify ? 'shortNames' : 'longNames', | 383 minify ? 'shortNames' : 'longNames', |
| 383 sliceOffsetArguments | 384 sliceOffsetArguments |
| 384 ])); | 385 ])); |
| 385 | 386 |
| 386 return statements; | 387 return statements; |
| 387 } | 388 } |
| 388 } | 389 } |
| OLD | NEW |