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.program_builder; | 5 library dart2js.js_emitter.program_builder; |
6 | 6 |
7 import 'js_emitter.dart' show computeMixinClass; | 7 import 'js_emitter.dart' show computeMixinClass; |
8 import 'model.dart'; | 8 import 'model.dart'; |
9 | 9 |
10 import '../common.dart'; | 10 import '../common.dart'; |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 if (element == _compiler.objectClass) { | 346 if (element == _compiler.objectClass) { |
347 Map<String, Selector> selectors = | 347 Map<String, Selector> selectors = |
348 classStubGenerator.computeSelectorsForNsmHandlers(); | 348 classStubGenerator.computeSelectorsForNsmHandlers(); |
349 selectors.forEach((String name, Selector selector) { | 349 selectors.forEach((String name, Selector selector) { |
350 noSuchMethodStubs | 350 noSuchMethodStubs |
351 .add(classStubGenerator.generateStubForNoSuchMethod(name, | 351 .add(classStubGenerator.generateStubForNoSuchMethod(name, |
352 selector)); | 352 selector)); |
353 }); | 353 }); |
354 } | 354 } |
355 | 355 |
| 356 if (element == backend.closureClass) { |
| 357 // We add a special getter here to allow for tearing off a closure from |
| 358 // itself. |
| 359 String name = namer.getterNameFromAccessorName( |
| 360 namer.getMappedInstanceName(Compiler.CALL_OPERATOR_NAME)); |
| 361 js.Fun function = js.js('function() { return this; }'); |
| 362 callStubs.add(_buildStubMethod(name, function)); |
| 363 } |
| 364 |
356 ClassElement implementation = element.implementation; | 365 ClassElement implementation = element.implementation; |
357 | 366 |
358 // MixinApplications run through the members of their mixin. Here, we are | 367 // MixinApplications run through the members of their mixin. Here, we are |
359 // only interested in direct members. | 368 // only interested in direct members. |
360 if (!onlyForRti && !element.isMixinApplication) { | 369 if (!onlyForRti && !element.isMixinApplication) { |
361 implementation.forEachMember(visitMember, includeBackendMembers: true); | 370 implementation.forEachMember(visitMember, includeBackendMembers: true); |
362 } | 371 } |
363 | 372 |
364 List<Field> instanceFields = | 373 List<Field> instanceFields = |
365 onlyForRti ? const <Field>[] : _buildFields(element, false); | 374 onlyForRti ? const <Field>[] : _buildFields(element, false); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 _registry.registerConstant(outputUnit, constantValue); | 667 _registry.registerConstant(outputUnit, constantValue); |
659 assert(!_constants.containsKey(constantValue)); | 668 assert(!_constants.containsKey(constantValue)); |
660 String name = namer.constantName(constantValue); | 669 String name = namer.constantName(constantValue); |
661 String constantObject = namer.globalObjectForConstant(constantValue); | 670 String constantObject = namer.globalObjectForConstant(constantValue); |
662 Holder holder = _registry.registerHolder(constantObject); | 671 Holder holder = _registry.registerHolder(constantObject); |
663 Constant constant = new Constant(name, holder, constantValue); | 672 Constant constant = new Constant(name, holder, constantValue); |
664 _constants[constantValue] = constant; | 673 _constants[constantValue] = constant; |
665 } | 674 } |
666 } | 675 } |
667 } | 676 } |
OLD | NEW |