Rename std::istr to std::str. Issue #855
This commit is contained in:
parent
913667ba25
commit
ab6bb035e5
112 changed files with 741 additions and 741 deletions
|
@ -5,7 +5,7 @@ import front::attr;
|
||||||
import middle::ty;
|
import middle::ty;
|
||||||
import metadata::encoder;
|
import metadata::encoder;
|
||||||
import middle::trans_common::crate_ctxt;
|
import middle::trans_common::crate_ctxt;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::fs;
|
import std::fs;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::option;
|
import std::option;
|
||||||
|
@ -37,7 +37,7 @@ fn llvm_err(sess: session::session, msg: &istr) {
|
||||||
sess.fatal(msg);
|
sess.fatal(msg);
|
||||||
} else {
|
} else {
|
||||||
sess.fatal(
|
sess.fatal(
|
||||||
msg + ~": " + istr::str_from_cstr(buf));
|
msg + ~": " + str::str_from_cstr(buf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ fn link_intrinsics(sess: session::session, llmod: ModuleRef) {
|
||||||
let path =
|
let path =
|
||||||
fs::connect(sess.get_opts().sysroot,
|
fs::connect(sess.get_opts().sysroot,
|
||||||
~"lib/intrinsics.bc");
|
~"lib/intrinsics.bc");
|
||||||
let membuf = istr::as_buf(path, { |buf|
|
let membuf = str::as_buf(path, { |buf|
|
||||||
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
|
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
|
||||||
});
|
});
|
||||||
if membuf as uint == 0u {
|
if membuf as uint == 0u {
|
||||||
|
@ -78,11 +78,11 @@ mod write {
|
||||||
// Decides what to call an intermediate file, given the name of the output
|
// Decides what to call an intermediate file, given the name of the output
|
||||||
// and the extension to use.
|
// and the extension to use.
|
||||||
fn mk_intermediate_name(output_path: &istr, extension: &istr) -> istr {
|
fn mk_intermediate_name(output_path: &istr, extension: &istr) -> istr {
|
||||||
let dot_pos = istr::index(output_path, '.' as u8);
|
let dot_pos = str::index(output_path, '.' as u8);
|
||||||
let stem;
|
let stem;
|
||||||
if dot_pos < 0 {
|
if dot_pos < 0 {
|
||||||
stem = output_path;
|
stem = output_path;
|
||||||
} else { stem = istr::substr(output_path, 0u, dot_pos as uint); }
|
} else { stem = str::substr(output_path, 0u, dot_pos as uint); }
|
||||||
ret stem + ~"." + extension;
|
ret stem + ~"." + extension;
|
||||||
}
|
}
|
||||||
fn run_passes(sess: session::session, llmod: ModuleRef, output: &istr) {
|
fn run_passes(sess: session::session, llmod: ModuleRef, output: &istr) {
|
||||||
|
@ -103,14 +103,14 @@ mod write {
|
||||||
output_type_bitcode. {
|
output_type_bitcode. {
|
||||||
if opts.optimize != 0u {
|
if opts.optimize != 0u {
|
||||||
let filename = mk_intermediate_name(output, ~"no-opt.bc");
|
let filename = mk_intermediate_name(output, ~"no-opt.bc");
|
||||||
istr::as_buf(filename, { |buf|
|
str::as_buf(filename, { |buf|
|
||||||
llvm::LLVMWriteBitcodeToFile(llmod, buf)
|
llvm::LLVMWriteBitcodeToFile(llmod, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ {
|
_ {
|
||||||
let filename = mk_intermediate_name(output, ~"bc");
|
let filename = mk_intermediate_name(output, ~"bc");
|
||||||
istr::as_buf(filename, { |buf|
|
str::as_buf(filename, { |buf|
|
||||||
llvm::LLVMWriteBitcodeToFile(llmod, buf)
|
llvm::LLVMWriteBitcodeToFile(llmod, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ mod write {
|
||||||
|
|
||||||
let filename = mk_intermediate_name(output, ~"opt.bc");
|
let filename = mk_intermediate_name(output, ~"opt.bc");
|
||||||
llvm::LLVMRunPassManager(pm.llpm, llmod);
|
llvm::LLVMRunPassManager(pm.llpm, llmod);
|
||||||
istr::as_buf(filename, { |buf|
|
str::as_buf(filename, { |buf|
|
||||||
llvm::LLVMWriteBitcodeToFile(llmod, buf)
|
llvm::LLVMWriteBitcodeToFile(llmod, buf)
|
||||||
});
|
});
|
||||||
pm = mk_pass_manager();
|
pm = mk_pass_manager();
|
||||||
|
@ -193,8 +193,8 @@ mod write {
|
||||||
|
|
||||||
if opts.output_type == output_type_assembly {
|
if opts.output_type == output_type_assembly {
|
||||||
let _: () =
|
let _: () =
|
||||||
istr::as_buf(x86::get_target_triple(), { |buf_t|
|
str::as_buf(x86::get_target_triple(), { |buf_t|
|
||||||
istr::as_buf(output, { |buf_o|
|
str::as_buf(output, { |buf_o|
|
||||||
llvm::LLVMRustWriteOutputFile(
|
llvm::LLVMRustWriteOutputFile(
|
||||||
pm.llpm, llmod,
|
pm.llpm, llmod,
|
||||||
buf_t,
|
buf_t,
|
||||||
|
@ -210,8 +210,8 @@ mod write {
|
||||||
if opts.output_type == output_type_object ||
|
if opts.output_type == output_type_object ||
|
||||||
opts.output_type == output_type_exe {
|
opts.output_type == output_type_exe {
|
||||||
let _: () =
|
let _: () =
|
||||||
istr::as_buf(x86::get_target_triple(), { |buf_t|
|
str::as_buf(x86::get_target_triple(), { |buf_t|
|
||||||
istr::as_buf(output, { |buf_o|
|
str::as_buf(output, { |buf_o|
|
||||||
llvm::LLVMRustWriteOutputFile(
|
llvm::LLVMRustWriteOutputFile(
|
||||||
pm.llpm, llmod,
|
pm.llpm, llmod,
|
||||||
buf_t,
|
buf_t,
|
||||||
|
@ -224,8 +224,8 @@ mod write {
|
||||||
// If we aren't saving temps then just output the file
|
// If we aren't saving temps then just output the file
|
||||||
// type corresponding to the '-c' or '-S' flag used
|
// type corresponding to the '-c' or '-S' flag used
|
||||||
|
|
||||||
let _: () = istr::as_buf(x86::get_target_triple(), { |buf_t|
|
let _: () = str::as_buf(x86::get_target_triple(), { |buf_t|
|
||||||
istr::as_buf(output, { |buf_o|
|
str::as_buf(output, { |buf_o|
|
||||||
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
|
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
|
||||||
buf_t,
|
buf_t,
|
||||||
buf_o,
|
buf_o,
|
||||||
|
@ -243,7 +243,7 @@ mod write {
|
||||||
// flag, then output it here
|
// flag, then output it here
|
||||||
|
|
||||||
llvm::LLVMRunPassManager(pm.llpm, llmod);
|
llvm::LLVMRunPassManager(pm.llpm, llmod);
|
||||||
istr::as_buf(output, { |buf|
|
str::as_buf(output, { |buf|
|
||||||
llvm::LLVMWriteBitcodeToFile(llmod, buf)
|
llvm::LLVMWriteBitcodeToFile(llmod, buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMDisposeModule(llmod);
|
llvm::LLVMDisposeModule(llmod);
|
||||||
|
@ -340,7 +340,7 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &istr,
|
||||||
fn crate_meta_extras_hash(sha: sha1, _crate: &ast::crate,
|
fn crate_meta_extras_hash(sha: sha1, _crate: &ast::crate,
|
||||||
metas: &provided_metas) -> istr {
|
metas: &provided_metas) -> istr {
|
||||||
fn len_and_str(s: &istr) -> istr {
|
fn len_and_str(s: &istr) -> istr {
|
||||||
ret #ifmt["%u_%s", istr::byte_len(s), s];
|
ret #ifmt["%u_%s", str::byte_len(s), s];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn len_and_str_lit(l: &ast::lit) -> istr {
|
fn len_and_str_lit(l: &ast::lit) -> istr {
|
||||||
|
@ -383,12 +383,12 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &istr,
|
||||||
none. {
|
none. {
|
||||||
let name =
|
let name =
|
||||||
{
|
{
|
||||||
let os = istr::split(
|
let os = str::split(
|
||||||
fs::basename(output),
|
fs::basename(output),
|
||||||
'.' as u8);
|
'.' as u8);
|
||||||
assert (vec::len(os) >= 2u);
|
assert (vec::len(os) >= 2u);
|
||||||
vec::pop(os);
|
vec::pop(os);
|
||||||
istr::connect(os, ~".")
|
str::connect(os, ~".")
|
||||||
};
|
};
|
||||||
warn_missing(sess, ~"name", name);
|
warn_missing(sess, ~"name", name);
|
||||||
name
|
name
|
||||||
|
@ -417,7 +417,7 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &istr,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn truncated_sha1_result(sha: sha1) -> istr {
|
fn truncated_sha1_result(sha: sha1) -> istr {
|
||||||
ret istr::substr(sha.result_str(), 0u, 16u);
|
ret str::substr(sha.result_str(), 0u, 16u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ fn mangle(ss: &[istr]) -> istr {
|
||||||
let n = ~"_ZN"; // Begin name-sequence.
|
let n = ~"_ZN"; // Begin name-sequence.
|
||||||
|
|
||||||
for s: istr in ss {
|
for s: istr in ss {
|
||||||
n += #ifmt["%u%s", istr::byte_len(s), s];
|
n += #ifmt["%u%s", str::byte_len(s), s];
|
||||||
}
|
}
|
||||||
n += ~"E"; // End name-sequence.
|
n += ~"E"; // End name-sequence.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std::istr;
|
import std::str;
|
||||||
import middle::trans;
|
import middle::trans;
|
||||||
import trans::decl_cdecl_fn;
|
import trans::decl_cdecl_fn;
|
||||||
import middle::trans_common::T_f32;
|
import middle::trans_common::T_f32;
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
|
|
||||||
import lib::llvm::llvm;
|
import lib::llvm::llvm;
|
||||||
import lib::llvm::llvm::ModuleRef;
|
import lib::llvm::llvm::ModuleRef;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::os::target_os;
|
import std::os::target_os;
|
||||||
|
|
||||||
fn get_module_asm() -> istr { ret ~""; }
|
fn get_module_asm() -> istr { ret ~""; }
|
||||||
|
|
||||||
fn get_meta_sect_name() -> istr {
|
fn get_meta_sect_name() -> istr {
|
||||||
if istr::eq(target_os(), ~"macos") { ret ~"__DATA,__note.rustc"; }
|
if str::eq(target_os(), ~"macos") { ret ~"__DATA,__note.rustc"; }
|
||||||
if istr::eq(target_os(), ~"win32") { ret ~".note.rustc"; }
|
if str::eq(target_os(), ~"win32") { ret ~".note.rustc"; }
|
||||||
ret ~".note.rustc";
|
ret ~".note.rustc";
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_data_layout() -> istr {
|
fn get_data_layout() -> istr {
|
||||||
if istr::eq(target_os(), ~"macos") {
|
if str::eq(target_os(), ~"macos") {
|
||||||
ret ~"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" +
|
ret ~"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" +
|
||||||
~"-i32:32:32-i64:32:64" +
|
~"-i32:32:32-i64:32:64" +
|
||||||
~"-f32:32:32-f64:32:64-v64:64:64" +
|
~"-f32:32:32-f64:32:64-v64:64:64" +
|
||||||
~"-v128:128:128-a0:0:64-f80:128:128" +
|
~"-v128:128:128-a0:0:64-f80:128:128" +
|
||||||
~"-n8:16:32";
|
~"-n8:16:32";
|
||||||
}
|
}
|
||||||
if istr::eq(target_os(), ~"win32") {
|
if str::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: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";
|
ret ~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32";
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_target_triple() -> istr {
|
fn get_target_triple() -> istr {
|
||||||
if istr::eq(target_os(), ~"macos") { ret ~"i686-apple-darwin"; }
|
if str::eq(target_os(), ~"macos") { ret ~"i686-apple-darwin"; }
|
||||||
if istr::eq(target_os(), ~"win32") { ret ~"i686-pc-mingw32"; }
|
if str::eq(target_os(), ~"win32") { ret ~"i686-pc-mingw32"; }
|
||||||
ret ~"i686-unknown-linux-gnu";
|
ret ~"i686-unknown-linux-gnu";
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
|
@ -26,7 +26,7 @@ import std::map::mk_hashmap;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::option::some;
|
import std::option::some;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::io;
|
import std::io;
|
||||||
|
@ -107,7 +107,7 @@ fn parse_input_src(sess: session::session, cfg: &ast::crate_cfg,
|
||||||
if infile != ~"-" {
|
if infile != ~"-" {
|
||||||
io::file_reader(infile)
|
io::file_reader(infile)
|
||||||
} else { io::stdin() }.read_whole_stream();
|
} else { io::stdin() }.read_whole_stream();
|
||||||
let src = istr::unsafe_from_bytes(srcbytes);
|
let src = str::unsafe_from_bytes(srcbytes);
|
||||||
let crate =
|
let crate =
|
||||||
parser::parse_crate_from_source_str(
|
parser::parse_crate_from_source_str(
|
||||||
infile,
|
infile,
|
||||||
|
@ -260,7 +260,7 @@ fn version(argv0: &istr) {
|
||||||
// FIXME: Restore after istr conversion
|
// FIXME: Restore after istr conversion
|
||||||
//let env_vers = #env["CFG_VERSION"];
|
//let env_vers = #env["CFG_VERSION"];
|
||||||
let env_vers = ~"FIXME";
|
let env_vers = ~"FIXME";
|
||||||
if istr::byte_len(env_vers) != 0u { vers = env_vers; }
|
if str::byte_len(env_vers) != 0u { vers = env_vers; }
|
||||||
io::stdout().write_str(
|
io::stdout().write_str(
|
||||||
#ifmt["%s %s\n",
|
#ifmt["%s %s\n",
|
||||||
argv0,
|
argv0,
|
||||||
|
@ -307,40 +307,40 @@ options:
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_os(triple: &istr) -> session::os {
|
fn get_os(triple: &istr) -> session::os {
|
||||||
ret if istr::find(triple, ~"win32") >= 0 ||
|
ret if str::find(triple, ~"win32") >= 0 ||
|
||||||
istr::find(triple, ~"mingw32") >= 0 {
|
str::find(triple, ~"mingw32") >= 0 {
|
||||||
session::os_win32
|
session::os_win32
|
||||||
} else if istr::find(triple, ~"darwin") >= 0 {
|
} else if str::find(triple, ~"darwin") >= 0 {
|
||||||
session::os_macos
|
session::os_macos
|
||||||
} else if istr::find(triple, ~"linux") >= 0 {
|
} else if str::find(triple, ~"linux") >= 0 {
|
||||||
session::os_linux
|
session::os_linux
|
||||||
} else { log_err ~"Unknown operating system!"; fail };
|
} else { log_err ~"Unknown operating system!"; fail };
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_arch(triple: &istr) -> session::arch {
|
fn get_arch(triple: &istr) -> session::arch {
|
||||||
ret if istr::find(triple, ~"i386") >= 0 ||
|
ret if str::find(triple, ~"i386") >= 0 ||
|
||||||
istr::find(triple, ~"i486") >= 0 ||
|
str::find(triple, ~"i486") >= 0 ||
|
||||||
istr::find(triple, ~"i586") >= 0 ||
|
str::find(triple, ~"i586") >= 0 ||
|
||||||
istr::find(triple, ~"i686") >= 0 ||
|
str::find(triple, ~"i686") >= 0 ||
|
||||||
istr::find(triple, ~"i786") >= 0 {
|
str::find(triple, ~"i786") >= 0 {
|
||||||
session::arch_x86
|
session::arch_x86
|
||||||
} else if istr::find(triple, ~"x86_64") >= 0 {
|
} else if str::find(triple, ~"x86_64") >= 0 {
|
||||||
session::arch_x64
|
session::arch_x64
|
||||||
} else if istr::find(triple, ~"arm") >= 0 ||
|
} else if str::find(triple, ~"arm") >= 0 ||
|
||||||
istr::find(triple, ~"xscale") >= 0 {
|
str::find(triple, ~"xscale") >= 0 {
|
||||||
session::arch_arm
|
session::arch_arm
|
||||||
} else { log_err ~"Unknown architecture! " + triple; fail };
|
} else { log_err ~"Unknown architecture! " + triple; fail };
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_default_sysroot(binary: &istr) -> istr {
|
fn get_default_sysroot(binary: &istr) -> istr {
|
||||||
let dirname = fs::dirname(binary);
|
let dirname = fs::dirname(binary);
|
||||||
if istr::eq(dirname, binary) { ret ~"."; }
|
if str::eq(dirname, binary) { ret ~"."; }
|
||||||
ret dirname;
|
ret dirname;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_target_config() -> @session::config {
|
fn build_target_config() -> @session::config {
|
||||||
let triple: istr =
|
let triple: istr =
|
||||||
istr::str_from_cstr(llvm::llvm::LLVMRustGetHostTriple());
|
str::str_from_cstr(llvm::llvm::LLVMRustGetHostTriple());
|
||||||
let target_cfg: @session::config =
|
let target_cfg: @session::config =
|
||||||
@{os: get_os(triple),
|
@{os: get_os(triple),
|
||||||
arch: get_arch(triple),
|
arch: get_arch(triple),
|
||||||
|
@ -442,13 +442,13 @@ fn build_session(sopts: @session::options) -> session::session {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_pretty(sess: session::session, name: &istr) -> pp_mode {
|
fn parse_pretty(sess: session::session, name: &istr) -> pp_mode {
|
||||||
if istr::eq(name, ~"normal") {
|
if str::eq(name, ~"normal") {
|
||||||
ret ppm_normal;
|
ret ppm_normal;
|
||||||
} else if istr::eq(name, ~"expanded") {
|
} else if str::eq(name, ~"expanded") {
|
||||||
ret ppm_expanded;
|
ret ppm_expanded;
|
||||||
} else if istr::eq(name, ~"typed") {
|
} else if str::eq(name, ~"typed") {
|
||||||
ret ppm_typed;
|
ret ppm_typed;
|
||||||
} else if istr::eq(name, ~"identified") { ret ppm_identified; }
|
} else if str::eq(name, ~"identified") { ret ppm_identified; }
|
||||||
sess.fatal(~"argument to `pretty` must be one of `normal`, `typed`, or "
|
sess.fatal(~"argument to `pretty` must be one of `normal`, `typed`, or "
|
||||||
+ ~"`identified`");
|
+ ~"`identified`");
|
||||||
}
|
}
|
||||||
|
@ -533,10 +533,10 @@ fn main(args: [istr]) {
|
||||||
// We want to toss everything after the final '.'
|
// We want to toss everything after the final '.'
|
||||||
let parts =
|
let parts =
|
||||||
if !input_is_stdin(ifile) {
|
if !input_is_stdin(ifile) {
|
||||||
istr::split(ifile, '.' as u8)
|
str::split(ifile, '.' as u8)
|
||||||
} else { [~"default", ~"rs"] };
|
} else { [~"default", ~"rs"] };
|
||||||
vec::pop(parts);
|
vec::pop(parts);
|
||||||
saved_out_filename = istr::connect(parts, ~".");
|
saved_out_filename = str::connect(parts, ~".");
|
||||||
let suffix =
|
let suffix =
|
||||||
alt sopts.output_type {
|
alt sopts.output_type {
|
||||||
link::output_type_none. { ~"none" }
|
link::output_type_none. { ~"none" }
|
||||||
|
@ -591,15 +591,15 @@ fn main(args: [istr]) {
|
||||||
bind fn (config: @session::config, filename: &istr) -> istr {
|
bind fn (config: @session::config, filename: &istr) -> istr {
|
||||||
if config.os == session::os_macos ||
|
if config.os == session::os_macos ||
|
||||||
config.os == session::os_linux &&
|
config.os == session::os_linux &&
|
||||||
istr::find(filename, ~"lib") == 0 {
|
str::find(filename, ~"lib") == 0 {
|
||||||
ret istr::slice(filename, 3u,
|
ret str::slice(filename, 3u,
|
||||||
istr::byte_len(filename));
|
str::byte_len(filename));
|
||||||
} else { ret filename; }
|
} else { ret filename; }
|
||||||
}(config, _);
|
}(config, _);
|
||||||
fn rmext(filename: &istr) -> istr {
|
fn rmext(filename: &istr) -> istr {
|
||||||
let parts = istr::split(filename, '.' as u8);
|
let parts = str::split(filename, '.' as u8);
|
||||||
vec::pop(parts);
|
vec::pop(parts);
|
||||||
ret istr::connect(parts, ~".");
|
ret str::connect(parts, ~".");
|
||||||
}
|
}
|
||||||
ret alt config.os {
|
ret alt config.os {
|
||||||
session::os_macos. { rmext(rmlib(filename)) }
|
session::os_macos. { rmext(rmlib(filename)) }
|
||||||
|
@ -610,7 +610,7 @@ fn main(args: [istr]) {
|
||||||
|
|
||||||
let cstore = sess.get_cstore();
|
let cstore = sess.get_cstore();
|
||||||
for cratepath: istr in cstore::get_used_crate_files(cstore) {
|
for cratepath: istr in cstore::get_used_crate_files(cstore) {
|
||||||
if istr::ends_with(cratepath, ~".rlib") {
|
if str::ends_with(cratepath, ~".rlib") {
|
||||||
gcc_args += [cratepath];
|
gcc_args += [cratepath];
|
||||||
cont;
|
cont;
|
||||||
}
|
}
|
||||||
|
@ -641,7 +641,7 @@ fn main(args: [istr]) {
|
||||||
#ifmt["linking with gcc failed with code %d", err_code]);
|
#ifmt["linking with gcc failed with code %d", err_code]);
|
||||||
sess.note(
|
sess.note(
|
||||||
#ifmt["gcc arguments: %s",
|
#ifmt["gcc arguments: %s",
|
||||||
istr::connect(gcc_args, ~" ")]);
|
str::connect(gcc_args, ~" ")]);
|
||||||
sess.abort_if_errors();
|
sess.abort_if_errors();
|
||||||
}
|
}
|
||||||
// Clean up on Darwin
|
// Clean up on Darwin
|
||||||
|
|
|
@ -9,7 +9,7 @@ import std::map;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::option::some;
|
import std::option::some;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import syntax::parse::parser::parse_sess;
|
import syntax::parse::parser::parse_sess;
|
||||||
|
|
||||||
tag os { os_win32; os_macos; os_linux; }
|
tag os { os_win32; os_macos; os_linux; }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Functions dealing with attributes and meta_items
|
// Functions dealing with attributes and meta_items
|
||||||
|
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::map;
|
import std::map;
|
||||||
import std::option;
|
import std::option;
|
||||||
import syntax::ast;
|
import syntax::ast;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import syntax::ast;
|
import syntax::ast;
|
||||||
import syntax::ast_util;
|
import syntax::ast_util;
|
||||||
import syntax::ast_util::*;
|
import syntax::ast_util::*;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::istr::sbuf;
|
import std::str::sbuf;
|
||||||
|
|
||||||
import llvm::ModuleRef;
|
import llvm::ModuleRef;
|
||||||
import llvm::ContextRef;
|
import llvm::ContextRef;
|
||||||
|
@ -1070,7 +1070,7 @@ resource target_data_res(TD: TargetDataRef) {
|
||||||
type target_data = {lltd: TargetDataRef, dtor: @target_data_res};
|
type target_data = {lltd: TargetDataRef, dtor: @target_data_res};
|
||||||
|
|
||||||
fn mk_target_data(string_rep: &istr) -> target_data {
|
fn mk_target_data(string_rep: &istr) -> target_data {
|
||||||
let lltd = istr::as_buf(string_rep, { |buf|
|
let lltd = str::as_buf(string_rep, { |buf|
|
||||||
llvm::LLVMCreateTargetData(buf)
|
llvm::LLVMCreateTargetData(buf)
|
||||||
});
|
});
|
||||||
ret {lltd: lltd, dtor: @target_data_res(lltd)};
|
ret {lltd: lltd, dtor: @target_data_res(lltd)};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// EBML tag definitions and utils shared by the encoder and decoder
|
// EBML tag definitions and utils shared by the encoder and decoder
|
||||||
|
|
||||||
import std::istr;
|
import std::str;
|
||||||
|
|
||||||
const tag_paths: uint = 0x01u;
|
const tag_paths: uint = 0x01u;
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ fn hash_node_id(node_id: &int) -> uint { ret 177573u ^ (node_id as uint); }
|
||||||
|
|
||||||
fn hash_path(s: &istr) -> uint {
|
fn hash_path(s: &istr) -> uint {
|
||||||
let h = 5381u;
|
let h = 5381u;
|
||||||
for ch: u8 in istr::bytes(s) { h = (h << 5u) + h ^ (ch as uint); }
|
for ch: u8 in str::bytes(s) { h = (h << 5u) + h ^ (ch as uint); }
|
||||||
ret h;
|
ret h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import syntax::codemap::span;
|
||||||
import back::x86;
|
import back::x86;
|
||||||
import util::common;
|
import util::common;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::fs;
|
import std::fs;
|
||||||
import std::io;
|
import std::io;
|
||||||
import std::option;
|
import std::option;
|
||||||
|
@ -173,7 +173,7 @@ fn find_library_crate_aux(nn: &{prefix: istr, suffix: istr},
|
||||||
for path: istr in fs::list_dir(library_search_path) {
|
for path: istr in fs::list_dir(library_search_path) {
|
||||||
log #ifmt["searching %s", path];
|
log #ifmt["searching %s", path];
|
||||||
let f: istr = fs::basename(path);
|
let f: istr = fs::basename(path);
|
||||||
if !(istr::starts_with(f, prefix) && istr::ends_with(f, suffix))
|
if !(str::starts_with(f, prefix) && str::ends_with(f, suffix))
|
||||||
{
|
{
|
||||||
log #ifmt["skipping %s, doesn't look like %s*%s",
|
log #ifmt["skipping %s, doesn't look like %s*%s",
|
||||||
path,
|
path,
|
||||||
|
@ -200,7 +200,7 @@ fn find_library_crate_aux(nn: &{prefix: istr, suffix: istr},
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_metadata_section(filename: &istr) -> option::t<@[u8]> {
|
fn get_metadata_section(filename: &istr) -> option::t<@[u8]> {
|
||||||
let mb = istr::as_buf(filename, { |buf|
|
let mb = str::as_buf(filename, { |buf|
|
||||||
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
|
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
|
||||||
});
|
});
|
||||||
if mb as int == 0 { ret option::none::<@[u8]>; }
|
if mb as int == 0 { ret option::none::<@[u8]>; }
|
||||||
|
@ -208,8 +208,8 @@ fn get_metadata_section(filename: &istr) -> option::t<@[u8]> {
|
||||||
let si = mk_section_iter(of.llof);
|
let si = mk_section_iter(of.llof);
|
||||||
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
|
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
|
||||||
let name_buf = llvm::LLVMGetSectionName(si.llsi);
|
let name_buf = llvm::LLVMGetSectionName(si.llsi);
|
||||||
let name = istr::str_from_cstr(name_buf);
|
let name = str::str_from_cstr(name_buf);
|
||||||
if istr::eq(name, x86::get_meta_sect_name()) {
|
if str::eq(name, x86::get_meta_sect_name()) {
|
||||||
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
|
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
|
||||||
let csz = llvm::LLVMGetSectionSize(si.llsi);
|
let csz = llvm::LLVMGetSectionSize(si.llsi);
|
||||||
let cvbuf: *u8 = std::unsafe::reinterpret_cast(cbuf);
|
let cvbuf: *u8 = std::unsafe::reinterpret_cast(cbuf);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::map;
|
import std::map;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import syntax::ast;
|
import syntax::ast;
|
||||||
|
|
||||||
export cstore;
|
export cstore;
|
||||||
|
@ -106,7 +106,7 @@ fn get_used_libraries(cstore: &cstore) -> [istr] {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_used_link_args(cstore: &cstore, args: &istr) {
|
fn add_used_link_args(cstore: &cstore, args: &istr) {
|
||||||
p(cstore).used_link_args += istr::split(args, ' ' as u8);
|
p(cstore).used_link_args += str::split(args, ' ' as u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_used_link_args(cstore: &cstore) -> [istr] {
|
fn get_used_link_args(cstore: &cstore) -> [istr] {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import std::ebml;
|
import std::ebml;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::io;
|
import std::io;
|
||||||
import std::map::hashmap;
|
import std::map::hashmap;
|
||||||
import syntax::ast;
|
import syntax::ast;
|
||||||
|
@ -85,7 +85,7 @@ fn item_family(item: &ebml::doc) -> u8 {
|
||||||
|
|
||||||
fn item_symbol(item: &ebml::doc) -> istr {
|
fn item_symbol(item: &ebml::doc) -> istr {
|
||||||
let sym = ebml::get_doc(item, tag_items_data_item_symbol);
|
let sym = ebml::get_doc(item, tag_items_data_item_symbol);
|
||||||
ret istr::unsafe_from_bytes(ebml::doc_data(sym));
|
ret str::unsafe_from_bytes(ebml::doc_data(sym));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn variant_tag_id(d: &ebml::doc) -> ast::def_id {
|
fn variant_tag_id(d: &ebml::doc) -> ast::def_id {
|
||||||
|
@ -98,7 +98,7 @@ fn item_type(item: &ebml::doc, this_cnum: ast::crate_num, tcx: ty::ctxt,
|
||||||
fn parse_external_def_id(this_cnum: ast::crate_num,
|
fn parse_external_def_id(this_cnum: ast::crate_num,
|
||||||
extres: &external_resolver, s: &istr) ->
|
extres: &external_resolver, s: &istr) ->
|
||||||
ast::def_id {
|
ast::def_id {
|
||||||
let buf = istr::bytes(s);
|
let buf = str::bytes(s);
|
||||||
let external_def_id = parse_def_id(buf);
|
let external_def_id = parse_def_id(buf);
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,9 +150,9 @@ fn tag_variant_ids(item: &ebml::doc, this_cnum: ast::crate_num) ->
|
||||||
// definition the path refers to.
|
// definition the path refers to.
|
||||||
fn resolve_path(path: &[ast::ident], data: @[u8]) -> [ast::def_id] {
|
fn resolve_path(path: &[ast::ident], data: @[u8]) -> [ast::def_id] {
|
||||||
fn eq_item(data: &[u8], s: &istr) -> bool {
|
fn eq_item(data: &[u8], s: &istr) -> bool {
|
||||||
ret istr::eq(istr::unsafe_from_bytes(data), s);
|
ret str::eq(str::unsafe_from_bytes(data), s);
|
||||||
}
|
}
|
||||||
let s = istr::connect(path, ~"::");
|
let s = str::connect(path, ~"::");
|
||||||
let md = ebml::new_doc(data);
|
let md = ebml::new_doc(data);
|
||||||
let paths = ebml::get_doc(md, tag_paths);
|
let paths = ebml::get_doc(md, tag_paths);
|
||||||
let eqer = bind eq_item(_, s);
|
let eqer = bind eq_item(_, s);
|
||||||
|
@ -272,7 +272,7 @@ fn read_path(d: &ebml::doc) -> {path: istr, pos: uint} {
|
||||||
let desc = ebml::doc_data(d);
|
let desc = ebml::doc_data(d);
|
||||||
let pos = ebml::be_uint_from_bytes(@desc, 0u, 4u);
|
let pos = ebml::be_uint_from_bytes(@desc, 0u, 4u);
|
||||||
let pathbytes = vec::slice::<u8>(desc, 4u, vec::len::<u8>(desc));
|
let pathbytes = vec::slice::<u8>(desc, 4u, vec::len::<u8>(desc));
|
||||||
let path = istr::unsafe_from_bytes(pathbytes);
|
let path = str::unsafe_from_bytes(pathbytes);
|
||||||
ret {path: path, pos: pos};
|
ret {path: path, pos: pos};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,15 +301,15 @@ fn get_meta_items(md: &ebml::doc) -> [@ast::meta_item] {
|
||||||
for each meta_item_doc: ebml::doc in
|
for each meta_item_doc: ebml::doc in
|
||||||
ebml::tagged_docs(md, tag_meta_item_word) {
|
ebml::tagged_docs(md, tag_meta_item_word) {
|
||||||
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
|
||||||
let n = istr::unsafe_from_bytes(ebml::doc_data(nd));
|
let n = str::unsafe_from_bytes(ebml::doc_data(nd));
|
||||||
items += [attr::mk_word_item(n)];
|
items += [attr::mk_word_item(n)];
|
||||||
}
|
}
|
||||||
for each meta_item_doc: ebml::doc in
|
for each meta_item_doc: ebml::doc in
|
||||||
ebml::tagged_docs(md, tag_meta_item_name_value) {
|
ebml::tagged_docs(md, tag_meta_item_name_value) {
|
||||||
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
|
||||||
let vd = ebml::get_doc(meta_item_doc, tag_meta_item_value);
|
let vd = ebml::get_doc(meta_item_doc, tag_meta_item_value);
|
||||||
let n = istr::unsafe_from_bytes(ebml::doc_data(nd));
|
let n = str::unsafe_from_bytes(ebml::doc_data(nd));
|
||||||
let v = istr::unsafe_from_bytes(ebml::doc_data(vd));
|
let v = str::unsafe_from_bytes(ebml::doc_data(vd));
|
||||||
// FIXME (#611): Should be able to decode meta_name_value variants,
|
// FIXME (#611): Should be able to decode meta_name_value variants,
|
||||||
// but currently they can't be encoded
|
// but currently they can't be encoded
|
||||||
items += [attr::mk_name_value_item_str(n, v)];
|
items += [attr::mk_name_value_item_str(n, v)];
|
||||||
|
@ -317,7 +317,7 @@ fn get_meta_items(md: &ebml::doc) -> [@ast::meta_item] {
|
||||||
for each meta_item_doc: ebml::doc in
|
for each meta_item_doc: ebml::doc in
|
||||||
ebml::tagged_docs(md, tag_meta_item_list) {
|
ebml::tagged_docs(md, tag_meta_item_list) {
|
||||||
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
|
||||||
let n = istr::unsafe_from_bytes(ebml::doc_data(nd));
|
let n = str::unsafe_from_bytes(ebml::doc_data(nd));
|
||||||
let subitems = get_meta_items(meta_item_doc);
|
let subitems = get_meta_items(meta_item_doc);
|
||||||
items += [attr::mk_list_item(n, subitems)];
|
items += [attr::mk_list_item(n, subitems)];
|
||||||
}
|
}
|
||||||
|
@ -377,7 +377,7 @@ fn get_crate_deps(data: @[u8]) -> [crate_dep] {
|
||||||
let depsdoc = ebml::get_doc(cratedoc, tag_crate_deps);
|
let depsdoc = ebml::get_doc(cratedoc, tag_crate_deps);
|
||||||
let crate_num = 1;
|
let crate_num = 1;
|
||||||
for each depdoc: ebml::doc in ebml::tagged_docs(depsdoc, tag_crate_dep) {
|
for each depdoc: ebml::doc in ebml::tagged_docs(depsdoc, tag_crate_dep) {
|
||||||
let depname = istr::unsafe_from_bytes(ebml::doc_data(depdoc));
|
let depname = str::unsafe_from_bytes(ebml::doc_data(depdoc));
|
||||||
deps += [{cnum: crate_num, ident: depname}];
|
deps += [{cnum: crate_num, ident: depname}];
|
||||||
crate_num += 1;
|
crate_num += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Metadata encoding
|
// Metadata encoding
|
||||||
|
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::io;
|
import std::io;
|
||||||
import std::option;
|
import std::option;
|
||||||
|
@ -28,13 +28,13 @@ type encode_ctxt = {ccx: @crate_ctxt, type_abbrevs: abbrev_map};
|
||||||
// Path table encoding
|
// Path table encoding
|
||||||
fn encode_name(ebml_w: &ebml::writer, name: &istr) {
|
fn encode_name(ebml_w: &ebml::writer, name: &istr) {
|
||||||
ebml::start_tag(ebml_w, tag_paths_data_name);
|
ebml::start_tag(ebml_w, tag_paths_data_name);
|
||||||
ebml_w.writer.write(istr::bytes(name));
|
ebml_w.writer.write(str::bytes(name));
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_def_id(ebml_w: &ebml::writer, id: &def_id) {
|
fn encode_def_id(ebml_w: &ebml::writer, id: &def_id) {
|
||||||
ebml::start_tag(ebml_w, tag_def_id);
|
ebml::start_tag(ebml_w, tag_def_id);
|
||||||
ebml_w.writer.write(istr::bytes(def_to_str(id)));
|
ebml_w.writer.write(str::bytes(def_to_str(id)));
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ fn add_to_index(ebml_w: &ebml::writer, path: &[istr],
|
||||||
index: &mutable [entry<istr>], name: &istr) {
|
index: &mutable [entry<istr>], name: &istr) {
|
||||||
let full_path = path + [name];
|
let full_path = path + [name];
|
||||||
index +=
|
index +=
|
||||||
[{val: istr::connect(full_path, ~"::"), pos: ebml_w.writer.tell()}];
|
[{val: str::connect(full_path, ~"::"), pos: ebml_w.writer.tell()}];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_native_module_item_paths(ebml_w: &ebml::writer, nmod: &native_mod,
|
fn encode_native_module_item_paths(ebml_w: &ebml::writer, nmod: &native_mod,
|
||||||
|
@ -197,7 +197,7 @@ fn encode_type_param_kinds(ebml_w: &ebml::writer, tps: &[ty_param]) {
|
||||||
|
|
||||||
fn encode_variant_id(ebml_w: &ebml::writer, vid: &def_id) {
|
fn encode_variant_id(ebml_w: &ebml::writer, vid: &def_id) {
|
||||||
ebml::start_tag(ebml_w, tag_items_data_item_variant);
|
ebml::start_tag(ebml_w, tag_items_data_item_variant);
|
||||||
ebml_w.writer.write(istr::bytes(def_to_str(vid)));
|
ebml_w.writer.write(str::bytes(def_to_str(vid)));
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,20 +214,20 @@ fn encode_type(ecx: &@encode_ctxt, ebml_w: &ebml::writer, typ: ty::t) {
|
||||||
|
|
||||||
fn encode_symbol(ecx: &@encode_ctxt, ebml_w: &ebml::writer, id: node_id) {
|
fn encode_symbol(ecx: &@encode_ctxt, ebml_w: &ebml::writer, id: node_id) {
|
||||||
ebml::start_tag(ebml_w, tag_items_data_item_symbol);
|
ebml::start_tag(ebml_w, tag_items_data_item_symbol);
|
||||||
ebml_w.writer.write(istr::bytes(ecx.ccx.item_symbols.get(id)));
|
ebml_w.writer.write(str::bytes(ecx.ccx.item_symbols.get(id)));
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_discriminant(ecx: &@encode_ctxt, ebml_w: &ebml::writer,
|
fn encode_discriminant(ecx: &@encode_ctxt, ebml_w: &ebml::writer,
|
||||||
id: node_id) {
|
id: node_id) {
|
||||||
ebml::start_tag(ebml_w, tag_items_data_item_symbol);
|
ebml::start_tag(ebml_w, tag_items_data_item_symbol);
|
||||||
ebml_w.writer.write(istr::bytes(ecx.ccx.discrim_symbols.get(id)));
|
ebml_w.writer.write(str::bytes(ecx.ccx.discrim_symbols.get(id)));
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_tag_id(ebml_w: &ebml::writer, id: &def_id) {
|
fn encode_tag_id(ebml_w: &ebml::writer, id: &def_id) {
|
||||||
ebml::start_tag(ebml_w, tag_items_data_item_tag_id);
|
ebml::start_tag(ebml_w, tag_items_data_item_tag_id);
|
||||||
ebml_w.writer.write(istr::bytes(def_to_str(id)));
|
ebml_w.writer.write(str::bytes(def_to_str(id)));
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,7 +454,7 @@ fn encode_meta_item(ebml_w: &ebml::writer, mi: &meta_item) {
|
||||||
meta_word(name) {
|
meta_word(name) {
|
||||||
ebml::start_tag(ebml_w, tag_meta_item_word);
|
ebml::start_tag(ebml_w, tag_meta_item_word);
|
||||||
ebml::start_tag(ebml_w, tag_meta_item_name);
|
ebml::start_tag(ebml_w, tag_meta_item_name);
|
||||||
ebml_w.writer.write(istr::bytes(name));
|
ebml_w.writer.write(str::bytes(name));
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
}
|
}
|
||||||
|
@ -463,10 +463,10 @@ fn encode_meta_item(ebml_w: &ebml::writer, mi: &meta_item) {
|
||||||
lit_str(value, _) {
|
lit_str(value, _) {
|
||||||
ebml::start_tag(ebml_w, tag_meta_item_name_value);
|
ebml::start_tag(ebml_w, tag_meta_item_name_value);
|
||||||
ebml::start_tag(ebml_w, tag_meta_item_name);
|
ebml::start_tag(ebml_w, tag_meta_item_name);
|
||||||
ebml_w.writer.write(istr::bytes(name));
|
ebml_w.writer.write(str::bytes(name));
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
ebml::start_tag(ebml_w, tag_meta_item_value);
|
ebml::start_tag(ebml_w, tag_meta_item_value);
|
||||||
ebml_w.writer.write(istr::bytes(value));
|
ebml_w.writer.write(str::bytes(value));
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
}
|
}
|
||||||
|
@ -476,7 +476,7 @@ fn encode_meta_item(ebml_w: &ebml::writer, mi: &meta_item) {
|
||||||
meta_list(name, items) {
|
meta_list(name, items) {
|
||||||
ebml::start_tag(ebml_w, tag_meta_item_list);
|
ebml::start_tag(ebml_w, tag_meta_item_list);
|
||||||
ebml::start_tag(ebml_w, tag_meta_item_name);
|
ebml::start_tag(ebml_w, tag_meta_item_name);
|
||||||
ebml_w.writer.write(istr::bytes(name));
|
ebml_w.writer.write(str::bytes(name));
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
for inner_item: @meta_item in items {
|
for inner_item: @meta_item in items {
|
||||||
encode_meta_item(ebml_w, *inner_item);
|
encode_meta_item(ebml_w, *inner_item);
|
||||||
|
@ -588,7 +588,7 @@ fn encode_crate_deps(ebml_w: &ebml::writer, cstore: &cstore::cstore) {
|
||||||
ebml::start_tag(ebml_w, tag_crate_deps);
|
ebml::start_tag(ebml_w, tag_crate_deps);
|
||||||
for cname: istr in get_ordered_names(cstore) {
|
for cname: istr in get_ordered_names(cstore) {
|
||||||
ebml::start_tag(ebml_w, tag_crate_dep);
|
ebml::start_tag(ebml_w, tag_crate_dep);
|
||||||
ebml_w.writer.write(istr::bytes(cname));
|
ebml_w.writer.write(str::bytes(cname));
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
}
|
}
|
||||||
ebml::end_tag(ebml_w);
|
ebml::end_tag(ebml_w);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Type decoding
|
// Type decoding
|
||||||
|
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
|
@ -44,7 +44,7 @@ fn parse_ident_(st: @pstate, _sd: str_def, is_last: fn(char) -> bool) ->
|
||||||
ast::ident {
|
ast::ident {
|
||||||
let rslt = ~"";
|
let rslt = ~"";
|
||||||
while !is_last(peek(st) as char) {
|
while !is_last(peek(st) as char) {
|
||||||
rslt += istr::unsafe_from_byte(next(st));
|
rslt += str::unsafe_from_byte(next(st));
|
||||||
}
|
}
|
||||||
ret rslt;
|
ret rslt;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t {
|
||||||
while peek(st) as char != ']' {
|
while peek(st) as char != ']' {
|
||||||
let name = ~"";
|
let name = ~"";
|
||||||
while peek(st) as char != '=' {
|
while peek(st) as char != '=' {
|
||||||
name += istr::unsafe_from_byte(next(st));
|
name += str::unsafe_from_byte(next(st));
|
||||||
}
|
}
|
||||||
st.pos = st.pos + 1u;
|
st.pos = st.pos + 1u;
|
||||||
fields += [{ident: name, mt: parse_mt(st, sd)}];
|
fields += [{ident: name, mt: parse_mt(st, sd)}];
|
||||||
|
@ -280,7 +280,7 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t {
|
||||||
}
|
}
|
||||||
let name = ~"";
|
let name = ~"";
|
||||||
while peek(st) as char != '[' {
|
while peek(st) as char != '[' {
|
||||||
name += istr::unsafe_from_byte(next(st));
|
name += str::unsafe_from_byte(next(st));
|
||||||
}
|
}
|
||||||
let func = parse_ty_fn(st, sd);
|
let func = parse_ty_fn(st, sd);
|
||||||
methods +=
|
methods +=
|
||||||
|
@ -345,7 +345,7 @@ fn parse_mt(st: @pstate, sd: str_def) -> ty::mt {
|
||||||
fn parse_def(st: @pstate, sd: str_def) -> ast::def_id {
|
fn parse_def(st: @pstate, sd: str_def) -> ast::def_id {
|
||||||
let def = ~"";
|
let def = ~"";
|
||||||
while peek(st) as char != '|' {
|
while peek(st) as char != '|' {
|
||||||
def += istr::unsafe_from_byte(next(st));
|
def += str::unsafe_from_byte(next(st));
|
||||||
}
|
}
|
||||||
st.pos = st.pos + 1u;
|
st.pos = st.pos + 1u;
|
||||||
ret sd(def);
|
ret sd(def);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Type encoding
|
// Type encoding
|
||||||
|
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::io;
|
import std::io;
|
||||||
import std::map::hashmap;
|
import std::map::hashmap;
|
||||||
import std::option::some;
|
import std::option::some;
|
||||||
|
|
|
@ -10,7 +10,7 @@ import syntax::codemap::span;
|
||||||
import syntax::visit;
|
import syntax::visit;
|
||||||
import visit::vt;
|
import visit::vt;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::option::some;
|
import std::option::some;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import std::map;
|
||||||
import std::map::*;
|
import std::map::*;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::option::*;
|
import std::option::*;
|
||||||
import syntax::ast;
|
import syntax::ast;
|
||||||
import syntax::ast_util;
|
import syntax::ast_util;
|
||||||
|
|
|
@ -10,7 +10,7 @@ import middle::ty;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
import std::option::some;
|
import std::option::some;
|
||||||
import std::ptr;
|
import std::ptr;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::unsafe;
|
import std::unsafe;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ type ctxt = @{mutable next_tydesc_num: uint};
|
||||||
fn mk_ctxt() -> ctxt { ret @{mutable next_tydesc_num: 0u}; }
|
fn mk_ctxt() -> ctxt { ret @{mutable next_tydesc_num: 0u}; }
|
||||||
|
|
||||||
fn add_global(ccx: &@crate_ctxt, llval: ValueRef, name: &istr) -> ValueRef {
|
fn add_global(ccx: &@crate_ctxt, llval: ValueRef, name: &istr) -> ValueRef {
|
||||||
let llglobal = istr::as_buf(name, { |buf|
|
let llglobal = str::as_buf(name, { |buf|
|
||||||
lll::LLVMAddGlobal(ccx.llmod, val_ty(llval), buf)
|
lll::LLVMAddGlobal(ccx.llmod, val_ty(llval), buf)
|
||||||
});
|
});
|
||||||
lll::LLVMSetInitializer(llglobal, llval);
|
lll::LLVMSetInitializer(llglobal, llval);
|
||||||
|
|
|
@ -77,7 +77,7 @@ import syntax::visit;
|
||||||
|
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::istr;
|
import std::str;
|
||||||
|
|
||||||
import ast::kind;
|
import ast::kind;
|
||||||
import ast::kind_unique;
|
import ast::kind_unique;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import std::{vec, istr, option};
|
import std::{vec, str, option};
|
||||||
import option::{some, none};
|
import option::{some, none};
|
||||||
import syntax::ast::*;
|
import syntax::ast::*;
|
||||||
import syntax::visit;
|
import syntax::visit;
|
||||||
|
@ -54,7 +54,7 @@ fn expr_root(tcx: &ty::ctxt, ex: @expr, autoderef: bool)
|
||||||
alt ty::struct(tcx, auto_unbox.t) {
|
alt ty::struct(tcx, auto_unbox.t) {
|
||||||
ty::ty_rec(fields) {
|
ty::ty_rec(fields) {
|
||||||
for fld: ty::field in fields {
|
for fld: ty::field in fields {
|
||||||
if istr::eq(ident, fld.ident) {
|
if str::eq(ident, fld.ident) {
|
||||||
mut = fld.mt.mut != imm;
|
mut = fld.mt.mut != imm;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import std::option;
|
||||||
import std::option::is_none;
|
import std::option::is_none;
|
||||||
import std::option::some;
|
import std::option::some;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import syntax::print::pprust::*;
|
import syntax::print::pprust::*;
|
||||||
|
|
||||||
export resolve_crate;
|
export resolve_crate;
|
||||||
|
@ -79,7 +79,7 @@ type ext_hash = hashmap<{did: def_id, ident: istr, ns: namespace}, def>;
|
||||||
fn new_ext_hash() -> ext_hash {
|
fn new_ext_hash() -> ext_hash {
|
||||||
type key = {did: def_id, ident: istr, ns: namespace};
|
type key = {did: def_id, ident: istr, ns: namespace};
|
||||||
fn hash(v: &key) -> uint {
|
fn hash(v: &key) -> uint {
|
||||||
ret istr::hash(v.ident) + util::common::hash_def(v.did) +
|
ret str::hash(v.ident) + util::common::hash_def(v.did) +
|
||||||
alt v.ns {
|
alt v.ns {
|
||||||
ns_value. { 1u }
|
ns_value. { 1u }
|
||||||
ns_type. { 2u }
|
ns_type. { 2u }
|
||||||
|
@ -88,7 +88,7 @@ fn new_ext_hash() -> ext_hash {
|
||||||
}
|
}
|
||||||
fn eq(v1: &key, v2: &key) -> bool {
|
fn eq(v1: &key, v2: &key) -> bool {
|
||||||
ret util::common::def_eq(v1.did, v2.did) &&
|
ret util::common::def_eq(v1.did, v2.did) &&
|
||||||
istr::eq(v1.ident, v2.ident) && v1.ns == v2.ns;
|
str::eq(v1.ident, v2.ident) && v1.ns == v2.ns;
|
||||||
}
|
}
|
||||||
ret std::map::mk_hashmap::<key, def>(hash, eq);
|
ret std::map::mk_hashmap::<key, def>(hash, eq);
|
||||||
}
|
}
|
||||||
|
@ -430,7 +430,7 @@ fn follow_import(e: &env, sc: &scopes, path: &[ident], sp: &span) ->
|
||||||
ast::def_mod(_) | ast::def_native_mod(_) { ret dcur; }
|
ast::def_mod(_) | ast::def_native_mod(_) { ret dcur; }
|
||||||
_ {
|
_ {
|
||||||
e.sess.span_err(sp,
|
e.sess.span_err(sp,
|
||||||
istr::connect(path, ~"::") +
|
str::connect(path, ~"::") +
|
||||||
~" does not name a module.");
|
~" does not name a module.");
|
||||||
ret none;
|
ret none;
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,7 @@ fn resolve_import(e: &env, defid: ast::def_id, name: &ast::ident,
|
||||||
let end_id = ids[n_idents - 1u];
|
let end_id = ids[n_idents - 1u];
|
||||||
// Ignore the current scope if this import would shadow itself.
|
// Ignore the current scope if this import would shadow itself.
|
||||||
let sc =
|
let sc =
|
||||||
if istr::eq(name, ids[0]) { std::list::cdr(sc_in) } else { sc_in };
|
if str::eq(name, ids[0]) { std::list::cdr(sc_in) } else { sc_in };
|
||||||
if n_idents == 1u {
|
if n_idents == 1u {
|
||||||
register(e, defid, sp, end_id, sc_in,
|
register(e, defid, sp, end_id, sc_in,
|
||||||
lookup_in_scope(e, sc, sp, end_id, ns_value),
|
lookup_in_scope(e, sc, sp, end_id, ns_value),
|
||||||
|
@ -560,7 +560,7 @@ fn unresolved_err(e: &env, sc: &scopes, sp: &span,
|
||||||
}
|
}
|
||||||
let err_scope = find_fn_or_mod_scope(sc);
|
let err_scope = find_fn_or_mod_scope(sc);
|
||||||
for rs: {ident: istr, sc: scope} in e.reported {
|
for rs: {ident: istr, sc: scope} in e.reported {
|
||||||
if istr::eq(rs.ident, name)
|
if str::eq(rs.ident, name)
|
||||||
&& err_scope == rs.sc { ret; }
|
&& err_scope == rs.sc { ret; }
|
||||||
}
|
}
|
||||||
e.reported += [{ident: name, sc: err_scope}];
|
e.reported += [{ident: name, sc: err_scope}];
|
||||||
|
@ -759,7 +759,7 @@ fn lookup_in_ty_params(name: &ident, ty_params: &[ast::ty_param]) ->
|
||||||
option::t<def> {
|
option::t<def> {
|
||||||
let i = 0u;
|
let i = 0u;
|
||||||
for tp: ast::ty_param in ty_params {
|
for tp: ast::ty_param in ty_params {
|
||||||
if istr::eq(tp.ident, name) { ret some(ast::def_ty_arg(i, tp.kind)); }
|
if str::eq(tp.ident, name) { ret some(ast::def_ty_arg(i, tp.kind)); }
|
||||||
i += 1u;
|
i += 1u;
|
||||||
}
|
}
|
||||||
ret none::<def>;
|
ret none::<def>;
|
||||||
|
@ -769,7 +769,7 @@ fn lookup_in_pat(name: &ident, pat: &@ast::pat) -> option::t<def_id> {
|
||||||
let found = none;
|
let found = none;
|
||||||
for each bound in ast_util::pat_bindings(pat) {
|
for each bound in ast_util::pat_bindings(pat) {
|
||||||
let p_name = alt bound.node { ast::pat_bind(n) { n } };
|
let p_name = alt bound.node { ast::pat_bind(n) { n } };
|
||||||
if istr::eq(p_name, name) { found = some(local_def(bound.id)); }
|
if str::eq(p_name, name) { found = some(local_def(bound.id)); }
|
||||||
}
|
}
|
||||||
ret found;
|
ret found;
|
||||||
}
|
}
|
||||||
|
@ -780,7 +780,7 @@ fn lookup_in_fn(name: &ident, decl: &ast::fn_decl,
|
||||||
alt ns {
|
alt ns {
|
||||||
ns_value. {
|
ns_value. {
|
||||||
for a: ast::arg in decl.inputs {
|
for a: ast::arg in decl.inputs {
|
||||||
if istr::eq(a.ident, name) {
|
if str::eq(a.ident, name) {
|
||||||
ret some(ast::def_arg(local_def(a.id), a.mode));
|
ret some(ast::def_arg(local_def(a.id), a.mode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -796,7 +796,7 @@ fn lookup_in_obj(name: &ident, ob: &ast::_obj, ty_params: &[ast::ty_param],
|
||||||
alt ns {
|
alt ns {
|
||||||
ns_value. {
|
ns_value. {
|
||||||
for f: ast::obj_field in ob.fields {
|
for f: ast::obj_field in ob.fields {
|
||||||
if istr::eq(f.ident, name) {
|
if str::eq(f.ident, name) {
|
||||||
ret some(ast::def_obj_field(local_def(f.id), f.mut));
|
ret some(ast::def_obj_field(local_def(f.id), f.mut));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -835,12 +835,12 @@ fn lookup_in_block(name: &ident, b: &ast::blk_, pos: uint, loc_pos: uint,
|
||||||
alt it.node {
|
alt it.node {
|
||||||
ast::item_tag(variants, _) {
|
ast::item_tag(variants, _) {
|
||||||
if ns == ns_type {
|
if ns == ns_type {
|
||||||
if istr::eq(it.ident, name) {
|
if str::eq(it.ident, name) {
|
||||||
ret some(ast::def_ty(local_def(it.id)));
|
ret some(ast::def_ty(local_def(it.id)));
|
||||||
}
|
}
|
||||||
} else if ns == ns_value {
|
} else if ns == ns_value {
|
||||||
for v: ast::variant in variants {
|
for v: ast::variant in variants {
|
||||||
if istr::eq(v.node.name, name) {
|
if str::eq(v.node.name, name) {
|
||||||
let i = v.node.id;
|
let i = v.node.id;
|
||||||
ret some(ast::def_variant(local_def(it.id),
|
ret some(ast::def_variant(local_def(it.id),
|
||||||
local_def(i)));
|
local_def(i)));
|
||||||
|
@ -849,7 +849,7 @@ fn lookup_in_block(name: &ident, b: &ast::blk_, pos: uint, loc_pos: uint,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ {
|
_ {
|
||||||
if istr::eq(it.ident, name) {
|
if str::eq(it.ident, name) {
|
||||||
let found = found_def_item(it, ns);
|
let found = found_def_item(it, ns);
|
||||||
if !is_none(found) { ret found; }
|
if !is_none(found) { ret found; }
|
||||||
}
|
}
|
||||||
|
@ -1332,7 +1332,7 @@ fn check_arm(e: &@env, a: &ast::arm, x: &(), v: &vt<()>) {
|
||||||
~"inconsistent number of bindings");
|
~"inconsistent number of bindings");
|
||||||
} else {
|
} else {
|
||||||
for name: ident in ch.seen {
|
for name: ident in ch.seen {
|
||||||
if is_none(vec::find(bind istr::eq(name, _), seen0)) {
|
if is_none(vec::find(bind str::eq(name, _), seen0)) {
|
||||||
// Fight the alias checker
|
// Fight the alias checker
|
||||||
let name_ = name;
|
let name_ = name;
|
||||||
e.sess.span_err(a.pats[i].span,
|
e.sess.span_err(a.pats[i].span,
|
||||||
|
@ -1428,7 +1428,7 @@ fn checker(e: &env, kind: &istr) -> checker {
|
||||||
|
|
||||||
fn check_name(ch: &checker, sp: &span, name: &ident) {
|
fn check_name(ch: &checker, sp: &span, name: &ident) {
|
||||||
for s: ident in ch.seen {
|
for s: ident in ch.seen {
|
||||||
if istr::eq(s, name) {
|
if str::eq(s, name) {
|
||||||
ch.sess.span_fatal(sp, ~"duplicate " + ch.kind
|
ch.sess.span_fatal(sp, ~"duplicate " + ch.kind
|
||||||
+ ~" name: " + name);
|
+ ~" name: " + name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ import std::vec;
|
||||||
import std::map::hashmap;
|
import std::map::hashmap;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
import std::option::some;
|
import std::option::some;
|
||||||
import std::istr;
|
import std::str;
|
||||||
|
|
||||||
import ty_ctxt = middle::ty::ctxt;
|
import ty_ctxt = middle::ty::ctxt;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ fn eq_res_info(a: &res_info, b: &res_info) -> bool {
|
||||||
|
|
||||||
fn mk_global(ccx: &@crate_ctxt, name: &istr, llval: ValueRef,
|
fn mk_global(ccx: &@crate_ctxt, name: &istr, llval: ValueRef,
|
||||||
internal: bool) -> ValueRef {
|
internal: bool) -> ValueRef {
|
||||||
let llglobal = istr::as_buf(name, { |buf|
|
let llglobal = str::as_buf(name, { |buf|
|
||||||
lib::llvm::llvm::LLVMAddGlobal(ccx.llmod, val_ty(llval), buf)
|
lib::llvm::llvm::LLVMAddGlobal(ccx.llmod, val_ty(llval), buf)
|
||||||
});
|
});
|
||||||
lib::llvm::llvm::LLVMSetInitializer(llglobal, llval);
|
lib::llvm::llvm::LLVMSetInitializer(llglobal, llval);
|
||||||
|
@ -248,7 +248,7 @@ fn s_float(_tcx: &ty_ctxt) -> u8 {
|
||||||
|
|
||||||
fn mk_ctxt(llmod: ModuleRef) -> ctxt {
|
fn mk_ctxt(llmod: ModuleRef) -> ctxt {
|
||||||
let llshapetablesty = trans_common::T_named_struct(~"shapes");
|
let llshapetablesty = trans_common::T_named_struct(~"shapes");
|
||||||
let llshapetables = istr::as_buf(~"shapes", { |buf|
|
let llshapetables = str::as_buf(~"shapes", { |buf|
|
||||||
lib::llvm::llvm::LLVMAddGlobal(llmod, llshapetablesty, buf)
|
lib::llvm::llvm::LLVMAddGlobal(llmod, llshapetablesty, buf)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// but many TypeRefs correspond to one ty::t; for instance, tup(int, int,
|
// but many TypeRefs correspond to one ty::t; for instance, tup(int, int,
|
||||||
// int) and rec(x=int, y=int, z=int) will have the same TypeRef.
|
// int) and rec(x=int, y=int, z=int) will have the same TypeRef.
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::map;
|
import std::map;
|
||||||
import std::map::hashmap;
|
import std::map::hashmap;
|
||||||
|
@ -301,7 +301,7 @@ fn sanitize(s: &istr) -> istr {
|
||||||
c != ' ' as u8 && c != '\t' as u8 && c != ';' as u8
|
c != ' ' as u8 && c != '\t' as u8 && c != ';' as u8
|
||||||
{
|
{
|
||||||
let v = [c];
|
let v = [c];
|
||||||
result += istr::unsafe_from_bytes(v);
|
result += str::unsafe_from_bytes(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ fn log_fn_time(ccx: &@crate_ctxt, name: &istr, start: &time::timeval,
|
||||||
|
|
||||||
fn decl_fn(llmod: ModuleRef, name: &istr, cc: uint, llty: TypeRef) ->
|
fn decl_fn(llmod: ModuleRef, name: &istr, cc: uint, llty: TypeRef) ->
|
||||||
ValueRef {
|
ValueRef {
|
||||||
let llfn: ValueRef = istr::as_buf(name, { |buf|
|
let llfn: ValueRef = str::as_buf(name, { |buf|
|
||||||
llvm::LLVMAddFunction(llmod, buf, llty)
|
llvm::LLVMAddFunction(llmod, buf, llty)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetFunctionCallConv(llfn, cc);
|
llvm::LLVMSetFunctionCallConv(llfn, cc);
|
||||||
|
@ -336,7 +336,7 @@ fn decl_cdecl_fn(llmod: ModuleRef, name: &istr, llty: TypeRef) -> ValueRef {
|
||||||
fn decl_fastcall_fn(llmod: ModuleRef, name: &istr,
|
fn decl_fastcall_fn(llmod: ModuleRef, name: &istr,
|
||||||
llty: TypeRef) -> ValueRef {
|
llty: TypeRef) -> ValueRef {
|
||||||
let llfn = decl_fn(llmod, name, lib::llvm::LLVMFastCallConv, llty);
|
let llfn = decl_fn(llmod, name, lib::llvm::LLVMFastCallConv, llty);
|
||||||
let _: () = istr::as_buf(~"rust", { |buf|
|
let _: () = str::as_buf(~"rust", { |buf|
|
||||||
llvm::LLVMSetGC(llfn, buf)
|
llvm::LLVMSetGC(llfn, buf)
|
||||||
});
|
});
|
||||||
ret llfn;
|
ret llfn;
|
||||||
|
@ -350,7 +350,7 @@ fn decl_internal_fastcall_fn(llmod: ModuleRef, name: &istr, llty: TypeRef) ->
|
||||||
let llfn = decl_fn(llmod, name, lib::llvm::LLVMFastCallConv, llty);
|
let llfn = decl_fn(llmod, name, lib::llvm::LLVMFastCallConv, llty);
|
||||||
llvm::LLVMSetLinkage(llfn,
|
llvm::LLVMSetLinkage(llfn,
|
||||||
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
|
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
|
||||||
let _: () = istr::as_buf(~"rust", { |buf|
|
let _: () = str::as_buf(~"rust", { |buf|
|
||||||
llvm::LLVMSetGC(llfn, buf)
|
llvm::LLVMSetGC(llfn, buf)
|
||||||
});
|
});
|
||||||
ret llfn;
|
ret llfn;
|
||||||
|
@ -375,7 +375,7 @@ fn get_extern_const(externs: &hashmap<istr, ValueRef>, llmod: ModuleRef,
|
||||||
if externs.contains_key(name) {
|
if externs.contains_key(name) {
|
||||||
ret externs.get(name);
|
ret externs.get(name);
|
||||||
}
|
}
|
||||||
let c = istr::as_buf(name, { |buf|
|
let c = str::as_buf(name, { |buf|
|
||||||
llvm::LLVMAddGlobal(llmod, ty, buf)
|
llvm::LLVMAddGlobal(llmod, ty, buf)
|
||||||
});
|
});
|
||||||
externs.insert(name, c);
|
externs.insert(name, c);
|
||||||
|
@ -1137,7 +1137,7 @@ fn declare_tydesc(cx: &@local_ctxt, sp: &span, t: ty::t, ty_params: &[uint])
|
||||||
name = mangle_internal_name_by_type_only(cx.ccx, t, ~"tydesc");
|
name = mangle_internal_name_by_type_only(cx.ccx, t, ~"tydesc");
|
||||||
name = sanitize(name);
|
name = sanitize(name);
|
||||||
} else { name = mangle_internal_name_by_seq(cx.ccx, ~"tydesc"); }
|
} else { name = mangle_internal_name_by_seq(cx.ccx, ~"tydesc"); }
|
||||||
let gvar = istr::as_buf(name, { |buf|
|
let gvar = str::as_buf(name, { |buf|
|
||||||
llvm::LLVMAddGlobal(ccx.llmod, ccx.tydesc_type, buf)
|
llvm::LLVMAddGlobal(ccx.llmod, ccx.tydesc_type, buf)
|
||||||
});
|
});
|
||||||
let info =
|
let info =
|
||||||
|
@ -1501,7 +1501,7 @@ fn decr_refcnt_maybe_free(cx: &@block_ctxt, box_ptr_alias: ValueRef,
|
||||||
// Structural comparison: a rather involved form of glue.
|
// Structural comparison: a rather involved form of glue.
|
||||||
fn maybe_name_value(cx: &@crate_ctxt, v: ValueRef, s: &istr) {
|
fn maybe_name_value(cx: &@crate_ctxt, v: ValueRef, s: &istr) {
|
||||||
if cx.sess.get_opts().save_temps {
|
if cx.sess.get_opts().save_temps {
|
||||||
let _: () = istr::as_buf(s, { |buf|
|
let _: () = str::as_buf(s, { |buf|
|
||||||
llvm::LLVMSetValueName(v, buf)
|
llvm::LLVMSetValueName(v, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3050,7 +3050,7 @@ fn lookup_discriminant(lcx: &@local_ctxt, vid: &ast::def_id) -> ValueRef {
|
||||||
// It's an external discriminant that we haven't seen yet.
|
// It's an external discriminant that we haven't seen yet.
|
||||||
assert (vid.crate != ast::local_crate);
|
assert (vid.crate != ast::local_crate);
|
||||||
let sym = csearch::get_symbol(lcx.ccx.sess.get_cstore(), vid);
|
let sym = csearch::get_symbol(lcx.ccx.sess.get_cstore(), vid);
|
||||||
let gvar = istr::as_buf(sym, { |buf|
|
let gvar = str::as_buf(sym, { |buf|
|
||||||
llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(), buf)
|
llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(), buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetLinkage(gvar,
|
llvm::LLVMSetLinkage(gvar,
|
||||||
|
@ -3998,7 +3998,7 @@ fn trans_rec(cx: &@block_ctxt, fields: &[ast::field],
|
||||||
bcx = dst_res.bcx;
|
bcx = dst_res.bcx;
|
||||||
let expr_provided = false;
|
let expr_provided = false;
|
||||||
for f: ast::field in fields {
|
for f: ast::field in fields {
|
||||||
if istr::eq(f.node.ident, tf.ident) {
|
if str::eq(f.node.ident, tf.ident) {
|
||||||
expr_provided = true;
|
expr_provided = true;
|
||||||
let lv = trans_lval(bcx, f.node.expr);
|
let lv = trans_lval(bcx, f.node.expr);
|
||||||
bcx = move_val_if_temp(lv.res.bcx, INIT, dst_res.val,
|
bcx = move_val_if_temp(lv.res.bcx, INIT, dst_res.val,
|
||||||
|
@ -4288,7 +4288,7 @@ fn load_if_immediate(cx: &@block_ctxt, v: ValueRef, t: ty::t) -> ValueRef {
|
||||||
|
|
||||||
fn trans_log(lvl: int, cx: &@block_ctxt, e: &@ast::expr) -> result {
|
fn trans_log(lvl: int, cx: &@block_ctxt, e: &@ast::expr) -> result {
|
||||||
let lcx = cx.fcx.lcx;
|
let lcx = cx.fcx.lcx;
|
||||||
let modname = istr::connect(lcx.module_path, ~"::");
|
let modname = str::connect(lcx.module_path, ~"::");
|
||||||
let global;
|
let global;
|
||||||
if lcx.ccx.module_data.contains_key(modname) {
|
if lcx.ccx.module_data.contains_key(modname) {
|
||||||
global = lcx.ccx.module_data.get(modname);
|
global = lcx.ccx.module_data.get(modname);
|
||||||
|
@ -4298,7 +4298,7 @@ fn trans_log(lvl: int, cx: &@block_ctxt, e: &@ast::expr) -> result {
|
||||||
lcx.ccx,
|
lcx.ccx,
|
||||||
lcx.module_path,
|
lcx.module_path,
|
||||||
~"loglevel");
|
~"loglevel");
|
||||||
global = istr::as_buf(s, { |buf|
|
global = str::as_buf(s, { |buf|
|
||||||
llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(), buf)
|
llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(), buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetGlobalConstant(global, False);
|
llvm::LLVMSetGlobalConstant(global, False);
|
||||||
|
@ -4677,7 +4677,7 @@ fn new_block_ctxt(cx: &@fn_ctxt, parent: &block_parent, kind: block_kind,
|
||||||
cx.lcx.ccx.sess.get_opts().debuginfo {
|
cx.lcx.ccx.sess.get_opts().debuginfo {
|
||||||
s = cx.lcx.ccx.names.next(name);
|
s = cx.lcx.ccx.names.next(name);
|
||||||
}
|
}
|
||||||
let llbb: BasicBlockRef = istr::as_buf(s, { |buf|
|
let llbb: BasicBlockRef = str::as_buf(s, { |buf|
|
||||||
llvm::LLVMAppendBasicBlock(cx.llfn, buf)
|
llvm::LLVMAppendBasicBlock(cx.llfn, buf)
|
||||||
});
|
});
|
||||||
ret @{llbb: llbb,
|
ret @{llbb: llbb,
|
||||||
|
@ -4836,7 +4836,7 @@ fn alloc_local(cx: &@block_ctxt, local: &@ast::local) -> result {
|
||||||
alt local.node.pat.node {
|
alt local.node.pat.node {
|
||||||
ast::pat_bind(ident) {
|
ast::pat_bind(ident) {
|
||||||
if bcx_ccx(cx).sess.get_opts().debuginfo {
|
if bcx_ccx(cx).sess.get_opts().debuginfo {
|
||||||
let _: () = istr::as_buf(ident, { |buf|
|
let _: () = str::as_buf(ident, { |buf|
|
||||||
llvm::LLVMSetValueName(r.val, buf)
|
llvm::LLVMSetValueName(r.val, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -4922,19 +4922,19 @@ fn mk_standard_basic_blocks(llfn: ValueRef) ->
|
||||||
dt: BasicBlockRef,
|
dt: BasicBlockRef,
|
||||||
da: BasicBlockRef,
|
da: BasicBlockRef,
|
||||||
rt: BasicBlockRef} {
|
rt: BasicBlockRef} {
|
||||||
ret {sa: istr::as_buf(~"statuc_allocas", { |buf|
|
ret {sa: str::as_buf(~"statuc_allocas", { |buf|
|
||||||
llvm::LLVMAppendBasicBlock(llfn, buf)
|
llvm::LLVMAppendBasicBlock(llfn, buf)
|
||||||
}),
|
}),
|
||||||
ca: istr::as_buf(~"copy_args", { |buf|
|
ca: str::as_buf(~"copy_args", { |buf|
|
||||||
llvm::LLVMAppendBasicBlock(llfn, buf)
|
llvm::LLVMAppendBasicBlock(llfn, buf)
|
||||||
}),
|
}),
|
||||||
dt: istr::as_buf(~"derived_tydescs", { |buf|
|
dt: str::as_buf(~"derived_tydescs", { |buf|
|
||||||
llvm::LLVMAppendBasicBlock(llfn, buf)
|
llvm::LLVMAppendBasicBlock(llfn, buf)
|
||||||
}),
|
}),
|
||||||
da: istr::as_buf(~"dynamic_allocas", { |buf|
|
da: str::as_buf(~"dynamic_allocas", { |buf|
|
||||||
llvm::LLVMAppendBasicBlock(llfn, buf)
|
llvm::LLVMAppendBasicBlock(llfn, buf)
|
||||||
}),
|
}),
|
||||||
rt: istr::as_buf(~"return", { |buf|
|
rt: str::as_buf(~"return", { |buf|
|
||||||
llvm::LLVMAppendBasicBlock(llfn, buf)
|
llvm::LLVMAppendBasicBlock(llfn, buf)
|
||||||
})};
|
})};
|
||||||
}
|
}
|
||||||
|
@ -5254,7 +5254,7 @@ fn trans_fn(cx: @local_ctxt, sp: &span, f: &ast::_fn, llfndecl: ValueRef,
|
||||||
let start = time::get_time();
|
let start = time::get_time();
|
||||||
trans_fn_inner(cx, sp, f, llfndecl, ty_self, ty_params, id);
|
trans_fn_inner(cx, sp, f, llfndecl, ty_self, ty_params, id);
|
||||||
let end = time::get_time();
|
let end = time::get_time();
|
||||||
log_fn_time(cx.ccx, istr::connect(cx.path, ~"::"),
|
log_fn_time(cx.ccx, str::connect(cx.path, ~"::"),
|
||||||
start, end);
|
start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5546,7 +5546,7 @@ fn create_main_wrapper(ccx: &@crate_ctxt, sp: &span, main_llfn: ValueRef,
|
||||||
|
|
||||||
// FIXME: This is a transitional way to let the runtime know
|
// FIXME: This is a transitional way to let the runtime know
|
||||||
// it needs to feed us istrs
|
// it needs to feed us istrs
|
||||||
let lltakesistr = istr::as_buf(~"_rust_main_takes_istr", { |buf|
|
let lltakesistr = str::as_buf(~"_rust_main_takes_istr", { |buf|
|
||||||
llvm::LLVMAddGlobal(ccx.llmod, T_int(), buf)
|
llvm::LLVMAddGlobal(ccx.llmod, T_int(), buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetInitializer(lltakesistr, C_uint(main_takes_istr as uint));
|
llvm::LLVMSetInitializer(lltakesistr, C_uint(main_takes_istr as uint));
|
||||||
|
@ -5597,7 +5597,7 @@ fn create_main_wrapper(ccx: &@crate_ctxt, sp: &span, main_llfn: ValueRef,
|
||||||
// space for the function's environment.
|
// space for the function's environment.
|
||||||
fn create_fn_pair(cx: &@crate_ctxt, ps: &istr, llfnty: TypeRef,
|
fn create_fn_pair(cx: &@crate_ctxt, ps: &istr, llfnty: TypeRef,
|
||||||
llfn: ValueRef, external: bool) -> ValueRef {
|
llfn: ValueRef, external: bool) -> ValueRef {
|
||||||
let gvar = istr::as_buf(ps, { |buf|
|
let gvar = str::as_buf(ps, { |buf|
|
||||||
llvm::LLVMAddGlobal(cx.llmod, T_fn_pair(*cx, llfnty), buf)
|
llvm::LLVMAddGlobal(cx.llmod, T_fn_pair(*cx, llfnty), buf)
|
||||||
});
|
});
|
||||||
let pair = C_struct([llfn, C_null(T_opaque_closure_ptr(*cx))]);
|
let pair = C_struct([llfn, C_null(T_opaque_closure_ptr(*cx))]);
|
||||||
|
@ -5874,7 +5874,7 @@ fn collect_item_1(ccx: @crate_ctxt, i: &@ast::item, pt: &[istr],
|
||||||
let s =
|
let s =
|
||||||
mangle_exported_name(ccx, pt + [i.ident],
|
mangle_exported_name(ccx, pt + [i.ident],
|
||||||
node_id_type(ccx, i.id));
|
node_id_type(ccx, i.id));
|
||||||
let g = istr::as_buf(s, { |buf|
|
let g = str::as_buf(s, { |buf|
|
||||||
llvm::LLVMAddGlobal(ccx.llmod, type_of(ccx, i.span, typ), buf)
|
llvm::LLVMAddGlobal(ccx.llmod, type_of(ccx, i.span, typ), buf)
|
||||||
});
|
});
|
||||||
ccx.item_symbols.insert(i.id, s);
|
ccx.item_symbols.insert(i.id, s);
|
||||||
|
@ -5966,7 +5966,7 @@ fn trans_constant(ccx: @crate_ctxt, it: &@ast::item, pt: &[istr],
|
||||||
~"discrim"];
|
~"discrim"];
|
||||||
let s = mangle_exported_name(ccx, p,
|
let s = mangle_exported_name(ccx, p,
|
||||||
ty::mk_int(ccx.tcx));
|
ty::mk_int(ccx.tcx));
|
||||||
let discrim_gvar = istr::as_buf(s, { |buf|
|
let discrim_gvar = str::as_buf(s, { |buf|
|
||||||
llvm::LLVMAddGlobal(ccx.llmod, T_int(), buf)
|
llvm::LLVMAddGlobal(ccx.llmod, T_int(), buf)
|
||||||
});
|
});
|
||||||
if n_variants != 1u {
|
if n_variants != 1u {
|
||||||
|
@ -6074,19 +6074,19 @@ fn make_common_glue(sess: &session::session, output: &istr) {
|
||||||
let task_type = T_task();
|
let task_type = T_task();
|
||||||
let taskptr_type = T_ptr(task_type);
|
let taskptr_type = T_ptr(task_type);
|
||||||
|
|
||||||
let llmod = istr::as_buf(~"rust_out", { |buf|
|
let llmod = str::as_buf(~"rust_out", { |buf|
|
||||||
llvm::LLVMModuleCreateWithNameInContext(buf,
|
llvm::LLVMModuleCreateWithNameInContext(buf,
|
||||||
llvm::LLVMGetGlobalContext())
|
llvm::LLVMGetGlobalContext())
|
||||||
});
|
});
|
||||||
let _: () = istr::as_buf(x86::get_data_layout(), { |buf|
|
let _: () = str::as_buf(x86::get_data_layout(), { |buf|
|
||||||
llvm::LLVMSetDataLayout(llmod, buf)
|
llvm::LLVMSetDataLayout(llmod, buf)
|
||||||
});
|
});
|
||||||
let _: () = istr::as_buf(x86::get_target_triple(), { |buf|
|
let _: () = str::as_buf(x86::get_target_triple(), { |buf|
|
||||||
llvm::LLVMSetTarget(llmod, buf)
|
llvm::LLVMSetTarget(llmod, buf)
|
||||||
});
|
});
|
||||||
mk_target_data(x86::get_data_layout());
|
mk_target_data(x86::get_data_layout());
|
||||||
declare_intrinsics(llmod);
|
declare_intrinsics(llmod);
|
||||||
let _: () = istr::as_buf(x86::get_module_asm(), { |buf|
|
let _: () = str::as_buf(x86::get_module_asm(), { |buf|
|
||||||
llvm::LLVMSetModuleInlineAsm(llmod, buf)
|
llvm::LLVMSetModuleInlineAsm(llmod, buf)
|
||||||
});
|
});
|
||||||
make_glues(llmod, taskptr_type);
|
make_glues(llmod, taskptr_type);
|
||||||
|
@ -6096,7 +6096,7 @@ fn make_common_glue(sess: &session::session, output: &istr) {
|
||||||
fn create_module_map(ccx: &@crate_ctxt) -> ValueRef {
|
fn create_module_map(ccx: &@crate_ctxt) -> ValueRef {
|
||||||
let elttype = T_struct([T_int(), T_int()]);
|
let elttype = T_struct([T_int(), T_int()]);
|
||||||
let maptype = T_array(elttype, ccx.module_data.size() + 1u);
|
let maptype = T_array(elttype, ccx.module_data.size() + 1u);
|
||||||
let map = istr::as_buf(~"_rust_mod_map", { |buf|
|
let map = str::as_buf(~"_rust_mod_map", { |buf|
|
||||||
llvm::LLVMAddGlobal(ccx.llmod, maptype, buf)
|
llvm::LLVMAddGlobal(ccx.llmod, maptype, buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetLinkage(map,
|
llvm::LLVMSetLinkage(map,
|
||||||
|
@ -6122,7 +6122,7 @@ fn create_crate_map(ccx: &@crate_ctxt) -> ValueRef {
|
||||||
while cstore::have_crate_data(cstore, i) {
|
while cstore::have_crate_data(cstore, i) {
|
||||||
let nm = ~"_rust_crate_map_" +
|
let nm = ~"_rust_crate_map_" +
|
||||||
cstore::get_crate_data(cstore, i).name;
|
cstore::get_crate_data(cstore, i).name;
|
||||||
let cr = istr::as_buf(nm, { |buf|
|
let cr = str::as_buf(nm, { |buf|
|
||||||
llvm::LLVMAddGlobal(ccx.llmod, T_int(), buf)
|
llvm::LLVMAddGlobal(ccx.llmod, T_int(), buf)
|
||||||
});
|
});
|
||||||
subcrates += [p2i(cr)];
|
subcrates += [p2i(cr)];
|
||||||
|
@ -6136,7 +6136,7 @@ fn create_crate_map(ccx: &@crate_ctxt) -> ValueRef {
|
||||||
let sym_name = ~"_rust_crate_map_" + mapname;
|
let sym_name = ~"_rust_crate_map_" + mapname;
|
||||||
let arrtype = T_array(T_int(), std::vec::len::<ValueRef>(subcrates));
|
let arrtype = T_array(T_int(), std::vec::len::<ValueRef>(subcrates));
|
||||||
let maptype = T_struct([T_int(), arrtype]);
|
let maptype = T_struct([T_int(), arrtype]);
|
||||||
let map = istr::as_buf(sym_name, { |buf|
|
let map = str::as_buf(sym_name, { |buf|
|
||||||
llvm::LLVMAddGlobal(ccx.llmod, maptype, buf)
|
llvm::LLVMAddGlobal(ccx.llmod, maptype, buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetLinkage(map,
|
llvm::LLVMSetLinkage(map,
|
||||||
|
@ -6152,11 +6152,11 @@ fn write_metadata(cx: &@crate_ctxt, crate: &@ast::crate) {
|
||||||
let llmeta = C_postr(
|
let llmeta = C_postr(
|
||||||
metadata::encoder::encode_metadata(cx, crate));
|
metadata::encoder::encode_metadata(cx, crate));
|
||||||
let llconst = trans_common::C_struct([llmeta]);
|
let llconst = trans_common::C_struct([llmeta]);
|
||||||
let llglobal = istr::as_buf(~"rust_metadata", { |buf|
|
let llglobal = str::as_buf(~"rust_metadata", { |buf|
|
||||||
llvm::LLVMAddGlobal(cx.llmod, val_ty(llconst), buf)
|
llvm::LLVMAddGlobal(cx.llmod, val_ty(llconst), buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetInitializer(llglobal, llconst);
|
llvm::LLVMSetInitializer(llglobal, llconst);
|
||||||
let _: () = istr::as_buf(x86::get_meta_sect_name(), { |buf|
|
let _: () = str::as_buf(x86::get_meta_sect_name(), { |buf|
|
||||||
llvm::LLVMSetSection(llglobal, buf)
|
llvm::LLVMSetSection(llglobal, buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetLinkage(llglobal,
|
llvm::LLVMSetLinkage(llglobal,
|
||||||
|
@ -6164,7 +6164,7 @@ fn write_metadata(cx: &@crate_ctxt, crate: &@ast::crate) {
|
||||||
|
|
||||||
let t_ptr_i8 = T_ptr(T_i8());
|
let t_ptr_i8 = T_ptr(T_i8());
|
||||||
llglobal = llvm::LLVMConstBitCast(llglobal, t_ptr_i8);
|
llglobal = llvm::LLVMConstBitCast(llglobal, t_ptr_i8);
|
||||||
let llvm_used = istr::as_buf(~"llvm.used", { |buf|
|
let llvm_used = str::as_buf(~"llvm.used", { |buf|
|
||||||
llvm::LLVMAddGlobal(cx.llmod, T_array(t_ptr_i8, 1u), buf)
|
llvm::LLVMAddGlobal(cx.llmod, T_array(t_ptr_i8, 1u), buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetLinkage(llvm_used,
|
llvm::LLVMSetLinkage(llvm_used,
|
||||||
|
@ -6181,14 +6181,14 @@ fn write_abi_version(ccx: &@crate_ctxt) {
|
||||||
fn trans_crate(sess: &session::session, crate: &@ast::crate, tcx: &ty::ctxt,
|
fn trans_crate(sess: &session::session, crate: &@ast::crate, tcx: &ty::ctxt,
|
||||||
output: &istr, amap: &ast_map::map, mut_map: mut::mut_map)
|
output: &istr, amap: &ast_map::map, mut_map: mut::mut_map)
|
||||||
-> ModuleRef {
|
-> ModuleRef {
|
||||||
let llmod = istr::as_buf(~"rust_out", { |buf|
|
let llmod = str::as_buf(~"rust_out", { |buf|
|
||||||
llvm::LLVMModuleCreateWithNameInContext(buf,
|
llvm::LLVMModuleCreateWithNameInContext(buf,
|
||||||
llvm::LLVMGetGlobalContext())
|
llvm::LLVMGetGlobalContext())
|
||||||
});
|
});
|
||||||
let _: () = istr::as_buf(x86::get_data_layout(), { |buf|
|
let _: () = str::as_buf(x86::get_data_layout(), { |buf|
|
||||||
llvm::LLVMSetDataLayout(llmod, buf)
|
llvm::LLVMSetDataLayout(llmod, buf)
|
||||||
});
|
});
|
||||||
let _: () = istr::as_buf(x86::get_target_triple(), { |buf|
|
let _: () = str::as_buf(x86::get_target_triple(), { |buf|
|
||||||
llvm::LLVMSetTarget(llmod, buf)
|
llvm::LLVMSetTarget(llmod, buf)
|
||||||
});
|
});
|
||||||
let td = mk_target_data(x86::get_data_layout());
|
let td = mk_target_data(x86::get_data_layout());
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::option;
|
import std::option;
|
||||||
import option::some;
|
import option::some;
|
||||||
|
@ -59,7 +59,7 @@ fn variant_opt(ccx: &@crate_ctxt, pat_id: ast::node_id) -> opt {
|
||||||
type bind_map = [{ident: ast::ident, val: ValueRef}];
|
type bind_map = [{ident: ast::ident, val: ValueRef}];
|
||||||
fn assoc(key: &istr, list: &bind_map) -> option::t<ValueRef> {
|
fn assoc(key: &istr, list: &bind_map) -> option::t<ValueRef> {
|
||||||
for elt: {ident: ast::ident, val: ValueRef} in list {
|
for elt: {ident: ast::ident, val: ValueRef} in list {
|
||||||
if istr::eq(elt.ident, key) { ret some(elt.val); }
|
if str::eq(elt.ident, key) { ret some(elt.val); }
|
||||||
}
|
}
|
||||||
ret none;
|
ret none;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ fn enter_rec(m: &match, col: uint, fields: &[ast::ident], val: ValueRef) ->
|
||||||
for fname: ast::ident in fields {
|
for fname: ast::ident in fields {
|
||||||
let pat = dummy;
|
let pat = dummy;
|
||||||
for fpat: ast::field_pat in fpats {
|
for fpat: ast::field_pat in fpats {
|
||||||
if istr::eq(fpat.ident, fname) { pat = fpat.pat; break; }
|
if str::eq(fpat.ident, fname) { pat = fpat.pat; break; }
|
||||||
}
|
}
|
||||||
pats += [pat];
|
pats += [pat];
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ fn collect_record_fields(m: &match, col: uint) -> [ast::ident] {
|
||||||
alt br.pats[col].node {
|
alt br.pats[col].node {
|
||||||
ast::pat_rec(fs, _) {
|
ast::pat_rec(fs, _) {
|
||||||
for f: ast::field_pat in fs {
|
for f: ast::field_pat in fs {
|
||||||
if !vec::any(bind istr::eq(f.ident, _), fields) {
|
if !vec::any(bind str::eq(f.ident, _), fields) {
|
||||||
fields += [f.ident];
|
fields += [f.ident];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import std::{vec, istr};
|
import std::{vec, str};
|
||||||
import std::istr::sbuf;
|
import std::str::sbuf;
|
||||||
import lib::llvm::llvm;
|
import lib::llvm::llvm;
|
||||||
import llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef,
|
import llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef,
|
||||||
Opcode, ModuleRef};
|
Opcode, ModuleRef};
|
||||||
|
@ -61,7 +61,7 @@ fn Invoke(cx: &@block_ctxt, Fn: ValueRef, Args: &[ValueRef],
|
||||||
Then: BasicBlockRef, Catch: BasicBlockRef) -> ValueRef {
|
Then: BasicBlockRef, Catch: BasicBlockRef) -> ValueRef {
|
||||||
assert (!cx.terminated);;
|
assert (!cx.terminated);;
|
||||||
cx.terminated = true;
|
cx.terminated = true;
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildInvoke(B(cx), Fn, vec::to_ptr(Args),
|
llvm::LLVMBuildInvoke(B(cx), Fn, vec::to_ptr(Args),
|
||||||
vec::len(Args), Then, Catch, buf)
|
vec::len(Args), Then, Catch, buf)
|
||||||
});
|
});
|
||||||
|
@ -75,212 +75,212 @@ fn Unreachable(cx: &@block_ctxt) -> ValueRef {
|
||||||
|
|
||||||
/* Arithmetic */
|
/* Arithmetic */
|
||||||
fn Add(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn Add(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildAdd(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildAdd(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn NSWAdd(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn NSWAdd(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildNSWAdd(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildNSWAdd(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn NUWAdd(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn NUWAdd(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildNUWAdd(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildNUWAdd(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn FAdd(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn FAdd(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildFAdd(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildFAdd(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Sub(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn Sub(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildSub(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildSub(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn NSWSub(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn NSWSub(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildNSWSub(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildNSWSub(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn NUWSub(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn NUWSub(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildNUWSub(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildNUWSub(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn FSub(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn FSub(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildFSub(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildFSub(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Mul(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn Mul(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildMul(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildMul(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn NSWMul(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn NSWMul(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildNSWMul(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildNSWMul(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn NUWMul(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn NUWMul(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildNUWMul(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildNUWMul(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn FMul(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn FMul(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildFMul(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildFMul(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn UDiv(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn UDiv(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildUDiv(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildUDiv(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SDiv(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn SDiv(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildSDiv(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildSDiv(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ExactSDiv(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn ExactSDiv(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildExactSDiv(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildExactSDiv(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn FDiv(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn FDiv(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildFDiv(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildFDiv(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn URem(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn URem(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildURem(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildURem(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SRem(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn SRem(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildSRem(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildSRem(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn FRem(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn FRem(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildFRem(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildFRem(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Shl(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn Shl(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildShl(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildShl(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn LShr(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn LShr(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildLShr(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildLShr(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn AShr(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn AShr(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildAShr(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildAShr(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn And(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn And(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildAnd(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildAnd(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Or(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn Or(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildOr(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildOr(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Xor(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn Xor(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildXor(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildXor(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn BinOp(cx: &@block_ctxt, Op: Opcode, LHS: ValueRef,
|
fn BinOp(cx: &@block_ctxt, Op: Opcode, LHS: ValueRef,
|
||||||
RHS: ValueRef) -> ValueRef {
|
RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildBinOp(B(cx), Op, LHS, RHS, buf)
|
llvm::LLVMBuildBinOp(B(cx), Op, LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Neg(cx: &@block_ctxt, V: ValueRef) -> ValueRef {
|
fn Neg(cx: &@block_ctxt, V: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildNeg(B(cx), V, buf)
|
llvm::LLVMBuildNeg(B(cx), V, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn NSWNeg(cx: &@block_ctxt, V: ValueRef) -> ValueRef {
|
fn NSWNeg(cx: &@block_ctxt, V: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildNSWNeg(B(cx), V, buf)
|
llvm::LLVMBuildNSWNeg(B(cx), V, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn NUWNeg(cx: &@block_ctxt, V: ValueRef) -> ValueRef {
|
fn NUWNeg(cx: &@block_ctxt, V: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildNUWNeg(B(cx), V, buf)
|
llvm::LLVMBuildNUWNeg(B(cx), V, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
fn FNeg(cx: &@block_ctxt, V: ValueRef) -> ValueRef {
|
fn FNeg(cx: &@block_ctxt, V: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildFNeg(B(cx), V, buf)
|
llvm::LLVMBuildFNeg(B(cx), V, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Not(cx: &@block_ctxt, V: ValueRef) -> ValueRef {
|
fn Not(cx: &@block_ctxt, V: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildNot(B(cx), V, buf)
|
llvm::LLVMBuildNot(B(cx), V, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Memory */
|
/* Memory */
|
||||||
fn Malloc(cx: &@block_ctxt, Ty: TypeRef) -> ValueRef {
|
fn Malloc(cx: &@block_ctxt, Ty: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildMalloc(B(cx), Ty, buf)
|
llvm::LLVMBuildMalloc(B(cx), Ty, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ArrayMalloc(cx: &@block_ctxt, Ty: TypeRef, Val: ValueRef) -> ValueRef {
|
fn ArrayMalloc(cx: &@block_ctxt, Ty: TypeRef, Val: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildArrayMalloc(B(cx), Ty, Val, buf)
|
llvm::LLVMBuildArrayMalloc(B(cx), Ty, Val, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Alloca(cx: &@block_ctxt, Ty: TypeRef) -> ValueRef {
|
fn Alloca(cx: &@block_ctxt, Ty: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildAlloca(B(cx), Ty, buf)
|
llvm::LLVMBuildAlloca(B(cx), Ty, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ArrayAlloca(cx: &@block_ctxt, Ty: TypeRef, Val: ValueRef) -> ValueRef {
|
fn ArrayAlloca(cx: &@block_ctxt, Ty: TypeRef, Val: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildArrayAlloca(B(cx), Ty, Val, buf)
|
llvm::LLVMBuildArrayAlloca(B(cx), Ty, Val, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ fn Free(cx: &@block_ctxt, PointerVal: ValueRef) -> ValueRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Load(cx: &@block_ctxt, PointerVal: ValueRef) -> ValueRef {
|
fn Load(cx: &@block_ctxt, PointerVal: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildLoad(B(cx), PointerVal, buf)
|
llvm::LLVMBuildLoad(B(cx), PointerVal, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ fn Store(cx: &@block_ctxt, Val: ValueRef, Ptr: ValueRef) -> ValueRef {
|
||||||
|
|
||||||
fn GEP(cx: &@block_ctxt, Pointer: ValueRef,
|
fn GEP(cx: &@block_ctxt, Pointer: ValueRef,
|
||||||
Indices: &[ValueRef]) -> ValueRef {
|
Indices: &[ValueRef]) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildGEP(B(cx), Pointer, vec::to_ptr(Indices),
|
llvm::LLVMBuildGEP(B(cx), Pointer, vec::to_ptr(Indices),
|
||||||
vec::len(Indices), buf)
|
vec::len(Indices), buf)
|
||||||
});
|
});
|
||||||
|
@ -309,122 +309,122 @@ fn GEP(cx: &@block_ctxt, Pointer: ValueRef,
|
||||||
|
|
||||||
fn InBoundsGEP(cx: &@block_ctxt, Pointer: ValueRef,
|
fn InBoundsGEP(cx: &@block_ctxt, Pointer: ValueRef,
|
||||||
Indices: &[ValueRef]) -> ValueRef {
|
Indices: &[ValueRef]) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildInBoundsGEP(B(cx), Pointer, vec::to_ptr(Indices),
|
llvm::LLVMBuildInBoundsGEP(B(cx), Pointer, vec::to_ptr(Indices),
|
||||||
vec::len(Indices), buf)
|
vec::len(Indices), buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn StructGEP(cx: &@block_ctxt, Pointer: ValueRef, Idx: uint) -> ValueRef {
|
fn StructGEP(cx: &@block_ctxt, Pointer: ValueRef, Idx: uint) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildStructGEP(B(cx), Pointer, Idx, buf)
|
llvm::LLVMBuildStructGEP(B(cx), Pointer, Idx, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GlobalString(cx: &@block_ctxt, _Str: sbuf) -> ValueRef {
|
fn GlobalString(cx: &@block_ctxt, _Str: sbuf) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildGlobalString(B(cx), _Str, buf)
|
llvm::LLVMBuildGlobalString(B(cx), _Str, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GlobalStringPtr(cx: &@block_ctxt, _Str: sbuf) -> ValueRef {
|
fn GlobalStringPtr(cx: &@block_ctxt, _Str: sbuf) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildGlobalStringPtr(B(cx), _Str, buf)
|
llvm::LLVMBuildGlobalStringPtr(B(cx), _Str, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Casts */
|
/* Casts */
|
||||||
fn Trunc(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
fn Trunc(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildTrunc(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildTrunc(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ZExt(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
fn ZExt(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildZExt(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildZExt(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SExt(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
fn SExt(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildSExt(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildSExt(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn FPToUI(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
fn FPToUI(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildFPToUI(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildFPToUI(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn FPToSI(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
fn FPToSI(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildFPToSI(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildFPToSI(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn UIToFP(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
fn UIToFP(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildUIToFP(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildUIToFP(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SIToFP(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
fn SIToFP(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildSIToFP(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildSIToFP(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn FPTrunc(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
fn FPTrunc(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildFPTrunc(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildFPTrunc(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn FPExt(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
fn FPExt(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildFPExt(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildFPExt(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn PtrToInt(cx: &@block_ctxt, Val: ValueRef,
|
fn PtrToInt(cx: &@block_ctxt, Val: ValueRef,
|
||||||
DestTy: TypeRef) -> ValueRef {
|
DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildPtrToInt(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildPtrToInt(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn IntToPtr(cx: &@block_ctxt, Val: ValueRef,
|
fn IntToPtr(cx: &@block_ctxt, Val: ValueRef,
|
||||||
DestTy: TypeRef) -> ValueRef {
|
DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildIntToPtr(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildIntToPtr(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn BitCast(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
fn BitCast(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildBitCast(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildBitCast(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ZExtOrBitCast(cx: &@block_ctxt, Val: ValueRef,
|
fn ZExtOrBitCast(cx: &@block_ctxt, Val: ValueRef,
|
||||||
DestTy: TypeRef) -> ValueRef {
|
DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildZExtOrBitCast(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildZExtOrBitCast(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SExtOrBitCast(cx: &@block_ctxt, Val: ValueRef,
|
fn SExtOrBitCast(cx: &@block_ctxt, Val: ValueRef,
|
||||||
DestTy: TypeRef) -> ValueRef {
|
DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildSExtOrBitCast(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildSExtOrBitCast(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn TruncOrBitCast(cx: &@block_ctxt, Val: ValueRef,
|
fn TruncOrBitCast(cx: &@block_ctxt, Val: ValueRef,
|
||||||
DestTy: TypeRef) -> ValueRef {
|
DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildTruncOrBitCast(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildTruncOrBitCast(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -432,25 +432,25 @@ fn TruncOrBitCast(cx: &@block_ctxt, Val: ValueRef,
|
||||||
fn Cast(cx: &@block_ctxt, Op: Opcode, Val: ValueRef,
|
fn Cast(cx: &@block_ctxt, Op: Opcode, Val: ValueRef,
|
||||||
DestTy: TypeRef, _Name: sbuf) ->
|
DestTy: TypeRef, _Name: sbuf) ->
|
||||||
ValueRef {
|
ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildCast(B(cx), Op, Val, DestTy, buf)
|
llvm::LLVMBuildCast(B(cx), Op, Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn PointerCast(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
fn PointerCast(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildPointerCast(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildPointerCast(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn IntCast(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
fn IntCast(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildIntCast(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildIntCast(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn FPCast(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
fn FPCast(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildFPCast(B(cx), Val, DestTy, buf)
|
llvm::LLVMBuildFPCast(B(cx), Val, DestTy, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -459,14 +459,14 @@ fn FPCast(cx: &@block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
||||||
/* Comparisons */
|
/* Comparisons */
|
||||||
fn ICmp(cx: &@block_ctxt, Op: uint, LHS: ValueRef,
|
fn ICmp(cx: &@block_ctxt, Op: uint, LHS: ValueRef,
|
||||||
RHS: ValueRef) -> ValueRef {
|
RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildICmp(B(cx), Op, LHS, RHS, buf)
|
llvm::LLVMBuildICmp(B(cx), Op, LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn FCmp(cx: &@block_ctxt, Op: uint, LHS: ValueRef,
|
fn FCmp(cx: &@block_ctxt, Op: uint, LHS: ValueRef,
|
||||||
RHS: ValueRef) -> ValueRef {
|
RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildFCmp(B(cx), Op, LHS, RHS, buf)
|
llvm::LLVMBuildFCmp(B(cx), Op, LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -475,7 +475,7 @@ fn FCmp(cx: &@block_ctxt, Op: uint, LHS: ValueRef,
|
||||||
/* Miscellaneous instructions */
|
/* Miscellaneous instructions */
|
||||||
fn Phi(cx: &@block_ctxt, Ty: TypeRef, vals: &[ValueRef],
|
fn Phi(cx: &@block_ctxt, Ty: TypeRef, vals: &[ValueRef],
|
||||||
bbs: &[BasicBlockRef]) -> ValueRef {
|
bbs: &[BasicBlockRef]) -> ValueRef {
|
||||||
let phi = istr::as_buf(~"", { |buf|
|
let phi = str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildPhi(B(cx), Ty, buf)
|
llvm::LLVMBuildPhi(B(cx), Ty, buf)
|
||||||
});
|
});
|
||||||
assert (vec::len::<ValueRef>(vals) == vec::len::<BasicBlockRef>(bbs));
|
assert (vec::len::<ValueRef>(vals) == vec::len::<BasicBlockRef>(bbs));
|
||||||
|
@ -491,14 +491,14 @@ fn AddIncomingToPhi(phi: ValueRef, vals: &[ValueRef], bbs: &[BasicBlockRef]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Call(cx: &@block_ctxt, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
|
fn Call(cx: &@block_ctxt, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args),
|
llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args),
|
||||||
vec::len(Args), buf)
|
vec::len(Args), buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn FastCall(cx: &@block_ctxt, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
|
fn FastCall(cx: &@block_ctxt, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
|
||||||
let v = istr::as_buf(~"", { |buf|
|
let v = str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args), vec::len(Args), buf)
|
llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args), vec::len(Args), buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetInstructionCallConv(v, lib::llvm::LLVMFastCallConv);
|
llvm::LLVMSetInstructionCallConv(v, lib::llvm::LLVMFastCallConv);
|
||||||
|
@ -507,7 +507,7 @@ fn FastCall(cx: &@block_ctxt, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
|
||||||
|
|
||||||
fn CallWithConv(cx: &@block_ctxt, Fn: ValueRef, Args: &[ValueRef],
|
fn CallWithConv(cx: &@block_ctxt, Fn: ValueRef, Args: &[ValueRef],
|
||||||
Conv: uint) -> ValueRef {
|
Conv: uint) -> ValueRef {
|
||||||
let v = istr::as_buf(~"", { |buf|
|
let v = str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args), vec::len(Args), buf)
|
llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args), vec::len(Args), buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetInstructionCallConv(v, Conv);
|
llvm::LLVMSetInstructionCallConv(v, Conv);
|
||||||
|
@ -516,20 +516,20 @@ fn CallWithConv(cx: &@block_ctxt, Fn: ValueRef, Args: &[ValueRef],
|
||||||
|
|
||||||
fn Select(cx: &@block_ctxt, If: ValueRef, Then: ValueRef,
|
fn Select(cx: &@block_ctxt, If: ValueRef, Then: ValueRef,
|
||||||
Else: ValueRef) -> ValueRef {
|
Else: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildSelect(B(cx), If, Then, Else, buf)
|
llvm::LLVMBuildSelect(B(cx), If, Then, Else, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn VAArg(cx: &@block_ctxt, list: ValueRef, Ty: TypeRef) -> ValueRef {
|
fn VAArg(cx: &@block_ctxt, list: ValueRef, Ty: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildVAArg(B(cx), list, Ty, buf)
|
llvm::LLVMBuildVAArg(B(cx), list, Ty, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ExtractElement(cx: &@block_ctxt, VecVal: ValueRef,
|
fn ExtractElement(cx: &@block_ctxt, VecVal: ValueRef,
|
||||||
Index: ValueRef) -> ValueRef {
|
Index: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildExtractElement(B(cx), VecVal, Index, buf)
|
llvm::LLVMBuildExtractElement(B(cx), VecVal, Index, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -537,45 +537,45 @@ fn ExtractElement(cx: &@block_ctxt, VecVal: ValueRef,
|
||||||
fn InsertElement(cx: &@block_ctxt, VecVal: ValueRef, EltVal: ValueRef,
|
fn InsertElement(cx: &@block_ctxt, VecVal: ValueRef, EltVal: ValueRef,
|
||||||
Index: ValueRef) ->
|
Index: ValueRef) ->
|
||||||
ValueRef {
|
ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildInsertElement(B(cx), VecVal, EltVal, Index, buf)
|
llvm::LLVMBuildInsertElement(B(cx), VecVal, EltVal, Index, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ShuffleVector(cx: &@block_ctxt, V1: ValueRef, V2: ValueRef,
|
fn ShuffleVector(cx: &@block_ctxt, V1: ValueRef, V2: ValueRef,
|
||||||
Mask: ValueRef) -> ValueRef {
|
Mask: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildShuffleVector(B(cx), V1, V2, Mask, buf)
|
llvm::LLVMBuildShuffleVector(B(cx), V1, V2, Mask, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ExtractValue(cx: &@block_ctxt, AggVal: ValueRef, Index: uint) -> ValueRef {
|
fn ExtractValue(cx: &@block_ctxt, AggVal: ValueRef, Index: uint) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildExtractValue(B(cx), AggVal, Index, buf)
|
llvm::LLVMBuildExtractValue(B(cx), AggVal, Index, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn InsertValue(cx: &@block_ctxt, AggVal: ValueRef,
|
fn InsertValue(cx: &@block_ctxt, AggVal: ValueRef,
|
||||||
EltVal: ValueRef, Index: uint) -> ValueRef {
|
EltVal: ValueRef, Index: uint) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildInsertValue(B(cx), AggVal, EltVal, Index, buf)
|
llvm::LLVMBuildInsertValue(B(cx), AggVal, EltVal, Index, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn IsNull(cx: &@block_ctxt, Val: ValueRef) -> ValueRef {
|
fn IsNull(cx: &@block_ctxt, Val: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildIsNull(B(cx), Val, buf)
|
llvm::LLVMBuildIsNull(B(cx), Val, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn IsNotNull(cx: &@block_ctxt, Val: ValueRef) -> ValueRef {
|
fn IsNotNull(cx: &@block_ctxt, Val: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildIsNotNull(B(cx), Val, buf)
|
llvm::LLVMBuildIsNotNull(B(cx), Val, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn PtrDiff(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
fn PtrDiff(cx: &@block_ctxt, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildPtrDiff(B(cx), LHS, RHS, buf)
|
llvm::LLVMBuildPtrDiff(B(cx), LHS, RHS, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -585,12 +585,12 @@ fn Trap(cx: &@block_ctxt) -> ValueRef {
|
||||||
let BB: BasicBlockRef = llvm::LLVMGetInsertBlock(b);
|
let BB: BasicBlockRef = llvm::LLVMGetInsertBlock(b);
|
||||||
let FN: ValueRef = llvm::LLVMGetBasicBlockParent(BB);
|
let FN: ValueRef = llvm::LLVMGetBasicBlockParent(BB);
|
||||||
let M: ModuleRef = llvm::LLVMGetGlobalParent(FN);
|
let M: ModuleRef = llvm::LLVMGetGlobalParent(FN);
|
||||||
let T: ValueRef = istr::as_buf(~"llvm.trap", { |buf|
|
let T: ValueRef = str::as_buf(~"llvm.trap", { |buf|
|
||||||
llvm::LLVMGetNamedFunction(M, buf)
|
llvm::LLVMGetNamedFunction(M, buf)
|
||||||
});
|
});
|
||||||
assert (T as int != 0);
|
assert (T as int != 0);
|
||||||
let Args: [ValueRef] = [];
|
let Args: [ValueRef] = [];
|
||||||
ret istr::as_buf(~"", { |buf|
|
ret str::as_buf(~"", { |buf|
|
||||||
llvm::LLVMBuildCall(b, T, vec::to_ptr(Args), vec::len(Args), buf)
|
llvm::LLVMBuildCall(b, T, vec::to_ptr(Args), vec::len(Args), buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::vec::to_ptr;
|
import std::vec::to_ptr;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::map;
|
import std::map;
|
||||||
import std::map::hashmap;
|
import std::map::hashmap;
|
||||||
|
@ -547,7 +547,7 @@ fn T_struct(elts: &[TypeRef]) -> TypeRef {
|
||||||
|
|
||||||
fn T_named_struct(name: &istr) -> TypeRef {
|
fn T_named_struct(name: &istr) -> TypeRef {
|
||||||
let c = llvm::LLVMGetGlobalContext();
|
let c = llvm::LLVMGetGlobalContext();
|
||||||
ret istr::as_buf(name, { |buf|
|
ret str::as_buf(name, { |buf|
|
||||||
llvm::LLVMStructCreateNamed(c, buf)
|
llvm::LLVMStructCreateNamed(c, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -767,13 +767,13 @@ fn C_integral(t: TypeRef, u: uint, sign_extend: Bool) -> ValueRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn C_float(s: &istr) -> ValueRef {
|
fn C_float(s: &istr) -> ValueRef {
|
||||||
ret istr::as_buf(s, { |buf|
|
ret str::as_buf(s, { |buf|
|
||||||
llvm::LLVMConstRealOfString(T_float(), buf)
|
llvm::LLVMConstRealOfString(T_float(), buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn C_floating(s: &istr, t: TypeRef) -> ValueRef {
|
fn C_floating(s: &istr, t: TypeRef) -> ValueRef {
|
||||||
ret istr::as_buf(s, { |buf|
|
ret str::as_buf(s, { |buf|
|
||||||
llvm::LLVMConstRealOfString(t, buf)
|
llvm::LLVMConstRealOfString(t, buf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -800,10 +800,10 @@ fn C_u8(i: uint) -> ValueRef { ret C_integral(T_i8(), i, False); }
|
||||||
// This is a 'c-like' raw string, which differs from
|
// This is a 'c-like' raw string, which differs from
|
||||||
// our boxed-and-length-annotated strings.
|
// our boxed-and-length-annotated strings.
|
||||||
fn C_cstr(cx: &@crate_ctxt, s: &istr) -> ValueRef {
|
fn C_cstr(cx: &@crate_ctxt, s: &istr) -> ValueRef {
|
||||||
let sc = istr::as_buf(s, { |buf|
|
let sc = str::as_buf(s, { |buf|
|
||||||
llvm::LLVMConstString(buf, istr::byte_len(s), False)
|
llvm::LLVMConstString(buf, str::byte_len(s), False)
|
||||||
});
|
});
|
||||||
let g = istr::as_buf(cx.names.next(~"str"), { |buf|
|
let g = str::as_buf(cx.names.next(~"str"), { |buf|
|
||||||
llvm::LLVMAddGlobal(cx.llmod, val_ty(sc), buf)
|
llvm::LLVMAddGlobal(cx.llmod, val_ty(sc), buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetInitializer(g, sc);
|
llvm::LLVMSetInitializer(g, sc);
|
||||||
|
@ -816,17 +816,17 @@ fn C_cstr(cx: &@crate_ctxt, s: &istr) -> ValueRef {
|
||||||
// A rust boxed-and-length-annotated string.
|
// A rust boxed-and-length-annotated string.
|
||||||
fn C_str(cx: &@crate_ctxt, s: &istr) -> ValueRef {
|
fn C_str(cx: &@crate_ctxt, s: &istr) -> ValueRef {
|
||||||
let len =
|
let len =
|
||||||
istr::byte_len(s); // 'alloc'
|
str::byte_len(s); // 'alloc'
|
||||||
// 'fill'
|
// 'fill'
|
||||||
// 'pad'
|
// 'pad'
|
||||||
|
|
||||||
let cstr = istr::as_buf(s, { |buf|
|
let cstr = str::as_buf(s, { |buf|
|
||||||
llvm::LLVMConstString(buf, len, False)
|
llvm::LLVMConstString(buf, len, False)
|
||||||
});
|
});
|
||||||
let box =
|
let box =
|
||||||
C_struct([C_int(abi::const_refcount as int), C_int(len + 1u as int),
|
C_struct([C_int(abi::const_refcount as int), C_int(len + 1u as int),
|
||||||
C_int(len + 1u as int), C_int(0), cstr]);
|
C_int(len + 1u as int), C_int(0), cstr]);
|
||||||
let g = istr::as_buf(cx.names.next(~"str"), { |buf|
|
let g = str::as_buf(cx.names.next(~"str"), { |buf|
|
||||||
llvm::LLVMAddGlobal(cx.llmod, val_ty(box), buf)
|
llvm::LLVMAddGlobal(cx.llmod, val_ty(box), buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetInitializer(g, box);
|
llvm::LLVMSetInitializer(g, box);
|
||||||
|
@ -837,8 +837,8 @@ fn C_str(cx: &@crate_ctxt, s: &istr) -> ValueRef {
|
||||||
|
|
||||||
// Returns a Plain Old LLVM String:
|
// Returns a Plain Old LLVM String:
|
||||||
fn C_postr(s: &istr) -> ValueRef {
|
fn C_postr(s: &istr) -> ValueRef {
|
||||||
ret istr::as_buf(s, { |buf|
|
ret str::as_buf(s, { |buf|
|
||||||
llvm::LLVMConstString(buf, istr::byte_len(s), False)
|
llvm::LLVMConstString(buf, str::byte_len(s), False)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,7 +871,7 @@ fn C_bytes(bytes: &[u8]) -> ValueRef {
|
||||||
|
|
||||||
fn C_shape(ccx: &@crate_ctxt, bytes: &[u8]) -> ValueRef {
|
fn C_shape(ccx: &@crate_ctxt, bytes: &[u8]) -> ValueRef {
|
||||||
let llshape = C_bytes(bytes);
|
let llshape = C_bytes(bytes);
|
||||||
let llglobal = istr::as_buf(ccx.names.next(~"shape"), { |buf|
|
let llglobal = str::as_buf(ccx.names.next(~"shape"), { |buf|
|
||||||
llvm::LLVMAddGlobal(ccx.llmod, val_ty(llshape), buf)
|
llvm::LLVMAddGlobal(ccx.llmod, val_ty(llshape), buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetInitializer(llglobal, llshape);
|
llvm::LLVMSetInitializer(llglobal, llshape);
|
||||||
|
|
|
@ -114,7 +114,7 @@ fn trans_ivec(bcx: &@block_ctxt, args: &[@ast::expr],
|
||||||
ret rslt(bcx, vptr);
|
ret rslt(bcx, vptr);
|
||||||
}
|
}
|
||||||
fn trans_istr(bcx: &@block_ctxt, s: istr) -> result {
|
fn trans_istr(bcx: &@block_ctxt, s: istr) -> result {
|
||||||
let veclen = std::istr::byte_len(s) + 1u; // +1 for \0
|
let veclen = std::str::byte_len(s) + 1u; // +1 for \0
|
||||||
let {bcx, val: sptr, _} =
|
let {bcx, val: sptr, _} =
|
||||||
alloc(bcx, ty::mk_istr(bcx_tcx(bcx)), veclen);
|
alloc(bcx, ty::mk_istr(bcx_tcx(bcx)), veclen);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Translation of object-related things to LLVM IR.
|
// Translation of object-related things to LLVM IR.
|
||||||
|
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import option::none;
|
import option::none;
|
||||||
|
@ -396,7 +396,7 @@ tag vtbl_mthd {
|
||||||
|
|
||||||
// Alphabetize ast::methods by ident. A helper for create_vtbl.
|
// Alphabetize ast::methods by ident. A helper for create_vtbl.
|
||||||
fn ast_mthd_lteq(a: &@ast::method, b: &@ast::method) -> bool {
|
fn ast_mthd_lteq(a: &@ast::method, b: &@ast::method) -> bool {
|
||||||
ret istr::lteq(a.node.ident, b.node.ident);
|
ret str::lteq(a.node.ident, b.node.ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alphabetize vtbl_mthds by ident. A helper for create_vtbl.
|
// Alphabetize vtbl_mthds by ident. A helper for create_vtbl.
|
||||||
|
@ -404,14 +404,14 @@ fn vtbl_mthd_lteq(a: &vtbl_mthd, b: &vtbl_mthd) -> bool {
|
||||||
alt a {
|
alt a {
|
||||||
normal_mthd(ma) {
|
normal_mthd(ma) {
|
||||||
alt b {
|
alt b {
|
||||||
normal_mthd(mb) { ret istr::lteq(ma.node.ident, mb.node.ident); }
|
normal_mthd(mb) { ret str::lteq(ma.node.ident, mb.node.ident); }
|
||||||
fwding_mthd(mb) { ret istr::lteq(ma.node.ident, mb.ident); }
|
fwding_mthd(mb) { ret str::lteq(ma.node.ident, mb.ident); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fwding_mthd(ma) {
|
fwding_mthd(ma) {
|
||||||
alt b {
|
alt b {
|
||||||
normal_mthd(mb) { ret istr::lteq(ma.ident, mb.node.ident); }
|
normal_mthd(mb) { ret str::lteq(ma.ident, mb.node.ident); }
|
||||||
fwding_mthd(mb) { ret istr::lteq(ma.ident, mb.ident); }
|
fwding_mthd(mb) { ret str::lteq(ma.ident, mb.ident); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -430,7 +430,7 @@ fn filtering_fn(cx: @local_ctxt, m: &vtbl_mthd, addtl_meths: [@ast::method])
|
||||||
alt m {
|
alt m {
|
||||||
fwding_mthd(fm) {
|
fwding_mthd(fm) {
|
||||||
for am: @ast::method in addtl_meths {
|
for am: @ast::method in addtl_meths {
|
||||||
if istr::eq(am.node.ident, fm.ident) { ret none; }
|
if str::eq(am.node.ident, fm.ident) { ret none; }
|
||||||
}
|
}
|
||||||
ret some(fwding_mthd(fm));
|
ret some(fwding_mthd(fm));
|
||||||
}
|
}
|
||||||
|
@ -570,7 +570,7 @@ fn finish_vtbl(cx: @local_ctxt, llmethods: [ValueRef], name: &istr) ->
|
||||||
let vtbl = C_struct(llmethods);
|
let vtbl = C_struct(llmethods);
|
||||||
let vtbl_name = mangle_internal_name_by_path(
|
let vtbl_name = mangle_internal_name_by_path(
|
||||||
cx.ccx, cx.path + [name]);
|
cx.ccx, cx.path + [name]);
|
||||||
let gvar = istr::as_buf(vtbl_name, { |buf|
|
let gvar = str::as_buf(vtbl_name, { |buf|
|
||||||
llvm::LLVMAddGlobal(cx.ccx.llmod, val_ty(vtbl), buf)
|
llvm::LLVMAddGlobal(cx.ccx.llmod, val_ty(vtbl), buf)
|
||||||
});
|
});
|
||||||
llvm::LLVMSetInitializer(gvar, vtbl);
|
llvm::LLVMSetInitializer(gvar, vtbl);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import std::option::some;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import syntax::ast::*;
|
import syntax::ast::*;
|
||||||
import syntax::ast_util::pat_binding_ids;
|
import syntax::ast_util::pat_binding_ids;
|
||||||
import syntax::visit;
|
import syntax::visit;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::int::str;
|
import std::int::str;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::option::*;
|
import std::option::*;
|
||||||
import std::int;
|
import std::int;
|
||||||
|
|
|
@ -37,7 +37,7 @@ import std::option;
|
||||||
import std::option::t;
|
import std::option::t;
|
||||||
import std::option::some;
|
import std::option::some;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import aux::*;
|
import aux::*;
|
||||||
import syntax::print::pprust::ty_to_str;
|
import syntax::print::pprust::ty_to_str;
|
||||||
import util::common::log_stmt_err;
|
import util::common::log_stmt_err;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
import std::option::some;
|
import std::option::some;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import syntax::print::pprust::path_to_str;
|
import syntax::print::pprust::path_to_str;
|
||||||
import util::ppaux::ty_to_str;
|
import util::ppaux::ty_to_str;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::option::get;
|
import std::option::get;
|
||||||
import std::option::is_none;
|
import std::option::is_none;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::box;
|
import std::box;
|
||||||
import std::ufind;
|
import std::ufind;
|
||||||
|
@ -1420,7 +1420,7 @@ fn hash_type_structure(st: &sty) -> uint {
|
||||||
ty_native_fn(_, args, rty) { ret hash_fn(28u, args, rty); }
|
ty_native_fn(_, args, rty) { ret hash_fn(28u, args, rty); }
|
||||||
ty_obj(methods) {
|
ty_obj(methods) {
|
||||||
let h = 29u;
|
let h = 29u;
|
||||||
for m: method in methods { h += h << 5u + istr::hash(m.ident); }
|
for m: method in methods { h += h << 5u + str::hash(m.ident); }
|
||||||
ret h;
|
ret h;
|
||||||
}
|
}
|
||||||
ty_var(v) { ret hash_uint(30u, v as uint); }
|
ty_var(v) { ret hash_uint(30u, v as uint); }
|
||||||
|
@ -1447,7 +1447,7 @@ fn hash_type_info(st: &sty, cname_opt: &option::t<istr>) -> uint {
|
||||||
let h = hash_type_structure(st);
|
let h = hash_type_structure(st);
|
||||||
alt cname_opt {
|
alt cname_opt {
|
||||||
none. {/* no-op */ }
|
none. {/* no-op */ }
|
||||||
some(s) { h += h << 5u + istr::hash(s); }
|
some(s) { h += h << 5u + str::hash(s); }
|
||||||
}
|
}
|
||||||
ret h;
|
ret h;
|
||||||
}
|
}
|
||||||
|
@ -1511,7 +1511,7 @@ fn eq_raw_ty(a: &@raw_t, b: &@raw_t) -> bool {
|
||||||
none. { alt b.cname { none. {/* ok */ } _ { ret false; } } }
|
none. { alt b.cname { none. {/* ok */ } _ { ret false; } } }
|
||||||
some(s_a) {
|
some(s_a) {
|
||||||
alt b.cname {
|
alt b.cname {
|
||||||
some(s_b) { if !istr::eq(s_a, s_b) { ret false; } }
|
some(s_b) { if !str::eq(s_a, s_b) { ret false; } }
|
||||||
_ { ret false; }
|
_ { ret false; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1708,7 +1708,7 @@ fn stmt_node_id(s: &@ast::stmt) -> ast::node_id {
|
||||||
fn field_idx(sess: &session::session, sp: &span, id: &ast::ident,
|
fn field_idx(sess: &session::session, sp: &span, id: &ast::ident,
|
||||||
fields: &[field]) -> uint {
|
fields: &[field]) -> uint {
|
||||||
let i: uint = 0u;
|
let i: uint = 0u;
|
||||||
for f: field in fields { if istr::eq(f.ident, id) { ret i; } i += 1u; }
|
for f: field in fields { if str::eq(f.ident, id) { ret i; } i += 1u; }
|
||||||
sess.span_fatal(sp, ~"unknown field '" +
|
sess.span_fatal(sp, ~"unknown field '" +
|
||||||
id + ~"' of record");
|
id + ~"' of record");
|
||||||
}
|
}
|
||||||
|
@ -1716,13 +1716,13 @@ fn field_idx(sess: &session::session, sp: &span, id: &ast::ident,
|
||||||
fn method_idx(sess: &session::session, sp: &span, id: &ast::ident,
|
fn method_idx(sess: &session::session, sp: &span, id: &ast::ident,
|
||||||
meths: &[method]) -> uint {
|
meths: &[method]) -> uint {
|
||||||
let i: uint = 0u;
|
let i: uint = 0u;
|
||||||
for m: method in meths { if istr::eq(m.ident, id) { ret i; } i += 1u; }
|
for m: method in meths { if str::eq(m.ident, id) { ret i; } i += 1u; }
|
||||||
sess.span_fatal(sp, ~"unknown method '" + id + ~"' of obj");
|
sess.span_fatal(sp, ~"unknown method '" + id + ~"' of obj");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sort_methods(meths: &[method]) -> [method] {
|
fn sort_methods(meths: &[method]) -> [method] {
|
||||||
fn method_lteq(a: &method, b: &method) -> bool {
|
fn method_lteq(a: &method, b: &method) -> bool {
|
||||||
ret istr::lteq(a.ident, b.ident);
|
ret str::lteq(a.ident, b.ident);
|
||||||
}
|
}
|
||||||
ret std::sort::merge_sort::<method>(bind method_lteq(_, _), meths);
|
ret std::sort::merge_sort::<method>(bind method_lteq(_, _), meths);
|
||||||
}
|
}
|
||||||
|
@ -2039,7 +2039,7 @@ mod unify {
|
||||||
while i < expected_len {
|
while i < expected_len {
|
||||||
let e_meth = expected_meths[i];
|
let e_meth = expected_meths[i];
|
||||||
let a_meth = actual_meths[i];
|
let a_meth = actual_meths[i];
|
||||||
if !istr::eq(e_meth.ident, a_meth.ident) {
|
if !str::eq(e_meth.ident, a_meth.ident) {
|
||||||
ret ures_err(terr_obj_meths(e_meth.ident, a_meth.ident));
|
ret ures_err(terr_obj_meths(e_meth.ident, a_meth.ident));
|
||||||
}
|
}
|
||||||
let r =
|
let r =
|
||||||
|
@ -2316,7 +2316,7 @@ mod unify {
|
||||||
none. { ret ures_err(terr_record_mutability); }
|
none. { ret ures_err(terr_record_mutability); }
|
||||||
some(m) { mut = m; }
|
some(m) { mut = m; }
|
||||||
}
|
}
|
||||||
if !istr::eq(expected_field.ident, actual_field.ident) {
|
if !str::eq(expected_field.ident, actual_field.ident) {
|
||||||
let err =
|
let err =
|
||||||
terr_record_fields(expected_field.ident,
|
terr_record_fields(expected_field.ident,
|
||||||
actual_field.ident);
|
actual_field.ident);
|
||||||
|
|
|
@ -36,7 +36,7 @@ import middle::ty::unify::fix_ok;
|
||||||
import middle::ty::unify::fix_err;
|
import middle::ty::unify::fix_err;
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::map;
|
import std::map;
|
||||||
import std::map::hashmap;
|
import std::map::hashmap;
|
||||||
|
@ -1443,7 +1443,7 @@ fn check_pat(fcx: &@fn_ctxt, map: &ast_util::pat_id_map, pat: &@ast::pat,
|
||||||
ex_f_count, f_count]);
|
ex_f_count, f_count]);
|
||||||
}
|
}
|
||||||
fn matches(name: &istr, f: &ty::field) -> bool {
|
fn matches(name: &istr, f: &ty::field) -> bool {
|
||||||
ret istr::eq(name, f.ident);
|
ret str::eq(name, f.ident);
|
||||||
}
|
}
|
||||||
for f: ast::field_pat in fields {
|
for f: ast::field_pat in fields {
|
||||||
alt vec::find(bind matches(f.ident, _), ex_fields) {
|
alt vec::find(bind matches(f.ident, _), ex_fields) {
|
||||||
|
@ -2233,7 +2233,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr, unify: &unifier,
|
||||||
for f: spanned<ty::field> in fields_t {
|
for f: spanned<ty::field> in fields_t {
|
||||||
let found = false;
|
let found = false;
|
||||||
for bf: ty::field in base_fields {
|
for bf: ty::field in base_fields {
|
||||||
if istr::eq(f.node.ident, bf.ident) {
|
if str::eq(f.node.ident, bf.ident) {
|
||||||
demand::simple(fcx, f.span, bf.mt.ty, f.node.mt.ty);
|
demand::simple(fcx, f.span, bf.mt.ty, f.node.mt.ty);
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
@ -2397,7 +2397,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr, unify: &unifier,
|
||||||
option::t<ty::method> {
|
option::t<ty::method> {
|
||||||
|
|
||||||
for om: @ast::method in outer_obj_methods {
|
for om: @ast::method in outer_obj_methods {
|
||||||
if istr::eq(om.node.ident, m.ident) {
|
if str::eq(om.node.ident, m.ident) {
|
||||||
// We'd better be overriding with one of the same
|
// We'd better be overriding with one of the same
|
||||||
// type. Check to make sure.
|
// type. Check to make sure.
|
||||||
let new_type = ty_of_method(ccx, om);
|
let new_type = ty_of_method(ccx, om);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::option;
|
import std::option;
|
||||||
import codemap::span;
|
import codemap::span;
|
||||||
import ast::*;
|
import ast::*;
|
||||||
|
@ -16,7 +16,7 @@ fn dummy_sp() -> span { ret mk_sp(0u, 0u); }
|
||||||
fn path_name(p: &path) -> istr { path_name_i(p.node.idents) }
|
fn path_name(p: &path) -> istr { path_name_i(p.node.idents) }
|
||||||
|
|
||||||
fn path_name_i(idents: &[ident]) -> istr {
|
fn path_name_i(idents: &[ident]) -> istr {
|
||||||
istr::connect(idents, ~"::")
|
str::connect(idents, ~"::")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn local_def(id: node_id) -> def_id { ret {crate: local_crate, node: id}; }
|
fn local_def(id: node_id) -> def_id { ret {crate: local_crate, node: id}; }
|
||||||
|
@ -157,7 +157,7 @@ fn is_exported(i: ident, m: _mod) -> bool {
|
||||||
for vi: @view_item in m.view_items {
|
for vi: @view_item in m.view_items {
|
||||||
alt vi.node {
|
alt vi.node {
|
||||||
view_item_export(ids, _) {
|
view_item_export(ids, _) {
|
||||||
for id in ids { if istr::eq(i, id) { ret true; } }
|
for id in ids { if str::eq(i, id) { ret true; } }
|
||||||
count += 1u;
|
count += 1u;
|
||||||
}
|
}
|
||||||
_ {/* fall through */ }
|
_ {/* fall through */ }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::term;
|
import std::term;
|
||||||
import std::io;
|
import std::io;
|
||||||
import std::option;
|
import std::option;
|
||||||
|
@ -148,13 +148,13 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
|
||||||
io::stdout().write_str(
|
io::stdout().write_str(
|
||||||
#ifmt[~"%s:%u ", fm.name, line + 1u]);
|
#ifmt[~"%s:%u ", fm.name, line + 1u]);
|
||||||
let s = get_line(fm, line as int, file);
|
let s = get_line(fm, line as int, file);
|
||||||
if !istr::ends_with(s, ~"\n") { s += ~"\n"; }
|
if !str::ends_with(s, ~"\n") { s += ~"\n"; }
|
||||||
io::stdout().write_str(s);
|
io::stdout().write_str(s);
|
||||||
}
|
}
|
||||||
if elided {
|
if elided {
|
||||||
let last_line = display_lines[vec::len(display_lines) - 1u];
|
let last_line = display_lines[vec::len(display_lines) - 1u];
|
||||||
let s = #ifmt[~"%s:%u ", fm.name, last_line + 1u];
|
let s = #ifmt[~"%s:%u ", fm.name, last_line + 1u];
|
||||||
let indent = istr::char_len(s);
|
let indent = str::char_len(s);
|
||||||
let out = ~"";
|
let out = ~"";
|
||||||
while indent > 0u { out += ~" "; indent -= 1u; }
|
while indent > 0u { out += ~" "; indent -= 1u; }
|
||||||
out += ~"...\n";
|
out += ~"...\n";
|
||||||
|
@ -172,16 +172,16 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
|
||||||
while num > 0u { num /= 10u; digits += 1u; }
|
while num > 0u { num /= 10u; digits += 1u; }
|
||||||
|
|
||||||
// indent past |name:## | and the 0-offset column location
|
// indent past |name:## | and the 0-offset column location
|
||||||
let left = istr::char_len(fm.name) + digits + lo.col + 3u;
|
let left = str::char_len(fm.name) + digits + lo.col + 3u;
|
||||||
let s = ~"";
|
let s = ~"";
|
||||||
while left > 0u { istr::push_char(s, ' '); left -= 1u; }
|
while left > 0u { str::push_char(s, ' '); left -= 1u; }
|
||||||
|
|
||||||
s += ~"^";
|
s += ~"^";
|
||||||
let hi = lookup_char_pos(cm, option::get(sp).hi);
|
let hi = lookup_char_pos(cm, option::get(sp).hi);
|
||||||
if hi.col != lo.col {
|
if hi.col != lo.col {
|
||||||
// the ^ already takes up one space
|
// the ^ already takes up one space
|
||||||
let width = hi.col - lo.col - 1u;
|
let width = hi.col - lo.col - 1u;
|
||||||
while width > 0u { istr::push_char(s, '~'); width -= 1u; }
|
while width > 0u { str::push_char(s, '~'); width -= 1u; }
|
||||||
}
|
}
|
||||||
io::stdout().write_str(s + ~"\n");
|
io::stdout().write_str(s + ~"\n");
|
||||||
}
|
}
|
||||||
|
@ -221,12 +221,12 @@ fn get_line(fm: filemap, line: int, file: &istr) -> istr {
|
||||||
// If we're not done parsing the file, we're at the limit of what's
|
// If we're not done parsing the file, we're at the limit of what's
|
||||||
// parsed. If we just slice the rest of the string, we'll print out
|
// parsed. If we just slice the rest of the string, we'll print out
|
||||||
// the remainder of the file, which is undesirable.
|
// the remainder of the file, which is undesirable.
|
||||||
end = istr::byte_len(file);
|
end = str::byte_len(file);
|
||||||
let rest = istr::slice(file, begin, end);
|
let rest = str::slice(file, begin, end);
|
||||||
let newline = istr::index(rest, '\n' as u8);
|
let newline = str::index(rest, '\n' as u8);
|
||||||
if newline != -1 { end = begin + (newline as uint); }
|
if newline != -1 { end = begin + (newline as uint); }
|
||||||
}
|
}
|
||||||
ret istr::slice(file, begin, end);
|
ret str::slice(file, begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_filemap(cm: codemap, filename: istr) -> filemap {
|
fn get_filemap(cm: codemap, filename: istr) -> filemap {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::map::hashmap;
|
import std::map::hashmap;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* interface.
|
* interface.
|
||||||
*/
|
*/
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::generic_os;
|
import std::generic_os;
|
||||||
import base::*;
|
import base::*;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import std::option::some;
|
||||||
|
|
||||||
import std::map::hashmap;
|
import std::map::hashmap;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
|
|
||||||
import syntax::ast::crate;
|
import syntax::ast::crate;
|
||||||
import syntax::ast::expr_;
|
import syntax::ast::expr_;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::option;
|
import std::option;
|
||||||
import base::*;
|
import base::*;
|
||||||
import syntax::ast;
|
import syntax::ast;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* compiler syntax extension plugin interface.
|
* compiler syntax extension plugin interface.
|
||||||
*/
|
*/
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
import std::option::some;
|
import std::option::some;
|
||||||
|
@ -103,7 +103,7 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
|
||||||
}
|
}
|
||||||
fn make_path_vec(cx: &ext_ctxt, ident: &ast::ident) -> [ast::ident] {
|
fn make_path_vec(cx: &ext_ctxt, ident: &ast::ident) -> [ast::ident] {
|
||||||
fn compiling_std(cx: &ext_ctxt) -> bool {
|
fn compiling_std(cx: &ext_ctxt) -> bool {
|
||||||
ret istr::find(cx.crate_file_name(), ~"std.rc") >= 0;
|
ret str::find(cx.crate_file_name(), ~"std.rc") >= 0;
|
||||||
}
|
}
|
||||||
if compiling_std(cx) {
|
if compiling_std(cx) {
|
||||||
ret [~"extifmt", ~"rt", ident];
|
ret [~"extifmt", ~"rt", ident];
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import std::option;
|
import std::option;
|
||||||
import base::*;
|
import base::*;
|
||||||
import syntax::ast;
|
import syntax::ast;
|
||||||
import std::istr;
|
import std::str;
|
||||||
|
|
||||||
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
|
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
|
||||||
_body: &option::t<istr>) -> @ast::expr {
|
_body: &option::t<istr>) -> @ast::expr {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std;
|
||||||
|
|
||||||
import codemap::span;
|
import codemap::span;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::map::hashmap;
|
import std::map::hashmap;
|
||||||
import std::map::new_str_hash;
|
import std::map::new_str_hash;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::option::some;
|
import std::option::some;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import std::io;
|
import std::io;
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::map;
|
import std::map;
|
||||||
import std::map::hashmap;
|
import std::map::hashmap;
|
||||||
import std::option;
|
import std::option;
|
||||||
|
@ -44,19 +44,19 @@ fn new_reader(cm: &codemap::codemap, src: &istr, filemap: codemap::filemap,
|
||||||
fn get_str_from(start: uint) -> istr {
|
fn get_str_from(start: uint) -> istr {
|
||||||
// I'm pretty skeptical about this subtraction. What if there's a
|
// I'm pretty skeptical about this subtraction. What if there's a
|
||||||
// multi-byte character before the mark?
|
// multi-byte character before the mark?
|
||||||
ret istr::slice(src, start - 1u, pos - 1u);
|
ret str::slice(src, start - 1u, pos - 1u);
|
||||||
}
|
}
|
||||||
fn get_chpos() -> uint { ret chpos; }
|
fn get_chpos() -> uint { ret chpos; }
|
||||||
fn get_byte_pos() -> uint { ret pos; }
|
fn get_byte_pos() -> uint { ret pos; }
|
||||||
fn curr() -> char { ret ch; }
|
fn curr() -> char { ret ch; }
|
||||||
fn next() -> char {
|
fn next() -> char {
|
||||||
if pos < len {
|
if pos < len {
|
||||||
ret istr::char_at(src, pos);
|
ret str::char_at(src, pos);
|
||||||
} else { ret -1 as char; }
|
} else { ret -1 as char; }
|
||||||
}
|
}
|
||||||
fn init() {
|
fn init() {
|
||||||
if pos < len {
|
if pos < len {
|
||||||
let next = istr::char_range_at(src, pos);
|
let next = str::char_range_at(src, pos);
|
||||||
pos = next.next;
|
pos = next.next;
|
||||||
ch = next.ch;
|
ch = next.ch;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ fn new_reader(cm: &codemap::codemap, src: &istr, filemap: codemap::filemap,
|
||||||
codemap::next_line(fm, chpos, pos + fm.start_pos.byte);
|
codemap::next_line(fm, chpos, pos + fm.start_pos.byte);
|
||||||
col = 0u;
|
col = 0u;
|
||||||
}
|
}
|
||||||
let next = istr::char_range_at(src, pos);
|
let next = str::char_range_at(src, pos);
|
||||||
pos = next.next;
|
pos = next.next;
|
||||||
ch = next.ch;
|
ch = next.ch;
|
||||||
} else { ch = -1 as char; }
|
} else { ch = -1 as char; }
|
||||||
|
@ -85,7 +85,7 @@ fn new_reader(cm: &codemap::codemap, src: &istr, filemap: codemap::filemap,
|
||||||
}
|
}
|
||||||
let strs: [istr] = [];
|
let strs: [istr] = [];
|
||||||
let rd =
|
let rd =
|
||||||
reader(cm, src, istr::byte_len(src), 0u, 0u, -1 as char,
|
reader(cm, src, str::byte_len(src), 0u, 0u, -1 as char,
|
||||||
filemap.start_pos.ch, strs, filemap, itr);
|
filemap.start_pos.ch, strs, filemap, itr);
|
||||||
rd.init();
|
rd.init();
|
||||||
ret rd;
|
ret rd;
|
||||||
|
@ -178,15 +178,15 @@ fn scan_exponent(rdr: &reader) -> option::t<istr> {
|
||||||
let c = rdr.curr();
|
let c = rdr.curr();
|
||||||
let rslt = ~"";
|
let rslt = ~"";
|
||||||
if c == 'e' || c == 'E' {
|
if c == 'e' || c == 'E' {
|
||||||
rslt += istr::unsafe_from_bytes([c as u8]);
|
rslt += str::unsafe_from_bytes([c as u8]);
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
c = rdr.curr();
|
c = rdr.curr();
|
||||||
if c == '-' || c == '+' {
|
if c == '-' || c == '+' {
|
||||||
rslt += istr::unsafe_from_bytes([c as u8]);
|
rslt += str::unsafe_from_bytes([c as u8]);
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
}
|
}
|
||||||
let exponent = scan_dec_digits(rdr);
|
let exponent = scan_dec_digits(rdr);
|
||||||
if istr::byte_len(exponent) > 0u {
|
if str::byte_len(exponent) > 0u {
|
||||||
ret some(rslt + exponent);
|
ret some(rslt + exponent);
|
||||||
} else { rdr.err(~"scan_exponent: bad fp literal"); fail; }
|
} else { rdr.err(~"scan_exponent: bad fp literal"); fail; }
|
||||||
} else { ret none::<istr>; }
|
} else { ret none::<istr>; }
|
||||||
|
@ -196,7 +196,7 @@ fn scan_dec_digits(rdr: &reader) -> istr {
|
||||||
let c = rdr.curr();
|
let c = rdr.curr();
|
||||||
let rslt: istr = ~"";
|
let rslt: istr = ~"";
|
||||||
while is_dec_digit(c) || c == '_' {
|
while is_dec_digit(c) || c == '_' {
|
||||||
if c != '_' { rslt += istr::unsafe_from_bytes([c as u8]); }
|
if c != '_' { rslt += str::unsafe_from_bytes([c as u8]); }
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
c = rdr.curr();
|
c = rdr.curr();
|
||||||
}
|
}
|
||||||
|
@ -348,11 +348,11 @@ fn next_token_inner(rdr: &reader) -> token::token {
|
||||||
let c = rdr.curr();
|
let c = rdr.curr();
|
||||||
if is_alpha(c) || c == '_' {
|
if is_alpha(c) || c == '_' {
|
||||||
while is_alnum(c) || c == '_' {
|
while is_alnum(c) || c == '_' {
|
||||||
istr::push_char(accum_str, c);
|
str::push_char(accum_str, c);
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
c = rdr.curr();
|
c = rdr.curr();
|
||||||
}
|
}
|
||||||
if istr::eq(accum_str, ~"_") { ret token::UNDERSCORE; }
|
if str::eq(accum_str, ~"_") { ret token::UNDERSCORE; }
|
||||||
let is_mod_name = c == ':' && rdr.next() == ':';
|
let is_mod_name = c == ':' && rdr.next() == ':';
|
||||||
ret token::IDENT(interner::intern::<istr>(
|
ret token::IDENT(interner::intern::<istr>(
|
||||||
*rdr.get_interner(),
|
*rdr.get_interner(),
|
||||||
|
@ -493,20 +493,20 @@ fn next_token_inner(rdr: &reader) -> token::token {
|
||||||
let escaped = rdr.curr();
|
let escaped = rdr.curr();
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
alt escaped {
|
alt escaped {
|
||||||
'n' { istr::push_byte(accum_str, '\n' as u8); }
|
'n' { str::push_byte(accum_str, '\n' as u8); }
|
||||||
'r' { istr::push_byte(accum_str, '\r' as u8); }
|
'r' { str::push_byte(accum_str, '\r' as u8); }
|
||||||
't' { istr::push_byte(accum_str, '\t' as u8); }
|
't' { str::push_byte(accum_str, '\t' as u8); }
|
||||||
'\\' { istr::push_byte(accum_str, '\\' as u8); }
|
'\\' { str::push_byte(accum_str, '\\' as u8); }
|
||||||
'"' { istr::push_byte(accum_str, '"' as u8); }
|
'"' { str::push_byte(accum_str, '"' as u8); }
|
||||||
'\n' { consume_whitespace(rdr); }
|
'\n' { consume_whitespace(rdr); }
|
||||||
'x' {
|
'x' {
|
||||||
istr::push_char(accum_str, scan_numeric_escape(rdr, 2u));
|
str::push_char(accum_str, scan_numeric_escape(rdr, 2u));
|
||||||
}
|
}
|
||||||
'u' {
|
'u' {
|
||||||
istr::push_char(accum_str, scan_numeric_escape(rdr, 4u));
|
str::push_char(accum_str, scan_numeric_escape(rdr, 4u));
|
||||||
}
|
}
|
||||||
'U' {
|
'U' {
|
||||||
istr::push_char(accum_str, scan_numeric_escape(rdr, 8u));
|
str::push_char(accum_str, scan_numeric_escape(rdr, 8u));
|
||||||
}
|
}
|
||||||
c2 {
|
c2 {
|
||||||
rdr.err(
|
rdr.err(
|
||||||
|
@ -516,7 +516,7 @@ fn next_token_inner(rdr: &reader) -> token::token {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ { istr::push_char(accum_str, ch); }
|
_ { str::push_char(accum_str, ch); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
|
@ -569,7 +569,7 @@ type cmnt = {style: cmnt_style, lines: [istr], pos: uint};
|
||||||
fn read_to_eol(rdr: &reader) -> istr {
|
fn read_to_eol(rdr: &reader) -> istr {
|
||||||
let val = ~"";
|
let val = ~"";
|
||||||
while rdr.curr() != '\n' && !rdr.is_eof() {
|
while rdr.curr() != '\n' && !rdr.is_eof() {
|
||||||
istr::push_char(val, rdr.curr());
|
str::push_char(val, rdr.curr());
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
}
|
}
|
||||||
if rdr.curr() == '\n' { rdr.bump(); }
|
if rdr.curr() == '\n' { rdr.bump(); }
|
||||||
|
@ -634,8 +634,8 @@ fn trim_whitespace_prefix_and_push_line(lines: &mutable [istr], s: &istr,
|
||||||
col: uint) {
|
col: uint) {
|
||||||
let s1;
|
let s1;
|
||||||
if all_whitespace(s, 0u, col) {
|
if all_whitespace(s, 0u, col) {
|
||||||
if col < istr::byte_len(s) {
|
if col < str::byte_len(s) {
|
||||||
s1 = istr::slice(s, col, istr::byte_len(s));
|
s1 = str::slice(s, col, str::byte_len(s));
|
||||||
} else { s1 = ~""; }
|
} else { s1 = ~""; }
|
||||||
} else { s1 = s; }
|
} else { s1 = s; }
|
||||||
log ~"pushing line: " + s1;
|
log ~"pushing line: " + s1;
|
||||||
|
@ -659,7 +659,7 @@ fn read_block_comment(rdr: &reader, code_to_the_left: bool) -> cmnt {
|
||||||
curr_line = ~"";
|
curr_line = ~"";
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
} else {
|
} else {
|
||||||
istr::push_char(curr_line, rdr.curr());
|
str::push_char(curr_line, rdr.curr());
|
||||||
if rdr.curr() == '/' && rdr.next() == '*' {
|
if rdr.curr() == '/' && rdr.next() == '*' {
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
|
@ -675,7 +675,7 @@ fn read_block_comment(rdr: &reader, code_to_the_left: bool) -> cmnt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if istr::byte_len(curr_line) != 0u {
|
if str::byte_len(curr_line) != 0u {
|
||||||
trim_whitespace_prefix_and_push_line(lines, curr_line, col);
|
trim_whitespace_prefix_and_push_line(lines, curr_line, col);
|
||||||
}
|
}
|
||||||
let style = if code_to_the_left { trailing } else { isolated };
|
let style = if code_to_the_left { trailing } else { isolated };
|
||||||
|
@ -722,8 +722,8 @@ type lit = {lit: istr, pos: uint};
|
||||||
fn gather_comments_and_literals(cm: &codemap::codemap, path: &istr,
|
fn gather_comments_and_literals(cm: &codemap::codemap, path: &istr,
|
||||||
srdr: io::reader) ->
|
srdr: io::reader) ->
|
||||||
{cmnts: [cmnt], lits: [lit]} {
|
{cmnts: [cmnt], lits: [lit]} {
|
||||||
let src = istr::unsafe_from_bytes(srdr.read_whole_stream());
|
let src = str::unsafe_from_bytes(srdr.read_whole_stream());
|
||||||
let itr = @interner::mk::<istr>(istr::hash, istr::eq);
|
let itr = @interner::mk::<istr>(str::hash, str::eq);
|
||||||
let rdr = new_reader(cm, src,
|
let rdr = new_reader(cm, src,
|
||||||
codemap::new_filemap(
|
codemap::new_filemap(
|
||||||
path, 0u, 0u), itr);
|
path, 0u, 0u), itr);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
import std::io;
|
import std::io;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::option::some;
|
import std::option::some;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
|
@ -66,7 +66,7 @@ fn new_parser_from_file(sess: parse_sess, cfg: &ast::crate_cfg, path: &istr,
|
||||||
let filemap = codemap::new_filemap(
|
let filemap = codemap::new_filemap(
|
||||||
path, chpos, byte_pos);
|
path, chpos, byte_pos);
|
||||||
sess.cm.files += [filemap];
|
sess.cm.files += [filemap];
|
||||||
let itr = @interner::mk(istr::hash, istr::eq);
|
let itr = @interner::mk(str::hash, str::eq);
|
||||||
let rdr = lexer::new_reader(sess.cm, src, filemap, itr);
|
let rdr = lexer::new_reader(sess.cm, src, filemap, itr);
|
||||||
ret new_parser(sess, cfg, rdr, ftype);
|
ret new_parser(sess, cfg, rdr, ftype);
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ fn eat(p: &parser, tok: &token::token) -> bool {
|
||||||
|
|
||||||
fn is_word(p: &parser, word: &istr) -> bool {
|
fn is_word(p: &parser, word: &istr) -> bool {
|
||||||
ret alt p.peek() {
|
ret alt p.peek() {
|
||||||
token::IDENT(sid, false) { istr::eq(word, p.get_str(sid)) }
|
token::IDENT(sid, false) { str::eq(word, p.get_str(sid)) }
|
||||||
_ { false }
|
_ { false }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ fn is_word(p: &parser, word: &istr) -> bool {
|
||||||
fn eat_word(p: &parser, word: &istr) -> bool {
|
fn eat_word(p: &parser, word: &istr) -> bool {
|
||||||
alt p.peek() {
|
alt p.peek() {
|
||||||
token::IDENT(sid, false) {
|
token::IDENT(sid, false) {
|
||||||
if istr::eq(word, p.get_str(sid)) {
|
if str::eq(word, p.get_str(sid)) {
|
||||||
p.bump();
|
p.bump();
|
||||||
ret true;
|
ret true;
|
||||||
} else { ret false; }
|
} else { ret false; }
|
||||||
|
@ -2036,14 +2036,14 @@ fn parse_item_native_mod(p: &parser, attrs: &[ast::attribute]) -> @ast::item {
|
||||||
let abi = ast::native_abi_cdecl;
|
let abi = ast::native_abi_cdecl;
|
||||||
if !is_word(p, ~"mod") {
|
if !is_word(p, ~"mod") {
|
||||||
let t = parse_str(p);
|
let t = parse_str(p);
|
||||||
if istr::eq(t, ~"cdecl") {
|
if str::eq(t, ~"cdecl") {
|
||||||
} else if istr::eq(t, ~"rust") {
|
} else if str::eq(t, ~"rust") {
|
||||||
abi = ast::native_abi_rust;
|
abi = ast::native_abi_rust;
|
||||||
} else if istr::eq(t, ~"llvm") {
|
} else if str::eq(t, ~"llvm") {
|
||||||
abi = ast::native_abi_llvm;
|
abi = ast::native_abi_llvm;
|
||||||
} else if istr::eq(t, ~"rust-intrinsic") {
|
} else if str::eq(t, ~"rust-intrinsic") {
|
||||||
abi = ast::native_abi_rust_intrinsic;
|
abi = ast::native_abi_rust_intrinsic;
|
||||||
} else if istr::eq(t, ~"x86stdcall") {
|
} else if str::eq(t, ~"x86stdcall") {
|
||||||
abi = ast::native_abi_x86stdcall;
|
abi = ast::native_abi_x86stdcall;
|
||||||
} else { p.fatal(~"unsupported abi: " + t); }
|
} else { p.fatal(~"unsupported abi: " + t); }
|
||||||
}
|
}
|
||||||
|
@ -2419,8 +2419,8 @@ fn is_view_item(p: &parser) -> bool {
|
||||||
alt p.peek() {
|
alt p.peek() {
|
||||||
token::IDENT(sid, false) {
|
token::IDENT(sid, false) {
|
||||||
let st = p.get_str(sid);
|
let st = p.get_str(sid);
|
||||||
ret istr::eq(st, ~"use") || istr::eq(st, ~"import") ||
|
ret str::eq(st, ~"use") || str::eq(st, ~"import") ||
|
||||||
istr::eq(st, ~"export");
|
str::eq(st, ~"export");
|
||||||
}
|
}
|
||||||
_ { ret false; }
|
_ { ret false; }
|
||||||
}
|
}
|
||||||
|
@ -2450,7 +2450,7 @@ fn parse_crate_from_source_str(name: &istr, source: &istr,
|
||||||
let ftype = SOURCE_FILE;
|
let ftype = SOURCE_FILE;
|
||||||
let filemap = codemap::new_filemap(name, 0u, 0u);
|
let filemap = codemap::new_filemap(name, 0u, 0u);
|
||||||
sess.cm.files += [filemap];
|
sess.cm.files += [filemap];
|
||||||
let itr = @interner::mk(istr::hash, istr::eq);
|
let itr = @interner::mk(str::hash, str::eq);
|
||||||
let rdr = lexer::new_reader(sess.cm, source,
|
let rdr = lexer::new_reader(sess.cm, source,
|
||||||
filemap, itr);
|
filemap, itr);
|
||||||
let p = new_parser(sess, cfg, rdr, ftype);
|
let p = new_parser(sess, cfg, rdr, ftype);
|
||||||
|
@ -2588,9 +2588,9 @@ fn parse_crate_from_crate_file(input: &istr, cfg: &ast::crate_cfg,
|
||||||
|
|
||||||
fn parse_crate_from_file(input: &istr, cfg: &ast::crate_cfg,
|
fn parse_crate_from_file(input: &istr, cfg: &ast::crate_cfg,
|
||||||
sess: &parse_sess) -> @ast::crate {
|
sess: &parse_sess) -> @ast::crate {
|
||||||
if istr::ends_with(input, ~".rc") {
|
if str::ends_with(input, ~".rc") {
|
||||||
parse_crate_from_crate_file(input, cfg, sess)
|
parse_crate_from_crate_file(input, cfg, sess)
|
||||||
} else if istr::ends_with(input, ~".rs") {
|
} else if str::ends_with(input, ~".rs") {
|
||||||
parse_crate_from_source_file(input, cfg, sess)
|
parse_crate_from_source_file(input, cfg, sess)
|
||||||
} else {
|
} else {
|
||||||
codemap::emit_error(none, ~"unknown input file type: "
|
codemap::emit_error(none, ~"unknown input file type: "
|
||||||
|
|
|
@ -5,7 +5,7 @@ import std::map::new_str_hash;
|
||||||
import util::interner;
|
import util::interner;
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::istr;
|
import std::str;
|
||||||
|
|
||||||
type str_num = uint;
|
type str_num = uint;
|
||||||
|
|
||||||
|
@ -166,8 +166,8 @@ fn to_str(r: lexer::reader, t: token) -> istr {
|
||||||
LIT_CHAR(c) {
|
LIT_CHAR(c) {
|
||||||
// FIXME: escape.
|
// FIXME: escape.
|
||||||
let tmp = ~"'";
|
let tmp = ~"'";
|
||||||
istr::push_char(tmp, c);
|
str::push_char(tmp, c);
|
||||||
istr::push_byte(tmp, '\'' as u8);
|
str::push_byte(tmp, '\'' as u8);
|
||||||
ret tmp;
|
ret tmp;
|
||||||
}
|
}
|
||||||
LIT_BOOL(b) { if b { ret ~"true"; } else { ret ~"false"; } }
|
LIT_BOOL(b) { if b { ret ~"true"; } else { ret ~"false"; } }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
import std::io;
|
import std::io;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This pretty-printer is a direct reimplementation of Philip Karlton's
|
* This pretty-printer is a direct reimplementation of Philip Karlton's
|
||||||
|
@ -496,7 +496,7 @@ fn end(p: printer) { p.pretty_print(END); }
|
||||||
fn eof(p: printer) { p.pretty_print(EOF); }
|
fn eof(p: printer) { p.pretty_print(EOF); }
|
||||||
|
|
||||||
fn word(p: printer, wrd: &istr) {
|
fn word(p: printer, wrd: &istr) {
|
||||||
p.pretty_print(STRING(wrd, istr::char_len(wrd) as int));
|
p.pretty_print(STRING(wrd, str::char_len(wrd) as int));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn huge_word(p: printer, wrd: &istr) {
|
fn huge_word(p: printer, wrd: &istr) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::io;
|
import std::io;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::option;
|
import std::option;
|
||||||
import parse::lexer;
|
import parse::lexer;
|
||||||
|
@ -156,7 +156,7 @@ fn head(s: &ps, w: &istr) {
|
||||||
// outer-box is consistent
|
// outer-box is consistent
|
||||||
cbox(s, indent_unit);
|
cbox(s, indent_unit);
|
||||||
// head-box is inconsistent
|
// head-box is inconsistent
|
||||||
ibox(s, istr::char_len(w) + 1u);
|
ibox(s, str::char_len(w) + 1u);
|
||||||
// keyword that starts the head
|
// keyword that starts the head
|
||||||
word_nbsp(s, w);
|
word_nbsp(s, w);
|
||||||
}
|
}
|
||||||
|
@ -432,7 +432,7 @@ fn print_item(s: &ps, item: &@ast::item) {
|
||||||
}
|
}
|
||||||
word_nbsp(s, ~"mod");
|
word_nbsp(s, ~"mod");
|
||||||
word_nbsp(s, item.ident);
|
word_nbsp(s, item.ident);
|
||||||
if !istr::eq(nmod.native_name, item.ident) {
|
if !str::eq(nmod.native_name, item.ident) {
|
||||||
word_space(s, ~"=");
|
word_space(s, ~"=");
|
||||||
print_string(s, nmod.native_name);
|
print_string(s, nmod.native_name);
|
||||||
nbsp(s);
|
nbsp(s);
|
||||||
|
@ -458,7 +458,7 @@ fn print_item(s: &ps, item: &@ast::item) {
|
||||||
ast::item_tag(variants, params) {
|
ast::item_tag(variants, params) {
|
||||||
let newtype =
|
let newtype =
|
||||||
vec::len(variants) == 1u &&
|
vec::len(variants) == 1u &&
|
||||||
istr::eq(item.ident, variants[0].node.name) &&
|
str::eq(item.ident, variants[0].node.name) &&
|
||||||
vec::len(variants[0].node.args) == 1u;
|
vec::len(variants[0].node.args) == 1u;
|
||||||
if newtype {
|
if newtype {
|
||||||
ibox(s, indent_unit);
|
ibox(s, indent_unit);
|
||||||
|
@ -1318,7 +1318,7 @@ fn print_view_item(s: &ps, item: &@ast::view_item) {
|
||||||
}
|
}
|
||||||
ast::view_item_import(id, ids, _) {
|
ast::view_item_import(id, ids, _) {
|
||||||
head(s, ~"import");
|
head(s, ~"import");
|
||||||
if !istr::eq(id, ids[vec::len(ids) - 1u]) {
|
if !str::eq(id, ids[vec::len(ids) - 1u]) {
|
||||||
word_space(s, id);
|
word_space(s, id);
|
||||||
word_space(s, ~"=");
|
word_space(s, ~"=");
|
||||||
}
|
}
|
||||||
|
@ -1510,7 +1510,7 @@ fn print_literal(s: &ps, lit: &@ast::lit) {
|
||||||
}
|
}
|
||||||
ast::lit_char(ch) {
|
ast::lit_char(ch) {
|
||||||
word(s.s,
|
word(s.s,
|
||||||
~"'" + escape_str(istr::unsafe_from_bytes([ch as u8]), '\'') +
|
~"'" + escape_str(str::unsafe_from_bytes([ch as u8]), '\'') +
|
||||||
~"'");
|
~"'");
|
||||||
}
|
}
|
||||||
ast::lit_int(val) { word(s.s, int::str(val)); }
|
ast::lit_int(val) { word(s.s, int::str(val)); }
|
||||||
|
@ -1572,7 +1572,7 @@ fn print_comment(s: &ps, cmnt: lexer::cmnt) {
|
||||||
for line: istr in cmnt.lines {
|
for line: istr in cmnt.lines {
|
||||||
// Don't print empty lines because they will end up as trailing
|
// Don't print empty lines because they will end up as trailing
|
||||||
// whitespace
|
// whitespace
|
||||||
if istr::is_not_empty(line) {
|
if str::is_not_empty(line) {
|
||||||
word(s.s, line);
|
word(s.s, line);
|
||||||
}
|
}
|
||||||
hardbreak(s.s);
|
hardbreak(s.s);
|
||||||
|
@ -1586,7 +1586,7 @@ fn print_comment(s: &ps, cmnt: lexer::cmnt) {
|
||||||
} else {
|
} else {
|
||||||
ibox(s, 0u);
|
ibox(s, 0u);
|
||||||
for line: istr in cmnt.lines {
|
for line: istr in cmnt.lines {
|
||||||
if istr::is_not_empty(line) {
|
if str::is_not_empty(line) {
|
||||||
word(s.s, line);
|
word(s.s, line);
|
||||||
}
|
}
|
||||||
hardbreak(s.s);
|
hardbreak(s.s);
|
||||||
|
@ -1615,7 +1615,7 @@ fn print_string(s: &ps, st: &istr) {
|
||||||
|
|
||||||
fn escape_str(st: &istr, to_escape: char) -> istr {
|
fn escape_str(st: &istr, to_escape: char) -> istr {
|
||||||
let out: istr = ~"";
|
let out: istr = ~"";
|
||||||
let len = istr::byte_len(st);
|
let len = str::byte_len(st);
|
||||||
let i = 0u;
|
let i = 0u;
|
||||||
while i < len {
|
while i < len {
|
||||||
alt st[i] as char {
|
alt st[i] as char {
|
||||||
|
@ -1627,7 +1627,7 @@ fn escape_str(st: &istr, to_escape: char) -> istr {
|
||||||
if cur == to_escape { out += ~"\\"; }
|
if cur == to_escape { out += ~"\\"; }
|
||||||
// FIXME some (or all?) non-ascii things should be escaped
|
// FIXME some (or all?) non-ascii things should be escaped
|
||||||
|
|
||||||
istr::push_char(out, cur);
|
str::push_char(out, cur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i += 1u;
|
i += 1u;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::map;
|
import std::map;
|
||||||
import std::map::hashmap;
|
import std::map::hashmap;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
|
@ -154,7 +154,7 @@ fn call_kind_str(c: call_kind) -> istr {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_main_name(path: &[ast::ident]) -> bool {
|
fn is_main_name(path: &[ast::ident]) -> bool {
|
||||||
istr::eq(option::get(std::vec::last(path)), ~"main")
|
str::eq(option::get(std::vec::last(path)), ~"main")
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME mode this to std::float when editing the stdlib no longer
|
// FIXME mode this to std::float when editing the stdlib no longer
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
|
@ -44,7 +44,7 @@ fn fn_ident_to_string(id: ast::node_id, i: &ast::fn_ident) -> istr {
|
||||||
fn get_id_ident(cx: &ctxt, id: ast::def_id) -> istr {
|
fn get_id_ident(cx: &ctxt, id: ast::def_id) -> istr {
|
||||||
if id.crate != ast::local_crate {
|
if id.crate != ast::local_crate {
|
||||||
alt cx.ext_map.find(id) {
|
alt cx.ext_map.find(id) {
|
||||||
some(j) { istr::connect(j, ~"::") }
|
some(j) { str::connect(j, ~"::") }
|
||||||
_ { fail (~"get_id_ident: can't find item in ext_map, id.crate = "
|
_ { fail (~"get_id_ident: can't find item in ext_map, id.crate = "
|
||||||
+ int::str(id.crate)) }
|
+ int::str(id.crate)) }
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> istr {
|
||||||
s += ~"(";
|
s += ~"(";
|
||||||
let strs = [];
|
let strs = [];
|
||||||
for a: arg in inputs { strs += [fn_input_to_str(cx, a)]; }
|
for a: arg in inputs { strs += [fn_input_to_str(cx, a)]; }
|
||||||
s += istr::connect(strs, ~", ");
|
s += str::connect(strs, ~", ");
|
||||||
s += ~")";
|
s += ~")";
|
||||||
if struct(cx, output) != ty_nil {
|
if struct(cx, output) != ty_nil {
|
||||||
alt cf {
|
alt cf {
|
||||||
|
@ -128,19 +128,19 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> istr {
|
||||||
ty_rec(elems) {
|
ty_rec(elems) {
|
||||||
let strs: [istr] = [];
|
let strs: [istr] = [];
|
||||||
for fld: field in elems { strs += [field_to_str(cx, fld)]; }
|
for fld: field in elems { strs += [field_to_str(cx, fld)]; }
|
||||||
~"{" + istr::connect(strs, ~",") + ~"}"
|
~"{" + str::connect(strs, ~",") + ~"}"
|
||||||
}
|
}
|
||||||
ty_tup(elems) {
|
ty_tup(elems) {
|
||||||
let strs = [];
|
let strs = [];
|
||||||
for elem in elems { strs += [ty_to_str(cx, elem)]; }
|
for elem in elems { strs += [ty_to_str(cx, elem)]; }
|
||||||
~"(" + istr::connect(strs, ~",") + ~")"
|
~"(" + str::connect(strs, ~",") + ~")"
|
||||||
}
|
}
|
||||||
ty_tag(id, tps) {
|
ty_tag(id, tps) {
|
||||||
let s = get_id_ident(cx, id);
|
let s = get_id_ident(cx, id);
|
||||||
if vec::len::<t>(tps) > 0u {
|
if vec::len::<t>(tps) > 0u {
|
||||||
let strs: [istr] = [];
|
let strs: [istr] = [];
|
||||||
for typ: t in tps { strs += [ty_to_str(cx, typ)]; }
|
for typ: t in tps { strs += [ty_to_str(cx, typ)]; }
|
||||||
s += ~"[" + istr::connect(strs, ~",") + ~"]";
|
s += ~"[" + str::connect(strs, ~",") + ~"]";
|
||||||
}
|
}
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
@ -154,12 +154,12 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> istr {
|
||||||
ty_obj(meths) {
|
ty_obj(meths) {
|
||||||
let strs = [];
|
let strs = [];
|
||||||
for m: method in meths { strs += [method_to_str(cx, m)]; }
|
for m: method in meths { strs += [method_to_str(cx, m)]; }
|
||||||
~"obj {\n\t" + istr::connect(strs, ~"\n\t") + ~"\n}"
|
~"obj {\n\t" + str::connect(strs, ~"\n\t") + ~"\n}"
|
||||||
}
|
}
|
||||||
ty_res(id, _, _) { get_id_ident(cx, id) }
|
ty_res(id, _, _) { get_id_ident(cx, id) }
|
||||||
ty_var(v) { ~"<T" + int::str(v) + ~">" }
|
ty_var(v) { ~"<T" + int::str(v) + ~">" }
|
||||||
ty_param(id, _) {
|
ty_param(id, _) {
|
||||||
~"'" + istr::unsafe_from_bytes([('a' as u8) + (id as u8)])
|
~"'" + str::unsafe_from_bytes([('a' as u8) + (id as u8)])
|
||||||
}
|
}
|
||||||
_ { ty_to_short_str(cx, typ) }
|
_ { ty_to_short_str(cx, typ) }
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> istr {
|
||||||
|
|
||||||
fn ty_to_short_str(cx: &ctxt, typ: t) -> istr {
|
fn ty_to_short_str(cx: &ctxt, typ: t) -> istr {
|
||||||
let s = encoder::encoded_ty(cx, typ);
|
let s = encoder::encoded_ty(cx, typ);
|
||||||
if istr::byte_len(s) >= 32u { s = istr::substr(s, 0u, 32u); }
|
if str::byte_len(s) >= 32u { s = str::substr(s, 0u, 32u); }
|
||||||
ret s;
|
ret s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import std::getopts::opt_str;
|
||||||
import std::io;
|
import std::io;
|
||||||
import std::io::stdout;
|
import std::io::stdout;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::option;
|
import std::option;
|
||||||
|
|
||||||
|
@ -28,20 +28,20 @@ fn write_file(filename: &istr, content: &istr) {
|
||||||
|
|
||||||
fn file_contains(filename: &istr, needle: &istr) -> bool {
|
fn file_contains(filename: &istr, needle: &istr) -> bool {
|
||||||
let contents = io::read_whole_file_str(filename);
|
let contents = io::read_whole_file_str(filename);
|
||||||
ret istr::find(contents, needle) != -1;
|
ret str::find(contents, needle) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn contains(haystack: &istr, needle: &istr) -> bool {
|
fn contains(haystack: &istr, needle: &istr) -> bool {
|
||||||
istr::find(haystack, needle) != -1
|
str::find(haystack, needle) != -1
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_rust_files(files: &mutable [istr], path: &istr) {
|
fn find_rust_files(files: &mutable [istr], path: &istr) {
|
||||||
if istr::ends_with(path, ~".rs") {
|
if str::ends_with(path, ~".rs") {
|
||||||
if file_contains(path, ~"xfail-test") {
|
if file_contains(path, ~"xfail-test") {
|
||||||
//log_err "Skipping " + path + " because it is marked as xfail-test";
|
//log_err "Skipping " + path + " because it is marked as xfail-test";
|
||||||
} else { files += [path]; }
|
} else { files += [path]; }
|
||||||
} else if fs::file_is_dir(path)
|
} else if fs::file_is_dir(path)
|
||||||
&& istr::find(path, ~"compile-fail") == -1 {
|
&& str::find(path, ~"compile-fail") == -1 {
|
||||||
for p in fs::list_dir(path) {
|
for p in fs::list_dir(path) {
|
||||||
find_rust_files(files, p);
|
find_rust_files(files, p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,8 @@ type ctx = chan<request>;
|
||||||
fn ip_to_sbuf(ip: net::ip_addr) -> *u8 {
|
fn ip_to_sbuf(ip: net::ip_addr) -> *u8 {
|
||||||
// FIXME: This is broken. We're creating a vector, getting a pointer
|
// FIXME: This is broken. We're creating a vector, getting a pointer
|
||||||
// to its buffer, then dropping the vector. On top of that, the vector
|
// to its buffer, then dropping the vector. On top of that, the vector
|
||||||
// created by istr::bytes is not null-terminated.
|
// created by str::bytes is not null-terminated.
|
||||||
vec::to_ptr(istr::bytes(net::format_addr(ip)))
|
vec::to_ptr(str::bytes(net::format_addr(ip)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn connect_task(ip: net::ip_addr, portnum: int, evt: chan<socket_event>) {
|
fn connect_task(ip: net::ip_addr, portnum: int, evt: chan<socket_event>) {
|
||||||
|
|
|
@ -72,10 +72,10 @@ mod ct {
|
||||||
|
|
||||||
fn parse_fmt_string(s: &istr, error: error_fn) -> [piece] {
|
fn parse_fmt_string(s: &istr, error: error_fn) -> [piece] {
|
||||||
let pieces: [piece] = [];
|
let pieces: [piece] = [];
|
||||||
let lim = istr::byte_len(s);
|
let lim = str::byte_len(s);
|
||||||
let buf = ~"";
|
let buf = ~"";
|
||||||
fn flush_buf(buf: &istr, pieces: &mutable [piece]) -> istr {
|
fn flush_buf(buf: &istr, pieces: &mutable [piece]) -> istr {
|
||||||
if istr::byte_len(buf) > 0u {
|
if str::byte_len(buf) > 0u {
|
||||||
let piece = piece_string(buf);
|
let piece = piece_string(buf);
|
||||||
pieces += [piece];
|
pieces += [piece];
|
||||||
}
|
}
|
||||||
|
@ -83,14 +83,14 @@ mod ct {
|
||||||
}
|
}
|
||||||
let i = 0u;
|
let i = 0u;
|
||||||
while i < lim {
|
while i < lim {
|
||||||
let curr = istr::substr(s, i, 1u);
|
let curr = str::substr(s, i, 1u);
|
||||||
if istr::eq(curr, ~"%") {
|
if str::eq(curr, ~"%") {
|
||||||
i += 1u;
|
i += 1u;
|
||||||
if i >= lim {
|
if i >= lim {
|
||||||
error(~"unterminated conversion at end of string");
|
error(~"unterminated conversion at end of string");
|
||||||
}
|
}
|
||||||
let curr2 = istr::substr(s, i, 1u);
|
let curr2 = str::substr(s, i, 1u);
|
||||||
if istr::eq(curr2, ~"%") {
|
if str::eq(curr2, ~"%") {
|
||||||
i += 1u;
|
i += 1u;
|
||||||
} else {
|
} else {
|
||||||
buf = flush_buf(buf, pieces);
|
buf = flush_buf(buf, pieces);
|
||||||
|
@ -217,27 +217,27 @@ mod ct {
|
||||||
fn parse_type(s: &istr, i: uint, lim: uint, error: error_fn) ->
|
fn parse_type(s: &istr, i: uint, lim: uint, error: error_fn) ->
|
||||||
{ty: ty, next: uint} {
|
{ty: ty, next: uint} {
|
||||||
if i >= lim { error(~"missing type in conversion"); }
|
if i >= lim { error(~"missing type in conversion"); }
|
||||||
let tstr = istr::substr(s, i, 1u);
|
let tstr = str::substr(s, i, 1u);
|
||||||
// TODO: Do we really want two signed types here?
|
// TODO: Do we really want two signed types here?
|
||||||
// How important is it to be printf compatible?
|
// How important is it to be printf compatible?
|
||||||
let t =
|
let t =
|
||||||
if istr::eq(tstr, ~"b") {
|
if str::eq(tstr, ~"b") {
|
||||||
ty_bool
|
ty_bool
|
||||||
} else if istr::eq(tstr, ~"s") {
|
} else if str::eq(tstr, ~"s") {
|
||||||
ty_str
|
ty_str
|
||||||
} else if istr::eq(tstr, ~"c") {
|
} else if str::eq(tstr, ~"c") {
|
||||||
ty_char
|
ty_char
|
||||||
} else if istr::eq(tstr, ~"d") || istr::eq(tstr, ~"i") {
|
} else if str::eq(tstr, ~"d") || str::eq(tstr, ~"i") {
|
||||||
ty_int(signed)
|
ty_int(signed)
|
||||||
} else if istr::eq(tstr, ~"u") {
|
} else if str::eq(tstr, ~"u") {
|
||||||
ty_int(unsigned)
|
ty_int(unsigned)
|
||||||
} else if istr::eq(tstr, ~"x") {
|
} else if str::eq(tstr, ~"x") {
|
||||||
ty_hex(case_lower)
|
ty_hex(case_lower)
|
||||||
} else if istr::eq(tstr, ~"X") {
|
} else if str::eq(tstr, ~"X") {
|
||||||
ty_hex(case_upper)
|
ty_hex(case_upper)
|
||||||
} else if istr::eq(tstr, ~"t") {
|
} else if str::eq(tstr, ~"t") {
|
||||||
ty_bits
|
ty_bits
|
||||||
} else if istr::eq(tstr, ~"o") {
|
} else if str::eq(tstr, ~"o") {
|
||||||
ty_octal
|
ty_octal
|
||||||
} else { error(~"unknown type in conversion: " + tstr) };
|
} else { error(~"unknown type in conversion: " + tstr) };
|
||||||
ret {ty: t, next: i + 1u};
|
ret {ty: t, next: i + 1u};
|
||||||
|
@ -289,7 +289,7 @@ mod rt {
|
||||||
alt cv.ty {
|
alt cv.ty {
|
||||||
ty_default. { uint_to_str_prec(u, 10u, prec) }
|
ty_default. { uint_to_str_prec(u, 10u, prec) }
|
||||||
ty_hex_lower. { uint_to_str_prec(u, 16u, prec) }
|
ty_hex_lower. { uint_to_str_prec(u, 16u, prec) }
|
||||||
ty_hex_upper. { istr::to_upper(uint_to_str_prec(u, 16u, prec)) }
|
ty_hex_upper. { str::to_upper(uint_to_str_prec(u, 16u, prec)) }
|
||||||
ty_bits. { uint_to_str_prec(u, 2u, prec) }
|
ty_bits. { uint_to_str_prec(u, 2u, prec) }
|
||||||
ty_octal. { uint_to_str_prec(u, 8u, prec) }
|
ty_octal. { uint_to_str_prec(u, 8u, prec) }
|
||||||
};
|
};
|
||||||
|
@ -303,7 +303,7 @@ mod rt {
|
||||||
ret conv_str(cv, s);
|
ret conv_str(cv, s);
|
||||||
}
|
}
|
||||||
fn conv_char(cv: &conv, c: char) -> istr {
|
fn conv_char(cv: &conv, c: char) -> istr {
|
||||||
ret pad(cv, istr::from_char(c), pad_nozero);
|
ret pad(cv, str::from_char(c), pad_nozero);
|
||||||
}
|
}
|
||||||
fn conv_str(cv: &conv, s: &istr) -> istr {
|
fn conv_str(cv: &conv, s: &istr) -> istr {
|
||||||
// For strings, precision is the maximum characters
|
// For strings, precision is the maximum characters
|
||||||
|
@ -314,8 +314,8 @@ mod rt {
|
||||||
alt cv.precision {
|
alt cv.precision {
|
||||||
count_implied. { s }
|
count_implied. { s }
|
||||||
count_is(max) {
|
count_is(max) {
|
||||||
if max as uint < istr::char_len(s) {
|
if max as uint < str::char_len(s) {
|
||||||
istr::substr(s, 0u, max as uint)
|
str::substr(s, 0u, max as uint)
|
||||||
} else { s }
|
} else { s }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -338,7 +338,7 @@ mod rt {
|
||||||
~""
|
~""
|
||||||
} else {
|
} else {
|
||||||
let s = uint::to_str(num, radix);
|
let s = uint::to_str(num, radix);
|
||||||
let len = istr::char_len(s);
|
let len = str::char_len(s);
|
||||||
if len < prec {
|
if len < prec {
|
||||||
let diff = prec - len;
|
let diff = prec - len;
|
||||||
let pad = str_init_elt('0', diff);
|
let pad = str_init_elt('0', diff);
|
||||||
|
@ -357,7 +357,7 @@ mod rt {
|
||||||
fn str_init_elt(c: char, n_elts: uint) -> istr {
|
fn str_init_elt(c: char, n_elts: uint) -> istr {
|
||||||
let svec = vec::init_elt::<u8>(c as u8, n_elts);
|
let svec = vec::init_elt::<u8>(c as u8, n_elts);
|
||||||
|
|
||||||
ret istr::unsafe_from_bytes(svec);
|
ret str::unsafe_from_bytes(svec);
|
||||||
}
|
}
|
||||||
tag pad_mode { pad_signed; pad_unsigned; pad_nozero; }
|
tag pad_mode { pad_signed; pad_unsigned; pad_nozero; }
|
||||||
fn pad(cv: &conv, s: &istr, mode: pad_mode) -> istr {
|
fn pad(cv: &conv, s: &istr, mode: pad_mode) -> istr {
|
||||||
|
@ -370,7 +370,7 @@ mod rt {
|
||||||
uwidth = width as uint;
|
uwidth = width as uint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let strlen = istr::char_len(s);
|
let strlen = str::char_len(s);
|
||||||
if uwidth <= strlen { ret s; }
|
if uwidth <= strlen { ret s; }
|
||||||
let padchar = ' ';
|
let padchar = ' ';
|
||||||
let diff = uwidth - strlen;
|
let diff = uwidth - strlen;
|
||||||
|
@ -403,12 +403,12 @@ mod rt {
|
||||||
// zeros. It may make sense to convert zero padding to a precision
|
// zeros. It may make sense to convert zero padding to a precision
|
||||||
// instead.
|
// instead.
|
||||||
|
|
||||||
if signed && zero_padding && istr::byte_len(s) > 0u {
|
if signed && zero_padding && str::byte_len(s) > 0u {
|
||||||
let head = s[0];
|
let head = s[0];
|
||||||
if head == '+' as u8 || head == '-' as u8 || head == ' ' as u8 {
|
if head == '+' as u8 || head == '-' as u8 || head == ' ' as u8 {
|
||||||
let headstr = istr::unsafe_from_bytes([head]);
|
let headstr = str::unsafe_from_bytes([head]);
|
||||||
let bytelen = istr::byte_len(s);
|
let bytelen = str::byte_len(s);
|
||||||
let numpart = istr::substr(s, 1u, bytelen - 1u);
|
let numpart = str::substr(s, 1u, bytelen - 1u);
|
||||||
ret headstr + padstr + numpart;
|
ret headstr + padstr + numpart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,37 +3,37 @@ import os::getcwd;
|
||||||
import os_fs;
|
import os_fs;
|
||||||
|
|
||||||
native "rust" mod rustrt {
|
native "rust" mod rustrt {
|
||||||
fn rust_file_is_dir(path: istr::sbuf) -> int;
|
fn rust_file_is_dir(path: str::sbuf) -> int;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_sep() -> istr { ret istr::from_char(os_fs::path_sep); }
|
fn path_sep() -> istr { ret str::from_char(os_fs::path_sep); }
|
||||||
|
|
||||||
type path = istr;
|
type path = istr;
|
||||||
|
|
||||||
fn dirname(p: &path) -> path {
|
fn dirname(p: &path) -> path {
|
||||||
let i: int = istr::rindex(p, os_fs::path_sep as u8);
|
let i: int = str::rindex(p, os_fs::path_sep as u8);
|
||||||
if i == -1 {
|
if i == -1 {
|
||||||
i = istr::rindex(p, os_fs::alt_path_sep as u8);
|
i = str::rindex(p, os_fs::alt_path_sep as u8);
|
||||||
if i == -1 { ret ~"."; }
|
if i == -1 { ret ~"."; }
|
||||||
}
|
}
|
||||||
ret istr::substr(p, 0u, i as uint);
|
ret str::substr(p, 0u, i as uint);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn basename(p: &path) -> path {
|
fn basename(p: &path) -> path {
|
||||||
let i: int = istr::rindex(p, os_fs::path_sep as u8);
|
let i: int = str::rindex(p, os_fs::path_sep as u8);
|
||||||
if i == -1 {
|
if i == -1 {
|
||||||
i = istr::rindex(p, os_fs::alt_path_sep as u8);
|
i = str::rindex(p, os_fs::alt_path_sep as u8);
|
||||||
if i == -1 { ret p; }
|
if i == -1 { ret p; }
|
||||||
}
|
}
|
||||||
let len = istr::byte_len(p);
|
let len = str::byte_len(p);
|
||||||
if i + 1 as uint >= len { ret p; }
|
if i + 1 as uint >= len { ret p; }
|
||||||
ret istr::slice(p, i + 1 as uint, len);
|
ret str::slice(p, i + 1 as uint, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FIXME: Need some typestate to avoid bounds check when len(pre) == 0
|
// FIXME: Need some typestate to avoid bounds check when len(pre) == 0
|
||||||
fn connect(pre: &path, post: &path) -> path {
|
fn connect(pre: &path, post: &path) -> path {
|
||||||
let len = istr::byte_len(pre);
|
let len = str::byte_len(pre);
|
||||||
ret if pre[len - 1u] == os_fs::path_sep as u8 {
|
ret if pre[len - 1u] == os_fs::path_sep as u8 {
|
||||||
|
|
||||||
// Trailing '/'?
|
// Trailing '/'?
|
||||||
|
@ -42,19 +42,19 @@ fn connect(pre: &path, post: &path) -> path {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn file_is_dir(p: &path) -> bool {
|
fn file_is_dir(p: &path) -> bool {
|
||||||
ret istr::as_buf(p, { |buf|
|
ret str::as_buf(p, { |buf|
|
||||||
rustrt::rust_file_is_dir(buf) != 0
|
rustrt::rust_file_is_dir(buf) != 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_dir(p: &path) -> [istr] {
|
fn list_dir(p: &path) -> [istr] {
|
||||||
let p = p;
|
let p = p;
|
||||||
let pl = istr::byte_len(p);
|
let pl = str::byte_len(p);
|
||||||
if pl == 0u || p[pl - 1u] as char != os_fs::path_sep { p += path_sep(); }
|
if pl == 0u || p[pl - 1u] as char != os_fs::path_sep { p += path_sep(); }
|
||||||
let full_paths: [istr] = [];
|
let full_paths: [istr] = [];
|
||||||
for filename: istr in os_fs::list_dir(p) {
|
for filename: istr in os_fs::list_dir(p) {
|
||||||
if !istr::eq(filename, ~".") {
|
if !str::eq(filename, ~".") {
|
||||||
if !istr::eq(filename, ~"..") { full_paths += [p + filename]; }
|
if !str::eq(filename, ~"..") { full_paths += [p + filename]; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret full_paths;
|
ret full_paths;
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import istr::sbuf;
|
import str::sbuf;
|
||||||
|
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
fn getenv(n: &istr) -> option::t<istr> {
|
fn getenv(n: &istr) -> option::t<istr> {
|
||||||
let s = istr::as_buf(n, { |buf|
|
let s = str::as_buf(n, { |buf|
|
||||||
os::libc::getenv(buf)
|
os::libc::getenv(buf)
|
||||||
});
|
});
|
||||||
ret if unsafe::reinterpret_cast(s) == 0 {
|
ret if unsafe::reinterpret_cast(s) == 0 {
|
||||||
option::none::<istr>
|
option::none::<istr>
|
||||||
} else {
|
} else {
|
||||||
let s = unsafe::reinterpret_cast(s);
|
let s = unsafe::reinterpret_cast(s);
|
||||||
option::some::<istr>(istr::str_from_cstr(s))
|
option::some::<istr>(str::str_from_cstr(s))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@ fn getenv(n: &istr) -> option::t<istr> {
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
fn setenv(n: &istr, v: &istr) {
|
fn setenv(n: &istr, v: &istr) {
|
||||||
// FIXME (868)
|
// FIXME (868)
|
||||||
let _: () = istr::as_buf(n, { |nbuf|
|
let _: () = str::as_buf(n, { |nbuf|
|
||||||
// FIXME (868)
|
// FIXME (868)
|
||||||
let _: () = istr::as_buf(v, { |vbuf|
|
let _: () = str::as_buf(v, { |vbuf|
|
||||||
os::libc::setenv(nbuf, vbuf, 1);
|
os::libc::setenv(nbuf, vbuf, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -33,7 +33,7 @@ fn getenv(n: &istr) -> option::t<istr> {
|
||||||
while true {
|
while true {
|
||||||
let v: [u8] = [];
|
let v: [u8] = [];
|
||||||
vec::reserve(v, nsize);
|
vec::reserve(v, nsize);
|
||||||
let res = istr::as_buf(n, { |nbuf|
|
let res = str::as_buf(n, { |nbuf|
|
||||||
let vbuf = vec::to_ptr(v);
|
let vbuf = vec::to_ptr(v);
|
||||||
os::kernel32::GetEnvironmentVariableA(nbuf, vbuf, nsize)
|
os::kernel32::GetEnvironmentVariableA(nbuf, vbuf, nsize)
|
||||||
});
|
});
|
||||||
|
@ -41,7 +41,7 @@ fn getenv(n: &istr) -> option::t<istr> {
|
||||||
ret option::none;
|
ret option::none;
|
||||||
} else if res < nsize {
|
} else if res < nsize {
|
||||||
vec::unsafe::set_len(v, res);
|
vec::unsafe::set_len(v, res);
|
||||||
ret option::some(istr::unsafe_from_bytes(v));
|
ret option::some(str::unsafe_from_bytes(v));
|
||||||
} else { nsize = res; }
|
} else { nsize = res; }
|
||||||
}
|
}
|
||||||
fail;
|
fail;
|
||||||
|
@ -50,8 +50,8 @@ fn getenv(n: &istr) -> option::t<istr> {
|
||||||
#[cfg(target_os = "win32")]
|
#[cfg(target_os = "win32")]
|
||||||
fn setenv(n: &istr, v: &istr) {
|
fn setenv(n: &istr, v: &istr) {
|
||||||
// FIXME (868)
|
// FIXME (868)
|
||||||
let _: () = istr::as_buf(n, { |nbuf|
|
let _: () = str::as_buf(n, { |nbuf|
|
||||||
let _: () = istr::as_buf(v, { |vbuf|
|
let _: () = str::as_buf(v, { |vbuf|
|
||||||
os::kernel32::SetEnvironmentVariableA(nbuf, vbuf);
|
os::kernel32::SetEnvironmentVariableA(nbuf, vbuf);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,8 +38,8 @@ tag occur { req; optional; multi; }
|
||||||
type opt = {name: name, hasarg: hasarg, occur: occur};
|
type opt = {name: name, hasarg: hasarg, occur: occur};
|
||||||
|
|
||||||
fn mkname(nm: &istr) -> name {
|
fn mkname(nm: &istr) -> name {
|
||||||
ret if istr::char_len(nm) == 1u {
|
ret if str::char_len(nm) == 1u {
|
||||||
short(istr::char_at(nm, 0u))
|
short(str::char_at(nm, 0u))
|
||||||
} else { long(nm) };
|
} else { long(nm) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,11 +68,11 @@ tag optval { val(istr); given; }
|
||||||
type match = {opts: [opt], vals: [mutable [optval]], free: [istr]};
|
type match = {opts: [opt], vals: [mutable [optval]], free: [istr]};
|
||||||
|
|
||||||
fn is_arg(arg: &istr) -> bool {
|
fn is_arg(arg: &istr) -> bool {
|
||||||
ret istr::byte_len(arg) > 1u && arg[0] == '-' as u8;
|
ret str::byte_len(arg) > 1u && arg[0] == '-' as u8;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn name_str(nm: &name) -> istr {
|
fn name_str(nm: &name) -> istr {
|
||||||
ret alt nm { short(ch) { istr::from_char(ch) } long(s) { s } };
|
ret alt nm { short(ch) { str::from_char(ch) } long(s) { s } };
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_opt(opts: &[opt], nm: &name) -> option::t<uint> {
|
fn find_opt(opts: &[opt], nm: &name) -> option::t<uint> {
|
||||||
|
@ -117,10 +117,10 @@ fn getopts(args: &[istr], opts: &[opt]) -> result {
|
||||||
let i = 0u;
|
let i = 0u;
|
||||||
while i < l {
|
while i < l {
|
||||||
let cur = args[i];
|
let cur = args[i];
|
||||||
let curlen = istr::byte_len(cur);
|
let curlen = str::byte_len(cur);
|
||||||
if !is_arg(cur) {
|
if !is_arg(cur) {
|
||||||
free += [cur];
|
free += [cur];
|
||||||
} else if istr::eq(cur, ~"--") {
|
} else if str::eq(cur, ~"--") {
|
||||||
let j = i + 1u;
|
let j = i + 1u;
|
||||||
while j < l { free += [args[j]]; j += 1u; }
|
while j < l { free += [args[j]]; j += 1u; }
|
||||||
break;
|
break;
|
||||||
|
@ -128,14 +128,14 @@ fn getopts(args: &[istr], opts: &[opt]) -> result {
|
||||||
let names;
|
let names;
|
||||||
let i_arg = option::none::<istr>;
|
let i_arg = option::none::<istr>;
|
||||||
if cur[1] == '-' as u8 {
|
if cur[1] == '-' as u8 {
|
||||||
let tail = istr::slice(cur, 2u, curlen);
|
let tail = str::slice(cur, 2u, curlen);
|
||||||
let eq = istr::index(tail, '=' as u8);
|
let eq = str::index(tail, '=' as u8);
|
||||||
if eq == -1 {
|
if eq == -1 {
|
||||||
names = [long(tail)];
|
names = [long(tail)];
|
||||||
} else {
|
} else {
|
||||||
names = [long(istr::slice(tail, 0u, eq as uint))];
|
names = [long(str::slice(tail, 0u, eq as uint))];
|
||||||
i_arg =
|
i_arg =
|
||||||
option::some::<istr>(istr::slice(tail,
|
option::some::<istr>(str::slice(tail,
|
||||||
(eq as uint) + 1u,
|
(eq as uint) + 1u,
|
||||||
curlen - 2u));
|
curlen - 2u));
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ fn getopts(args: &[istr], opts: &[opt]) -> result {
|
||||||
let j = 1u;
|
let j = 1u;
|
||||||
names = [];
|
names = [];
|
||||||
while j < curlen {
|
while j < curlen {
|
||||||
let range = istr::char_range_at(cur, j);
|
let range = str::char_range_at(cur, j);
|
||||||
names += [short(range.ch)];
|
names += [short(range.ch)];
|
||||||
j = range.next;
|
j = range.next;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ obj new_reader(rdr: buf_reader) {
|
||||||
|
|
||||||
}
|
}
|
||||||
let b0 = c0 as u8;
|
let b0 = c0 as u8;
|
||||||
let w = istr::utf8_char_width(b0);
|
let w = str::utf8_char_width(b0);
|
||||||
assert (w > 0u);
|
assert (w > 0u);
|
||||||
if w == 1u { ret b0 as char; }
|
if w == 1u { ret b0 as char; }
|
||||||
let val = 0u;
|
let val = 0u;
|
||||||
|
@ -117,7 +117,7 @@ obj new_reader(rdr: buf_reader) {
|
||||||
go_on = false;
|
go_on = false;
|
||||||
} else { buf += [ch as u8]; }
|
} else { buf += [ch as u8]; }
|
||||||
}
|
}
|
||||||
ret istr::unsafe_from_bytes(buf);
|
ret str::unsafe_from_bytes(buf);
|
||||||
}
|
}
|
||||||
fn read_c_str() -> istr {
|
fn read_c_str() -> istr {
|
||||||
let buf: [u8] = [];
|
let buf: [u8] = [];
|
||||||
|
@ -126,7 +126,7 @@ obj new_reader(rdr: buf_reader) {
|
||||||
let ch = rdr.read_byte();
|
let ch = rdr.read_byte();
|
||||||
if ch < 1 { go_on = false; } else { buf += [ch as u8]; }
|
if ch < 1 { go_on = false; } else { buf += [ch as u8]; }
|
||||||
}
|
}
|
||||||
ret istr::unsafe_from_bytes(buf);
|
ret str::unsafe_from_bytes(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME deal with eof?
|
// FIXME deal with eof?
|
||||||
|
@ -175,8 +175,8 @@ fn stdin() -> reader {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn file_reader(path: &istr) -> reader {
|
fn file_reader(path: &istr) -> reader {
|
||||||
let f = istr::as_buf(path, { |pathbuf|
|
let f = str::as_buf(path, { |pathbuf|
|
||||||
istr::as_buf(~"r", { |modebuf|
|
str::as_buf(~"r", { |modebuf|
|
||||||
os::libc::fopen(pathbuf, modebuf)
|
os::libc::fopen(pathbuf, modebuf)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -220,7 +220,7 @@ fn new_byte_buf_reader(buf: &[u8]) -> buf_reader {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn string_reader(s: &istr) -> reader {
|
fn string_reader(s: &istr) -> reader {
|
||||||
ret new_reader(new_byte_buf_reader(istr::bytes(s)));
|
ret new_reader(new_byte_buf_reader(str::bytes(s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ fn file_buf_writer(path: &istr, flags: &[fileflag]) -> buf_writer {
|
||||||
none. { }
|
none. { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let fd = istr::as_buf(path, { |pathbuf|
|
let fd = str::as_buf(path, { |pathbuf|
|
||||||
os::libc::open(pathbuf, fflags,
|
os::libc::open(pathbuf, fflags,
|
||||||
os::libc_constants::S_IRUSR() |
|
os::libc_constants::S_IRUSR() |
|
||||||
os::libc_constants::S_IWUSR())
|
os::libc_constants::S_IWUSR())
|
||||||
|
@ -334,19 +334,19 @@ fn uint_to_be_bytes(n: uint, size: uint) -> [u8] {
|
||||||
|
|
||||||
obj new_writer(out: buf_writer) {
|
obj new_writer(out: buf_writer) {
|
||||||
fn get_buf_writer() -> buf_writer { ret out; }
|
fn get_buf_writer() -> buf_writer { ret out; }
|
||||||
fn write_str(s: &istr) { out.write(istr::bytes(s)); }
|
fn write_str(s: &istr) { out.write(str::bytes(s)); }
|
||||||
fn write_line(s: &istr) {
|
fn write_line(s: &istr) {
|
||||||
out.write(istr::bytes(s));
|
out.write(str::bytes(s));
|
||||||
out.write(istr::bytes(~"\n"));
|
out.write(str::bytes(~"\n"));
|
||||||
}
|
}
|
||||||
fn write_char(ch: char) {
|
fn write_char(ch: char) {
|
||||||
// FIXME needlessly consy
|
// FIXME needlessly consy
|
||||||
|
|
||||||
out.write(istr::bytes(istr::from_char(ch)));
|
out.write(str::bytes(str::from_char(ch)));
|
||||||
}
|
}
|
||||||
fn write_int(n: int) { out.write(istr::bytes(
|
fn write_int(n: int) { out.write(str::bytes(
|
||||||
int::to_str(n, 10u))); }
|
int::to_str(n, 10u))); }
|
||||||
fn write_uint(n: uint) { out.write(istr::bytes(
|
fn write_uint(n: uint) { out.write(str::bytes(
|
||||||
uint::to_str(n, 10u))); }
|
uint::to_str(n, 10u))); }
|
||||||
fn write_bytes(bytes: &[u8]) { out.write(bytes); }
|
fn write_bytes(bytes: &[u8]) { out.write(bytes); }
|
||||||
fn write_le_uint(n: uint, size: uint) {
|
fn write_le_uint(n: uint, size: uint) {
|
||||||
|
@ -367,8 +367,8 @@ fn file_writer(path: &istr, flags: &[fileflag]) -> writer {
|
||||||
|
|
||||||
// FIXME: fileflags
|
// FIXME: fileflags
|
||||||
fn buffered_file_buf_writer(path: &istr) -> buf_writer {
|
fn buffered_file_buf_writer(path: &istr) -> buf_writer {
|
||||||
let f = istr::as_buf(path, { |pathbuf|
|
let f = str::as_buf(path, { |pathbuf|
|
||||||
istr::as_buf(~"w", { |modebuf|
|
str::as_buf(~"w", { |modebuf|
|
||||||
os::libc::fopen(pathbuf, modebuf)
|
os::libc::fopen(pathbuf, modebuf)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -427,7 +427,7 @@ fn string_writer() -> str_writer {
|
||||||
let buf: mutable_byte_buf = @{mutable buf: b, mutable pos: 0u};
|
let buf: mutable_byte_buf = @{mutable buf: b, mutable pos: 0u};
|
||||||
obj str_writer_wrap(wr: writer, buf: mutable_byte_buf) {
|
obj str_writer_wrap(wr: writer, buf: mutable_byte_buf) {
|
||||||
fn get_writer() -> writer { ret wr; }
|
fn get_writer() -> writer { ret wr; }
|
||||||
fn get_str() -> istr { ret istr::unsafe_from_bytes(buf.buf); }
|
fn get_str() -> istr { ret str::unsafe_from_bytes(buf.buf); }
|
||||||
}
|
}
|
||||||
ret str_writer_wrap(new_writer(byte_buf_writer(buf)), buf);
|
ret str_writer_wrap(new_writer(byte_buf_writer(buf)), buf);
|
||||||
}
|
}
|
||||||
|
@ -448,7 +448,7 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) ->
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_whole_file_str(file: &istr) -> istr {
|
fn read_whole_file_str(file: &istr) -> istr {
|
||||||
istr::unsafe_from_bytes(read_whole_file(file))
|
str::unsafe_from_bytes(read_whole_file(file))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_whole_file(file: &istr) -> [u8] {
|
fn read_whole_file(file: &istr) -> [u8] {
|
||||||
|
|
|
@ -7,11 +7,11 @@ native "cdecl" mod libc = "" {
|
||||||
fn write(fd: int, buf: *u8, count: uint) -> int;
|
fn write(fd: int, buf: *u8, count: uint) -> int;
|
||||||
fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
|
fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
|
||||||
fn fwrite(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
|
fn fwrite(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
|
||||||
fn open(s: istr::sbuf, flags: int, mode: uint) -> int;
|
fn open(s: str::sbuf, flags: int, mode: uint) -> int;
|
||||||
fn close(fd: int) -> int;
|
fn close(fd: int) -> int;
|
||||||
type FILE;
|
type FILE;
|
||||||
fn fopen(path: istr::sbuf, mode: istr::sbuf) -> FILE;
|
fn fopen(path: str::sbuf, mode: str::sbuf) -> FILE;
|
||||||
fn fdopen(fd: int, mode: istr::sbuf) -> FILE;
|
fn fdopen(fd: int, mode: str::sbuf) -> FILE;
|
||||||
fn fclose(f: FILE);
|
fn fclose(f: FILE);
|
||||||
fn fgetc(f: FILE) -> int;
|
fn fgetc(f: FILE) -> int;
|
||||||
fn ungetc(c: int, f: FILE);
|
fn ungetc(c: int, f: FILE);
|
||||||
|
@ -19,13 +19,13 @@ native "cdecl" mod libc = "" {
|
||||||
fn fseek(f: FILE, offset: int, whence: int) -> int;
|
fn fseek(f: FILE, offset: int, whence: int) -> int;
|
||||||
fn ftell(f: FILE) -> int;
|
fn ftell(f: FILE) -> int;
|
||||||
type dir;
|
type dir;
|
||||||
fn opendir(d: istr::sbuf) -> dir;
|
fn opendir(d: str::sbuf) -> dir;
|
||||||
fn closedir(d: dir) -> int;
|
fn closedir(d: dir) -> int;
|
||||||
type dirent;
|
type dirent;
|
||||||
fn readdir(d: dir) -> dirent;
|
fn readdir(d: dir) -> dirent;
|
||||||
fn getenv(n: istr::sbuf) -> istr::sbuf;
|
fn getenv(n: str::sbuf) -> str::sbuf;
|
||||||
fn setenv(n: istr::sbuf, v: istr::sbuf, overwrite: int) -> int;
|
fn setenv(n: str::sbuf, v: str::sbuf, overwrite: int) -> int;
|
||||||
fn unsetenv(n: istr::sbuf) -> int;
|
fn unsetenv(n: str::sbuf) -> int;
|
||||||
fn pipe(buf: *mutable int) -> int;
|
fn pipe(buf: *mutable int) -> int;
|
||||||
fn waitpid(pid: int, status: &mutable int, options: int) -> int;
|
fn waitpid(pid: int, status: &mutable int, options: int) -> int;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ fn pipe() -> {in: int, out: int} {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fd_FILE(fd: int) -> libc::FILE {
|
fn fd_FILE(fd: int) -> libc::FILE {
|
||||||
ret istr::as_buf(~"r", { |modebuf|
|
ret str::as_buf(~"r", { |modebuf|
|
||||||
libc::fdopen(fd, modebuf)
|
libc::fdopen(fd, modebuf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,11 @@ native "cdecl" mod libc = "" {
|
||||||
fn write(fd: int, buf: *u8, count: uint) -> int;
|
fn write(fd: int, buf: *u8, count: uint) -> int;
|
||||||
fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
|
fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
|
||||||
fn fwrite(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
|
fn fwrite(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
|
||||||
fn open(s: istr::sbuf, flags: int, mode: uint) -> int;
|
fn open(s: str::sbuf, flags: int, mode: uint) -> int;
|
||||||
fn close(fd: int) -> int;
|
fn close(fd: int) -> int;
|
||||||
type FILE;
|
type FILE;
|
||||||
fn fopen(path: istr::sbuf, mode: istr::sbuf) -> FILE;
|
fn fopen(path: str::sbuf, mode: str::sbuf) -> FILE;
|
||||||
fn fdopen(fd: int, mode: istr::sbuf) -> FILE;
|
fn fdopen(fd: int, mode: str::sbuf) -> FILE;
|
||||||
fn fclose(f: FILE);
|
fn fclose(f: FILE);
|
||||||
fn fgetc(f: FILE) -> int;
|
fn fgetc(f: FILE) -> int;
|
||||||
fn ungetc(c: int, f: FILE);
|
fn ungetc(c: int, f: FILE);
|
||||||
|
@ -16,13 +16,13 @@ native "cdecl" mod libc = "" {
|
||||||
fn fseek(f: FILE, offset: int, whence: int) -> int;
|
fn fseek(f: FILE, offset: int, whence: int) -> int;
|
||||||
fn ftell(f: FILE) -> int;
|
fn ftell(f: FILE) -> int;
|
||||||
type dir;
|
type dir;
|
||||||
fn opendir(d: istr::sbuf) -> dir;
|
fn opendir(d: str::sbuf) -> dir;
|
||||||
fn closedir(d: dir) -> int;
|
fn closedir(d: dir) -> int;
|
||||||
type dirent;
|
type dirent;
|
||||||
fn readdir(d: dir) -> dirent;
|
fn readdir(d: dir) -> dirent;
|
||||||
fn getenv(n: istr::sbuf) -> istr::sbuf;
|
fn getenv(n: str::sbuf) -> str::sbuf;
|
||||||
fn setenv(n: istr::sbuf, v: istr::sbuf, overwrite: int) -> int;
|
fn setenv(n: str::sbuf, v: str::sbuf, overwrite: int) -> int;
|
||||||
fn unsetenv(n: istr::sbuf) -> int;
|
fn unsetenv(n: str::sbuf) -> int;
|
||||||
fn pipe(buf: *mutable int) -> int;
|
fn pipe(buf: *mutable int) -> int;
|
||||||
fn waitpid(pid: int, status: &mutable int, options: int) -> int;
|
fn waitpid(pid: int, status: &mutable int, options: int) -> int;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ fn pipe() -> {in: int, out: int} {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fd_FILE(fd: int) -> libc::FILE {
|
fn fd_FILE(fd: int) -> libc::FILE {
|
||||||
ret istr::as_buf(~"r", { |modebuf|
|
ret str::as_buf(~"r", { |modebuf|
|
||||||
libc::fdopen(fd, modebuf)
|
libc::fdopen(fd, modebuf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,7 @@ fn mk_hashmap<@K, @V>(hasher: &hashfn<K>, eqer: &eqfn<K>) -> hashmap<K, V> {
|
||||||
// Hash map constructors for basic types
|
// Hash map constructors for basic types
|
||||||
|
|
||||||
fn new_str_hash<@V>() -> hashmap<istr, V> {
|
fn new_str_hash<@V>() -> hashmap<istr, V> {
|
||||||
ret mk_hashmap(istr::hash, istr::eq);
|
ret mk_hashmap(str::hash, str::eq);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_int_hash<@V>() -> hashmap<int, V> {
|
fn new_int_hash<@V>() -> hashmap<int, V> {
|
||||||
|
|
|
@ -15,7 +15,7 @@ fn format_addr(ip: ip_addr) -> istr {
|
||||||
fn parse_addr(ip: &istr) -> ip_addr {
|
fn parse_addr(ip: &istr) -> ip_addr {
|
||||||
let parts = vec::map(
|
let parts = vec::map(
|
||||||
{ |&s| uint::from_str(s) },
|
{ |&s| uint::from_str(s) },
|
||||||
istr::split(ip, ~"."[0]));
|
str::split(ip, ~"."[0]));
|
||||||
if vec::len(parts) != 4u { fail "Too many dots in IP address"; }
|
if vec::len(parts) != 4u { fail "Too many dots in IP address"; }
|
||||||
for i in parts { if i > 255u { fail "Invalid IP Address part."; } }
|
for i in parts { if i > 255u { fail "Invalid IP Address part."; } }
|
||||||
ipv4(parts[0] as u8, parts[1] as u8, parts[2] as u8, parts[3] as u8)
|
ipv4(parts[0] as u8, parts[1] as u8, parts[2] as u8, parts[3] as u8)
|
||||||
|
|
|
@ -31,7 +31,7 @@ fn list_dir(path: &istr) -> [istr] {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_is_absolute(p: &istr) -> bool { ret istr::char_at(p, 0u) == '/'; }
|
fn path_is_absolute(p: &istr) -> bool { ret str::char_at(p, 0u) == '/'; }
|
||||||
|
|
||||||
const path_sep: char = '/';
|
const path_sep: char = '/';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import istr::sbuf;
|
import str::sbuf;
|
||||||
|
|
||||||
export program;
|
export program;
|
||||||
export run_program;
|
export run_program;
|
||||||
|
@ -13,9 +13,9 @@ native "rust" mod rustrt {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn arg_vec(prog: &istr, args: &[@istr]) -> [sbuf] {
|
fn arg_vec(prog: &istr, args: &[@istr]) -> [sbuf] {
|
||||||
let argptrs = istr::as_buf(prog, { |buf| [buf] });
|
let argptrs = str::as_buf(prog, { |buf| [buf] });
|
||||||
for arg in args {
|
for arg in args {
|
||||||
argptrs += istr::as_buf(*arg, { |buf| [buf] });
|
argptrs += str::as_buf(*arg, { |buf| [buf] });
|
||||||
}
|
}
|
||||||
argptrs += [unsafe::reinterpret_cast(0)];
|
argptrs += [unsafe::reinterpret_cast(0)];
|
||||||
ret argptrs;
|
ret argptrs;
|
||||||
|
@ -106,7 +106,7 @@ fn read_all(rd: &io::reader) -> istr {
|
||||||
let buf = ~"";
|
let buf = ~"";
|
||||||
while !rd.eof() {
|
while !rd.eof() {
|
||||||
let bytes = rd.read_bytes(4096u);
|
let bytes = rd.read_bytes(4096u);
|
||||||
buf += istr::unsafe_from_bytes(bytes);
|
buf += str::unsafe_from_bytes(bytes);
|
||||||
}
|
}
|
||||||
ret buf;
|
ret buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ fn mk_sha1() -> sha1 {
|
||||||
st.computed = false;
|
st.computed = false;
|
||||||
}
|
}
|
||||||
fn input(msg: &[u8]) { add_input(st, msg); }
|
fn input(msg: &[u8]) { add_input(st, msg); }
|
||||||
fn input_str(msg: &istr) { add_input(st, istr::bytes(msg)); }
|
fn input_str(msg: &istr) { add_input(st, str::bytes(msg)); }
|
||||||
fn result() -> [u8] { ret mk_result(st); }
|
fn result() -> [u8] { ret mk_result(st); }
|
||||||
fn result_str() -> istr {
|
fn result_str() -> istr {
|
||||||
let r = mk_result(st);
|
let r = mk_result(st);
|
||||||
|
|
|
@ -15,7 +15,7 @@ mod uint;
|
||||||
mod u8;
|
mod u8;
|
||||||
mod u64;
|
mod u64;
|
||||||
mod vec;
|
mod vec;
|
||||||
mod istr;
|
mod str;
|
||||||
|
|
||||||
// General io and system-services modules.
|
// General io and system-services modules.
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ fn color_supported() -> bool {
|
||||||
ret alt generic_os::getenv(~"TERM") {
|
ret alt generic_os::getenv(~"TERM") {
|
||||||
option::some(env) {
|
option::some(env) {
|
||||||
for term: istr in supported_terms {
|
for term: istr in supported_terms {
|
||||||
if istr::eq(term, env) { ret true; }
|
if str::eq(term, env) { ret true; }
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,7 +265,7 @@ fn filter_tests(opts: &test_opts, tests: &[test_desc]) -> [test_desc] {
|
||||||
let filter =
|
let filter =
|
||||||
bind fn (test: &test_desc, filter_str: &istr) ->
|
bind fn (test: &test_desc, filter_str: &istr) ->
|
||||||
option::t<test_desc> {
|
option::t<test_desc> {
|
||||||
if istr::find(test.name, filter_str) >= 0 {
|
if str::find(test.name, filter_str) >= 0 {
|
||||||
ret option::some(test);
|
ret option::some(test);
|
||||||
} else { ret option::none; }
|
} else { ret option::none; }
|
||||||
}(_, filter_str);
|
}(_, filter_str);
|
||||||
|
@ -296,7 +296,7 @@ fn filter_tests(opts: &test_opts, tests: &[test_desc]) -> [test_desc] {
|
||||||
filtered =
|
filtered =
|
||||||
{
|
{
|
||||||
fn lteq(t1: &test_desc, t2: &test_desc) -> bool {
|
fn lteq(t1: &test_desc, t2: &test_desc) -> bool {
|
||||||
istr::lteq(t1.name, t2.name)
|
str::lteq(t1.name, t2.name)
|
||||||
}
|
}
|
||||||
sort::merge_sort(lteq, filtered)
|
sort::merge_sort(lteq, filtered)
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,7 +56,7 @@ fn parse_buf(buf: &[u8], radix: uint) -> uint {
|
||||||
fail;
|
fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_str(s: &istr) -> uint { parse_buf(istr::bytes(s), 10u) }
|
fn from_str(s: &istr) -> uint { parse_buf(str::bytes(s), 10u) }
|
||||||
|
|
||||||
fn to_str(num: uint, radix: uint) -> istr {
|
fn to_str(num: uint, radix: uint) -> istr {
|
||||||
let n = num;
|
let n = num;
|
||||||
|
@ -85,12 +85,12 @@ fn to_str(num: uint, radix: uint) -> istr {
|
||||||
if n == 0u { ret ~"0"; }
|
if n == 0u { ret ~"0"; }
|
||||||
let s: istr = ~"";
|
let s: istr = ~"";
|
||||||
while n != 0u {
|
while n != 0u {
|
||||||
s += istr::unsafe_from_byte(digit(n % radix) as u8);
|
s += str::unsafe_from_byte(digit(n % radix) as u8);
|
||||||
n /= radix;
|
n /= radix;
|
||||||
}
|
}
|
||||||
let s1: istr = ~"";
|
let s1: istr = ~"";
|
||||||
let len: uint = istr::byte_len(s);
|
let len: uint = str::byte_len(s);
|
||||||
while len != 0u { len -= 1u; s1 += istr::unsafe_from_byte(s[len]); }
|
while len != 0u { len -= 1u; s1 += str::unsafe_from_byte(s[len]); }
|
||||||
ret s1;
|
ret s1;
|
||||||
}
|
}
|
||||||
fn str(i: uint) -> istr { ret to_str(i, 10u); }
|
fn str(i: uint) -> istr { ret to_str(i, 10u); }
|
||||||
|
|
|
@ -11,8 +11,8 @@ fn list_dir(path: &istr) -> [istr] {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_is_absolute(p: &istr) -> bool {
|
fn path_is_absolute(p: &istr) -> bool {
|
||||||
ret istr::char_at(p, 0u) == '/' ||
|
ret str::char_at(p, 0u) == '/' ||
|
||||||
istr::char_at(p, 1u) == ':' && istr::char_at(p, 2u) == '\\';
|
str::char_at(p, 1u) == ':' && str::char_at(p, 2u) == '\\';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: win32 path handling actually accepts '/' or '\' and has subtly
|
/* FIXME: win32 path handling actually accepts '/' or '\' and has subtly
|
||||||
|
|
|
@ -4,11 +4,11 @@ native "cdecl" mod libc = "" {
|
||||||
fn write(fd: int, buf: *u8, count: uint) -> int;
|
fn write(fd: int, buf: *u8, count: uint) -> int;
|
||||||
fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
|
fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
|
||||||
fn fwrite(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
|
fn fwrite(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
|
||||||
fn open(s: istr::sbuf, flags: int, mode: uint) -> int = "_open";
|
fn open(s: str::sbuf, flags: int, mode: uint) -> int = "_open";
|
||||||
fn close(fd: int) -> int = "_close";
|
fn close(fd: int) -> int = "_close";
|
||||||
type FILE;
|
type FILE;
|
||||||
fn fopen(path: istr::sbuf, mode: istr::sbuf) -> FILE;
|
fn fopen(path: str::sbuf, mode: str::sbuf) -> FILE;
|
||||||
fn _fdopen(fd: int, mode: istr::sbuf) -> FILE;
|
fn _fdopen(fd: int, mode: str::sbuf) -> FILE;
|
||||||
fn fclose(f: FILE);
|
fn fclose(f: FILE);
|
||||||
fn fgetc(f: FILE) -> int;
|
fn fgetc(f: FILE) -> int;
|
||||||
fn ungetc(c: int, f: FILE);
|
fn ungetc(c: int, f: FILE);
|
||||||
|
@ -40,9 +40,9 @@ mod libc_constants {
|
||||||
}
|
}
|
||||||
|
|
||||||
native "x86stdcall" mod kernel32 {
|
native "x86stdcall" mod kernel32 {
|
||||||
fn GetEnvironmentVariableA(n: istr::sbuf, v: istr::sbuf,
|
fn GetEnvironmentVariableA(n: str::sbuf, v: str::sbuf,
|
||||||
nsize: uint) -> uint;
|
nsize: uint) -> uint;
|
||||||
fn SetEnvironmentVariableA(n: istr::sbuf, v: istr::sbuf) -> int;
|
fn SetEnvironmentVariableA(n: str::sbuf, v: str::sbuf) -> int;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exec_suffix() -> istr { ret ~".exe"; }
|
fn exec_suffix() -> istr { ret ~".exe"; }
|
||||||
|
@ -69,7 +69,7 @@ fn pipe() -> {in: int, out: int} {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fd_FILE(fd: int) -> libc::FILE {
|
fn fd_FILE(fd: int) -> libc::FILE {
|
||||||
ret istr::as_buf(~"r", { |modebuf|
|
ret str::as_buf(~"r", { |modebuf|
|
||||||
libc::_fdopen(fd, modebuf)
|
libc::_fdopen(fd, modebuf)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
use std;
|
use std;
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::istr;
|
import std::str;
|
||||||
|
|
||||||
fn b1() -> istr { ret ~"# of beer on the wall, # of beer."; }
|
fn b1() -> istr { ret ~"# of beer on the wall, # of beer."; }
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ fn sub(t: &istr, n: int) -> istr {
|
||||||
1 { ns = ~"1 bottle"; }
|
1 { ns = ~"1 bottle"; }
|
||||||
_ { ns = int::to_str(n, 10u) + ~" bottles"; }
|
_ { ns = int::to_str(n, 10u) + ~" bottles"; }
|
||||||
}
|
}
|
||||||
while i < istr::byte_len(t) {
|
while i < str::byte_len(t) {
|
||||||
if t[i] == '#' as u8 { b += ns; } else { istr::push_byte(b, t[i]); }
|
if t[i] == '#' as u8 { b += ns; } else { str::push_byte(b, t[i]); }
|
||||||
i += 1u;
|
i += 1u;
|
||||||
}
|
}
|
||||||
ret b;
|
ret b;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
use std;
|
use std;
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::istr;
|
import std::str;
|
||||||
|
|
||||||
tag bottle { none; dual; single; multiple(int); }
|
tag bottle { none; dual; single; multiple(int); }
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
use std;
|
use std;
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::istr;
|
import std::str;
|
||||||
|
|
||||||
fn b1() -> istr { ret ~"# of beer on the wall, # of beer."; }
|
fn b1() -> istr { ret ~"# of beer on the wall, # of beer."; }
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ fn sub(t: &istr, n: int) -> istr {
|
||||||
1 { ns = ~"1 bottle"; }
|
1 { ns = ~"1 bottle"; }
|
||||||
_ { ns = int::to_str(n, 10u) + ~" bottles"; }
|
_ { ns = int::to_str(n, 10u) + ~" bottles"; }
|
||||||
}
|
}
|
||||||
while i < istr::byte_len(t) {
|
while i < str::byte_len(t) {
|
||||||
if t[i] == '#' as u8 { b += ns; } else { istr::push_byte(b, t[i]); }
|
if t[i] == '#' as u8 { b += ns; } else { str::push_byte(b, t[i]); }
|
||||||
i += 1u;
|
i += 1u;
|
||||||
}
|
}
|
||||||
ret b;
|
ret b;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
use std;
|
use std;
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::istr;
|
import std::str;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
fn multiple(n: int) {
|
fn multiple(n: int) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::int;
|
import std::int;
|
||||||
import std::istr;
|
import std::str;
|
||||||
|
|
||||||
fn LINE_LENGTH() -> uint { ret 60u; }
|
fn LINE_LENGTH() -> uint { ret 60u; }
|
||||||
|
|
||||||
|
@ -49,21 +49,21 @@ fn make_random_fasta(id: &istr, desc: &istr,
|
||||||
let rng = myrandom(std::rand::mk_rng().next());
|
let rng = myrandom(std::rand::mk_rng().next());
|
||||||
let op: istr = ~"";
|
let op: istr = ~"";
|
||||||
for each i: uint in uint::range(0u, n as uint) {
|
for each i: uint in uint::range(0u, n as uint) {
|
||||||
istr::push_byte(op, select_random(rng.next(100u32), genelist) as u8);
|
str::push_byte(op, select_random(rng.next(100u32), genelist) as u8);
|
||||||
if istr::byte_len(op) >= LINE_LENGTH() { log op; op = ~""; }
|
if str::byte_len(op) >= LINE_LENGTH() { log op; op = ~""; }
|
||||||
}
|
}
|
||||||
if istr::byte_len(op) > 0u { log op; }
|
if str::byte_len(op) > 0u { log op; }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_repeat_fasta(id: &istr, desc: &istr, s: &istr, n: int) {
|
fn make_repeat_fasta(id: &istr, desc: &istr, s: &istr, n: int) {
|
||||||
log ~">" + id + ~" " + desc;
|
log ~">" + id + ~" " + desc;
|
||||||
let op: istr = ~"";
|
let op: istr = ~"";
|
||||||
let sl: uint = istr::byte_len(s);
|
let sl: uint = str::byte_len(s);
|
||||||
for each i: uint in uint::range(0u, n as uint) {
|
for each i: uint in uint::range(0u, n as uint) {
|
||||||
istr::push_byte(op, s[i % sl]);
|
str::push_byte(op, s[i % sl]);
|
||||||
if istr::byte_len(op) >= LINE_LENGTH() { log op; op = ~""; }
|
if str::byte_len(op) >= LINE_LENGTH() { log op; op = ~""; }
|
||||||
}
|
}
|
||||||
if istr::byte_len(op) > 0u { log op; }
|
if str::byte_len(op) > 0u { log op; }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn acid(ch: char, prob: u32) -> aminoacids { ret {ch: ch, prob: prob}; }
|
fn acid(ch: char, prob: u32) -> aminoacids { ret {ch: ch, prob: prob}; }
|
||||||
|
|
|
@ -14,7 +14,7 @@ use std;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::time;
|
import std::time;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::int::range;
|
import std::int::range;
|
||||||
import std::io;
|
import std::io;
|
||||||
import std::getopts;
|
import std::getopts;
|
||||||
|
@ -91,7 +91,7 @@ fn main(argv: [istr]) {
|
||||||
if opts.stress {
|
if opts.stress {
|
||||||
stress(2);
|
stress(2);
|
||||||
} else {
|
} else {
|
||||||
let max = uint::parse_buf(istr::bytes(argv[1]), 10u) as int;
|
let max = uint::parse_buf(str::bytes(argv[1]), 10u) as int;
|
||||||
|
|
||||||
let num_trials = 10;
|
let num_trials = 10;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::task;
|
import std::task;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::istr;
|
import std::str;
|
||||||
|
|
||||||
fn f(n: uint) {
|
fn f(n: uint) {
|
||||||
let i = 0u;
|
let i = 0u;
|
||||||
|
@ -17,7 +17,7 @@ fn main(args: [istr]) {
|
||||||
let n =
|
let n =
|
||||||
if vec::len(args) < 2u {
|
if vec::len(args) < 2u {
|
||||||
10u
|
10u
|
||||||
} else { uint::parse_buf(istr::bytes(args[1]), 10u) };
|
} else { uint::parse_buf(str::bytes(args[1]), 10u) };
|
||||||
let i = 0u;
|
let i = 0u;
|
||||||
while i < n { task::spawn(bind f(n)); i += 1u; }
|
while i < n { task::spawn(bind f(n)); i += 1u; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
use std;
|
use std;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::uint;
|
import std::uint;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::task;
|
import std::task;
|
||||||
|
|
||||||
fn f(n: uint) {
|
fn f(n: uint) {
|
||||||
|
@ -20,7 +20,7 @@ fn main(args: [istr]) {
|
||||||
let n = if vec::len(args) < 2u {
|
let n = if vec::len(args) < 2u {
|
||||||
100u
|
100u
|
||||||
} else {
|
} else {
|
||||||
uint::parse_buf(istr::bytes(args[1]), 10u)
|
uint::parse_buf(str::bytes(args[1]), 10u)
|
||||||
};
|
};
|
||||||
for each i in uint::range(0u, 100u) {
|
for each i in uint::range(0u, 100u) {
|
||||||
task::spawn(bind f(n));
|
task::spawn(bind f(n));
|
||||||
|
|
|
@ -13,7 +13,7 @@ use std;
|
||||||
import option = std::option::t;
|
import option = std::option::t;
|
||||||
import std::option::some;
|
import std::option::some;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::treemap;
|
import std::treemap;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::io;
|
import std::io;
|
||||||
|
@ -30,11 +30,11 @@ import std::comm::recv;
|
||||||
import std::comm::send;
|
import std::comm::send;
|
||||||
|
|
||||||
fn map(filename: &[u8], emit: &map_reduce::putter<[u8], int>) {
|
fn map(filename: &[u8], emit: &map_reduce::putter<[u8], int>) {
|
||||||
let f = io::file_reader(istr::unsafe_from_bytes(filename));
|
let f = io::file_reader(str::unsafe_from_bytes(filename));
|
||||||
|
|
||||||
while true {
|
while true {
|
||||||
alt read_word(f) {
|
alt read_word(f) {
|
||||||
some(w) { emit(istr::bytes(w), 1); }
|
some(w) { emit(str::bytes(w), 1); }
|
||||||
none. { break; }
|
none. { break; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ fn main(argv: [istr]) {
|
||||||
|
|
||||||
let iargs = [];
|
let iargs = [];
|
||||||
for a in vec::slice(argv, 1u, vec::len(argv)) {
|
for a in vec::slice(argv, 1u, vec::len(argv)) {
|
||||||
iargs += [istr::bytes(a)];
|
iargs += [str::bytes(a)];
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can get by with 8k stacks, and we'll probably exhaust our
|
// We can get by with 8k stacks, and we'll probably exhaust our
|
||||||
|
@ -239,7 +239,7 @@ fn read_word(r: io::reader) -> option<istr> {
|
||||||
|
|
||||||
|
|
||||||
if is_word_char(c) {
|
if is_word_char(c) {
|
||||||
w += istr::from_char(c);
|
w += str::from_char(c);
|
||||||
} else { if w != ~"" { ret some(w); } }
|
} else { if w != ~"" { ret some(w); } }
|
||||||
}
|
}
|
||||||
ret none;
|
ret none;
|
||||||
|
|
|
@ -13,7 +13,7 @@ use std;
|
||||||
import option = std::option::t;
|
import option = std::option::t;
|
||||||
import std::option::some;
|
import std::option::some;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::map;
|
import std::map;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::io;
|
import std::io;
|
||||||
|
@ -227,7 +227,7 @@ fn read_word(r: io::reader) -> option<istr> {
|
||||||
|
|
||||||
|
|
||||||
if is_word_char(c) {
|
if is_word_char(c) {
|
||||||
w += istr::from_char(c);
|
w += str::from_char(c);
|
||||||
} else { if w != ~"" { ret some(w); } }
|
} else { if w != ~"" { ret some(w); } }
|
||||||
}
|
}
|
||||||
ret none;
|
ret none;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// error-pattern:precondition constraint (for example, uint::le(a, b)
|
// error-pattern:precondition constraint (for example, uint::le(a, b)
|
||||||
use std;
|
use std;
|
||||||
import std::istr::*;
|
import std::str::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let a: uint = 4u;
|
let a: uint = 4u;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// error-pattern:Unsatisfied precondition constraint (for example, le(b, d
|
// error-pattern:Unsatisfied precondition constraint (for example, le(b, d
|
||||||
use std;
|
use std;
|
||||||
import std::istr::*;
|
import std::str::*;
|
||||||
import std::uint::*;
|
import std::uint::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import std::option;
|
||||||
import std::getopts;
|
import std::getopts;
|
||||||
import std::test;
|
import std::test;
|
||||||
import std::fs;
|
import std::fs;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::task;
|
import std::task;
|
||||||
|
|
||||||
|
@ -164,11 +164,11 @@ fn is_test(config: &config, testfile: &istr) -> bool {
|
||||||
let valid = false;
|
let valid = false;
|
||||||
|
|
||||||
for ext in valid_extensions {
|
for ext in valid_extensions {
|
||||||
if istr::ends_with(name, ext) { valid = true }
|
if str::ends_with(name, ext) { valid = true }
|
||||||
}
|
}
|
||||||
|
|
||||||
for pre in invalid_prefixes {
|
for pre in invalid_prefixes {
|
||||||
if istr::starts_with(name, pre) { valid = false }
|
if str::starts_with(name, pre) { valid = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
ret valid;
|
ret valid;
|
||||||
|
@ -210,7 +210,7 @@ fn make_test_closure(testfile: &istr, configchan: chan<[u8]>) ->
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_config(testfile: istr, configchan: chan<[u8]>) {
|
fn send_config(testfile: istr, configchan: chan<[u8]>) {
|
||||||
send(configchan, istr::bytes(testfile));
|
send(configchan, str::bytes(testfile));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::io;
|
import std::io;
|
||||||
import std::fs;
|
import std::fs;
|
||||||
|
|
||||||
|
@ -74,8 +74,8 @@ iter iter_header(testfile: &istr) -> istr {
|
||||||
// Assume that any directives will be found before the first
|
// Assume that any directives will be found before the first
|
||||||
// module or function. This doesn't seem to be an optimization
|
// module or function. This doesn't seem to be an optimization
|
||||||
// with a warm page cache. Maybe with a cold one.
|
// with a warm page cache. Maybe with a cold one.
|
||||||
if istr::starts_with(ln, ~"fn")
|
if str::starts_with(ln, ~"fn")
|
||||||
|| istr::starts_with(ln, ~"mod") {
|
|| str::starts_with(ln, ~"mod") {
|
||||||
break;
|
break;
|
||||||
} else { put ln; }
|
} else { put ln; }
|
||||||
}
|
}
|
||||||
|
@ -103,17 +103,17 @@ fn parse_pp_exact(line: &istr, testfile: &istr) -> option::t<istr> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_name_directive(line: &istr, directive: &istr) -> bool {
|
fn parse_name_directive(line: &istr, directive: &istr) -> bool {
|
||||||
istr::find(line, directive) >= 0
|
str::find(line, directive) >= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_name_value_directive(line: &istr,
|
fn parse_name_value_directive(line: &istr,
|
||||||
directive: &istr) -> option::t<istr> {
|
directive: &istr) -> option::t<istr> {
|
||||||
let keycolon = directive + ~":";
|
let keycolon = directive + ~":";
|
||||||
if istr::find(line, keycolon) >= 0 {
|
if str::find(line, keycolon) >= 0 {
|
||||||
let colon = istr::find(line, keycolon) as uint;
|
let colon = str::find(line, keycolon) as uint;
|
||||||
let value =
|
let value =
|
||||||
istr::slice(line, colon + istr::byte_len(keycolon),
|
str::slice(line, colon + str::byte_len(keycolon),
|
||||||
istr::byte_len(line));
|
str::byte_len(line));
|
||||||
log #ifmt("%s: %s", directive,
|
log #ifmt("%s: %s", directive,
|
||||||
value);
|
value);
|
||||||
option::some(value)
|
option::some(value)
|
||||||
|
|
|
@ -12,7 +12,7 @@ import std::vec;
|
||||||
import std::os;
|
import std::os;
|
||||||
import std::run;
|
import std::run;
|
||||||
import std::io;
|
import std::io;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::comm::chan;
|
import std::comm::chan;
|
||||||
import std::comm::port;
|
import std::comm::port;
|
||||||
import std::comm::send;
|
import std::comm::send;
|
||||||
|
@ -58,7 +58,7 @@ fn run(handle: &handle, lib_path: &istr, prog: &istr, args: &[istr],
|
||||||
let p = port();
|
let p = port();
|
||||||
let ch = chan(p);
|
let ch = chan(p);
|
||||||
send(handle.chan,
|
send(handle.chan,
|
||||||
exec(istr::bytes(lib_path), istr::bytes(prog), clone_vecstr(args),
|
exec(str::bytes(lib_path), str::bytes(prog), clone_vecstr(args),
|
||||||
ch));
|
ch));
|
||||||
let resp = recv(p);
|
let resp = recv(p);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ fn readclose(fd: int) -> istr {
|
||||||
let buf = ~"";
|
let buf = ~"";
|
||||||
while !reader.eof() {
|
while !reader.eof() {
|
||||||
let bytes = reader.read_bytes(4096u);
|
let bytes = reader.read_bytes(4096u);
|
||||||
buf += istr::unsafe_from_bytes(bytes);
|
buf += str::unsafe_from_bytes(bytes);
|
||||||
}
|
}
|
||||||
os::libc::fclose(file);
|
os::libc::fclose(file);
|
||||||
ret buf;
|
ret buf;
|
||||||
|
@ -114,8 +114,8 @@ fn worker(p: port<request>) {
|
||||||
// the alt discriminant are wrong.
|
// the alt discriminant are wrong.
|
||||||
alt recv(p) {
|
alt recv(p) {
|
||||||
exec(lib_path, prog, args, respchan) {
|
exec(lib_path, prog, args, respchan) {
|
||||||
{lib_path: istr::unsafe_from_bytes(lib_path),
|
{lib_path: str::unsafe_from_bytes(lib_path),
|
||||||
prog: istr::unsafe_from_bytes(prog),
|
prog: str::unsafe_from_bytes(prog),
|
||||||
args: clone_vecu8str(args),
|
args: clone_vecu8str(args),
|
||||||
respchan: respchan}
|
respchan: respchan}
|
||||||
}
|
}
|
||||||
|
@ -174,14 +174,14 @@ fn export_lib_path(path: &istr) {
|
||||||
|
|
||||||
fn clone_vecstr(v: &[istr]) -> [[u8]] {
|
fn clone_vecstr(v: &[istr]) -> [[u8]] {
|
||||||
let r = [];
|
let r = [];
|
||||||
for t: istr in vec::slice(v, 0u, vec::len(v)) { r += [istr::bytes(t)]; }
|
for t: istr in vec::slice(v, 0u, vec::len(v)) { r += [str::bytes(t)]; }
|
||||||
ret r;
|
ret r;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone_vecu8str(v: &[[u8]]) -> [istr] {
|
fn clone_vecu8str(v: &[[u8]]) -> [istr] {
|
||||||
let r = [];
|
let r = [];
|
||||||
for t in vec::slice(v, 0u, vec::len(v)) {
|
for t in vec::slice(v, 0u, vec::len(v)) {
|
||||||
r += [istr::unsafe_from_bytes(t)];
|
r += [str::unsafe_from_bytes(t)];
|
||||||
}
|
}
|
||||||
ret r;
|
ret r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import std::io;
|
import std::io;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::fs;
|
import std::fs;
|
||||||
import std::os;
|
import std::os;
|
||||||
|
@ -19,7 +19,7 @@ import util::logv;
|
||||||
export run;
|
export run;
|
||||||
|
|
||||||
fn run(cx: &cx, _testfile: -[u8]) {
|
fn run(cx: &cx, _testfile: -[u8]) {
|
||||||
let testfile = istr::unsafe_from_bytes(_testfile);
|
let testfile = str::unsafe_from_bytes(_testfile);
|
||||||
if cx.config.verbose {
|
if cx.config.verbose {
|
||||||
// We're going to be dumping a lot of info. Start on a new line.
|
// We're going to be dumping a lot of info. Start on a new line.
|
||||||
io::stdout().write_str(~"\n\n");
|
io::stdout().write_str(~"\n\n");
|
||||||
|
@ -116,9 +116,9 @@ fn run_pretty_test(cx: &cx, props: &test_props, testfile: &istr) {
|
||||||
if option::is_some(props.pp_exact) {
|
if option::is_some(props.pp_exact) {
|
||||||
// Now we have to care about line endings
|
// Now we have to care about line endings
|
||||||
let cr = ~"\r";
|
let cr = ~"\r";
|
||||||
check (istr::is_not_empty(cr));
|
check (str::is_not_empty(cr));
|
||||||
actual = istr::replace(actual, cr, ~"");
|
actual = str::replace(actual, cr, ~"");
|
||||||
expected = istr::replace(expected, cr, ~"");
|
expected = str::replace(expected, cr, ~"");
|
||||||
}
|
}
|
||||||
|
|
||||||
compare_source(expected, actual);
|
compare_source(expected, actual);
|
||||||
|
@ -188,8 +188,8 @@ fn check_error_patterns(props: &test_props, testfile: &istr,
|
||||||
|
|
||||||
let next_err_idx = 0u;
|
let next_err_idx = 0u;
|
||||||
let next_err_pat = props.error_patterns[next_err_idx];
|
let next_err_pat = props.error_patterns[next_err_idx];
|
||||||
for line: istr in istr::split(procres.stdout, '\n' as u8) {
|
for line: istr in str::split(procres.stdout, '\n' as u8) {
|
||||||
if istr::find(line, next_err_pat) > 0 {
|
if str::find(line, next_err_pat) > 0 {
|
||||||
log #ifmt["found error pattern %s",
|
log #ifmt["found error pattern %s",
|
||||||
next_err_pat];
|
next_err_pat];
|
||||||
next_err_idx += 1u;
|
next_err_idx += 1u;
|
||||||
|
@ -289,7 +289,7 @@ fn split_maybe_args(argstr: &option::t<istr>) -> [istr] {
|
||||||
}
|
}
|
||||||
|
|
||||||
alt argstr {
|
alt argstr {
|
||||||
option::some(s) { rm_whitespace(istr::split(s, ' ' as u8)) }
|
option::some(s) { rm_whitespace(str::split(s, ' ' as u8)) }
|
||||||
option::none. { [] }
|
option::none. { [] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,7 +315,7 @@ fn make_cmdline(libpath: &istr, prog: &istr, args: &[istr]) -> istr {
|
||||||
#ifmt["%s %s %s",
|
#ifmt["%s %s %s",
|
||||||
lib_path_cmd_prefix(libpath),
|
lib_path_cmd_prefix(libpath),
|
||||||
prog,
|
prog,
|
||||||
istr::connect(args, ~" ")]
|
str::connect(args, ~" ")]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the LD_LIBRARY_PATH variable as it would be seen on the command line
|
// Build the LD_LIBRARY_PATH variable as it would be seen on the command line
|
||||||
|
@ -357,10 +357,10 @@ fn output_base_name(config: &config, testfile: &istr) -> istr {
|
||||||
let base = config.build_base;
|
let base = config.build_base;
|
||||||
let filename =
|
let filename =
|
||||||
{
|
{
|
||||||
let parts = istr::split(fs::basename(testfile),
|
let parts = str::split(fs::basename(testfile),
|
||||||
'.' as u8);
|
'.' as u8);
|
||||||
parts = vec::slice(parts, 0u, vec::len(parts) - 1u);
|
parts = vec::slice(parts, 0u, vec::len(parts) - 1u);
|
||||||
istr::connect(parts, ~".")
|
str::connect(parts, ~".")
|
||||||
};
|
};
|
||||||
#ifmt["%s%s.%s", base, filename,
|
#ifmt["%s%s.%s", base, filename,
|
||||||
config.stage_id]
|
config.stage_id]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::generic_os::getenv;
|
import std::generic_os::getenv;
|
||||||
import std::io;
|
import std::io;
|
||||||
import std::istr;
|
import std::str;
|
||||||
|
|
||||||
import common::config;
|
import common::config;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// error-pattern:Predicate le(a, b) failed
|
// error-pattern:Predicate le(a, b) failed
|
||||||
use std;
|
use std;
|
||||||
import std::istr::*;
|
import std::str::*;
|
||||||
import std::uint::le;
|
import std::uint::le;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std;
|
use std;
|
||||||
import std::istr::*;
|
import std::str::*;
|
||||||
import std::uint::*;
|
import std::uint::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std;
|
use std;
|
||||||
import std::istr::*;
|
import std::str::*;
|
||||||
import std::uint::*;
|
import std::uint::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std;
|
use std;
|
||||||
import std::istr::*;
|
import std::str::*;
|
||||||
import std::uint::*;
|
import std::uint::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std;
|
use std;
|
||||||
import std::istr::*;
|
import std::str::*;
|
||||||
import std::uint::*;
|
import std::uint::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std;
|
use std;
|
||||||
import std::istr::*;
|
import std::str::*;
|
||||||
import std::uint::*;
|
import std::uint::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std;
|
||||||
import option = std::option::t;
|
import option = std::option::t;
|
||||||
import std::option::some;
|
import std::option::some;
|
||||||
import std::option::none;
|
import std::option::none;
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::vec;
|
import std::vec;
|
||||||
import std::map;
|
import std::map;
|
||||||
import std::task;
|
import std::task;
|
||||||
|
@ -50,7 +50,7 @@ mod map_reduce {
|
||||||
none. {
|
none. {
|
||||||
let p = port();
|
let p = port();
|
||||||
log_err "sending find_reducer";
|
log_err "sending find_reducer";
|
||||||
send(ctrl, find_reducer(istr::bytes(key), chan(p)));
|
send(ctrl, find_reducer(str::bytes(key), chan(p)));
|
||||||
log_err "receiving";
|
log_err "receiving";
|
||||||
c = recv(p);
|
c = recv(p);
|
||||||
log_err c;
|
log_err c;
|
||||||
|
@ -82,7 +82,7 @@ mod map_reduce {
|
||||||
mapper_done. { num_mappers -= 1; }
|
mapper_done. { num_mappers -= 1; }
|
||||||
find_reducer(k, cc) {
|
find_reducer(k, cc) {
|
||||||
let c;
|
let c;
|
||||||
alt reducers.find(istr::unsafe_from_bytes(k)) {
|
alt reducers.find(str::unsafe_from_bytes(k)) {
|
||||||
some(_c) { c = _c; }
|
some(_c) { c = _c; }
|
||||||
none. { c = 0; }
|
none. { c = 0; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
|
|
||||||
use std;
|
use std;
|
||||||
|
|
||||||
import std::istr;
|
import std::str;
|
||||||
import std::comm;
|
import std::comm;
|
||||||
import std::task;
|
import std::task;
|
||||||
|
|
||||||
type ctx = comm::chan<int>;
|
type ctx = comm::chan<int>;
|
||||||
|
|
||||||
fn iotask(cx: ctx, ip: -istr) { assert (istr::eq(ip, ~"localhost")); }
|
fn iotask(cx: ctx, ip: -istr) { assert (str::eq(ip, ~"localhost")); }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let p = comm::port::<int>();
|
let p = comm::port::<int>();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// -*- rust -*-
|
// -*- rust -*-
|
||||||
use std;
|
use std;
|
||||||
import std::istr;
|
import std::str;
|
||||||
|
|
||||||
fn test1() {
|
fn test1() {
|
||||||
let s: istr = ~"hello";
|
let s: istr = ~"hello";
|
||||||
|
@ -19,8 +19,8 @@ fn test2() {
|
||||||
let b: istr = ~"ABC" + ff + ~"ABC";
|
let b: istr = ~"ABC" + ff + ~"ABC";
|
||||||
log a;
|
log a;
|
||||||
log b;
|
log b;
|
||||||
assert (istr::eq(a, ~"abcABCabc"));
|
assert (str::eq(a, ~"abcABCabc"));
|
||||||
assert (istr::eq(b, ~"ABCabcABC"));
|
assert (str::eq(b, ~"ABCabcABC"));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { test1(); test2(); }
|
fn main() { test1(); test2(); }
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue