OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** A dynamic member stub. */ | 5 /** A dynamic member stub. */ |
6 class VarMember { | 6 class VarMember { |
7 final String name; | 7 final String name; |
8 | 8 |
9 VarMember(this.name); | 9 VarMember(this.name); |
10 | 10 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 * 'Object': function($0, capture) { | 240 * 'Object': function($0, capture) { |
241 * return this.noSuchMethod('addEventListener', [$0], | 241 * return this.noSuchMethod('addEventListener', [$0], |
242 * {'capture': capture}); | 242 * {'capture': capture}); |
243 * } | 243 * } |
244 * }); | 244 * }); |
245 */ | 245 */ |
246 void generate(CodeWriter code) { | 246 void generate(CodeWriter code) { |
247 if (_fallbackStubs.length == 0) return; | 247 if (_fallbackStubs.length == 0) return; |
248 | 248 |
249 code.enterBlock('\$varMethod("$name", {'); | 249 code.enterBlock('\$varMethod("$name", {'); |
| 250 var lastOne = _fallbackStubs[_fallbackStubs.length - 1]; |
250 for (var stub in _fallbackStubs) { | 251 for (var stub in _fallbackStubs) { |
251 code.write('"${stub.typeName}": '); | 252 code.write('"${stub.typeName}": '); |
252 stub.generateBody(code); | 253 stub.generateBody(code); |
253 code.writeln(','); | 254 code.writeln(stub == lastOne ? '' : ','); |
254 } | 255 } |
255 code.exitBlock('});'); | 256 code.exitBlock('});'); |
256 } | 257 } |
257 } | 258 } |
258 | 259 |
259 String _getCallStubName(String name, Arguments args) { | 260 String _getCallStubName(String name, Arguments args) { |
260 final nameBuilder = new StringBuffer('${name}\$${args.bareCount}'); | 261 final nameBuilder = new StringBuffer('${name}\$${args.bareCount}'); |
261 for (int i = args.bareCount; i < args.length; i++) { | 262 for (int i = args.bareCount; i < args.length; i++) { |
262 nameBuilder.add('\$').add(args.getName(i)); | 263 nameBuilder.add('\$').add(args.getName(i)); |
263 } | 264 } |
264 return nameBuilder.toString(); | 265 return nameBuilder.toString(); |
265 } | 266 } |
OLD | NEW |