Convert std::os to istrs. Issue #855

This commit is contained in:
Brian Anderson 2011-08-25 11:11:21 -07:00
parent 85b4253bc1
commit 15e3ae7936
8 changed files with 30 additions and 22 deletions

View File

@ -2,31 +2,32 @@
import lib::llvm::llvm;
import lib::llvm::llvm::ModuleRef;
import std::str;
import std::istr;
import std::os::target_os;
fn get_module_asm() -> str { ret ""; }
fn get_meta_sect_name() -> str {
if str::eq(target_os(), "macos") { ret "__DATA,__note.rustc"; }
if str::eq(target_os(), "win32") { ret ".note.rustc"; }
if istr::eq(target_os(), ~"macos") { ret "__DATA,__note.rustc"; }
if istr::eq(target_os(), ~"win32") { ret ".note.rustc"; }
ret ".note.rustc";
}
fn get_data_layout() -> str {
if str::eq(target_os(), "macos") {
if istr::eq(target_os(), ~"macos") {
ret "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" + "-i32:32:32-i64:32:64" +
"-f32:32:32-f64:32:64-v64:64:64" +
"-v128:128:128-a0:0:64-f80:128:128" + "-n8:16:32";
}
if str::eq(target_os(), "win32") {
if istr::eq(target_os(), ~"win32") {
ret "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32";
}
ret "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32";
}
fn get_target_triple() -> str {
if str::eq(target_os(), "macos") { ret "i686-apple-darwin"; }
if str::eq(target_os(), "win32") { ret "i686-pc-mingw32"; }
if istr::eq(target_os(), ~"macos") { ret "i686-apple-darwin"; }
if istr::eq(target_os(), ~"win32") { ret "i686-pc-mingw32"; }
ret "i686-unknown-linux-gnu";
}
//

View File

@ -55,7 +55,8 @@ fn default_configuration(sess: session::session, argv0: str, input: str) ->
let mk = attr::mk_name_value_item_str;
ret [ // Target bindings.
mk("target_os", std::os::target_os()), mk("target_arch", "x86"),
mk("target_os", istr::to_estr(std::os::target_os())),
mk("target_arch", "x86"),
mk("target_libc", libc),
// Build bindings.
mk("build_compiler", argv0), mk("build_input", input)];

View File

@ -70,7 +70,7 @@ fn make_absolute(p: &path) -> path {
if path_is_absolute(p) {
ret p;
} else {
ret connect(istr::from_estr(getcwd()), p);
ret connect(getcwd(), p);
}
}

View File

@ -52,11 +52,11 @@ mod libc_constants {
fn S_IWUSR() -> uint { ret 128u; }
}
fn exec_suffix() -> str { ret ""; }
fn exec_suffix() -> istr { ret ~""; }
fn target_os() -> str { ret "linux"; }
fn target_os() -> istr { ret ~"linux"; }
fn dylib_filename(base: str) -> str { ret "lib" + base + ".so"; }
fn dylib_filename(base: &istr) -> istr { ret ~"lib" + base + ~".so"; }
fn pipe() -> {in: int, out: int} {
let fds = {mutable in: 0, mutable out: 0};
@ -76,7 +76,9 @@ native "rust" mod rustrt {
fn rust_getcwd() -> str;
}
fn getcwd() -> str { ret rustrt::rust_getcwd(); }
fn getcwd() -> istr {
ret istr::from_estr(rustrt::rust_getcwd());
}
// Local Variables:

View File

@ -49,11 +49,11 @@ mod libc_constants {
fn S_IWUSR() -> uint { ret 512u; }
}
fn exec_suffix() -> str { ret ""; }
fn exec_suffix() -> istr { ret ~""; }
fn target_os() -> str { ret "macos"; }
fn target_os() -> istr { ret ~"macos"; }
fn dylib_filename(base: str) -> str { ret "lib" + base + ".dylib"; }
fn dylib_filename(base: &istr) -> istr { ret ~"lib" + base + ~".dylib"; }
fn pipe() -> {in: int, out: int} {
let fds = {mutable in: 0, mutable out: 0};
@ -73,7 +73,9 @@ native "rust" mod rustrt {
fn rust_getcwd() -> str;
}
fn getcwd() -> str { ret rustrt::rust_getcwd(); }
fn getcwd() -> istr {
ret istr::from_estr(rustrt::rust_getcwd());
}
// Local Variables:

View File

@ -46,11 +46,11 @@ native "x86stdcall" mod kernel32 {
fn SetEnvironmentVariableA(n: sbuf, v: sbuf) -> int;
}
fn exec_suffix() -> str { ret ".exe"; }
fn exec_suffix() -> istr { ret ~".exe"; }
fn target_os() -> str { ret "win32"; }
fn target_os() -> istr { ret ~"win32"; }
fn dylib_filename(base: str) -> str { ret base + ".dll"; }
fn dylib_filename(base: &istr) -> istr { ret base + ~".dll"; }
fn pipe() -> {in: int, out: int} {
// Windows pipes work subtly differently than unix pipes, and their
@ -78,7 +78,9 @@ native "rust" mod rustrt {
fn waitpid(pid: int) -> int { ret rustrt::rust_process_wait(pid); }
fn getcwd() -> str { ret rustrt::rust_getcwd(); }
fn getcwd() -> istr {
ret istr::from_estr(rustrt::rust_getcwd());
}
// Local Variables:
// mode: rust;

View File

@ -252,7 +252,7 @@ fn make_compile_args(config: &config, props: &test_props, testfile: &str) ->
}
fn make_exe_name(config: &config, testfile: &str) -> str {
output_base_name(config, testfile) + os::exec_suffix()
output_base_name(config, testfile) + istr::to_estr(os::exec_suffix())
}
fn make_run_args(config: &config, props: &test_props, testfile: &str) ->

View File

@ -10,7 +10,7 @@ import std::os;
fn test() {
assert (!fs::path_is_absolute(~"test-path"));
log "Current working directory: " + os::getcwd();
log ~"Current working directory: " + os::getcwd();
log fs::make_absolute(~"test-path");
log fs::make_absolute(~"/usr/bin");