Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 5 |
| 6 /** | 6 /** |
| 7 * If true, print a warning for each method that was resolved, but not | 7 * If true, print a warning for each method that was resolved, but not |
| 8 * compiled. | 8 * compiled. |
| 9 */ | 9 */ |
| 10 final bool REPORT_EXCESS_RESOLUTION = false; | 10 final bool REPORT_EXCESS_RESOLUTION = false; |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 delayedPatches.forEach((String path, LibraryElement importedLibrary) { | 549 delayedPatches.forEach((String path, LibraryElement importedLibrary) { |
| 550 patchDartLibrary(importedLibrary, path); | 550 patchDartLibrary(importedLibrary, path); |
| 551 }); | 551 }); |
| 552 } | 552 } |
| 553 | 553 |
| 554 void applyContainerPatch(ContainerElement original, Link<Element> patches, | 554 void applyContainerPatch(ContainerElement original, Link<Element> patches, |
| 555 Element lookup(SourceString name)) { | 555 Element lookup(SourceString name)) { |
| 556 while (!patches.isEmpty()) { | 556 while (!patches.isEmpty()) { |
| 557 Element patchElement = patches.head; | 557 Element patchElement = patches.head; |
| 558 Element originalElement = lookup(patchElement.name); | 558 Element originalElement = lookup(patchElement.name); |
| 559 if (patchElement.isAccessor()) { | 559 if (patchElement.isAccessor() && originalElement !== null) { |
|
Anders Johnsen
2012/08/07 13:02:30
Maybe move originalElement !== null check out (and
| |
| 560 // Skip accessors. An accessor always has an abstract field, | 560 if (originalElement.kind !== ElementKind.ABSTRACT_FIELD) { |
| 561 // representing the accessor in the lookup scope. We can thus skip the | |
| 562 // accessors and just handle the abstract field. | |
| 563 } else if (patchElement.kind === ElementKind.ABSTRACT_FIELD) { | |
| 564 // Getters and setters are kept inside a synthetic field. | |
| 565 if (originalElement !== null && | |
| 566 originalElement.kind !== ElementKind.ABSTRACT_FIELD) { | |
| 567 internalError("Cannot patch non-getter/setter with getter/setter", | 561 internalError("Cannot patch non-getter/setter with getter/setter", |
| 568 element: originalElement); | 562 element: originalElement); |
| 569 } | 563 } |
| 570 AbstractFieldElement patchField = patchElement; | |
| 571 AbstractFieldElement originalField = originalElement; | 564 AbstractFieldElement originalField = originalElement; |
| 572 if (patchField.getter !== null) { | 565 if (patchElement.isGetter()) { |
| 573 if (originalField === null || originalField.getter === null) { | 566 originalElement = originalField.getter; |
| 574 original.addGetterOrSetter(clonePatch(patchField.getter), | 567 } else { |
| 575 originalField, | 568 originalElement = originalField.setter; |
| 576 this); | |
| 577 if (originalField === null && patchField.setter !== null) { | |
| 578 // It exists now, so find it for the setter patching. | |
| 579 originalField = lookup(patchElement.name); | |
| 580 } | |
| 581 } else { | |
| 582 patchMember(originalField.getter, patchField.getter); | |
| 583 } | |
| 584 } | 569 } |
| 585 if (patchField.setter !== null) { | 570 } |
| 586 if (originalField === null || originalField.setter === null) { | 571 if (originalElement === null) { |
| 587 original.addGetterOrSetter(clonePatch(patchField.setter), | |
| 588 originalField, | |
| 589 this); | |
| 590 } else { | |
| 591 patchMember(originalField.setter, patchField.setter); | |
| 592 } | |
| 593 } | |
| 594 } else if (originalElement === null) { | |
| 595 if (isPatchElement(patchElement)) { | 572 if (isPatchElement(patchElement)) { |
| 596 internalError("Cannot patch non-existing member '" | 573 internalError("Cannot patch non-existing member '" |
| 597 "${patchElement.name.slowToString()}'."); | 574 "${patchElement.name.slowToString()}'."); |
| 598 } | 575 } |
| 599 original.addMember(clonePatch(patchElement), this); | 576 original.addMember(clonePatch(patchElement), this); |
| 600 } else { | 577 } else { |
| 601 patchMember(originalElement, patchElement); | 578 patchMember(originalElement, patchElement); |
| 602 } | 579 } |
| 603 patches = patches.tail; | 580 patches = patches.tail; |
| 604 } | 581 } |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1095 final endOffset = end.charOffset + end.slowCharCount; | 1072 final endOffset = end.charOffset + end.slowCharCount; |
| 1096 | 1073 |
| 1097 // [begin] and [end] might be the same for the same empty token. This | 1074 // [begin] and [end] might be the same for the same empty token. This |
| 1098 // happens for instance when scanning '$$'. | 1075 // happens for instance when scanning '$$'. |
| 1099 assert(endOffset >= beginOffset); | 1076 assert(endOffset >= beginOffset); |
| 1100 return f(beginOffset, endOffset); | 1077 return f(beginOffset, endOffset); |
| 1101 } | 1078 } |
| 1102 | 1079 |
| 1103 String toString() => 'SourceSpan($uri, $begin, $end)'; | 1080 String toString() => 'SourceSpan($uri, $begin, $end)'; |
| 1104 } | 1081 } |
| OLD | NEW |