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

Side by Side Diff: client/dart.js

Issue 10414077: Change the default Dart-to-JavaScript compiler in the editor to be dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/frog/FrogCompiler.java » ('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) 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 // Bootstrap support for Dart scripts on the page as this script. 5 // Bootstrap support for Dart scripts on the page as this script.
6 if (navigator.webkitStartDart) { 6 if (navigator.webkitStartDart) {
7 if (!navigator.webkitStartDart()) { 7 if (!navigator.webkitStartDart()) {
8 document.body.innerHTML = 'This build has expired. Please download a new Da rtium at http://www.dartlang.org/dartium/index.html'; 8 document.body.innerHTML = 'This build has expired. Please download a new Da rtium at http://www.dartlang.org/dartium/index.html';
9 } 9 }
10 } else { 10 } else {
11 // TODO: 11 // TODO:
12 // - Support in-browser compilation. 12 // - Support in-browser compilation.
13 // - Handle inline Dart scripts. 13 // - Handle inline Dart scripts.
14 window.addEventListener("DOMContentLoaded", function (e) { 14 window.addEventListener("DOMContentLoaded", function (e) {
15 // Fall back to compiled JS. Run through all the scripts and 15 // Fall back to compiled JS. Run through all the scripts and
16 // replace them if they have a type that indicate that they source 16 // replace them if they have a type that indicate that they source
17 // in Dart code. 17 // in Dart code.
18 // 18 //
19 // <script type="application/dart" src="<file>.dart"></script> 19 // <script type="application/dart" src="<file>.dart"></script>
20 // 20 //
21 // If the script tag has a 'data-compiler' attribute set to 21 // If the script tag has a 'data-compiler' attribute set to
22 // dart2js then we use the dart2js generated file rather than the 22 // frog then we use the frog generated file rather than the
23 // one produced by frog: 23 // one produced by dart2js:
24 // 24 //
25 // <script ... data-compiler="dart2js"></script> 25 // <script ... data-compiler="frog"></script>
26 // 26 //
27 var scripts = document.getElementsByTagName("script"); 27 var scripts = document.getElementsByTagName("script");
28 var length = scripts.length; 28 var length = scripts.length;
29 for (var i = 0; i < length; ++i) { 29 for (var i = 0; i < length; ++i) {
30 if (scripts[i].type == "application/dart") { 30 if (scripts[i].type == "application/dart") {
31 // Remap foo.dart to foo.js or foo.js_ depending 31 // Remap foo.dart to foo.js or foo.js_ depending
32 // on the chosen compiler (frog or dart2js). 32 // on the chosen compiler (frog or dart2js).
33 if (scripts[i].src && scripts[i].src != '') { 33 if (scripts[i].src && scripts[i].src != '') {
34 var script = document.createElement('script'); 34 var script = document.createElement('script');
35 var compiler = scripts[i].getAttribute('data-compiler'); 35 var compiler = scripts[i].getAttribute('data-compiler');
36 if (compiler == "dart2js") { 36 if (compiler == "frog") {
37 script.src = scripts[i].src + '.js_'; 37 script.src = scripts[i].src + '.js_';
38 } else { 38 } else {
39 script.src = scripts[i].src + '.js'; 39 script.src = scripts[i].src + '.js';
40 } 40 }
41 var parent = scripts[i].parentNode; 41 var parent = scripts[i].parentNode;
42 parent.replaceChild(script, scripts[i]); 42 parent.replaceChild(script, scripts[i]);
43 } 43 }
44 } 44 }
45 } 45 }
46 }, false); 46 }, false);
47 } 47 }
OLDNEW
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/frog/FrogCompiler.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698