Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
|
ahe
2012/03/06 08:27:15
This file LGTM, but you may want to change how you
| |
| 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. | |
|
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
| |
| 34 String resolveScriptUri(String cwd, String scriptName) { | |
| 35 _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
| |
| 36 _logResolution("# ScriptName: $scriptName"); | |
| 37 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
| |
| 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 } | |
| OLD | NEW |