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

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

Issue 10860036: Few tweaks to the generated code to avoid eg parenthesis. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 | lib/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 interface NodeVisitor<T> { 5 interface NodeVisitor<T> {
6 T visitProgram(Program node); 6 T visitProgram(Program node);
7 7
8 T visitBlock(Block node); 8 T visitBlock(Block node);
9 T visitExpressionStatement(ExpressionStatement node); 9 T visitExpressionStatement(ExpressionStatement node);
10 T visitEmptyStatement(EmptyStatement node); 10 T visitEmptyStatement(EmptyStatement node);
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 435
436 LiteralExpression(this.template) : inputs = const []; 436 LiteralExpression(this.template) : inputs = const [];
437 LiteralExpression.withData(this.template, this.inputs); 437 LiteralExpression.withData(this.template, this.inputs);
438 438
439 accept(NodeVisitor visitor) => visitor.visitLiteralExpression(this); 439 accept(NodeVisitor visitor) => visitor.visitLiteralExpression(this);
440 440
441 void visitChildren(NodeVisitor visitor) { 441 void visitChildren(NodeVisitor visitor) {
442 for (Expression expr in inputs) expr.accept(visitor); 442 for (Expression expr in inputs) expr.accept(visitor);
443 } 443 }
444 444
445 int get precedenceLevel() => EXPRESSION; 445 // Code that uses JS must take care of operator precedences, and
446 // put parenthesis if needed.
447 int get precedenceLevel() => PRIMARY;
446 } 448 }
447 449
448 /** 450 /**
449 * [VariableDeclarationList] is a subclass of [Expression] to simplify the 451 * [VariableDeclarationList] is a subclass of [Expression] to simplify the
450 * AST. 452 * AST.
451 */ 453 */
452 class VariableDeclarationList extends Expression { 454 class VariableDeclarationList extends Expression {
453 final List<VariableInitialization> declarations; 455 final List<VariableInitialization> declarations;
454 456
455 VariableDeclarationList(this.declarations); 457 VariableDeclarationList(this.declarations);
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 /** Contains the pattern and the flags.*/ 830 /** Contains the pattern and the flags.*/
829 String pattern; 831 String pattern;
830 832
831 RegExpLiteral(this.pattern); 833 RegExpLiteral(this.pattern);
832 834
833 accept(NodeVisitor visitor) => visitor.visitRegExpLiteral(this); 835 accept(NodeVisitor visitor) => visitor.visitRegExpLiteral(this);
834 void visitChildren(NodeVisitor visitor) {} 836 void visitChildren(NodeVisitor visitor) {}
835 837
836 int get precedenceLevel() => PRIMARY; 838 int get precedenceLevel() => PRIMARY;
837 } 839 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/js/printer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698