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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js/nodes.dart

Issue 260233003: Remove js.Sequence and use binary comma operator instead. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 | sdk/lib/_internal/compiler/implementation/js/printer.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 part of js; 5 part of js;
6 6
7 abstract class NodeVisitor<T> { 7 abstract class NodeVisitor<T> {
8 T visitProgram(Program node); 8 T visitProgram(Program node);
9 9
10 T visitBlock(Block node); 10 T visitBlock(Block node);
(...skipping 13 matching lines...) Expand all
24 T visitSwitch(Switch node); 24 T visitSwitch(Switch node);
25 T visitCase(Case node); 25 T visitCase(Case node);
26 T visitDefault(Default node); 26 T visitDefault(Default node);
27 T visitFunctionDeclaration(FunctionDeclaration node); 27 T visitFunctionDeclaration(FunctionDeclaration node);
28 T visitLabeledStatement(LabeledStatement node); 28 T visitLabeledStatement(LabeledStatement node);
29 T visitLiteralStatement(LiteralStatement node); 29 T visitLiteralStatement(LiteralStatement node);
30 30
31 T visitBlob(Blob node); 31 T visitBlob(Blob node);
32 T visitLiteralExpression(LiteralExpression node); 32 T visitLiteralExpression(LiteralExpression node);
33 T visitVariableDeclarationList(VariableDeclarationList node); 33 T visitVariableDeclarationList(VariableDeclarationList node);
34 T visitSequence(Sequence node);
35 T visitAssignment(Assignment node); 34 T visitAssignment(Assignment node);
36 T visitVariableInitialization(VariableInitialization node); 35 T visitVariableInitialization(VariableInitialization node);
37 T visitConditional(Conditional cond); 36 T visitConditional(Conditional cond);
38 T visitNew(New node); 37 T visitNew(New node);
39 T visitCall(Call node); 38 T visitCall(Call node);
40 T visitBinary(Binary node); 39 T visitBinary(Binary node);
41 T visitPrefix(Prefix node); 40 T visitPrefix(Prefix node);
42 T visitPostfix(Postfix node); 41 T visitPostfix(Postfix node);
43 42
44 T visitVariableUse(VariableUse node); 43 T visitVariableUse(VariableUse node);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 T visitCase(Case node) => visitNode(node); 105 T visitCase(Case node) => visitNode(node);
107 T visitDefault(Default node) => visitNode(node); 106 T visitDefault(Default node) => visitNode(node);
108 107
109 T visitExpression(Expression node) => visitNode(node); 108 T visitExpression(Expression node) => visitNode(node);
110 T visitBlob(Blob node) => visitExpression(node); 109 T visitBlob(Blob node) => visitExpression(node);
111 T visitVariableReference(VariableReference node) => visitExpression(node); 110 T visitVariableReference(VariableReference node) => visitExpression(node);
112 111
113 T visitLiteralExpression(LiteralExpression node) => visitExpression(node); 112 T visitLiteralExpression(LiteralExpression node) => visitExpression(node);
114 T visitVariableDeclarationList(VariableDeclarationList node) 113 T visitVariableDeclarationList(VariableDeclarationList node)
115 => visitExpression(node); 114 => visitExpression(node);
116 T visitSequence(Sequence node) => visitExpression(node);
117 T visitAssignment(Assignment node) => visitExpression(node); 115 T visitAssignment(Assignment node) => visitExpression(node);
118 T visitVariableInitialization(VariableInitialization node) { 116 T visitVariableInitialization(VariableInitialization node) {
119 if (node.value != null) { 117 if (node.value != null) {
120 return visitAssignment(node); 118 return visitAssignment(node);
121 } else { 119 } else {
122 return visitExpression(node); 120 return visitExpression(node);
123 } 121 }
124 } 122 }
125 T visitConditional(Conditional node) => visitExpression(node); 123 T visitConditional(Conditional node) => visitExpression(node);
126 T visitNew(New node) => visitExpression(node); 124 T visitNew(New node) => visitExpression(node);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 return clone; 196 return clone;
199 } 197 }
200 198
201 // Returns a node equivalent to [this], but with new [this.sourcePositions], 199 // Returns a node equivalent to [this], but with new [this.sourcePositions],
202 // keeping the existing [endPosition] 200 // keeping the existing [endPosition]
203 Node withLocation(var sourcePosition) => 201 Node withLocation(var sourcePosition) =>
204 withPosition(sourcePosition, this.endSourcePosition); 202 withPosition(sourcePosition, this.endSourcePosition);
205 203
206 VariableUse asVariableUse() => null; 204 VariableUse asVariableUse() => null;
207 205
206 bool get isCommaOperator => false;
207
208 Statement toStatement() { 208 Statement toStatement() {
209 throw new UnsupportedError('toStatement'); 209 throw new UnsupportedError('toStatement');
210 } 210 }
211 } 211 }
212 212
213 class Program extends Node { 213 class Program extends Node {
214 final List<Statement> body; 214 final List<Statement> body;
215 Program(this.body); 215 Program(this.body);
216 216
217 accept(NodeVisitor visitor) => visitor.visitProgram(this); 217 accept(NodeVisitor visitor) => visitor.visitProgram(this);
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 for (VariableInitialization declaration in declarations) { 594 for (VariableInitialization declaration in declarations) {
595 declaration.accept(visitor); 595 declaration.accept(visitor);
596 } 596 }
597 } 597 }
598 598
599 VariableDeclarationList _clone() => new VariableDeclarationList(declarations); 599 VariableDeclarationList _clone() => new VariableDeclarationList(declarations);
600 600
601 int get precedenceLevel => EXPRESSION; 601 int get precedenceLevel => EXPRESSION;
602 } 602 }
603 603
604 class Sequence extends Expression {
605 final List<Expression> expressions;
606
607 Sequence(this.expressions);
608
609 accept(NodeVisitor visitor) => visitor.visitSequence(this);
610
611 void visitChildren(NodeVisitor visitor) {
612 for (Expression expr in expressions) expr.accept(visitor);
613 }
614
615 Sequence _clone() => new Sequence(expressions);
616
617 int get precedenceLevel => EXPRESSION;
618 }
619
620 class Assignment extends Expression { 604 class Assignment extends Expression {
621 final Expression leftHandSide; 605 final Expression leftHandSide;
622 final String op; // Null, if the assignment is not compound. 606 final String op; // Null, if the assignment is not compound.
623 final Expression value; // May be null, for [VariableInitialization]s. 607 final Expression value; // May be null, for [VariableInitialization]s.
624 608
625 Assignment(leftHandSide, value) 609 Assignment(leftHandSide, value)
626 : this.compound(leftHandSide, null, value); 610 : this.compound(leftHandSide, null, value);
627 Assignment.compound(this.leftHandSide, this.op, this.value); 611 Assignment.compound(this.leftHandSide, this.op, this.value);
628 612
629 int get precedenceLevel => ASSIGNMENT; 613 int get precedenceLevel => ASSIGNMENT;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 693
710 accept(NodeVisitor visitor) => visitor.visitBinary(this); 694 accept(NodeVisitor visitor) => visitor.visitBinary(this);
711 695
712 Binary _clone() => new Binary(op, left, right); 696 Binary _clone() => new Binary(op, left, right);
713 697
714 void visitChildren(NodeVisitor visitor) { 698 void visitChildren(NodeVisitor visitor) {
715 left.accept(visitor); 699 left.accept(visitor);
716 right.accept(visitor); 700 right.accept(visitor);
717 } 701 }
718 702
703 bool get isCommaOperator => op == ',';
704
719 int get precedenceLevel { 705 int get precedenceLevel {
720 // TODO(floitsch): switch to constant map. 706 // TODO(floitsch): switch to constant map.
721 switch (op) { 707 switch (op) {
722 case "*": 708 case "*":
723 case "/": 709 case "/":
724 case "%": 710 case "%":
725 return MULTIPLICATIVE; 711 return MULTIPLICATIVE;
726 case "+": 712 case "+":
727 case "-": 713 case "-":
728 return ADDITIVE; 714 return ADDITIVE;
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 class Comment extends Statement { 1110 class Comment extends Statement {
1125 final String comment; 1111 final String comment;
1126 1112
1127 Comment(this.comment); 1113 Comment(this.comment);
1128 1114
1129 accept(NodeVisitor visitor) => visitor.visitComment(this); 1115 accept(NodeVisitor visitor) => visitor.visitComment(this);
1130 Comment _clone() => new Comment(comment); 1116 Comment _clone() => new Comment(comment);
1131 1117
1132 void visitChildren(NodeVisitor visitor) {} 1118 void visitChildren(NodeVisitor visitor) {}
1133 } 1119 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/js/printer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698