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

Side by Side Diff: bin/builtin.dart

Issue 9608028: - D:\rive\letters (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 9 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 | « no previous file | bin/main.cc » ('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 6
7 void print(arg) { 7 void print(arg) {
8 _Logger._printString(arg.toString()); 8 _Logger._printString(arg.toString());
9 } 9 }
10 10
11 void exit(int status) { 11 void exit(int status) {
12 if (status is !int) { 12 if (status is !int) {
13 throw new IllegalArgumentException("int status expected"); 13 throw new IllegalArgumentException("int status expected");
14 } 14 }
15 _exit(status); 15 _exit(status);
16 } 16 }
17 17
18 _exit(int status) native "Exit"; 18 _exit(int status) native "Exit";
19 19
20 class _Logger { 20 class _Logger {
21 static void _printString(String s) native "Logger_PrintString"; 21 static void _printString(String s) native "Logger_PrintString";
22 } 22 }
23 23
24 24
25 // Code to deal with URI resolution for the standalone binary. 25 // Code to deal with URI resolution for the standalone binary.
26 var _is_windows;
27
26 void _logResolution(String msg) { 28 void _logResolution(String msg) {
27 final enabled = false; 29 final enabled = false;
28 if (enabled) { 30 if (enabled || _is_windows) {
29 _Logger._printString(msg); 31 _Logger._printString(msg);
30 } 32 }
31 } 33 }
32 34
33 // TODO(iposva): Make these private once the Dart API is fixed. 35 // TODO(iposva): Make these private once the Dart API is fixed.
34 String resolveScriptUri(String cwd, String scriptName) { 36 String resolveScriptUri(String cwd, String scriptName, bool windows) {
37 _is_windows = windows;
35 _logResolution("# Current working directory: $cwd"); 38 _logResolution("# Current working directory: $cwd");
36 _logResolution("# ScriptName: $scriptName"); 39 _logResolution("# ScriptName: $scriptName");
40 if (windows) {
41 // Convert
42 // C:\one\two\three
43 // to
44 // /C:/one/two/three
45 cwd = "/${cwd.replaceAll('\\', '/')}";
46 _logResolution("## cwd: $cwd");
47 if ((scriptName.length > 2) && (scriptName[1] == ":")) {
48 // This is an absolute path.
49 scriptName = "/${scriptName.replaceAll('\\', '/')}";
50 } else {
51 scriptName = scriptName.replaceAll('\\', '/');
52 }
53 _logResolution("## scriptName: $scriptName");
54 }
37 var base = new Uri(scheme: "file", path: cwd.endsWith("/") ? cwd : "$cwd/"); 55 var base = new Uri(scheme: "file", path: cwd.endsWith("/") ? cwd : "$cwd/");
38 var resolved = base.resolve(scriptName); 56 var resolved = base.resolve(scriptName);
39 _logResolution("# Resolved to: $resolved"); 57 _logResolution("# Resolved to: $resolved");
40 return resolved.toString(); 58 return resolved.toString();
41 } 59 }
42 60
43 String resolveUri(String base, String userString) { 61 String resolveUri(String base, String userString) {
44 var baseUri = new Uri.fromString(base); 62 var baseUri = new Uri.fromString(base);
45 _logResolution("# Resolving: $userString from $base"); 63 _logResolution("# Resolving: $userString from $base");
46 var resolved = baseUri.resolve(userString); 64 var resolved = baseUri.resolve(userString);
47 _logResolution("# Resolved to: $resolved"); 65 _logResolution("# Resolved to: $resolved");
48 return resolved.toString(); 66 return resolved.toString();
49 } 67 }
50 68
51 String filePathFromUri(String userUri) { 69 String filePathFromUri(String userUri) {
52 var uri = new Uri.fromString(userUri); 70 var uri = new Uri.fromString(userUri);
53 _logResolution("# Getting file path from: $uri"); 71 _logResolution("# Getting file path from: $uri");
54 if ("file" != uri.scheme) { 72 if ("file" != uri.scheme) {
55 // Only handling file URIs in standalone binary. 73 // Only handling file URIs in standalone binary.
56 _logResolution("# Not a file URI."); 74 _logResolution("# Not a file URI.");
57 throw "Not a file uri: $uri"; 75 throw "Not a file uri: $uri";
58 } 76 }
59 _logResolution("# Path: ${uri.path}"); 77 _logResolution("# Path: ${uri.path}");
60 return uri.path; 78 return uri.path;
61 } 79 }
OLDNEW
« no previous file with comments | « no previous file | bin/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698