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

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

Issue 255843005: Avoid generating VariableUse nodes with non-identifier names (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
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 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 accept(NodeVisitor visitor) => visitor.visitPostfix(this); 693 accept(NodeVisitor visitor) => visitor.visitPostfix(this);
694 694
695 int get precedenceLevel => UNARY; 695 int get precedenceLevel => UNARY;
696 } 696 }
697 697
698 abstract class VariableReference extends Expression { 698 abstract class VariableReference extends Expression {
699 final String name; 699 final String name;
700 700
701 // We treat operators as if they were special functions. They can thus be 701 // We treat operators as if they were special functions. They can thus be
702 // referenced like other variables. 702 // referenced like other variables.
703 VariableReference(this.name); 703 VariableReference(this.name) {
704 assert(_identiferOrOperatorRE.hasMatch(name));
705 }
706 static RegExp _identiferOrOperatorRE =
floitsch 2014/04/28 14:17:51 identifierOrOperatorRE (missing "i")
sra1 2014/04/28 23:00:41 Done.
707 new RegExp(r'^([A-Za-z_$][A-Za-z_$0-9]*|[-<=>+\*\/%^!|&~,]*)$');
floitsch 2014/04/28 14:17:51 you don't need to escape '*' inside a character gr
sra1 2014/04/28 23:00:41 'Done'. After the operators cl, the test is just
704 708
705 accept(NodeVisitor visitor); 709 accept(NodeVisitor visitor);
706 int get precedenceLevel => PRIMARY; 710 int get precedenceLevel => PRIMARY;
707 void visitChildren(NodeVisitor visitor) {} 711 void visitChildren(NodeVisitor visitor) {}
708 } 712 }
709 713
710 class VariableUse extends VariableReference { 714 class VariableUse extends VariableReference {
711 VariableUse(String name) : super(name); 715 VariableUse(String name) : super(name);
712 716
713 accept(NodeVisitor visitor) => visitor.visitVariableUse(this); 717 accept(NodeVisitor visitor) => visitor.visitVariableUse(this);
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 */ 995 */
992 class Comment extends Statement { 996 class Comment extends Statement {
993 final String comment; 997 final String comment;
994 998
995 Comment(this.comment); 999 Comment(this.comment);
996 1000
997 accept(NodeVisitor visitor) => visitor.visitComment(this); 1001 accept(NodeVisitor visitor) => visitor.visitComment(this);
998 1002
999 void visitChildren(NodeVisitor visitor) {} 1003 void visitChildren(NodeVisitor visitor) {}
1000 } 1004 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698