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

Side by Side Diff: runtime/bin/builtin.dart

Issue 10332257: Revert my last change. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « runtime/bin/builtin.cc ('k') | runtime/bin/dartutils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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("builtin"); 5 #library("builtin");
6 #import("dart:uri"); 6 #import("dart:uri");
7 7
8 void print(arg) { 8 void print(arg) {
9 _Logger._printString(arg.toString()); 9 _Logger._printString(arg.toString());
10 } 10 }
11 11
12 void exit(int status) { 12 void exit(int status) {
13 if (status is !int) { 13 if (status is !int) {
14 throw new IllegalArgumentException("int status expected"); 14 throw new IllegalArgumentException("int status expected");
15 } 15 }
16 _exit(status); 16 _exit(status);
17 } 17 }
18 18
19 _exit(int status) native "Exit"; 19 _exit(int status) native "Exit";
20 20
21 class _Logger { 21 class _Logger {
22 static void _printString(String s) native "Logger_PrintString"; 22 static void _printString(String s) native "Logger_PrintString";
23 } 23 }
24 24
25 25
26 // Code to deal with URI resolution for the standalone binary.
27 // For Windows we need to massage the paths a bit according to
28 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx
29 var _is_windows;
30
26 // The URI that the entrypoint script was loaded from. Remembered so that 31 // The URI that the entrypoint script was loaded from. Remembered so that
27 // package imports can be resolved relative to it. 32 // package imports can be resolved relative to it.
28 var _entrypoint; 33 var _entrypoint;
29 34
30 // The directory to look in to resolve "package:" scheme URIs. 35 // The directory to look in to resolve "package:" scheme URIs.
31 var _packageRoot; 36 var _packageRoot;
32 37
33 void _logResolution(String msg) { 38 void _logResolution(String msg) {
34 final enabled = false; 39 final enabled = false;
35 if (enabled) { 40 if (enabled) {
36 _Logger._printString(msg); 41 _Logger._printString(msg);
37 } 42 }
38 } 43 }
39 44
40 String _setPackageRoot(String packageRoot) { 45 String _setPackageRoot(String packageRoot) {
41 // TODO(mattsh) - refactor windows drive and path handling code 46 // TODO(mattsh) - refactor windows drive and path handling code
42 // so it can be used here if needed. 47 // so it can be used here if needed.
43 _packageRoot = packageRoot; 48 _packageRoot = packageRoot;
44 } 49 }
45 50
46 String _resolveScriptUri(String cwd, String scriptName, bool isWindows) { 51 String _resolveScriptUri(String cwd, String scriptName, bool windows) {
52 _is_windows = windows;
47 _logResolution("# Current working directory: $cwd"); 53 _logResolution("# Current working directory: $cwd");
48 _logResolution("# ScriptName: $scriptName"); 54 _logResolution("# ScriptName: $scriptName");
49 if (isWindows) { 55 if (windows) {
50 // For Windows we need to massage the paths a bit according to
51 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx
52 //
53 // Convert 56 // Convert
54 // C:\one\two\three 57 // C:\one\two\three
55 // to 58 // to
56 // /C:/one/two/three 59 // /C:/one/two/three
57 cwd = "/${cwd.replaceAll('\\', '/')}"; 60 cwd = "/${cwd.replaceAll('\\', '/')}";
58 _logResolution("## cwd: $cwd"); 61 _logResolution("## cwd: $cwd");
59 if ((scriptName.length > 2) && (scriptName[1] == ":")) { 62 if ((scriptName.length > 2) && (scriptName[1] == ":")) {
60 // This is an absolute path. 63 // This is an absolute path.
61 scriptName = "/${scriptName.replaceAll('\\', '/')}"; 64 scriptName = "/${scriptName.replaceAll('\\', '/')}";
62 } else { 65 } else {
(...skipping 19 matching lines...) Expand all
82 resolved = baseUri.resolve(uri.path); 85 resolved = baseUri.resolve(uri.path);
83 resolved = new Uri(scheme: "dart-ext", path: resolved.path); 86 resolved = new Uri(scheme: "dart-ext", path: resolved.path);
84 } else { 87 } else {
85 resolved = baseUri.resolve(userString); 88 resolved = baseUri.resolve(userString);
86 } 89 }
87 _logResolution("# Resolved to: $resolved"); 90 _logResolution("# Resolved to: $resolved");
88 return resolved.toString(); 91 return resolved.toString();
89 } 92 }
90 93
91 94
92 String _filePathFromUri(String userUri, bool isWindows) { 95 String _filePathFromUri(String userUri) {
93 var uri = new Uri.fromString(userUri); 96 var uri = new Uri.fromString(userUri);
94 _logResolution("# Getting file path from: $uri"); 97 _logResolution("# Getting file path from: $uri");
95 98
96 var path; 99 var path;
97 switch (uri.scheme) { 100 switch (uri.scheme) {
98 case 'file': 101 case 'file':
99 path = _filePathFromFileUri(uri); 102 path = _filePathFromFileUri(uri);
100 break; 103 break;
101 case 'dart-ext': 104 case 'dart-ext':
102 path = _filePathFromOtherUri(uri); 105 path = _filePathFromOtherUri(uri);
103 break; 106 break;
104 case 'package': 107 case 'package':
105 path = _filePathFromPackageUri(uri); 108 path = _filePathFromPackageUri(uri);
106 break; 109 break;
107 default: 110 default:
108 // Only handling file and package URIs in standalone binary. 111 // Only handling file and package URIs in standalone binary.
109 _logResolution("# Unknown scheme (${uri.scheme}) in $uri."); 112 _logResolution("# Unknown scheme (${uri.scheme}) in $uri.");
110 throw "Not a known scheme: $uri"; 113 throw "Not a known scheme: $uri";
111 } 114 }
112 115
113 if (isWindows) { 116 if (_is_windows) {
114 // For Windows we need to massage the paths a bit according to
115 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx
116 //
117 // Drop the leading / before the drive letter. 117 // Drop the leading / before the drive letter.
118 path = path.substring(1); 118 path = path.substring(1);
119 _logResolution("# path: $path"); 119 _logResolution("# path: $path");
120 } 120 }
121 121
122 return path; 122 return path;
123 } 123 }
124 124
125 String _filePathFromFileUri(Uri uri) { 125 String _filePathFromFileUri(Uri uri) {
126 if (uri.domain != '') { 126 if (uri.domain != '') {
(...skipping 26 matching lines...) Expand all
153 var path; 153 var path;
154 if (_packageRoot !== null) { 154 if (_packageRoot !== null) {
155 path = "${_packageRoot}${uri.path}"; 155 path = "${_packageRoot}${uri.path}";
156 } else { 156 } else {
157 path = _entrypoint.resolve('packages/${uri.path}').path; 157 path = _entrypoint.resolve('packages/${uri.path}').path;
158 } 158 }
159 159
160 _logResolution("# Package: $path"); 160 _logResolution("# Package: $path");
161 return path; 161 return path;
162 } 162 }
OLDNEW
« no previous file with comments | « runtime/bin/builtin.cc ('k') | runtime/bin/dartutils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698