Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #import("dart:html", prefix:"html"); | 5 #import("dart:html", prefix:"html"); |
| 6 #import('../../../lib/compiler/compiler.dart', prefix: "compiler_lib"); | 6 #import('../../../lib/compiler/compiler.dart', prefix: "compiler_lib"); |
| 7 #import('../../../lib/uri/uri.dart', prefix:"uri_lib"); | 7 #import('../../../lib/uri/uri.dart', prefix:"uri_lib"); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * This is the entrypoint for a version of the leg compiler that | 10 * This is the entrypoint for a version of the leg compiler that |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 setText("input", readAll(mainFile)); | 73 setText("input", readAll(mainFile)); |
| 74 Stopwatch stopwatch = new Stopwatch.start(); | 74 Stopwatch stopwatch = new Stopwatch.start(); |
| 75 runLeg(); | 75 runLeg(); |
| 76 int elapsedMillis = stopwatch.elapsedInMs(); | 76 int elapsedMillis = stopwatch.elapsedInMs(); |
| 77 if (output === null) { | 77 if (output === null) { |
| 78 output = "throw 'dart2js compilation error';\n"; | 78 output = "throw 'dart2js compilation error';\n"; |
| 79 } | 79 } |
| 80 | 80 |
| 81 setText("output", output); | 81 setText("output", output); |
| 82 setText("warnings", warnings); | 82 setText("warnings", warnings); |
| 83 String timing = "generated ${output.length} characters in " + | 83 int lineCount = lineCount(output); |
| 84 String timing = "generated $lineCount lines " + | |
| 85 "(${output.length} characters) in " + | |
| 84 "${((elapsedMillis) / 1000).toStringAsPrecision(3)} seconds"; | 86 "${((elapsedMillis) / 1000).toStringAsPrecision(3)} seconds"; |
| 85 setText("timing", timing); | 87 setText("timing", timing); |
| 86 } | 88 } |
| 89 | |
| 90 static int lineCount(String s) { | |
|
ahe
2012/04/10 21:36:54
I feel this should be easier, but I don't know how
| |
| 91 Iterable<Match> matches = "\n".allMatches(s); | |
| 92 int n = 0; | |
| 93 for (Match m in matches) { | |
| 94 n++; | |
| 95 } | |
| 96 return n; | |
| 97 } | |
| 87 | 98 |
| 88 void runLeg() { | 99 void runLeg() { |
| 89 uri_lib.Uri mainUri = new uri_lib.Uri.fromString(getText(MAIN_ID)); | 100 uri_lib.Uri mainUri = new uri_lib.Uri.fromString(getText(MAIN_ID)); |
| 90 uri_lib.Uri libraryRoot = new uri_lib.Uri.fromString("dartdir/"); | 101 uri_lib.Uri libraryRoot = new uri_lib.Uri.fromString("dartdir/"); |
| 91 List<String> compilerArgs = [ | 102 List<String> compilerArgs = [ |
| 92 "--enable_type_checks", | 103 "--enable_type_checks", |
| 93 "--enable_asserts" | 104 "--enable_asserts" |
| 94 ]; | 105 ]; |
| 95 | 106 |
| 96 // TODO(mattsh): dart2js api should be synchronous | 107 // TODO(mattsh): dart2js api should be synchronous |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 118 } | 129 } |
| 119 return element.text.trim(); | 130 return element.text.trim(); |
| 120 } | 131 } |
| 121 | 132 |
| 122 // TODO(mattsh): should exist in standard lib somewhere | 133 // TODO(mattsh): should exist in standard lib somewhere |
| 123 static String htmlEscape(String text) { | 134 static String htmlEscape(String text) { |
| 124 return text.replaceAll('&', '&').replaceAll( | 135 return text.replaceAll('&', '&').replaceAll( |
| 125 '>', '>').replaceAll('<', '<'); | 136 '>', '>').replaceAll('<', '<'); |
| 126 } | 137 } |
| 127 } | 138 } |
| OLD | NEW |