| 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 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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 Token getEndToken() => token; | 615 Token getEndToken() => token; |
| 616 } | 616 } |
| 617 | 617 |
| 618 class LiteralInt extends Literal<int> { | 618 class LiteralInt extends Literal<int> { |
| 619 LiteralInt(Token token, DecodeErrorHandler handler) : super(token, handler); | 619 LiteralInt(Token token, DecodeErrorHandler handler) : super(token, handler); |
| 620 | 620 |
| 621 LiteralInt asLiteralInt() => this; | 621 LiteralInt asLiteralInt() => this; |
| 622 | 622 |
| 623 int get value() { | 623 int get value() { |
| 624 try { | 624 try { |
| 625 Token token = this.token; | 625 Token valueToken = token; |
| 626 if (token.kind === PLUS_TOKEN) token = token.next; | 626 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next; |
| 627 return Math.parseInt(token.value.slowToString()); | 627 return Math.parseInt(valueToken.value.slowToString()); |
| 628 } catch (BadNumberFormatException ex) { | 628 } catch (BadNumberFormatException ex) { |
| 629 (this.handler)(token, ex); | 629 (this.handler)(token, ex); |
| 630 } | 630 } |
| 631 } | 631 } |
| 632 | 632 |
| 633 accept(Visitor visitor) => visitor.visitLiteralInt(this); | 633 accept(Visitor visitor) => visitor.visitLiteralInt(this); |
| 634 } | 634 } |
| 635 | 635 |
| 636 class LiteralDouble extends Literal<double> { | 636 class LiteralDouble extends Literal<double> { |
| 637 LiteralDouble(Token token, DecodeErrorHandler handler) | 637 LiteralDouble(Token token, DecodeErrorHandler handler) |
| 638 : super(token, handler); | 638 : super(token, handler); |
| 639 | 639 |
| 640 LiteralDouble asLiteralDouble() => this; | 640 LiteralDouble asLiteralDouble() => this; |
| 641 | 641 |
| 642 double get value() { | 642 double get value() { |
| 643 try { | 643 try { |
| 644 Token token = this.token; | 644 Token valueToken = token; |
| 645 if (token.kind === PLUS_TOKEN) token = token.next; | 645 if (valueToken.kind === PLUS_TOKEN) valueToken = valueToken.next; |
| 646 return Math.parseDouble(token.value.slowToString()); | 646 return Math.parseDouble(valueToken.value.slowToString()); |
| 647 } catch (BadNumberFormatException ex) { | 647 } catch (BadNumberFormatException ex) { |
| 648 (this.handler)(token, ex); | 648 (this.handler)(token, ex); |
| 649 } | 649 } |
| 650 } | 650 } |
| 651 | 651 |
| 652 accept(Visitor visitor) => visitor.visitLiteralDouble(this); | 652 accept(Visitor visitor) => visitor.visitLiteralDouble(this); |
| 653 } | 653 } |
| 654 | 654 |
| 655 class LiteralBool extends Literal<bool> { | 655 class LiteralBool extends Literal<bool> { |
| 656 LiteralBool(Token token, DecodeErrorHandler handler) : super(token, handler); | 656 LiteralBool(Token token, DecodeErrorHandler handler) : super(token, handler); |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 token = token.next.next; | 1369 token = token.next.next; |
| 1370 } | 1370 } |
| 1371 Link<Token> recursiveGetCases(Token token, Link<Expression> expressions) { | 1371 Link<Token> recursiveGetCases(Token token, Link<Expression> expressions) { |
| 1372 if (token.stringValue === 'case') { | 1372 if (token.stringValue === 'case') { |
| 1373 Token colon = expressions.head.getEndToken().next; | 1373 Token colon = expressions.head.getEndToken().next; |
| 1374 return new Link<Token>(token, | 1374 return new Link<Token>(token, |
| 1375 recursiveGetCases(colon.next, expressions.tail)); | 1375 recursiveGetCases(colon.next, expressions.tail)); |
| 1376 } | 1376 } |
| 1377 return const EmptyLink<Token>(); | 1377 return const EmptyLink<Token>(); |
| 1378 } | 1378 } |
| 1379 return recursiveGetCases(token, expressions); | 1379 return recursiveGetCases(token, expressions.nodes); |
| 1380 } | 1380 } |
| 1381 } | 1381 } |
| 1382 | 1382 |
| 1383 class GotoStatement extends Statement { | 1383 class GotoStatement extends Statement { |
| 1384 final Identifier target; | 1384 final Identifier target; |
| 1385 final Token keywordToken; | 1385 final Token keywordToken; |
| 1386 final Token semicolonToken; | 1386 final Token semicolonToken; |
| 1387 | 1387 |
| 1388 GotoStatement(this.target, this.keywordToken, this.semicolonToken); | 1388 GotoStatement(this.target, this.keywordToken, this.semicolonToken); |
| 1389 | 1389 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1643 * argument). | 1643 * argument). |
| 1644 * | 1644 * |
| 1645 * TODO(ahe): This method is controversial, the team needs to discuss | 1645 * TODO(ahe): This method is controversial, the team needs to discuss |
| 1646 * if top-level methods are acceptable and what naming conventions to | 1646 * if top-level methods are acceptable and what naming conventions to |
| 1647 * use. | 1647 * use. |
| 1648 */ | 1648 */ |
| 1649 initializerDo(Node node, f(Node node)) { | 1649 initializerDo(Node node, f(Node node)) { |
| 1650 SendSet send = node.asSendSet(); | 1650 SendSet send = node.asSendSet(); |
| 1651 if (send !== null) return f(send.arguments.head); | 1651 if (send !== null) return f(send.arguments.head); |
| 1652 } | 1652 } |
| OLD | NEW |