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 library dart2js; | 5 library dart2js; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection' show Queue, LinkedHashMap; | 8 import 'dart:collection' show Queue, LinkedHashMap; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'dart:uri'; | 10 import 'dart:uri'; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 libraryRoot = cwd.resolve(extractPath(argument)); | 89 libraryRoot = cwd.resolve(extractPath(argument)); |
90 } | 90 } |
91 | 91 |
92 setPackageRoot(String argument) { | 92 setPackageRoot(String argument) { |
93 packageRoot = cwd.resolve(extractPath(argument)); | 93 packageRoot = cwd.resolve(extractPath(argument)); |
94 } | 94 } |
95 | 95 |
96 setOutput(String argument) { | 96 setOutput(String argument) { |
97 explicitOut = true; | 97 explicitOut = true; |
98 out = cwd.resolve(nativeToUriPath(extractParameter(argument))); | 98 out = cwd.resolve(nativeToUriPath(extractParameter(argument))); |
99 sourceMapOut = new Uri.fromString('$out.map'); | 99 sourceMapOut = Uri.parse('$out.map'); |
100 } | 100 } |
101 | 101 |
102 setOutputType(String argument) { | 102 setOutputType(String argument) { |
103 if (argument == '--output-type=dart') { | 103 if (argument == '--output-type=dart') { |
104 outputLanguage = OUTPUT_LANGUAGE_DART; | 104 outputLanguage = OUTPUT_LANGUAGE_DART; |
105 if (!explicitOut) { | 105 if (!explicitOut) { |
106 out = cwd.resolve('out.dart'); | 106 out = cwd.resolve('out.dart'); |
107 sourceMapOut = cwd.resolve('out.dart.map'); | 107 sourceMapOut = cwd.resolve('out.dart.map'); |
108 } | 108 } |
109 } | 109 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 inputProvider.readStringFromUri, | 223 inputProvider.readStringFromUri, |
224 handler, | 224 handler, |
225 options)); | 225 options)); |
226 if (code == null) { | 226 if (code == null) { |
227 fail('Error: Compilation failed.'); | 227 fail('Error: Compilation failed.'); |
228 } | 228 } |
229 String sourceMapFileName = | 229 String sourceMapFileName = |
230 sourceMapOut.path.substring(sourceMapOut.path.lastIndexOf('/') + 1); | 230 sourceMapOut.path.substring(sourceMapOut.path.lastIndexOf('/') + 1); |
231 code = '$code\n//@ sourceMappingURL=${sourceMapFileName}'; | 231 code = '$code\n//@ sourceMappingURL=${sourceMapFileName}'; |
232 writeString(out, code); | 232 writeString(out, code); |
233 writeString(new Uri.fromString('$out.deps'), | 233 writeString(Uri.parse('$out.deps'), |
234 getDepsOutput(inputProvider.sourceFiles)); | 234 getDepsOutput(inputProvider.sourceFiles)); |
235 int dartBytesRead = inputProvider.dartBytesRead; | 235 int dartBytesRead = inputProvider.dartBytesRead; |
236 int bytesWritten = code.length; | 236 int bytesWritten = code.length; |
237 diagnosticHandler.info( | 237 diagnosticHandler.info( |
238 'compiled $dartBytesRead bytes Dart -> $bytesWritten bytes ' | 238 'compiled $dartBytesRead bytes Dart -> $bytesWritten bytes ' |
239 '$outputLanguage in ${relativize(cwd, out, isWindows)}'); | 239 '$outputLanguage in ${relativize(cwd, out, isWindows)}'); |
240 if (!explicitOut) { | 240 if (!explicitOut) { |
241 String input = uriPathToNative(arguments[0]); | 241 String input = uriPathToNative(arguments[0]); |
242 String output = relativize(cwd, out, isWindows); | 242 String output = relativize(cwd, out, isWindows); |
243 print('Dart file $input compiled to $outputLanguage: $output'); | 243 print('Dart file $input compiled to $outputLanguage: $output'); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 } catch (ignored) { | 393 } catch (ignored) { |
394 print('Internal error: error while printing exception'); | 394 print('Internal error: error while printing exception'); |
395 } | 395 } |
396 try { | 396 try { |
397 print(trace); | 397 print(trace); |
398 } finally { | 398 } finally { |
399 exit(253); // 253 is recognized as a crash by our test scripts. | 399 exit(253); // 253 is recognized as a crash by our test scripts. |
400 } | 400 } |
401 } | 401 } |
402 } | 402 } |
OLD | NEW |