| 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 |
| 11 * runs in the browser. | 11 * runs in the browser. |
| 12 * | 12 * |
| 13 * Because this is running in the browser, we do not access | 13 * Because this is running in the browser, we do not access |
| 14 * the file system. Instead, we assume that all necessary files | 14 * the file system. Instead, we assume that all necessary files |
| 15 * have been placed in inert <script> elements somewhere on the html page. | 15 * have been placed in inert <script> elements somewhere on the html page. |
| 16 * | 16 * |
| 17 * (See legpad.py for more details on how the html page is constructed.) | 17 * (See legpad.py for more details on how the html page is constructed.) |
| 18 */ | 18 */ |
| 19 void main() { | 19 void main() { |
| 20 new Legpad().run(); | 20 new Legpad().run(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 class Legpad { | 23 class Legpad { |
| 24 // id of script element containing name of the main dart file | 24 // id of script element containing name of the main dart file |
| 25 // to compile | 25 // to compile |
| 26 static final String MAIN_ID = "main_id"; | 26 static const String MAIN_ID = "main_id"; |
| 27 | 27 |
| 28 Legpad() : warnings = new StringBuffer(); | 28 Legpad() : warnings = new StringBuffer(); |
| 29 | 29 |
| 30 // accumulates diagnostic messages emitted by the leg compiler | 30 // accumulates diagnostic messages emitted by the leg compiler |
| 31 StringBuffer warnings; | 31 StringBuffer warnings; |
| 32 | 32 |
| 33 // the generated javascript | 33 // the generated javascript |
| 34 String output; | 34 String output; |
| 35 | 35 |
| 36 String readAll(String filename) { | 36 String readAll(String filename) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 127 } |
| 128 return element.text.trim(); | 128 return element.text.trim(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 // TODO(mattsh): should exist in standard lib somewhere | 131 // TODO(mattsh): should exist in standard lib somewhere |
| 132 static String htmlEscape(String text) { | 132 static String htmlEscape(String text) { |
| 133 return text.replaceAll('&', '&').replaceAll( | 133 return text.replaceAll('&', '&').replaceAll( |
| 134 '>', '>').replaceAll('<', '<'); | 134 '>', '>').replaceAll('<', '<'); |
| 135 } | 135 } |
| 136 } | 136 } |
| OLD | NEW |