| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** | 5 /** |
| 6 * An code reader that abstracts away the distinction between internal and user | 6 * An code reader that abstracts away the distinction between internal and user |
| 7 * libraries. | 7 * libraries. |
| 8 */ | 8 */ |
| 9 class LibraryReader { | 9 class LibraryReader { |
| 10 Map _specialLibs; | 10 Map _specialLibs; |
| 11 LibraryReader() { | 11 LibraryReader() { |
| 12 _specialLibs = { | 12 _specialLibs = { |
| 13 'dart:core': joinPaths(options.libDir, 'corelib.dart'), | 13 'dart:core': joinPaths(options.libDir, 'corelib.dart'), |
| 14 'dart:coreimpl': joinPaths(options.libDir, 'corelib_impl.dart'), | 14 'dart:coreimpl': joinPaths(options.libDir, 'corelib_impl.dart'), |
| 15 'dart:html': joinPaths(options.libDir, | 15 'dart:html': joinPaths(options.libDir, |
| 16 '../../client/html/release/html.dart'), | 16 '../../client/html/release/html.dart'), |
| 17 'dart:htmlimpl': joinPaths(options.libDir, |
| 18 '../../client/html/release/htmlimpl.dart'), |
| 17 'dart:dom': joinPaths(options.libDir, | 19 'dart:dom': joinPaths(options.libDir, |
| 18 '../../client/dom/frog/frog_dom.dart'), | 20 '../../client/dom/frog/frog_dom.dart'), |
| 19 'dart:json': joinPaths(options.libDir, 'json.dart'), | 21 'dart:json': joinPaths(options.libDir, 'json.dart'), |
| 20 }; | 22 }; |
| 21 } | 23 } |
| 22 | 24 |
| 23 SourceFile readFile(String fullname) { | 25 SourceFile readFile(String fullname) { |
| 24 var filename = _specialLibs[fullname]; | 26 var filename = _specialLibs[fullname]; |
| 25 if (filename == null) { | 27 if (filename == null) { |
| 26 filename = fullname; | 28 filename = fullname; |
| 27 } | 29 } |
| 28 | 30 |
| 29 if (world.files.fileExists(filename)) { | 31 if (world.files.fileExists(filename)) { |
| 30 // TODO(jimhug): Should we cache these based on time stamps here? | 32 // TODO(jimhug): Should we cache these based on time stamps here? |
| 31 return new SourceFile(filename, world.files.readAll(filename)); | 33 return new SourceFile(filename, world.files.readAll(filename)); |
| 32 } else { | 34 } else { |
| 33 world.error('File not found: $filename', null); | 35 world.error('File not found: $filename', null); |
| 34 return new SourceFile(filename, ''); | 36 return new SourceFile(filename, ''); |
| 35 } | 37 } |
| 36 } | 38 } |
| 37 } | 39 } |
| OLD | NEW |