Chromium Code Reviews| 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 js.Expression code = backend.generatedCode[element]; | 409 js.Expression code = backend.generatedCode[element]; |
| 410 | 410 |
| 411 // TODO(kasperl): Figure out under which conditions code is null. | 411 // TODO(kasperl): Figure out under which conditions code is null. |
| 412 if (code == null) return null; | 412 if (code == null) return null; |
| 413 | 413 |
| 414 bool canTearOff = false; | 414 bool canTearOff = false; |
| 415 String tearOffName; | 415 String tearOffName; |
| 416 bool isClosure = false; | 416 bool isClosure = false; |
| 417 bool isNotApplyTarget = !element.isFunction || element.isAccessor; | 417 bool isNotApplyTarget = !element.isFunction || element.isAccessor; |
| 418 | 418 |
| 419 final bool needsStubs = _methodNeedsStubs(element); | 419 final bool needsStubs = _methodNeedsStubs(element); |
|
floitsch
2015/01/29 15:24:36
no need for final (here and other locals).
herhut
2015/02/03 10:20:17
Done.
| |
| 420 final bool canBeApplied = _methodCanBeApplied(element); | 420 final bool canBeApplied = _methodCanBeApplied(element); |
| 421 final bool hasSuperAlias = backend.isAliasedSuperMember(element); | 421 |
| 422 final String aliasName = backend.isAliasedSuperMember(element) ? | |
| 423 namer.getNameOfAliasedSuperMember(element) : null; | |
|
zarah
2015/01/29 15:15:11
Personal taste: if it can't fit on one line I thin
herhut
2015/02/03 10:20:17
Done.
| |
| 422 | 424 |
| 423 if (isNotApplyTarget) { | 425 if (isNotApplyTarget) { |
| 424 canTearOff = false; | 426 canTearOff = false; |
| 425 } else { | 427 } else { |
| 426 if (element.enclosingClass.isClosure) { | 428 if (element.enclosingClass.isClosure) { |
| 427 canTearOff = false; | 429 canTearOff = false; |
| 428 isClosure = true; | 430 isClosure = true; |
| 429 } else { | 431 } else { |
| 430 // Careful with operators. | 432 // Careful with operators. |
| 431 canTearOff = universe.hasInvokedGetter(element, _compiler.world); | 433 canTearOff = universe.hasInvokedGetter(element, _compiler.world); |
| 432 assert(canTearOff || | 434 assert(canTearOff || |
| 433 !universe.methodsNeedingSuperGetter.contains(element)); | 435 !universe.methodsNeedingSuperGetter.contains(element)); |
| 434 tearOffName = namer.getterName(element); | 436 tearOffName = namer.getterName(element); |
| 435 } | 437 } |
| 436 } | 438 } |
| 437 | 439 |
| 438 if (canTearOff) { | 440 if (canTearOff) { |
| 439 assert(invariant(element, !element.isGenerativeConstructor)); | 441 assert(invariant(element, !element.isGenerativeConstructor)); |
| 440 assert(invariant(element, !element.isGenerativeConstructorBody)); | 442 assert(invariant(element, !element.isGenerativeConstructorBody)); |
| 441 assert(invariant(element, !element.isConstructor)); | 443 assert(invariant(element, !element.isConstructor)); |
| 442 } | 444 } |
| 443 | 445 |
| 444 return new InstanceMethod(element, name, code, needsTearOff: canTearOff, | 446 return new InstanceMethod(element, name, code, needsTearOff: canTearOff, |
| 445 tearOffName: tearOffName, isClosure: isClosure, | 447 tearOffName: tearOffName, isClosure: isClosure, |
| 446 hasSuperAlias: hasSuperAlias, canBeApplied: canBeApplied, | 448 aliasName: aliasName, canBeApplied: canBeApplied, |
| 447 needsStubs: needsStubs); | 449 needsStubs: needsStubs); |
| 448 } | 450 } |
| 449 | 451 |
| 450 /// Builds a stub method. | 452 /// Builds a stub method. |
| 451 /// | 453 /// |
| 452 /// Stub methods may have an element that can be used for code-size | 454 /// Stub methods may have an element that can be used for code-size |
| 453 /// attribution. | 455 /// attribution. |
| 454 Method _buildStubMethod(String name, js.Expression code, | 456 Method _buildStubMethod(String name, js.Expression code, |
| 455 {Element element}) { | 457 {Element element}) { |
| 456 return new StubMethod(name, code, element: element); | 458 return new StubMethod(name, code, element: element); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 _registry.registerConstant(outputUnit, constantValue); | 580 _registry.registerConstant(outputUnit, constantValue); |
| 579 assert(!_constants.containsKey(constantValue)); | 581 assert(!_constants.containsKey(constantValue)); |
| 580 String name = namer.constantName(constantValue); | 582 String name = namer.constantName(constantValue); |
| 581 String constantObject = namer.globalObjectForConstant(constantValue); | 583 String constantObject = namer.globalObjectForConstant(constantValue); |
| 582 Holder holder = _registry.registerHolder(constantObject); | 584 Holder holder = _registry.registerHolder(constantObject); |
| 583 Constant constant = new Constant(name, holder, constantValue); | 585 Constant constant = new Constant(name, holder, constantValue); |
| 584 _constants[constantValue] = constant; | 586 _constants[constantValue] = constant; |
| 585 } | 587 } |
| 586 } | 588 } |
| 587 } | 589 } |
| OLD | NEW |