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

Side by Side Diff: frog/code_writer.dart

Issue 10060002: Repo for extremely slow 'const'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 5 /**
6 * Support for generating code to be extended with source location mapping. 6 * Support for generating code to be extended with source location mapping.
7 */ 7 */
8 class CodeWriter { 8 class CodeWriter {
9 static final INDENTATION = ' '; 9 static final INDENTATION = ' ';
10 10
11 static final int INC_INDENT = +1; 11 static final int INC_INDENT = +1;
12 static final int DEC_INDENT = -1; 12 static final int DEC_INDENT = -1;
13 static final NEWLINE = null; // Anything but an int, String or List. 13 static final NEWLINE = const Newline();
14 14
15 List _buf; 15 List _buf;
16 bool writeComments = true; 16 bool writeComments = true;
17 17
18 CodeWriter(): _buf = []; 18 CodeWriter(): _buf = [];
19 19
20 bool get isEmpty() => _buf.length == 0; 20 bool get isEmpty() => _buf.length == 0;
21 21
22 String get text() { 22 String get text() {
23 StringBuffer sb = new StringBuffer(); 23 StringBuffer sb = new StringBuffer();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 writeln(text); 101 writeln(text);
102 } 102 }
103 103
104 /** Switch to an adjacent block in one line, e.g. "} else if (...) {" */ 104 /** Switch to an adjacent block in one line, e.g. "} else if (...) {" */
105 nextBlock(String text) { 105 nextBlock(String text) {
106 _buf.add(DEC_INDENT); 106 _buf.add(DEC_INDENT);
107 writeln(text); 107 writeln(text);
108 _buf.add(INC_INDENT); 108 _buf.add(INC_INDENT);
109 } 109 }
110 } 110 }
111
112 class Newline {
113 const Newline();
114 }
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