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

Side by Side Diff: pkg/js_ast/lib/src/nodes.dart

Issue 2748103010: Run dartfmt on js_ast (Closed)
Patch Set: Created 3 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
« no previous file with comments | « pkg/js_ast/lib/src/characters.dart ('k') | pkg/js_ast/lib/src/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_ast; 5 part of js_ast;
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return null; 88 return null;
89 } 89 }
90 90
91 T visitProgram(Program node) => visitNode(node); 91 T visitProgram(Program node) => visitNode(node);
92 92
93 T visitStatement(Statement node) => visitNode(node); 93 T visitStatement(Statement node) => visitNode(node);
94 T visitLoop(Loop node) => visitStatement(node); 94 T visitLoop(Loop node) => visitStatement(node);
95 T visitJump(Statement node) => visitStatement(node); 95 T visitJump(Statement node) => visitStatement(node);
96 96
97 T visitBlock(Block node) => visitStatement(node); 97 T visitBlock(Block node) => visitStatement(node);
98 T visitExpressionStatement(ExpressionStatement node) 98 T visitExpressionStatement(ExpressionStatement node) => visitStatement(node);
99 => visitStatement(node);
100 T visitEmptyStatement(EmptyStatement node) => visitStatement(node); 99 T visitEmptyStatement(EmptyStatement node) => visitStatement(node);
101 T visitIf(If node) => visitStatement(node); 100 T visitIf(If node) => visitStatement(node);
102 T visitFor(For node) => visitLoop(node); 101 T visitFor(For node) => visitLoop(node);
103 T visitForIn(ForIn node) => visitLoop(node); 102 T visitForIn(ForIn node) => visitLoop(node);
104 T visitWhile(While node) => visitLoop(node); 103 T visitWhile(While node) => visitLoop(node);
105 T visitDo(Do node) => visitLoop(node); 104 T visitDo(Do node) => visitLoop(node);
106 T visitContinue(Continue node) => visitJump(node); 105 T visitContinue(Continue node) => visitJump(node);
107 T visitBreak(Break node) => visitJump(node); 106 T visitBreak(Break node) => visitJump(node);
108 T visitReturn(Return node) => visitJump(node); 107 T visitReturn(Return node) => visitJump(node);
109 T visitThrow(Throw node) => visitJump(node); 108 T visitThrow(Throw node) => visitJump(node);
110 T visitTry(Try node) => visitStatement(node); 109 T visitTry(Try node) => visitStatement(node);
111 T visitSwitch(Switch node) => visitStatement(node); 110 T visitSwitch(Switch node) => visitStatement(node);
112 T visitFunctionDeclaration(FunctionDeclaration node) 111 T visitFunctionDeclaration(FunctionDeclaration node) => visitStatement(node);
113 => visitStatement(node);
114 T visitLabeledStatement(LabeledStatement node) => visitStatement(node); 112 T visitLabeledStatement(LabeledStatement node) => visitStatement(node);
115 T visitLiteralStatement(LiteralStatement node) => visitStatement(node); 113 T visitLiteralStatement(LiteralStatement node) => visitStatement(node);
116 114
117 T visitCatch(Catch node) => visitNode(node); 115 T visitCatch(Catch node) => visitNode(node);
118 T visitCase(Case node) => visitNode(node); 116 T visitCase(Case node) => visitNode(node);
119 T visitDefault(Default node) => visitNode(node); 117 T visitDefault(Default node) => visitNode(node);
120 118
121 T visitExpression(Expression node) => visitNode(node); 119 T visitExpression(Expression node) => visitNode(node);
122 T visitVariableReference(VariableReference node) => visitExpression(node); 120 T visitVariableReference(VariableReference node) => visitExpression(node);
123 121
124 T visitLiteralExpression(LiteralExpression node) => visitExpression(node); 122 T visitLiteralExpression(LiteralExpression node) => visitExpression(node);
125 T visitVariableDeclarationList(VariableDeclarationList node) 123 T visitVariableDeclarationList(VariableDeclarationList node) =>
126 => visitExpression(node); 124 visitExpression(node);
127 T visitAssignment(Assignment node) => visitExpression(node); 125 T visitAssignment(Assignment node) => visitExpression(node);
128 T visitVariableInitialization(VariableInitialization node) { 126 T visitVariableInitialization(VariableInitialization node) {
129 if (node.value != null) { 127 if (node.value != null) {
130 return visitAssignment(node); 128 return visitAssignment(node);
131 } else { 129 } else {
132 return visitExpression(node); 130 return visitExpression(node);
133 } 131 }
134 } 132 }
133
135 T visitConditional(Conditional node) => visitExpression(node); 134 T visitConditional(Conditional node) => visitExpression(node);
136 T visitNew(New node) => visitExpression(node); 135 T visitNew(New node) => visitExpression(node);
137 T visitCall(Call node) => visitExpression(node); 136 T visitCall(Call node) => visitExpression(node);
138 T visitBinary(Binary node) => visitExpression(node); 137 T visitBinary(Binary node) => visitExpression(node);
139 T visitPrefix(Prefix node) => visitExpression(node); 138 T visitPrefix(Prefix node) => visitExpression(node);
140 T visitPostfix(Postfix node) => visitExpression(node); 139 T visitPostfix(Postfix node) => visitExpression(node);
141 T visitAccess(PropertyAccess node) => visitExpression(node); 140 T visitAccess(PropertyAccess node) => visitExpression(node);
142 141
143 T visitVariableUse(VariableUse node) => visitVariableReference(node); 142 T visitVariableUse(VariableUse node) => visitVariableReference(node);
144 T visitVariableDeclaration(VariableDeclaration node) 143 T visitVariableDeclaration(VariableDeclaration node) =>
145 => visitVariableReference(node); 144 visitVariableReference(node);
146 T visitParameter(Parameter node) => visitVariableDeclaration(node); 145 T visitParameter(Parameter node) => visitVariableDeclaration(node);
147 T visitThis(This node) => visitParameter(node); 146 T visitThis(This node) => visitParameter(node);
148 147
149 T visitNamedFunction(NamedFunction node) => visitExpression(node); 148 T visitNamedFunction(NamedFunction node) => visitExpression(node);
150 T visitFun(Fun node) => visitExpression(node); 149 T visitFun(Fun node) => visitExpression(node);
151 150
152 T visitToken(DeferredToken node) => visitExpression(node); 151 T visitToken(DeferredToken node) => visitExpression(node);
153 152
154 T visitDeferredExpression(DeferredExpression node) => visitExpression(node); 153 T visitDeferredExpression(DeferredExpression node) => visitExpression(node);
155 T visitDeferredNumber(DeferredNumber node) => visitToken(node); 154 T visitDeferredNumber(DeferredNumber node) => visitToken(node);
(...skipping 11 matching lines...) Expand all
167 T visitName(Name node) => visitNode(node); 166 T visitName(Name node) => visitNode(node);
168 167
169 T visitArrayInitializer(ArrayInitializer node) => visitExpression(node); 168 T visitArrayInitializer(ArrayInitializer node) => visitExpression(node);
170 T visitArrayHole(ArrayHole node) => visitExpression(node); 169 T visitArrayHole(ArrayHole node) => visitExpression(node);
171 T visitObjectInitializer(ObjectInitializer node) => visitExpression(node); 170 T visitObjectInitializer(ObjectInitializer node) => visitExpression(node);
172 T visitProperty(Property node) => visitNode(node); 171 T visitProperty(Property node) => visitNode(node);
173 T visitRegExpLiteral(RegExpLiteral node) => visitExpression(node); 172 T visitRegExpLiteral(RegExpLiteral node) => visitExpression(node);
174 173
175 T visitInterpolatedNode(InterpolatedNode node) => visitNode(node); 174 T visitInterpolatedNode(InterpolatedNode node) => visitNode(node);
176 175
177 T visitInterpolatedExpression(InterpolatedExpression node) 176 T visitInterpolatedExpression(InterpolatedExpression node) =>
178 => visitInterpolatedNode(node); 177 visitInterpolatedNode(node);
179 T visitInterpolatedLiteral(InterpolatedLiteral node) 178 T visitInterpolatedLiteral(InterpolatedLiteral node) =>
180 => visitInterpolatedNode(node); 179 visitInterpolatedNode(node);
181 T visitInterpolatedParameter(InterpolatedParameter node) 180 T visitInterpolatedParameter(InterpolatedParameter node) =>
182 => visitInterpolatedNode(node); 181 visitInterpolatedNode(node);
183 T visitInterpolatedSelector(InterpolatedSelector node) 182 T visitInterpolatedSelector(InterpolatedSelector node) =>
184 => visitInterpolatedNode(node); 183 visitInterpolatedNode(node);
185 T visitInterpolatedStatement(InterpolatedStatement node) 184 T visitInterpolatedStatement(InterpolatedStatement node) =>
186 => visitInterpolatedNode(node); 185 visitInterpolatedNode(node);
187 T visitInterpolatedDeclaration(InterpolatedDeclaration node) { 186 T visitInterpolatedDeclaration(InterpolatedDeclaration node) {
188 return visitInterpolatedNode(node); 187 return visitInterpolatedNode(node);
189 } 188 }
190 189
191 // Ignore comments by default. 190 // Ignore comments by default.
192 T visitComment(Comment node) => null; 191 T visitComment(Comment node) => null;
193 192
194 T visitAwait(Await node) => visitExpression(node); 193 T visitAwait(Await node) => visitExpression(node);
195 T visitDartYield(DartYield node) => visitStatement(node); 194 T visitDartYield(DartYield node) => visitStatement(node);
196 } 195 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 236 }
238 237
239 class Program extends Node { 238 class Program extends Node {
240 final List<Statement> body; 239 final List<Statement> body;
241 Program(this.body); 240 Program(this.body);
242 241
243 accept(NodeVisitor visitor) => visitor.visitProgram(this); 242 accept(NodeVisitor visitor) => visitor.visitProgram(this);
244 void visitChildren(NodeVisitor visitor) { 243 void visitChildren(NodeVisitor visitor) {
245 for (Statement statement in body) statement.accept(visitor); 244 for (Statement statement in body) statement.accept(visitor);
246 } 245 }
246
247 Program _clone() => new Program(body); 247 Program _clone() => new Program(body);
248 } 248 }
249 249
250 abstract class Statement extends Node { 250 abstract class Statement extends Node {
251 Statement toStatement() => this; 251 Statement toStatement() => this;
252 } 252 }
253 253
254 class Block extends Statement { 254 class Block extends Statement {
255 final List<Statement> statements; 255 final List<Statement> statements;
256 Block(this.statements); 256 Block(this.statements);
257 Block.empty() : this.statements = <Statement>[]; 257 Block.empty() : this.statements = <Statement>[];
258 258
259 accept(NodeVisitor visitor) => visitor.visitBlock(this); 259 accept(NodeVisitor visitor) => visitor.visitBlock(this);
260 void visitChildren(NodeVisitor visitor) { 260 void visitChildren(NodeVisitor visitor) {
261 for (Statement statement in statements) statement.accept(visitor); 261 for (Statement statement in statements) statement.accept(visitor);
262 } 262 }
263
263 Block _clone() => new Block(statements); 264 Block _clone() => new Block(statements);
264 } 265 }
265 266
266 class ExpressionStatement extends Statement { 267 class ExpressionStatement extends Statement {
267 final Expression expression; 268 final Expression expression;
268 ExpressionStatement(this.expression) { 269 ExpressionStatement(this.expression) {
269 assert(this.expression != null); 270 assert(this.expression != null);
270 } 271 }
271 272
272 accept(NodeVisitor visitor) => visitor.visitExpressionStatement(this); 273 accept(NodeVisitor visitor) => visitor.visitExpressionStatement(this);
273 void visitChildren(NodeVisitor visitor) { expression.accept(visitor); } 274 void visitChildren(NodeVisitor visitor) {
275 expression.accept(visitor);
276 }
277
274 ExpressionStatement _clone() => new ExpressionStatement(expression); 278 ExpressionStatement _clone() => new ExpressionStatement(expression);
275 } 279 }
276 280
277 class EmptyStatement extends Statement { 281 class EmptyStatement extends Statement {
278 EmptyStatement(); 282 EmptyStatement();
279 283
280 accept(NodeVisitor visitor) => visitor.visitEmptyStatement(this); 284 accept(NodeVisitor visitor) => visitor.visitEmptyStatement(this);
281 void visitChildren(NodeVisitor visitor) {} 285 void visitChildren(NodeVisitor visitor) {}
282 EmptyStatement _clone() => new EmptyStatement(); 286 EmptyStatement _clone() => new EmptyStatement();
283 } 287 }
284 288
285 class If extends Statement { 289 class If extends Statement {
286 final Expression condition; 290 final Expression condition;
287 final Statement then; 291 final Statement then;
288 final Statement otherwise; 292 final Statement otherwise;
289 293
290 If(this.condition, this.then, this.otherwise); 294 If(this.condition, this.then, this.otherwise);
291 If.noElse(this.condition, this.then) : this.otherwise = new EmptyStatement(); 295 If.noElse(this.condition, this.then) : this.otherwise = new EmptyStatement();
292 296
293 bool get hasElse => otherwise is !EmptyStatement; 297 bool get hasElse => otherwise is! EmptyStatement;
294 298
295 accept(NodeVisitor visitor) => visitor.visitIf(this); 299 accept(NodeVisitor visitor) => visitor.visitIf(this);
296 300
297 void visitChildren(NodeVisitor visitor) { 301 void visitChildren(NodeVisitor visitor) {
298 condition.accept(visitor); 302 condition.accept(visitor);
299 then.accept(visitor); 303 then.accept(visitor);
300 otherwise.accept(visitor); 304 otherwise.accept(visitor);
301 } 305 }
302 306
303 If _clone() => new If(condition, then, otherwise); 307 If _clone() => new If(condition, then, otherwise);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 374
371 void visitChildren(NodeVisitor visitor) { 375 void visitChildren(NodeVisitor visitor) {
372 body.accept(visitor); 376 body.accept(visitor);
373 condition.accept(visitor); 377 condition.accept(visitor);
374 } 378 }
375 379
376 Do _clone() => new Do(body, condition); 380 Do _clone() => new Do(body, condition);
377 } 381 }
378 382
379 class Continue extends Statement { 383 class Continue extends Statement {
380 final String targetLabel; // Can be null. 384 final String targetLabel; // Can be null.
381 385
382 Continue(this.targetLabel); 386 Continue(this.targetLabel);
383 387
384 accept(NodeVisitor visitor) => visitor.visitContinue(this); 388 accept(NodeVisitor visitor) => visitor.visitContinue(this);
385 void visitChildren(NodeVisitor visitor) {} 389 void visitChildren(NodeVisitor visitor) {}
386 390
387 Continue _clone() => new Continue(targetLabel); 391 Continue _clone() => new Continue(targetLabel);
388 } 392 }
389 393
390 class Break extends Statement { 394 class Break extends Statement {
391 final String targetLabel; // Can be null. 395 final String targetLabel; // Can be null.
392 396
393 Break(this.targetLabel); 397 Break(this.targetLabel);
394 398
395 accept(NodeVisitor visitor) => visitor.visitBreak(this); 399 accept(NodeVisitor visitor) => visitor.visitBreak(this);
396 void visitChildren(NodeVisitor visitor) {} 400 void visitChildren(NodeVisitor visitor) {}
397 401
398 Break _clone() => new Break(targetLabel); 402 Break _clone() => new Break(targetLabel);
399 } 403 }
400 404
401 class Return extends Statement { 405 class Return extends Statement {
402 final Expression value; // Can be null. 406 final Expression value; // Can be null.
403 407
404 Return([this.value = null]); 408 Return([this.value = null]);
405 409
406 accept(NodeVisitor visitor) => visitor.visitReturn(this); 410 accept(NodeVisitor visitor) => visitor.visitReturn(this);
407 411
408 void visitChildren(NodeVisitor visitor) { 412 void visitChildren(NodeVisitor visitor) {
409 if (value != null) value.accept(visitor); 413 if (value != null) value.accept(visitor);
410 } 414 }
411 415
412 Return _clone() => new Return(value); 416 Return _clone() => new Return(value);
413 } 417 }
414 418
415 class Throw extends Statement { 419 class Throw extends Statement {
416 final Expression expression; 420 final Expression expression;
417 421
418 Throw(this.expression); 422 Throw(this.expression);
419 423
420 accept(NodeVisitor visitor) => visitor.visitThrow(this); 424 accept(NodeVisitor visitor) => visitor.visitThrow(this);
421 425
422 void visitChildren(NodeVisitor visitor) { 426 void visitChildren(NodeVisitor visitor) {
423 expression.accept(visitor); 427 expression.accept(visitor);
424 } 428 }
425 429
426 Throw _clone() => new Throw(expression); 430 Throw _clone() => new Throw(expression);
427 } 431 }
428 432
429 class Try extends Statement { 433 class Try extends Statement {
430 final Block body; 434 final Block body;
431 final Catch catchPart; // Can be null if [finallyPart] is non-null. 435 final Catch catchPart; // Can be null if [finallyPart] is non-null.
432 final Block finallyPart; // Can be null if [catchPart] is non-null. 436 final Block finallyPart; // Can be null if [catchPart] is non-null.
433 437
434 Try(this.body, this.catchPart, this.finallyPart) { 438 Try(this.body, this.catchPart, this.finallyPart) {
435 assert(catchPart != null || finallyPart != null); 439 assert(catchPart != null || finallyPart != null);
436 } 440 }
437 441
438 accept(NodeVisitor visitor) => visitor.visitTry(this); 442 accept(NodeVisitor visitor) => visitor.visitTry(this);
439 443
440 void visitChildren(NodeVisitor visitor) { 444 void visitChildren(NodeVisitor visitor) {
441 body.accept(visitor); 445 body.accept(visitor);
442 if (catchPart != null) catchPart.accept(visitor); 446 if (catchPart != null) catchPart.accept(visitor);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 545
542 LabeledStatement _clone() => new LabeledStatement(label, body); 546 LabeledStatement _clone() => new LabeledStatement(label, body);
543 } 547 }
544 548
545 class LiteralStatement extends Statement { 549 class LiteralStatement extends Statement {
546 final String code; 550 final String code;
547 551
548 LiteralStatement(this.code); 552 LiteralStatement(this.code);
549 553
550 accept(NodeVisitor visitor) => visitor.visitLiteralStatement(this); 554 accept(NodeVisitor visitor) => visitor.visitLiteralStatement(this);
551 void visitChildren(NodeVisitor visitor) { } 555 void visitChildren(NodeVisitor visitor) {}
552 556
553 LiteralStatement _clone() => new LiteralStatement(code); 557 LiteralStatement _clone() => new LiteralStatement(code);
554 } 558 }
555 559
556 // Not a real JavaScript node, but represents the yield statement from a dart 560 // Not a real JavaScript node, but represents the yield statement from a dart
557 // program translated to JavaScript. 561 // program translated to JavaScript.
558 class DartYield extends Statement { 562 class DartYield extends Statement {
559 final Expression expression; 563 final Expression expression;
560 564
561 final bool hasStar; 565 final bool hasStar;
562 566
563 DartYield(this.expression, this.hasStar); 567 DartYield(this.expression, this.hasStar);
564 568
565 accept(NodeVisitor visitor) => visitor.visitDartYield(this); 569 accept(NodeVisitor visitor) => visitor.visitDartYield(this);
566 570
567 void visitChildren(NodeVisitor visitor) { 571 void visitChildren(NodeVisitor visitor) {
568 expression.accept(visitor); 572 expression.accept(visitor);
569 } 573 }
570 574
571 DartYield _clone() => new DartYield(expression, hasStar); 575 DartYield _clone() => new DartYield(expression, hasStar);
572 } 576 }
573 577
574 abstract class Expression extends Node { 578 abstract class Expression extends Node {
575 int get precedenceLevel; 579 int get precedenceLevel;
576 580
577 Statement toStatement() => new ExpressionStatement(this); 581 Statement toStatement() => new ExpressionStatement(this);
578 } 582 }
579 583
580 abstract class Declaration implements VariableReference { 584 abstract class Declaration implements VariableReference {}
581
582 }
583 585
584 /// An implementation of [Name] represents a potentially late bound name in 586 /// An implementation of [Name] represents a potentially late bound name in
585 /// the generated ast. 587 /// the generated ast.
586 /// 588 ///
587 /// While [Name] implements comparable, there is no requirement on the actual 589 /// While [Name] implements comparable, there is no requirement on the actual
588 /// implementation of [compareTo] other than that it needs to be stable. 590 /// implementation of [compareTo] other than that it needs to be stable.
589 /// In particular, there is no guarantee that implementations of [compareTo] 591 /// In particular, there is no guarantee that implementations of [compareTo]
590 /// will implement some form of lexicographic ordering like [String.compareTo]. 592 /// will implement some form of lexicographic ordering like [String.compareTo].
591 abstract class Name extends Literal 593 abstract class Name extends Literal
592 implements Declaration, Parameter, Comparable { 594 implements Declaration, Parameter, Comparable {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 } 655 }
654 } 656 }
655 657
656 VariableDeclarationList _clone() => new VariableDeclarationList(declarations); 658 VariableDeclarationList _clone() => new VariableDeclarationList(declarations);
657 659
658 int get precedenceLevel => EXPRESSION; 660 int get precedenceLevel => EXPRESSION;
659 } 661 }
660 662
661 class Assignment extends Expression { 663 class Assignment extends Expression {
662 final Expression leftHandSide; 664 final Expression leftHandSide;
663 final String op; // Null, if the assignment is not compound. 665 final String op; // Null, if the assignment is not compound.
664 final Expression value; // May be null, for [VariableInitialization]s. 666 final Expression value; // May be null, for [VariableInitialization]s.
665 667
666 Assignment(leftHandSide, value) 668 Assignment(leftHandSide, value) : this.compound(leftHandSide, null, value);
667 : this.compound(leftHandSide, null, value);
668 // If `this.op == null` this will be a non-compound assignment. 669 // If `this.op == null` this will be a non-compound assignment.
669 Assignment.compound(this.leftHandSide, this.op, this.value); 670 Assignment.compound(this.leftHandSide, this.op, this.value);
670 671
671 int get precedenceLevel => ASSIGNMENT; 672 int get precedenceLevel => ASSIGNMENT;
672 673
673 bool get isCompound => op != null; 674 bool get isCompound => op != null;
674 675
675 accept(NodeVisitor visitor) => visitor.visitAssignment(this); 676 accept(NodeVisitor visitor) => visitor.visitAssignment(this);
676 677
677 void visitChildren(NodeVisitor visitor) { 678 void visitChildren(NodeVisitor visitor) {
678 leftHandSide.accept(visitor); 679 leftHandSide.accept(visitor);
679 if (value != null) value.accept(visitor); 680 if (value != null) value.accept(visitor);
680 } 681 }
681 682
682 Assignment _clone() => 683 Assignment _clone() => new Assignment.compound(leftHandSide, op, value);
683 new Assignment.compound(leftHandSide, op, value);
684 } 684 }
685 685
686 class VariableInitialization extends Assignment { 686 class VariableInitialization extends Assignment {
687 /** [value] may be null. */ 687 /** [value] may be null. */
688 VariableInitialization(Declaration declaration, Expression value) 688 VariableInitialization(Declaration declaration, Expression value)
689 : super(declaration, value); 689 : super(declaration, value);
690 690
691 Declaration get declaration => leftHandSide; 691 Declaration get declaration => leftHandSide;
692 692
693 accept(NodeVisitor visitor) => visitor.visitVariableInitialization(this); 693 accept(NodeVisitor visitor) => visitor.visitVariableInitialization(this);
(...skipping 20 matching lines...) Expand all
714 Conditional _clone() => new Conditional(condition, then, otherwise); 714 Conditional _clone() => new Conditional(condition, then, otherwise);
715 715
716 int get precedenceLevel => ASSIGNMENT; 716 int get precedenceLevel => ASSIGNMENT;
717 } 717 }
718 718
719 class Call extends Expression { 719 class Call extends Expression {
720 Expression target; 720 Expression target;
721 List<Expression> arguments; 721 List<Expression> arguments;
722 722
723 Call(this.target, this.arguments, 723 Call(this.target, this.arguments,
724 {JavaScriptNodeSourceInformation sourceInformation}) { 724 {JavaScriptNodeSourceInformation sourceInformation}) {
725 this._sourceInformation = sourceInformation; 725 this._sourceInformation = sourceInformation;
726 } 726 }
727 727
728 accept(NodeVisitor visitor) => visitor.visitCall(this); 728 accept(NodeVisitor visitor) => visitor.visitCall(this);
729 729
730 void visitChildren(NodeVisitor visitor) { 730 void visitChildren(NodeVisitor visitor) {
731 target.accept(visitor); 731 target.accept(visitor);
732 for (Expression arg in arguments) { 732 for (Expression arg in arguments) {
733 arg.accept(visitor); 733 arg.accept(visitor);
734 } 734 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 Postfix(this.op, this.argument); 833 Postfix(this.op, this.argument);
834 834
835 accept(NodeVisitor visitor) => visitor.visitPostfix(this); 835 accept(NodeVisitor visitor) => visitor.visitPostfix(this);
836 836
837 Postfix _clone() => new Postfix(op, argument); 837 Postfix _clone() => new Postfix(op, argument);
838 838
839 void visitChildren(NodeVisitor visitor) { 839 void visitChildren(NodeVisitor visitor) {
840 argument.accept(visitor); 840 argument.accept(visitor);
841 } 841 }
842 842
843
844 int get precedenceLevel => UNARY; 843 int get precedenceLevel => UNARY;
845 } 844 }
846 845
847 abstract class VariableReference extends Expression { 846 abstract class VariableReference extends Expression {
848 final String name; 847 final String name;
849 848
850 VariableReference(this.name) { 849 VariableReference(this.name) {
851 assert(_identifierRE.hasMatch(name)); 850 assert(_identifierRE.hasMatch(name));
852 } 851 }
853 static RegExp _identifierRE = new RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$'); 852 static RegExp _identifierRE = new RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$');
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 final Fun function; 894 final Fun function;
896 895
897 NamedFunction(this.name, this.function); 896 NamedFunction(this.name, this.function);
898 897
899 accept(NodeVisitor visitor) => visitor.visitNamedFunction(this); 898 accept(NodeVisitor visitor) => visitor.visitNamedFunction(this);
900 899
901 void visitChildren(NodeVisitor visitor) { 900 void visitChildren(NodeVisitor visitor) {
902 name.accept(visitor); 901 name.accept(visitor);
903 function.accept(visitor); 902 function.accept(visitor);
904 } 903 }
904
905 NamedFunction _clone() => new NamedFunction(name, function); 905 NamedFunction _clone() => new NamedFunction(name, function);
906 906
907 int get precedenceLevel => LEFT_HAND_SIDE; 907 int get precedenceLevel => LEFT_HAND_SIDE;
908 } 908 }
909 909
910 class Fun extends Expression { 910 class Fun extends Expression {
911 final List<Parameter> params; 911 final List<Parameter> params;
912 final Block body; 912 final Block body;
913 final AsyncModifier asyncModifier; 913 final AsyncModifier asyncModifier;
914 914
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 accept(NodeVisitor visitor) => visitor.visitStringConcatenation(this); 1067 accept(NodeVisitor visitor) => visitor.visitStringConcatenation(this);
1068 1068
1069 void visitChildren(NodeVisitor visitor) { 1069 void visitChildren(NodeVisitor visitor) {
1070 for (Literal part in parts) part.accept(visitor); 1070 for (Literal part in parts) part.accept(visitor);
1071 } 1071 }
1072 1072
1073 StringConcatenation _clone() => new StringConcatenation(this.parts); 1073 StringConcatenation _clone() => new StringConcatenation(this.parts);
1074 } 1074 }
1075 1075
1076 class LiteralNumber extends Literal { 1076 class LiteralNumber extends Literal {
1077 final String value; // Must be a valid JavaScript number literal. 1077 final String value; // Must be a valid JavaScript number literal.
1078 1078
1079 LiteralNumber(this.value); 1079 LiteralNumber(this.value);
1080 1080
1081 int get precedenceLevel => value.startsWith('-') ? UNARY : PRIMARY; 1081 int get precedenceLevel => value.startsWith('-') ? UNARY : PRIMARY;
1082 1082
1083 accept(NodeVisitor visitor) => visitor.visitLiteralNumber(this); 1083 accept(NodeVisitor visitor) => visitor.visitLiteralNumber(this);
1084 LiteralNumber _clone() => new LiteralNumber(value); 1084 LiteralNumber _clone() => new LiteralNumber(value);
1085 } 1085 }
1086 1086
1087 class ArrayInitializer extends Expression { 1087 class ArrayInitializer extends Expression {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 bool get isPositional => nameOrPosition is int; 1163 bool get isPositional => nameOrPosition is int;
1164 } 1164 }
1165 1165
1166 class InterpolatedExpression extends Expression with InterpolatedNode { 1166 class InterpolatedExpression extends Expression with InterpolatedNode {
1167 final nameOrPosition; 1167 final nameOrPosition;
1168 1168
1169 InterpolatedExpression(this.nameOrPosition); 1169 InterpolatedExpression(this.nameOrPosition);
1170 1170
1171 accept(NodeVisitor visitor) => visitor.visitInterpolatedExpression(this); 1171 accept(NodeVisitor visitor) => visitor.visitInterpolatedExpression(this);
1172 void visitChildren(NodeVisitor visitor) {} 1172 void visitChildren(NodeVisitor visitor) {}
1173 InterpolatedExpression _clone() => 1173 InterpolatedExpression _clone() => new InterpolatedExpression(nameOrPosition);
1174 new InterpolatedExpression(nameOrPosition);
1175 1174
1176 int get precedenceLevel => PRIMARY; 1175 int get precedenceLevel => PRIMARY;
1177 } 1176 }
1178 1177
1179 class InterpolatedLiteral extends Literal with InterpolatedNode { 1178 class InterpolatedLiteral extends Literal with InterpolatedNode {
1180 final nameOrPosition; 1179 final nameOrPosition;
1181 1180
1182 InterpolatedLiteral(this.nameOrPosition); 1181 InterpolatedLiteral(this.nameOrPosition);
1183 1182
1184 accept(NodeVisitor visitor) => visitor.visitInterpolatedLiteral(this); 1183 accept(NodeVisitor visitor) => visitor.visitInterpolatedLiteral(this);
1185 void visitChildren(NodeVisitor visitor) {} 1184 void visitChildren(NodeVisitor visitor) {}
1186 InterpolatedLiteral _clone() => new InterpolatedLiteral(nameOrPosition); 1185 InterpolatedLiteral _clone() => new InterpolatedLiteral(nameOrPosition);
1187 } 1186 }
1188 1187
1189 class InterpolatedParameter extends Expression with InterpolatedNode 1188 class InterpolatedParameter extends Expression
1189 with InterpolatedNode
1190 implements Parameter { 1190 implements Parameter {
1191 final nameOrPosition; 1191 final nameOrPosition;
1192 1192
1193 String get name { throw "InterpolatedParameter.name must not be invoked"; } 1193 String get name {
1194 throw "InterpolatedParameter.name must not be invoked";
1195 }
1196
1194 bool get allowRename => false; 1197 bool get allowRename => false;
1195 1198
1196 InterpolatedParameter(this.nameOrPosition); 1199 InterpolatedParameter(this.nameOrPosition);
1197 1200
1198 accept(NodeVisitor visitor) => visitor.visitInterpolatedParameter(this); 1201 accept(NodeVisitor visitor) => visitor.visitInterpolatedParameter(this);
1199 void visitChildren(NodeVisitor visitor) {} 1202 void visitChildren(NodeVisitor visitor) {}
1200 InterpolatedParameter _clone() => new InterpolatedParameter(nameOrPosition); 1203 InterpolatedParameter _clone() => new InterpolatedParameter(nameOrPosition);
1201 1204
1202 int get precedenceLevel => PRIMARY; 1205 int get precedenceLevel => PRIMARY;
1203 } 1206 }
(...skipping 14 matching lines...) Expand all
1218 final nameOrPosition; 1221 final nameOrPosition;
1219 1222
1220 InterpolatedStatement(this.nameOrPosition); 1223 InterpolatedStatement(this.nameOrPosition);
1221 1224
1222 accept(NodeVisitor visitor) => visitor.visitInterpolatedStatement(this); 1225 accept(NodeVisitor visitor) => visitor.visitInterpolatedStatement(this);
1223 void visitChildren(NodeVisitor visitor) {} 1226 void visitChildren(NodeVisitor visitor) {}
1224 InterpolatedStatement _clone() => new InterpolatedStatement(nameOrPosition); 1227 InterpolatedStatement _clone() => new InterpolatedStatement(nameOrPosition);
1225 } 1228 }
1226 1229
1227 class InterpolatedDeclaration extends Expression 1230 class InterpolatedDeclaration extends Expression
1228 with InterpolatedNode 1231 with InterpolatedNode
1229 implements Declaration { 1232 implements Declaration {
1230 final nameOrPosition; 1233 final nameOrPosition;
1231 1234
1232 InterpolatedDeclaration(this.nameOrPosition); 1235 InterpolatedDeclaration(this.nameOrPosition);
1233 1236
1234 accept(NodeVisitor visitor) => visitor.visitInterpolatedDeclaration(this); 1237 accept(NodeVisitor visitor) => visitor.visitInterpolatedDeclaration(this);
1235 void visitChildren(NodeVisitor visitor) {} 1238 void visitChildren(NodeVisitor visitor) {}
1236 InterpolatedDeclaration _clone() { 1239 InterpolatedDeclaration _clone() {
1237 return new InterpolatedDeclaration(nameOrPosition); 1240 return new InterpolatedDeclaration(nameOrPosition);
1238 } 1241 }
1239 1242
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 class Comment extends Statement { 1292 class Comment extends Statement {
1290 final String comment; 1293 final String comment;
1291 1294
1292 Comment(this.comment); 1295 Comment(this.comment);
1293 1296
1294 accept(NodeVisitor visitor) => visitor.visitComment(this); 1297 accept(NodeVisitor visitor) => visitor.visitComment(this);
1295 Comment _clone() => new Comment(comment); 1298 Comment _clone() => new Comment(comment);
1296 1299
1297 void visitChildren(NodeVisitor visitor) {} 1300 void visitChildren(NodeVisitor visitor) {}
1298 } 1301 }
OLDNEW
« no previous file with comments | « pkg/js_ast/lib/src/characters.dart ('k') | pkg/js_ast/lib/src/printer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698