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

Side by Side Diff: dart/frog/leg/elements/elements.dart

Issue 9447100: Return null from stringValue and call slowToString() instead of toString(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: changes Created 8 years, 9 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 | dart/frog/leg/emitter.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 #library('elements'); 5 #library('elements');
6 6
7 #import('../tree/tree.dart'); 7 #import('../tree/tree.dart');
8 #import('../scanner/scannerlib.dart'); 8 #import('../scanner/scannerlib.dart');
9 #import('../leg.dart'); // TODO(karlklose): we only need type. 9 #import('../leg.dart'); // TODO(karlklose): we only need type.
10 #import('../util/util.dart'); 10 #import('../util/util.dart');
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 void addMember(Element element, DiagnosticListener listener) { 530 void addMember(Element element, DiagnosticListener listener) {
531 members = members.prepend(element); 531 members = members.prepend(element);
532 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR || 532 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR ||
533 element.modifiers.isFactory()) { 533 element.modifiers.isFactory()) {
534 constructors[element.name] = element; 534 constructors[element.name] = element;
535 } else if (element.kind == ElementKind.GETTER 535 } else if (element.kind == ElementKind.GETTER
536 || element.kind == ElementKind.SETTER) { 536 || element.kind == ElementKind.SETTER) {
537 Element existing = localMembers[element.name]; 537 Element existing = localMembers[element.name];
538 if (existing != null) { 538 if (existing != null) {
539 if (existing.kind !== ElementKind.ABSTRACT_FIELD) { 539 if (existing.kind !== ElementKind.ABSTRACT_FIELD) {
540 listener.cancel('duplicate definition of $name', element: element); 540 listener.cancel('duplicate definition of ${name.slowToString()}',
541 element: element);
541 listener.cancel('existing definition', element: existing); 542 listener.cancel('existing definition', element: existing);
542 } else { 543 } else {
543 AbstractFieldElement field = existing; 544 AbstractFieldElement field = existing;
544 if (element.kind == ElementKind.GETTER) { 545 if (element.kind == ElementKind.GETTER) {
545 if (field.getter != null) { 546 if (field.getter != null) {
546 listener.cancel('duplicate definition of getter ${element.name}', 547 listener.cancel('duplicate definition of getter ${element.name}',
547 element: element); 548 element: element);
548 listener.cancel('existing definition', element: field.getter); 549 listener.cancel('existing definition', element: field.getter);
549 } else { 550 } else {
550 field.getter = element; 551 field.getter = element;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 Element element = elements[send]; 699 Element element = elements[send];
699 // (o)() or foo()(). 700 // (o)() or foo()().
700 if (element === null && send.selector.asIdentifier() === null) return true; 701 if (element === null && send.selector.asIdentifier() === null) return true;
701 if (element === null) return false; 702 if (element === null) return false;
702 // foo() with foo a local or a parameter. 703 // foo() with foo a local or a parameter.
703 return isLocal(element); 704 return isLocal(element);
704 } 705 }
705 706
706 static SourceString constructConstructorName(SourceString receiver, 707 static SourceString constructConstructorName(SourceString receiver,
707 SourceString selector) { 708 SourceString selector) {
708 return new SourceString('$receiver\$$selector'); 709 String r = receiver.slowToString();
710 String s = selector.slowToString();
711 return new SourceString('$r\$$s');
709 } 712 }
710 713
711 static SourceString constructOperatorName(SourceString receiver, 714 static SourceString constructOperatorName(SourceString receiver,
712 SourceString selector, 715 SourceString selector,
713 [bool isPrefix = false]) { 716 [bool isPrefix = false]) {
714 String str = selector.stringValue; 717 String str = selector.stringValue;
715 if (str === '==' || str === '!=') return Namer.OPERATOR_EQUALS; 718 if (str === '==' || str === '!=') return Namer.OPERATOR_EQUALS;
716 719
717 if (str === '~') str = 'not'; 720 if (str === '~') str = 'not';
718 else if (str === 'negate' || (str === '-' && isPrefix)) str = 'negate'; 721 else if (str === 'negate' || (str === '-' && isPrefix)) str = 'negate';
719 else if (str === '[]') str = 'index'; 722 else if (str === '[]') str = 'index';
720 else if (str === '[]=') str = 'indexSet'; 723 else if (str === '[]=') str = 'indexSet';
721 else if (str === '*' || str === '*=') str = 'mul'; 724 else if (str === '*' || str === '*=') str = 'mul';
722 else if (str === '/' || str === '/=') str = 'div'; 725 else if (str === '/' || str === '/=') str = 'div';
723 else if (str === '%' || str === '%=') str = 'mod'; 726 else if (str === '%' || str === '%=') str = 'mod';
724 else if (str === '~/' || str === '~/=') str = 'tdiv'; 727 else if (str === '~/' || str === '~/=') str = 'tdiv';
725 else if (str === '+' || str === '+=') str = 'add'; 728 else if (str === '+' || str === '+=') str = 'add';
726 else if (str === '-' || str === '-=') str = 'sub'; 729 else if (str === '-' || str === '-=') str = 'sub';
727 else if (str === '<<' || str === '<<=') str = 'shl'; 730 else if (str === '<<' || str === '<<=') str = 'shl';
728 else if (str === '>>' || str === '>>=') str = 'shr'; 731 else if (str === '>>' || str === '>>=') str = 'shr';
729 else if (str === '>=') str = 'ge'; 732 else if (str === '>=') str = 'ge';
730 else if (str === '>') str = 'gt'; 733 else if (str === '>') str = 'gt';
731 else if (str === '<=') str = 'le'; 734 else if (str === '<=') str = 'le';
732 else if (str === '<') str = 'lt'; 735 else if (str === '<') str = 'lt';
733 else if (str === '&' || str === '&=') str = 'and'; 736 else if (str === '&' || str === '&=') str = 'and';
734 else if (str === '^' || str === '^=') str = 'xor'; 737 else if (str === '^' || str === '^=') str = 'xor';
735 else if (str === '|' || str === '|=') str = 'or'; 738 else if (str === '|' || str === '|=') str = 'or';
739 else {
740 throw new Exception('Unhandled selector: ${selector.slowToString()}');
741 }
736 return new SourceString('$receiver\$$str'); 742 return new SourceString('$receiver\$$str');
737 } 743 }
738 } 744 }
739 745
740 // Represents a reference to a statement, either a label or the 746 // Represents a reference to a statement, either a label or the
741 // default target of a break or continue. 747 // default target of a break or continue.
742 class StatementElement extends Element { 748 class StatementElement extends Element {
743 final Statement origin; 749 final Statement origin;
744 bool isBreakTarget = false; 750 bool isBreakTarget = false;
745 bool isContinueTarget = false; 751 bool isContinueTarget = false;
746 752
747 StatementElement(this.origin, Element enclosingElement) 753 StatementElement(this.origin, Element enclosingElement)
748 : super(const SourceString(""), ElementKind.STATEMENT, enclosingElement); 754 : super(const SourceString(""), ElementKind.STATEMENT, enclosingElement);
749 StatementElement.label(String name, this.origin, Element enclosingElement) 755 StatementElement.label(String name, this.origin, Element enclosingElement)
750 : super(new SourceString(name), ElementKind.STATEMENT, enclosingElement); 756 : super(new SourceString(name), ElementKind.STATEMENT, enclosingElement);
751 bool get isTarget() => isBreakTarget || isContinueTarget; 757 bool get isTarget() => isBreakTarget || isContinueTarget;
752 758
753 Node parseNode(DiagnosticListener l) => origin; 759 Node parseNode(DiagnosticListener l) => origin;
754 } 760 }
OLDNEW
« no previous file with comments | « no previous file | dart/frog/leg/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698