| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 source_file_provider; | 5 library source_file_provider; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'dart:math' as math; | 10 import 'dart:math' as math; |
| 11 | 11 |
| 12 import '../compiler.dart' as api show Diagnostic, DiagnosticHandler; | 12 import '../compiler.dart' as api show Diagnostic, DiagnosticHandler; |
| 13 import 'dart2js.dart' show AbortLeg; | 13 import 'dart2js.dart' show AbortLeg; |
| 14 import 'colors.dart' as colors; | 14 import 'colors.dart' as colors; |
| 15 import 'io/source_file.dart'; | 15 import 'io/source_file.dart'; |
| 16 import 'filenames.dart'; | 16 import 'filenames.dart'; |
| 17 import 'util/uri_extras.dart'; | 17 import 'util/uri_extras.dart'; |
| 18 import 'dart:typed_data'; | 18 import 'dart:typed_data'; |
| 19 | 19 |
| 20 List<int> readAll(String filename) { | 20 List<int> readAll(String filename) { |
| 21 var file = (new File(filename)).openSync(); | 21 var file = (new File(filename)).openSync(); |
| 22 var length = file.lengthSync(); | 22 var length = file.lengthSync(); |
| 23 // +1 to have a 0 terminated list, see [Scanner]. | 23 // +1 to have a 0 terminated list, see [Scanner]. |
| 24 var buffer = new Uint8List(length + 1); | 24 var buffer = new Uint8List(length + 1); |
| 25 var bytes = file.readIntoSync(buffer, 0, length); | 25 file.readIntoSync(buffer, 0, length); |
| 26 file.closeSync(); | 26 file.closeSync(); |
| 27 return buffer; | 27 return buffer; |
| 28 } | 28 } |
| 29 | 29 |
| 30 abstract class SourceFileProvider { | 30 abstract class SourceFileProvider { |
| 31 bool isWindows = (Platform.operatingSystem == 'windows'); | 31 bool isWindows = (Platform.operatingSystem == 'windows'); |
| 32 Uri cwd = currentDirectory; | 32 Uri cwd = currentDirectory; |
| 33 Map<Uri, SourceFile> sourceFiles = <Uri, SourceFile>{}; | 33 Map<Uri, SourceFile> sourceFiles = <Uri, SourceFile>{}; |
| 34 int dartCharactersRead = 0; | 34 int dartCharactersRead = 0; |
| 35 | 35 |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 var onAdd, onClose; | 325 var onAdd, onClose; |
| 326 | 326 |
| 327 EventSinkWrapper(this.onAdd, this.onClose); | 327 EventSinkWrapper(this.onAdd, this.onClose); |
| 328 | 328 |
| 329 void add(String data) => onAdd(data); | 329 void add(String data) => onAdd(data); |
| 330 | 330 |
| 331 void addError(error, [StackTrace stackTrace]) => throw error; | 331 void addError(error, [StackTrace stackTrace]) => throw error; |
| 332 | 332 |
| 333 void close() => onClose(); | 333 void close() => onClose(); |
| 334 } | 334 } |
| OLD | NEW |