| 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 if (options.config == 'dev') { |
| 13 'dart:core': joinPaths(options.libDir, 'corelib.dart'), | 13 _specialLibs = { |
| 14 'dart:coreimpl': joinPaths(options.libDir, 'corelib_impl.dart'), | 14 'dart:core': joinPaths(options.libDir, 'corelib.dart'), |
| 15 'dart:html': joinPaths(options.libDir, | 15 'dart:coreimpl': joinPaths(options.libDir, 'corelib_impl.dart'), |
| 16 '../../client/html/release/html.dart'), | 16 'dart:html': joinPaths(options.libDir, |
| 17 'dart:htmlimpl': joinPaths(options.libDir, | 17 '../../client/html/release/html.dart'), |
| 18 '../../client/html/release/htmlimpl.dart'), | 18 'dart:htmlimpl': joinPaths(options.libDir, |
| 19 'dart:dom': joinPaths(options.libDir, | 19 '../../client/html/release/htmlimpl.dart'), |
| 20 '../../client/dom/frog/frog_dom.dart'), | 20 'dart:dom': joinPaths(options.libDir, |
| 21 'dart:json': joinPaths(options.libDir, 'json.dart'), | 21 '../../client/dom/frog/frog_dom.dart'), |
| 22 }; | 22 'dart:json': joinPaths(options.libDir, 'json.dart'), |
| 23 }; |
| 24 } else if (options.config == 'sdk') { |
| 25 _specialLibs = { |
| 26 'dart:core': joinPaths(options.libDir, 'core/core_frog.dart'), |
| 27 'dart:coreimpl': joinPaths(options.libDir, |
| 28 'coreimpl/coreimpl_frog.dart'), |
| 29 'dart:html': joinPaths(options.libDir, 'html/html.dart'), |
| 30 'dart:htmlimpl': joinPaths(options.libDir, 'htmlimpl/htmlimpl.dart'), |
| 31 'dart:dom': joinPaths(options.libDir, 'dom/frog/frog_dom.dart'), |
| 32 'dart:json': joinPaths(options.libDir, 'coreimpl/frog/json.dart'), |
| 33 }; |
| 34 } else { |
| 35 world.error('Invalid configuration ${options.config}'); |
| 36 } |
| 23 } | 37 } |
| 24 | 38 |
| 25 SourceFile readFile(String fullname) { | 39 SourceFile readFile(String fullname) { |
| 26 var filename = _specialLibs[fullname]; | 40 var filename = _specialLibs[fullname]; |
| 27 if (filename == null) { | 41 if (filename == null) { |
| 28 filename = fullname; | 42 filename = fullname; |
| 29 } | 43 } |
| 30 | 44 |
| 31 if (world.files.fileExists(filename)) { | 45 if (world.files.fileExists(filename)) { |
| 32 // TODO(jimhug): Should we cache these based on time stamps here? | 46 // TODO(jimhug): Should we cache these based on time stamps here? |
| 33 return new SourceFile(filename, world.files.readAll(filename)); | 47 return new SourceFile(filename, world.files.readAll(filename)); |
| 34 } else { | 48 } else { |
| 35 world.error('File not found: $filename', null); | 49 world.error('File not found: $filename', null); |
| 36 return new SourceFile(filename, ''); | 50 return new SourceFile(filename, ''); |
| 37 } | 51 } |
| 38 } | 52 } |
| 39 } | 53 } |
| OLD | NEW |