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

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

Issue 11415199: Rename regexp to reflect review feedback on semicolon change. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | no next file » | 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; 5 part of js;
6 6
7 class Printer implements NodeVisitor { 7 class Printer implements NodeVisitor {
8 final bool shouldCompressOutput; 8 final bool shouldCompressOutput;
9 leg.Compiler compiler; 9 leg.Compiler compiler;
10 leg.CodeBuffer outBuffer; 10 leg.CodeBuffer outBuffer;
11 int indentLevel = 0; 11 int indentLevel = 0;
12 bool inForInit = false; 12 bool inForInit = false;
13 bool atStatementBegin = false; 13 bool atStatementBegin = false;
14 final DanglingElseVisitor danglingElseVisitor; 14 final DanglingElseVisitor danglingElseVisitor;
15 final Namer namer; 15 final Namer namer;
16 bool pendingSemicolon = false; 16 bool pendingSemicolon = false;
17 bool pendingSpace = false; 17 bool pendingSpace = false;
18 static final identifierRegexp = new RegExp(r'^[a-zA-Z_0-9$]'); 18 static final identifierCharacterRegExp = new RegExp(r'^[a-zA-Z_0-9$]');
19 19
20 Printer(leg.Compiler compiler, { allowVariableMinification: true }) 20 Printer(leg.Compiler compiler, { allowVariableMinification: true })
21 : shouldCompressOutput = compiler.enableMinification, 21 : shouldCompressOutput = compiler.enableMinification,
22 this.compiler = compiler, 22 this.compiler = compiler,
23 outBuffer = new leg.CodeBuffer(), 23 outBuffer = new leg.CodeBuffer(),
24 danglingElseVisitor = new DanglingElseVisitor(compiler), 24 danglingElseVisitor = new DanglingElseVisitor(compiler),
25 namer = determineRenamer(compiler.enableMinification, 25 namer = determineRenamer(compiler.enableMinification,
26 allowVariableMinification); 26 allowVariableMinification);
27 27
28 static Namer determineRenamer(bool shouldCompressOutput, 28 static Namer determineRenamer(bool shouldCompressOutput,
(...skipping 15 matching lines...) Expand all
44 assert(lastAddedString.length != ""); 44 assert(lastAddedString.length != "");
45 return lastAddedString.charCodeAt(lastAddedString.length - 1); 45 return lastAddedString.charCodeAt(lastAddedString.length - 1);
46 } 46 }
47 47
48 void out(String str) { 48 void out(String str) {
49 if (str != "") { 49 if (str != "") {
50 if (pendingSemicolon && (!shouldCompressOutput || str != "}")) { 50 if (pendingSemicolon && (!shouldCompressOutput || str != "}")) {
51 outBuffer.add(";"); 51 outBuffer.add(";");
52 } 52 }
53 if (pendingSpace && 53 if (pendingSpace &&
54 (!shouldCompressOutput || identifierRegexp.hasMatch(str))) { 54 (!shouldCompressOutput || identifierCharacterRegExp.hasMatch(str))) {
55 outBuffer.add(" "); 55 outBuffer.add(" ");
56 } 56 }
57 pendingSpace = false; 57 pendingSpace = false;
58 pendingSemicolon = false; 58 pendingSemicolon = false;
59 outBuffer.add(str); 59 outBuffer.add(str);
60 lastAddedString = str; 60 lastAddedString = str;
61 } 61 }
62 } 62 }
63 63
64 void outLn(String str) { 64 void outLn(String str) {
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 codes.add(nthLetter((n ~/ nameSpaceSize) % LETTERS)); 1065 codes.add(nthLetter((n ~/ nameSpaceSize) % LETTERS));
1066 } 1066 }
1067 codes.add(charCodes.$0 + digit); 1067 codes.add(charCodes.$0 + digit);
1068 newName = new String.fromCharCodes(codes); 1068 newName = new String.fromCharCodes(codes);
1069 } 1069 }
1070 assert(new RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName)); 1070 assert(new RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName));
1071 maps.last[oldName] = newName; 1071 maps.last[oldName] = newName;
1072 return newName; 1072 return newName;
1073 } 1073 }
1074 } 1074 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698