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