| 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:io'; | 8 import 'dart:io'; |
| 8 import 'dart:uri'; | 9 import 'dart:uri'; |
| 9 import 'dart:utf'; | 10 import 'dart:utf'; |
| 10 | 11 |
| 11 import '../compiler.dart' as api; | 12 import '../compiler.dart' as api; |
| 12 import 'colors.dart' as colors; | 13 import 'colors.dart' as colors; |
| 13 import 'source_file.dart'; | 14 import 'source_file.dart'; |
| 14 import 'filenames.dart'; | 15 import 'filenames.dart'; |
| 15 import 'util/uri_extras.dart'; | 16 import 'util/uri_extras.dart'; |
| 16 | 17 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 281 |
| 281 Uri uri = cwd.resolve(arguments[0]); | 282 Uri uri = cwd.resolve(arguments[0]); |
| 282 if (packageRoot == null) { | 283 if (packageRoot == null) { |
| 283 packageRoot = uri.resolve('./packages/'); | 284 packageRoot = uri.resolve('./packages/'); |
| 284 } | 285 } |
| 285 | 286 |
| 286 info('package root is $packageRoot'); | 287 info('package root is $packageRoot'); |
| 287 | 288 |
| 288 // TODO(ahe): We expect the future to be complete and call value | 289 // TODO(ahe): We expect the future to be complete and call value |
| 289 // directly. In effect, we don't support truly asynchronous API. | 290 // directly. In effect, we don't support truly asynchronous API. |
| 290 String code = api.compile(uri, libraryRoot, packageRoot, provider, handler, | 291 String code = deprecatedFutureValue( |
| 291 options).value; | 292 api.compile(uri, libraryRoot, packageRoot, provider, handler, options)); |
| 292 if (code == null) { | 293 if (code == null) { |
| 293 fail('Error: Compilation failed.'); | 294 fail('Error: Compilation failed.'); |
| 294 } | 295 } |
| 295 String sourceMapFileName = | 296 String sourceMapFileName = |
| 296 sourceMapOut.path.substring(sourceMapOut.path.lastIndexOf('/') + 1); | 297 sourceMapOut.path.substring(sourceMapOut.path.lastIndexOf('/') + 1); |
| 297 code = '$code\n//@ sourceMappingURL=${sourceMapFileName}'; | 298 code = '$code\n//@ sourceMappingURL=${sourceMapFileName}'; |
| 298 writeString(out, code); | 299 writeString(out, code); |
| 299 writeString(new Uri.fromString('$out.deps'), getDepsOutput(sourceFiles)); | 300 writeString(new Uri.fromString('$out.deps'), getDepsOutput(sourceFiles)); |
| 300 int bytesWritten = code.length; | 301 int bytesWritten = code.length; |
| 301 info('compiled $dartBytesRead bytes Dart -> $bytesWritten bytes ' | 302 info('compiled $dartBytesRead bytes Dart -> $bytesWritten bytes ' |
| (...skipping 16 matching lines...) Expand all Loading... |
| 318 fail('Error: Unhandled scheme ${uri.scheme}.'); | 319 fail('Error: Unhandled scheme ${uri.scheme}.'); |
| 319 } | 320 } |
| 320 var file = new File(uriPathToNative(uri.path)).openSync(FileMode.WRITE); | 321 var file = new File(uriPathToNative(uri.path)).openSync(FileMode.WRITE); |
| 321 file.writeStringSync(text); | 322 file.writeStringSync(text); |
| 322 file.closeSync(); | 323 file.closeSync(); |
| 323 } | 324 } |
| 324 | 325 |
| 325 String readAll(String filename) { | 326 String readAll(String filename) { |
| 326 var file = (new File(filename)).openSync(FileMode.READ); | 327 var file = (new File(filename)).openSync(FileMode.READ); |
| 327 var length = file.lengthSync(); | 328 var length = file.lengthSync(); |
| 328 var buffer = new List<int>(length); | 329 var buffer = new List<int>.fixedLength(length); |
| 329 var bytes = file.readListSync(buffer, 0, length); | 330 var bytes = file.readListSync(buffer, 0, length); |
| 330 file.closeSync(); | 331 file.closeSync(); |
| 331 return new String.fromCharCodes(new Utf8Decoder(buffer).decodeRest()); | 332 return new String.fromCharCodes(new Utf8Decoder(buffer).decodeRest()); |
| 332 } | 333 } |
| 333 | 334 |
| 334 void fail(String message) { | 335 void fail(String message) { |
| 335 print(message); | 336 print(message); |
| 336 exit(1); | 337 exit(1); |
| 337 } | 338 } |
| 338 | 339 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 } catch (ignored) { | 466 } catch (ignored) { |
| 466 print('Internal error: error while printing exception'); | 467 print('Internal error: error while printing exception'); |
| 467 } | 468 } |
| 468 try { | 469 try { |
| 469 print(trace); | 470 print(trace); |
| 470 } finally { | 471 } finally { |
| 471 exit(253); // 253 is recognized as a crash by our test scripts. | 472 exit(253); // 253 is recognized as a crash by our test scripts. |
| 472 } | 473 } |
| 473 } | 474 } |
| 474 } | 475 } |
| OLD | NEW |