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

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 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 argument.accept(visitor); 792 argument.accept(visitor);
793 } 793 }
794 794
795 795
796 int get precedenceLevel => UNARY; 796 int get precedenceLevel => UNARY;
797 } 797 }
798 798
799 abstract class VariableReference extends Expression { 799 abstract class VariableReference extends Expression {
800 final String name; 800 final String name;
801 801
802 // We treat operators as if they were special functions. They can thus be 802 VariableReference(this.name) {
803 // referenced like other variables. 803 assert(_identifierRE.hasMatch(name));
804 VariableReference(this.name); 804 }
805 static RegExp _identifierRE = new RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$');
805 806
806 accept(NodeVisitor visitor); 807 accept(NodeVisitor visitor);
807 int get precedenceLevel => PRIMARY; 808 int get precedenceLevel => PRIMARY;
808 void visitChildren(NodeVisitor visitor) {} 809 void visitChildren(NodeVisitor visitor) {}
809 } 810 }
810 811
811 class VariableUse extends VariableReference { 812 class VariableUse extends VariableReference {
812 VariableUse(String name) : super(name); 813 VariableUse(String name) : super(name);
813 814
814 accept(NodeVisitor visitor) => visitor.visitVariableUse(this); 815 accept(NodeVisitor visitor) => visitor.visitVariableUse(this);
815 VariableUse _clone() => new VariableUse(name); 816 VariableUse _clone() => new VariableUse(name);
816 817
817 VariableUse asVariableUse() => this; 818 VariableUse asVariableUse() => this;
818 819
819 toString() => 'VariableUse($name)'; 820 toString() => 'VariableUse($name)';
820 } 821 }
821 822
822 class VariableDeclaration extends VariableReference { 823 class VariableDeclaration extends VariableReference {
823 VariableDeclaration(String name) : super(name); 824 VariableDeclaration(String name) : super(name);
824 825
825 accept(NodeVisitor visitor) => visitor.visitVariableDeclaration(this); 826 accept(NodeVisitor visitor) => visitor.visitVariableDeclaration(this);
826 VariableDeclaration _clone() => new VariableDeclaration(name); 827 VariableDeclaration _clone() => new VariableDeclaration(name);
827 } 828 }
828 829
829 class Parameter extends VariableDeclaration { 830 class Parameter extends VariableDeclaration {
830 Parameter(String id) : super(id); 831 Parameter(String name) : super(name);
831 832
832 accept(NodeVisitor visitor) => visitor.visitParameter(this); 833 accept(NodeVisitor visitor) => visitor.visitParameter(this);
833 Parameter _clone() => new Parameter(name); 834 Parameter _clone() => new Parameter(name);
834 } 835 }
835 836
836 class This extends Parameter { 837 class This extends Parameter {
837 This() : super("this"); 838 This() : super("this");
838 839
839 accept(NodeVisitor visitor) => visitor.visitThis(this); 840 accept(NodeVisitor visitor) => visitor.visitThis(this);
840 This _clone() => new This(); 841 This _clone() => new This();
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 class Comment extends Statement { 1124 class Comment extends Statement {
1124 final String comment; 1125 final String comment;
1125 1126
1126 Comment(this.comment); 1127 Comment(this.comment);
1127 1128
1128 accept(NodeVisitor visitor) => visitor.visitComment(this); 1129 accept(NodeVisitor visitor) => visitor.visitComment(this);
1129 Comment _clone() => new Comment(comment); 1130 Comment _clone() => new Comment(comment);
1130 1131
1131 void visitChildren(NodeVisitor visitor) {} 1132 void visitChildren(NodeVisitor visitor) {}
1132 } 1133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698