| 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 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 visitCascade(Cascade node); | 8 R visitCascade(Cascade node); |
| 9 R visitCascadeReceiver(CascadeReceiver node); | 9 R visitCascadeReceiver(CascadeReceiver node); |
| 10 R visitCaseMatch(CaseMatch node); | 10 R visitCaseMatch(CaseMatch node); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 accept(Visitor visitor) => visitor.visitClassNode(this); | 204 accept(Visitor visitor) => visitor.visitClassNode(this); |
| 205 | 205 |
| 206 visitChildren(Visitor visitor) { | 206 visitChildren(Visitor visitor) { |
| 207 if (name !== null) name.accept(visitor); | 207 if (name !== null) name.accept(visitor); |
| 208 if (typeParameters !== null) typeParameters.accept(visitor); | 208 if (typeParameters !== null) typeParameters.accept(visitor); |
| 209 if (superclass !== null) superclass.accept(visitor); | 209 if (superclass !== null) superclass.accept(visitor); |
| 210 if (interfaces !== null) interfaces.accept(visitor); | 210 if (interfaces !== null) interfaces.accept(visitor); |
| 211 if (body !== null) body.accept(visitor); | 211 if (body !== null) body.accept(visitor); |
| 212 } | 212 } |
| 213 | 213 |
| 214 bool get isInterface() => beginToken.stringValue === 'interface'; | 214 bool get isInterface => beginToken.stringValue === 'interface'; |
| 215 | 215 |
| 216 bool get isClass() => !isInterface; | 216 bool get isClass => !isInterface; |
| 217 | 217 |
| 218 Token getBeginToken() => beginToken; | 218 Token getBeginToken() => beginToken; |
| 219 | 219 |
| 220 Token getEndToken() => endToken; | 220 Token getEndToken() => endToken; |
| 221 } | 221 } |
| 222 | 222 |
| 223 class Expression extends Node { | 223 class Expression extends Node { |
| 224 Expression(); | 224 Expression(); |
| 225 | 225 |
| 226 Expression asExpression() => this; | 226 Expression asExpression() => this; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 244 * A message send aka method invocation. In Dart, most operations can | 244 * A message send aka method invocation. In Dart, most operations can |
| 245 * (and should) be considered as message sends. Getters and setters | 245 * (and should) be considered as message sends. Getters and setters |
| 246 * are just methods with a special syntax. Consequently, we model | 246 * are just methods with a special syntax. Consequently, we model |
| 247 * property access, assignment, operators, and method calls with this | 247 * property access, assignment, operators, and method calls with this |
| 248 * one node. | 248 * one node. |
| 249 */ | 249 */ |
| 250 class Send extends Expression { | 250 class Send extends Expression { |
| 251 final Node receiver; | 251 final Node receiver; |
| 252 final Node selector; | 252 final Node selector; |
| 253 final NodeList argumentsNode; | 253 final NodeList argumentsNode; |
| 254 Link<Node> get arguments() => argumentsNode.nodes; | 254 Link<Node> get arguments => argumentsNode.nodes; |
| 255 | 255 |
| 256 Send([this.receiver, this.selector, this.argumentsNode]); | 256 Send([this.receiver, this.selector, this.argumentsNode]); |
| 257 Send.postfix(this.receiver, this.selector, [Node argument = null]) | 257 Send.postfix(this.receiver, this.selector, [Node argument = null]) |
| 258 : argumentsNode = (argument === null) | 258 : argumentsNode = (argument === null) |
| 259 ? new Postfix() | 259 ? new Postfix() |
| 260 : new Postfix.singleton(argument); | 260 : new Postfix.singleton(argument); |
| 261 Send.prefix(this.receiver, this.selector, [Node argument = null]) | 261 Send.prefix(this.receiver, this.selector, [Node argument = null]) |
| 262 : argumentsNode = (argument === null) | 262 : argumentsNode = (argument === null) |
| 263 ? new Prefix() | 263 ? new Prefix() |
| 264 : new Prefix.singleton(argument); | 264 : new Prefix.singleton(argument); |
| 265 | 265 |
| 266 Send asSend() => this; | 266 Send asSend() => this; |
| 267 | 267 |
| 268 accept(Visitor visitor) => visitor.visitSend(this); | 268 accept(Visitor visitor) => visitor.visitSend(this); |
| 269 | 269 |
| 270 visitChildren(Visitor visitor) { | 270 visitChildren(Visitor visitor) { |
| 271 if (receiver !== null) receiver.accept(visitor); | 271 if (receiver !== null) receiver.accept(visitor); |
| 272 if (selector !== null) selector.accept(visitor); | 272 if (selector !== null) selector.accept(visitor); |
| 273 if (argumentsNode !== null) argumentsNode.accept(visitor); | 273 if (argumentsNode !== null) argumentsNode.accept(visitor); |
| 274 } | 274 } |
| 275 | 275 |
| 276 int argumentCount() => (argumentsNode === null) ? -1 : argumentsNode.length(); | 276 int argumentCount() => (argumentsNode === null) ? -1 : argumentsNode.length(); |
| 277 | 277 |
| 278 bool get isSuperCall() { | 278 bool get isSuperCall { |
| 279 return receiver !== null && | 279 return receiver !== null && |
| 280 receiver.asIdentifier() !== null && | 280 receiver.asIdentifier() !== null && |
| 281 receiver.asIdentifier().isSuper(); | 281 receiver.asIdentifier().isSuper(); |
| 282 } | 282 } |
| 283 bool get isOperator() => selector is Operator; | 283 bool get isOperator => selector is Operator; |
| 284 bool get isPropertyAccess() => argumentsNode === null; | 284 bool get isPropertyAccess => argumentsNode === null; |
| 285 bool get isFunctionObjectInvocation() => selector === null; | 285 bool get isFunctionObjectInvocation => selector === null; |
| 286 bool get isPrefix() => argumentsNode is Prefix; | 286 bool get isPrefix => argumentsNode is Prefix; |
| 287 bool get isPostfix() => argumentsNode is Postfix; | 287 bool get isPostfix => argumentsNode is Postfix; |
| 288 bool get isCall() => !isOperator && !isPropertyAccess; | 288 bool get isCall => !isOperator && !isPropertyAccess; |
| 289 bool get isIndex() => | 289 bool get isIndex => |
| 290 isOperator && selector.asOperator().source.stringValue === '[]'; | 290 isOperator && selector.asOperator().source.stringValue === '[]'; |
| 291 bool get isLogicalAnd() => | 291 bool get isLogicalAnd => |
| 292 isOperator && selector.asOperator().source.stringValue === '&&'; | 292 isOperator && selector.asOperator().source.stringValue === '&&'; |
| 293 bool get isLogicalOr() => | 293 bool get isLogicalOr => |
| 294 isOperator && selector.asOperator().source.stringValue === '||'; | 294 isOperator && selector.asOperator().source.stringValue === '||'; |
| 295 | 295 |
| 296 Token getBeginToken() { | 296 Token getBeginToken() { |
| 297 if (isPrefix && !isIndex) return selector.getBeginToken(); | 297 if (isPrefix && !isIndex) return selector.getBeginToken(); |
| 298 return firstBeginToken(receiver, selector); | 298 return firstBeginToken(receiver, selector); |
| 299 } | 299 } |
| 300 | 300 |
| 301 Token getEndToken() { | 301 Token getEndToken() { |
| 302 if (isPrefix) { | 302 if (isPrefix) { |
| 303 if (receiver !== null) return receiver.getEndToken(); | 303 if (receiver !== null) return receiver.getEndToken(); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 final Statement elsePart; | 475 final Statement elsePart; |
| 476 | 476 |
| 477 final Token ifToken; | 477 final Token ifToken; |
| 478 final Token elseToken; | 478 final Token elseToken; |
| 479 | 479 |
| 480 If(this.condition, this.thenPart, this.elsePart, | 480 If(this.condition, this.thenPart, this.elsePart, |
| 481 this.ifToken, this.elseToken); | 481 this.ifToken, this.elseToken); |
| 482 | 482 |
| 483 If asIf() => this; | 483 If asIf() => this; |
| 484 | 484 |
| 485 bool get hasElsePart() => elsePart !== null; | 485 bool get hasElsePart => elsePart !== null; |
| 486 | 486 |
| 487 void validate() { | 487 void validate() { |
| 488 // TODO(ahe): Check that condition has size one. | 488 // TODO(ahe): Check that condition has size one. |
| 489 } | 489 } |
| 490 | 490 |
| 491 accept(Visitor visitor) => visitor.visitIf(this); | 491 accept(Visitor visitor) => visitor.visitIf(this); |
| 492 | 492 |
| 493 visitChildren(Visitor visitor) { | 493 visitChildren(Visitor visitor) { |
| 494 if (condition !== null) condition.accept(visitor); | 494 if (condition !== null) condition.accept(visitor); |
| 495 if (thenPart !== null) thenPart.accept(visitor); | 495 if (thenPart !== null) thenPart.accept(visitor); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 final Statement conditionStatement; | 537 final Statement conditionStatement; |
| 538 final NodeList update; | 538 final NodeList update; |
| 539 | 539 |
| 540 final Token forToken; | 540 final Token forToken; |
| 541 | 541 |
| 542 For(this.initializer, this.conditionStatement, this.update, body, | 542 For(this.initializer, this.conditionStatement, this.update, body, |
| 543 this.forToken) : super(body); | 543 this.forToken) : super(body); |
| 544 | 544 |
| 545 For asFor() => this; | 545 For asFor() => this; |
| 546 | 546 |
| 547 Expression get condition() { | 547 Expression get condition { |
| 548 if (conditionStatement is ExpressionStatement) { | 548 if (conditionStatement is ExpressionStatement) { |
| 549 return conditionStatement.asExpressionStatement().expression; | 549 return conditionStatement.asExpressionStatement().expression; |
| 550 } else { | 550 } else { |
| 551 return null; | 551 return null; |
| 552 } | 552 } |
| 553 } | 553 } |
| 554 | 554 |
| 555 accept(Visitor visitor) => visitor.visitFor(this); | 555 accept(Visitor visitor) => visitor.visitFor(this); |
| 556 | 556 |
| 557 visitChildren(Visitor visitor) { | 557 visitChildren(Visitor visitor) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 Token getBeginToken() => token; | 653 Token getBeginToken() => token; |
| 654 | 654 |
| 655 Token getEndToken() => token; | 655 Token getEndToken() => token; |
| 656 } | 656 } |
| 657 | 657 |
| 658 class LiteralInt extends Literal<int> { | 658 class LiteralInt extends Literal<int> { |
| 659 LiteralInt(Token token, DecodeErrorHandler handler) : super(token, handler); | 659 LiteralInt(Token token, DecodeErrorHandler handler) : super(token, handler); |
| 660 | 660 |
| 661 LiteralInt asLiteralInt() => this; | 661 LiteralInt asLiteralInt() => this; |
| 662 | 662 |
| 663 int get value() { | 663 int get value { |
| 664 try { | 664 try { |
| 665 Token valueToken = token; | 665 Token valueToken = token; |
| 666 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next; | 666 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next; |
| 667 return Math.parseInt(valueToken.value.slowToString()); | 667 return Math.parseInt(valueToken.value.slowToString()); |
| 668 } catch (FormatException ex) { | 668 } catch (FormatException ex) { |
| 669 (this.handler)(token, ex); | 669 (this.handler)(token, ex); |
| 670 } | 670 } |
| 671 } | 671 } |
| 672 | 672 |
| 673 accept(Visitor visitor) => visitor.visitLiteralInt(this); | 673 accept(Visitor visitor) => visitor.visitLiteralInt(this); |
| 674 } | 674 } |
| 675 | 675 |
| 676 class LiteralDouble extends Literal<double> { | 676 class LiteralDouble extends Literal<double> { |
| 677 LiteralDouble(Token token, DecodeErrorHandler handler) | 677 LiteralDouble(Token token, DecodeErrorHandler handler) |
| 678 : super(token, handler); | 678 : super(token, handler); |
| 679 | 679 |
| 680 LiteralDouble asLiteralDouble() => this; | 680 LiteralDouble asLiteralDouble() => this; |
| 681 | 681 |
| 682 double get value() { | 682 double get value { |
| 683 try { | 683 try { |
| 684 Token valueToken = token; | 684 Token valueToken = token; |
| 685 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next; | 685 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next; |
| 686 return Math.parseDouble(valueToken.value.slowToString()); | 686 return Math.parseDouble(valueToken.value.slowToString()); |
| 687 } catch (FormatException ex) { | 687 } catch (FormatException ex) { |
| 688 (this.handler)(token, ex); | 688 (this.handler)(token, ex); |
| 689 } | 689 } |
| 690 } | 690 } |
| 691 | 691 |
| 692 accept(Visitor visitor) => visitor.visitLiteralDouble(this); | 692 accept(Visitor visitor) => visitor.visitLiteralDouble(this); |
| 693 } | 693 } |
| 694 | 694 |
| 695 class LiteralBool extends Literal<bool> { | 695 class LiteralBool extends Literal<bool> { |
| 696 LiteralBool(Token token, DecodeErrorHandler handler) : super(token, handler); | 696 LiteralBool(Token token, DecodeErrorHandler handler) : super(token, handler); |
| 697 | 697 |
| 698 LiteralBool asLiteralBool() => this; | 698 LiteralBool asLiteralBool() => this; |
| 699 | 699 |
| 700 bool get value() { | 700 bool get value { |
| 701 if (token.value == Keyword.TRUE) return true; | 701 if (token.value == Keyword.TRUE) return true; |
| 702 if (token.value == Keyword.FALSE) return false; | 702 if (token.value == Keyword.FALSE) return false; |
| 703 (this.handler)(token, "not a bool ${token.value}"); | 703 (this.handler)(token, "not a bool ${token.value}"); |
| 704 } | 704 } |
| 705 | 705 |
| 706 accept(Visitor visitor) => visitor.visitLiteralBool(this); | 706 accept(Visitor visitor) => visitor.visitLiteralBool(this); |
| 707 } | 707 } |
| 708 | 708 |
| 709 | 709 |
| 710 class StringQuoting { | 710 class StringQuoting { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 MULTILINE_NL_SQ, | 758 MULTILINE_NL_SQ, |
| 759 RAW_MULTILINE_NL_SQ, | 759 RAW_MULTILINE_NL_SQ, |
| 760 MULTILINE_NL2_SQ, | 760 MULTILINE_NL2_SQ, |
| 761 RAW_MULTILINE_NL2_SQ | 761 RAW_MULTILINE_NL2_SQ |
| 762 ]; | 762 ]; |
| 763 final bool raw; | 763 final bool raw; |
| 764 final int leftQuoteCharCount; | 764 final int leftQuoteCharCount; |
| 765 final int quote; | 765 final int quote; |
| 766 const StringQuoting(this.quote, [bool raw, int leftQuoteLength]) | 766 const StringQuoting(this.quote, [bool raw, int leftQuoteLength]) |
| 767 : this.raw = raw, this.leftQuoteCharCount = leftQuoteLength; | 767 : this.raw = raw, this.leftQuoteCharCount = leftQuoteLength; |
| 768 String get quoteChar() => quote === $DQ ? '"' : "'"; | 768 String get quoteChar => quote === $DQ ? '"' : "'"; |
| 769 | 769 |
| 770 int get leftQuoteLength() => (raw ? 1 : 0) + leftQuoteCharCount; | 770 int get leftQuoteLength => (raw ? 1 : 0) + leftQuoteCharCount; |
| 771 int get rightQuoteLength() => (leftQuoteCharCount > 2) ? 3 : 1; | 771 int get rightQuoteLength => (leftQuoteCharCount > 2) ? 3 : 1; |
| 772 static StringQuoting getQuoting(int quote, bool raw, int quoteLength) { | 772 static StringQuoting getQuoting(int quote, bool raw, int quoteLength) { |
| 773 int index = quoteLength - 1; | 773 int index = quoteLength - 1; |
| 774 if (quoteLength > 2) index -= 1; | 774 if (quoteLength > 2) index -= 1; |
| 775 return mapping[(raw ? 1 : 0) + index * 2 + (quote === $SQ ? 8 : 0)]; | 775 return mapping[(raw ? 1 : 0) + index * 2 + (quote === $SQ ? 8 : 0)]; |
| 776 } | 776 } |
| 777 } | 777 } |
| 778 | 778 |
| 779 /** | 779 /** |
| 780 * Superclass for classes representing string literals. | 780 * Superclass for classes representing string literals. |
| 781 */ | 781 */ |
| 782 class StringNode extends Expression { | 782 class StringNode extends Expression { |
| 783 abstract DartString get dartString(); | 783 abstract DartString get dartString(); |
| 784 abstract bool get isInterpolation(); | 784 abstract bool get isInterpolation(); |
| 785 | 785 |
| 786 StringNode asStringNode() => this; | 786 StringNode asStringNode() => this; |
| 787 } | 787 } |
| 788 | 788 |
| 789 class LiteralString extends StringNode { | 789 class LiteralString extends StringNode { |
| 790 final Token token; | 790 final Token token; |
| 791 /** Non-null on validated string literals. */ | 791 /** Non-null on validated string literals. */ |
| 792 final DartString dartString; | 792 final DartString dartString; |
| 793 | 793 |
| 794 LiteralString(this.token, this.dartString); | 794 LiteralString(this.token, this.dartString); |
| 795 | 795 |
| 796 LiteralString asLiteralString() => this; | 796 LiteralString asLiteralString() => this; |
| 797 | 797 |
| 798 void visitChildren(Visitor visitor) {} | 798 void visitChildren(Visitor visitor) {} |
| 799 | 799 |
| 800 bool get isInterpolation() => false; | 800 bool get isInterpolation => false; |
| 801 bool isValidated() => dartString !== null; | 801 bool isValidated() => dartString !== null; |
| 802 | 802 |
| 803 Token getBeginToken() => token; | 803 Token getBeginToken() => token; |
| 804 Token getEndToken() => token; | 804 Token getEndToken() => token; |
| 805 | 805 |
| 806 accept(Visitor visitor) => visitor.visitLiteralString(this); | 806 accept(Visitor visitor) => visitor.visitLiteralString(this); |
| 807 } | 807 } |
| 808 | 808 |
| 809 class LiteralNull extends Literal<SourceString> { | 809 class LiteralNull extends Literal<SourceString> { |
| 810 LiteralNull(Token token) : super(token, null); | 810 LiteralNull(Token token) : super(token, null); |
| 811 | 811 |
| 812 LiteralNull asLiteralNull() => this; | 812 LiteralNull asLiteralNull() => this; |
| 813 | 813 |
| 814 SourceString get value() => null; | 814 SourceString get value => null; |
| 815 | 815 |
| 816 accept(Visitor visitor) => visitor.visitLiteralNull(this); | 816 accept(Visitor visitor) => visitor.visitLiteralNull(this); |
| 817 } | 817 } |
| 818 | 818 |
| 819 class LiteralList extends Expression { | 819 class LiteralList extends Expression { |
| 820 final TypeAnnotation type; | 820 final TypeAnnotation type; |
| 821 final NodeList elements; | 821 final NodeList elements; |
| 822 | 822 |
| 823 final Token constKeyword; | 823 final Token constKeyword; |
| 824 | 824 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 838 if (constKeyword !== null) return constKeyword; | 838 if (constKeyword !== null) return constKeyword; |
| 839 return firstBeginToken(type, elements); | 839 return firstBeginToken(type, elements); |
| 840 } | 840 } |
| 841 | 841 |
| 842 Token getEndToken() => elements.getEndToken(); | 842 Token getEndToken() => elements.getEndToken(); |
| 843 } | 843 } |
| 844 | 844 |
| 845 class Identifier extends Expression { | 845 class Identifier extends Expression { |
| 846 final Token token; | 846 final Token token; |
| 847 | 847 |
| 848 SourceString get source() => token.value; | 848 SourceString get source => token.value; |
| 849 | 849 |
| 850 Identifier(Token this.token); | 850 Identifier(Token this.token); |
| 851 | 851 |
| 852 bool isThis() => source.stringValue === 'this'; | 852 bool isThis() => source.stringValue === 'this'; |
| 853 | 853 |
| 854 bool isSuper() => source.stringValue === 'super'; | 854 bool isSuper() => source.stringValue === 'super'; |
| 855 | 855 |
| 856 Identifier asIdentifier() => this; | 856 Identifier asIdentifier() => this; |
| 857 | 857 |
| 858 accept(Visitor visitor) => visitor.visitIdentifier(this); | 858 accept(Visitor visitor) => visitor.visitIdentifier(this); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 874 | 874 |
| 875 class Return extends Statement { | 875 class Return extends Statement { |
| 876 final Expression expression; | 876 final Expression expression; |
| 877 final Token beginToken; | 877 final Token beginToken; |
| 878 final Token endToken; | 878 final Token endToken; |
| 879 | 879 |
| 880 Return(this.beginToken, this.endToken, this.expression); | 880 Return(this.beginToken, this.endToken, this.expression); |
| 881 | 881 |
| 882 Return asReturn() => this; | 882 Return asReturn() => this; |
| 883 | 883 |
| 884 bool get hasExpression() => expression !== null; | 884 bool get hasExpression => expression !== null; |
| 885 | 885 |
| 886 accept(Visitor visitor) => visitor.visitReturn(this); | 886 accept(Visitor visitor) => visitor.visitReturn(this); |
| 887 | 887 |
| 888 visitChildren(Visitor visitor) { | 888 visitChildren(Visitor visitor) { |
| 889 if (expression !== null) expression.accept(visitor); | 889 if (expression !== null) expression.accept(visitor); |
| 890 } | 890 } |
| 891 | 891 |
| 892 Token getBeginToken() => beginToken; | 892 Token getBeginToken() => beginToken; |
| 893 | 893 |
| 894 Token getEndToken() { | 894 Token getEndToken() { |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 } | 1156 } |
| 1157 | 1157 |
| 1158 class StringInterpolation extends StringNode { | 1158 class StringInterpolation extends StringNode { |
| 1159 final LiteralString string; | 1159 final LiteralString string; |
| 1160 final NodeList parts; | 1160 final NodeList parts; |
| 1161 | 1161 |
| 1162 StringInterpolation(this.string, this.parts); | 1162 StringInterpolation(this.string, this.parts); |
| 1163 | 1163 |
| 1164 StringInterpolation asStringInterpolation() => this; | 1164 StringInterpolation asStringInterpolation() => this; |
| 1165 | 1165 |
| 1166 DartString get dartString() => null; | 1166 DartString get dartString => null; |
| 1167 bool get isInterpolation() => true; | 1167 bool get isInterpolation => true; |
| 1168 | 1168 |
| 1169 accept(Visitor visitor) => visitor.visitStringInterpolation(this); | 1169 accept(Visitor visitor) => visitor.visitStringInterpolation(this); |
| 1170 | 1170 |
| 1171 visitChildren(Visitor visitor) { | 1171 visitChildren(Visitor visitor) { |
| 1172 string.accept(visitor); | 1172 string.accept(visitor); |
| 1173 parts.accept(visitor); | 1173 parts.accept(visitor); |
| 1174 } | 1174 } |
| 1175 | 1175 |
| 1176 Token getBeginToken() => string.getBeginToken(); | 1176 Token getBeginToken() => string.getBeginToken(); |
| 1177 Token getEndToken() => parts.getEndToken(); | 1177 Token getEndToken() => parts.getEndToken(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 * Caches a Dart string representation of the entire juxtaposition's | 1215 * Caches a Dart string representation of the entire juxtaposition's |
| 1216 * content. Only juxtapositions that don't (transitively) contains | 1216 * content. Only juxtapositions that don't (transitively) contains |
| 1217 * interpolations have a static representation. | 1217 * interpolations have a static representation. |
| 1218 */ | 1218 */ |
| 1219 DartString dartStringCache = null; | 1219 DartString dartStringCache = null; |
| 1220 | 1220 |
| 1221 StringJuxtaposition(this.first, this.second); | 1221 StringJuxtaposition(this.first, this.second); |
| 1222 | 1222 |
| 1223 StringJuxtaposition asStringJuxtaposition() => this; | 1223 StringJuxtaposition asStringJuxtaposition() => this; |
| 1224 | 1224 |
| 1225 bool get isInterpolation() { | 1225 bool get isInterpolation { |
| 1226 if (isInterpolationCache === null) { | 1226 if (isInterpolationCache === null) { |
| 1227 isInterpolationCache = (first.accept(const IsInterpolationVisitor()) || | 1227 isInterpolationCache = (first.accept(const IsInterpolationVisitor()) || |
| 1228 second.accept(const IsInterpolationVisitor())); | 1228 second.accept(const IsInterpolationVisitor())); |
| 1229 } | 1229 } |
| 1230 return isInterpolationCache; | 1230 return isInterpolationCache; |
| 1231 } | 1231 } |
| 1232 | 1232 |
| 1233 /** | 1233 /** |
| 1234 * Retrieve a single DartString that represents this entire juxtaposition | 1234 * Retrieve a single DartString that represents this entire juxtaposition |
| 1235 * of string literals. | 1235 * of string literals. |
| 1236 * Should only be called if [isInterpolation] returns false. | 1236 * Should only be called if [isInterpolation] returns false. |
| 1237 */ | 1237 */ |
| 1238 DartString get dartString() { | 1238 DartString get dartString { |
| 1239 if (isInterpolation) { | 1239 if (isInterpolation) { |
| 1240 throw new NodeAssertionFailure(this, | 1240 throw new NodeAssertionFailure(this, |
| 1241 "Getting dartString on interpolation;"); | 1241 "Getting dartString on interpolation;"); |
| 1242 } | 1242 } |
| 1243 if (dartStringCache === null) { | 1243 if (dartStringCache === null) { |
| 1244 DartString firstString = first.accept(const GetDartStringVisitor()); | 1244 DartString firstString = first.accept(const GetDartStringVisitor()); |
| 1245 DartString secondString = second.accept(const GetDartStringVisitor()); | 1245 DartString secondString = second.accept(const GetDartStringVisitor()); |
| 1246 if (firstString === null || secondString === null) { | 1246 if (firstString === null || secondString === null) { |
| 1247 return null; | 1247 return null; |
| 1248 } | 1248 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 final ParenthesizedExpression parenthesizedExpression; | 1354 final ParenthesizedExpression parenthesizedExpression; |
| 1355 final NodeList cases; | 1355 final NodeList cases; |
| 1356 | 1356 |
| 1357 final Token switchKeyword; | 1357 final Token switchKeyword; |
| 1358 | 1358 |
| 1359 SwitchStatement(this.parenthesizedExpression, this.cases, | 1359 SwitchStatement(this.parenthesizedExpression, this.cases, |
| 1360 this.switchKeyword); | 1360 this.switchKeyword); |
| 1361 | 1361 |
| 1362 SwitchStatement asSwitchStatement() => this; | 1362 SwitchStatement asSwitchStatement() => this; |
| 1363 | 1363 |
| 1364 Expression get expression() => parenthesizedExpression.expression; | 1364 Expression get expression => parenthesizedExpression.expression; |
| 1365 | 1365 |
| 1366 accept(Visitor visitor) => visitor.visitSwitchStatement(this); | 1366 accept(Visitor visitor) => visitor.visitSwitchStatement(this); |
| 1367 | 1367 |
| 1368 visitChildren(Visitor visitor) { | 1368 visitChildren(Visitor visitor) { |
| 1369 parenthesizedExpression.accept(visitor); | 1369 parenthesizedExpression.accept(visitor); |
| 1370 cases.accept(visitor); | 1370 cases.accept(visitor); |
| 1371 } | 1371 } |
| 1372 | 1372 |
| 1373 Token getBeginToken() => switchKeyword; | 1373 Token getBeginToken() => switchKeyword; |
| 1374 | 1374 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1404 /** List of statements, the body of the case. */ | 1404 /** List of statements, the body of the case. */ |
| 1405 final NodeList statements; | 1405 final NodeList statements; |
| 1406 | 1406 |
| 1407 final Token startToken; | 1407 final Token startToken; |
| 1408 | 1408 |
| 1409 SwitchCase(this.labelsAndCases, this.defaultKeyword, | 1409 SwitchCase(this.labelsAndCases, this.defaultKeyword, |
| 1410 this.statements, this.startToken); | 1410 this.statements, this.startToken); |
| 1411 | 1411 |
| 1412 SwitchCase asSwitchCase() => this; | 1412 SwitchCase asSwitchCase() => this; |
| 1413 | 1413 |
| 1414 bool get isDefaultCase() => defaultKeyword !== null; | 1414 bool get isDefaultCase => defaultKeyword !== null; |
| 1415 | 1415 |
| 1416 bool isValidContinueTarget() => true; | 1416 bool isValidContinueTarget() => true; |
| 1417 | 1417 |
| 1418 accept(Visitor visitor) => visitor.visitSwitchCase(this); | 1418 accept(Visitor visitor) => visitor.visitSwitchCase(this); |
| 1419 | 1419 |
| 1420 visitChildren(Visitor visitor) { | 1420 visitChildren(Visitor visitor) { |
| 1421 labelsAndCases.accept(visitor); | 1421 labelsAndCases.accept(visitor); |
| 1422 statements.accept(visitor); | 1422 statements.accept(visitor); |
| 1423 } | 1423 } |
| 1424 | 1424 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 class ForIn extends Loop { | 1481 class ForIn extends Loop { |
| 1482 final Node declaredIdentifier; | 1482 final Node declaredIdentifier; |
| 1483 final Expression expression; | 1483 final Expression expression; |
| 1484 | 1484 |
| 1485 final Token forToken; | 1485 final Token forToken; |
| 1486 final Token inToken; | 1486 final Token inToken; |
| 1487 | 1487 |
| 1488 ForIn(this.declaredIdentifier, this.expression, | 1488 ForIn(this.declaredIdentifier, this.expression, |
| 1489 Statement body, this.forToken, this.inToken) : super(body); | 1489 Statement body, this.forToken, this.inToken) : super(body); |
| 1490 | 1490 |
| 1491 Expression get condition() => null; | 1491 Expression get condition => null; |
| 1492 | 1492 |
| 1493 ForIn asForIn() => this; | 1493 ForIn asForIn() => this; |
| 1494 | 1494 |
| 1495 accept(Visitor visitor) => visitor.visitForIn(this); | 1495 accept(Visitor visitor) => visitor.visitForIn(this); |
| 1496 | 1496 |
| 1497 visitChildren(Visitor visitor) { | 1497 visitChildren(Visitor visitor) { |
| 1498 declaredIdentifier.accept(visitor); | 1498 declaredIdentifier.accept(visitor); |
| 1499 expression.accept(visitor); | 1499 expression.accept(visitor); |
| 1500 body.accept(visitor); | 1500 body.accept(visitor); |
| 1501 } | 1501 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 final Token onKeyword; | 1681 final Token onKeyword; |
| 1682 final Token catchKeyword; | 1682 final Token catchKeyword; |
| 1683 | 1683 |
| 1684 CatchBlock(this.type, this.formals, this.block, | 1684 CatchBlock(this.type, this.formals, this.block, |
| 1685 this.onKeyword, this.catchKeyword); | 1685 this.onKeyword, this.catchKeyword); |
| 1686 | 1686 |
| 1687 CatchBlock asCatchBlock() => this; | 1687 CatchBlock asCatchBlock() => this; |
| 1688 | 1688 |
| 1689 accept(Visitor visitor) => visitor.visitCatchBlock(this); | 1689 accept(Visitor visitor) => visitor.visitCatchBlock(this); |
| 1690 | 1690 |
| 1691 Node get exception() { | 1691 Node get exception { |
| 1692 if (formals.nodes.isEmpty()) return null; | 1692 if (formals.nodes.isEmpty()) return null; |
| 1693 VariableDefinitions declarations = formals.nodes.head; | 1693 VariableDefinitions declarations = formals.nodes.head; |
| 1694 return declarations.definitions.nodes.head; | 1694 return declarations.definitions.nodes.head; |
| 1695 } | 1695 } |
| 1696 | 1696 |
| 1697 Node get trace() { | 1697 Node get trace { |
| 1698 if (formals.nodes.isEmpty()) return null; | 1698 if (formals.nodes.isEmpty()) return null; |
| 1699 Link<Node> declarations = formals.nodes.tail; | 1699 Link<Node> declarations = formals.nodes.tail; |
| 1700 if (declarations.isEmpty()) return null; | 1700 if (declarations.isEmpty()) return null; |
| 1701 VariableDefinitions head = declarations.head; | 1701 VariableDefinitions head = declarations.head; |
| 1702 return head.definitions.nodes.head; | 1702 return head.definitions.nodes.head; |
| 1703 } | 1703 } |
| 1704 | 1704 |
| 1705 visitChildren(Visitor visitor) { | 1705 visitChildren(Visitor visitor) { |
| 1706 if (type != null) type.accept(visitor); | 1706 if (type != null) type.accept(visitor); |
| 1707 formals.accept(visitor); | 1707 formals.accept(visitor); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 * argument). | 1756 * argument). |
| 1757 * | 1757 * |
| 1758 * TODO(ahe): This method is controversial, the team needs to discuss | 1758 * TODO(ahe): This method is controversial, the team needs to discuss |
| 1759 * if top-level methods are acceptable and what naming conventions to | 1759 * if top-level methods are acceptable and what naming conventions to |
| 1760 * use. | 1760 * use. |
| 1761 */ | 1761 */ |
| 1762 initializerDo(Node node, f(Node node)) { | 1762 initializerDo(Node node, f(Node node)) { |
| 1763 SendSet send = node.asSendSet(); | 1763 SendSet send = node.asSendSet(); |
| 1764 if (send !== null) return f(send.arguments.head); | 1764 if (send !== null) return f(send.arguments.head); |
| 1765 } | 1765 } |
| OLD | NEW |