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 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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 } | 458 } |
459 } | 459 } |
460 | 460 |
461 Statement toStatement() => new ExpressionStatement(this); | 461 Statement toStatement() => new ExpressionStatement(this); |
462 | 462 |
463 Call call([expression]) { | 463 Call call([expression]) { |
464 List<Expression> arguments; | 464 List<Expression> arguments; |
465 if (expression == null) { | 465 if (expression == null) { |
466 arguments = <Expression>[]; | 466 arguments = <Expression>[]; |
467 } else if (expression is List) { | 467 } else if (expression is List) { |
468 arguments = expression.map(js.toExpression).toList(); | 468 arguments = expression.map(jsBuilder.toExpression).toList(); |
469 } else { | 469 } else { |
470 arguments = <Expression>[js.toExpression(expression)]; | 470 arguments = <Expression>[jsBuilder.toExpression(expression)]; |
471 } | 471 } |
472 return callWith(arguments); | 472 return callWith(arguments); |
473 } | 473 } |
474 | 474 |
475 Expression equals(expression) => binary('==', expression); | 475 Expression equals(expression) => binary('==', expression); |
476 | 476 |
477 Expression strictEquals(expression) => binary('===', expression); | 477 Expression strictEquals(expression) => binary('===', expression); |
478 | 478 |
479 Expression notEquals(expression) => binary('!=', expression); | 479 Expression notEquals(expression) => binary('!=', expression); |
480 | 480 |
481 Expression operator +(expression) => binary('+', expression); | 481 Expression operator +(expression) => binary('+', expression); |
482 | 482 |
483 Expression operator -(expression) => binary('-', expression); | 483 Expression operator -(expression) => binary('-', expression); |
484 | 484 |
485 Expression operator &(expression) => binary('&', expression); | 485 Expression operator &(expression) => binary('&', expression); |
486 | 486 |
487 Expression operator <(expression) => binary('<', expression); | 487 Expression operator <(expression) => binary('<', expression); |
488 | 488 |
489 Expression operator >(expression) => binary('>', expression); | 489 Expression operator >(expression) => binary('>', expression); |
490 | 490 |
491 Expression operator >=(expression) => binary('>=', expression); | 491 Expression operator >=(expression) => binary('>=', expression); |
492 | 492 |
493 Expression binary(String operator, expression) { | 493 Expression binary(String operator, expression) { |
494 return new Binary(operator, this, js.toExpression(expression)); | 494 return new Binary(operator, this, jsBuilder.toExpression(expression)); |
495 } | 495 } |
496 | 496 |
497 Expression assign(expression) { | 497 Expression assign(expression) { |
498 return new Assignment(this, js.toExpression(expression)); | 498 return new Assignment(this, jsBuilder.toExpression(expression)); |
499 } | 499 } |
500 | 500 |
501 Expression update(String operator, expression) { | 501 Expression update(String operator, expression) { |
502 return new Assignment.compound(this, operator, js.toExpression(expression)); | 502 return new Assignment.compound( |
| 503 this, operator, jsBuilder.toExpression(expression)); |
503 } | 504 } |
504 | 505 |
505 Expression get plusPlus => new Postfix('++', this); | 506 Expression get plusPlus => new Postfix('++', this); |
506 | 507 |
507 Prefix get typeof => new Prefix('typeof', this); | 508 Prefix get typeof => new Prefix('typeof', this); |
508 | 509 |
509 Prefix get not => new Prefix('!', this); | 510 Prefix get not => new Prefix('!', this); |
510 } | 511 } |
511 | 512 |
512 class LiteralExpression extends Expression { | 513 class LiteralExpression extends Expression { |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 */ | 941 */ |
941 class Comment extends Statement { | 942 class Comment extends Statement { |
942 final String comment; | 943 final String comment; |
943 | 944 |
944 Comment(this.comment); | 945 Comment(this.comment); |
945 | 946 |
946 accept(NodeVisitor visitor) => visitor.visitComment(this); | 947 accept(NodeVisitor visitor) => visitor.visitComment(this); |
947 | 948 |
948 void visitChildren(NodeVisitor visitor) {} | 949 void visitChildren(NodeVisitor visitor) {} |
949 } | 950 } |
OLD | NEW |