Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: dart/frog/leg/frog_leg.dart

Issue 9866006: Add library mapping. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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('frog_leg'); 5 #library('frog_leg');
6 6
7 #import('dart:io');
8
7 #import('../../lib/uri/uri.dart'); 9 #import('../../lib/uri/uri.dart');
8 #import('source_file.dart'); 10 #import('source_file.dart');
9 #import('../lang.dart', prefix: 'frog'); 11 #import('../lang.dart', prefix: 'frog');
10 #import('api.dart', prefix: 'api'); 12 #import('api.dart', prefix: 'api');
11 #import('io/io.dart', prefix: 'io');
12 13
13 String relativize(Uri base, Uri uri) { 14 String relativize(Uri base, Uri uri) {
14 if (base.scheme == 'file' && 15 if (base.scheme == 'file' &&
15 base.scheme == uri.scheme && 16 base.scheme == uri.scheme &&
16 base.userInfo == uri.userInfo && 17 base.userInfo == uri.userInfo &&
17 base.domain == uri.domain && 18 base.domain == uri.domain &&
18 base.port == uri.port && 19 base.port == uri.port &&
19 uri.query == "" && uri.fragment == "") { 20 uri.query == "" && uri.fragment == "") {
20 if (uri.path.startsWith(base.path)) { 21 if (uri.path.startsWith(base.path)) {
21 return uri.path.substring(base.path.length); 22 return uri.path.substring(base.path.length);
(...skipping 16 matching lines...) Expand all
38 return sb.toString(); 39 return sb.toString();
39 } 40 }
40 return uri.toString(); 41 return uri.toString();
41 } 42 }
42 43
43 bool compile(frog.World world) { 44 bool compile(frog.World world) {
44 final throwOnError = frog.options.throwOnErrors; 45 final throwOnError = frog.options.throwOnErrors;
45 final showWarnings = frog.options.showWarnings; 46 final showWarnings = frog.options.showWarnings;
46 final allowMockCompilation = frog.options.allowMockCompilation; 47 final allowMockCompilation = frog.options.allowMockCompilation;
47 // final compiler = new WorldCompiler(world, throwOnError); 48 // final compiler = new WorldCompiler(world, throwOnError);
48 Uri cwd = new Uri(scheme: 'file', path: io.getCurrentDirectory()); 49 Uri cwd = new Uri(scheme: 'file', path: getCurrentDirectory());
49 Uri uri = cwd.resolve(frog.options.dartScript); 50 Uri uri = cwd.resolve(frog.options.dartScript);
50 String frogLibDir = frog.options.libDir; 51 String frogLibDir = frog.options.libDir;
51 if (!frogLibDir.endsWith("/")) frogLibDir = "$frogLibDir/"; 52 if (!frogLibDir.endsWith("/")) frogLibDir = "$frogLibDir/";
52 Uri frogLib = new Uri(scheme: 'file', path: frogLibDir); 53 Uri frogLib = new Uri(scheme: 'file', path: frogLibDir);
53 Uri libraryRoot = frogLib.resolve('../leg/lib/'); 54 Uri libraryRoot = frogLib.resolve('../../');
54 Map<String, SourceFile> sourceFiles = <SourceFile>{}; 55 Map<String, SourceFile> sourceFiles = <SourceFile>{};
55 56
56 Future<String> provider(Uri uri) { 57 Future<String> provider(Uri uri) {
57 if (uri.scheme != 'file') { 58 if (uri.scheme != 'file') {
58 throw new IllegalArgumentException(uri); 59 throw new IllegalArgumentException(uri);
59 } 60 }
60 String source = world.files.readAll(uri.path); 61 String source = world.files.readAll(uri.path);
61 world.dartBytesRead += source.length; 62 world.dartBytesRead += source.length;
62 sourceFiles[uri.toString()] = 63 sourceFiles[uri.toString()] =
63 new SourceFile(relativize(cwd, uri), source); 64 new SourceFile(relativize(cwd, uri), source);
(...skipping 27 matching lines...) Expand all
91 world.legCode = code; 92 world.legCode = code;
92 world.jsBytesWritten = code.length; 93 world.jsBytesWritten = code.length;
93 return true; 94 return true;
94 } 95 }
95 96
96 class AbortLeg { 97 class AbortLeg {
97 final message; 98 final message;
98 AbortLeg(this.message); 99 AbortLeg(this.message);
99 toString() => 'Aborted due to --throw-on-error: $message'; 100 toString() => 'Aborted due to --throw-on-error: $message';
100 } 101 }
102
103 String getCurrentDirectory() {
ahe 2012/03/26 21:39:33 Duplicated code. This file will go away when we fu
104 String dir = new File(".").fullPathSync();
105 if (dir.endsWith("/")) return dir;
106 return "$dir/";
107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698