Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: lib/compiler/implementation/compiler.dart

Issue 10837140: Make addGetterOrSetter (now: defineAccessor) not add the abstract field as a member. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cleaner validation of member accessors. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | lib/compiler/implementation/elements/elements.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 if (patchUri !== null) { 381 if (patchUri !== null) {
382 patchParser.patchLibrary(patchUri, library); 382 patchParser.patchLibrary(patchUri, library);
383 } 383 }
384 } 384 }
385 385
386 void applyContainerPatch(ScopeContainerElement original, 386 void applyContainerPatch(ScopeContainerElement original,
387 Link<Element> patches) { 387 Link<Element> patches) {
388 while (!patches.isEmpty()) { 388 while (!patches.isEmpty()) {
389 Element patchElement = patches.head; 389 Element patchElement = patches.head;
390 Element originalElement = original.localLookup(patchElement.name); 390 Element originalElement = original.localLookup(patchElement.name);
391 if (patchElement.isAccessor()) { 391 if (patchElement.isAccessor() && originalElement !== null) {
392 // TODO(lrn): When we change to always add accessors to members, and 392 if (originalElement.kind !== ElementKind.ABSTRACT_FIELD) {
393 // not add abstract fields, the logic here should be reversed.
394 // For now, access getters through the abstract field and skip
395 // any accessors.
396 } else if (patchElement.kind === ElementKind.ABSTRACT_FIELD) {
397 // Getters and setters are kept inside a synthetic field.
398 if (originalElement !== null &&
399 originalElement.kind !== ElementKind.ABSTRACT_FIELD) {
400 internalError("Cannot patch non-getter/setter with getter/setter", 393 internalError("Cannot patch non-getter/setter with getter/setter",
401 element: originalElement); 394 element: originalElement);
402 } 395 }
403 AbstractFieldElement patchField = patchElement;
404 AbstractFieldElement originalField = originalElement; 396 AbstractFieldElement originalField = originalElement;
405 if (patchField.getter !== null) { 397 if (patchElement.isGetter()) {
406 if (originalField === null || originalField.getter === null) { 398 originalElement = originalField.getter;
407 original.addGetterOrSetter(clonePatch(patchField.getter, original), 399 } else {
408 originalField, 400 originalElement = originalField.setter;
409 this);
410 if (originalField === null && patchField.setter !== null) {
411 // It exists now, so find it for the setter patching.
412 originalField = original.localLookup(patchElement.name);
413 }
414 } else {
415 patchMember(originalField.getter, patchField.getter);
416 }
417 } 401 }
418 if (patchField.setter !== null) { 402 }
419 if (originalField === null || originalField.setter === null) { 403 if (originalElement === null) {
420 original.addGetterOrSetter(clonePatch(patchField.setter, original),
421 originalField,
422 this);
423 } else {
424 patchMember(originalField.setter, patchField.setter);
425 }
426 }
427 } else if (originalElement === null) {
428 if (isPatchElement(patchElement)) { 404 if (isPatchElement(patchElement)) {
429 internalError("Cannot patch non-existing member '" 405 internalError("Cannot patch non-existing member '"
430 "${patchElement.name.slowToString()}'."); 406 "${patchElement.name.slowToString()}'.");
431 } 407 }
432 original.addMember(clonePatch(patchElement, original), this); 408 original.addMember(clonePatch(patchElement, original), this);
433 } else { 409 } else {
434 patchMember(originalElement, patchElement); 410 patchMember(originalElement, patchElement);
435 } 411 }
436 patches = patches.tail; 412 patches = patches.tail;
437 } 413 }
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 final endOffset = end.charOffset + end.slowCharCount; 875 final endOffset = end.charOffset + end.slowCharCount;
900 876
901 // [begin] and [end] might be the same for the same empty token. This 877 // [begin] and [end] might be the same for the same empty token. This
902 // happens for instance when scanning '$$'. 878 // happens for instance when scanning '$$'.
903 assert(endOffset >= beginOffset); 879 assert(endOffset >= beginOffset);
904 return f(beginOffset, endOffset); 880 return f(beginOffset, endOffset);
905 } 881 }
906 882
907 String toString() => 'SourceSpan($uri, $begin, $end)'; 883 String toString() => 'SourceSpan($uri, $begin, $end)';
908 } 884 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/elements/elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698