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

Side by Side Diff: utils/template/codegen.dart

Issue 10919024: - Change "static final" to "static const" in the (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | « utils/pub/yaml/parser.dart ('k') | utils/template/tokenkind.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) 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 class CGBlock { 5 class CGBlock {
6 int _blockType; // Code type of this block 6 int _blockType; // Code type of this block
7 int _indent; // Number of spaces to prefix for each statement 7 int _indent; // Number of spaces to prefix for each statement
8 bool _inEach; // This block or any currently active blocks is a 8 bool _inEach; // This block or any currently active blocks is a
9 // #each. If so then any element marked with a 9 // #each. If so then any element marked with a
10 // var attribute is repeated therefore the var 10 // var attribute is repeated therefore the var
11 // is a List type instead of an Element type. 11 // is a List type instead of an Element type.
12 String _localName; // optional local name for #each or #with 12 String _localName; // optional local name for #each or #with
13 List<CGStatement> _stmts; 13 List<CGStatement> _stmts;
14 int localIndex; // Local variable index (e.g., e0, e1, etc.) 14 int localIndex; // Local variable index (e.g., e0, e1, etc.)
15 15
16 // Block Types: 16 // Block Types:
17 static final int CONSTRUCTOR = 0; 17 static const int CONSTRUCTOR = 0;
18 static final int EACH = 1; 18 static const int EACH = 1;
19 static final int WITH = 2; 19 static const int WITH = 2;
20 20
21 CGBlock([this._indent = 4, 21 CGBlock([this._indent = 4,
22 this._blockType = CGBlock.CONSTRUCTOR, 22 this._blockType = CGBlock.CONSTRUCTOR,
23 this._inEach = false, 23 this._inEach = false,
24 this._localName = null]) : 24 this._localName = null]) :
25 _stmts = new List<CGStatement>(), localIndex = 0 { 25 _stmts = new List<CGStatement>(), localIndex = 0 {
26 assert(_blockType >= CGBlock.CONSTRUCTOR && _blockType <= CGBlock.WITH); 26 assert(_blockType >= CGBlock.CONSTRUCTOR && _blockType <= CGBlock.WITH);
27 } 27 }
28 28
29 bool get anyStatements() => !_stmts.isEmpty(); 29 bool get anyStatements() => !_stmts.isEmpty();
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 statement.add("${spaces}${varName}.add(${tmpRepeat});\n"); 240 statement.add("${spaces}${varName}.add(${tmpRepeat});\n");
241 } 241 }
242 } 242 }
243 } 243 }
244 244
245 return statement.toString(); 245 return statement.toString();
246 } 246 }
247 } 247 }
248 248
249 class Codegen { 249 class Codegen {
250 static final String SPACES = " "; 250 static const String SPACES = " ";
251 static String spaces(int numSpaces) { 251 static String spaces(int numSpaces) {
252 return SPACES.substring(0, numSpaces); 252 return SPACES.substring(0, numSpaces);
253 } 253 }
254 254
255 // TODO(terry): Before generating Dart class need a validate phase that 255 // TODO(terry): Before generating Dart class need a validate phase that
256 // checks mangles all class names to be prefix with the 256 // checks mangles all class names to be prefix with the
257 // template name to avoid any class name collisions. Also, 257 // template name to avoid any class name collisions. Also,
258 // investigate possible runtime check mode to insure that only 258 // investigate possible runtime check mode to insure that only
259 // valid CSS class names are used (in case someone uses strings 259 // valid CSS class names are used (in case someone uses strings
260 // and not the generated getters to the CSS class selector. This 260 // and not the generated getters to the CSS class selector. This
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 for (var eachFunc in ecg.eachs) { 451 for (var eachFunc in ecg.eachs) {
452 buff.add("${eachFunc}\n"); 452 buff.add("${eachFunc}\n");
453 } 453 }
454 454
455 buff.add("\n // With functions:\n"); 455 buff.add("\n // With functions:\n");
456 for (var withFunc in ecg.withs) { 456 for (var withFunc in ecg.withs) {
457 buff.add("${withFunc}\n"); 457 buff.add("${withFunc}\n");
458 } 458 }
459 459
460 buff.add("\n // CSS for this template.\n"); 460 buff.add("\n // CSS for this template.\n");
461 buff.add(" static final String stylesheet = "); 461 buff.add(" static const String stylesheet = ");
462 462
463 if (content.css != null) { 463 if (content.css != null) {
464 buff.add("\'\'\'\n ${content.css.toString()}\n"); 464 buff.add("\'\'\'\n ${content.css.toString()}\n");
465 buff.add(" \'\'\';\n\n"); 465 buff.add(" \'\'\';\n\n");
466 466
467 // TODO(terry): Emit all known selectors for this template. 467 // TODO(terry): Emit all known selectors for this template.
468 buff.add(" // Stylesheet class selectors:\n"); 468 buff.add(" // Stylesheet class selectors:\n");
469 } else { 469 } else {
470 buff.add("\"\";\n"); 470 buff.add("\"\";\n");
471 } 471 }
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 for (String name in names) { 1004 for (String name in names) {
1005 buff.add(" var ${name} = _scopes[\"${name}\"];\n"); 1005 buff.add(" var ${name} = _scopes[\"${name}\"];\n");
1006 } 1006 }
1007 buff.add("\n"); 1007 buff.add("\n");
1008 } 1008 }
1009 1009
1010 return buff.toString(); 1010 return buff.toString();
1011 } 1011 }
1012 1012
1013 } 1013 }
OLDNEW
« no previous file with comments | « utils/pub/yaml/parser.dart ('k') | utils/template/tokenkind.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698