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

Side by Side Diff: dart/frog/leg/tree/nodes.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 | « dart/frog/leg/ssa/tracer.dart ('k') | dart/frog/leg/typechecker.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 interface Visitor<R> { 5 interface Visitor<R> {
6 R visitBlock(Block node); 6 R visitBlock(Block node);
7 R visitBreakStatement(BreakStatement node); 7 R visitBreakStatement(BreakStatement node);
8 R visitCatchBlock(CatchBlock node); 8 R visitCatchBlock(CatchBlock node);
9 R visitClassNode(ClassNode node); 9 R visitClassNode(ClassNode node);
10 R visitConditional(Conditional node); 10 R visitConditional(Conditional node);
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 575
576 class LiteralInt extends Literal<int> { 576 class LiteralInt extends Literal<int> {
577 LiteralInt(Token token, DecodeErrorHandler handler) : super(token, handler); 577 LiteralInt(Token token, DecodeErrorHandler handler) : super(token, handler);
578 578
579 LiteralInt asLiteralInt() => this; 579 LiteralInt asLiteralInt() => this;
580 580
581 int get value() { 581 int get value() {
582 try { 582 try {
583 Token token = this.token; 583 Token token = this.token;
584 if (token.kind === PLUS_TOKEN) token = token.next; 584 if (token.kind === PLUS_TOKEN) token = token.next;
585 return Math.parseInt(token.value.toString()); 585 return Math.parseInt(token.value.slowToString());
586 } catch (BadNumberFormatException ex) { 586 } catch (BadNumberFormatException ex) {
587 (this.handler)(token, ex); 587 (this.handler)(token, ex);
588 } 588 }
589 } 589 }
590 590
591 accept(Visitor visitor) => visitor.visitLiteralInt(this); 591 accept(Visitor visitor) => visitor.visitLiteralInt(this);
592 } 592 }
593 593
594 class LiteralDouble extends Literal<double> { 594 class LiteralDouble extends Literal<double> {
595 LiteralDouble(Token token, DecodeErrorHandler handler) 595 LiteralDouble(Token token, DecodeErrorHandler handler)
596 : super(token, handler); 596 : super(token, handler);
597 597
598 LiteralDouble asLiteralDouble() => this; 598 LiteralDouble asLiteralDouble() => this;
599 599
600 double get value() { 600 double get value() {
601 try { 601 try {
602 Token token = this.token; 602 Token token = this.token;
603 if (token.kind === PLUS_TOKEN) token = token.next; 603 if (token.kind === PLUS_TOKEN) token = token.next;
604 return Math.parseDouble(token.value.toString()); 604 return Math.parseDouble(token.value.slowToString());
605 } catch (BadNumberFormatException ex) { 605 } catch (BadNumberFormatException ex) {
606 (this.handler)(token, ex); 606 (this.handler)(token, ex);
607 } 607 }
608 } 608 }
609 609
610 accept(Visitor visitor) => visitor.visitLiteralDouble(this); 610 accept(Visitor visitor) => visitor.visitLiteralDouble(this);
611 } 611 }
612 612
613 class LiteralBool extends Literal<bool> { 613 class LiteralBool extends Literal<bool> {
614 LiteralBool(Token token, DecodeErrorHandler handler) : super(token, handler); 614 LiteralBool(Token token, DecodeErrorHandler handler) : super(token, handler);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 final int length; 741 final int length;
742 SourceBasedDartString(this.source, this.length); 742 SourceBasedDartString(this.source, this.length);
743 abstract Iterator<int> iterator(); 743 abstract Iterator<int> iterator();
744 } 744 }
745 745
746 class RawSourceDartString extends SourceBasedDartString { 746 class RawSourceDartString extends SourceBasedDartString {
747 RawSourceDartString(source, length) : super(source, length); 747 RawSourceDartString(source, length) : super(source, length);
748 Iterator<int> iterator() => source.iterator(); 748 Iterator<int> iterator() => source.iterator();
749 String toString() { 749 String toString() {
750 if (toStringCache !== null) return toStringCache; 750 if (toStringCache !== null) return toStringCache;
751 toStringCache = source.stringValue; 751 toStringCache = source.slowToString();
752 return toStringCache; 752 return toStringCache;
753 } 753 }
754 } 754 }
755 755
756 class EscapedSourceDartString extends SourceBasedDartString { 756 class EscapedSourceDartString extends SourceBasedDartString {
757 EscapedSourceDartString(source, length) : super(source, length); 757 EscapedSourceDartString(source, length) : super(source, length);
758 Iterator<int> iterator() { 758 Iterator<int> iterator() {
759 if (toStringCache !== null) return new StringCodeIterator(toStringCache); 759 if (toStringCache !== null) return new StringCodeIterator(toStringCache);
760 return new StringEscapeIterator(source); 760 return new StringEscapeIterator(source);
761 } 761 }
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 } 925 }
926 926
927 class Identifier extends Expression { 927 class Identifier extends Expression {
928 final Token token; 928 final Token token;
929 929
930 SourceString get source() => token.value; 930 SourceString get source() => token.value;
931 931
932 Identifier(Token this.token); 932 Identifier(Token this.token);
933 Identifier.synthetic(String name) : token = new StringToken(null, name, null); 933 Identifier.synthetic(String name) : token = new StringToken(null, name, null);
934 934
935 bool isThis() => source.stringValue == 'this'; 935 bool isThis() => source.stringValue === 'this';
936 936
937 bool isSuper() => source.stringValue == 'super'; 937 bool isSuper() => source.stringValue === 'super';
938 938
939 Identifier asIdentifier() => this; 939 Identifier asIdentifier() => this;
940 940
941 accept(Visitor visitor) => visitor.visitIdentifier(this); 941 accept(Visitor visitor) => visitor.visitIdentifier(this);
942 942
943 visitChildren(Visitor visitor) {} 943 visitChildren(Visitor visitor) {}
944 944
945 Token getBeginToken() => token; 945 Token getBeginToken() => token;
946 946
947 Token getEndToken() => token; 947 Token getEndToken() => token;
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 static bool isConstructorRedirect(Send node) { 1551 static bool isConstructorRedirect(Send node) {
1552 return (node.receiver === null && 1552 return (node.receiver === null &&
1553 node.selector.asIdentifier() !== null && 1553 node.selector.asIdentifier() !== null &&
1554 node.selector.asIdentifier().isThis()) || 1554 node.selector.asIdentifier().isThis()) ||
1555 (node.receiver !== null && 1555 (node.receiver !== null &&
1556 node.receiver.asIdentifier() !== null && 1556 node.receiver.asIdentifier() !== null &&
1557 node.receiver.asIdentifier().isThis() && 1557 node.receiver.asIdentifier().isThis() &&
1558 node.selector.asIdentifier() !== null); 1558 node.selector.asIdentifier() !== null);
1559 } 1559 }
1560 } 1560 }
OLDNEW
« no previous file with comments | « dart/frog/leg/ssa/tracer.dart ('k') | dart/frog/leg/typechecker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698