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

Side by Side Diff: bin/builtin.dart

Issue 9614006: - Proper URI resolution when loading scripts from the standalone binary. (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/builtin_nolib.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) 2011, 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:nativewrappers");
7 #import("dart:coreimpl");
8 6
9 void print(arg) { 7 void print(arg) {
10 _Logger._printString(arg.toString()); 8 _Logger._printString(arg.toString());
11 } 9 }
12 10
13 void exit(int status) { 11 void exit(int status) {
14 if (status is !int) { 12 if (status is !int) {
15 throw new IllegalArgumentException("int status expected"); 13 throw new IllegalArgumentException("int status expected");
16 } 14 }
17 _exit(status); 15 _exit(status);
18 } 16 }
19 17
20 _exit(int status) native "Exit"; 18 _exit(int status) native "Exit";
21 19
22 class _Logger { 20 class _Logger {
23 static void _printString(String s) native "Logger_PrintString"; 21 static void _printString(String s) native "Logger_PrintString";
24 } 22 }
23
24
25 // Code to deal with URI resolution for the standalone binary.
26 void _logResolution(String msg) {
27 final enabled = false;
28 if (enabled) {
29 _Logger._printString(msg);
30 }
31 }
32
33 // TODO(iposva): Make these private once the Dart API is fixed.
34 String resolveScriptUri(String cwd, String scriptName) {
35 _logResolution("# Current working directory: $cwd");
36 _logResolution("# ScriptName: $scriptName");
37 var base = new Uri(scheme: "file", path: cwd.endsWith("/") ? cwd : "$cwd/");
38 var resolved = base.resolve(scriptName);
39 _logResolution("# Resolved to: $resolved");
40 return resolved.toString();
41 }
42
43 String resolveUri(String base, String userString) {
44 var baseUri = new Uri.fromString(base);
45 _logResolution("# Resolving: $userString from $base");
46 var resolved = baseUri.resolve(userString);
47 _logResolution("# Resolved to: $resolved");
48 return resolved.toString();
49 }
50
51 String filePathFromUri(String userUri) {
52 var uri = new Uri.fromString(userUri);
53 _logResolution("# Getting file path from: $uri");
54 if ("file" != uri.scheme) {
55 // Only handling file URIs in standalone binary.
56 _logResolution("# Not a file URI.");
57 throw "Not a file uri: $uri";
58 }
59 _logResolution("# Path: ${uri.path}");
60 return uri.path;
61 }
OLDNEW
« no previous file with comments | « no previous file | bin/builtin_nolib.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698