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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | bin/builtin_nolib.cc » ('j') | bin/gen_snapshot.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/builtin.dart
===================================================================
--- bin/builtin.dart (revision 4985)
+++ bin/builtin.dart (working copy)
@@ -3,8 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
#library("builtin");
-#import("dart:nativewrappers");
-#import("dart:coreimpl");
void print(arg) {
_Logger._printString(arg.toString());
@@ -22,3 +20,42 @@
class _Logger {
static void _printString(String s) native "Logger_PrintString";
}
+
+
+// Code to deal with URI resolution for the standalone binary.
+void _logResolution(String msg) {
+ final enabled = false;
+ if (enabled) {
+ _Logger._printString(msg);
+ }
+}
+
+// TODO(iposva): Make these private once the Dart API is fixed.
ahe 2012/03/06 08:27:15 I'm curious, what needs to be fixed?
Ivan Posva 2012/03/07 07:46:53 Currently calling private methods through the Dart
ahe 2012/03/07 08:22:38 I guess that by Dart API, you are referring to the
+String resolveScriptUri(String cwd, String scriptName) {
+ _logResolution("# Current working directory: $cwd");
ahe 2012/03/06 08:27:15 This form of logging is expensive because you have
Ivan Posva 2012/03/07 07:46:53 Will be removed once I am convinced that this work
+ _logResolution("# ScriptName: $scriptName");
+ var base = new Uri(scheme: "file", path: "$cwd/");
ahe 2012/03/06 08:27:15 Appending / doesn't work for the root directory. S
Ivan Posva 2012/03/07 07:46:53 The problem with io.dart in leg is that it is curr
ahe 2012/03/07 08:22:38 I meant to refer to how I handle trailing "/" in d
+ var resolved = base.resolve(scriptName);
+ _logResolution("# Resolved to: $resolved");
+ return resolved.toString();
+}
+
+String resolveUri(String base, String userString) {
+ var baseUri = new Uri.fromString(base);
+ _logResolution("# Resolving: $userString from $base");
+ var resolved = baseUri.resolve(userString);
+ _logResolution("# Resolved to: $resolved");
+ return resolved.toString();
+}
+
+String filePathFromUri(String userUri) {
+ var uri = new Uri.fromString(userUri);
+ _logResolution("# Getting file path from: $uri");
+ if ("file" != uri.scheme) {
+ // Only handling file URIs in standalone binary.
+ _logResolution("# Not a file URI.");
+ throw "Not a file uri: $uri";
+ }
+ _logResolution("# Path: ${uri.path}");
+ return uri.path;
+}
« no previous file with comments | « no previous file | bin/builtin_nolib.cc » ('j') | bin/gen_snapshot.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698