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

Side by Side Diff: tools/testing/frogpad/frogpad.dart

Issue 9610002: remove node.js dependency by running the frog compiler in (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: language status Created 8 years, 9 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
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 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 /** 6 /**
7 * This is the entrypoint for a version of the frog compiler that 7 * This is the entrypoint for a version of the frog compiler that
8 * can run in the browser. 8 * can run in the browser.
9 * Because this is running in the browser, frog cannot access 9 * Because this is running in the browser, frog cannot access
10 * the file system. Instead, we assume the all necessary files 10 * the file system. Instead, we assume the all necessary files
11 * have been placed in inert <script> elements somewhere on the page. 11 * have been placed in inert <script> elements somewhere on the page.
12 * (See frogpad.py for more details on how the html page is constructed.) 12 * (See frogpad.py for more details on how the html page is constructed.)
13 */ 13 */
14 14
15 #import("dart:html", prefix:"html"); 15 #import("dart:html", prefix:"html");
16 #import("../../../frog/lang.dart"); 16 #import("../../../frog/lang.dart");
17 #import("../../../frog/file_system.dart"); 17 #import("../../../frog/file_system.dart");
18 18
19 // id of script element containing name of the main dart file 19 // id of script element containing name of the main dart file
20 // to compile. 20 // to compile.
21 final String MAIN_ID = "main_id"; 21 final String MAIN_ID = "main_id";
22 22
23 void main() { 23 void main() {
24 String warnings = ""; 24 String warnings = "";
25 HtmlFileSystem fs = new HtmlFileSystem(); 25 HtmlFileSystem fs = new HtmlFileSystem();
26 String mainFile = getText(MAIN_ID); 26 String mainFile = getText(MAIN_ID);
27 setText("input", fs.readAll(mainFile)); 27 setText("input", fs.readAll(mainFile));
28 28
29 int time1 = new Date.now().value; 29 int time1 = new Date.now().value;
30 List<String> args = ["dummy_arg1", "dummy_arg2", mainFile]; 30 List<String> args = [
31 "dummy_arg1",
32 "dummy_arg2",
33 "--enable_type_checks",
34 "--enable_asserts",
35 mainFile];
31 parseOptions("dummy_home_dir", args, fs); 36 parseOptions("dummy_home_dir", args, fs);
32 37
33 options.useColors = false; 38 options.useColors = false;
34 39
35 initializeWorld(fs); 40 initializeWorld(fs);
36 world.messageHandler = void _( 41 world.messageHandler = void _(
37 String prefix, String message, SourceSpan span) { 42 String prefix, String message, SourceSpan span) {
38 String location = ""; 43 String location = "";
39 if (span !== null) { 44 if (span !== null) {
40 location = span.locationText; 45 location = span.locationText;
41 } 46 }
42 warnings += prefix + message + location + "\n"; 47 warnings += prefix + message + location + "\n";
43 }; 48 };
44 bool success = world.compile(); 49 bool success = world.compile();
45 int time2 = new Date.now().value; 50 int time2 = new Date.now().value;
46 String output = world.getGeneratedCode(); 51 String output = "throw 'frogpad compilation error';\n";
47 if (success) { 52 if (success) {
48 setText("output", output); 53 output = world.getGeneratedCode();
49 } 54 }
55 setText("output", output);
50 setText("warnings", warnings); 56 setText("warnings", warnings);
51 57
52 ((time2 - time1) / 1000).toStringAsPrecision(3); 58 ((time2 - time1) / 1000).toStringAsPrecision(3);
53 String timing = "generated ${output.length} characters in " + 59 String timing = "generated ${output.length} characters in " +
54 "${((time2 - time1) / 1000).toStringAsPrecision(3)} seconds"; 60 "${((time2 - time1) / 1000).toStringAsPrecision(3)} seconds";
55 setText("timing", timing); 61 setText("timing", timing);
56 } 62 }
57 63
58 void setText(String id, String text) { 64 void setText(String id, String text) {
59 html.Element element = html.document.query("#$id"); 65 html.Element element = html.document.query("#$id");
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 139 }
134 140
135 void createDirectory(String path, [bool recursive]) { 141 void createDirectory(String path, [bool recursive]) {
136 throw new UnsupportedOperationException(""); 142 throw new UnsupportedOperationException("");
137 } 143 }
138 144
139 void removeDirectory(String path, [bool recursive]) { 145 void removeDirectory(String path, [bool recursive]) {
140 throw new UnsupportedOperationException(""); 146 throw new UnsupportedOperationException("");
141 } 147 }
142 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698