diff options
| author | Marijn Haverbeke <[email protected]> | 2011-05-06 22:13:13 +0200 |
|---|---|---|
| committer | Marijn Haverbeke <[email protected]> | 2011-05-06 22:51:19 +0200 |
| commit | a3ec0b1f643d00b9418e4884bd7caa07bf052201 (patch) | |
| tree | 82000510ac9c9cf3f0c7cf4ae5f3c6b123b559cb /src | |
| parent | Register new snapshots. (diff) | |
| download | rust-a3ec0b1f643d00b9418e4884bd7caa07bf052201.tar.xz rust-a3ec0b1f643d00b9418e4884bd7caa07bf052201.zip | |
Rename std modules to be camelcased
(Have fun mergining your stuff with this.)
Diffstat (limited to 'src')
100 files changed, 2150 insertions, 2151 deletions
diff --git a/src/comp/back/Link.rs b/src/comp/back/Link.rs index ebeda8dc..695d3202 100644 --- a/src/comp/back/Link.rs +++ b/src/comp/back/Link.rs @@ -1,8 +1,8 @@ import driver.session; import lib.llvm.llvm; import middle.trans; -import std._str; -import std.fs; +import std.Str; +import std.FS; import lib.llvm.llvm.ModuleRef; import lib.llvm.llvm.ValueRef; @@ -19,14 +19,14 @@ tag output_type { } fn llvm_err(session.session sess, str msg) { - sess.err(msg + ": " + _str.str_from_cstr(llvm.LLVMRustGetLastError())); + sess.err(msg + ": " + Str.str_from_cstr(llvm.LLVMRustGetLastError())); fail; } fn link_intrinsics(session.session sess, ModuleRef llmod) { - auto path = fs.connect(sess.get_opts().sysroot, "intrinsics.bc"); + auto path = FS.connect(sess.get_opts().sysroot, "intrinsics.bc"); auto membuf = - llvm.LLVMRustCreateMemoryBufferWithContentsOfFile(_str.buf(path)); + llvm.LLVMRustCreateMemoryBufferWithContentsOfFile(Str.buf(path)); if ((membuf as uint) == 0u) { llvm_err(sess, "installation problem: couldn't open intrinstics.bc"); fail; @@ -58,12 +58,12 @@ mod Write { // Decides what to call an intermediate file, given the name of the output // and the extension to use. fn mk_intermediate_name(str output_path, str extension) -> str { - auto dot_pos = _str.index(output_path, '.' as u8); + auto dot_pos = Str.index(output_path, '.' as u8); auto stem; if (dot_pos < 0) { stem = output_path; } else { - stem = _str.substr(output_path, 0u, dot_pos as uint); + stem = Str.substr(output_path, 0u, dot_pos as uint); } ret stem + "." + extension; } @@ -86,12 +86,12 @@ mod Write { auto filename = mk_intermediate_name(output, "no-opt.bc"); llvm.LLVMWriteBitcodeToFile(llmod, - _str.buf(filename)); + Str.buf(filename)); } } case (_) { auto filename = mk_intermediate_name(output, "bc"); - llvm.LLVMWriteBitcodeToFile(llmod, _str.buf(filename)); + llvm.LLVMWriteBitcodeToFile(llmod, Str.buf(filename)); } } } @@ -183,15 +183,15 @@ mod Write { "opt.bc"); llvm.LLVMRunPassManager(pm.llpm, llmod); llvm.LLVMWriteBitcodeToFile(llmod, - _str.buf(filename)); + Str.buf(filename)); pm = mk_pass_manager(); } } } llvm.LLVMRustWriteOutputFile(pm.llpm, llmod, - _str.buf(x86.get_target_triple()), - _str.buf(output), + Str.buf(x86.get_target_triple()), + Str.buf(output), FileType); llvm.LLVMDisposeModule(llmod); ret; @@ -199,7 +199,7 @@ mod Write { llvm.LLVMRunPassManager(pm.llpm, llmod); - llvm.LLVMWriteBitcodeToFile(llmod, _str.buf(output)); + llvm.LLVMWriteBitcodeToFile(llmod, Str.buf(output)); llvm.LLVMDisposeModule(llmod); } } diff --git a/src/comp/back/x86.rs b/src/comp/back/x86.rs index 855bd51b..bad4eb3e 100644 --- a/src/comp/back/x86.rs +++ b/src/comp/back/x86.rs @@ -1,8 +1,8 @@ import lib.llvm.llvm; import lib.llvm.llvm.ModuleRef; -import std._str; -import std._vec; -import std.os.target_os; +import std.Str; +import std.Vec; +import std.OS.target_os; import util.common.istr; const int wordsz = 4; @@ -241,7 +241,7 @@ fn native_glue(int n_args, abi.native_glue_type ngt) -> vec[str] { } auto m = vec("movl " + src_off + "(%ebp),%eax", "movl %eax," + dst_off + "(%esp)"); - ret _str.connect(m, "\n\t"); + ret Str.connect(m, "\n\t"); } auto carg = bind copy_arg(pass_task, _); @@ -259,7 +259,7 @@ fn native_glue(int n_args, abi.native_glue_type ngt) -> vec[str] { + vec("subl $" + wstr(n_args) + ", %esp # esp -= args", "andl $~0xf, %esp # align esp down") - + _vec.init_fn[str](carg, (n_args) as uint) + + Vec.init_fn[str](carg, (n_args) as uint) + vec("movl %edx, %edi # save task from edx to edi", "call *%ecx # call *%ecx", @@ -278,7 +278,7 @@ fn decl_glue(int align, str prefix, str name, vec[str] insns) -> str { ret "\t.globl " + sym + "\n" + "\t.balign " + istr(align) + "\n" + sym + ":\n" + - "\t" + _str.connect(insns, "\n\t"); + "\t" + Str.connect(insns, "\n\t"); } @@ -291,8 +291,8 @@ fn decl_native_glue(int align, str prefix, abi.native_glue_type ngt, uint n) } fn get_symbol_prefix() -> str { - if (_str.eq(target_os(), "macos") || - _str.eq(target_os(), "win32")) { + if (Str.eq(target_os(), "macos") || + Str.eq(target_os(), "win32")) { ret "_"; } else { ret ""; @@ -313,44 +313,44 @@ fn get_module_asm() -> str { abi.yield_glue_name(), rust_yield_glue())) - + _vec.init_fn[str](bind decl_native_glue(align, prefix, + + Vec.init_fn[str](bind decl_native_glue(align, prefix, abi.ngt_rust, _), (abi.n_native_glues + 1) as uint) - + _vec.init_fn[str](bind decl_native_glue(align, prefix, + + Vec.init_fn[str](bind decl_native_glue(align, prefix, abi.ngt_pure_rust, _), (abi.n_native_glues + 1) as uint) - + _vec.init_fn[str](bind decl_native_glue(align, prefix, + + Vec.init_fn[str](bind decl_native_glue(align, prefix, abi.ngt_cdecl, _), (abi.n_native_glues + 1) as uint); - ret _str.connect(glues, "\n\n"); + ret Str.connect(glues, "\n\n"); } fn get_meta_sect_name() -> str { - if (_str.eq(target_os(), "macos")) { + if (Str.eq(target_os(), "macos")) { ret "__DATA,__note.rustc"; } - if (_str.eq(target_os(), "win32")) { + if (Str.eq(target_os(), "win32")) { ret ".note.rustc"; } ret ".note.rustc"; } fn get_data_layout() -> str { - if (_str.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-i32:32:32-i64:32:64" + "-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" + "-n8:16:32"; } - if (_str.eq(target_os(), "win32")) { + if (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:32:64-i64:32:64-f80:32:32-n8:16:32"; } fn get_target_triple() -> str { - if (_str.eq(target_os(), "macos")) { + if (Str.eq(target_os(), "macos")) { ret "i686-apple-darwin"; } - if (_str.eq(target_os(), "win32")) { + if (Str.eq(target_os(), "win32")) { ret "i686-pc-mingw32"; } ret "i686-unknown-linux-gnu"; diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index 9c6c352d..cb8b676d 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -15,14 +15,14 @@ import back.Link; import lib.llvm; import util.common; -import std.fs; -import std.map.mk_hashmap; -import std.option; -import std.option.some; -import std.option.none; -import std._str; -import std._vec; -import std.io; +import std.FS; +import std.Map.mk_hashmap; +import std.Option; +import std.Option.some; +import std.Option.none; +import std.Str; +import std.Vec; +import std.IO; import std.Time; import std.GetOpts; @@ -47,7 +47,7 @@ fn default_environment(session.session sess, ret vec( // Target bindings. - tup("target_os", eval.val_str(std.os.target_os())), + tup("target_os", eval.val_str(std.OS.target_os())), tup("target_arch", eval.val_str("x86")), tup("target_libc", eval.val_str(libc)), @@ -60,9 +60,9 @@ fn default_environment(session.session sess, fn parse_input(session.session sess, parser.parser p, str input) -> @ast.crate { - if (_str.ends_with(input, ".rc")) { + if (Str.ends_with(input, ".rc")) { ret parser.parse_crate_from_crate_file(p); - } else if (_str.ends_with(input, ".rs")) { + } else if (Str.ends_with(input, ".rs")) { ret parser.parse_crate_from_source_file(p); } sess.err("unknown input file type: " + input); @@ -123,20 +123,20 @@ fn pretty_print_input(session.session sess, auto def = tup(0, 0); auto p = front.parser.new_parser(sess, env, def, input, 0u); auto crate = front.parser.parse_crate_from_source_file(p); - pretty.pprust.print_file(crate.node.module, input, std.io.stdout()); + pretty.pprust.print_file(crate.node.module, input, std.IO.stdout()); } fn version(str argv0) { auto vers = "unknown version"; auto env_vers = #env("CFG_VERSION"); - if (_str.byte_len(env_vers) != 0u) { + if (Str.byte_len(env_vers) != 0u) { vers = env_vers; } - io.stdout().write_str(#fmt("%s %s\n", argv0, vers)); + IO.stdout().write_str(#fmt("%s %s\n", argv0, vers)); } fn usage(str argv0) { - io.stdout().write_str(#fmt("usage: %s [options] <input>\n", argv0) + " + IO.stdout().write_str(#fmt("usage: %s [options] <input>\n", argv0) + " options: -h --help display this message @@ -162,38 +162,38 @@ options: } fn get_os(str triple) -> session.os { - if (_str.find(triple, "win32") > 0 || - _str.find(triple, "mingw32") > 0 ) { + if (Str.find(triple, "win32") > 0 || + Str.find(triple, "mingw32") > 0 ) { ret session.os_win32; - } else if (_str.find(triple, "darwin") > 0) { ret session.os_macos; } - else if (_str.find(triple, "linux") > 0) { ret session.os_linux; } + } else if (Str.find(triple, "darwin") > 0) { ret session.os_macos; } + else if (Str.find(triple, "linux") > 0) { ret session.os_linux; } } fn get_arch(str triple) -> session.arch { - if (_str.find(triple, "i386") > 0 || - _str.find(triple, "i486") > 0 || - _str.find(triple, "i586") > 0 || - _str.find(triple, "i686") > 0 || - _str.find(triple, "i786") > 0 ) { + if (Str.find(triple, "i386") > 0 || + Str.find(triple, "i486") > 0 || + Str.find(triple, "i586") > 0 || + Str.find(triple, "i686") > 0 || + Str.find(triple, "i786") > 0 ) { ret session.arch_x86; - } else if (_str.find(triple, "x86_64") > 0) { + } else if (Str.find(triple, "x86_64") > 0) { ret session.arch_x64; - } else if (_str.find(triple, "arm") > 0 || - _str.find(triple, "xscale") > 0 ) { + } else if (Str.find(triple, "arm") > 0 || + Str.find(triple, "xscale") > 0 ) { ret session.arch_arm; } } fn get_default_sysroot(str binary) -> str { - auto dirname = fs.dirname(binary); - if (_str.eq(dirname, binary)) { ret "."; } + auto dirname = FS.dirname(binary); + if (Str.eq(dirname, binary)) { ret "."; } ret dirname; } fn main(vec[str] args) { let str triple = - std._str.rustrt.str_from_cstr(llvm.llvm.LLVMRustGetHostTriple()); + std.Str.rustrt.str_from_cstr(llvm.llvm.LLVMRustGetHostTriple()); let @session.config target_cfg = @rec(os = get_os(triple), @@ -211,7 +211,7 @@ fn main(vec[str] args) { optflag("save-temps"), optopt("sysroot"), optflag("time-passes"), optflag("no-typestate"), optflag("noverify")); - auto binary = _vec.shift[str](args); + auto binary = Vec.shift[str](args); auto match; alt (GetOpts.getopts(args, opts)) { case (GetOpts.failure(?f)) { @@ -282,13 +282,13 @@ fn main(vec[str] args) { session.session(target_crate_num, target_cfg, sopts, crate_cache, md, front.codemap.new_codemap()); - auto n_inputs = _vec.len[str](match.free); + auto n_inputs = Vec.len[str](match.free); if (glue) { if (n_inputs > 0u) { sess.err("No input files allowed with --glue."); } - auto out = option.from_maybe[str]("glue.bc", output_file); + auto out = Option.from_maybe[str]("glue.bc", output_file); middle.trans.make_common_glue(sess, out); ret; } @@ -304,19 +304,19 @@ fn main(vec[str] args) { if (pretty) { pretty_print_input(sess, env, ifile); } else if (ls) { - front.creader.list_file_metadata(ifile, std.io.stdout()); + front.creader.list_file_metadata(ifile, std.IO.stdout()); } else { alt (output_file) { case (none[str]) { - let vec[str] parts = _str.split(ifile, '.' as u8); - _vec.pop[str](parts); + let vec[str] parts = Str.split(ifile, '.' as u8); + Vec.pop[str](parts); alt (output_type) { case (Link.output_type_none) { parts += vec("pp"); } case (Link.output_type_bitcode) { parts += vec("bc"); } case (Link.output_type_assembly) { parts += vec("s"); } case (Link.output_type_object) { parts += vec("o"); } } - auto ofile = _str.connect(parts, "."); + auto ofile = Str.connect(parts, "."); compile_input(sess, env, ifile, ofile); } case (some[str](?ofile)) { diff --git a/src/comp/driver/session.rs b/src/comp/driver/session.rs index cf34bb7c..644846d0 100644 --- a/src/comp/driver/session.rs +++ b/src/comp/driver/session.rs @@ -2,10 +2,10 @@ import front.ast; import front.codemap; import util.common.span; import util.common.ty_mach; -import std._uint; +import std.UInt; import std.Term; -import std.io; -import std.map; +import std.IO; +import std.Map; tag os { os_win32; @@ -42,25 +42,25 @@ type crate_metadata = rec(str name, fn emit_diagnostic(span sp, str msg, str kind, u8 color, codemap.codemap cm) { auto lo = codemap.lookup_pos(cm, sp.lo); auto hi = codemap.lookup_pos(cm, sp.hi); - io.stdout().write_str(#fmt("%s:%u:%u:%u:%u: ", lo.filename, lo.line, + IO.stdout().write_str(#fmt("%s:%u:%u:%u:%u: ", lo.filename, lo.line, lo.col, hi.line, hi.col)); if (Term.color_supported()) { - Term.fg(io.stdout().get_buf_writer(), color); + Term.fg(IO.stdout().get_buf_writer(), color); } - io.stdout().write_str(#fmt("%s:", kind)); + IO.stdout().write_str(#fmt("%s:", kind)); if (Term.color_supported()) { - Term.reset(io.stdout().get_buf_writer()); + Term.reset(IO.stdout().get_buf_writer()); } - io.stdout().write_str(#fmt(" %s\n", msg)); + IO.stdout().write_str(#fmt(" %s\n", msg)); } state obj session(ast.crate_num cnum, @config targ_cfg, @options opts, - map.hashmap[int, crate_metadata] crates, + Map.hashmap[int, crate_metadata] crates, mutable vec[@ast.meta_item] metadata, codemap.codemap cm) { diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 574ebd4a..0e15c964 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -1,8 +1,8 @@ -import std.map.hashmap; -import std.option; -import std._str; -import std._vec; +import std.Map.hashmap; +import std.Option; +import std.Str; +import std.Vec; import util.common.span; import util.common.spanned; import util.common.ty_mach; @@ -24,8 +24,8 @@ type ty_param = ident; tag ann { ann_none; ann_type(middle.ty.t, - option.t[vec[middle.ty.t]], /* ty param substs */ - option.t[@ts_ann]); /* pre- and postcondition for typestate */ + Option.t[vec[middle.ty.t]], /* ty param substs */ + Option.t[@ts_ann]); /* pre- and postcondition for typestate */ } tag def { @@ -79,8 +79,8 @@ tag crate_directive_ { // and redirected to the use of const stmt_decls inside // crate directive blocks. cdir_let(ident, @expr, vec[@crate_directive]); - cdir_src_mod(ident, option.t[filename]); - cdir_dir_mod(ident, option.t[filename], vec[@crate_directive]); + cdir_src_mod(ident, Option.t[filename]); + cdir_dir_mod(ident, Option.t[filename], vec[@crate_directive]); cdir_view_item(@view_item); cdir_meta(vec[@meta_item]); cdir_syntax(path); @@ -100,7 +100,7 @@ tag block_index_entry { bie_tag_variant(@item /* tag item */, uint /* variant index */); } type block_ = rec(vec[@stmt] stmts, - option.t[@expr] expr, + Option.t[@expr] expr, hashmap[ident,block_index_entry] index, ann a); /* ann is only meaningful for the ts_ann field */ @@ -111,7 +111,7 @@ tag pat_ { pat_wild(ann); pat_bind(ident, def_id, ann); pat_lit(@lit, ann); - pat_tag(path, vec[@pat], option.t[variant_def], ann); + pat_tag(path, vec[@pat], Option.t[variant_def], ann); } tag mutability { @@ -226,10 +226,10 @@ tag init_op { type initializer = rec(init_op op, @expr expr); -type local = rec(option.t[@ty] ty, +type local = rec(Option.t[@ty] ty, bool infer, ident ident, - option.t[initializer] init, + Option.t[initializer] init, def_id id, ann ann); @@ -253,16 +253,16 @@ type expr = spanned[expr_]; tag expr_ { expr_vec(vec[@expr], mutability, ann); expr_tup(vec[elt], ann); - expr_rec(vec[field], option.t[@expr], ann); + expr_rec(vec[field], Option.t[@expr], ann); expr_call(@expr, vec[@expr], ann); expr_self_method(ident, ann); - expr_bind(@expr, vec[option.t[@expr]], ann); - expr_spawn(spawn_dom, option.t[str], @expr, vec[@expr], ann); + expr_bind(@expr, vec[Option.t[@expr]], ann); + expr_spawn(spawn_dom, Option.t[str], @expr, vec[@expr], ann); expr_binary(binop, @expr, @expr, ann); expr_unary(unop, @expr, ann); expr_lit(@lit, ann); expr_cast(@expr, @ty, ann); - expr_if(@expr, block, option.t[@expr], ann); + expr_if(@expr, block, Option.t[@expr], ann); expr_while(@expr, block, ann); expr_for(@decl, @expr, block, ann); expr_for_each(@decl, @expr, block, ann); @@ -275,13 +275,13 @@ tag expr_ { expr_recv(@expr /* TODO: @expr|is_lval */, @expr, ann); expr_field(@expr, ident, ann); expr_index(@expr, @expr, ann); - expr_path(path, option.t[def], ann); - expr_ext(path, vec[@expr], option.t[str], @expr, ann); + expr_path(path, Option.t[def], ann); + expr_ext(path, vec[@expr], Option.t[str], @expr, ann); expr_fail(ann); expr_break(ann); expr_cont(ann); - expr_ret(option.t[@expr], ann); - expr_put(option.t[@expr], ann); + expr_ret(Option.t[@expr], ann); + expr_put(Option.t[@expr], ann); expr_be(@expr, ann); expr_log(int, @expr, ann); /* just an assert, no significance to typestate */ @@ -331,7 +331,7 @@ tag ty_ { ty_rec(vec[ty_field]); ty_fn(proto, vec[ty_arg], @ty); ty_obj(vec[ty_method]); - ty_path(path, option.t[def]); + ty_path(path, Option.t[def]); ty_type; ty_constr(@ty, vec[@constr]); } @@ -364,7 +364,7 @@ type method = spanned[method_]; type obj_field = rec(@ty ty, ident ident, def_id id, ann ann); type _obj = rec(vec[obj_field] fields, vec[@method] methods, - option.t[@method] dtor); + Option.t[@method] dtor); tag mod_index_entry { mie_view_item(@view_item); @@ -402,8 +402,8 @@ type variant = spanned[variant_]; type view_item = spanned[view_item_]; tag view_item_ { - view_item_use(ident, vec[@meta_item], def_id, option.t[int]); - view_item_import(ident, vec[ident], def_id, option.t[def]); + view_item_use(ident, vec[@meta_item], def_id, Option.t[int]); + view_item_import(ident, vec[ident], def_id, Option.t[def]); view_item_export(ident); } @@ -423,7 +423,7 @@ tag item_ { type native_item = spanned[native_item_]; tag native_item_ { native_item_ty(ident, def_id); - native_item_fn(ident, option.t[str], + native_item_fn(ident, Option.t[str], fn_decl, vec[ty_param], def_id, ann); } @@ -542,7 +542,7 @@ fn is_exported(ident i, _mod m) -> bool { for (@ast.view_item vi in m.view_items) { alt (vi.node) { case (ast.view_item_export(?id)) { - if (_str.eq(i, id)) { + if (Str.eq(i, id)) { ret true; } count += 1; @@ -574,7 +574,7 @@ fn is_constraint_arg(@expr e) -> bool { case (expr_lit(_,_)) { ret true; } - case (expr_path(_, option.some[def](def_local(_)), _)) { + case (expr_path(_, Option.some[def](def_local(_)), _)) { ret true; } case (_) { diff --git a/src/comp/front/codemap.rs b/src/comp/front/codemap.rs index 402b4884..578f574b 100644 --- a/src/comp/front/codemap.rs +++ b/src/comp/front/codemap.rs @@ -1,4 +1,4 @@ -import std._vec; +import std.Vec; /* A codemap is a thing that maps uints to file/line/column positions * in a crate. This to make it possible to represent the positions @@ -24,18 +24,18 @@ fn new_filemap(str filename, uint start_pos) -> filemap { } fn next_line(filemap file, uint pos) { - _vec.push[uint](file.lines, pos); + Vec.push[uint](file.lines, pos); } fn lookup_pos(codemap map, uint pos) -> loc { - auto a = 0u; auto b = _vec.len[filemap](map.files); + auto a = 0u; auto b = Vec.len[filemap](map.files); while (b - a > 1u) { auto m = (a + b) / 2u; if (map.files.(m).start_pos > pos) { b = m; } else { a = m; } } auto f = map.files.(a); - a = 0u; b = _vec.len[uint](f.lines); + a = 0u; b = Vec.len[uint](f.lines); while (b - a > 1u) { auto m = (a + b) / 2u; if (f.lines.(m) > pos) { b = m; } diff --git a/src/comp/front/creader.rs b/src/comp/front/creader.rs index a9660bf5..d5067b25 100644 --- a/src/comp/front/creader.rs +++ b/src/comp/front/creader.rs @@ -14,17 +14,17 @@ import back.x86; import util.common; import util.common.span; -import std._str; -import std._uint; -import std._vec; -import std.ebml; -import std.fs; -import std.io; -import std.option; -import std.option.none; -import std.option.some; -import std.os; -import std.map.hashmap; +import std.Str; +import std.UInt; +import std.Vec; +import std.EBML; +import std.FS; +import std.IO; +import std.Option; +import std.Option.none; +import std.Option.some; +import std.OS; +import std.Map.hashmap; // TODO: map to a real type here. type env = @rec( @@ -122,7 +122,7 @@ fn parse_ty(@pstate st, str_def sd) -> ty.t { while (peek(st) as char != ']') { auto name = ""; while (peek(st) as char != '=') { - name += _str.unsafe_from_byte(next(st)); + name += Str.unsafe_from_byte(next(st)); } st.pos = st.pos + 1u; fields += vec(rec(ident=name, mt=parse_mt(st, sd))); @@ -160,7 +160,7 @@ fn parse_ty(@pstate st, str_def sd) -> ty.t { } auto name = ""; while (peek(st) as char != '[') { - name += _str.unsafe_from_byte(next(st)); + name += Str.unsafe_from_byte(next(st)); } auto func = parse_ty_fn(st, sd); methods += vec(rec(proto=proto, @@ -210,7 +210,7 @@ fn parse_mt(@pstate st, str_def sd) -> ty.mt { fn parse_def(@pstate st, str_def sd) -> ast.def_id { auto def = ""; while (peek(st) as char != '|') { - def += _str.unsafe_from_byte(next(st)); + def += Str.unsafe_from_byte(next(st)); } st.pos = st.pos + 1u; ret sd(def); @@ -265,7 +265,7 @@ fn parse_ty_fn(@pstate st, str_def sd) -> tup(vec[ty.arg], ty.t) { fn parse_def_id(vec[u8] buf) -> ast.def_id { auto colon_idx = 0u; - auto len = _vec.len[u8](buf); + auto len = Vec.len[u8](buf); while (colon_idx < len && buf.(colon_idx) != (':' as u8)) { colon_idx += 1u; } @@ -274,30 +274,30 @@ fn parse_def_id(vec[u8] buf) -> ast.def_id { fail; } - auto crate_part = _vec.slice[u8](buf, 0u, colon_idx); - auto def_part = _vec.slice[u8](buf, colon_idx + 1u, len); - auto crate_num = _uint.parse_buf(crate_part, 10u) as int; - auto def_num = _uint.parse_buf(def_part, 10u) as int; + auto crate_part = Vec.slice[u8](buf, 0u, colon_idx); + auto def_part = Vec.slice[u8](buf, colon_idx + 1u, len); + auto crate_num = UInt.parse_buf(crate_part, 10u) as int; + auto def_num = UInt.parse_buf(def_part, 10u) as int; ret tup(crate_num, def_num); } -fn lookup_hash(&ebml.doc d, fn(vec[u8]) -> bool eq_fn, uint hash) - -> option.t[ebml.doc] { - auto index = ebml.get_doc(d, metadata.tag_index); - auto table = ebml.get_doc(index, metadata.tag_index_table); +fn lookup_hash(&EBML.doc d, fn(vec[u8]) -> bool eq_fn, uint hash) + -> Option.t[EBML.doc] { + auto index = EBML.get_doc(d, metadata.tag_index); + auto table = EBML.get_doc(index, metadata.tag_index_table); auto hash_pos = table.start + (hash % 256u) * 4u; - auto pos = ebml.be_uint_from_bytes(d.data, hash_pos, 4u); - auto bucket = ebml.doc_at(d.data, pos); + auto pos = EBML.be_uint_from_bytes(d.data, hash_pos, 4u); + auto bucket = EBML.doc_at(d.data, pos); // Awkward logic because we can't ret from foreach yet - auto result = option.none[ebml.doc]; + auto result = Option.none[EBML.doc]; auto belt = metadata.tag_index_buckets_bucket_elt; - for each (ebml.doc elt in ebml.tagged_docs(bucket, belt)) { + for each (EBML.doc elt in EBML.tagged_docs(bucket, belt)) { alt (result) { - case (option.none[ebml.doc]) { - auto pos = ebml.be_uint_from_bytes(elt.data, elt.start, 4u); - if (eq_fn(_vec.slice[u8](elt.data, elt.start+4u, elt.end))) { - result = option.some[ebml.doc](ebml.doc_at(d.data, pos)); + case (Option.none[EBML.doc]) { + auto pos = EBML.be_uint_from_bytes(elt.data, elt.start, 4u); + if (eq_fn(Vec.slice[u8](elt.data, elt.start+4u, elt.end))) { + result = Option.some[EBML.doc](EBML.doc_at(d.data, pos)); } } case (_) {} @@ -310,113 +310,113 @@ fn lookup_hash(&ebml.doc d, fn(vec[u8]) -> bool eq_fn, uint hash) // definition the path refers to. fn resolve_path(vec[ast.ident] path, vec[u8] data) -> resolve_result { fn eq_item(vec[u8] data, str s) -> bool { - ret _str.eq(_str.unsafe_from_bytes(data), s); + ret Str.eq(Str.unsafe_from_bytes(data), s); } - auto s = _str.connect(path, "."); - auto md = ebml.new_doc(data); - auto paths = ebml.get_doc(md, metadata.tag_paths); + auto s = Str.connect(path, "."); + auto md = EBML.new_doc(data); + auto paths = EBML.get_doc(md, metadata.tag_paths); auto eqer = bind eq_item(_, s); alt (lookup_hash(paths, eqer, metadata.hash_path(s))) { - case (option.some[ebml.doc](?d)) { - auto did_doc = ebml.get_doc(d, metadata.tag_def_id); - ret rr_ok(parse_def_id(ebml.doc_data(did_doc))); + case (Option.some[EBML.doc](?d)) { + auto did_doc = EBML.get_doc(d, metadata.tag_def_id); + ret rr_ok(parse_def_id(EBML.doc_data(did_doc))); } - case (option.none[ebml.doc]) { + case (Option.none[EBML.doc]) { ret rr_not_found(s); } } } -fn maybe_find_item(int item_id, &ebml.doc items) -> option.t[ebml.doc] { +fn maybe_find_item(int item_id, &EBML.doc items) -> Option.t[EBML.doc] { fn eq_item(vec[u8] bytes, int item_id) -> bool { - ret ebml.be_uint_from_bytes(bytes, 0u, 4u) as int == item_id; + ret EBML.be_uint_from_bytes(bytes, 0u, 4u) as int == item_id; } auto eqer = bind eq_item(_, item_id); ret lookup_hash(items, eqer, metadata.hash_def_num(item_id)); } -fn find_item(int item_id, &ebml.doc items) -> ebml.doc { +fn find_item(int item_id, &EBML.doc items) -> EBML.doc { alt (maybe_find_item(item_id, items)) { - case (option.some[ebml.doc](?d)) {ret d;} + case (Option.some[EBML.doc](?d)) {ret d;} } } // Looks up an item in the given metadata and returns an EBML doc pointing // to the item data. -fn lookup_item(int item_id, vec[u8] data) -> ebml.doc { - auto items = ebml.get_doc(ebml.new_doc(data), metadata.tag_items); +fn lookup_item(int item_id, vec[u8] data) -> EBML.doc { + auto items = EBML.get_doc(EBML.new_doc(data), metadata.tag_items); ret find_item(item_id, items); } -fn item_kind(&ebml.doc item) -> u8 { - auto kind = ebml.get_doc(item, metadata.tag_items_data_item_kind); - ret ebml.doc_as_uint(kind) as u8; +fn item_kind(&EBML.doc item) -> u8 { + auto kind = EBML.get_doc(item, metadata.tag_items_data_item_kind); + ret EBML.doc_as_uint(kind) as u8; } -fn item_symbol(&ebml.doc item) -> str { - auto sym = ebml.get_doc(item, metadata.tag_items_data_item_symbol); - ret _str.unsafe_from_bytes(ebml.doc_data(sym)); +fn item_symbol(&EBML.doc item) -> str { + auto sym = EBML.get_doc(item, metadata.tag_items_data_item_symbol); + ret Str.unsafe_from_bytes(EBML.doc_data(sym)); } -fn variant_tag_id(&ebml.doc d) -> ast.def_id { - auto tagdoc = ebml.get_doc(d, metadata.tag_items_data_item_tag_id); - ret parse_def_id(ebml.doc_data(tagdoc)); +fn variant_tag_id(&EBML.doc d) -> ast.def_id { + auto tagdoc = EBML.get_doc(d, metadata.tag_items_data_item_tag_id); + ret parse_def_id(EBML.doc_data(tagdoc)); } -fn item_type(&ebml.doc item, int this_cnum, ty.ctxt tcx) -> ty.t { +fn item_type(&EBML.doc item, int this_cnum, ty.ctxt tcx) -> ty.t { fn parse_external_def_id(int this_cnum, str s) -> ast.def_id { // FIXME: This is completely wrong when linking against a crate // that, in turn, links against another crate. We need a mapping // from crate ID to crate "meta" attributes as part of the crate // metadata. - auto buf = _str.bytes(s); + auto buf = Str.bytes(s); auto external_def_id = parse_def_id(buf); ret tup(this_cnum, external_def_id._1); } - auto tp = ebml.get_doc(item, metadata.tag_items_data_item_type); - auto s = _str.unsafe_from_bytes(ebml.doc_data(tp)); + auto tp = EBML.get_doc(item, metadata.tag_items_data_item_type); + auto s = Str.unsafe_from_bytes(EBML.doc_data(tp)); ret parse_ty_data(item.data, this_cnum, tp.start, tp.end - tp.start, bind parse_external_def_id(this_cnum, _), tcx); } -fn item_ty_param_count(&ebml.doc item, int this_cnum) -> uint { +fn item_ty_param_count(&EBML.doc item, int this_cnum) -> uint { let uint ty_param_count = 0u; auto tp = metadata.tag_items_data_item_ty_param_count; - for each (ebml.doc p in ebml.tagged_docs(item, tp)) { - ty_param_count = ebml.vint_at(ebml.doc_data(p), 0u)._0; + for each (EBML.doc p in EBML.tagged_docs(item, tp)) { + ty_param_count = EBML.vint_at(EBML.doc_data(p), 0u)._0; } ret ty_param_count; } -fn tag_variant_ids(&ebml.doc item, int this_cnum) -> vec[ast.def_id] { +fn tag_variant_ids(&EBML.doc item, int this_cnum) -> vec[ast.def_id] { let vec[ast.def_id] ids = vec(); auto v = metadata.tag_items_data_item_variant; - for each (ebml.doc p in ebml.tagged_docs(item, v)) { - auto ext = parse_def_id(ebml.doc_data(p)); - _vec.push[ast.def_id](ids, tup(this_cnum, ext._1)); + for each (EBML.doc p in EBML.tagged_docs(item, v)) { + auto ext = parse_def_id(EBML.doc_data(p)); + Vec.push[ast.def_id](ids, tup(this_cnum, ext._1)); } ret ids; } -fn get_metadata_section(str filename) -> option.t[vec[u8]] { +fn get_metadata_section(str filename) -> Option.t[vec[u8]] { auto mb = llvm.LLVMRustCreateMemoryBufferWithContentsOfFile - (_str.buf(filename)); - if (mb as int == 0) {ret option.none[vec[u8]];} + (Str.buf(filename)); + if (mb as int == 0) {ret Option.none[vec[u8]];} auto of = mk_object_file(mb); auto si = mk_section_iter(of.llof); while (llvm.LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False) { auto name_buf = llvm.LLVMGetSectionName(si.llsi); - auto name = _str.str_from_cstr(name_buf); - if (_str.eq(name, x86.get_meta_sect_name())) { + auto name = Str.str_from_cstr(name_buf); + if (Str.eq(name, x86.get_meta_sect_name())) { auto cbuf = llvm.LLVMGetSectionContents(si.llsi); auto csz = llvm.LLVMGetSectionSize(si.llsi); - auto cvbuf = cbuf as _vec.vbuf; - ret option.some[vec[u8]](_vec.vec_from_vbuf[u8](cvbuf, csz)); + auto cvbuf = cbuf as Vec.vbuf; + ret Option.some[vec[u8]](Vec.vec_from_vbuf[u8](cvbuf, csz)); } llvm.LLVMMoveToNextSection(si.llsi); } - ret option.none[vec[u8]]; + ret Option.none[vec[u8]]; } @@ -426,9 +426,9 @@ fn load_crate(session.session sess, vec[str] library_search_paths) { auto filename = parser.default_native_name(sess, ident); for (str library_search_path in library_search_paths) { - auto path = fs.connect(library_search_path, filename); + auto path = FS.connect(library_search_path, filename); alt (get_metadata_section(path)) { - case (option.some[vec[u8]](?cvec)) { + case (Option.some[vec[u8]](?cvec)) { sess.set_external_crate(cnum, rec(name=ident, data=cvec)); ret; } @@ -442,7 +442,7 @@ fn load_crate(session.session sess, } fn fold_view_item_use(&env e, &span sp, ast.ident ident, - vec[@ast.meta_item] meta_items, ast.def_id id, option.t[int] cnum_opt) + vec[@ast.meta_item] meta_items, ast.def_id id, Option.t[int] cnum_opt) -> @ast.view_item { auto cnum; if (!e.crate_cache.contains_key(ident)) { @@ -497,7 +497,7 @@ fn kind_has_type_params(u8 kind_ch) -> bool { // Crate metadata queries fn lookup_def(session.session sess, int cnum, vec[ast.ident] path) - -> option.t[ast.def] { + -> Option.t[ast.def] { auto data = sess.get_external_crate(cnum).data; auto did; @@ -568,7 +568,7 @@ fn get_tag_variants(session.session sess, ty.ctxt tcx, ast.def_id def) -> vec[trans.variant_info] { auto external_crate_id = def._0; auto data = sess.get_external_crate(external_crate_id).data; - auto items = ebml.get_doc(ebml.new_doc(data), metadata.tag_items); + auto items = EBML.get_doc(EBML.new_doc(data), metadata.tag_items); auto item = find_item(def._1, items); let vec[trans.variant_info] infos = vec(); @@ -593,52 +593,52 @@ fn get_tag_variants(session.session sess, ty.ctxt tcx, ast.def_id def) ret infos; } -fn list_file_metadata(str path, io.writer out) { +fn list_file_metadata(str path, IO.writer out) { alt (get_metadata_section(path)) { - case (option.some[vec[u8]](?bytes)) { + case (Option.some[vec[u8]](?bytes)) { list_crate_metadata(bytes, out); } - case (option.none[vec[u8]]) { + case (Option.none[vec[u8]]) { out.write_str("Could not find metadata in " + path + ".\n"); } } } -fn read_path(&ebml.doc d) -> tup(str, uint) { - auto desc = ebml.doc_data(d); - auto pos = ebml.be_uint_from_bytes(desc, 0u, 4u); - auto pathbytes = _vec.slice[u8](desc, 4u, _vec.len[u8](desc)); - auto path = _str.unsafe_from_bytes(pathbytes); +fn read_path(&EBML.doc d) -> tup(str, uint) { + auto desc = EBML.doc_data(d); + auto pos = EBML.be_uint_from_bytes(desc, 0u, 4u); + auto pathbytes = Vec.slice[u8](desc, 4u, Vec.len[u8](desc)); + auto path = Str.unsafe_from_bytes(pathbytes); ret tup(path, pos); } -fn list_crate_metadata(vec[u8] bytes, io.writer out) { - auto md = ebml.new_doc(bytes); - auto paths = ebml.get_doc(md, metadata.tag_paths); - auto items = ebml.get_doc(md, metadata.tag_items); - auto index = ebml.get_doc(paths, metadata.tag_index); - auto bs = ebml.get_doc(index, metadata.tag_index_buckets); - for each (ebml.doc bucket in - ebml.tagged_docs(bs, metadata.tag_index_buckets_bucket)) { +fn list_crate_metadata(vec[u8] bytes, IO.writer out) { + auto md = EBML.new_doc(bytes); + auto paths = EBML.get_doc(md, metadata.tag_paths); + auto items = EBML.get_doc(md, metadata.tag_items); + auto index = EBML.get_doc(paths, metadata.tag_index); + auto bs = EBML.get_doc(index, metadata.tag_index_buckets); + for each (EBML.doc bucket in + EBML.tagged_docs(bs, metadata.tag_index_buckets_bucket)) { auto et = metadata.tag_index_buckets_bucket_elt; - for each (ebml.doc elt in ebml.tagged_docs(bucket, et)) { + for each (EBML.doc elt in EBML.tagged_docs(bucket, et)) { auto data = read_path(elt); - auto def = ebml.doc_at(bytes, data._1); - auto did_doc = ebml.get_doc(def, metadata.tag_def_id); - auto did = parse_def_id(ebml.doc_data(did_doc)); + auto def = EBML.doc_at(bytes, data._1); + auto did_doc = EBML.get_doc(def, metadata.tag_def_id); + auto did = parse_def_id(EBML.doc_data(did_doc)); out.write_str(#fmt("%s (%s)\n", data._0, describe_def(items, did))); } } } -fn describe_def(&ebml.doc items, ast.def_id id) -> str { +fn describe_def(&EBML.doc items, ast.def_id id) -> str { if (id._0 != 0) {ret "external";} alt (maybe_find_item(id._1 as int, items)) { - case (option.some[ebml.doc](?item)) { + case (Option.some[EBML.doc](?item)) { ret item_kind_to_str(item_kind(item)); } - case (option.none[ebml.doc]) { + case (Option.none[EBML.doc]) { ret "??"; // Native modules don't seem to get item entries. } } diff --git a/src/comp/front/eval.rs b/src/comp/front/eval.rs index a1b3392c..e1ad59bc 100644 --- a/src/comp/front/eval.rs +++ b/src/comp/front/eval.rs @@ -1,9 +1,9 @@ -import std._vec; -import std._str; -import std.option; -import std.option.some; -import std.option.none; -import std.map.hashmap; +import std.Vec; +import std.Str; +import std.Option; +import std.Option.some; +import std.Option.none; +import std.Map.hashmap; import driver.session; import ast.ident; @@ -91,7 +91,7 @@ fn val_as_str(val v) -> str { fn lookup(session.session sess, env e, span sp, ident i) -> val { for (tup(ident, val) pair in e) { - if (_str.eq(i, pair._0)) { + if (Str.eq(i, pair._0)) { ret pair._1; } } @@ -114,8 +114,8 @@ fn eval_lit(ctx cx, span sp, @ast.lit lit) -> val { fn eval_expr(ctx cx, env e, @ast.expr x) -> val { alt (x.node) { case (ast.expr_path(?pth, _, _)) { - if (_vec.len[ident](pth.node.idents) == 1u && - _vec.len[@ast.ty](pth.node.types) == 0u) { + if (Vec.len[ident](pth.node.idents) == 1u && + Vec.len[@ast.ty](pth.node.types) == 0u) { ret lookup(cx.sess, e, x.span, pth.node.idents.(0)); } cx.sess.span_err(x.span, "evaluating structured path-name"); @@ -224,7 +224,7 @@ fn val_eq(session.session sess, span sp, val av, val bv) -> bool { ret val_as_int(av) == val_as_int(bv); } if (val_is_str(av) && val_is_str(bv)) { - ret _str.eq(val_as_str(av), + ret Str.eq(val_as_str(av), val_as_str(bv)); } sess.span_err(sp, "bad types in comparison"); @@ -388,7 +388,7 @@ fn eval_crate_directive(ctx cx, case (none[filename]) {} } - auto full_path = prefix + std.fs.path_sep() + file_path; + auto full_path = prefix + std.FS.path_sep() + file_path; if (cx.mode == mode_depend) { cx.deps += vec(full_path); @@ -405,7 +405,7 @@ fn eval_crate_directive(ctx cx, auto im = ast.item_mod(id, m0, next_id); auto i = @spanned(cdir.span.lo, cdir.span.hi, im); ast.index_item(index, i); - _vec.push[@ast.item](items, i); + Vec.push[@ast.item](items, i); } case (ast.cdir_dir_mod(?id, ?dir_opt, ?cdirs)) { @@ -418,16 +418,16 @@ fn eval_crate_directive(ctx cx, case (none[filename]) {} } - auto full_path = prefix + std.fs.path_sep() + path; + auto full_path = prefix + std.FS.path_sep() + path; auto m0 = eval_crate_directives_to_mod(cx, e, cdirs, full_path); auto im = ast.item_mod(id, m0, cx.p.next_def_id()); auto i = @spanned(cdir.span.lo, cdir.span.hi, im); ast.index_item(index, i); - _vec.push[@ast.item](items, i); + Vec.push[@ast.item](items, i); } case (ast.cdir_view_item(?vi)) { - _vec.push[@ast.view_item](view_items, vi); + Vec.push[@ast.view_item](view_items, vi); ast.index_view_item(index, vi); } diff --git a/src/comp/front/extenv.rs b/src/comp/front/extenv.rs index 6dc9c5ec..a3fdde95 100644 --- a/src/comp/front/extenv.rs +++ b/src/comp/front/extenv.rs @@ -6,9 +6,9 @@ import util.common; -import std._str; -import std._vec; -import std.option; +import std.Str; +import std.Vec; +import std.Option; import std.GenericOS; export expand_syntax_ext; @@ -17,9 +17,9 @@ export expand_syntax_ext; fn expand_syntax_ext(parser.parser p, common.span sp, vec[@ast.expr] args, - option.t[str] body) -> @ast.expr { + Option.t[str] body) -> @ast.expr { - if (_vec.len[@ast.expr](args) != 1u) { + if (Vec.len[@ast.expr](args) != 1u) { p.err("malformed #env call"); } diff --git a/src/comp/front/extfmt.rs b/src/comp/front/extfmt.rs index aea3e7df..8aedf587 100644 --- a/src/comp/front/extfmt.rs +++ b/src/comp/front/extfmt.rs @@ -6,11 +6,11 @@ import util.common; -import std._str; -import std._vec; -import std.option; -import std.option.none; -import std.option.some; +import std.Str; +import std.Vec; +import std.Option; +import std.Option.none; +import std.Option.some; import std.ExtFmt.CT.signedness; import std.ExtFmt.CT.signed; @@ -47,9 +47,9 @@ export expand_syntax_ext; // FIXME: Need to thread parser through here to handle errors correctly fn expand_syntax_ext(vec[@ast.expr] args, - option.t[str] body) -> @ast.expr { + Option.t[str] body) -> @ast.expr { - if (_vec.len[@ast.expr](args) == 0u) { + if (Vec.len[@ast.expr](args) == 0u) { log_err "malformed #fmt call"; fail; } @@ -60,8 +60,8 @@ fn expand_syntax_ext(vec[@ast.expr] args, // log fmt; auto pieces = parse_fmt_string(fmt); - auto args_len = _vec.len[@ast.expr](args); - auto fmt_args = _vec.slice[@ast.expr](args, 1u, args_len - 1u); + auto args_len = Vec.len[@ast.expr](args); + auto fmt_args = Vec.slice[@ast.expr](args, 1u, args_len - 1u); ret pieces_to_expr(pieces, args); } @@ -148,7 +148,7 @@ fn pieces_to_expr(vec[piece] pieces, vec[@ast.expr] args) -> @ast.expr { } auto recexpr = ast.expr_rec(astfields, - option.none[@ast.expr], + Option.none[@ast.expr], ast.ann_none); auto sp_recexpr = @rec(node=recexpr, span=sp); ret sp_recexpr; @@ -196,7 +196,7 @@ fn pieces_to_expr(vec[piece] pieces, vec[@ast.expr] args) -> @ast.expr { // FIXME: 0-length vectors can't have their type inferred // through the rec that these flags are a member of, so // this is a hack placeholder flag - if (_vec.len[@ast.expr](flagexprs) == 0u) { + if (Vec.len[@ast.expr](flagexprs) == 0u) { flagexprs += vec(make_rt_path_expr(sp, "flag_none")); } @@ -303,7 +303,7 @@ fn pieces_to_expr(vec[piece] pieces, vec[@ast.expr] args) -> @ast.expr { auto unsupported = "conversion not supported in #fmt string"; alt (cnv.param) { - case (option.none[int]) { + case (Option.none[int]) { } case (_) { log_err unsupported; @@ -398,7 +398,7 @@ fn pieces_to_expr(vec[piece] pieces, vec[@ast.expr] args) -> @ast.expr { fn log_conv(conv c) { alt (c.param) { case (some[int](?p)) { - log "param: " + std._int.to_str(p, 10u); + log "param: " + std.Int.to_str(p, 10u); } case (_) { log "param: none"; @@ -425,10 +425,10 @@ fn pieces_to_expr(vec[piece] pieces, vec[@ast.expr] args) -> @ast.expr { } alt (c.width) { case (count_is(?i)) { - log "width: count is " + std._int.to_str(i, 10u); + log "width: count is " + std.Int.to_str(i, 10u); } case (count_is_param(?i)) { - log "width: count is param " + std._int.to_str(i, 10u); + log "width: count is param " + std.Int.to_str(i, 10u); } case (count_is_next_param) { log "width: count is next param"; @@ -439,10 +439,10 @@ fn pieces_to_expr(vec[piece] pieces, vec[@ast.expr] args) -> @ast.expr { } alt (c.precision) { case (count_is(?i)) { - log "prec: count is " + std._int.to_str(i, 10u); + log "prec: count is " + std.Int.to_str(i, 10u); } case (count_is_param(?i)) { - log "prec: count is param " + std._int.to_str(i, 10u); + log "prec: count is param " + std.Int.to_str(i, 10u); } case (count_is_next_param) { log "prec: count is next param"; @@ -498,7 +498,7 @@ fn pieces_to_expr(vec[piece] pieces, vec[@ast.expr] args) -> @ast.expr { tmp_expr = make_add_expr(sp, tmp_expr, s_expr); } case (piece_conv(?conv)) { - if (n >= _vec.len[@ast.expr](args)) { + if (n >= Vec.len[@ast.expr](args)) { log_err "too many conversions in #fmt string"; fail; } diff --git a/src/comp/front/lexer.rs b/src/comp/front/lexer.rs index 4153533a..a17dd514 100644 --- a/src/comp/front/lexer.rs +++ b/src/comp/front/lexer.rs @@ -1,12 +1,12 @@ -import std.io; -import std._str; -import std._vec; -import std._int; -import std.map; -import std.map.hashmap; -import std.option; -import std.option.some; -import std.option.none; +import std.IO; +import std.Str; +import std.Vec; +import std.Int; +import std.Map; +import std.Map.hashmap; +import std.Option; +import std.Option.some; +import std.Option.none; import util.common; import util.common.new_str_hash; @@ -24,7 +24,7 @@ state type reader = state obj { fn get_filemap() -> codemap.filemap; }; -fn new_reader(io.reader rdr, str filename, codemap.filemap filemap) +fn new_reader(IO.reader rdr, str filename, codemap.filemap filemap) -> reader { state obj reader(str file, uint len, @@ -49,13 +49,13 @@ fn new_reader(io.reader rdr, str filename, codemap.filemap filemap) } fn next() -> char { - if (pos < len) {ret _str.char_at(file, pos);} + if (pos < len) {ret Str.char_at(file, pos);} else {ret -1 as char;} } fn init() { if (pos < len) { - auto next = _str.char_range_at(file, pos); + auto next = Str.char_range_at(file, pos); pos = next._1; ch = next._0; } @@ -67,7 +67,7 @@ fn new_reader(io.reader rdr, str filename, codemap.filemap filemap) if (ch == '\n') { codemap.next_line(fm, chpos); } - auto next = _str.char_range_at(file, pos); + auto next = Str.char_range_at(file, pos); pos = next._1; ch = next._0; } else { @@ -87,8 +87,8 @@ fn new_reader(io.reader rdr, str filename, codemap.filemap filemap) ret fm; } } - auto file = _str.unsafe_from_bytes(rdr.read_whole_stream()); - auto rd = reader(file, _str.byte_len(file), 0u, -1 as char, + auto file = Str.unsafe_from_bytes(rdr.read_whole_stream()); + auto rd = reader(file, Str.byte_len(file), 0u, -1 as char, filemap.start_pos, filemap.start_pos, keyword_table(), reserved_word_table(), @@ -97,7 +97,7 @@ fn new_reader(io.reader rdr, str filename, codemap.filemap filemap) ret rd; } -fn keyword_table() -> std.map.hashmap[str, token.token] { +fn keyword_table() -> std.Map.hashmap[str, token.token] { auto keywords = new_str_hash[token.token](); keywords.insert("mod", token.MOD); @@ -205,7 +205,7 @@ fn keyword_table() -> std.map.hashmap[str, token.token] { ret keywords; } -fn reserved_word_table() -> std.map.hashmap[str, ()] { +fn reserved_word_table() -> std.Map.hashmap[str, ()] { auto reserved = new_str_hash[()](); reserved.insert("f16", ()); // IEEE 754-2008 'binary16' interchange fmt reserved.insert("f80", ()); // IEEE 754-1985 'extended' @@ -341,20 +341,20 @@ fn digits_to_string(str s) -> int { ret accum_int; } -fn scan_exponent(reader rdr) -> option.t[str] { +fn scan_exponent(reader rdr) -> Option.t[str] { auto c = rdr.curr(); auto res = ""; if (c == 'e' || c == 'E') { - res += _str.from_bytes(vec(c as u8)); + res += Str.from_bytes(vec(c as u8)); rdr.bump(); c = rdr.curr(); if (c == '-' || c == '+') { - res += _str.from_bytes(vec(c as u8)); + res += Str.from_bytes(vec(c as u8)); rdr.bump(); } auto exponent = scan_dec_digits(rdr); - if (_str.byte_len(exponent) > 0u) { + if (Str.byte_len(exponent) > 0u) { ret(some(res + exponent)); } else { @@ -374,7 +374,7 @@ fn scan_dec_digits(reader rdr) -> str { while (is_dec_digit (c) || c == '_') { if (c != '_') { - res += _str.from_bytes(vec(c as u8)); + res += Str.from_bytes(vec(c as u8)); } rdr.bump(); c = rdr.curr(); @@ -574,12 +574,12 @@ fn next_token(reader rdr) -> token.token { if (is_alpha(c) || c == '_') { while (is_alnum(c) || c == '_') { - _str.push_char(accum_str, c); + Str.push_char(accum_str, c); rdr.bump(); c = rdr.curr(); } - if (_str.eq(accum_str, "_")) { + if (Str.eq(accum_str, "_")) { ret token.UNDERSCORE; } @@ -738,37 +738,37 @@ fn next_token(reader rdr) -> token.token { alt (rdr.next()) { case ('n') { rdr.bump(); - _str.push_byte(accum_str, '\n' as u8); + Str.push_byte(accum_str, '\n' as u8); } case ('r') { rdr.bump(); - _str.push_byte(accum_str, '\r' as u8); + Str.push_byte(accum_str, '\r' as u8); } case ('t') { rdr.bump(); - _str.push_byte(accum_str, '\t' as u8); + Str.push_byte(accum_str, '\t' as u8); } case ('\\') { rdr.bump(); - _str.push_byte(accum_str, '\\' as u8); + Str.push_byte(accum_str, '\\' as u8); } case ('"') { rdr.bump(); - _str.push_byte(accum_str, '"' as u8); + Str.push_byte(accum_str, '"' as u8); } case ('x') { - _str.push_char(accum_str, + Str.push_char(accum_str, scan_numeric_escape(rdr)); } case ('u') { - _str.push_char(accum_str, + Str.push_char(accum_str, scan_numeric_escape(rdr)); } case ('U') { - _str.push_char(accum_str, + Str.push_char(accum_str, scan_numeric_escape(rdr)); } @@ -780,7 +780,7 @@ fn next_token(reader rdr) -> token.token { } } case (_) { - _str.push_char(accum_str, rdr.curr()); + Str.push_char(accum_str, rdr.curr()); } } rdr.bump(); @@ -870,7 +870,7 @@ fn read_line_comment(reader rdr) -> cmnt { while (rdr.curr() == ' ') {rdr.bump();} auto val = ""; while (rdr.curr() != '\n' && !rdr.is_eof()) { - _str.push_char(val, rdr.curr()); + Str.push_char(val, rdr.curr()); rdr.bump(); } ret rec(val=cmnt_line(val), @@ -887,7 +887,7 @@ fn read_block_comment(reader rdr) -> cmnt { auto level = 1; while (true) { if (rdr.curr() == '\n') { - _vec.push[str](lines, val); + Vec.push[str](lines, val); val = ""; consume_whitespace(rdr); } else { @@ -895,13 +895,13 @@ fn read_block_comment(reader rdr) -> cmnt { level -= 1; if (level == 0) { rdr.bump(); rdr.bump(); - _vec.push[str](lines, val); + Vec.push[str](lines, val); break; } } else if (rdr.curr() == '/' && rdr.next() == '*') { level += 1; } - _str.push_char(val, rdr.curr()); + Str.push_char(val, rdr.curr()); rdr.bump(); } if (rdr.is_eof()) {fail;} @@ -912,16 +912,16 @@ fn read_block_comment(reader rdr) -> cmnt { } fn gather_comments(str path) -> vec[cmnt] { - auto srdr = io.file_reader(path); + auto srdr = IO.file_reader(path); auto rdr = new_reader(srdr, path, codemap.new_filemap(path, 0u)); let vec[cmnt] comments = vec(); while (!rdr.is_eof()) { while (true) { consume_whitespace(rdr); if (rdr.curr() == '/' && rdr.next() == '/') { - _vec.push[cmnt](comments, read_line_comment(rdr)); + Vec.push[cmnt](comments, read_line_comment(rdr)); } else if (rdr.curr() == '/' && rdr.next() == '*') { - _vec.push[cmnt](comments, read_block_comment(rdr)); + Vec.push[cmnt](comments, read_block_comment(rdr)); } else { break; } } next_token(rdr); diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index e355290d..bcde1671 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -1,10 +1,10 @@ -import std.io; -import std._vec; -import std._str; -import std.option; -import std.option.some; -import std.option.none; -import std.map.hashmap; +import std.IO; +import std.Vec; +import std.Str; +import std.Option; +import std.Option.some; +import std.Option.none; +import std.Map.hashmap; import driver.session; import util.common; @@ -118,12 +118,12 @@ fn new_parser(session.session sess, fn get_chpos() -> uint {ret rdr.get_chpos();} } auto ftype = SOURCE_FILE; - if (_str.ends_with(path, ".rc")) { + if (Str.ends_with(path, ".rc")) { ftype = CRATE_FILE; } - auto srdr = io.file_reader(path); + auto srdr = IO.file_reader(path); auto filemap = codemap.new_filemap(path, pos); - _vec.push[codemap.filemap](sess.get_codemap().files, filemap); + Vec.push[codemap.filemap](sess.get_codemap().files, filemap); auto rdr = lexer.new_reader(srdr, path, filemap); // Make sure npos points at first actual token. lexer.consume_any_whitespace(rdr); @@ -320,7 +320,7 @@ fn parse_constrs(parser p) -> common.spanned[vec[@ast.constr]] { case (token.IDENT(_)) { auto constr = parse_ty_constr(p); hi = constr.span.hi; - _vec.push[@ast.constr](constrs, constr); + Vec.push[@ast.constr](constrs, constr); if (p.peek() == token.COMMA) { p.bump(); more = false; @@ -496,7 +496,7 @@ fn parse_arg(parser p) -> ast.arg { } fn parse_seq_to_end[T](token.token ket, - option.t[token.token] sep, + Option.t[token.token] sep, (fn(parser) -> T) f, uint hi, parser p) -> vec[T] { @@ -525,7 +525,7 @@ fn parse_seq_to_end[T](token.token ket, fn parse_seq[T](token.token bra, token.token ket, - option.t[token.token] sep, + Option.t[token.token] sep, (fn(parser) -> T) f, parser p) -> util.common.spanned[vec[T]] { auto lo = p.get_lo_pos(); @@ -764,7 +764,7 @@ fn parse_bottom_expr(parser p) -> @ast.expr { case (token.BIND) { p.bump(); auto e = parse_expr_res(p, RESTRICT_NO_CALL_EXPRS); - fn parse_expr_opt(parser p) -> option.t[@ast.expr] { + fn parse_expr_opt(parser p) -> Option.t[@ast.expr] { alt (p.peek()) { case (token.UNDERSCORE) { p.bump(); @@ -777,7 +777,7 @@ fn parse_bottom_expr(parser p) -> @ast.expr { } auto pf = parse_expr_opt; - auto es = parse_seq[option.t[@ast.expr]](token.LPAREN, + auto es = parse_seq[Option.t[@ast.expr]](token.LPAREN, token.RPAREN, some(token.COMMA), pf, p); @@ -939,18 +939,18 @@ fn parse_bottom_expr(parser p) -> @ast.expr { fn expand_syntax_ext(parser p, ast.span sp, &ast.path path, vec[@ast.expr] args, - option.t[str] body) -> ast.expr_ { + Option.t[str] body) -> ast.expr_ { - assert (_vec.len[ast.ident](path.node.idents) > 0u); + assert (Vec.len[ast.ident](path.node.idents) > 0u); auto extname = path.node.idents.(0); - if (_str.eq(extname, "fmt")) { + if (Str.eq(extname, "fmt")) { auto expanded = extfmt.expand_syntax_ext(args, body); auto newexpr = ast.expr_ext(path, args, body, expanded, ast.ann_none); ret newexpr; - } else if (_str.eq(extname, "env")) { + } else if (Str.eq(extname, "env")) { auto expanded = extenv.expand_syntax_ext(p, sp, args, body); auto newexpr = ast.expr_ext(path, args, body, expanded, @@ -968,7 +968,7 @@ fn extend_expr_by_ident(parser p, uint lo, uint hi, auto e_ = e.node; alt (e.node) { case (ast.expr_path(?pth, ?def, ?ann)) { - if (_vec.len[@ast.ty](pth.node.types) == 0u) { + if (Vec.len[@ast.ty](pth.node.types) == 0u) { auto idents_ = pth.node.idents; idents_ += vec(i); auto tys = parse_ty_args(p, hi); @@ -1238,7 +1238,7 @@ fn parse_if_expr(parser p) -> @ast.expr { auto cond = parse_expr(p); expect(p, token.RPAREN); auto thn = parse_block(p); - let option.t[@ast.expr] els = none[@ast.expr]; + let Option.t[@ast.expr] els = none[@ast.expr]; auto hi = thn.span.hi; alt (p.peek()) { case (token.ELSE) { @@ -1398,7 +1398,7 @@ fn parse_spawn_expr(parser p) -> @ast.expr { pf, p); auto hi = es.span.hi; auto spawn_expr = ast.expr_spawn(ast.dom_implicit, - option.none[str], + Option.none[str], fn_expr, es.node, ast.ann_none); @@ -1449,7 +1449,7 @@ fn parse_expr_inner(parser p) -> @ast.expr { } } -fn parse_initializer(parser p) -> option.t[ast.initializer] { +fn parse_initializer(parser p) -> Option.t[ast.initializer] { alt (p.peek()) { case (token.EQ) { p.bump(); @@ -1521,7 +1521,7 @@ fn parse_pat(parser p) -> @ast.pat { ret @spanned(lo, hi, pat); } -fn parse_local_full(&option.t[@ast.ty] tyopt, +fn parse_local_full(&Option.t[@ast.ty] tyopt, parser p) -> @ast.local { auto ident = parse_ident(p); auto init = parse_initializer(p); @@ -1607,7 +1607,7 @@ fn parse_source_stmt(parser p) -> @ast.stmt { fail; } -fn index_block(vec[@ast.stmt] stmts, option.t[@ast.expr] expr) -> ast.block_ { +fn index_block(vec[@ast.stmt] stmts, Option.t[@ast.expr] expr) -> ast.block_ { auto index = new_str_hash[ast.block_index_entry](); for (@ast.stmt s in stmts) { ast.index_stmt(index, s); @@ -1634,7 +1634,7 @@ fn index_arm(@ast.pat pat) -> hashmap[ast.ident,ast.def_id] { ret index; } -fn stmt_to_expr(@ast.stmt stmt) -> option.t[@ast.expr] { +fn stmt_to_expr(@ast.stmt stmt) -> Option.t[@ast.expr] { alt (stmt.node) { case (ast.stmt_expr(?e,_)) { ret some[@ast.expr](e); } case (_) { /* fall through */ } @@ -1697,7 +1697,7 @@ fn parse_block(parser p) -> ast.block { auto lo = p.get_lo_pos(); let vec[@ast.stmt] stmts = vec(); - let option.t[@ast.expr] expr = none[@ast.expr]; + let Option.t[@ast.expr] expr = none[@ast.expr]; expect(p, token.LBRACE); while (p.peek() != token.RBRACE) { @@ -1871,7 +1871,7 @@ fn parse_item_obj(parser p, ast.layer lyr) -> @ast.item { pf, p); let vec[@ast.method] meths = vec(); - let option.t[@ast.method] dtor = none[@ast.method]; + let Option.t[@ast.method] dtor = none[@ast.method]; expect(p, token.LBRACE); while (p.peek() != token.RBRACE) { @@ -1880,7 +1880,7 @@ fn parse_item_obj(parser p, ast.layer lyr) -> @ast.item { dtor = some[@ast.method](parse_dtor(p)); } case (_) { - _vec.push[@ast.method](meths, + Vec.push[@ast.method](meths, parse_method(p)); } } @@ -2020,12 +2020,12 @@ fn parse_item_native_mod(parser p) -> @ast.item { auto abi = ast.native_abi_cdecl; if (p.peek() != token.MOD) { auto t = parse_str_lit_or_env_ident(p); - if (_str.eq(t, "cdecl")) { - } else if (_str.eq(t, "rust")) { + if (Str.eq(t, "cdecl")) { + } else if (Str.eq(t, "rust")) { abi = ast.native_abi_rust; - } else if (_str.eq(t, "llvm")) { + } else if (Str.eq(t, "llvm")) { abi = ast.native_abi_llvm; - } else if (_str.eq(t, "rust-intrinsic")) { + } else if (Str.eq(t, "rust-intrinsic")) { abi = ast.native_abi_rust_intrinsic; } else { p.err("unsupported abi: " + t); @@ -2264,7 +2264,7 @@ fn parse_use(parser p) -> @ast.view_item { } fn parse_rest_import_name(parser p, ast.ident first, - option.t[ast.ident] def_ident) + Option.t[ast.ident] def_ident) -> @ast.view_item { auto lo = p.get_lo_pos(); let vec[ast.ident] identifiers = vec(first); @@ -2281,7 +2281,7 @@ fn parse_rest_import_name(parser p, ast.ident first, defined_id = i; } case (_) { - auto len = _vec.len[ast.ident](identifiers); + auto len = Vec.len[ast.ident](identifiers); defined_id = identifiers.(len - 1u); } } @@ -2506,7 +2506,7 @@ fn parse_crate_directives(parser p, token.token term) while (p.peek() != term) { auto cdir = @parse_crate_directive(p); - _vec.push[@ast.crate_directive](cdirs, cdir); + Vec.push[@ast.crate_directive](cdirs, cdir); } ret cdirs; @@ -2514,7 +2514,7 @@ fn parse_crate_directives(parser p, token.token term) fn parse_crate_from_crate_file(parser p) -> @ast.crate { auto lo = p.get_lo_pos(); - auto prefix = std.fs.dirname(p.get_filemap().name); + auto prefix = std.FS.dirname(p.get_filemap().name); auto cdirs = parse_crate_directives(p, token.EOF); let vec[str] deps = vec(); auto cx = @rec(p=p, diff --git a/src/comp/front/token.rs b/src/comp/front/token.rs index b0fa0588..f0b6c4be 100644 --- a/src/comp/front/token.rs +++ b/src/comp/front/token.rs @@ -1,9 +1,9 @@ import util.common.ty_mach; import util.common.ty_mach_to_str; import util.common.new_str_hash; -import std._int; -import std._uint; -import std._str; +import std.Int; +import std.UInt; +import std.Str; tag binop { PLUS; @@ -295,10 +295,10 @@ fn to_str(token t) -> str { case (JOIN) { ret "join"; } /* Literals */ - case (LIT_INT(?i)) { ret _int.to_str(i, 10u); } - case (LIT_UINT(?u)) { ret _uint.to_str(u, 10u); } + case (LIT_INT(?i)) { ret Int.to_str(i, 10u); } + case (LIT_UINT(?u)) { ret UInt.to_str(u, 10u); } case (LIT_MACH_INT(?tm, ?i)) { - ret _int.to_str(i, 10u) + ret Int.to_str(i, 10u) + "_" + ty_mach_to_str(tm); } case (LIT_FLOAT(?s)) { ret s; } @@ -309,8 +309,8 @@ fn to_str(token t) -> str { case (LIT_CHAR(?c)) { // FIXME: escape. auto tmp = "'"; - _str.push_char(tmp, c); - _str.push_byte(tmp, '\'' as u8); + Str.push_char(tmp, c); + Str.push_byte(tmp, '\'' as u8); ret tmp; } @@ -320,7 +320,7 @@ fn to_str(token t) -> str { /* Name components */ case (IDENT(?s)) { auto si = "ident:"; si += s; ret si; } - case (IDX(?i)) { ret "_" + _int.to_str(i, 10u); } + case (IDX(?i)) { ret "_" + Int.to_str(i, 10u); } case (UNDERSCORE) { ret "_"; } /* Reserved type names */ diff --git a/src/comp/lib/llvm.rs b/src/comp/lib/llvm.rs index 1d2529cc..2c0ac2fc 100644 --- a/src/comp/lib/llvm.rs +++ b/src/comp/lib/llvm.rs @@ -1,7 +1,7 @@ -import std._vec; -import std._str; -import std._str.rustrt.sbuf; -import std._vec.rustrt.vbuf; +import std.Vec; +import std.Str; +import std.Str.rustrt.sbuf; +import std.Vec.rustrt.vbuf; import llvm.ModuleRef; import llvm.ContextRef; @@ -831,7 +831,7 @@ native mod llvm = llvm_lib { /** Destroys a section iterator. */ fn LLVMDisposeSectionIterator(SectionIteratorRef SI); /** Returns true if the section iterator is at the end of the section - list. */ + List. */ fn LLVMIsSectionIteratorAtEnd(ObjectFileRef ObjectFile, SectionIteratorRef SI) -> Bool; /** Moves the section iterator to point to the next section. */ @@ -894,8 +894,8 @@ obj builder(BuilderRef B, @mutable bool terminated) { assert (!*terminated); *terminated = true; ret llvm.LLVMBuildAggregateRet(B, - _vec.buf[ValueRef](RetVals), - _vec.len[ValueRef](RetVals)); + Vec.buf[ValueRef](RetVals), + Vec.len[ValueRef](RetVals)); } fn Br(BasicBlockRef Dest) -> ValueRef { @@ -930,10 +930,10 @@ obj builder(BuilderRef B, @mutable bool terminated) { assert (!*terminated); *terminated = true; ret llvm.LLVMBuildInvoke(B, Fn, - _vec.buf[ValueRef](Args), - _vec.len[ValueRef](Args), + Vec.buf[ValueRef](Args), + Vec.len[ValueRef](Args), Then, Catch, - _str.buf("")); + Str.buf("")); } fn Unwind() -> ValueRef { @@ -951,176 +951,176 @@ obj builder(BuilderRef B, @mutable bool terminated) { /* Arithmetic */ fn Add(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildAdd(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildAdd(B, LHS, RHS, Str.buf("")); } fn NSWAdd(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildNSWAdd(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildNSWAdd(B, LHS, RHS, Str.buf("")); } fn NUWAdd(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildNUWAdd(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildNUWAdd(B, LHS, RHS, Str.buf("")); } fn FAdd(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildFAdd(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildFAdd(B, LHS, RHS, Str.buf("")); } fn Sub(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildSub(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildSub(B, LHS, RHS, Str.buf("")); } fn NSWSub(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildNSWSub(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildNSWSub(B, LHS, RHS, Str.buf("")); } fn NUWSub(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildNUWSub(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildNUWSub(B, LHS, RHS, Str.buf("")); } fn FSub(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildFSub(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildFSub(B, LHS, RHS, Str.buf("")); } fn Mul(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildMul(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildMul(B, LHS, RHS, Str.buf("")); } fn NSWMul(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildNSWMul(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildNSWMul(B, LHS, RHS, Str.buf("")); } fn NUWMul(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildNUWMul(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildNUWMul(B, LHS, RHS, Str.buf("")); } fn FMul(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildFMul(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildFMul(B, LHS, RHS, Str.buf("")); } fn UDiv(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildUDiv(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildUDiv(B, LHS, RHS, Str.buf("")); } fn SDiv(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildSDiv(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildSDiv(B, LHS, RHS, Str.buf("")); } fn ExactSDiv(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildExactSDiv(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildExactSDiv(B, LHS, RHS, Str.buf("")); } fn FDiv(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildFDiv(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildFDiv(B, LHS, RHS, Str.buf("")); } fn URem(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildURem(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildURem(B, LHS, RHS, Str.buf("")); } fn SRem(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildSRem(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildSRem(B, LHS, RHS, Str.buf("")); } fn FRem(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildFRem(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildFRem(B, LHS, RHS, Str.buf("")); } fn Shl(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildShl(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildShl(B, LHS, RHS, Str.buf("")); } fn LShr(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildLShr(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildLShr(B, LHS, RHS, Str.buf("")); } fn AShr(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildAShr(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildAShr(B, LHS, RHS, Str.buf("")); } fn And(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildAnd(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildAnd(B, LHS, RHS, Str.buf("")); } fn Or(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildOr(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildOr(B, LHS, RHS, Str.buf("")); } fn Xor(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildXor(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildXor(B, LHS, RHS, Str.buf("")); } fn BinOp(Opcode Op, ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildBinOp(B, Op, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildBinOp(B, Op, LHS, RHS, Str.buf("")); } fn Neg(ValueRef V) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildNeg(B, V, _str.buf("")); + ret llvm.LLVMBuildNeg(B, V, Str.buf("")); } fn NSWNeg(ValueRef V) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildNSWNeg(B, V, _str.buf("")); + ret llvm.LLVMBuildNSWNeg(B, V, Str.buf("")); } fn NUWNeg(ValueRef V) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildNUWNeg(B, V, _str.buf("")); + ret llvm.LLVMBuildNUWNeg(B, V, Str.buf("")); } fn FNeg(ValueRef V) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildFNeg(B, V, _str.buf("")); + ret llvm.LLVMBuildFNeg(B, V, Str.buf("")); } fn Not(ValueRef V) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildNot(B, V, _str.buf("")); + ret llvm.LLVMBuildNot(B, V, Str.buf("")); } /* Memory */ fn Malloc(TypeRef Ty) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildMalloc(B, Ty, _str.buf("")); + ret llvm.LLVMBuildMalloc(B, Ty, Str.buf("")); } fn ArrayMalloc(TypeRef Ty, ValueRef Val) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildArrayMalloc(B, Ty, Val, _str.buf("")); + ret llvm.LLVMBuildArrayMalloc(B, Ty, Val, Str.buf("")); } fn Alloca(TypeRef Ty) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildAlloca(B, Ty, _str.buf("")); + ret llvm.LLVMBuildAlloca(B, Ty, Str.buf("")); } fn ArrayAlloca(TypeRef Ty, ValueRef Val) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildArrayAlloca(B, Ty, Val, _str.buf("")); + ret llvm.LLVMBuildArrayAlloca(B, Ty, Val, Str.buf("")); } fn Free(ValueRef PointerVal) -> ValueRef { @@ -1130,7 +1130,7 @@ obj builder(BuilderRef B, @mutable bool terminated) { fn Load(ValueRef PointerVal) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildLoad(B, PointerVal, _str.buf("")); + ret llvm.LLVMBuildLoad(B, PointerVal, Str.buf("")); } fn Store(ValueRef Val, ValueRef Ptr) -> ValueRef { @@ -1141,140 +1141,140 @@ obj builder(BuilderRef B, @mutable bool terminated) { fn GEP(ValueRef Pointer, vec[ValueRef] Indices) -> ValueRef { assert (!*terminated); ret llvm.LLVMBuildGEP(B, Pointer, - _vec.buf[ValueRef](Indices), - _vec.len[ValueRef](Indices), - _str.buf("")); + Vec.buf[ValueRef](Indices), + Vec.len[ValueRef](Indices), + Str.buf("")); } fn InBoundsGEP(ValueRef Pointer, vec[ValueRef] Indices) -> ValueRef { assert (!*terminated); ret llvm.LLVMBuildInBoundsGEP(B, Pointer, - _vec.buf[ValueRef](Indices), - _vec.len[ValueRef](Indices), - _str.buf("")); + Vec.buf[ValueRef](Indices), + Vec.len[ValueRef](Indices), + Str.buf("")); } fn StructGEP(ValueRef Pointer, uint Idx) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildStructGEP(B, Pointer, Idx, _str.buf("")); + ret llvm.LLVMBuildStructGEP(B, Pointer, Idx, Str.buf("")); } - fn GlobalString(sbuf Str) -> ValueRef { + fn GlobalString(sbuf _Str) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildGlobalString(B, Str, _str.buf("")); + ret llvm.LLVMBuildGlobalString(B, _Str, Str.buf("")); } - fn GlobalStringPtr(sbuf Str) -> ValueRef { + fn GlobalStringPtr(sbuf _Str) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildGlobalStringPtr(B, Str, _str.buf("")); + ret llvm.LLVMBuildGlobalStringPtr(B, _Str, Str.buf("")); } /* Casts */ fn Trunc(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildTrunc(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildTrunc(B, Val, DestTy, Str.buf("")); } fn ZExt(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildZExt(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildZExt(B, Val, DestTy, Str.buf("")); } fn SExt(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildSExt(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildSExt(B, Val, DestTy, Str.buf("")); } fn FPToUI(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildFPToUI(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildFPToUI(B, Val, DestTy, Str.buf("")); } fn FPToSI(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildFPToSI(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildFPToSI(B, Val, DestTy, Str.buf("")); } fn UIToFP(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildUIToFP(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildUIToFP(B, Val, DestTy, Str.buf("")); } fn SIToFP(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildSIToFP(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildSIToFP(B, Val, DestTy, Str.buf("")); } fn FPTrunc(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildFPTrunc(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildFPTrunc(B, Val, DestTy, Str.buf("")); } fn FPExt(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildFPExt(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildFPExt(B, Val, DestTy, Str.buf("")); } fn PtrToInt(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildPtrToInt(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildPtrToInt(B, Val, DestTy, Str.buf("")); } fn IntToPtr(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildIntToPtr(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildIntToPtr(B, Val, DestTy, Str.buf("")); } fn BitCast(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildBitCast(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildBitCast(B, Val, DestTy, Str.buf("")); } fn ZExtOrBitCast(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildZExtOrBitCast(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildZExtOrBitCast(B, Val, DestTy, Str.buf("")); } fn SExtOrBitCast(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildSExtOrBitCast(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildSExtOrBitCast(B, Val, DestTy, Str.buf("")); } fn TruncOrBitCast(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildTruncOrBitCast(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildTruncOrBitCast(B, Val, DestTy, Str.buf("")); } fn Cast(Opcode Op, ValueRef Val, TypeRef DestTy, sbuf Name) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildCast(B, Op, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildCast(B, Op, Val, DestTy, Str.buf("")); } fn PointerCast(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildPointerCast(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildPointerCast(B, Val, DestTy, Str.buf("")); } fn IntCast(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildIntCast(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildIntCast(B, Val, DestTy, Str.buf("")); } fn FPCast(ValueRef Val, TypeRef DestTy) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildFPCast(B, Val, DestTy, _str.buf("")); + ret llvm.LLVMBuildFPCast(B, Val, DestTy, Str.buf("")); } /* Comparisons */ fn ICmp(uint Op, ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildICmp(B, Op, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildICmp(B, Op, LHS, RHS, Str.buf("")); } fn FCmp(uint Op, ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildFCmp(B, Op, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildFCmp(B, Op, LHS, RHS, Str.buf("")); } @@ -1282,94 +1282,94 @@ obj builder(BuilderRef B, @mutable bool terminated) { fn Phi(TypeRef Ty, vec[ValueRef] vals, vec[BasicBlockRef] bbs) -> ValueRef { assert (!*terminated); - auto phi = llvm.LLVMBuildPhi(B, Ty, _str.buf("")); - assert (_vec.len[ValueRef](vals) == _vec.len[BasicBlockRef](bbs)); + auto phi = llvm.LLVMBuildPhi(B, Ty, Str.buf("")); + assert (Vec.len[ValueRef](vals) == Vec.len[BasicBlockRef](bbs)); llvm.LLVMAddIncoming(phi, - _vec.buf[ValueRef](vals), - _vec.buf[BasicBlockRef](bbs), - _vec.len[ValueRef](vals)); + Vec.buf[ValueRef](vals), + Vec.buf[BasicBlockRef](bbs), + Vec.len[ValueRef](vals)); ret phi; } fn AddIncomingToPhi(ValueRef phi, vec[ValueRef] vals, vec[BasicBlockRef] bbs) { - assert (_vec.len[ValueRef](vals) == _vec.len[BasicBlockRef](bbs)); + assert (Vec.len[ValueRef](vals) == Vec.len[BasicBlockRef](bbs)); llvm.LLVMAddIncoming(phi, - _vec.buf[ValueRef](vals), - _vec.buf[BasicBlockRef](bbs), - _vec.len[ValueRef](vals)); + Vec.buf[ValueRef](vals), + Vec.buf[BasicBlockRef](bbs), + Vec.len[ValueRef](vals)); } fn Call(ValueRef Fn, vec[ValueRef] Args) -> ValueRef { assert (!*terminated); ret llvm.LLVMBuildCall(B, Fn, - _vec.buf[ValueRef](Args), - _vec.len[ValueRef](Args), - _str.buf("")); + Vec.buf[ValueRef](Args), + Vec.len[ValueRef](Args), + Str.buf("")); } fn FastCall(ValueRef Fn, vec[ValueRef] Args) -> ValueRef { assert (!*terminated); auto v = llvm.LLVMBuildCall(B, Fn, - _vec.buf[ValueRef](Args), - _vec.len[ValueRef](Args), - _str.buf("")); + Vec.buf[ValueRef](Args), + Vec.len[ValueRef](Args), + Str.buf("")); llvm.LLVMSetInstructionCallConv(v, LLVMFastCallConv); ret v; } fn Select(ValueRef If, ValueRef Then, ValueRef Else) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildSelect(B, If, Then, Else, _str.buf("")); + ret llvm.LLVMBuildSelect(B, If, Then, Else, Str.buf("")); } fn VAArg(ValueRef List, TypeRef Ty) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildVAArg(B, List, Ty, _str.buf("")); + ret llvm.LLVMBuildVAArg(B, List, Ty, Str.buf("")); } fn ExtractElement(ValueRef VecVal, ValueRef Index) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildExtractElement(B, VecVal, Index, _str.buf("")); + ret llvm.LLVMBuildExtractElement(B, VecVal, Index, Str.buf("")); } fn InsertElement(ValueRef VecVal, ValueRef EltVal, ValueRef Index) -> ValueRef { assert (!*terminated); ret llvm.LLVMBuildInsertElement(B, VecVal, EltVal, Index, - _str.buf("")); + Str.buf("")); } fn ShuffleVector(ValueRef V1, ValueRef V2, ValueRef Mask) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildShuffleVector(B, V1, V2, Mask, _str.buf("")); + ret llvm.LLVMBuildShuffleVector(B, V1, V2, Mask, Str.buf("")); } fn ExtractValue(ValueRef AggVal, uint Index) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildExtractValue(B, AggVal, Index, _str.buf("")); + ret llvm.LLVMBuildExtractValue(B, AggVal, Index, Str.buf("")); } fn InsertValue(ValueRef AggVal, ValueRef EltVal, uint Index) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildInsertValue(B, AggVal, EltVal, Index, _str.buf("")); + ret llvm.LLVMBuildInsertValue(B, AggVal, EltVal, Index, Str.buf("")); } fn IsNull(ValueRef Val) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildIsNull(B, Val, _str.buf("")); + ret llvm.LLVMBuildIsNull(B, Val, Str.buf("")); } fn IsNotNull(ValueRef Val) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildIsNotNull(B, Val, _str.buf("")); + ret llvm.LLVMBuildIsNotNull(B, Val, Str.buf("")); } fn PtrDiff(ValueRef LHS, ValueRef RHS) -> ValueRef { assert (!*terminated); - ret llvm.LLVMBuildPtrDiff(B, LHS, RHS, _str.buf("")); + ret llvm.LLVMBuildPtrDiff(B, LHS, RHS, Str.buf("")); } fn Trap() -> ValueRef { @@ -1377,13 +1377,13 @@ obj builder(BuilderRef B, @mutable bool terminated) { let BasicBlockRef BB = llvm.LLVMGetInsertBlock(B); let ValueRef FN = llvm.LLVMGetBasicBlockParent(BB); let ModuleRef M = llvm.LLVMGetGlobalParent(FN); - let ValueRef T = llvm.LLVMGetNamedFunction(M, _str.buf("llvm.trap")); + let ValueRef T = llvm.LLVMGetNamedFunction(M, Str.buf("llvm.trap")); assert (T as int != 0); let vec[ValueRef] Args = vec(); ret llvm.LLVMBuildCall(B, T, - _vec.buf[ValueRef](Args), - _vec.len[ValueRef](Args), - _str.buf("")); + Vec.buf[ValueRef](Args), + Vec.len[ValueRef](Args), + Str.buf("")); } drop { @@ -1405,8 +1405,8 @@ fn mk_type_handle() -> type_handle { } -state obj type_names(std.map.hashmap[TypeRef, str] type_names, - std.map.hashmap[str, TypeRef] named_types) { +state obj type_names(std.Map.hashmap[TypeRef, str] type_names, + std.Map.hashmap[str, TypeRef] named_types) { fn associate(str s, TypeRef t) { assert (!named_types.contains_key(s)); @@ -1443,9 +1443,9 @@ fn mk_type_names() -> type_names { ret (a as uint) == (b as uint); } - let std.map.hashfn[TypeRef] hasher = hash; - let std.map.eqfn[TypeRef] eqer = eq; - auto tn = std.map.mk_hashmap[TypeRef,str](hasher, eqer); + let std.Map.hashfn[TypeRef] hasher = hash; + let std.Map.eqfn[TypeRef] eqer = eq; + auto tn = std.Map.mk_hashmap[TypeRef,str](hasher, eqer); ret type_names(tn, nt); } @@ -1503,8 +1503,8 @@ fn type_to_str_inner(type_names names, let TypeRef out_ty = llvm.LLVMGetReturnType(ty); let uint n_args = llvm.LLVMCountParamTypes(ty); let vec[TypeRef] args = - _vec.init_elt[TypeRef](0 as TypeRef, n_args); - llvm.LLVMGetParamTypes(ty, _vec.buf[TypeRef](args)); + Vec.init_elt[TypeRef](0 as TypeRef, n_args); + llvm.LLVMGetParamTypes(ty, Vec.buf[TypeRef](args)); s += tys_str(names, outer, args); s += ") -> "; s += type_to_str_inner(names, outer, out_ty); @@ -1515,8 +1515,8 @@ fn type_to_str_inner(type_names names, let str s = "{"; let uint n_elts = llvm.LLVMCountStructElementTypes(ty); let vec[TypeRef] elts = - _vec.init_elt[TypeRef](0 as TypeRef, n_elts); - llvm.LLVMGetStructElementTypes(ty, _vec.buf[TypeRef](elts)); + Vec.init_elt[TypeRef](0 as TypeRef, n_elts); + llvm.LLVMGetStructElementTypes(ty, Vec.buf[TypeRef](elts)); s += tys_str(names, outer, elts); s += "}"; ret s; @@ -1529,7 +1529,7 @@ fn type_to_str_inner(type_names names, for (TypeRef tout in outer0) { i += 1u; if (tout as int == ty as int) { - let uint n = _vec.len[TypeRef](outer0) - i; + let uint n = Vec.len[TypeRef](outer0) - i; ret "*\\" + util.common.istr(n as int); } } @@ -1556,7 +1556,7 @@ obj target_data_dtor(TargetDataRef TD) { type target_data = rec(TargetDataRef lltd, target_data_dtor dtor); fn mk_target_data(str string_rep) -> target_data { - auto lltd = llvm.LLVMCreateTargetData(_str.buf(string_rep)); + auto lltd = llvm.LLVMCreateTargetData(Str.buf(string_rep)); ret rec(lltd=lltd, dtor=target_data_dtor(lltd)); } diff --git a/src/comp/middle/capture.rs b/src/comp/middle/capture.rs index 02431580..003c3897 100644 --- a/src/comp/middle/capture.rs +++ b/src/comp/middle/capture.rs @@ -1,29 +1,29 @@ import driver.session; import front.ast; -import std.map.hashmap; -import std.option; -import std.option.some; -import std.option.none; -import std._int; -import std._vec; +import std.Map.hashmap; +import std.Option; +import std.Option.some; +import std.Option.none; +import std.Int; +import std.Vec; import util.common; -type fn_id_of_local = std.map.hashmap[ast.def_id, ast.def_id]; +type fn_id_of_local = std.Map.hashmap[ast.def_id, ast.def_id]; type env = rec(mutable vec[ast.def_id] current_context, // fn or obj fn_id_of_local idmap, session.session sess); fn current_context(&env e) -> ast.def_id { - ret e.current_context.(_vec.len(e.current_context) - 1u); + ret e.current_context.(Vec.len(e.current_context) - 1u); } fn enter_item(@env e, @ast.item i) { alt (i.node) { case (ast.item_fn(?name, _, _, ?id, _)) { - _vec.push(e.current_context, id); + Vec.push(e.current_context, id); } case (ast.item_obj(_, _, _, ?ids, _)) { - _vec.push(e.current_context, ids.ty); + Vec.push(e.current_context, ids.ty); } case (_) {} } @@ -32,10 +32,10 @@ fn enter_item(@env e, @ast.item i) { fn leave_item(@env e, @ast.item i) { alt (i.node) { case (ast.item_fn(?name, _, _, ?id, _)) { - _vec.pop(e.current_context); + Vec.pop(e.current_context); } case (ast.item_obj(_, _, _, ?ids, _)) { - _vec.pop(e.current_context); + Vec.pop(e.current_context); } case (_) {} } @@ -61,13 +61,13 @@ fn walk_expr(@env e, @ast.expr x) { } case (ast.expr_path(_, ?def, _)) { auto local_id; - alt (option.get(def)) { + alt (Option.get(def)) { case (ast.def_local(?id)) { local_id = id; } case (_) { ret; } } - auto df = ast.def_id_of_def(option.get(def)); - auto def_context = option.get(e.idmap.find(df)); + auto df = ast.def_id_of_def(Option.get(def)); + auto def_context = Option.get(e.idmap.find(df)); if (current_context(*e) != def_context) { e.sess.span_err(x.span, diff --git a/src/comp/middle/fold.rs b/src/comp/middle/fold.rs index b37f7be8..ace45c2f 100644 --- a/src/comp/middle/fold.rs +++ b/src/comp/middle/fold.rs @@ -1,7 +1,7 @@ -import std.map.hashmap; -import std.option; -import std.option.some; -import std.option.none; +import std.Map.hashmap; +import std.Option; +import std.Option.some; +import std.Option.none; import util.common.new_str_hash; import util.common.spanned; @@ -32,8 +32,8 @@ import front.ast.ann; import front.ast.mt; import front.ast.purity; -import std._uint; -import std._vec; +import std.UInt; +import std.Vec; type ast_fold[ENV] = @rec @@ -67,7 +67,7 @@ type ast_fold[ENV] = @ty output) -> @ty) fold_ty_fn, (fn(&ENV e, &span sp, ast.path p, - &option.t[def] d) -> @ty) fold_ty_path, + &Option.t[def] d) -> @ty) fold_ty_path, (fn(&ENV e, &span sp, @ty t) -> @ty) fold_ty_chan, (fn(&ENV e, &span sp, @ty t) -> @ty) fold_ty_port, @@ -82,7 +82,7 @@ type ast_fold[ENV] = (fn(&ENV e, &span sp, vec[ast.field] fields, - option.t[@expr] base, ann a) -> @expr) fold_expr_rec, + Option.t[@expr] base, ann a) -> @expr) fold_expr_rec, (fn(&ENV e, &span sp, @expr f, vec[@expr] args, @@ -92,11 +92,11 @@ type ast_fold[ENV] = ident id, ann a) -> @expr) fold_expr_self_method, (fn(&ENV e, &span sp, - @expr f, vec[option.t[@expr]] args, + @expr f, vec[Option.t[@expr]] args, ann a) -> @expr) fold_expr_bind, (fn(&ENV e, &span sp, - ast.spawn_dom dom, option.t[str] name, + ast.spawn_dom dom, Option.t[str] name, @expr f, vec[@expr] args, ann a) -> @expr) fold_expr_spawn, @@ -118,7 +118,7 @@ type ast_fold[ENV] = (fn(&ENV e, &span sp, @expr cond, &block thn, - &option.t[@expr] els, + &Option.t[@expr] els, ann a) -> @expr) fold_expr_if, (fn(&ENV e, &span sp, @@ -169,12 +169,12 @@ type ast_fold[ENV] = (fn(&ENV e, &span sp, &path p, - &option.t[def] d, + &Option.t[def] d, ann a) -> @expr) fold_expr_path, (fn(&ENV e, &span sp, &path p, vec[@expr] args, - option.t[str] body, + Option.t[str] body, @expr expanded, ann a) -> @expr) fold_expr_ext, @@ -185,10 +185,10 @@ type ast_fold[ENV] = (fn(&ENV e, &span sp, ann a) -> @expr) fold_expr_cont, (fn(&ENV e, &span sp, - &option.t[@expr] rv, ann a) -> @expr) fold_expr_ret, + &Option.t[@expr] rv, ann a) -> @expr) fold_expr_ret, (fn(&ENV e, &span sp, - &option.t[@expr] rv, ann a) -> @expr) fold_expr_put, + &Option.t[@expr] rv, ann a) -> @expr) fold_expr_put, (fn(&ENV e, &span sp, @expr e, ann a) -> @expr) fold_expr_be, @@ -229,7 +229,7 @@ type ast_fold[ENV] = (fn(&ENV e, &span sp, path p, vec[@pat] args, - option.t[ast.variant_def] d, + Option.t[ast.variant_def] d, ann a) -> @pat) fold_pat_tag, @@ -253,7 +253,7 @@ type ast_fold[ENV] = def_id id, ann a) -> @item) fold_item_fn, (fn(&ENV e, &span sp, ident ident, - option.t[str] link_name, + Option.t[str] link_name, &ast.fn_decl decl, vec[ast.ty_param] ty_params, def_id id, ann a) -> @native_item) fold_native_item_fn, @@ -284,10 +284,10 @@ type ast_fold[ENV] = // View Item folds. (fn(&ENV e, &span sp, ident ident, vec[@meta_item] meta_items, - def_id id, option.t[int]) -> @view_item) fold_view_item_use, + def_id id, Option.t[int]) -> @view_item) fold_view_item_use, (fn(&ENV e, &span sp, ident i, vec[ident] idents, - def_id id, option.t[def]) -> @view_item) fold_view_item_import, + def_id id, Option.t[def]) -> @view_item) fold_view_item_import, (fn(&ENV e, &span sp, ident i) -> @view_item) fold_view_item_export, @@ -316,7 +316,7 @@ type ast_fold[ENV] = (fn(&ENV e, vec[ast.obj_field] fields, vec[@ast.method] methods, - option.t[@ast.method] dtor) -> ast._obj) fold_obj, + Option.t[@ast.method] dtor) -> ast._obj) fold_obj, // Env updates. (fn(&ENV e, @ast.crate c) -> ENV) update_env_for_crate, @@ -341,7 +341,7 @@ type ast_fold[ENV] = fn fold_path[ENV](&ENV env, ast_fold[ENV] fld, &path p) -> path { let vec[@ast.ty] tys_ = vec(); for (@ast.ty t in p.node.types) { - _vec.push[@ast.ty](tys_, fold_ty(env, fld, t)); + Vec.push[@ast.ty](tys_, fold_ty(env, fld, t)); } let ast.path_ p_ = rec(idents=p.node.idents, types=tys_); ret fld.fold_path(env, p.span, p_); @@ -382,7 +382,7 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty { let vec[mt] elts_ = vec(); for (mt elt in elts) { auto ty_ = fold_ty(env, fld, elt.ty); - _vec.push[mt](elts_, rec(ty=ty_, mut=elt.mut)); + Vec.push[mt](elts_, rec(ty=ty_, mut=elt.mut)); } ret fld.fold_ty_tup(env_, t.span, elts_); } @@ -391,7 +391,7 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty { let vec[ast.ty_field] flds_ = vec(); for (ast.ty_field f in flds) { auto ty_ = fold_ty(env, fld, f.mt.ty); - _vec.push[ast.ty_field] + Vec.push[ast.ty_field] (flds_, rec(mt=rec(ty=ty_, mut=f.mt.mut) with f)); } ret fld.fold_ty_rec(env_, t.span, flds_); @@ -404,7 +404,7 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty { m.inputs, m.output); alt (tfn.node) { case (ast.ty_fn(?p, ?ins, ?out)) { - _vec.push[ast.ty_method] + Vec.push[ast.ty_method] (meths_, rec(proto=p, inputs=ins, output=out with m)); } @@ -518,7 +518,7 @@ fn fold_pat[ENV](&ENV env, ast_fold[ENV] fld, @ast.pat p) -> @ast.pat { fn fold_exprs[ENV](&ENV env, ast_fold[ENV] fld, vec[@expr] es) -> vec[@expr] { let vec[@expr] exprs = vec(); for (@expr e in es) { - _vec.push[@expr](exprs, fold_expr(env, fld, e)); + Vec.push[@expr](exprs, fold_expr(env, fld, e)); } ret exprs; } @@ -558,7 +558,7 @@ fn fold_expr[ENV](&ENV env, ast_fold[ENV] fld, &@expr e) -> @expr { case (ast.expr_rec(?fs, ?base, ?t)) { let vec[ast.field] fields = vec(); - let option.t[@expr] b = none[@expr]; + let Option.t[@expr] b = none[@expr]; for (ast.field f in fs) { fields += vec(fold_rec_field(env, fld, f)); } @@ -586,8 +586,8 @@ fn fold_expr[ENV](&ENV env, ast_fold[ENV] fld, &@expr e) -> @expr { case (ast.expr_bind(?f, ?args_opt, ?t)) { auto ff = fold_expr(env_, fld, f); - let vec[option.t[@ast.expr]] aargs_opt = vec(); - for (option.t[@ast.expr] t_opt in args_opt) { + let vec[Option.t[@ast.expr]] aargs_opt = vec(); + for (Option.t[@ast.expr] t_opt in args_opt) { alt (t_opt) { case (none[@ast.expr]) { aargs_opt += vec(none[@ast.expr]); @@ -865,7 +865,7 @@ fn fold_block[ENV](&ENV env, ast_fold[ENV] fld, &block blk) -> block { let vec[@ast.stmt] stmts = vec(); for (@ast.stmt s in blk.node.stmts) { auto new_stmt = fold_stmt[ENV](env_, fld, s); - _vec.push[@ast.stmt](stmts, new_stmt); + Vec.push[@ast.stmt](stmts, new_stmt); ast.index_stmt(index, new_stmt); } @@ -935,7 +935,7 @@ fn fold_obj[ENV](&ENV env, ast_fold[ENV] fld, &ast._obj ob) -> ast._obj { for (ast.obj_field f in ob.fields) { fields += vec(fold_obj_field(env, fld, f)); } - let option.t[@ast.method] dtor = none[@ast.method]; + let Option.t[@ast.method] dtor = none[@ast.method]; alt (ob.dtor) { case (none[@ast.method]) { } case (some[@ast.method](?m)) { @@ -954,7 +954,7 @@ fn fold_obj[ENV](&ENV env, ast_fold[ENV] fld, &ast._obj ob) -> ast._obj { m.node.ann), span=m.span); let ENV _env = fld.update_env_for_item(env, i); - _vec.push[@ast.method](meths, fold_method(_env, fld, m)); + Vec.push[@ast.method](meths, fold_method(_env, fld, m)); } ret fld.fold_obj(env, fields, meths, dtor); } @@ -1057,13 +1057,13 @@ fn fold_mod[ENV](&ENV e, ast_fold[ENV] fld, &ast._mod m) -> ast._mod { for (@view_item vi in m.view_items) { auto new_vi = fold_view_item[ENV](e, fld, vi); - _vec.push[@view_item](view_items, new_vi); + Vec.push[@view_item](view_items, new_vi); ast.index_view_item(index, new_vi); } for (@item i in m.items) { auto new_item = fold_item[ENV](e, fld, i); - _vec.push[@item](items, new_item); + Vec.push[@item](items, new_item); ast.index_item(index, new_item); } @@ -1098,12 +1098,12 @@ fn fold_native_mod[ENV](&ENV e, ast_fold[ENV] fld, for (@view_item vi in m.view_items) { auto new_vi = fold_view_item[ENV](e, fld, vi); - _vec.push[@view_item](view_items, new_vi); + Vec.push[@view_item](view_items, new_vi); } for (@native_item i in m.items) { auto new_item = fold_native_item[ENV](e, fld, i); - _vec.push[@native_item](items, new_item); + Vec.push[@native_item](items, new_item); ast.index_native_item(index, new_item); } @@ -1202,7 +1202,7 @@ fn identity_fold_ty_fn[ENV](&ENV env, &span sp, } fn identity_fold_ty_path[ENV](&ENV env, &span sp, ast.path p, - &option.t[def] d) -> @ty { + &Option.t[def] d) -> @ty { ret @respan(sp, ast.ty_path(p, d)); } @@ -1228,7 +1228,7 @@ fn identity_fold_expr_tup[ENV](&ENV env, &span sp, fn identity_fold_expr_rec[ENV](&ENV env, &span sp, vec[ast.field] fields, - option.t[@expr] base, ann a) -> @expr { + Option.t[@expr] base, ann a) -> @expr { ret @respan(sp, ast.expr_rec(fields, base, a)); } @@ -1243,13 +1243,13 @@ fn identity_fold_expr_self_method[ENV](&ENV env, &span sp, ident id, } fn identity_fold_expr_bind[ENV](&ENV env, &span sp, @expr f, - vec[option.t[@expr]] args_opt, ann a) + vec[Option.t[@expr]] args_opt, ann a) -> @expr { ret @respan(sp, ast.expr_bind(f, args_opt, a)); } fn identity_fold_expr_spawn[ENV](&ENV env, &span sp, - ast.spawn_dom dom, option.t[str] name, + ast.spawn_dom dom, Option.t[str] name, @expr f, vec[@expr] args, ann a) -> @expr { ret @respan(sp, ast.expr_spawn(dom, name, f, args, a)); } @@ -1278,7 +1278,7 @@ fn identity_fold_expr_cast[ENV](&ENV env, &span sp, @ast.expr e, fn identity_fold_expr_if[ENV](&ENV env, &span sp, @expr cond, &block thn, - &option.t[@expr] els, ann a) -> @expr { + &Option.t[@expr] els, ann a) -> @expr { ret @respan(sp, ast.expr_if(cond, thn, els, a)); } @@ -1347,14 +1347,14 @@ fn identity_fold_expr_index[ENV](&ENV env, &span sp, } fn identity_fold_expr_path[ENV](&ENV env, &span sp, - &path p, &option.t[def] d, + &path p, &Option.t[def] d, ann a) -> @expr { ret @respan(sp, ast.expr_path(p, d, a)); } fn identity_fold_expr_ext[ENV](&ENV env, &span sp, &path p, vec[@expr] args, - option.t[str] body, + Option.t[str] body, @expr expanded, ann a) -> @expr { ret @respan(sp, ast.expr_ext(p, args, body, expanded, a)); @@ -1373,12 +1373,12 @@ fn identity_fold_expr_cont[ENV](&ENV env, &span sp, ann a) -> @expr { } fn identity_fold_expr_ret[ENV](&ENV env, &span sp, - &option.t[@expr] rv, ann a) -> @expr { + &Option.t[@expr] rv, ann a) -> @expr { ret @respan(sp, ast.expr_ret(rv, a)); } fn identity_fold_expr_put[ENV](&ENV env, &span sp, - &option.t[@expr] rv, ann a) -> @expr { + &Option.t[@expr] rv, ann a) -> @expr { ret @respan(sp, ast.expr_put(rv, a)); } @@ -1437,7 +1437,7 @@ fn identity_fold_pat_bind[ENV](&ENV e, &span sp, ident i, def_id did, ann a) } fn identity_fold_pat_tag[ENV](&ENV e, &span sp, path p, vec[@pat] args, - option.t[ast.variant_def] d, ann a) -> @pat { + Option.t[ast.variant_def] d, ann a) -> @pat { ret @respan(sp, ast.pat_tag(p, args, d, a)); } @@ -1468,7 +1468,7 @@ fn identity_fold_item_fn[ENV](&ENV e, &span sp, ident i, } fn identity_fold_native_item_fn[ENV](&ENV e, &span sp, ident i, - option.t[str] link_name, + Option.t[str] link_name, &ast.fn_decl decl, vec[ast.ty_param] ty_params, def_id id, ann a) -> @native_item { @@ -1513,14 +1513,14 @@ fn identity_fold_item_obj[ENV](&ENV e, &span sp, ident i, fn identity_fold_view_item_use[ENV](&ENV e, &span sp, ident i, vec[@meta_item] meta_items, - def_id id, option.t[int] cnum) + def_id id, Option.t[int] cnum) -> @view_item { ret @respan(sp, ast.view_item_use(i, meta_items, id, cnum)); } fn identity_fold_view_item_import[ENV](&ENV e, &span sp, ident i, vec[ident] is, def_id id, - option.t[def] target_def) + Option.t[def] target_def) -> @view_item { ret @respan(sp, ast.view_item_import(i, is, id, target_def)); } @@ -1574,7 +1574,7 @@ fn identity_fold_crate[ENV](&ENV e, &span sp, fn identity_fold_obj[ENV](&ENV e, vec[ast.obj_field] fields, vec[@ast.method] methods, - option.t[@ast.method] dtor) -> ast._obj { + Option.t[@ast.method] dtor) -> ast._obj { ret rec(fields=fields, methods=methods, dtor=dtor); } diff --git a/src/comp/middle/metadata.rs b/src/comp/middle/metadata.rs index ce37822d..f8e7a96e 100644 --- a/src/comp/middle/metadata.rs +++ b/src/comp/middle/metadata.rs @@ -1,12 +1,12 @@ -import std._str; -import std._uint; -import std._vec; -import std.map.hashmap; -import std.ebml; -import std.io; -import std.option; -import std.option.some; -import std.option.none; +import std.Str; +import std.UInt; +import std.Vec; +import std.Map.hashmap; +import std.EBML; +import std.IO; +import std.Option; +import std.Option.some; +import std.Option.none; import front.ast; import middle.fold; @@ -75,12 +75,12 @@ mod Encode { fn ty_str(@ctxt cx, ty.t t) -> str { assert (!cx_uses_abbrevs(cx)); - auto sw = io.string_writer(); + auto sw = IO.string_writer(); enc_ty(sw.get_writer(), cx, t); ret sw.get_str(); } - fn enc_ty(io.writer w, @ctxt cx, ty.t t) { + fn enc_ty(IO.writer w, @ctxt cx, ty.t t) { alt (cx.abbrevs) { case (ac_no_abbrevs) { enc_sty(w, cx, ty.struct(cx.tcx, t)); } case (ac_use_abbrevs(?abbrevs)) { @@ -109,8 +109,8 @@ mod Encode { if (abbrev_len < len) { // I.e. it's actually an abbreviation. auto s = ("#" - + _uint.to_str(pos, 16u) + ":" - + _uint.to_str(len, 16u) + "#"); + + UInt.to_str(pos, 16u) + ":" + + UInt.to_str(len, 16u) + "#"); auto a = rec(pos=pos, len=len, s=s); abbrevs.insert(t, a); } @@ -121,7 +121,7 @@ mod Encode { } } - fn enc_mt(io.writer w, @ctxt cx, &ty.mt mt) { + fn enc_mt(IO.writer w, @ctxt cx, &ty.mt mt) { alt (mt.mut) { case (ast.imm) { } case (ast.mut) { w.write_char('m'); } @@ -130,7 +130,7 @@ mod Encode { enc_ty(w, cx, mt.ty); } - fn enc_sty(io.writer w, @ctxt cx, ty.sty st) { + fn enc_sty(IO.writer w, @ctxt cx, ty.sty st) { alt (st) { case (ty.ty_nil) { w.write_char('n'); } case (ty.ty_bool) { w.write_char('b'); } @@ -231,14 +231,14 @@ mod Encode { } } - fn enc_proto(io.writer w, ast.proto proto) { + fn enc_proto(IO.writer w, ast.proto proto) { alt (proto) { case (ast.proto_iter) { w.write_char('W'); } case (ast.proto_fn) { w.write_char('F'); } } } - fn enc_ty_fn(io.writer w, @ctxt cx, vec[ty.arg] args, ty.t out) { + fn enc_ty_fn(IO.writer w, @ctxt cx, vec[ty.arg] args, ty.t out) { w.write_char('['); for (ty.arg arg in args) { if (arg.mode == ast.alias) { w.write_char('&'); } @@ -253,46 +253,46 @@ mod Encode { // Returns a Plain Old LLVM String. fn C_postr(str s) -> ValueRef { - ret llvm.LLVMConstString(_str.buf(s), _str.byte_len(s), False); + ret llvm.LLVMConstString(Str.buf(s), Str.byte_len(s), False); } // Path table encoding -fn encode_name(&ebml.writer ebml_w, str name) { - ebml.start_tag(ebml_w, tag_paths_data_name); - ebml_w.writer.write(_str.bytes(name)); - ebml.end_tag(ebml_w); +fn encode_name(&EBML.writer ebml_w, str name) { + EBML.start_tag(ebml_w, tag_paths_data_name); + ebml_w.writer.write(Str.bytes(name)); + EBML.end_tag(ebml_w); } -fn encode_def_id(&ebml.writer ebml_w, &ast.def_id id) { - ebml.start_tag(ebml_w, tag_def_id); - ebml_w.writer.write(_str.bytes(def_to_str(id))); - ebml.end_tag(ebml_w); +fn encode_def_id(&EBML.writer ebml_w, &ast.def_id id) { + EBML.start_tag(ebml_w, tag_def_id); + ebml_w.writer.write(Str.bytes(def_to_str(id))); + EBML.end_tag(ebml_w); } -fn encode_tag_variant_paths(&ebml.writer ebml_w, +fn encode_tag_variant_paths(&EBML.writer ebml_w, vec[ast.variant] variants, vec[str] path, &mutable vec[tup(str, uint)] index) { for (ast.variant variant in variants) { add_to_index(ebml_w, path, index, variant.node.name); - ebml.start_tag(ebml_w, tag_paths_data_item); + EBML.start_tag(ebml_w, tag_paths_data_item); encode_name(ebml_w, variant.node.name); encode_def_id(ebml_w, variant.node.id); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } } -fn add_to_index(&ebml.writer ebml_w, +fn add_to_index(&EBML.writer ebml_w, vec[str] path, &mutable vec[tup(str, uint)] index, str name) { auto full_path = path + vec(name); - index += vec(tup(_str.connect(full_path, "."), ebml_w.writer.tell())); + index += vec(tup(Str.connect(full_path, "."), ebml_w.writer.tell())); } -fn encode_native_module_item_paths(&ebml.writer ebml_w, +fn encode_native_module_item_paths(&EBML.writer ebml_w, &ast.native_mod nmod, vec[str] path, &mutable vec[tup(str, uint)] index) { @@ -300,23 +300,23 @@ fn encode_native_module_item_paths(&ebml.writer ebml_w, alt (nitem.node) { case (ast.native_item_ty(?id, ?did)) { add_to_index(ebml_w, path, index, id); - ebml.start_tag(ebml_w, tag_paths_data_item); + EBML.start_tag(ebml_w, tag_paths_data_item); encode_name(ebml_w, id); encode_def_id(ebml_w, did); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } case (ast.native_item_fn(?id, _, _, _, ?did, _)) { add_to_index(ebml_w, path, index, id); - ebml.start_tag(ebml_w, tag_paths_data_item); + EBML.start_tag(ebml_w, tag_paths_data_item); encode_name(ebml_w, id); encode_def_id(ebml_w, did); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } } } } -fn encode_module_item_paths(&ebml.writer ebml_w, +fn encode_module_item_paths(&EBML.writer ebml_w, &ast._mod module, vec[str] path, &mutable vec[tup(str, uint)] index) { @@ -325,197 +325,197 @@ fn encode_module_item_paths(&ebml.writer ebml_w, alt (it.node) { case (ast.item_const(?id, _, ?tps, ?did, ?ann)) { add_to_index(ebml_w, path, index, id); - ebml.start_tag(ebml_w, tag_paths_data_item); + EBML.start_tag(ebml_w, tag_paths_data_item); encode_name(ebml_w, id); encode_def_id(ebml_w, did); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } case (ast.item_fn(?id, _, ?tps, ?did, ?ann)) { add_to_index(ebml_w, path, index, id); - ebml.start_tag(ebml_w, tag_paths_data_item); + EBML.start_tag(ebml_w, tag_paths_data_item); encode_name(ebml_w, id); encode_def_id(ebml_w, did); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } case (ast.item_mod(?id, ?_mod, ?did)) { add_to_index(ebml_w, path, index, id); - ebml.start_tag(ebml_w, tag_paths_data_mod); + EBML.start_tag(ebml_w, tag_paths_data_mod); encode_name(ebml_w, id); encode_def_id(ebml_w, did); encode_module_item_paths(ebml_w, _mod, path + vec(id), index); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } case (ast.item_native_mod(?id, ?nmod, ?did)) { add_to_index(ebml_w, path, index, id); - ebml.start_tag(ebml_w, tag_paths_data_mod); + EBML.start_tag(ebml_w, tag_paths_data_mod); encode_name(ebml_w, id); encode_def_id(ebml_w, did); encode_native_module_item_paths(ebml_w, nmod, path + vec(id), index); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } case (ast.item_ty(?id, _, ?tps, ?did, ?ann)) { add_to_index(ebml_w, path, index, id); - ebml.start_tag(ebml_w, tag_paths_data_item); + EBML.start_tag(ebml_w, tag_paths_data_item); encode_name(ebml_w, id); encode_def_id(ebml_w, did); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } case (ast.item_tag(?id, ?variants, ?tps, ?did, _)) { add_to_index(ebml_w, path, index, id); - ebml.start_tag(ebml_w, tag_paths_data_item); + EBML.start_tag(ebml_w, tag_paths_data_item); encode_name(ebml_w, id); encode_def_id(ebml_w, did); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); encode_tag_variant_paths(ebml_w, variants, path, index); } case (ast.item_obj(?id, _, ?tps, ?odid, ?ann)) { add_to_index(ebml_w, path, index, id); - ebml.start_tag(ebml_w, tag_paths_data_item); + EBML.start_tag(ebml_w, tag_paths_data_item); encode_name(ebml_w, id); encode_def_id(ebml_w, odid.ctor); encode_obj_type_id(ebml_w, odid.ty); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } } } } -fn encode_item_paths(&ebml.writer ebml_w, @ast.crate crate) +fn encode_item_paths(&EBML.writer ebml_w, @ast.crate crate) -> vec[tup(str, uint)] { let vec[tup(str, uint)] index = vec(); let vec[str] path = vec(); - ebml.start_tag(ebml_w, tag_paths); + EBML.start_tag(ebml_w, tag_paths); encode_module_item_paths(ebml_w, crate.node.module, path, index); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); ret index; } // Item info table encoding -fn encode_kind(&ebml.writer ebml_w, u8 c) { - ebml.start_tag(ebml_w, tag_items_data_item_kind); +fn encode_kind(&EBML.writer ebml_w, u8 c) { + EBML.start_tag(ebml_w, tag_items_data_item_kind); ebml_w.writer.write(vec(c)); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } fn def_to_str(ast.def_id did) -> str { ret #fmt("%d:%d", did._0, did._1); } -fn encode_type_param_count(&ebml.writer ebml_w, vec[ast.ty_param] tps) { - ebml.start_tag(ebml_w, tag_items_data_item_ty_param_count); - ebml.write_vint(ebml_w.writer, _vec.len[ast.ty_param](tps)); - ebml.end_tag(ebml_w); +fn encode_type_param_count(&EBML.writer ebml_w, vec[ast.ty_param] tps) { + EBML.start_tag(ebml_w, tag_items_data_item_ty_param_count); + EBML.write_vint(ebml_w.writer, Vec.len[ast.ty_param](tps)); + EBML.end_tag(ebml_w); } -fn encode_variant_id(&ebml.writer ebml_w, ast.def_id vid) { - ebml.start_tag(ebml_w, tag_items_data_item_variant); - ebml_w.writer.write(_str.bytes(def_to_str(vid))); - ebml.end_tag(ebml_w); +fn encode_variant_id(&EBML.writer ebml_w, ast.def_id vid) { + EBML.start_tag(ebml_w, tag_items_data_item_variant); + ebml_w.writer.write(Str.bytes(def_to_str(vid))); + EBML.end_tag(ebml_w); } -fn encode_type(@trans.crate_ctxt cx, &ebml.writer ebml_w, ty.t typ) { - ebml.start_tag(ebml_w, tag_items_data_item_type); +fn encode_type(@trans.crate_ctxt cx, &EBML.writer ebml_w, ty.t typ) { + EBML.start_tag(ebml_w, tag_items_data_item_type); auto f = def_to_str; auto ty_str_ctxt = @rec(ds=f, tcx=cx.tcx, abbrevs=ac_use_abbrevs(cx.type_abbrevs)); - Encode.enc_ty(io.new_writer_(ebml_w.writer), ty_str_ctxt, typ); - ebml.end_tag(ebml_w); + Encode.enc_ty(IO.new_writer_(ebml_w.writer), ty_str_ctxt, typ); + EBML.end_tag(ebml_w); } -fn encode_symbol(@trans.crate_ctxt cx, &ebml.writer ebml_w, ast.def_id did) { - ebml.start_tag(ebml_w, tag_items_data_item_symbol); - ebml_w.writer.write(_str.bytes(cx.item_symbols.get(did))); - ebml.end_tag(ebml_w); +fn encode_symbol(@trans.crate_ctxt cx, &EBML.writer ebml_w, ast.def_id did) { + EBML.start_tag(ebml_w, tag_items_data_item_symbol); + ebml_w.writer.write(Str.bytes(cx.item_symbols.get(did))); + EBML.end_tag(ebml_w); } -fn encode_discriminant(@trans.crate_ctxt cx, &ebml.writer ebml_w, +fn encode_discriminant(@trans.crate_ctxt cx, &EBML.writer ebml_w, ast.def_id did) { - ebml.start_tag(ebml_w, tag_items_data_item_symbol); - ebml_w.writer.write(_str.bytes(cx.discrim_symbols.get(did))); - ebml.end_tag(ebml_w); + EBML.start_tag(ebml_w, tag_items_data_item_symbol); + ebml_w.writer.write(Str.bytes(cx.discrim_symbols.get(did))); + EBML.end_tag(ebml_w); } -fn encode_tag_id(&ebml.writer ebml_w, &ast.def_id id) { - ebml.start_tag(ebml_w, tag_items_data_item_tag_id); - ebml_w.writer.write(_str.bytes(def_to_str(id))); - ebml.end_tag(ebml_w); +fn encode_tag_id(&EBML.writer ebml_w, &ast.def_id id) { + EBML.start_tag(ebml_w, tag_items_data_item_tag_id); + ebml_w.writer.write(Str.bytes(def_to_str(id))); + EBML.end_tag(ebml_w); } -fn encode_obj_type_id(&ebml.writer ebml_w, &ast.def_id id) { - ebml.start_tag(ebml_w, tag_items_data_item_obj_type_id); - ebml_w.writer.write(_str.bytes(def_to_str(id))); - ebml.end_tag(ebml_w); +fn encode_obj_type_id(&EBML.writer ebml_w, &ast.def_id id) { + EBML.start_tag(ebml_w, tag_items_data_item_obj_type_id); + ebml_w.writer.write(Str.bytes(def_to_str(id))); + EBML.end_tag(ebml_w); } -fn encode_tag_variant_info(@trans.crate_ctxt cx, &ebml.writer ebml_w, +fn encode_tag_variant_info(@trans.crate_ctxt cx, &EBML.writer ebml_w, ast.def_id did, vec[ast.variant] variants, &mutable vec[tup(int, uint)] index, vec[ast.ty_param] ty_params) { for (ast.variant variant in variants) { index += vec(tup(variant.node.id._1, ebml_w.writer.tell())); - ebml.start_tag(ebml_w, tag_items_data_item); + EBML.start_tag(ebml_w, tag_items_data_item); encode_def_id(ebml_w, variant.node.id); encode_kind(ebml_w, 'v' as u8); encode_tag_id(ebml_w, did); encode_type(cx, ebml_w, trans.node_ann_type(cx, variant.node.ann)); - if (_vec.len[ast.variant_arg](variant.node.args) > 0u) { + if (Vec.len[ast.variant_arg](variant.node.args) > 0u) { encode_symbol(cx, ebml_w, variant.node.id); } encode_discriminant(cx, ebml_w, variant.node.id); encode_type_param_count(ebml_w, ty_params); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } } -fn encode_info_for_item(@trans.crate_ctxt cx, &ebml.writer ebml_w, +fn encode_info_for_item(@trans.crate_ctxt cx, &EBML.writer ebml_w, @ast.item item, &mutable vec[tup(int, uint)] index) { alt (item.node) { case (ast.item_const(_, _, _, ?did, ?ann)) { - ebml.start_tag(ebml_w, tag_items_data_item); + EBML.start_tag(ebml_w, tag_items_data_item); encode_def_id(ebml_w, did); encode_kind(ebml_w, 'c' as u8); encode_type(cx, ebml_w, trans.node_ann_type(cx, ann)); encode_symbol(cx, ebml_w, did); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } case (ast.item_fn(_, _, ?tps, ?did, ?ann)) { - ebml.start_tag(ebml_w, tag_items_data_item); + EBML.start_tag(ebml_w, tag_items_data_item); encode_def_id(ebml_w, did); encode_kind(ebml_w, 'f' as u8); encode_type_param_count(ebml_w, tps); encode_type(cx, ebml_w, trans.node_ann_type(cx, ann)); encode_symbol(cx, ebml_w, did); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } case (ast.item_mod(_, _, ?did)) { - ebml.start_tag(ebml_w, tag_items_data_item); + EBML.start_tag(ebml_w, tag_items_data_item); encode_def_id(ebml_w, did); encode_kind(ebml_w, 'm' as u8); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } case (ast.item_native_mod(_, _, ?did)) { - ebml.start_tag(ebml_w, tag_items_data_item); + EBML.start_tag(ebml_w, tag_items_data_item); encode_def_id(ebml_w, did); encode_kind(ebml_w, 'n' as u8); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } case (ast.item_ty(?id, _, ?tps, ?did, ?ann)) { - ebml.start_tag(ebml_w, tag_items_data_item); + EBML.start_tag(ebml_w, tag_items_data_item); encode_def_id(ebml_w, did); encode_kind(ebml_w, 'y' as u8); encode_type_param_count(ebml_w, tps); encode_type(cx, ebml_w, trans.node_ann_type(cx, ann)); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } case (ast.item_tag(?id, ?variants, ?tps, ?did, ?ann)) { - ebml.start_tag(ebml_w, tag_items_data_item); + EBML.start_tag(ebml_w, tag_items_data_item); encode_def_id(ebml_w, did); encode_kind(ebml_w, 't' as u8); encode_type_param_count(ebml_w, tps); @@ -523,33 +523,33 @@ fn encode_info_for_item(@trans.crate_ctxt cx, &ebml.writer ebml_w, for (ast.variant v in variants) { encode_variant_id(ebml_w, v.node.id); } - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); encode_tag_variant_info(cx, ebml_w, did, variants, index, tps); } case (ast.item_obj(?id, _, ?tps, ?odid, ?ann)) { - ebml.start_tag(ebml_w, tag_items_data_item); + EBML.start_tag(ebml_w, tag_items_data_item); encode_def_id(ebml_w, odid.ctor); encode_kind(ebml_w, 'o' as u8); encode_type_param_count(ebml_w, tps); auto fn_ty = trans.node_ann_type(cx, ann); encode_type(cx, ebml_w, fn_ty); encode_symbol(cx, ebml_w, odid.ctor); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); - ebml.start_tag(ebml_w, tag_items_data_item); + EBML.start_tag(ebml_w, tag_items_data_item); encode_def_id(ebml_w, odid.ty); encode_kind(ebml_w, 'y' as u8); encode_type_param_count(ebml_w, tps); encode_type(cx, ebml_w, ty.ty_fn_ret(cx.tcx, fn_ty)); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } } } -fn encode_info_for_native_item(@trans.crate_ctxt cx, &ebml.writer ebml_w, +fn encode_info_for_native_item(@trans.crate_ctxt cx, &EBML.writer ebml_w, @ast.native_item nitem) { - ebml.start_tag(ebml_w, tag_items_data_item); + EBML.start_tag(ebml_w, tag_items_data_item); alt (nitem.node) { case (ast.native_item_ty(_, ?did)) { encode_def_id(ebml_w, did); @@ -564,14 +564,14 @@ fn encode_info_for_native_item(@trans.crate_ctxt cx, &ebml.writer ebml_w, encode_symbol(cx, ebml_w, did); } } - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } -fn encode_info_for_items(@trans.crate_ctxt cx, &ebml.writer ebml_w) +fn encode_info_for_items(@trans.crate_ctxt cx, &EBML.writer ebml_w) -> vec[tup(int, uint)] { let vec[tup(int, uint)] index = vec(); - ebml.start_tag(ebml_w, tag_items_data); + EBML.start_tag(ebml_w, tag_items_data); for each (@tup(ast.def_id, @ast.item) kvp in cx.items.items()) { index += vec(tup(kvp._0._1, ebml_w.writer.tell())); encode_info_for_item(cx, ebml_w, kvp._1, index); @@ -581,7 +581,7 @@ fn encode_info_for_items(@trans.crate_ctxt cx, &ebml.writer ebml_w) index += vec(tup(kvp._0._1, ebml_w.writer.tell())); encode_info_for_native_item(cx, ebml_w, kvp._1); } - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); ret index; } @@ -597,7 +597,7 @@ fn hash_def_num(&int def_num) -> uint { fn hash_path(&str s) -> uint { auto h = 5381u; - for (u8 ch in _str.bytes(s)) { + for (u8 ch in Str.bytes(s)) { h = ((h << 5u) + h) ^ (ch as uint); } ret h; @@ -606,7 +606,7 @@ fn hash_path(&str s) -> uint { fn create_index[T](vec[tup(T, uint)] index, fn(&T) -> uint hash_fn) -> vec[vec[tup(T, uint)]] { let vec[vec[tup(T, uint)]] buckets = vec(); - for each (uint i in _uint.range(0u, 256u)) { + for each (uint i in UInt.range(0u, 256u)) { let vec[tup(T, uint)] bucket = vec(); buckets += vec(bucket); } @@ -619,69 +619,69 @@ fn create_index[T](vec[tup(T, uint)] index, fn(&T) -> uint hash_fn) ret buckets; } -fn encode_index[T](&ebml.writer ebml_w, vec[vec[tup(T, uint)]] buckets, - fn(io.writer, &T) write_fn) { - auto writer = io.new_writer_(ebml_w.writer); +fn encode_index[T](&EBML.writer ebml_w, vec[vec[tup(T, uint)]] buckets, + fn(IO.writer, &T) write_fn) { + auto writer = IO.new_writer_(ebml_w.writer); - ebml.start_tag(ebml_w, tag_index); + EBML.start_tag(ebml_w, tag_index); let vec[uint] bucket_locs = vec(); - ebml.start_tag(ebml_w, tag_index_buckets); + EBML.start_tag(ebml_w, tag_index_buckets); for (vec[tup(T, uint)] bucket in buckets) { bucket_locs += vec(ebml_w.writer.tell()); - ebml.start_tag(ebml_w, tag_index_buckets_bucket); + EBML.start_tag(ebml_w, tag_index_buckets_bucket); for (tup(T, uint) elt in bucket) { - ebml.start_tag(ebml_w, tag_index_buckets_bucket_elt); + EBML.start_tag(ebml_w, tag_index_buckets_bucket_elt); writer.write_be_uint(elt._1, 4u); write_fn(writer, elt._0); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); - ebml.start_tag(ebml_w, tag_index_table); + EBML.start_tag(ebml_w, tag_index_table); for (uint pos in bucket_locs) { writer.write_be_uint(pos, 4u); } - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); } -fn write_str(io.writer writer, &str s) { +fn write_str(IO.writer writer, &str s) { writer.write_str(s); } -fn write_int(io.writer writer, &int n) { +fn write_int(IO.writer writer, &int n) { writer.write_be_uint(n as uint, 4u); } fn encode_metadata(@trans.crate_ctxt cx, @ast.crate crate) -> ValueRef { - auto string_w = io.string_writer(); + auto string_w = IO.string_writer(); auto buf_w = string_w.get_writer().get_buf_writer(); - auto ebml_w = ebml.create_writer(buf_w); + auto ebml_w = EBML.create_writer(buf_w); // Encode and index the paths. - ebml.start_tag(ebml_w, tag_paths); + EBML.start_tag(ebml_w, tag_paths); auto paths_index = encode_item_paths(ebml_w, crate); auto str_writer = write_str; auto path_hasher = hash_path; auto paths_buckets = create_index[str](paths_index, path_hasher); encode_index[str](ebml_w, paths_buckets, str_writer); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); // Encode and index the items. - ebml.start_tag(ebml_w, tag_items); + EBML.start_tag(ebml_w, tag_items); auto items_index = encode_info_for_items(cx, ebml_w); auto int_writer = write_int; auto item_hasher = hash_def_num; auto items_buckets = create_index[int](items_index, item_hasher); encode_index[int](ebml_w, items_buckets, int_writer); - ebml.end_tag(ebml_w); + EBML.end_tag(ebml_w); // Pad this, since something (LLVM, presumably) is cutting off the // remaining % 4 bytes. @@ -698,9 +698,9 @@ fn write_metadata(@trans.crate_ctxt cx, @ast.crate crate) { auto llconst = trans.C_struct(vec(llmeta)); auto llglobal = llvm.LLVMAddGlobal(cx.llmod, trans.val_ty(llconst), - _str.buf("rust_metadata")); + Str.buf("rust_metadata")); llvm.LLVMSetInitializer(llglobal, llconst); - llvm.LLVMSetSection(llglobal, _str.buf(x86.get_meta_sect_name())); + llvm.LLVMSetSection(llglobal, Str.buf(x86.get_meta_sect_name())); } // diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 8b92cabd..433b4734 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -7,15 +7,15 @@ import driver.session; import util.common.new_def_hash; import util.common.span; import util.typestate_ann.ts_ann; -import std.map.hashmap; -import std.list.list; -import std.list.nil; -import std.list.cons; -import std.option; -import std.option.some; -import std.option.none; -import std._str; -import std._vec; +import std.Map.hashmap; +import std.List.list; +import std.List.nil; +import std.List.cons; +import std.Option; +import std.Option.some; +import std.Option.none; +import std.Str; +import std.Vec; tag scope { scope_crate(@ast.crate); @@ -43,7 +43,7 @@ tag direction { down; } -type import_map = std.map.hashmap[ast.def_id,def_wrap]; +type import_map = std.Map.hashmap[ast.def_id,def_wrap]; // A simple wrapper over defs that stores a bit more information about modules // and uses so that we can use the regular lookup_name when resolving imports. @@ -112,7 +112,7 @@ fn unwrap_def(def_wrap d) -> def { } fn lookup_external_def(session.session sess, int cnum, vec[ident] idents) - -> option.t[def_wrap] { + -> Option.t[def_wrap] { alt (creader.lookup_def(sess, cnum, idents)) { case (none[ast.def]) { ret none[def_wrap]; @@ -141,7 +141,7 @@ fn lookup_external_def(session.session sess, int cnum, vec[ident] idents) fn find_final_def(&env e, import_map index, &span sp, vec[ident] idents, namespace ns, - option.t[ast.def_id] import_id) -> def_wrap { + Option.t[ast.def_id] import_id) -> def_wrap { // We are given a series of identifiers (p.q.r) and we know that // in the environment 'e' the identifier 'p' was resolved to 'd'. We @@ -153,8 +153,8 @@ fn find_final_def(&env e, import_map index, fn found_mod(&env e, &import_map index, &span sp, vec[ident] idents, namespace ns, @ast.item i) -> def_wrap { - auto len = _vec.len[ident](idents); - auto rest_idents = _vec.slice[ident](idents, 1u, len); + auto len = Vec.len[ident](idents); + auto rest_idents = Vec.slice[ident](idents, 1u, len); auto empty_e = rec(scopes = nil[scope], sess = e.sess); auto tmp_e = update_env_for_item(empty_e, i); @@ -178,8 +178,8 @@ fn find_final_def(&env e, import_map index, vec[ident] idents, namespace ns, ast.def_id mod_id) -> def_wrap { - auto len = _vec.len[ident](idents); - auto rest_idents = _vec.slice[ident](idents, 1u, len); + auto len = Vec.len[ident](idents); + auto rest_idents = Vec.slice[ident](idents, 1u, len); auto empty_e = rec(scopes = nil[scope], sess = e.sess); auto tmp_e = update_env_for_external_mod(empty_e, mod_id, idents); @@ -202,12 +202,12 @@ fn find_final_def(&env e, import_map index, fn found_crate(&env e, &import_map index, &span sp, vec[ident] idents, int cnum) -> def_wrap { - auto len = _vec.len[ident](idents); - auto rest_idents = _vec.slice[ident](idents, 1u, len); + auto len = Vec.len[ident](idents); + auto rest_idents = Vec.slice[ident](idents, 1u, len); alt (lookup_external_def(e.sess, cnum, rest_idents)) { case (none[def_wrap]) { e.sess.span_err(sp, #fmt("unbound name '%s'", - _str.connect(idents, "."))); + Str.connect(idents, "."))); fail; } case (some[def_wrap](?dw)) { ret dw; } @@ -227,7 +227,7 @@ fn find_final_def(&env e, import_map index, case (_) { } } - auto len = _vec.len[ident](idents); + auto len = Vec.len[ident](idents); if (len == 1u) { ret d; } @@ -247,13 +247,13 @@ fn find_final_def(&env e, import_map index, case (def_wrap_use(?vi)) { alt (vi.node) { case (ast.view_item_use(_, _, _, ?cnum_opt)) { - auto cnum = option.get[int](cnum_opt); + auto cnum = Option.get[int](cnum_opt); ret found_crate(e, index, sp, idents, cnum); } } } case (def_wrap_other(?d)) { - let uint l = _vec.len[ident](idents); + let uint l = Vec.len[ident](idents); ret def_wrap_expr_field(l, d); } } @@ -261,7 +261,7 @@ fn find_final_def(&env e, import_map index, } if (import_id != none[ast.def_id]) { - alt (index.find(option.get[ast.def_id](import_id))) { + alt (index.find(Option.get[ast.def_id](import_id))) { case (some[def_wrap](?x)) { alt (x) { case (def_wrap_resolving) { @@ -276,7 +276,7 @@ fn find_final_def(&env e, import_map index, case (none[def_wrap]) { } } - index.insert(option.get[ast.def_id](import_id), def_wrap_resolving); + index.insert(Option.get[ast.def_id](import_id), def_wrap_resolving); } auto first = idents.(0); auto d_ = lookup_name_wrapped(e, first, ns, up); @@ -288,7 +288,7 @@ fn find_final_def(&env e, import_map index, case (some[tup(@env, def_wrap)](?d)) { auto x = found_something(*d._0, index, sp, idents, ns, d._1); if (import_id != none[ast.def_id]) { - index.insert(option.get[ast.def_id](import_id), x); + index.insert(Option.get[ast.def_id](import_id), x); } ret x; } @@ -296,7 +296,7 @@ fn find_final_def(&env e, import_map index, } fn lookup_name_wrapped(&env e, ast.ident i, namespace ns, direction dir) - -> option.t[tup(@env, def_wrap)] { + -> Option.t[tup(@env, def_wrap)] { // log "resolving name " + i; @@ -357,7 +357,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns, direction dir) } fn check_mod(ast.ident i, ast._mod m, namespace ns, - direction dir) -> option.t[def_wrap] { + direction dir) -> Option.t[def_wrap] { fn visible(ast.ident i, ast._mod m, direction dir) -> bool { @@ -411,7 +411,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns, direction dir) } } - fn check_native_mod(ast.ident i, ast.native_mod m) -> option.t[def_wrap] { + fn check_native_mod(ast.ident i, ast.native_mod m) -> Option.t[def_wrap] { alt (m.index.find(i)) { case (some[ast.native_mod_index_entry](?ent)) { @@ -431,9 +431,9 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns, direction dir) } fn handle_fn_decl(ast.ident identifier, &ast.fn_decl decl, - &vec[ast.ty_param] ty_params) -> option.t[def_wrap] { + &vec[ast.ty_param] ty_params) -> Option.t[def_wrap] { for (ast.arg a in decl.inputs) { - if (_str.eq(a.ident, identifier)) { + if (Str.eq(a.ident, identifier)) { auto t = ast.def_arg(a.id); ret some(def_wrap_other(t)); } @@ -441,7 +441,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns, direction dir) auto i = 0u; for (ast.ty_param tp in ty_params) { - if (_str.eq(tp, identifier)) { + if (Str.eq(tp, identifier)) { auto t = ast.def_ty_arg(i); ret some(def_wrap_other(t)); } @@ -465,7 +465,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns, direction dir) } fn check_block(ast.ident i, &ast.block_ b, namespace ns) - -> option.t[def_wrap] { + -> Option.t[def_wrap] { alt (b.index.find(i)) { case (some[ast.block_index_entry](?ix)) { alt(ix) { @@ -486,7 +486,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns, direction dir) } fn in_scope(&session.session sess, ast.ident identifier, &scope s, - namespace ns, direction dir) -> option.t[def_wrap] { + namespace ns, direction dir) -> Option.t[def_wrap] { alt (s) { case (scope_crate(?c)) { @@ -500,7 +500,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns, direction dir) } case (ast.item_obj(_, ?ob, ?ty_params, _, _)) { for (ast.obj_field f in ob.fields) { - if (_str.eq(f.ident, identifier)) { + if (Str.eq(f.ident, identifier)) { auto t = ast.def_obj_field(f.id); ret some(def_wrap_other(t)); } @@ -508,7 +508,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns, direction dir) auto i = 0u; for (ast.ty_param tp in ty_params) { - if (_str.eq(tp, identifier)) { + if (Str.eq(tp, identifier)) { auto t = ast.def_ty_arg(i); ret some(def_wrap_other(t)); } @@ -518,7 +518,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns, direction dir) case (ast.item_tag(_,?variants,?ty_params,?tag_id,_)) { auto i = 0u; for (ast.ty_param tp in ty_params) { - if (_str.eq(tp, identifier)) { + if (Str.eq(tp, identifier)) { auto t = ast.def_ty_arg(i); ret some(def_wrap_other(t)); } @@ -534,7 +534,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns, direction dir) case (ast.item_ty(_, _, ?ty_params, _, _)) { auto i = 0u; for (ast.ty_param tp in ty_params) { - if (_str.eq(tp, identifier)) { + if (Str.eq(tp, identifier)) { auto t = ast.def_ty_arg(i); ret some(def_wrap_other(t)); } @@ -560,7 +560,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns, direction dir) case (scope_loop(?d)) { alt (d.node) { case (ast.decl_local(?local)) { - if (_str.eq(local.ident, identifier)) { + if (Str.eq(local.ident, identifier)) { auto lc = ast.def_local(local.id); ret some(def_wrap_other(lc)); } @@ -605,9 +605,9 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns, direction dir) } fn fold_pat_tag(&env e, &span sp, ast.path p, vec[@ast.pat] args, - option.t[ast.variant_def] old_def, + Option.t[ast.variant_def] old_def, ann a) -> @ast.pat { - auto len = _vec.len[ast.ident](p.node.idents); + auto len = Vec.len[ast.ident](p.node.idents); auto last_id = p.node.idents.(len - 1u); auto new_def; auto index = new_def_hash[def_wrap](); @@ -646,9 +646,9 @@ fn fold_pat_tag(&env e, &span sp, ast.path p, vec[@ast.pat] args, // and split that off as the 'primary' expr_path, with secondary expr_field // expressions tacked on the end. -fn fold_expr_path(&env e, &span sp, &ast.path p, &option.t[def] d, +fn fold_expr_path(&env e, &span sp, &ast.path p, &Option.t[def] d, ann a) -> @ast.expr { - auto n_idents = _vec.len[ast.ident](p.node.idents); + auto n_idents = Vec.len[ast.ident](p.node.idents); assert (n_idents != 0u); auto index = new_def_hash[def_wrap](); @@ -669,7 +669,7 @@ fn fold_expr_path(&env e, &span sp, &ast.path p, &option.t[def] d, } } auto path_elems = - _vec.slice[ident](p.node.idents, 0u, path_len); + Vec.slice[ident](p.node.idents, 0u, path_len); auto p_ = rec(node=rec(idents = path_elems with p.node) with p); auto d_ = some(unwrap_def(d)); auto ex = @fold.respan[ast.expr_](sp, ast.expr_path(p_, d_, a)); @@ -685,9 +685,9 @@ fn fold_expr_path(&env e, &span sp, &ast.path p, &option.t[def] d, fn fold_view_item_import(&env e, &span sp, import_map index, ident i, vec[ident] is, ast.def_id id, - option.t[def] target_id) -> @ast.view_item { + Option.t[def] target_id) -> @ast.view_item { // Produce errors for invalid imports - auto len = _vec.len[ast.ident](is); + auto len = Vec.len[ast.ident](is); auto last_id = is.(len - 1u); auto d = find_final_def(e, index, sp, is, ns_value, some(id)); alt (d) { @@ -698,12 +698,12 @@ fn fold_view_item_import(&env e, &span sp, case (_) { } } - let option.t[def] target_def = some(unwrap_def(d)); + let Option.t[def] target_def = some(unwrap_def(d)); ret @fold.respan[ast.view_item_](sp, ast.view_item_import(i, is, id, target_def)); } -fn fold_ty_path(&env e, &span sp, ast.path p, &option.t[def] d) -> @ast.ty { +fn fold_ty_path(&env e, &span sp, ast.path p, &Option.t[def] d) -> @ast.ty { auto index = new_def_hash[def_wrap](); auto d = find_final_def(e, index, sp, p.node.idents, ns_type, none[ast.def_id]); diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 86ddcddf..9f10097d 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -1,14 +1,14 @@ -import std._int; -import std._str; -import std._uint; -import std._vec; -import std._str.rustrt.sbuf; -import std._vec.rustrt.vbuf; -import std.map; -import std.map.hashmap; -import std.option; -import std.option.some; -import std.option.none; +import std.Int; +import std.Str; +import std.UInt; +import std.Vec; +import std.Str.rustrt.sbuf; +import std.Vec.rustrt.vbuf; +import std.Map; +import std.Map.hashmap; +import std.Option; +import std.Option.some; +import std.Option.none; import front.ast; import front.creader; @@ -110,7 +110,7 @@ state type crate_ctxt = rec(session.session sess, hashmap[ty.t, TypeRef] lltypes, @glue_fns glues, namegen names, - std.sha1.sha1 sha, + std.SHA1.sha1 sha, hashmap[ty.t, str] type_sha1s, hashmap[ty.t, metadata.ty_abbrev] type_abbrevs, ty.ctxt tcx); @@ -129,8 +129,8 @@ state type fn_ctxt = rec(ValueRef llfn, ValueRef llenv, ValueRef llretptr, mutable BasicBlockRef llallocas, - mutable option.t[self_vt] llself, - mutable option.t[ValueRef] lliterbody, + mutable Option.t[self_vt] llself, + mutable Option.t[ValueRef] lliterbody, hashmap[ast.def_id, ValueRef] llargs, hashmap[ast.def_id, ValueRef] llobjfields, hashmap[ast.def_id, ValueRef] lllocals, @@ -145,7 +145,7 @@ tag cleanup { tag block_kind { SCOPE_BLOCK; - LOOP_SCOPE_BLOCK(option.t[@block_ctxt], @block_ctxt); + LOOP_SCOPE_BLOCK(Option.t[@block_ctxt], @block_ctxt); NON_SCOPE_BLOCK; } @@ -156,7 +156,7 @@ state type block_ctxt = rec(BasicBlockRef llbb, mutable vec[cleanup] cleanups, @fn_ctxt fcx); -// FIXME: we should be able to use option.t[@block_parent] here but +// FIXME: we should be able to use Option.t[@block_parent] here but // the infinite-tag check in rustboot gets upset. tag block_parent { @@ -177,7 +177,7 @@ fn extend_path(@local_ctxt cx, str name) -> @local_ctxt { } fn path_name(vec[str] path) -> str { - ret _str.connect(path, sep()); + ret Str.connect(path, sep()); } @@ -192,7 +192,7 @@ fn get_type_sha1(@crate_ctxt ccx, ty.t t) -> str { // to be independent of one another in the crate. auto cx = @rec(ds=f, tcx=ccx.tcx, abbrevs=metadata.ac_no_abbrevs); ccx.sha.input_str(metadata.Encode.ty_str(cx, t)); - hash = _str.substr(ccx.sha.result_str(), 0u, 16u); + hash = Str.substr(ccx.sha.result_str(), 0u, 16u); ccx.type_sha1s.insert(t, hash); } } @@ -306,8 +306,8 @@ fn T_char() -> TypeRef { fn T_fn(vec[TypeRef] inputs, TypeRef output) -> TypeRef { ret llvm.LLVMFunctionType(output, - _vec.buf[TypeRef](inputs), - _vec.len[TypeRef](inputs), + Vec.buf[TypeRef](inputs), + Vec.len[TypeRef](inputs), False); } @@ -321,8 +321,8 @@ fn T_ptr(TypeRef t) -> TypeRef { } fn T_struct(vec[TypeRef] elts) -> TypeRef { - ret llvm.LLVMStructType(_vec.buf[TypeRef](elts), - _vec.len[TypeRef](elts), + ret llvm.LLVMStructType(Vec.buf[TypeRef](elts), + Vec.len[TypeRef](elts), False); } @@ -352,9 +352,9 @@ fn T_task(type_names tn) -> TypeRef { fn T_tydesc_field(type_names tn, int field) -> TypeRef { // Bit of a kludge: pick the fn typeref out of the tydesc.. let vec[TypeRef] tydesc_elts = - _vec.init_elt[TypeRef](T_nil(), abi.n_tydesc_fields as uint); + Vec.init_elt[TypeRef](T_nil(), abi.n_tydesc_fields as uint); llvm.LLVMGetStructElementTypes(T_tydesc(tn), - _vec.buf[TypeRef](tydesc_elts)); + Vec.buf[TypeRef](tydesc_elts)); auto t = llvm.LLVMGetElementType(tydesc_elts.(field)); ret t; } @@ -372,7 +372,7 @@ fn T_glue_fn(type_names tn) -> TypeRef { fn T_dtor(@crate_ctxt ccx, TypeRef llself_ty) -> TypeRef { ret type_of_fn_full(ccx, ast.proto_fn, some[TypeRef](llself_ty), - _vec.empty[ty.arg](), ty.mk_nil(ccx.tcx), 0u); + Vec.empty[ty.arg](), ty.mk_nil(ccx.tcx), 0u); } fn T_cmp_glue_fn(type_names tn) -> TypeRef { @@ -535,7 +535,7 @@ fn T_opaque_closure_ptr(type_names tn) -> TypeRef { } fn T_tag(type_names tn, uint size) -> TypeRef { - auto s = "tag_" + _uint.to_str(size, 10u); + auto s = "tag_" + UInt.to_str(size, 10u); if (tn.name_has_type(s)) { ret tn.get_type(s); } @@ -559,7 +559,7 @@ fn T_opaque_tag_ptr(type_names tn) -> TypeRef { } fn T_captured_tydescs(type_names tn, uint n) -> TypeRef { - ret T_struct(_vec.init_elt[TypeRef](T_ptr(T_tydesc(tn)), n)); + ret T_struct(Vec.init_elt[TypeRef](T_ptr(T_tydesc(tn)), n)); } fn T_obj_ptr(type_names tn, uint n_captured_tydescs) -> TypeRef { @@ -623,7 +623,7 @@ fn type_of_explicit_args(@crate_ctxt cx, vec[ty.arg] inputs) -> vec[TypeRef] { fn type_of_fn_full(@crate_ctxt cx, ast.proto proto, - option.t[TypeRef] obj_self, + Option.t[TypeRef] obj_self, vec[ty.arg] inputs, ty.t output, uint ty_param_count) -> TypeRef { @@ -811,7 +811,7 @@ fn type_of_inner(@crate_ctxt cx, ty.t t) -> TypeRef { } assert (llty as int != 0); - llvm.LLVMAddTypeName(cx.llmod, _str.buf(ty.ty_to_short_str(cx.tcx, t)), + llvm.LLVMAddTypeName(cx.llmod, Str.buf(ty.ty_to_short_str(cx.tcx, t)), llty); cx.lltypes.insert(t, llty); ret llty; @@ -872,7 +872,7 @@ fn sanitize(str s) -> str { c != (' ' as u8) && c != ('\t' as u8) && c != (';' as u8)) { auto v = vec(c); - result += _str.from_bytes(v); + result += Str.from_bytes(v); } } } @@ -894,15 +894,15 @@ fn C_integral(int i, TypeRef t) -> ValueRef { // // ret llvm.LLVMConstInt(T_int(), t as LLVM.ULongLong, False); // - ret llvm.LLVMConstIntOfString(t, _str.buf(istr(i)), 10); + ret llvm.LLVMConstIntOfString(t, Str.buf(istr(i)), 10); } fn C_float(str s) -> ValueRef { - ret llvm.LLVMConstRealOfString(T_float(), _str.buf(s)); + ret llvm.LLVMConstRealOfString(T_float(), Str.buf(s)); } fn C_floating(str s, TypeRef t) -> ValueRef { - ret llvm.LLVMConstRealOfString(t, _str.buf(s)); + ret llvm.LLVMConstRealOfString(t, Str.buf(s)); } fn C_nil() -> ValueRef { @@ -929,9 +929,9 @@ fn C_i8(uint i) -> ValueRef { // This is a 'c-like' raw string, which differs from // our boxed-and-length-annotated strings. fn C_cstr(@crate_ctxt cx, str s) -> ValueRef { - auto sc = llvm.LLVMConstString(_str.buf(s), _str.byte_len(s), False); + auto sc = llvm.LLVMConstString(Str.buf(s), Str.byte_len(s), False); auto g = llvm.LLVMAddGlobal(cx.llmod, val_ty(sc), - _str.buf(cx.names.next("str"))); + Str.buf(cx.names.next("str"))); llvm.LLVMSetInitializer(g, sc); llvm.LLVMSetGlobalConstant(g, True); llvm.LLVMSetLinkage(g, lib.llvm.LLVMInternalLinkage @@ -941,15 +941,15 @@ fn C_cstr(@crate_ctxt cx, str s) -> ValueRef { // A rust boxed-and-length-annotated string. fn C_str(@crate_ctxt cx, str s) -> ValueRef { - auto len = _str.byte_len(s); + auto len = Str.byte_len(s); auto box = C_struct(vec(C_int(abi.const_refcount as int), C_int(len + 1u as int), // 'alloc' C_int(len + 1u as int), // 'fill' C_int(0), // 'pad' - llvm.LLVMConstString(_str.buf(s), + llvm.LLVMConstString(Str.buf(s), len, False))); auto g = llvm.LLVMAddGlobal(cx.llmod, val_ty(box), - _str.buf(cx.names.next("str"))); + Str.buf(cx.names.next("str"))); llvm.LLVMSetInitializer(g, box); llvm.LLVMSetGlobalConstant(g, True); llvm.LLVMSetLinkage(g, lib.llvm.LLVMInternalLinkage @@ -964,24 +964,24 @@ fn C_zero_byte_arr(uint size) -> ValueRef { elts += vec(C_integral(0, T_i8())); i += 1u; } - ret llvm.LLVMConstArray(T_i8(), _vec.buf[ValueRef](elts), - _vec.len[ValueRef](elts)); + ret llvm.LLVMConstArray(T_i8(), Vec.buf[ValueRef](elts), + Vec.len[ValueRef](elts)); } fn C_struct(vec[ValueRef] elts) -> ValueRef { - ret llvm.LLVMConstStruct(_vec.buf[ValueRef](elts), - _vec.len[ValueRef](elts), + ret llvm.LLVMConstStruct(Vec.buf[ValueRef](elts), + Vec.len[ValueRef](elts), False); } fn C_array(TypeRef ty, vec[ValueRef] elts) -> ValueRef { - ret llvm.LLVMConstArray(ty, _vec.buf[ValueRef](elts), - _vec.len[ValueRef](elts)); + ret llvm.LLVMConstArray(ty, Vec.buf[ValueRef](elts), + Vec.len[ValueRef](elts)); } fn decl_fn(ModuleRef llmod, str name, uint cc, TypeRef llty) -> ValueRef { let ValueRef llfn = - llvm.LLVMAddFunction(llmod, _str.buf(name), llty); + llvm.LLVMAddFunction(llmod, Str.buf(name), llty); llvm.LLVMSetFunctionCallConv(llfn, cc); ret llfn; } @@ -1026,7 +1026,7 @@ fn decl_native_glue(ModuleRef llmod, type_names tn, args += vec(T_int()); // taskptr, will not be passed } - args += _vec.init_elt[TypeRef](T_int(), n as uint); + args += Vec.init_elt[TypeRef](T_int(), n as uint); ret decl_fastcall_fn(llmod, s, T_fn(args, T_int())); } @@ -1047,14 +1047,14 @@ fn get_extern_const(&hashmap[str, ValueRef] externs, if (externs.contains_key(name)) { ret externs.get(name); } - auto c = llvm.LLVMAddGlobal(llmod, ty, _str.buf(name)); + auto c = llvm.LLVMAddGlobal(llmod, ty, Str.buf(name)); externs.insert(name, c); ret c; } fn get_simple_extern_fn(&hashmap[str, ValueRef] externs, ModuleRef llmod, str name, int n_args) -> ValueRef { - auto inputs = _vec.init_elt[TypeRef](T_int(), n_args as uint); + auto inputs = Vec.init_elt[TypeRef](T_int(), n_args as uint); auto output = T_int(); auto t = T_fn(inputs, output); ret get_extern_fn(externs, llmod, name, lib.llvm.LLVMCCallConv, t); @@ -1075,7 +1075,7 @@ fn trans_native_call(builder b, @glue_fns glues, ValueRef lltaskptr, &hashmap[str, ValueRef] externs, type_names tn, ModuleRef llmod, str name, bool pass_task, vec[ValueRef] args) -> ValueRef { - let int n = (_vec.len[ValueRef](args) as int); + let int n = (Vec.len[ValueRef](args) as int); let ValueRef llnative = get_simple_extern_fn(externs, llmod, name, n); llnative = llvm.LLVMConstPointerCast(llnative, T_int()); @@ -1395,7 +1395,7 @@ fn GEP_tup_like(@block_ctxt cx, ty.t t, fn split_type(@crate_ctxt ccx, ty.t t, vec[int] ixs, uint n) -> rec(vec[ty.t] prefix, ty.t target) { - let uint len = _vec.len[int](ixs); + let uint len = Vec.len[int](ixs); // We don't support 0-index or 1-index GEPs. The former is nonsense // and the latter would only be meaningful if we supported non-0 @@ -1417,7 +1417,7 @@ fn GEP_tup_like(@block_ctxt cx, ty.t t, let vec[ty.t] prefix = vec(); let int i = 0; while (i < ix) { - _vec.push[ty.t](prefix, + Vec.push[ty.t](prefix, ty.get_element_type(ccx.tcx, t, i as uint)); i += 1 ; } @@ -1617,8 +1617,8 @@ fn mk_derived_tydesc(@block_ctxt cx, ty.t t, bool escapes) -> result { let uint n_params = ty.count_ty_params(cx.fcx.lcx.ccx.tcx, t); auto tys = linearize_ty_params(cx, t); - assert (n_params == _vec.len[uint](tys._0)); - assert (n_params == _vec.len[ValueRef](tys._1)); + assert (n_params == Vec.len[uint](tys._0)); + assert (n_params == Vec.len[ValueRef](tys._1)); auto root = get_static_tydesc(cx, t, tys._0).tydesc; @@ -1746,7 +1746,7 @@ fn declare_tydesc(@local_ctxt cx, ty.t t) -> @tydesc_info { auto name = mangle_name_by_type_only(ccx, t, "tydesc"); auto gvar = llvm.LLVMAddGlobal(ccx.llmod, T_tydesc(ccx.tn), - _str.buf(name)); + Str.buf(name)); auto tydesc = C_struct(vec(C_null(T_ptr(T_ptr(T_tydesc(ccx.tn)))), llsize, llalign, @@ -1827,20 +1827,20 @@ fn make_generic_glue(@local_ctxt cx, llty = T_ptr(type_of(cx.ccx, t)); } - auto ty_param_count = _vec.len[uint](ty_params); + auto ty_param_count = Vec.len[uint](ty_params); auto lltyparams = llvm.LLVMGetParam(llfn, 3u); - auto lltydescs = _vec.empty_mut[ValueRef](); + auto lltydescs = Vec.empty_mut[ValueRef](); auto p = 0u; while (p < ty_param_count) { auto llparam = bcx.build.GEP(lltyparams, vec(C_int(p as int))); llparam = bcx.build.Load(llparam); - _vec.grow_set[ValueRef](lltydescs, ty_params.(p), 0 as ValueRef, + Vec.grow_set[ValueRef](lltydescs, ty_params.(p), 0 as ValueRef, llparam); p += 1u; } - bcx.fcx.lltydescs = _vec.freeze[ValueRef](lltydescs); + bcx.fcx.lltydescs = Vec.freeze[ValueRef](lltydescs); auto llrawptr0 = llvm.LLVMGetParam(llfn, 4u); auto llval0 = bcx.build.BitCast(llrawptr0, llty); @@ -2157,7 +2157,7 @@ fn make_cmp_glue(@block_ctxt cx, */ auto flag = alloca(scx, T_i1()); - llvm.LLVMSetValueName(flag, _str.buf("flag")); + llvm.LLVMSetValueName(flag, Str.buf("flag")); auto r; if (ty.type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) { @@ -2378,7 +2378,7 @@ fn tag_variants(@crate_ctxt cx, ast.def_id id) -> vec[variant_info] { for (ast.variant variant in variants) { auto ctor_ty = node_ann_type(cx, variant.node.ann); let vec[ty.t] arg_tys = vec(); - if (_vec.len[ast.variant_arg](variant.node.args) > 0u) { + if (Vec.len[ast.variant_arg](variant.node.args) > 0u) { for (ty.arg a in ty.ty_fn_args(cx.tcx, ctor_ty)) { arg_tys += vec(a.ty); } @@ -2399,7 +2399,7 @@ fn tag_variant_with_id(@crate_ctxt cx, auto variants = tag_variants(cx, tag_id); auto i = 0u; - while (i < _vec.len[variant_info](variants)) { + while (i < Vec.len[variant_info](variants)) { auto variant = variants.(i); if (common.def_eq(variant.id, variant_id)) { ret variant; @@ -2495,7 +2495,7 @@ fn iter_structural_ty_full(@block_ctxt cx, } case (ty.ty_tag(?tid, ?tps)) { auto variants = tag_variants(cx.fcx.lcx.ccx, tid); - auto n_variants = _vec.len[variant_info](variants); + auto n_variants = Vec.len[variant_info](variants); // Cast the tags to types we can GEP into. auto lltagty = T_opaque_tag_ptr(cx.fcx.lcx.ccx.tn); @@ -2532,10 +2532,10 @@ fn iter_structural_ty_full(@block_ctxt cx, for (variant_info variant in variants) { auto variant_cx = new_sub_block_ctxt(bcx, "tag-iter-variant-" + - _uint.to_str(i, 10u)); + UInt.to_str(i, 10u)); llvm.LLVMAddCase(llswitch, C_int(i as int), variant_cx.llbb); - if (_vec.len[ty.t](variant.args) > 0u) { + if (Vec.len[ty.t](variant.args) > 0u) { // N-ary variant. auto fn_ty = variant.ctor_ty; alt (ty.struct(bcx.fcx.lcx.ccx.tcx, fn_ty)) { @@ -3386,12 +3386,12 @@ fn join_results(@block_ctxt parent_cx, } } - alt (_vec.len[result](live)) { + alt (Vec.len[result](live)) { case (0u) { // No incoming edges are live, so we're in dead-code-land. // Arbitrarily pick the first dead edge, since the caller // is just going to propagate it outward. - assert (_vec.len[result](ins) >= 1u); + assert (Vec.len[result](ins) >= 1u); ret ins.(0); } @@ -3408,7 +3408,7 @@ fn join_results(@block_ctxt parent_cx, } fn trans_if(@block_ctxt cx, @ast.expr cond, - &ast.block thn, &option.t[@ast.expr] els) -> result { + &ast.block thn, &Option.t[@ast.expr] els) -> result { auto cond_res = trans_expr(cx, cond); @@ -3472,7 +3472,7 @@ fn trans_for(@block_ctxt cx, auto next_cx = new_sub_block_ctxt(cx, "next"); auto scope_cx = - new_loop_scope_block_ctxt(cx, option.some[@block_ctxt](next_cx), + new_loop_scope_block_ctxt(cx, Option.some[@block_ctxt](next_cx), outer_next_cx, "for loop scope"); cx.build.Br(scope_cx.llbb); @@ -3517,15 +3517,15 @@ fn collect_upvars(@block_ctxt cx, &ast.block bloc, &ast.def_id initial_decl) fn walk_expr(env e, @ast.expr expr) { alt (expr.node) { case (ast.expr_path(?path, ?d, _)) { - alt (option.get[ast.def](d)) { + alt (Option.get[ast.def](d)) { case (ast.def_arg(?did)) { - _vec.push[ast.def_id](e.refs, did); + Vec.push[ast.def_id](e.refs, did); } case (ast.def_local(?did)) { - _vec.push[ast.def_id](e.refs, did); + Vec.push[ast.def_id](e.refs, did); } case (ast.def_upvar(?did)) { - _vec.push[ast.def_id](e.refs, did); + Vec.push[ast.def_id](e.refs, did); } case (_) {} } @@ -3606,7 +3606,7 @@ fn trans_for_each(@block_ctxt cx, } auto upvars = collect_upvars(cx, body, decl_id); - auto upvar_count = _vec.len[ast.def_id](upvars); + auto upvar_count = Vec.len[ast.def_id](upvars); auto llbindingsptr; if (upvar_count > 0u) { @@ -3645,7 +3645,7 @@ fn trans_for_each(@block_ctxt cx, } // Create an environment and populate it with the bindings. - auto tydesc_count = _vec.len[ValueRef](cx.fcx.lltydescs); + auto tydesc_count = Vec.len[ValueRef](cx.fcx.lltydescs); auto llenvptrty = T_closure_ptr(lcx.ccx.tn, T_ptr(T_nil()), val_ty(llbindingsptr), tydesc_count); auto llenvptr = alloca(cx, llvm.LLVMGetElementType(llenvptrty)); @@ -3776,7 +3776,7 @@ fn trans_while(@block_ctxt cx, @ast.expr cond, auto cond_cx = new_scope_block_ctxt(cx, "while cond"); auto next_cx = new_sub_block_ctxt(cx, "next"); - auto body_cx = new_loop_scope_block_ctxt(cx, option.none[@block_ctxt], + auto body_cx = new_loop_scope_block_ctxt(cx, Option.none[@block_ctxt], next_cx, "while loop body"); auto body_res = trans_block(body_cx, body); @@ -3795,7 +3795,7 @@ fn trans_do_while(@block_ctxt cx, &ast.block body, @ast.expr cond) -> result { auto next_cx = new_sub_block_ctxt(cx, "next"); - auto body_cx = new_loop_scope_block_ctxt(cx, option.none[@block_ctxt], + auto body_cx = new_loop_scope_block_ctxt(cx, Option.none[@block_ctxt], next_cx, "do-while loop body"); auto body_res = trans_block(body_cx, body); @@ -3834,7 +3834,7 @@ fn trans_pat_match(@block_ctxt cx, @ast.pat pat, ValueRef llval, vec(C_int(0), C_int(0))); auto lldiscrim = cx.build.Load(lldiscrimptr); - auto vdef = option.get[ast.variant_def](vdef_opt); + auto vdef = Option.get[ast.variant_def](vdef_opt); auto variant_id = vdef._1; auto variant_tag = 0; @@ -3857,7 +3857,7 @@ fn trans_pat_match(@block_ctxt cx, @ast.pat pat, ValueRef llval, auto ty_params = node_ann_ty_params(ann); - if (_vec.len[@ast.pat](subpats) > 0u) { + if (Vec.len[@ast.pat](subpats) > 0u) { auto llblobptr = matched_cx.build.GEP(lltagptr, vec(C_int(0), C_int(1))); auto i = 0; @@ -3899,7 +3899,7 @@ fn trans_pat_binding(@block_ctxt cx, @ast.pat pat, auto rslt = alloc_ty(cx, t); auto dst = rslt.val; auto bcx = rslt.bcx; - llvm.LLVMSetValueName(dst, _str.buf(id)); + llvm.LLVMSetValueName(dst, Str.buf(id)); bcx.fcx.lllocals.insert(def_id, dst); bcx.cleanups += vec(clean(bind drop_slot(_, dst, t))); @@ -3907,10 +3907,10 @@ fn trans_pat_binding(@block_ctxt cx, @ast.pat pat, } } case (ast.pat_tag(_, ?subpats, ?vdef_opt, ?ann)) { - if (_vec.len[@ast.pat](subpats) == 0u) { ret res(cx, llval); } + if (Vec.len[@ast.pat](subpats) == 0u) { ret res(cx, llval); } // Get the appropriate variant for this tag. - auto vdef = option.get[ast.variant_def](vdef_opt); + auto vdef = Option.get[ast.variant_def](vdef_opt); auto lltagptr = cx.build.PointerCast(llval, T_opaque_tag_ptr(cx.fcx.lcx.ccx.tn)); @@ -3982,9 +3982,9 @@ type generic_info = rec(ty.t item_type, type lval_result = rec(result res, bool is_mem, - option.t[generic_info] generic, - option.t[ValueRef] llobj, - option.t[ty.t] method_ty); + Option.t[generic_info] generic, + Option.t[ValueRef] llobj, + Option.t[ty.t] method_ty); fn lval_mem(@block_ctxt cx, ValueRef val) -> lval_result { ret rec(res=res(cx, val), @@ -4035,18 +4035,18 @@ fn lval_generic_fn(@block_ctxt cx, } case (ast.ann_type(?monoty_, ?tps, _)) { monoty = monoty_; - tys = option.get[vec[ty.t]](tps); + tys = Option.get[vec[ty.t]](tps); } } - if (_vec.len[ty.t](tys) != 0u) { + if (Vec.len[ty.t](tys) != 0u) { auto bcx = lv.res.bcx; let vec[ValueRef] tydescs = vec(); for (ty.t t in tys) { // TODO: Doesn't always escape. auto td = get_tydesc(bcx, t, true); bcx = td.bcx; - _vec.push[ValueRef](tydescs, td.val); + Vec.push[ValueRef](tydescs, td.val); } auto gen = rec( item_type = tpt._1, tydescs = tydescs ); @@ -4065,7 +4065,7 @@ fn lookup_discriminant(@local_ctxt lcx, ast.def_id tid, ast.def_id vid) assert (lcx.ccx.sess.get_targ_crate_num() != vid._0); auto sym = creader.get_symbol(lcx.ccx.sess, vid); auto gvar = llvm.LLVMAddGlobal(lcx.ccx.llmod, T_int(), - _str.buf(sym)); + Str.buf(sym)); llvm.LLVMSetLinkage(gvar, lib.llvm.LLVMExternalLinkage as llvm.Linkage); llvm.LLVMSetGlobalConstant(gvar, True); @@ -4076,7 +4076,7 @@ fn lookup_discriminant(@local_ctxt lcx, ast.def_id tid, ast.def_id vid) } } -fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt, +fn trans_path(@block_ctxt cx, &ast.path p, &Option.t[ast.def] dopt, &ast.ann ann) -> lval_result { alt (dopt) { case (some[ast.def](?def)) { @@ -4246,10 +4246,10 @@ fn trans_index(@block_ctxt cx, &ast.span sp, @ast.expr base, auto unit_ty = node_ann_type(cx.fcx.lcx.ccx, ann); auto unit_sz = size_of(bcx, unit_ty); bcx = unit_sz.bcx; - llvm.LLVMSetValueName(unit_sz.val, _str.buf("unit_sz")); + llvm.LLVMSetValueName(unit_sz.val, Str.buf("unit_sz")); auto scaled_ix = bcx.build.Mul(ix_val, unit_sz.val); - llvm.LLVMSetValueName(scaled_ix, _str.buf("scaled_ix")); + llvm.LLVMSetValueName(scaled_ix, Str.buf("scaled_ix")); auto lim = bcx.build.GEP(v, vec(C_int(0), C_int(abi.vec_elt_fill))); lim = bcx.build.Load(lim); @@ -4369,7 +4369,7 @@ fn trans_cast(@block_ctxt cx, @ast.expr e, &ast.ann ann) -> result { fn trans_bind_thunk(@local_ctxt cx, ty.t incoming_fty, ty.t outgoing_fty, - vec[option.t[@ast.expr]] args, + vec[Option.t[@ast.expr]] args, ty.t closure_ty, vec[ty.t] bound_tys, uint ty_param_count) -> ValueRef { @@ -4433,7 +4433,7 @@ fn trans_bind_thunk(@local_ctxt cx, let vec[TypeRef] llout_arg_tys = type_of_explicit_args(cx.ccx, outgoing_args); - for (option.t[@ast.expr] arg in args) { + for (Option.t[@ast.expr] arg in args) { auto out_arg = outgoing_args.(outgoing_arg_index); auto llout_arg_ty = llout_arg_tys.(outgoing_arg_index); @@ -4516,7 +4516,7 @@ fn trans_bind_thunk(@local_ctxt cx, } fn trans_bind(@block_ctxt cx, @ast.expr f, - vec[option.t[@ast.expr]] args, + vec[Option.t[@ast.expr]] args, &ast.ann ann) -> result { auto f_res = trans_lval(cx, f); if (f_res.is_mem) { @@ -4524,12 +4524,12 @@ fn trans_bind(@block_ctxt cx, @ast.expr f, } else { let vec[@ast.expr] bound = vec(); - for (option.t[@ast.expr] argopt in args) { + for (Option.t[@ast.expr] argopt in args) { alt (argopt) { case (none[@ast.expr]) { } case (some[@ast.expr](?e)) { - _vec.push[@ast.expr](bound, e); + Vec.push[@ast.expr](bound, e); } } } @@ -4547,9 +4547,9 @@ fn trans_bind(@block_ctxt cx, @ast.expr f, lltydescs = ginfo.tydescs; } } - auto ty_param_count = _vec.len[ValueRef](lltydescs); + auto ty_param_count = Vec.len[ValueRef](lltydescs); - if (_vec.len[@ast.expr](bound) == 0u && ty_param_count == 0u) { + if (Vec.len[@ast.expr](bound) == 0u && ty_param_count == 0u) { // Trivial 'binding': just return the static pair-ptr. ret f_res.res; } else { @@ -4565,8 +4565,8 @@ fn trans_bind(@block_ctxt cx, @ast.expr f, auto arg = trans_expr(bcx, e); bcx = arg.bcx; - _vec.push[ValueRef](bound_vals, arg.val); - _vec.push[ty.t](bound_tys, + Vec.push[ValueRef](bound_vals, arg.val); + Vec.push[ty.t](bound_tys, ty.expr_ty(cx.fcx.lcx.ccx.tcx, e)); i += 1u; @@ -4582,7 +4582,7 @@ fn trans_bind(@block_ctxt cx, @ast.expr f, let ty.t tydesc_ty = ty.mk_type(cx.fcx.lcx.ccx.tcx); let vec[ty.t] captured_tys = - _vec.init_elt[ty.t](tydesc_ty, ty_param_count); + Vec.init_elt[ty.t](tydesc_ty, ty_param_count); let vec[ty.t] closure_tys = vec(tydesc_ty, @@ -4778,9 +4778,9 @@ fn trans_arg_expr(@block_ctxt cx, fn trans_args(@block_ctxt cx, ValueRef llenv, - option.t[ValueRef] llobj, - option.t[generic_info] gen, - option.t[ValueRef] lliterbody, + Option.t[ValueRef] llobj, + Option.t[generic_info] gen, + Option.t[ValueRef] lliterbody, &vec[@ast.expr] es, ty.t fn_ty) -> tup(@block_ctxt, vec[ValueRef], ValueRef) { @@ -4869,7 +4869,7 @@ fn trans_args(@block_ctxt cx, } fn trans_call(@block_ctxt cx, @ast.expr f, - option.t[ValueRef] lliterbody, + Option.t[ValueRef] lliterbody, vec[@ast.expr] args, &ast.ann ann) -> result { @@ -4997,7 +4997,7 @@ fn trans_vec(@block_ctxt cx, vec[@ast.expr] args, auto bcx = cx; auto unit_sz = size_of(bcx, unit_ty); bcx = unit_sz.bcx; - auto data_sz = bcx.build.Mul(C_int(_vec.len[@ast.expr](args) as int), + auto data_sz = bcx.build.Mul(C_int(Vec.len[@ast.expr](args) as int), unit_sz.val); // FIXME: pass tydesc properly. @@ -5015,8 +5015,8 @@ fn trans_vec(@block_ctxt cx, vec[@ast.expr] args, auto pseudo_tup_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx, - _vec.init_elt[ty.t](unit_ty, - _vec.len[@ast.expr](args))); + Vec.init_elt[ty.t](unit_ty, + Vec.len[@ast.expr](args))); let int i = 0; for (@ast.expr e in args) { @@ -5056,7 +5056,7 @@ fn trans_vec(@block_ctxt cx, vec[@ast.expr] args, } fn trans_rec(@block_ctxt cx, vec[ast.field] fields, - option.t[@ast.expr] base, &ast.ann ann) -> result { + Option.t[@ast.expr] base, &ast.ann ann) -> result { auto bcx = cx; auto t = node_ann_type(bcx.fcx.lcx.ccx, ann); @@ -5093,7 +5093,7 @@ fn trans_rec(@block_ctxt cx, vec[ast.field] fields, auto src_res = res(bcx, C_nil()); for (ast.field f in fields) { - if (_str.eq(f.ident, tf.ident)) { + if (Str.eq(f.ident, tf.ident)) { expr_provided = true; src_res = trans_expr(bcx, f.expr); } @@ -5326,13 +5326,13 @@ fn load_if_immediate(@block_ctxt cx, ValueRef v, ty.t t) -> ValueRef { fn trans_log(int lvl, @block_ctxt cx, @ast.expr e) -> result { auto lcx = cx.fcx.lcx; - auto modname = _str.connect(lcx.module_path, "."); + auto modname = Str.connect(lcx.module_path, "."); auto global; if (lcx.ccx.module_data.contains_key(modname)) { global = lcx.ccx.module_data.get(modname); } else { global = llvm.LLVMAddGlobal(lcx.ccx.llmod, T_int(), - _str.buf("_rust_mod_log_" + modname)); + Str.buf("_rust_mod_log_" + modname)); llvm.LLVMSetGlobalConstant(global, False); llvm.LLVMSetInitializer(global, C_null(T_int())); llvm.LLVMSetLinkage(global, lib.llvm.LLVMInternalLinkage @@ -5418,7 +5418,7 @@ fn trans_check_expr(@block_ctxt cx, @ast.expr e) -> result { ret res(next_cx, C_nil()); } -fn trans_fail(@block_ctxt cx, option.t[common.span] sp_opt, str fail_str) +fn trans_fail(@block_ctxt cx, Option.t[common.span] sp_opt, str fail_str) -> result { auto V_fail_str = p2i(C_cstr(cx.fcx.lcx.ccx, fail_str)); @@ -5442,7 +5442,7 @@ fn trans_fail(@block_ctxt cx, option.t[common.span] sp_opt, str fail_str) ret res(sub.bcx, C_nil()); } -fn trans_put(@block_ctxt cx, &option.t[@ast.expr] e) -> result { +fn trans_put(@block_ctxt cx, &Option.t[@ast.expr] e) -> result { auto llcallee = C_nil(); auto llenv = C_nil(); @@ -5490,7 +5490,7 @@ fn trans_break_cont(@block_ctxt cx, bool to_end) -> result { bcx.build.Br(_break.llbb); } else { alt (_cont) { - case (option.some[@block_ctxt](?_cont)) { + case (Option.some[@block_ctxt](?_cont)) { bcx.build.Br(_cont.llbb); } case (_) { @@ -5519,7 +5519,7 @@ fn trans_cont(@block_ctxt cx) -> result { } -fn trans_ret(@block_ctxt cx, &option.t[@ast.expr] e) -> result { +fn trans_ret(@block_ctxt cx, &Option.t[@ast.expr] e) -> result { auto bcx = cx; auto val = C_nil(); @@ -5765,7 +5765,7 @@ fn new_block_ctxt(@fn_ctxt cx, block_parent parent, let vec[cleanup] cleanups = vec(); let BasicBlockRef llbb = llvm.LLVMAppendBasicBlock(cx.llfn, - _str.buf(cx.lcx.ccx.names.next(name))); + Str.buf(cx.lcx.ccx.names.next(name))); ret @rec(llbb=llbb, build=new_builder(llbb), @@ -5786,7 +5786,7 @@ fn new_scope_block_ctxt(@block_ctxt bcx, str n) -> @block_ctxt { ret new_block_ctxt(bcx.fcx, parent_some(bcx), SCOPE_BLOCK, n); } -fn new_loop_scope_block_ctxt(@block_ctxt bcx, option.t[@block_ctxt] _cont, +fn new_loop_scope_block_ctxt(@block_ctxt bcx, Option.t[@block_ctxt] _cont, @block_ctxt _break, str n) -> @block_ctxt { ret new_block_ctxt(bcx.fcx, parent_some(bcx), LOOP_SCOPE_BLOCK(_cont, _break), n); @@ -5803,10 +5803,10 @@ fn trans_block_cleanups(@block_ctxt cx, auto bcx = cx; if (cleanup_cx.kind == NON_SCOPE_BLOCK) { - assert (_vec.len[cleanup](cleanup_cx.cleanups) == 0u); + assert (Vec.len[cleanup](cleanup_cx.cleanups) == 0u); } - auto i = _vec.len[cleanup](cleanup_cx.cleanups); + auto i = Vec.len[cleanup](cleanup_cx.cleanups); while (i > 0u) { i -= 1u; auto c = cleanup_cx.cleanups.(i); @@ -5983,7 +5983,7 @@ fn new_fn_ctxt(@local_ctxt cx, let hashmap[ast.def_id, ValueRef] llupvars = new_def_hash[ValueRef](); let BasicBlockRef llallocas = - llvm.LLVMAppendBasicBlock(llfndecl, _str.buf("allocas")); + llvm.LLVMAppendBasicBlock(llfndecl, Str.buf("allocas")); ret @rec(llfn=llfndecl, lltaskptr=lltaskptr, @@ -5996,7 +5996,7 @@ fn new_fn_ctxt(@local_ctxt cx, llobjfields=llobjfields, lllocals=lllocals, llupvars=llupvars, - mutable lltydescs=_vec.empty[ValueRef](), + mutable lltydescs=Vec.empty[ValueRef](), lcx=cx); } @@ -6009,7 +6009,7 @@ fn new_fn_ctxt(@local_ctxt cx, fn create_llargs_for_fn_args(&@fn_ctxt cx, ast.proto proto, - option.t[tup(TypeRef, ty.t)] ty_self, + Option.t[tup(TypeRef, ty.t)] ty_self, ty.t ret_ty, &vec[ast.arg] args, &vec[ast.ty_param] ty_params) { @@ -6052,7 +6052,7 @@ fn create_llargs_for_fn_args(&@fn_ctxt cx, // were passed and whatnot. Apparently mem2reg will mop up. fn copy_any_self_to_alloca(@fn_ctxt fcx, - option.t[tup(TypeRef, ty.t)] ty_self) { + Option.t[tup(TypeRef, ty.t)] ty_self) { auto bcx = llallocas_block_ctxt(fcx); @@ -6152,7 +6152,7 @@ fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) { // its magic. auto fields_tup_ty = ty.mk_imm_tup(fcx.lcx.ccx.tcx, field_tys); - auto n_typarams = _vec.len[ast.ty_param](bcx.fcx.lcx.obj_typarams); + auto n_typarams = Vec.len[ast.ty_param](bcx.fcx.lcx.obj_typarams); let TypeRef llobj_box_ty = T_obj_ptr(bcx.fcx.lcx.ccx.tn, n_typarams); auto box_cell = @@ -6209,7 +6209,7 @@ fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) { } fn trans_fn(@local_ctxt cx, &ast._fn f, ast.def_id fid, - option.t[tup(TypeRef, ty.t)] ty_self, + Option.t[tup(TypeRef, ty.t)] ty_self, &vec[ast.ty_param] ty_params, &ast.ann ann) { auto llfndecl = cx.ccx.item_ids.get(fid); @@ -6264,10 +6264,10 @@ fn trans_vtbl(@local_ctxt cx, let vec[ValueRef] methods = vec(dtor); fn meth_lteq(&@ast.method a, &@ast.method b) -> bool { - ret _str.lteq(a.node.ident, b.node.ident); + ret Str.lteq(a.node.ident, b.node.ident); } - auto meths = std.sort.merge_sort[@ast.method](bind meth_lteq(_,_), + auto meths = std.Sort.merge_sort[@ast.method](bind meth_lteq(_,_), ob.methods); for (@ast.method m in meths) { @@ -6278,7 +6278,7 @@ fn trans_vtbl(@local_ctxt cx, llfnty = type_of_fn_full(cx.ccx, proto, some[TypeRef](llself_ty), inputs, output, - _vec.len[ast.ty_param](ty_params)); + Vec.len[ast.ty_param](ty_params)); } } @@ -6297,7 +6297,7 @@ fn trans_vtbl(@local_ctxt cx, auto vtbl = C_struct(methods); auto vtbl_name = mangle_name_by_seq(cx.ccx, cx.path, "vtbl"); auto gvar = llvm.LLVMAddGlobal(cx.ccx.llmod, val_ty(vtbl), - _str.buf(vtbl_name)); + Str.buf(vtbl_name)); llvm.LLVMSetInitializer(gvar, vtbl); llvm.LLVMSetGlobalConstant(gvar, True); llvm.LLVMSetLinkage(gvar, lib.llvm.LLVMInternalLinkage @@ -6368,22 +6368,22 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid, // FIXME we should probably also allocate a box for empty objs that have a // dtor, since otherwise they are never dropped, and the dtor never runs - if (_vec.len[ast.ty_param](ty_params) == 0u && - _vec.len[ty.arg](arg_tys) == 0u) { + if (Vec.len[ast.ty_param](ty_params) == 0u && + Vec.len[ty.arg](arg_tys) == 0u) { // Store null into pair, if no args or typarams. bcx.build.Store(C_null(llbox_ty), pair_box); } else { // Malloc a box for the body and copy args in. let vec[ty.t] obj_fields = vec(); for (ty.arg a in arg_tys) { - _vec.push[ty.t](obj_fields, a.ty); + Vec.push[ty.t](obj_fields, a.ty); } // Synthesize an obj body type. auto tydesc_ty = ty.mk_type(ccx.tcx); let vec[ty.t] tps = vec(); for (ast.ty_param tp in ty_params) { - _vec.push[ty.t](tps, tydesc_ty); + Vec.push[ty.t](tps, tydesc_ty); } let ty.t typarams_ty = ty.mk_imm_tup(ccx.tcx, tps); @@ -6467,7 +6467,7 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid, fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id, &ast.variant variant, int index, &vec[ast.ty_param] ty_params) { - if (_vec.len[ast.variant_arg](variant.node.args) == 0u) { + if (Vec.len[ast.variant_arg](variant.node.args) == 0u) { ret; // nullary constructors are just constants } @@ -6477,7 +6477,7 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id, for (ast.variant_arg varg in variant.node.args) { fn_args += vec(rec(mode=ast.alias, ty=varg.ty, - ident="arg" + _uint.to_str(i, 10u), + ident="arg" + UInt.to_str(i, 10u), id=varg.id)); } @@ -6617,7 +6617,7 @@ fn get_pair_fn_ty(TypeRef llpairty) -> TypeRef { // Bit of a kludge: pick the fn typeref out of the pair. let vec[TypeRef] pair_tys = vec(T_nil(), T_nil()); llvm.LLVMGetStructElementTypes(llpairty, - _vec.buf[TypeRef](pair_tys)); + Vec.buf[TypeRef](pair_tys)); ret llvm.LLVMGetElementType(pair_tys.(0)); } @@ -6633,7 +6633,7 @@ fn decl_fn_and_pair(@crate_ctxt ccx, alt (ty.struct(ccx.tcx, node_ann_type(ccx, ann))) { case (ty.ty_fn(?proto, ?inputs, ?output)) { llfty = type_of_fn(ccx, proto, inputs, output, - _vec.len[ast.ty_param](ty_params)); + Vec.len[ast.ty_param](ty_params)); llpairty = T_fn_pair(ccx.tn, llfty); } case (_) { @@ -6655,7 +6655,7 @@ fn decl_fn_and_pair(@crate_ctxt ccx, fn register_fn_pair(@crate_ctxt cx, str ps, TypeRef llpairty, ValueRef llfn, ast.def_id id) { let ValueRef gvar = llvm.LLVMAddGlobal(cx.llmod, llpairty, - _str.buf(ps)); + Str.buf(ps)); auto pair = C_struct(vec(llfn, C_null(T_opaque_closure_ptr(cx.tn)))); @@ -6681,7 +6681,7 @@ fn native_fn_ty_param_count(@crate_ctxt cx, &ast.def_id id) -> uint { fail; } case (ast.native_item_fn(_, _, _, ?tps, _, _)) { - count = _vec.len[ast.ty_param](tps); + count = Vec.len[ast.ty_param](tps); } } ret count; @@ -6768,7 +6768,7 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx, if (pass_task) { call_args += vec(lltaskptr); } auto arg_n = 3u; - for each (uint i in _uint.range(0u, num_ty_param)) { + for each (uint i in UInt.range(0u, num_ty_param)) { auto llarg = llvm.LLVMGetParam(fcx.llfn, arg_n); fcx.lltydescs += vec(llarg); assert (llarg as int != 0); @@ -6900,13 +6900,13 @@ fn new_walk_ctxt() -> @walk_ctxt { fn enter_item(@walk_ctxt cx, @ast.item item) { alt (item.node) { case (ast.item_fn(?name, _, _, _, _)) { - _vec.push[str](cx.path, name); + Vec.push[str](cx.path, name); } case (ast.item_obj(?name, _, _, _, _)) { - _vec.push[str](cx.path, name); + Vec.push[str](cx.path, name); } case (ast.item_mod(?name, _, _)) { - _vec.push[str](cx.path, name); + Vec.push[str](cx.path, name); } case (_) { } } @@ -6915,13 +6915,13 @@ fn enter_item(@walk_ctxt cx, @ast.item item) { fn leave_item(@walk_ctxt cx, @ast.item item) { alt (item.node) { case (ast.item_fn(_, _, _, _, _)) { - _vec.pop[str](cx.path); + Vec.pop[str](cx.path); } case (ast.item_obj(_, _, _, _, _)) { - _vec.pop[str](cx.path); + Vec.pop[str](cx.path); } case (ast.item_mod(_, _, _)) { - _vec.pop[str](cx.path); + Vec.pop[str](cx.path); } case (_) { } } @@ -6948,7 +6948,7 @@ fn collect_item_1(@crate_ctxt ccx, @walk_ctxt wcx, @ast.item i) { case (ast.item_const(?name, _, _, ?cid, ?ann)) { auto typ = node_ann_type(ccx, ann); auto g = llvm.LLVMAddGlobal(ccx.llmod, type_of(ccx, typ), - _str.buf(ccx.names.next(name))); + Str.buf(ccx.names.next(name))); llvm.LLVMSetLinkage(g, lib.llvm.LLVMInternalLinkage as llvm.Linkage); ccx.items.insert(cid, i); @@ -7009,7 +7009,7 @@ fn collect_tag_ctor(@crate_ctxt ccx, @walk_ctxt wcx, @ast.item i) { alt (i.node) { case (ast.item_tag(_, ?variants, ?tps, _, _)) { for (ast.variant variant in variants) { - if (_vec.len[ast.variant_arg](variant.node.args) != 0u) { + if (Vec.len[ast.variant_arg](variant.node.args) != 0u) { decl_fn_and_pair(ccx, wcx.path + vec(variant.node.name), "tag", tps, variant.node.ann, variant.node.id); @@ -7037,7 +7037,7 @@ fn trans_constant(@crate_ctxt ccx, @walk_ctxt wcx, @ast.item it) { alt (it.node) { case (ast.item_tag(?ident, ?variants, _, ?tag_id, _)) { auto i = 0u; - auto n_variants = _vec.len[ast.variant](variants); + auto n_variants = Vec.len[ast.variant](variants); while (i < n_variants) { auto variant = variants.(i); @@ -7047,7 +7047,7 @@ fn trans_constant(@crate_ctxt ccx, @walk_ctxt wcx, @ast.item it) { #fmt("_rust_tag_discrim_%s_%u", ident, i)); auto discrim_gvar = llvm.LLVMAddGlobal(ccx.llmod, T_int(), - _str.buf(s)); + Str.buf(s)); llvm.LLVMSetInitializer(discrim_gvar, discrim_val); llvm.LLVMSetGlobalConstant(discrim_gvar, True); @@ -7107,7 +7107,7 @@ fn trans_exit_task_glue(@glue_fns glues, auto llfn = glues.exit_task_glue; - auto entrybb = llvm.LLVMAppendBasicBlock(llfn, _str.buf("entry")); + auto entrybb = llvm.LLVMAppendBasicBlock(llfn, Str.buf("entry")); auto build = new_builder(entrybb); let ValueRef arg1 = llvm.LLVMGetParam(llfn, 0u); @@ -7129,9 +7129,9 @@ fn trans_exit_task_glue(@glue_fns glues, } fn create_typedefs(@crate_ctxt cx) { - llvm.LLVMAddTypeName(cx.llmod, _str.buf("crate"), T_crate(cx.tn)); - llvm.LLVMAddTypeName(cx.llmod, _str.buf("task"), T_task(cx.tn)); - llvm.LLVMAddTypeName(cx.llmod, _str.buf("tydesc"), T_tydesc(cx.tn)); + llvm.LLVMAddTypeName(cx.llmod, Str.buf("crate"), T_crate(cx.tn)); + llvm.LLVMAddTypeName(cx.llmod, Str.buf("task"), T_task(cx.tn)); + llvm.LLVMAddTypeName(cx.llmod, Str.buf("tydesc"), T_tydesc(cx.tn)); } fn create_crate_constant(ValueRef crate_ptr, @glue_fns glues) { @@ -7173,7 +7173,7 @@ fn find_main_fn(@crate_ctxt cx) -> ValueRef { let ValueRef v = C_nil(); let uint n = 0u; for each (@tup(ast.def_id, str) i in cx.item_symbols.items()) { - if (_str.ends_with(i._1, e)) { + if (Str.ends_with(i._1, e)) { n += 1u; v = cx.item_ids.get(i._0); } @@ -7197,7 +7197,7 @@ fn trans_main_fn(@local_ctxt cx, ValueRef llcrate, ValueRef crate_map) { auto T_rust_start_args = vec(T_int(), T_int(), T_int(), T_int(), T_int()); auto main_name; - if (_str.eq(std.os.target_os(), "win32")) { + if (Str.eq(std.OS.target_os(), "win32")) { main_name = "WinMain@16"; } else { main_name = "main"; @@ -7222,7 +7222,7 @@ fn trans_main_fn(@local_ctxt cx, ValueRef llcrate, ValueRef crate_map) { // let BasicBlockRef llbb = - llvm.LLVMAppendBasicBlock(llmain, _str.buf("")); + llvm.LLVMAppendBasicBlock(llmain, Str.buf("")); auto b = new_builder(llbb); auto start_args = vec(p2i(llrust_main), p2i(llcrate), llargc, llargv, @@ -7267,7 +7267,7 @@ fn decl_no_op_type_glue(ModuleRef llmod, type_names tn) -> ValueRef { } fn make_no_op_type_glue(ValueRef fun) { - auto bb_name = _str.buf("_rust_no_op_type_glue_bb"); + auto bb_name = Str.buf("_rust_no_op_type_glue_bb"); auto llbb = llvm.LLVMAppendBasicBlock(fun, bb_name); new_builder(llbb).RetVoid(); } @@ -7283,10 +7283,10 @@ fn make_memcpy_glue(ValueRef fun) { // We're not using the LLVM memcpy intrinsic. It appears to call through // to the platform memcpy in some cases, which is not terribly safe to run // on a rust stack. - auto initbb = llvm.LLVMAppendBasicBlock(fun, _str.buf("init")); - auto hdrbb = llvm.LLVMAppendBasicBlock(fun, _str.buf("hdr")); - auto loopbb = llvm.LLVMAppendBasicBlock(fun, _str.buf("loop")); - auto endbb = llvm.LLVMAppendBasicBlock(fun, _str.buf("end")); + auto initbb = llvm.LLVMAppendBasicBlock(fun, Str.buf("init")); + auto hdrbb = llvm.LLVMAppendBasicBlock(fun, Str.buf("hdr")); + auto loopbb = llvm.LLVMAppendBasicBlock(fun, Str.buf("loop")); + auto endbb = llvm.LLVMAppendBasicBlock(fun, Str.buf("end")); auto dst = llvm.LLVMGetParam(fun, 0u); auto src = llvm.LLVMGetParam(fun, 1u); @@ -7325,10 +7325,10 @@ fn decl_bzero_glue(ModuleRef llmod) -> ValueRef { fn make_bzero_glue(ValueRef fun) -> ValueRef { // We're not using the LLVM memset intrinsic. Same as with memcpy. - auto initbb = llvm.LLVMAppendBasicBlock(fun, _str.buf("init")); - auto hdrbb = llvm.LLVMAppendBasicBlock(fun, _str.buf("hdr")); - auto loopbb = llvm.LLVMAppendBasicBlock(fun, _str.buf("loop")); - auto endbb = llvm.LLVMAppendBasicBlock(fun, _str.buf("end")); + auto initbb = llvm.LLVMAppendBasicBlock(fun, Str.buf("init")); + auto hdrbb = llvm.LLVMAppendBasicBlock(fun, Str.buf("hdr")); + auto loopbb = llvm.LLVMAppendBasicBlock(fun, Str.buf("loop")); + auto endbb = llvm.LLVMAppendBasicBlock(fun, Str.buf("end")); auto dst = llvm.LLVMGetParam(fun, 0u); auto count = llvm.LLVMGetParam(fun, 1u); @@ -7440,7 +7440,7 @@ fn trans_vec_append_glue(@local_ctxt cx) { let ValueRef llskipnull = llvm.LLVMGetParam(llfn, 5u); let BasicBlockRef llallocas = - llvm.LLVMAppendBasicBlock(llfn, _str.buf("allocas")); + llvm.LLVMAppendBasicBlock(llfn, Str.buf("allocas")); auto fcx = @rec(llfn=llfn, lltaskptr=lltaskptr, @@ -7453,7 +7453,7 @@ fn trans_vec_append_glue(@local_ctxt cx) { llobjfields=new_def_hash[ValueRef](), lllocals=new_def_hash[ValueRef](), llupvars=new_def_hash[ValueRef](), - mutable lltydescs=_vec.empty[ValueRef](), + mutable lltydescs=Vec.empty[ValueRef](), lcx=cx); auto bcx = new_top_block_ctxt(fcx); @@ -7476,14 +7476,14 @@ fn trans_vec_append_glue(@local_ctxt cx) { bcx = llnew_vec_res.bcx; auto llnew_vec = vi2p(bcx, llnew_vec_res.val, T_opaque_vec_ptr()); - llvm.LLVMSetValueName(llnew_vec, _str.buf("llnew_vec")); + llvm.LLVMSetValueName(llnew_vec, Str.buf("llnew_vec")); auto copy_dst_cx = new_sub_block_ctxt(bcx, "copy new <- dst"); auto copy_src_cx = new_sub_block_ctxt(bcx, "copy new <- src"); auto pp0 = alloca(bcx, T_ptr(T_i8())); bcx.build.Store(vec_p1_adjusted(bcx, llnew_vec, llskipnull), pp0); - llvm.LLVMSetValueName(pp0, _str.buf("pp0")); + llvm.LLVMSetValueName(pp0, Str.buf("pp0")); bcx.build.CondBr(bcx.build.TruncOrBitCast (bcx.build.Load(llcopy_dst_ptr), @@ -7499,13 +7499,13 @@ fn trans_vec_append_glue(@local_ctxt cx) { ValueRef n_bytes) -> result { auto src_lim = cx.build.GEP(src, vec(n_bytes)); - llvm.LLVMSetValueName(src_lim, _str.buf("src_lim")); + llvm.LLVMSetValueName(src_lim, Str.buf("src_lim")); auto elt_llsz = cx.build.Load(cx.build.GEP(elt_tydesc, vec(C_int(0), C_int(abi.tydesc_field_size)))); - llvm.LLVMSetValueName(elt_llsz, _str.buf("elt_llsz")); + llvm.LLVMSetValueName(elt_llsz, Str.buf("elt_llsz")); fn take_one(ValueRef elt_tydesc, @block_ctxt cx, @@ -7526,7 +7526,7 @@ fn trans_vec_append_glue(@local_ctxt cx) { // Copy any dst elements in, omitting null if doing str. auto n_bytes = vec_fill_adjusted(copy_dst_cx, lldst_vec, llskipnull); - llvm.LLVMSetValueName(n_bytes, _str.buf("n_bytes")); + llvm.LLVMSetValueName(n_bytes, Str.buf("n_bytes")); copy_dst_cx = copy_elts(copy_dst_cx, llelt_tydesc, @@ -7576,13 +7576,13 @@ fn make_glues(ModuleRef llmod, type_names tn) -> @glue_fns { T_void())), native_glues_rust = - _vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn, + Vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn, abi.ngt_rust, _), abi.n_native_glues + 1 as uint), native_glues_pure_rust = - _vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn, + Vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn, abi.ngt_pure_rust, _), abi.n_native_glues + 1 as uint), native_glues_cdecl = - _vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn, + Vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn, abi.ngt_cdecl, _), abi.n_native_glues + 1 as uint), no_op_type_glue = decl_no_op_type_glue(llmod, tn), memcpy_glue = decl_memcpy_glue(llmod), @@ -7595,19 +7595,19 @@ fn make_common_glue(session.session sess, str output) { // to autogen it, but things like the memcpy implementation are not // and it might be better to just check in a .ll file. auto llmod = - llvm.LLVMModuleCreateWithNameInContext(_str.buf("rust_out"), + llvm.LLVMModuleCreateWithNameInContext(Str.buf("rust_out"), llvm.LLVMGetGlobalContext()); - llvm.LLVMSetDataLayout(llmod, _str.buf(x86.get_data_layout())); - llvm.LLVMSetTarget(llmod, _str.buf(x86.get_target_triple())); + llvm.LLVMSetDataLayout(llmod, Str.buf(x86.get_data_layout())); + llvm.LLVMSetTarget(llmod, Str.buf(x86.get_target_triple())); auto td = mk_target_data(x86.get_data_layout()); auto tn = mk_type_names(); let ValueRef crate_ptr = - llvm.LLVMAddGlobal(llmod, T_crate(tn), _str.buf("rust_crate")); + llvm.LLVMAddGlobal(llmod, T_crate(tn), Str.buf("rust_crate")); auto intrinsics = declare_intrinsics(llmod); - llvm.LLVMSetModuleInlineAsm(llmod, _str.buf(x86.get_module_asm())); + llvm.LLVMSetModuleInlineAsm(llmod, Str.buf(x86.get_module_asm())); auto glues = make_glues(llmod, tn); create_crate_constant(crate_ptr, glues); @@ -7624,22 +7624,22 @@ fn create_module_map(@crate_ctxt ccx) -> ValueRef { auto elttype = T_struct(vec(T_int(), T_int())); auto maptype = T_array(elttype, ccx.module_data.size() + 1u); auto map = llvm.LLVMAddGlobal(ccx.llmod, maptype, - _str.buf("_rust_mod_map")); + Str.buf("_rust_mod_map")); llvm.LLVMSetLinkage(map, lib.llvm.LLVMInternalLinkage as llvm.Linkage); let vec[ValueRef] elts = vec(); for each (@tup(str, ValueRef) item in ccx.module_data.items()) { auto elt = C_struct(vec(p2i(C_cstr(ccx, item._0)), p2i(item._1))); - _vec.push[ValueRef](elts, elt); + Vec.push[ValueRef](elts, elt); } auto term = C_struct(vec(C_int(0), C_int(0))); - _vec.push[ValueRef](elts, term); + Vec.push[ValueRef](elts, term); llvm.LLVMSetInitializer(map, C_array(elttype, elts)); ret map; } fn crate_name(@crate_ctxt ccx, str deflt) -> str { for (@ast.meta_item item in ccx.sess.get_metadata()) { - if (_str.eq(item.node.name, "name")) { + if (Str.eq(item.node.name, "name")) { ret item.node.value; } } @@ -7653,15 +7653,15 @@ fn create_crate_map(@crate_ctxt ccx) -> ValueRef { while (ccx.sess.has_external_crate(i)) { auto name = ccx.sess.get_external_crate(i).name; auto cr = llvm.LLVMAddGlobal(ccx.llmod, T_int(), - _str.buf("_rust_crate_map_" + name)); - _vec.push[ValueRef](subcrates, p2i(cr)); + Str.buf("_rust_crate_map_" + name)); + Vec.push[ValueRef](subcrates, p2i(cr)); i += 1; } - _vec.push[ValueRef](subcrates, C_int(0)); + Vec.push[ValueRef](subcrates, C_int(0)); auto sym_name = "_rust_crate_map_" + crate_name(ccx, "__none__"); - auto arrtype = T_array(T_int(), _vec.len[ValueRef](subcrates)); + auto arrtype = T_array(T_int(), Vec.len[ValueRef](subcrates)); auto maptype = T_struct(vec(T_int(), arrtype)); - auto map = llvm.LLVMAddGlobal(ccx.llmod, maptype, _str.buf(sym_name)); + auto map = llvm.LLVMAddGlobal(ccx.llmod, maptype, Str.buf(sym_name)); llvm.LLVMSetLinkage(map, lib.llvm.LLVMExternalLinkage as llvm.Linkage); llvm.LLVMSetInitializer(map, C_struct(vec(p2i(create_module_map(ccx)), C_array(T_int(), subcrates)))); @@ -7672,26 +7672,26 @@ fn trans_crate(session.session sess, @ast.crate crate, ty.ctxt tcx, ty.type_cache type_cache, str output) -> ModuleRef { auto llmod = - llvm.LLVMModuleCreateWithNameInContext(_str.buf("rust_out"), + llvm.LLVMModuleCreateWithNameInContext(Str.buf("rust_out"), llvm.LLVMGetGlobalContext()); - llvm.LLVMSetDataLayout(llmod, _str.buf(x86.get_data_layout())); - llvm.LLVMSetTarget(llmod, _str.buf(x86.get_target_triple())); + llvm.LLVMSetDataLayout(llmod, Str.buf(x86.get_data_layout())); + llvm.LLVMSetTarget(llmod, Str.buf(x86.get_target_triple())); auto td = mk_target_data(x86.get_data_layout()); auto tn = mk_type_names(); let ValueRef crate_ptr = - llvm.LLVMAddGlobal(llmod, T_crate(tn), _str.buf("rust_crate")); + llvm.LLVMAddGlobal(llmod, T_crate(tn), Str.buf("rust_crate")); auto intrinsics = declare_intrinsics(llmod); auto glues = make_glues(llmod, tn); auto hasher = ty.hash_ty; auto eqer = ty.eq_ty; - auto tag_sizes = map.mk_hashmap[ty.t,uint](hasher, eqer); - auto tydescs = map.mk_hashmap[ty.t,@tydesc_info](hasher, eqer); - auto lltypes = map.mk_hashmap[ty.t,TypeRef](hasher, eqer); - auto sha1s = map.mk_hashmap[ty.t,str](hasher, eqer); - auto abbrevs = map.mk_hashmap[ty.t,metadata.ty_abbrev](hasher, eqer); + auto tag_sizes = Map.mk_hashmap[ty.t,uint](hasher, eqer); + auto tydescs = Map.mk_hashmap[ty.t,@tydesc_info](hasher, eqer); + auto lltypes = Map.mk_hashmap[ty.t,TypeRef](hasher, eqer); + auto sha1s = Map.mk_hashmap[ty.t,str](hasher, eqer); + auto abbrevs = Map.mk_hashmap[ty.t,metadata.ty_abbrev](hasher, eqer); auto ccx = @rec(sess = sess, llmod = llmod, @@ -7716,7 +7716,7 @@ fn trans_crate(session.session sess, @ast.crate crate, ty.ctxt tcx, lltypes = lltypes, glues = glues, names = namegen(0), - sha = std.sha1.mk_sha1(), + sha = std.SHA1.mk_sha1(), type_sha1s = sha1s, type_abbrevs = abbrevs, tcx = tcx); diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 5baa6b7a..44fc5486 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -1,13 +1,13 @@ -import std._str; -import std._uint; -import std._vec; +import std.Str; +import std.UInt; +import std.Vec; import std.Box; import std.UFind; -import std.map; -import std.map.hashmap; -import std.option; -import std.option.none; -import std.option.some; +import std.Map; +import std.Map.hashmap; +import std.Option; +import std.Option.none; +import std.Option.some; import driver.session; import front.ast; @@ -65,7 +65,7 @@ fn method_ty_to_fn_ty(ctxt cx, method m) -> t { // TODO: It'd be really nice to be able to hide this definition from the // outside world, to enforce the above invariants. type raw_t = rec(sty struct, - option.t[str] cname, + Option.t[str] cname, uint magic, uint hash, bool has_params, @@ -108,7 +108,7 @@ tag sty { // Data structures used in type unification type unify_handler = obj { - fn resolve_local(ast.def_id id) -> option.t[t]; + fn resolve_local(ast.def_id id) -> Option.t[t]; fn record_local(ast.def_id id, t ty); // TODO: -> Unify.result fn record_param(uint index, t binding) -> Unify.result; }; @@ -168,8 +168,8 @@ fn mk_type_store() -> @type_store { auto hasher = hash_ty; auto eqer = eq_ty_full; - ret @rec(empty_vec_ty = _vec.empty[ty.t](), - empty_vec_mutable_ty = _vec.empty_mut[ty.t](), + ret @rec(empty_vec_ty = Vec.empty[ty.t](), + empty_vec_mutable_ty = Vec.empty_mut[ty.t](), t_nil = mk_ty_full(ty_nil, none[str]), t_bool = mk_ty_full(ty_bool, none[str]), t_int = mk_ty_full(ty_int, none[str]), @@ -196,11 +196,11 @@ fn mk_type_store() -> @type_store { t_native = mk_ty_full(ty_native, none[str]), t_type = mk_ty_full(ty_type, none[str]), - mutable t_params = _vec.empty[ty.t](), - mutable t_bound_params = _vec.empty[ty.t](), - mutable t_vars = _vec.empty[ty.t](), + mutable t_params = Vec.empty[ty.t](), + mutable t_bound_params = Vec.empty[ty.t](), + mutable t_vars = Vec.empty[ty.t](), - others=map.mk_hashmap[t,t](hasher, eqer)); + others=Map.mk_hashmap[t,t](hasher, eqer)); } fn mk_rcache() -> creader_cache { @@ -215,7 +215,7 @@ fn mk_rcache() -> creader_cache { } auto h = hash_cache_entry; auto e = eq_cache_entries; - ret map.mk_hashmap[tup(int,uint,uint),t](h, e); + ret Map.mk_hashmap[tup(int,uint,uint),t](h, e); } fn mk_ctxt(session.session s) -> ctxt { @@ -225,7 +225,7 @@ fn mk_ctxt(session.session s) -> ctxt { } // Type constructors -fn mk_ty_full(&sty st, option.t[str] cname) -> t { +fn mk_ty_full(&sty st, Option.t[str] cname) -> t { auto h = hash_type_info(st, cname); auto magic = mk_magic(st); @@ -350,7 +350,7 @@ fn mk_ty_full(&sty st, option.t[str] cname) -> t { has_locals = has_locals); } -fn gen_ty_full(ctxt cx, &sty st, option.t[str] cname) -> t { +fn gen_ty_full(ctxt cx, &sty st, Option.t[str] cname) -> t { auto new_type = mk_ty_full(st, cname); // Do not intern anything with locals or vars; it'll be nearly @@ -457,7 +457,7 @@ fn mk_local(ctxt cx, ast.def_id did) -> t { } fn mk_param(ctxt cx, uint n) -> t { - let uint i = _vec.len[t](cx.ts.t_params); + let uint i = Vec.len[t](cx.ts.t_params); while (i <= n) { cx.ts.t_params += vec(mk_ty_full(ty_param(i), none[str])); i += 1u; @@ -466,7 +466,7 @@ fn mk_param(ctxt cx, uint n) -> t { } fn mk_bound_param(ctxt cx, uint n) -> t { - let uint i = _vec.len[t](cx.ts.t_bound_params); + let uint i = Vec.len[t](cx.ts.t_bound_params); while (i <= n) { cx.ts.t_bound_params += vec(mk_ty_full(ty_bound_param(i), none[str])); i += 1u; @@ -482,17 +482,17 @@ fn mk_native(ctxt cx) -> t { ret cx.ts.t_native; } fn struct(ctxt cx, t typ) -> sty { ret typ.struct; } // Returns the canonical name of the given type. -fn cname(ctxt cx, t typ) -> option.t[str] { ret typ.cname; } +fn cname(ctxt cx, t typ) -> Option.t[str] { ret typ.cname; } // Stringification fn path_to_str(&ast.path pth) -> str { - auto result = _str.connect(pth.node.idents, "."); - if (_vec.len[@ast.ty](pth.node.types) > 0u) { + auto result = Str.connect(pth.node.idents, "."); + if (Vec.len[@ast.ty](pth.node.types) > 0u) { auto f = pretty.pprust.ty_to_str; result += "["; - result += _str.connect(_vec.map[@ast.ty,str](f, pth.node.types), ","); + result += Str.connect(Vec.map[@ast.ty,str](f, pth.node.types), ","); result += "]"; } ret result; @@ -513,7 +513,7 @@ fn ty_to_str(ctxt cx, &t typ) -> str { fn fn_to_str(ctxt cx, ast.proto proto, - option.t[ast.ident] ident, + Option.t[ast.ident] ident, vec[arg] inputs, t output) -> str { auto f = bind fn_input_to_str(cx, _); @@ -536,7 +536,7 @@ fn ty_to_str(ctxt cx, &t typ) -> str { } s += "("; - s += _str.connect(_vec.map[arg,str](f, inputs), ", "); + s += Str.connect(Vec.map[arg,str](f, inputs), ", "); s += ")"; if (struct(cx, output) != ty_nil) { @@ -592,24 +592,24 @@ fn ty_to_str(ctxt cx, &t typ) -> str { case (ty_tup(?elems)) { auto f = bind mt_to_str(cx, _); - auto strs = _vec.map[mt,str](f, elems); - s += "tup(" + _str.connect(strs, ",") + ")"; + auto strs = Vec.map[mt,str](f, elems); + s += "tup(" + Str.connect(strs, ",") + ")"; } case (ty_rec(?elems)) { auto f = bind field_to_str(cx, _); - auto strs = _vec.map[field,str](f, elems); - s += "rec(" + _str.connect(strs, ",") + ")"; + auto strs = Vec.map[field,str](f, elems); + s += "rec(" + Str.connect(strs, ",") + ")"; } case (ty_tag(?id, ?tps)) { // The user should never see this if the cname is set properly! s += "<tag#" + util.common.istr(id._0) + ":" + util.common.istr(id._1) + ">"; - if (_vec.len[t](tps) > 0u) { + if (Vec.len[t](tps) > 0u) { auto f = bind ty_to_str(cx, _); - auto strs = _vec.map[t,str](f, tps); - s += "[" + _str.connect(strs, ",") + "]"; + auto strs = Vec.map[t,str](f, tps); + s += "[" + Str.connect(strs, ",") + "]"; } } @@ -623,8 +623,8 @@ fn ty_to_str(ctxt cx, &t typ) -> str { case (ty_obj(?meths)) { auto f = bind method_to_str(cx, _); - auto m = _vec.map[method,str](f, meths); - s += "obj {\n\t" + _str.connect(m, "\n\t") + "\n}"; + auto m = Vec.map[method,str](f, meths); + s += "obj {\n\t" + Str.connect(m, "\n\t") + "\n}"; } case (ty_var(?v)) { @@ -637,11 +637,11 @@ fn ty_to_str(ctxt cx, &t typ) -> str { } case (ty_param(?id)) { - s += "'" + _str.unsafe_from_bytes(vec(('a' as u8) + (id as u8))); + s += "'" + Str.unsafe_from_bytes(vec(('a' as u8) + (id as u8))); } case (ty_bound_param(?id)) { - s += "''" + _str.unsafe_from_bytes(vec(('a' as u8) + (id as u8))); + s += "''" + Str.unsafe_from_bytes(vec(('a' as u8) + (id as u8))); } } @@ -652,7 +652,7 @@ fn ty_to_short_str(ctxt cx, t typ) -> str { auto f = def_to_str; auto ecx = @rec(ds=f, tcx=cx, abbrevs=metadata.ac_no_abbrevs); auto s = metadata.Encode.ty_str(ecx, typ); - if (_str.byte_len(s) >= 64u) { s = _str.substr(s, 0u, 64u); } + if (Str.byte_len(s) >= 64u) { s = Str.substr(s, 0u, 64u); } ret s; } @@ -956,14 +956,14 @@ fn type_has_dynamic_size(ctxt cx, t ty) -> bool { alt (struct(cx, ty)) { case (ty_tup(?mts)) { auto i = 0u; - while (i < _vec.len[mt](mts)) { + while (i < Vec.len[mt](mts)) { if (type_has_dynamic_size(cx, mts.(i).ty)) { ret true; } i += 1u; } } case (ty_rec(?fields)) { auto i = 0u; - while (i < _vec.len[field](fields)) { + while (i < Vec.len[field](fields)) { if (type_has_dynamic_size(cx, fields.(i).mt.ty)) { ret true; } @@ -972,7 +972,7 @@ fn type_has_dynamic_size(ctxt cx, t ty) -> bool { } case (ty_tag(_, ?subtys)) { auto i = 0u; - while (i < _vec.len[t](subtys)) { + while (i < Vec.len[t](subtys)) { if (type_has_dynamic_size(cx, subtys.(i))) { ret true; } i += 1u; } @@ -1041,7 +1041,7 @@ fn type_is_signed(ctxt cx, t ty) -> bool { fail; } -fn type_param(ctxt cx, t ty) -> option.t[uint] { +fn type_param(ctxt cx, t ty) -> Option.t[uint] { alt (struct(cx, ty)) { case (ty_param(?id)) { ret some[uint](id); } case (_) { /* fall through */ } @@ -1174,7 +1174,7 @@ fn hash_type_structure(&sty st) -> uint { case (ty_obj(?methods)) { auto h = 27u; for (method m in methods) { - h += h << 5u + _str.hash(m.ident); + h += h << 5u + Str.hash(m.ident); } ret h; } @@ -1187,11 +1187,11 @@ fn hash_type_structure(&sty st) -> uint { } } -fn hash_type_info(&sty st, option.t[str] cname_opt) -> uint { +fn hash_type_info(&sty st, Option.t[str] cname_opt) -> uint { auto h = hash_type_structure(st); alt (cname_opt) { case (none[str]) { /* no-op */ } - case (some[str](?s)) { h += h << 5u + _str.hash(s); } + case (some[str](?s)) { h += h << 5u + Str.hash(s); } } ret h; } @@ -1297,8 +1297,8 @@ fn equal_type_structures(&sty a, &sty b) -> bool { vec[arg] args_b, t rty_b) -> bool { if (!eq_ty(rty_a, rty_b)) { ret false; } - auto len = _vec.len[arg](args_a); - if (len != _vec.len[arg](args_b)) { ret false; } + auto len = Vec.len[arg](args_a); + if (len != Vec.len[arg](args_b)) { ret false; } auto i = 0u; while (i < len) { @@ -1370,8 +1370,8 @@ fn equal_type_structures(&sty a, &sty b) -> bool { case (ty_tag(?id_b, ?tys_b)) { if (!equal_def(id_a, id_b)) { ret false; } - auto len = _vec.len[t](tys_a); - if (len != _vec.len[t](tys_b)) { ret false; } + auto len = Vec.len[t](tys_a); + if (len != Vec.len[t](tys_b)) { ret false; } auto i = 0u; while (i < len) { if (!eq_ty(tys_a.(i), tys_b.(i))) { ret false; } @@ -1415,8 +1415,8 @@ fn equal_type_structures(&sty a, &sty b) -> bool { case (ty_tup(?mts_a)) { alt (b) { case (ty_tup(?mts_b)) { - auto len = _vec.len[mt](mts_a); - if (len != _vec.len[mt](mts_b)) { ret false; } + auto len = Vec.len[mt](mts_a); + if (len != Vec.len[mt](mts_b)) { ret false; } auto i = 0u; while (i < len) { if (!equal_mt(mts_a.(i), mts_b.(i))) { ret false; } @@ -1430,12 +1430,12 @@ fn equal_type_structures(&sty a, &sty b) -> bool { case (ty_rec(?flds_a)) { alt (b) { case (ty_rec(?flds_b)) { - auto len = _vec.len[field](flds_a); - if (len != _vec.len[field](flds_b)) { ret false; } + auto len = Vec.len[field](flds_a); + if (len != Vec.len[field](flds_b)) { ret false; } auto i = 0u; while (i < len) { auto fld_a = flds_a.(i); auto fld_b = flds_b.(i); - if (!_str.eq(fld_a.ident, fld_b.ident) || + if (!Str.eq(fld_a.ident, fld_b.ident) || !equal_mt(fld_a.mt, fld_b.mt)) { ret false; } @@ -1467,13 +1467,13 @@ fn equal_type_structures(&sty a, &sty b) -> bool { case (ty_obj(?methods_a)) { alt (b) { case (ty_obj(?methods_b)) { - auto len = _vec.len[method](methods_a); - if (len != _vec.len[method](methods_b)) { ret false; } + auto len = Vec.len[method](methods_a); + if (len != Vec.len[method](methods_b)) { ret false; } auto i = 0u; while (i < len) { auto m_a = methods_a.(i); auto m_b = methods_b.(i); if (!equal_proto(m_a.proto, m_b.proto) || - !_str.eq(m_a.ident, m_b.ident) || + !Str.eq(m_a.ident, m_b.ident) || !equal_fn(m_a.inputs, m_a.output, m_b.inputs, m_b.output)) { ret false; @@ -1546,7 +1546,7 @@ fn eq_ty_full(&t a, &t b) -> bool { case (some[str](?s_a)) { alt (b.cname) { case (some[str](?s_b)) { - if (!_str.eq(s_a, s_b)) { ret false; } + if (!Str.eq(s_a, s_b)) { ret false; } } case (_) { ret false; } } @@ -1651,7 +1651,7 @@ fn count_ty_params(ctxt cx, t ty) -> uint { let @mutable vec[uint] param_indices = @mutable v; auto f = bind counter(cx, param_indices, _); walk_ty(cx, f, ty); - ret _vec.len[uint](*param_indices); + ret Vec.len[uint](*param_indices); } fn type_contains_vars(ctxt cx, t typ) -> bool { @@ -1721,7 +1721,7 @@ fn native_item_ty(@ast.native_item it) -> ty_param_count_and_ty { auto result_ty; alt (it.node) { case (ast.native_item_fn(_, _, _, ?tps, _, ?ann)) { - ty_param_count = _vec.len[ast.ty_param](tps); + ty_param_count = Vec.len[ast.ty_param](tps); result_ty = ann_to_type(ann); } } @@ -1737,22 +1737,22 @@ fn item_ty(@ast.item it) -> ty_param_count_and_ty { result_ty = ann_to_type(ann); } case (ast.item_fn(_, _, ?tps, _, ?ann)) { - ty_param_count = _vec.len[ast.ty_param](tps); + ty_param_count = Vec.len[ast.ty_param](tps); result_ty = ann_to_type(ann); } case (ast.item_mod(_, _, _)) { fail; // modules are typeless } case (ast.item_ty(_, _, ?tps, _, ?ann)) { - ty_param_count = _vec.len[ast.ty_param](tps); + ty_param_count = Vec.len[ast.ty_param](tps); result_ty = ann_to_type(ann); } case (ast.item_tag(_, _, ?tps, ?did, ?ann)) { - ty_param_count = _vec.len[ast.ty_param](tps); + ty_param_count = Vec.len[ast.ty_param](tps); result_ty = ann_to_type(ann); } case (ast.item_obj(_, _, ?tps, _, ?ann)) { - ty_param_count = _vec.len[ast.ty_param](tps); + ty_param_count = Vec.len[ast.ty_param](tps); result_ty = ann_to_type(ann); } } @@ -1924,7 +1924,7 @@ fn expr_has_ty_params(@ast.expr expr) -> bool { alt (expr_ann(expr)) { case (ast.ann_none) { fail; } case (ast.ann_type(_, ?tps_opt, _)) { - ret !option.is_none[vec[t]](tps_opt); + ret !Option.is_none[vec[t]](tps_opt); } } } @@ -1987,7 +1987,7 @@ fn field_num(session.session sess, &span sp, &ast.ident id) -> uint { accum += (c as uint) - ('0' as uint); } else { auto s = ""; - s += _str.unsafe_from_byte(c); + s += Str.unsafe_from_byte(c); sess.span_err(sp, "bad numeric field on tuple: " + " non-digit character: " @@ -2003,7 +2003,7 @@ fn field_idx(session.session sess, &span sp, &ast.ident id, vec[field] fields) -> uint { let uint i = 0u; for (field f in fields) { - if (_str.eq(f.ident, id)) { + if (Str.eq(f.ident, id)) { ret i; } i += 1u; @@ -2016,7 +2016,7 @@ fn method_idx(session.session sess, &span sp, &ast.ident id, vec[method] meths) -> uint { let uint i = 0u; for (method m in meths) { - if (_str.eq(m.ident, id)) { + if (Str.eq(m.ident, id)) { ret i; } i += 1u; @@ -2027,10 +2027,10 @@ fn method_idx(session.session sess, &span sp, fn sort_methods(vec[method] meths) -> vec[method] { fn method_lteq(&method a, &method b) -> bool { - ret _str.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); } fn is_lval(@ast.expr expr) -> bool { @@ -2078,7 +2078,7 @@ mod Unify { // Unifies two mutability flags. fn unify_mut(ast.mutability expected, ast.mutability actual) - -> option.t[ast.mutability] { + -> Option.t[ast.mutability] { if (expected == actual) { ret some[ast.mutability](expected); } @@ -2102,8 +2102,8 @@ mod Unify { vec[arg] expected_inputs, t expected_output, vec[arg] actual_inputs, t actual_output) -> fn_common_res { - auto expected_len = _vec.len[arg](expected_inputs); - auto actual_len = _vec.len[arg](actual_inputs); + auto expected_len = Vec.len[arg](expected_inputs); + auto actual_len = Vec.len[arg](actual_inputs); if (expected_len != actual_len) { ret fn_common_res_err(ures_err(terr_arg_count, expected, actual)); @@ -2213,8 +2213,8 @@ mod Unify { vec[method] actual_meths) -> result { let vec[method] result_meths = vec(); let uint i = 0u; - let uint expected_len = _vec.len[method](expected_meths); - let uint actual_len = _vec.len[method](actual_meths); + let uint expected_len = Vec.len[method](expected_meths); + let uint actual_len = Vec.len[method](actual_meths); if (expected_len != actual_len) { ret ures_err(terr_meth_count, expected, actual); @@ -2223,7 +2223,7 @@ mod Unify { while (i < expected_len) { auto e_meth = expected_meths.(i); auto a_meth = actual_meths.(i); - if (! _str.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), expected, actual); } @@ -2287,7 +2287,7 @@ mod Unify { case (_) { // Just bind the type variable to the expected type. - auto vlen = _vec.len[vec[t]](cx.types); + auto vlen = Vec.len[vec[t]](cx.types); if (actual_n < vlen) { cx.types.(actual_n) += vec(expected); } else { @@ -2354,7 +2354,7 @@ mod Unify { // ty.ty_tup case let vec[t] result_tps = vec(); auto i = 0u; - auto expected_len = _vec.len[t](expected_tps); + auto expected_len = Vec.len[t](expected_tps); while (i < expected_len) { auto expected_tp = expected_tps.(i); auto actual_tp = actual_tps.(i); @@ -2365,7 +2365,7 @@ mod Unify { alt (result) { case (ures_ok(?rty)) { - _vec.push[t](result_tps, rty); + Vec.push[t](result_tps, rty); } case (_) { ret result; @@ -2494,8 +2494,8 @@ mod Unify { case (ty.ty_tup(?expected_elems)) { alt (struct(cx.tcx, actual)) { case (ty.ty_tup(?actual_elems)) { - auto expected_len = _vec.len[ty.mt](expected_elems); - auto actual_len = _vec.len[ty.mt](actual_elems); + auto expected_len = Vec.len[ty.mt](expected_elems); + auto actual_len = Vec.len[ty.mt](actual_elems); if (expected_len != actual_len) { auto err = terr_tuple_size(expected_len, actual_len); @@ -2548,8 +2548,8 @@ mod Unify { case (ty.ty_rec(?expected_fields)) { alt (struct(cx.tcx, actual)) { case (ty.ty_rec(?actual_fields)) { - auto expected_len = _vec.len[field](expected_fields); - auto actual_len = _vec.len[field](actual_fields); + auto expected_len = Vec.len[field](expected_fields); + auto actual_len = Vec.len[field](actual_fields); if (expected_len != actual_len) { auto err = terr_record_size(expected_len, actual_len); @@ -2574,7 +2574,7 @@ mod Unify { case (some[ast.mutability](?m)) { mut = m; } } - if (!_str.eq(expected_field.ident, + if (!Str.eq(expected_field.ident, actual_field.ident)) { auto err = terr_record_fields(expected_field.ident, @@ -2588,7 +2588,7 @@ mod Unify { alt (result) { case (ures_ok(?rty)) { auto mt = rec(ty=rty, mut=mut); - _vec.push[field] + Vec.push[field] (result_fields, rec(mt=mt with expected_field)); } @@ -2655,7 +2655,7 @@ mod Unify { case (ty.ty_var(?expected_id)) { // Add a binding. auto expected_n = get_or_create_set(cx, expected_id); - auto vlen = _vec.len[vec[t]](cx.types); + auto vlen = Vec.len[vec[t]](cx.types); if (expected_n < vlen) { cx.types.(expected_n) += vec(actual); } else { @@ -2719,7 +2719,7 @@ mod Unify { fn unify_sets(@ctxt cx) -> vec[t] { let vec[t] throwaway = vec(); let vec[mutable vec[t]] set_types = vec(mutable throwaway); - _vec.pop[vec[t]](set_types); // FIXME: botch + Vec.pop[vec[t]](set_types); // FIXME: botch for (UFind.node node in cx.sets.nodes) { let vec[t] v = vec(); @@ -2727,7 +2727,7 @@ mod Unify { } auto i = 0u; - while (i < _vec.len[vec[t]](set_types)) { + while (i < Vec.len[vec[t]](set_types)) { auto root = UFind.find(cx.sets, i); set_types.(root) += cx.types.(i); i += 1u; @@ -2735,7 +2735,7 @@ mod Unify { let vec[t] result = vec(); for (vec[t] types in set_types) { - if (_vec.len[t](types) > 1u) { + if (Vec.len[t](types) > 1u) { log_err "unification of > 1 types in a type set is " + "unimplemented"; fail; @@ -2752,7 +2752,7 @@ mod Unify { ty_ctxt tcx) -> result { let vec[t] throwaway = vec(); let vec[mutable vec[t]] types = vec(mutable throwaway); - _vec.pop[vec[t]](types); // FIXME: botch + Vec.pop[vec[t]](types); // FIXME: botch auto cx = @rec(sets=UFind.make(), var_ids=common.new_int_hash[uint](), @@ -2765,7 +2765,7 @@ mod Unify { case (ures_ok(?typ)) { // Fast path: if there are no local variables, don't perform // substitutions. - if (_vec.len(cx.sets.nodes) == 0u) { + if (Vec.len(cx.sets.nodes) == 0u) { ret ures_ok(typ); } @@ -2791,16 +2791,16 @@ fn type_err_to_str(&ty.type_err err) -> str { ret "vectors differ in mutability"; } case (terr_tuple_size(?e_sz, ?a_sz)) { - ret "expected a tuple with " + _uint.to_str(e_sz, 10u) + - " elements but found one with " + _uint.to_str(a_sz, 10u) + + ret "expected a tuple with " + UInt.to_str(e_sz, 10u) + + " elements but found one with " + UInt.to_str(a_sz, 10u) + " elements"; } case (terr_tuple_mutability) { ret "tuple elements differ in mutability"; } case (terr_record_size(?e_sz, ?a_sz)) { - ret "expected a record with " + _uint.to_str(e_sz, 10u) + - " fields but found one with " + _uint.to_str(a_sz, 10u) + + ret "expected a record with " + UInt.to_str(e_sz, 10u) + + " fields but found one with " + UInt.to_str(a_sz, 10u) + " fields"; } case (terr_record_mutability) { diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 65e443df..091616fc 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -32,15 +32,15 @@ import middle.ty.ty_nil; import middle.ty.Unify.ures_ok; import middle.ty.Unify.ures_err; -import std._str; -import std._uint; -import std._vec; -import std.map; -import std.map.hashmap; -import std.option; -import std.option.none; -import std.option.some; -import std.option.from_maybe; +import std.Str; +import std.UInt; +import std.Vec; +import std.Map; +import std.Map.hashmap; +import std.Option; +import std.Option.none; +import std.Option.some; +import std.Option.from_maybe; import util.typestate_ann.ts_ann; @@ -61,7 +61,7 @@ type crate_ctxt = rec(session.session sess, ty.type_cache type_cache, @ty_item_table item_items, vec[ast.obj_field] obj_fields, - option.t[ast.def_id] this_obj, + Option.t[ast.def_id] this_obj, @fn_purity_table fn_purity_table, mutable int next_var_id, unify_cache unify_cache, @@ -91,12 +91,12 @@ fn substitute_ty_params(&@crate_ctxt ccx, } } - auto supplied_len = _vec.len[ty.t](supplied); + auto supplied_len = Vec.len[ty.t](supplied); if (ty_param_count != supplied_len) { ccx.sess.span_err(sp, "expected " + - _uint.to_str(ty_param_count, 10u) + + UInt.to_str(ty_param_count, 10u) + " type parameter(s) but found " + - _uint.to_str(supplied_len, 10u) + " parameter(s)"); + UInt.to_str(supplied_len, 10u) + " parameter(s)"); fail; } @@ -181,7 +181,7 @@ fn instantiate_path(@fn_ctxt fcx, &ast.path pth, &ty_param_count_and_ty tpt, auto t = bind_params_in_type(fcx.ccx.tcx, tpt._1); auto ty_substs_opt; - auto ty_substs_len = _vec.len[@ast.ty](pth.node.types); + auto ty_substs_len = Vec.len[@ast.ty](pth.node.types); if (ty_substs_len > 0u) { let vec[ty.t] ty_substs = vec(); auto i = 0u; @@ -281,7 +281,7 @@ fn ast_ty_to_ty(ty.ctxt tcx, ty_getter getter, &@ast.ty ast_ty) -> ty.t { case (ast.ty_tup(?fields)) { let vec[ty.mt] flds = vec(); for (ast.mt field in fields) { - _vec.push[ty.mt](flds, ast_mt_to_mt(tcx, getter, field)); + Vec.push[ty.mt](flds, ast_mt_to_mt(tcx, getter, field)); } typ = ty.mk_tup(tcx, flds); } @@ -289,21 +289,21 @@ fn ast_ty_to_ty(ty.ctxt tcx, ty_getter getter, &@ast.ty ast_ty) -> ty.t { let vec[field] flds = vec(); for (ast.ty_field f in fields) { auto tm = ast_mt_to_mt(tcx, getter, f.mt); - _vec.push[field](flds, rec(ident=f.ident, mt=tm)); + Vec.push[field](flds, rec(ident=f.ident, mt=tm)); } typ = ty.mk_rec(tcx, flds); } case (ast.ty_fn(?proto, ?inputs, ?output)) { auto f = bind ast_arg_to_arg(tcx, getter, _); - auto i = _vec.map[ast.ty_arg, arg](f, inputs); + auto i = Vec.map[ast.ty_arg, arg](f, inputs); auto out_ty = ast_ty_to_ty(tcx, getter, output); typ = ty.mk_fn(tcx, proto, i, out_ty); } case (ast.ty_path(?path, ?def)) { assert (def != none[ast.def]); - alt (option.get[ast.def](def)) { + alt (Option.get[ast.def](def)) { case (ast.def_ty(?id)) { typ = instantiate(tcx, getter, id, path.node.types); } @@ -325,9 +325,9 @@ fn ast_ty_to_ty(ty.ctxt tcx, ty_getter getter, &@ast.ty ast_ty) -> ty.t { let vec[ty.method] tmeths = vec(); auto f = bind ast_arg_to_arg(tcx, getter, _); for (ast.ty_method m in meths) { - auto ins = _vec.map[ast.ty_arg, arg](f, m.inputs); + auto ins = Vec.map[ast.ty_arg, arg](f, m.inputs); auto out = ast_ty_to_ty(tcx, getter, m.output); - _vec.push[ty.method](tmeths, + Vec.push[ty.method](tmeths, rec(proto=m.proto, ident=m.ident, inputs=ins, @@ -383,10 +383,10 @@ mod Collect { ast.proto proto, vec[ast.ty_param] ty_params, ast.def_id def_id) -> ty.ty_param_count_and_ty { - auto input_tys = _vec.map[ast.arg,arg](ty_of_arg, decl.inputs); + auto input_tys = Vec.map[ast.arg,arg](ty_of_arg, decl.inputs); auto output_ty = convert(decl.output); auto t_fn = ty.mk_fn(cx.tcx, proto, input_tys, output_ty); - auto ty_param_count = _vec.len[ast.ty_param](ty_params); + auto ty_param_count = Vec.len[ast.ty_param](ty_params); auto tpt = tup(ty_param_count, t_fn); cx.type_cache.insert(def_id, tpt); ret tpt; @@ -399,10 +399,10 @@ mod Collect { ast.native_abi abi, vec[ast.ty_param] ty_params, ast.def_id def_id) -> ty.ty_param_count_and_ty { - auto input_tys = _vec.map[ast.arg,arg](ty_of_arg, decl.inputs); + auto input_tys = Vec.map[ast.arg,arg](ty_of_arg, decl.inputs); auto output_ty = convert(decl.output); auto t_fn = ty.mk_native_fn(cx.tcx, abi, input_tys, output_ty); - auto ty_param_count = _vec.len[ast.ty_param](ty_params); + auto ty_param_count = Vec.len[ast.ty_param](ty_params); auto tpt = tup(ty_param_count, t_fn); cx.type_cache.insert(def_id, tpt); ret tpt; @@ -438,7 +438,7 @@ mod Collect { auto get = bind getter(cx, _); auto convert = bind ast_ty_to_ty(cx.tcx, get, _); auto f = bind ty_of_arg(cx, _); - auto inputs = _vec.map[ast.arg,arg](f, m.node.meth.decl.inputs); + auto inputs = Vec.map[ast.arg,arg](f, m.node.meth.decl.inputs); auto output = convert(m.node.meth.decl.output); ret rec(proto=m.node.meth.proto, ident=m.node.ident, inputs=inputs, output=output); @@ -449,11 +449,11 @@ mod Collect { &ast._obj obj_info, vec[ast.ty_param] ty_params) -> ty.ty_param_count_and_ty { auto f = bind ty_of_method(cx, _); - auto methods = _vec.map[@ast.method,method](f, obj_info.methods); + auto methods = Vec.map[@ast.method,method](f, obj_info.methods); auto t_obj = ty.mk_obj(cx.tcx, ty.sort_methods(methods)); t_obj = ty.rename(cx.tcx, t_obj, id); - auto ty_param_count = _vec.len[ast.ty_param](ty_params); + auto ty_param_count = Vec.len[ast.ty_param](ty_params); ret tup(ty_param_count, t_obj); } @@ -468,7 +468,7 @@ mod Collect { for (ast.obj_field f in obj_info.fields) { auto g = bind getter(cx, _); auto t_field = ast_ty_to_ty(cx.tcx, g, f.ty); - _vec.push[arg](t_inputs, rec(mode=ast.alias, ty=t_field)); + Vec.push[arg](t_inputs, rec(mode=ast.alias, ty=t_field)); } cx.type_cache.insert(obj_ty_id, t_obj); @@ -515,7 +515,7 @@ mod Collect { // Tell ast_ty_to_ty() that we want to perform a recursive // call to resolve any named types. auto typ = convert(t); - auto ty_param_count = _vec.len[ast.ty_param](tps); + auto ty_param_count = Vec.len[ast.ty_param](tps); auto tpt = tup(ty_param_count, typ); cx.type_cache.insert(def_id, tpt); ret tpt; @@ -533,7 +533,7 @@ mod Collect { auto t = ty.mk_tag(cx.tcx, def_id, subtys); - auto ty_param_count = _vec.len[ast.ty_param](tps); + auto ty_param_count = Vec.len[ast.ty_param](tps); auto tpt = tup(ty_param_count, t); cx.type_cache.insert(def_id, tpt); ret tpt; @@ -585,13 +585,13 @@ mod Collect { i += 1u; } - auto ty_param_count = _vec.len[ast.ty_param](ty_params); + auto ty_param_count = Vec.len[ast.ty_param](ty_params); for (ast.variant variant in variants) { // Nullary tag constructors get turned into constants; n-ary tag // constructors get turned into functions. auto result_ty; - if (_vec.len[ast.variant_arg](variant.node.args) == 0u) { + if (Vec.len[ast.variant_arg](variant.node.args) == 0u) { result_ty = ty.mk_tag(cx.tcx, tag_id, ty_param_tys); } else { // As above, tell ast_ty_to_ty() that trans_ty_item_to_ty() @@ -691,7 +691,7 @@ mod Collect { ret @fold.respan[ast.item_](sp, item); } - fn fold_native_item_fn(&@env e, &span sp, ast.ident i, option.t[str] ln, + fn fold_native_item_fn(&@env e, &span sp, ast.ident i, Option.t[str] ln, &ast.fn_decl d, vec[ast.ty_param] ty_params, ast.def_id id, ast.ann a) -> @ast.native_item { // assert (e.cx.type_cache.contains_key(id)); @@ -746,7 +746,7 @@ mod Collect { with meth.node ); m = @rec(node=m_ with *meth); - _vec.push[@ast.method](methods, m); + Vec.push[@ast.method](methods, m); } auto g = bind getter(e.cx, _); for (ast.obj_field fld in ob.fields) { @@ -754,7 +754,7 @@ mod Collect { let ast.obj_field f = rec(ann=triv_ann(fty) with fld ); - _vec.push[ast.obj_field](fields, f); + Vec.push[ast.obj_field](fields, f); } auto dtor = none[@ast.method]; @@ -847,7 +847,7 @@ mod Unify { // FIXME: horrid botch let vec[mutable ty.t] param_substs = vec(mutable ty.mk_nil(fcx.ccx.tcx)); - _vec.pop(param_substs); + Vec.pop(param_substs); ret with_params(fcx, expected, actual, param_substs); } @@ -865,7 +865,7 @@ mod Unify { } obj unify_handler(@fn_ctxt fcx, vec[mutable ty.t] param_substs) { - fn resolve_local(ast.def_id id) -> option.t[ty.t] { + fn resolve_local(ast.def_id id) -> Option.t[ty.t] { alt (fcx.locals.find(id)) { case (none[ty.t]) { ret none[ty.t]; } case (some[ty.t](?existing_type)) { @@ -905,7 +905,7 @@ mod Unify { } fn record_param(uint index, ty.t binding) -> ty.Unify.result { // Unify with the appropriate type in the parameter - // substitution list. + // substitution List. auto old_subst = param_substs.(index); auto result = with_params(fcx, old_subst, binding, @@ -1004,7 +1004,7 @@ mod Demand { let vec[mutable ty.t] ty_param_substs = vec(mutable ty.mk_nil(fcx.ccx.tcx)); - _vec.pop(ty_param_substs); // FIXME: horrid botch + Vec.pop(ty_param_substs); // FIXME: horrid botch for (ty.t ty_param_subst in ty_param_substs_0) { ty_param_substs += vec(mutable ty_param_subst); } @@ -1047,7 +1047,7 @@ fn are_compatible(&@fn_ctxt fcx, ty.t expected, ty.t actual) -> bool { // Returns the types of the arguments to a tag variant. fn variant_arg_types(@crate_ctxt ccx, &span sp, ast.def_id vid, vec[ty.t] tag_ty_params) -> vec[ty.t] { - auto ty_param_count = _vec.len[ty.t](tag_ty_params); + auto ty_param_count = Vec.len[ty.t](tag_ty_params); let vec[ty.t] result = vec(); @@ -1130,7 +1130,7 @@ mod Pushdown { } // Get the types of the arguments of the variant. - auto vdef = option.get[ast.variant_def](vdef_opt); + auto vdef = Option.get[ast.variant_def](vdef_opt); auto arg_tys = variant_arg_types(fcx.ccx, pat.span, vdef._1, tag_tps); @@ -1218,7 +1218,7 @@ mod Pushdown { case (none[@ast.expr]) { auto i = 0u; for (ast.field field_0 in fields_0) { - assert (_str.eq(field_0.ident, + assert (Str.eq(field_0.ident, field_mts.(i).ident)); auto e_1 = pushdown_expr(fcx, @@ -1240,7 +1240,7 @@ mod Pushdown { for (ast.field field_0 in fields_0) { for (ty.field ft in field_mts) { - if (_str.eq(field_0.ident, + if (Str.eq(field_0.ident, ft.ident)) { auto e_1 = pushdown_expr(fcx, ft.mt.ty, @@ -1508,9 +1508,9 @@ mod Pushdown { // Local variable resolution: the phase that finds all the types in the AST // and replaces opaque "ty_local" types with the resolved local types. -fn writeback_local(&option.t[@fn_ctxt] env, &span sp, @ast.local local) +fn writeback_local(&Option.t[@fn_ctxt] env, &span sp, @ast.local local) -> @ast.decl { - auto fcx = option.get[@fn_ctxt](env); + auto fcx = Option.get[@fn_ctxt](env); auto local_ty; alt (fcx.locals.find(local.id)) { @@ -1530,7 +1530,7 @@ fn writeback_local(&option.t[@fn_ctxt] env, &span sp, @ast.local local) ret @fold.respan[ast.decl_](sp, ast.decl_local(local_wb)); } -fn resolve_local_types_in_annotation(&option.t[@fn_ctxt] env, ast.ann ann) +fn resolve_local_types_in_annotation(&Option.t[@fn_ctxt] env, ast.ann ann) -> ast.ann { fn resolver(@fn_ctxt fcx, ty.t typ) -> ty.t { alt (struct(fcx.ccx.tcx, typ)) { @@ -1539,7 +1539,7 @@ fn resolve_local_types_in_annotation(&option.t[@fn_ctxt] env, ast.ann ann) } } - auto fcx = option.get[@fn_ctxt](env); + auto fcx = Option.get[@fn_ctxt](env); alt (ann) { case (ast.ann_none) { log "warning: no type for expression"; @@ -1559,16 +1559,16 @@ fn resolve_local_types_in_annotation(&option.t[@fn_ctxt] env, ast.ann ann) fn resolve_local_types_in_block(&@fn_ctxt fcx, &ast.block block) -> ast.block { - fn update_env_for_item(&option.t[@fn_ctxt] env, @ast.item i) - -> option.t[@fn_ctxt] { + fn update_env_for_item(&Option.t[@fn_ctxt] env, @ast.item i) + -> Option.t[@fn_ctxt] { ret none[@fn_ctxt]; } - fn keep_going(&option.t[@fn_ctxt] env) -> bool { - ret !option.is_none[@fn_ctxt](env); + fn keep_going(&Option.t[@fn_ctxt] env) -> bool { + ret !Option.is_none[@fn_ctxt](env); } // FIXME: rustboot bug prevents us from using these functions directly - auto fld = fold.new_identity_fold[option.t[@fn_ctxt]](); + auto fld = fold.new_identity_fold[Option.t[@fn_ctxt]](); auto wbl = writeback_local; auto rltia = bind resolve_local_types_in_annotation(_,_); auto uefi = update_env_for_item; @@ -1580,7 +1580,7 @@ fn resolve_local_types_in_block(&@fn_ctxt fcx, &ast.block block) keep_going = kg with *fld ); - ret fold.fold_block[option.t[@fn_ctxt]](some[@fn_ctxt](fcx), fld, block); + ret fold.fold_block[Option.t[@fn_ctxt]](some[@fn_ctxt](fcx), fld, block); } // AST fragment checking @@ -1616,10 +1616,10 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat { new_pat = ast.pat_bind(id, def_id, ann); } case (ast.pat_tag(?p, ?subpats, ?vdef_opt, _)) { - auto vdef = option.get[ast.variant_def](vdef_opt); + auto vdef = Option.get[ast.variant_def](vdef_opt); auto t = ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx, fcx.ccx.type_cache, vdef._1)._1; - auto len = _vec.len[ast.ident](p.node.idents); + auto len = Vec.len[ast.ident](p.node.idents); auto last_id = p.node.idents.(len - 1u); auto tpt = ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx, @@ -1629,14 +1629,14 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat { alt (struct(fcx.ccx.tcx, t)) { // N-ary variants have function types. case (ty.ty_fn(_, ?args, ?tag_ty)) { - auto arg_len = _vec.len[arg](args); - auto subpats_len = _vec.len[@ast.pat](subpats); + auto arg_len = Vec.len[arg](args); + auto subpats_len = Vec.len[@ast.pat](subpats); if (arg_len != subpats_len) { // TODO: pluralize properly auto err_msg = "tag type " + last_id + " has " + - _uint.to_str(subpats_len, 10u) + + UInt.to_str(subpats_len, 10u) + " field(s), but this pattern has " + - _uint.to_str(arg_len, 10u) + + UInt.to_str(arg_len, 10u) + " field(s)"; fcx.ccx.sess.span_err(pat.span, err_msg); @@ -1653,13 +1653,13 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat { // Nullary variants have tag types. case (ty.ty_tag(?tid, _)) { - auto subpats_len = _vec.len[@ast.pat](subpats); + auto subpats_len = Vec.len[@ast.pat](subpats); if (subpats_len > 0u) { // TODO: pluralize properly auto err_msg = "tag type " + last_id + " has no field(s)," + " but this pattern has " + - _uint.to_str(subpats_len, 10u) + + UInt.to_str(subpats_len, 10u) + " field(s)"; fcx.ccx.sess.span_err(pat.span, err_msg); @@ -1689,7 +1689,7 @@ fn require_impure(&session.session sess, } fn get_function_purity(@crate_ctxt ccx, &ast.def_id d_id) -> ast.purity { - let option.t[ast.purity] o = ccx.fn_purity_table.find(d_id); + let Option.t[ast.purity] o = ccx.fn_purity_table.find(d_id); ret from_maybe[ast.purity](ast.impure_fn, o); } @@ -1738,16 +1738,16 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr { // A generic function to factor out common logic from call and bind // expressions. fn check_call_or_bind(&@fn_ctxt fcx, &@ast.expr f, - &vec[option.t[@ast.expr]] args) - -> tup(@ast.expr, vec[option.t[@ast.expr]]) { + &vec[Option.t[@ast.expr]] args) + -> tup(@ast.expr, vec[Option.t[@ast.expr]]) { // Check the function. auto f_0 = check_expr(fcx, f); // Check the arguments and generate the argument signature. - let vec[option.t[@ast.expr]] args_0 = vec(); + let vec[Option.t[@ast.expr]] args_0 = vec(); let vec[arg] arg_tys_0 = vec(); - for (option.t[@ast.expr] a_opt in args) { + for (Option.t[@ast.expr] a_opt in args) { alt (a_opt) { case (some[@ast.expr](?a)) { auto a_0 = check_expr(fcx, a); @@ -1756,14 +1756,14 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr { // FIXME: this breaks aliases. We need a ty_fn_arg. auto arg_ty = rec(mode=ast.val, ty=expr_ty(fcx.ccx.tcx, a_0)); - _vec.push[arg](arg_tys_0, arg_ty); + Vec.push[arg](arg_tys_0, arg_ty); } case (none[@ast.expr]) { args_0 += vec(none[@ast.expr]); // FIXME: breaks aliases too? auto typ = next_ty_var(fcx.ccx); - _vec.push[arg](arg_tys_0, rec(mode=ast.val, ty=typ)); + Vec.push[arg](arg_tys_0, rec(mode=ast.val, ty=typ)); } } } @@ -1812,7 +1812,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr { fn check_call(&@fn_ctxt fcx, @ast.expr f, vec[@ast.expr] args) -> tup(@ast.expr, vec[@ast.expr]) { - let vec[option.t[@ast.expr]] args_opt_0 = vec(); + let vec[Option.t[@ast.expr]] args_opt_0 = vec(); for (@ast.expr arg in args) { args_opt_0 += vec(some[@ast.expr](arg)); } @@ -1822,8 +1822,8 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr { // Pull out the arguments. let vec[@ast.expr] args_1 = vec(); - for (option.t[@ast.expr] arg in result._1) { - args_1 += vec(option.get[@ast.expr](arg)); + for (Option.t[@ast.expr] arg in result._1) { + args_1 += vec(Option.get[@ast.expr](arg)); } ret tup(result._0, args_1); @@ -1901,7 +1901,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr { case (ast.expr_path(?pth, ?defopt, _)) { auto t = ty.mk_nil(fcx.ccx.tcx); assert (defopt != none[ast.def]); - auto defn = option.get[ast.def](defopt); + auto defn = Option.get[ast.def](defopt); auto tpt = ty_param_count_and_ty_for_def(fcx, expr.span, defn); @@ -1913,7 +1913,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr { // The definition doesn't take type parameters. If the programmer // supplied some, that's an error. - if (_vec.len[@ast.ty](pth.node.types) > 0u) { + if (Vec.len[@ast.ty](pth.node.types) > 0u) { fcx.ccx.sess.span_err(expr.span, "this kind of value does " + "not take type parameters"); fail; @@ -2295,7 +2295,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr { // For each blank argument, add the type of that argument // to the resulting function type. auto i = 0u; - while (i < _vec.len[option.t[@ast.expr]](args)) { + while (i < Vec.len[Option.t[@ast.expr]](args)) { alt (args.(i)) { case (some[@ast.expr](_)) { /* no-op */ } case (none[@ast.expr]) { @@ -2434,7 +2434,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr { let vec[@ast.expr] args_1 = vec(); let ty.t t; - if (_vec.len[@ast.expr](args) == 0u) { + if (Vec.len[@ast.expr](args) == 0u) { t = next_ty_var(fcx.ccx); } else { auto expr_1 = check_expr(fcx, args.(0)); @@ -2445,7 +2445,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr { auto expr_1 = check_expr(fcx, e); auto expr_t = expr_ty(fcx.ccx.tcx, expr_1); Demand.simple(fcx, expr.span, t, expr_t); - _vec.push[@ast.expr](args_1,expr_1); + Vec.push[@ast.expr](args_1,expr_1); } auto ann = triv_ann(ty.mk_vec(fcx.ccx.tcx, @@ -2461,7 +2461,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr { for (ast.elt e in elts) { auto expr_1 = check_expr(fcx, e.expr); auto expr_t = expr_ty(fcx.ccx.tcx, expr_1); - _vec.push[ast.elt](elts_1, rec(expr=expr_1 with e)); + Vec.push[ast.elt](elts_1, rec(expr=expr_1 with e)); elts_mt += vec(rec(ty=expr_t, mut=e.mut)); } @@ -2486,10 +2486,10 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr { for (ast.field f in fields) { auto expr_1 = check_expr(fcx, f.expr); auto expr_t = expr_ty(fcx.ccx.tcx, expr_1); - _vec.push[ast.field](fields_1, rec(expr=expr_1 with f)); + Vec.push[ast.field](fields_1, rec(expr=expr_1 with f)); auto expr_mt = rec(ty=expr_t, mut=f.mut); - _vec.push[field](fields_t, rec(ident=f.ident, mt=expr_mt)); + Vec.push[field](fields_t, rec(ident=f.ident, mt=expr_mt)); } auto ann = ast.ann_none; @@ -2521,7 +2521,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr { for (ty.field f in fields_t) { auto found = false; for (ty.field bf in base_fields) { - if (_str.eq(f.ident, bf.ident)) { + if (Str.eq(f.ident, bf.ident)) { Demand.simple(fcx, expr.span, f.mt.ty, bf.mt.ty); found = true; @@ -2549,7 +2549,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr { case (ty.ty_tup(?args)) { let uint ix = ty.field_num(fcx.ccx.sess, expr.span, field); - if (ix >= _vec.len[ty.mt](args)) { + if (ix >= Vec.len[ty.mt](args)) { fcx.ccx.sess.span_err(expr.span, "bad index on tuple"); } @@ -2563,7 +2563,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr { case (ty.ty_rec(?fields)) { let uint ix = ty.field_idx(fcx.ccx.sess, expr.span, field, fields); - if (ix >= _vec.len[typeck.field](fields)) { + if (ix >= Vec.len[typeck.field](fields)) { fcx.ccx.sess.span_err(expr.span, "bad index on record"); } @@ -2577,7 +2577,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr { case (ty.ty_obj(?methods)) { let uint ix = ty.method_idx(fcx.ccx.sess, expr.span, field, methods); - if (ix >= _vec.len[typeck.method](methods)) { + if (ix >= Vec.len[typeck.method](methods)) { fcx.ccx.sess.span_err(expr.span, "bad index on obj"); } @@ -2775,7 +2775,7 @@ fn check_stmt(&@fn_ctxt fcx, &@ast.stmt stmt) -> @ast.stmt { fn check_block(&@fn_ctxt fcx, &ast.block block) -> ast.block { let vec[@ast.stmt] stmts = vec(); for (@ast.stmt s in block.node.stmts) { - _vec.push[@ast.stmt](stmts, check_stmt(fcx, s)); + Vec.push[@ast.stmt](stmts, check_stmt(fcx, s)); } auto expr = none[@ast.expr]; @@ -2900,7 +2900,7 @@ fn hash_unify_cache_entry(&unify_cache_entry uce) -> uint { h += h << 5u + ty.hash_ty(uce._1); auto i = 0u; - auto tys_len = _vec.len(uce._2); + auto tys_len = Vec.len(uce._2); while (i < tys_len) { h += h << 5u + ty.hash_ty(uce._2.(i)); i += 1u; @@ -2913,8 +2913,8 @@ fn eq_unify_cache_entry(&unify_cache_entry a, &unify_cache_entry b) -> bool { if (!ty.eq_ty(a._0, b._0) || !ty.eq_ty(a._1, b._1)) { ret false; } auto i = 0u; - auto tys_len = _vec.len(a._2); - if (_vec.len(b._2) != tys_len) { ret false; } + auto tys_len = Vec.len(a._2); + if (Vec.len(b._2) != tys_len) { ret false; } while (i < tys_len) { if (!ty.eq_ty(a._2.(i), b._2.(i))) { ret false; } @@ -2957,7 +2957,7 @@ fn check_crate(ty.ctxt tcx, @ast.crate crate) auto hasher = hash_unify_cache_entry; auto eqer = eq_unify_cache_entry; auto unify_cache = - map.mk_hashmap[unify_cache_entry,ty.Unify.result](hasher, eqer); + Map.mk_hashmap[unify_cache_entry,ty.Unify.result](hasher, eqer); auto fpt = mk_fn_purity_table(crate); // use a variation on Collect diff --git a/src/comp/middle/typestate_check.rs b/src/comp/middle/typestate_check.rs index e15c720a..e571fa21 100644 --- a/src/comp/middle/typestate_check.rs +++ b/src/comp/middle/typestate_check.rs @@ -155,37 +155,37 @@ import pretty.pprust.print_block; import pretty.pprust.print_expr; import pretty.pprust.print_decl; import pretty.pp.mkstate; -import std.io.stdout; -import std.io.str_writer; -import std.io.string_writer; -import std._vec.map; -import std._vec; -import std._vec.len; -import std._vec.pop; -import std._vec.push; -import std._vec.slice; -import std._vec.unzip; -import std._vec.plus_option; -import std._vec.cat_options; -import std.option; -import std.option.t; -import std.option.some; -import std.option.none; -import std.option.from_maybe; -import std.option.maybe; -import std.option.is_none; -import std.option.get; -import std.map.hashmap; -import std.list; -import std.list.list; -import std.list.cons; -import std.list.nil; -import std.list.foldl; -import std.list.find; -import std._uint; -import std.bitv; -import std.util.fst; -import std.util.snd; +import std.IO.stdout; +import std.IO.str_writer; +import std.IO.string_writer; +import std.Vec.map; +import std.Vec; +import std.Vec.len; +import std.Vec.pop; +import std.Vec.push; +import std.Vec.slice; +import std.Vec.unzip; +import std.Vec.plus_option; +import std.Vec.cat_options; +import std.Option; +import std.Option.t; +import std.Option.some; +import std.Option.none; +import std.Option.from_maybe; +import std.Option.maybe; +import std.Option.is_none; +import std.Option.get; +import std.Map.hashmap; +import std.List; +import std.List.list; +import std.List.cons; +import std.List.nil; +import std.List.foldl; +import std.List.find; +import std.UInt; +import std.BitV; +import std.Util.fst; +import std.Util.snd; import util.typestate_ann; import util.typestate_ann.difference; @@ -195,22 +195,22 @@ import util.typestate_ann.require_and_preserve; /**** debugging junk ****/ -fn bitv_to_str(fn_info enclosing, bitv.t v) -> str { +fn bitv_to_str(fn_info enclosing, BitV.t v) -> str { auto s = ""; for each (@tup(def_id, tup(uint, ident)) p in enclosing.items()) { - if (bitv.get(v, p._1._0)) { + if (BitV.get(v, p._1._0)) { s += " " + p._1._1 + " "; } } ret s; } -fn log_bitv(fn_info enclosing, bitv.t v) { +fn log_bitv(fn_info enclosing, BitV.t v) { log(bitv_to_str(enclosing, v)); } -fn log_bitv_err(fn_info enclosing, bitv.t v) { +fn log_bitv_err(fn_info enclosing, BitV.t v) { log_err(bitv_to_str(enclosing, v)); } @@ -235,8 +235,8 @@ fn log_cond_err(vec[uint] v) -> () { } fn log_pp(&pre_and_post pp) -> () { - auto p1 = bitv.to_vec(pp.precondition); - auto p2 = bitv.to_vec(pp.postcondition); + auto p1 = BitV.to_vec(pp.precondition); + auto p2 = BitV.to_vec(pp.postcondition); log("pre:"); log_cond(p1); log("post:"); @@ -244,8 +244,8 @@ fn log_pp(&pre_and_post pp) -> () { } fn log_pp_err(&pre_and_post pp) -> () { - auto p1 = bitv.to_vec(pp.precondition); - auto p2 = bitv.to_vec(pp.postcondition); + auto p1 = BitV.to_vec(pp.precondition); + auto p2 = BitV.to_vec(pp.postcondition); log_err("pre:"); log_cond_err(p1); log_err("post:"); @@ -253,8 +253,8 @@ fn log_pp_err(&pre_and_post pp) -> () { } fn log_states(&pre_and_post_state pp) -> () { - auto p1 = bitv.to_vec(pp.prestate); - auto p2 = bitv.to_vec(pp.poststate); + auto p1 = BitV.to_vec(pp.prestate); + auto p2 = BitV.to_vec(pp.poststate); log("prestate:"); log_cond(p1); log("poststate:"); @@ -262,8 +262,8 @@ fn log_states(&pre_and_post_state pp) -> () { } fn log_states_err(&pre_and_post_state pp) -> () { - auto p1 = bitv.to_vec(pp.prestate); - auto p2 = bitv.to_vec(pp.poststate); + auto p1 = BitV.to_vec(pp.prestate); + auto p2 = BitV.to_vec(pp.poststate); log_err("prestate:"); log_cond_err(p1); log_err("poststate:"); @@ -288,9 +288,9 @@ fn print_idents(vec[ident] idents) -> () { variable in a given function) to bit number (also remembers the ident for error-logging purposes) */ type var_info = tup(uint, ident); -type fn_info = std.map.hashmap[def_id, var_info]; +type fn_info = std.Map.hashmap[def_id, var_info]; /* mapping from function name to fn_info map */ -type fn_info_map = std.map.hashmap[def_id, fn_info]; +type fn_info_map = std.Map.hashmap[def_id, fn_info]; fn bit_num(def_id v, fn_info m) -> uint { assert (m.contains_key(v)); @@ -312,12 +312,12 @@ fn num_locals(fn_info m) -> uint { fn collect_local(&@vec[tup(ident, def_id)] vars, &span sp, @ast.local loc) -> @decl { log("collect_local: pushing " + loc.ident); - _vec.push[tup(ident, def_id)](*vars, tup(loc.ident, loc.id)); + Vec.push[tup(ident, def_id)](*vars, tup(loc.ident, loc.id)); ret @respan(sp, decl_local(loc)); } fn find_locals(_fn f) -> @vec[tup(ident,def_id)] { - auto res = @_vec.alloc[tup(ident,def_id)](0u); + auto res = @Vec.alloc[tup(ident,def_id)](0u); auto fld = fold.new_identity_fold[@vec[tup(ident, def_id)]](); fld = @rec(fold_decl_local = bind collect_local(_,_,_) with *fld); @@ -343,7 +343,7 @@ fn mk_fn_info(_fn f) -> fn_info { just collect locally declared vars */ let @vec[tup(ident,def_id)] locals = find_locals(f); - log(uistr(_vec.len[tup(ident, def_id)](*locals)) + " locals"); + log(uistr(Vec.len[tup(ident, def_id)](*locals)) + " locals"); for (tup(ident,def_id) p in *locals) { next = add_var(p._1, p._0, next, res); } @@ -364,7 +364,7 @@ fn mk_fn_info_item_fn(&fn_info_map fi, &span sp, ident i, &ast._fn f, function IDs to fn_info maps */ fn mk_fn_info_item_obj(&fn_info_map fi, &span sp, ident i, &ast._obj o, vec[ast.ty_param] ty_params, ast.obj_def_ids odid, ann a) -> @item { - auto all_methods = _vec.clone[@method](o.methods); + auto all_methods = Vec.clone[@method](o.methods); plus_option[@method](all_methods, o.dtor); for (@method m in all_methods) { fi.insert(m.node.id, mk_fn_info(m.node.meth)); @@ -403,7 +403,7 @@ fn ann_to_ts_ann(ann a, uint nv) -> ts_ann { } } -fn ann_to_ts_ann_fail(ann a) -> option.t[@ts_ann] { +fn ann_to_ts_ann_fail(ann a) -> Option.t[@ts_ann] { alt (a) { case (ann_none) { log("ann_to_ts_ann_fail: didn't expect ann_none here"); @@ -432,7 +432,7 @@ fn ann_to_poststate(ann a) -> poststate { ret (ann_to_ts_ann_fail_more(a)).states.poststate; } -fn stmt_to_ann(&stmt s) -> option.t[@ts_ann] { +fn stmt_to_ann(&stmt s) -> Option.t[@ts_ann] { alt (s.node) { case (stmt_decl(_,?a)) { ret ann_to_ts_ann_fail(a); @@ -652,7 +652,7 @@ fn seq_preconds(fn_info enclosing, vec[pre_and_post] pps) -> precond { /* works on either postconds or preconds should probably rethink the whole type synonym situation */ fn union_postconds_go(&postcond first, &vec[postcond] rest) -> postcond { - auto sz = _vec.len[postcond](rest); + auto sz = Vec.len[postcond](rest); if (sz > 0u) { auto other = rest.(0); @@ -665,7 +665,7 @@ fn union_postconds_go(&postcond first, &vec[postcond] rest) -> postcond { fn union_postconds(uint nv, &vec[postcond] pcs) -> postcond { if (len[postcond](pcs) > 0u) { - ret union_postconds_go(bitv.clone(pcs.(0)), pcs); + ret union_postconds_go(BitV.clone(pcs.(0)), pcs); } else { ret empty_prestate(nv); @@ -674,7 +674,7 @@ fn union_postconds(uint nv, &vec[postcond] pcs) -> postcond { /* Gee, maybe we could use foldl or something */ fn intersect_postconds_go(&postcond first, &vec[postcond] rest) -> postcond { - auto sz = _vec.len[postcond](rest); + auto sz = Vec.len[postcond](rest); if (sz > 0u) { auto other = rest.(0); @@ -689,7 +689,7 @@ fn intersect_postconds_go(&postcond first, &vec[postcond] rest) -> postcond { fn intersect_postconds(&vec[postcond] pcs) -> postcond { assert (len[postcond](pcs) > 0u); - ret intersect_postconds_go(bitv.clone(pcs.(0)), pcs); + ret intersect_postconds_go(BitV.clone(pcs.(0)), pcs); } /******* AST-traversing code ********/ @@ -720,8 +720,8 @@ fn find_pre_post_obj(&fn_info_map fm, _obj o) -> () { find_pre_post_fn(fm, fm.get(m.node.id), m.node.meth); } auto f = bind do_a_method(fm,_); - _vec.map[@method, ()](f, o.methods); - option.map[@method, ()](f, o.dtor); + Vec.map[@method, ()](f, o.methods); + Option.map[@method, ()](f, o.dtor); } fn find_pre_post_state_obj(fn_info_map fm, _obj o) -> bool { @@ -730,8 +730,8 @@ fn find_pre_post_state_obj(fn_info_map fm, _obj o) -> bool { ret find_pre_post_state_fn(fm, fm.get(m.node.id), m.node.meth); } auto f = bind do_a_method(fm,_); - auto flags = _vec.map[@method, bool](f, o.methods); - auto changed = _vec.or(flags); + auto flags = Vec.map[@method, bool](f, o.methods); + auto changed = Vec.or(flags); changed = changed || maybe[@method, bool](false, f, o.dtor); ret changed; } @@ -777,19 +777,19 @@ fn find_pre_post_exprs(&fn_info_map fm, &fn_info enclosing, } auto f = bind do_one(fm, enclosing, _); - _vec.map[@expr, ()](f, args); + Vec.map[@expr, ()](f, args); fn get_pp(&@expr e) -> pre_and_post { ret expr_pp(e); } auto g = get_pp; - auto pps = _vec.map[@expr, pre_and_post](g, args); + auto pps = Vec.map[@expr, pre_and_post](g, args); auto h = get_post; set_pre_and_post(a, rec(precondition=seq_preconds(enclosing, pps), postcondition=union_postconds - (nv, (_vec.map[pre_and_post, postcond](h, pps))))); + (nv, (Vec.map[pre_and_post, postcond](h, pps))))); } fn find_pre_post_loop(&fn_info_map fm, &fn_info enclosing, &@decl d, @@ -822,13 +822,13 @@ fn find_pre_post_expr(&fn_info_map fm, &fn_info enclosing, @expr e) -> () { alt (e.node) { case (expr_call(?operator, ?operands, ?a)) { - auto args = _vec.clone[@expr](operands); - _vec.push[@expr](args, operator); + auto args = Vec.clone[@expr](operands); + Vec.push[@expr](args, operator); find_pre_post_exprs(fm, enclosing, args, a); } case (expr_spawn(_, _, ?operator, ?operands, ?a)) { - auto args = _vec.clone[@expr](operands); - _vec.push[@expr](args, operator); + auto args = Vec.clone[@expr](operands); + Vec.push[@expr](args, operator); find_pre_post_exprs(fm, enclosing, args, a); } case (expr_vec(?args, _, ?a)) { @@ -888,7 +888,7 @@ fn find_pre_post_expr(&fn_info_map fm, &fn_info enclosing, @expr e) -> () { } case (expr_rec(?fields,?maybe_base,?a)) { auto es = field_exprs(fields); - _vec.plus_option[@expr](es, maybe_base); + Vec.plus_option[@expr](es, maybe_base); find_pre_post_exprs(fm, enclosing, es, a); } case (expr_assign(?lhs, ?rhs, ?a)) { @@ -1051,7 +1051,7 @@ fn find_pre_post_expr(&fn_info_map fm, &fn_info enclosing, @expr e) -> () { ret block_pp(an_alt.block); } auto f = bind do_an_alt(fm, enclosing, _); - auto alt_pps = _vec.map[arm, pre_and_post](f, alts); + auto alt_pps = Vec.map[arm, pre_and_post](f, alts); fn combine_pp(pre_and_post antec, fn_info enclosing, &pre_and_post pp, &pre_and_post next) -> pre_and_post { @@ -1065,7 +1065,7 @@ fn find_pre_post_expr(&fn_info_map fm, &fn_info enclosing, @expr e) -> () { postcondition=false_postcond(num_local_vars)); auto g = bind combine_pp(antec_pp, enclosing, _, _); - auto alts_overall_pp = _vec.foldl[pre_and_post, pre_and_post] + auto alts_overall_pp = Vec.foldl[pre_and_post, pre_and_post] (g, e_pp, alt_pps); set_pre_and_post(a, alts_overall_pp); @@ -1091,8 +1091,8 @@ fn find_pre_post_expr(&fn_info_map fm, &fn_info enclosing, @expr e) -> () { set_pre_and_post(a, expr_pp(p)); } case(expr_bind(?operator, ?maybe_args, ?a)) { - auto args = _vec.cat_options[@expr](maybe_args); - _vec.push[@expr](args, operator); /* ??? order of eval? */ + auto args = Vec.cat_options[@expr](maybe_args); + Vec.push[@expr](args, operator); /* ??? order of eval? */ find_pre_post_exprs(fm, enclosing, args, a); } case (expr_break(?a)) { @@ -1210,12 +1210,12 @@ fn find_pre_post_block(&fn_info_map fm, &fn_info enclosing, block b) } auto do_one = bind do_one_(fm, enclosing, _); - _vec.map[@stmt, ()](do_one, b.node.stmts); + Vec.map[@stmt, ()](do_one, b.node.stmts); fn do_inner_(fn_info_map fm, fn_info i, &@expr e) -> () { find_pre_post_expr(fm, i, e); } auto do_inner = bind do_inner_(fm, enclosing, _); - option.map[@expr, ()](do_inner, b.node.expr); + Option.map[@expr, ()](do_inner, b.node.expr); let vec[pre_and_post] pps = vec(); @@ -1223,20 +1223,20 @@ fn find_pre_post_block(&fn_info_map fm, &fn_info enclosing, block b) ret stmt_pp(*s); } auto f = get_pp_stmt; - pps += _vec.map[@stmt, pre_and_post](f, b.node.stmts); + pps += Vec.map[@stmt, pre_and_post](f, b.node.stmts); fn get_pp_expr(&@expr e) -> pre_and_post { ret expr_pp(e); } auto g = get_pp_expr; plus_option[pre_and_post](pps, - option.map[@expr, pre_and_post](g, b.node.expr)); + Option.map[@expr, pre_and_post](g, b.node.expr)); auto block_precond = seq_preconds(enclosing, pps); auto h = get_post; - auto postconds = _vec.map[pre_and_post, postcond](h, pps); + auto postconds = Vec.map[pre_and_post, postcond](h, pps); /* A block may be empty, so this next line ensures that the postconds vector is non-empty. */ - _vec.push[postcond](postconds, block_precond); + Vec.push[postcond](postconds, block_precond); auto block_postcond = empty_poststate(nv); /* conservative approximation */ if (! has_nonlocal_exits(b)) { @@ -1696,7 +1696,7 @@ fn find_pre_post_state_expr(&fn_info_map fm, &fn_info enclosing, changed = find_pre_post_state_expr(fm, enclosing, pres, e) || changed; auto e_post = expr_poststate(e); auto a_post; - if (_vec.len[arm](alts) > 0u) { + if (Vec.len[arm](alts) > 0u) { a_post = false_postcond(num_local_vars); for (arm an_alt in alts) { changed = find_pre_post_state_block(fm, enclosing, e_post, @@ -1775,9 +1775,9 @@ fn find_pre_post_state_stmt(&fn_info_map fm, &fn_info enclosing, log("*At beginning: stmt = "); log_stmt(*s); log("*prestate = "); - log(bitv.to_str(stmt_ann.states.prestate)); + log(BitV.to_str(stmt_ann.states.prestate)); log("*poststate ="); - log(bitv.to_str(stmt_ann.states.poststate)); + log(BitV.to_str(stmt_ann.states.poststate)); log("*changed ="); log(changed); @@ -1798,7 +1798,7 @@ fn find_pre_post_state_stmt(&fn_info_map fm, &fn_info enclosing, log("Summary: stmt = "); log_stmt(*s); log("prestate = "); - log(bitv.to_str(stmt_ann.states.prestate)); + log(BitV.to_str(stmt_ann.states.prestate)); log_bitv(enclosing, stmt_ann.states.prestate); log("poststate ="); log_bitv(enclosing, stmt_ann.states.poststate); @@ -1835,10 +1835,10 @@ fn find_pre_post_state_stmt(&fn_info_map fm, &fn_info enclosing, log("Summary: stmt = "); log_stmt(*s); log("prestate = "); - log(bitv.to_str(stmt_ann.states.prestate)); + log(BitV.to_str(stmt_ann.states.prestate)); log_bitv(enclosing, stmt_ann.states.prestate); log("poststate ="); - log(bitv.to_str(stmt_ann.states.poststate)); + log(BitV.to_str(stmt_ann.states.poststate)); log_bitv(enclosing, stmt_ann.states.poststate); log("changed ="); log(changed); @@ -1986,12 +1986,12 @@ fn check_states_against_conditions(fn_info enclosing, &ast._fn f) -> () { } auto do_one = bind do_one_(enclosing, _); - _vec.map[@stmt, ()](do_one, f.body.node.stmts); + Vec.map[@stmt, ()](do_one, f.body.node.stmts); fn do_inner_(fn_info i, &@expr e) -> () { check_states_expr(i, e); } auto do_inner = bind do_inner_(enclosing, _); - option.map[@expr, ()](do_inner, f.body.node.expr); + Option.map[@expr, ()](do_inner, f.body.node.expr); } @@ -2027,13 +2027,13 @@ fn check_method_states(&fn_info_map f_info_map, @method m) -> () { } fn check_obj_state(&fn_info_map f_info_map, vec[obj_field] fields, - vec[@method] methods, option.t[@method] dtor) -> ast._obj { + vec[@method] methods, Option.t[@method] dtor) -> ast._obj { fn one(fn_info_map fm, &@method m) -> () { ret check_method_states(fm, m); } auto f = bind one(f_info_map,_); - _vec.map[@method, ()](f, methods); - option.map[@method, ()](f, dtor); + Vec.map[@method, ()](f, methods); + Option.map[@method, ()](f, dtor); ret rec(fields=fields, methods=methods, dtor=dtor); } @@ -2122,7 +2122,7 @@ fn annotate_exprs(&fn_info_map fm, &vec[@expr] es) -> vec[@expr] { ret annotate_expr(fm, e); } auto f = bind one(fm,_); - ret _vec.map[@expr, @expr](f, es); + ret Vec.map[@expr, @expr](f, es); } fn annotate_elts(&fn_info_map fm, &vec[elt] es) -> vec[elt] { fn one(fn_info_map fm, &elt e) -> elt { @@ -2130,7 +2130,7 @@ fn annotate_elts(&fn_info_map fm, &vec[elt] es) -> vec[elt] { expr=annotate_expr(fm, e.expr)); } auto f = bind one(fm,_); - ret _vec.map[elt, elt](f, es); + ret Vec.map[elt, elt](f, es); } fn annotate_fields(&fn_info_map fm, &vec[field] fs) -> vec[field] { fn one(fn_info_map fm, &field f) -> field { @@ -2139,23 +2139,23 @@ fn annotate_fields(&fn_info_map fm, &vec[field] fs) -> vec[field] { expr=annotate_expr(fm, f.expr)); } auto f = bind one(fm,_); - ret _vec.map[field, field](f, fs); + ret Vec.map[field, field](f, fs); } -fn annotate_option_exp(&fn_info_map fm, &option.t[@expr] o) - -> option.t[@expr] { +fn annotate_option_exp(&fn_info_map fm, &Option.t[@expr] o) + -> Option.t[@expr] { fn one(fn_info_map fm, &@expr e) -> @expr { ret annotate_expr(fm, e); } auto f = bind one(fm,_); - ret option.map[@expr, @expr](f, o); + ret Option.map[@expr, @expr](f, o); } -fn annotate_option_exprs(&fn_info_map fm, &vec[option.t[@expr]] es) - -> vec[option.t[@expr]] { - fn one(fn_info_map fm, &option.t[@expr] o) -> option.t[@expr] { +fn annotate_option_exprs(&fn_info_map fm, &vec[Option.t[@expr]] es) + -> vec[Option.t[@expr]] { + fn one(fn_info_map fm, &Option.t[@expr] o) -> Option.t[@expr] { ret annotate_option_exp(fm, o); } auto f = bind one(fm,_); - ret _vec.map[option.t[@expr], option.t[@expr]](f, es); + ret Vec.map[Option.t[@expr], Option.t[@expr]](f, es); } fn annotate_decl(&fn_info_map fm, &@decl d) -> @decl { auto d1 = d.node; @@ -2163,7 +2163,7 @@ fn annotate_decl(&fn_info_map fm, &@decl d) -> @decl { case (decl_local(?l)) { alt(l.init) { case (some[initializer](?init)) { - let option.t[initializer] an_i = + let Option.t[initializer] an_i = some[initializer] (rec(expr=annotate_expr(fm, init.expr) with init)); @@ -2186,7 +2186,7 @@ fn annotate_alts(&fn_info_map fm, &vec[arm] alts) -> vec[arm] { index=a.index); } auto f = bind one(fm,_); - ret _vec.map[arm, arm](f, alts); + ret Vec.map[arm, arm](f, alts); } fn annotate_expr(&fn_info_map fm, &@expr e) -> @expr { @@ -2338,7 +2338,7 @@ fn annotate_block(&fn_info_map fm, &block b) -> block { for (@stmt s in b.node.stmts) { auto new_s = annotate_stmt(fm, s); - _vec.push[@stmt](new_stmts, new_s); + Vec.push[@stmt](new_stmts, new_s); ast.index_stmt(new_index, new_s); } fn ann_e(fn_info_map fm, &@expr e) -> @expr { @@ -2346,7 +2346,7 @@ fn annotate_block(&fn_info_map fm, &block b) -> block { } auto f = bind ann_e(fm,_); - auto new_e = option.map[@expr, @expr](f, b.node.expr); + auto new_e = Option.map[@expr, @expr](f, b.node.expr); ret respan(b.span, rec(stmts=new_stmts, expr=new_e, index=new_index with b.node)); @@ -2362,7 +2362,7 @@ fn annotate_mod(&fn_info_map fm, &ast._mod m) -> ast._mod { for (@item i in m.items) { auto new_i = annotate_item(fm, i); - _vec.push[@item](new_items, new_i); + Vec.push[@item](new_items, new_i); ast.index_item(new_index, new_i); } ret rec(items=new_items, index=new_index with m); @@ -2383,8 +2383,8 @@ fn annotate_obj(&fn_info_map fm, &ast._obj o) -> ast._obj { ret annotate_method(fm, m); } auto f = bind one(fm,_); - auto new_methods = _vec.map[@method, @method](f, o.methods); - auto new_dtor = option.map[@method, @method](f, o.dtor); + auto new_methods = Vec.map[@method, @method](f, o.methods); + auto new_dtor = Option.map[@method, @method](f, o.dtor); ret rec(methods=new_methods, dtor=new_dtor with o); } @@ -2476,7 +2476,7 @@ fn annotate_module(&fn_info_map fm, &ast._mod module) -> ast._mod { for (@item i in module.items) { auto new_item = annotate_item(fm, i); - _vec.push[@item](new_items, new_item); + Vec.push[@item](new_items, new_item); ast.index_item(new_index, new_item); } diff --git a/src/comp/middle/walk.rs b/src/comp/middle/walk.rs index 8a5d40dc..2df69261 100644 --- a/src/comp/middle/walk.rs +++ b/src/comp/middle/walk.rs @@ -1,8 +1,8 @@ import front.ast; -import std.option; -import std.option.some; -import std.option.none; +import std.Option; +import std.Option.some; +import std.Option.none; type ast_visitor = rec(fn () -> bool keep_going, @@ -257,7 +257,7 @@ fn walk_decl(&ast_visitor v, @ast.decl d) { v.visit_decl_post(d); } -fn walk_expr_opt(&ast_visitor v, option.t[@ast.expr] eo) { +fn walk_expr_opt(&ast_visitor v, Option.t[@ast.expr] eo) { alt (eo) { case (none[@ast.expr]) {} case (some[@ast.expr](?e)) { @@ -297,7 +297,7 @@ fn walk_expr(&ast_visitor v, @ast.expr e) { case (ast.expr_self_method(_, _)) { } case (ast.expr_bind(?callee, ?args, _)) { walk_expr(v, callee); - for (option.t[@ast.expr] eo in args) { + for (Option.t[@ast.expr] eo in args) { walk_expr_opt(v, eo); } } diff --git a/src/comp/pretty/pp.rs b/src/comp/pretty/pp.rs index 85651c78..f9667042 100644 --- a/src/comp/pretty/pp.rs +++ b/src/comp/pretty/pp.rs @@ -1,6 +1,6 @@ -import std.io; -import std._vec; -import std._str; +import std.IO; +import std.Vec; +import std.Str; tag boxtype {box_h; box_v; box_hv; box_align;} tag contexttype {cx_h; cx_v;} @@ -19,7 +19,7 @@ type context = rec(contexttype tp, uint indent); type ps = @rec(mutable vec[context] context, uint width, - io.writer out, + IO.writer out, mutable uint col, mutable uint spaces, mutable vec[token] buffered, @@ -30,7 +30,7 @@ type ps = @rec(mutable vec[context] context, mutable bool start_of_box, mutable bool potential_brk); -fn mkstate(io.writer out, uint width) -> ps { +fn mkstate(IO.writer out, uint width) -> ps { let vec[context] stack = vec(rec(tp=cx_v, indent=0u)); let vec[token] buff = vec(); let vec[boxtype] sd = vec(); @@ -57,12 +57,12 @@ fn write_spaces(ps p, uint i) { fn push_context(ps p, contexttype tp, uint indent) { before_print(p, false); - _vec.push[context](p.context, rec(tp=tp, indent=indent)); + Vec.push[context](p.context, rec(tp=tp, indent=indent)); p.start_of_box = true; } fn pop_context(ps p) { - _vec.pop[context](p.context); + Vec.pop[context](p.context); } fn add_token(ps p, token tok) { @@ -89,7 +89,7 @@ fn buffer_token(ps p, token tok) { } else { alt (tok) { case (open(?tp,_)) { - _vec.push[boxtype](p.scandepth, tp); + Vec.push[boxtype](p.scandepth, tp); if (p.scanning == scan_h) { if (tp == box_h) { check_potential_brk(p); @@ -97,14 +97,14 @@ fn buffer_token(ps p, token tok) { } } case (close) { - _vec.pop[boxtype](p.scandepth); - if (_vec.len[boxtype](p.scandepth) == 0u) { + Vec.pop[boxtype](p.scandepth); + if (Vec.len[boxtype](p.scandepth) == 0u) { finish_scan(p, true); } } case (brk(_)) { if (p.scanning == scan_h) { - if (p.scandepth.(_vec.len[boxtype](p.scandepth)-1u) == box_v) { + if (p.scandepth.(Vec.len[boxtype](p.scandepth)-1u) == box_v) { finish_scan(p, true); } } @@ -123,7 +123,7 @@ fn check_potential_brk(ps p) { fn finish_scan(ps p, bool fits) { auto buf = p.buffered; - auto front = _vec.shift[token](buf); + auto front = Vec.shift[token](buf); auto chosen_tp = cx_h; if (!fits) {chosen_tp = cx_v;} alt (front) { @@ -154,10 +154,10 @@ fn start_scan(ps p, token tok, scantype tp) { } fn cur_context(ps p) -> context { - ret p.context.(_vec.len[context](p.context)-1u); + ret p.context.(Vec.len[context](p.context)-1u); } fn base_indent(ps p) -> uint { - auto i = _vec.len[context](p.context); + auto i = Vec.len[context](p.context); while (i > 0u) { i -= 1u; auto cx = p.context.(i); @@ -190,7 +190,7 @@ fn do_token(ps p, token tok) { line_break(p); } case (word(?w)) { - auto len = _str.char_len(w); + auto len = Str.char_len(w); if (len + p.col + p.spaces > p.width && !start_of_box && !p.start_of_line) { line_break(p); @@ -202,7 +202,7 @@ fn do_token(ps p, token tok) { case (cword(?w)) { before_print(p, true); p.out.write_str(w); - p.col += _str.char_len(w); + p.col += Str.char_len(w); } case (open(?tp, ?indent)) { if (tp == box_v) { @@ -247,8 +247,8 @@ fn token_size(token tok) -> uint { alt (tok) { case (brk(?sz)) {ret sz;} case (hardbrk) {ret 0xFFFFFFu;} - case (word(?w)) {ret _str.char_len(w);} - case (cword(?w)) {ret _str.char_len(w);} + case (word(?w)) {ret Str.char_len(w);} + case (cword(?w)) {ret Str.char_len(w);} case (open(_, _)) {ret 0u;} case (close) {ret 0u;} } diff --git a/src/comp/pretty/pprust.rs b/src/comp/pretty/pprust.rs index 3111b012..17547bb6 100644 --- a/src/comp/pretty/pprust.rs +++ b/src/comp/pretty/pprust.rs @@ -1,7 +1,7 @@ -import std._vec; -import std._str; -import std.io; -import std.option; +import std.Vec; +import std.Str; +import std.IO; +import std.Option; import front.ast; import front.lexer; import util.common; @@ -12,39 +12,39 @@ const int as_prec = 5; const uint default_columns = 78u; type ps = @rec(pp.ps s, - option.t[vec[lexer.cmnt]] comments, + Option.t[vec[lexer.cmnt]] comments, mutable uint cur_cmnt); -fn print_file(ast._mod _mod, str filename, io.writer out) { +fn print_file(ast._mod _mod, str filename, IO.writer out) { auto cmnts = lexer.gather_comments(filename); auto s = @rec(s=pp.mkstate(out, default_columns), - comments=option.some[vec[lexer.cmnt]](cmnts), + comments=Option.some[vec[lexer.cmnt]](cmnts), mutable cur_cmnt=0u); print_mod(s, _mod); } fn ty_to_str(&@ast.ty ty) -> str { - auto writer = io.string_writer(); + auto writer = IO.string_writer(); auto s = @rec(s=pp.mkstate(writer.get_writer(), 0u), - comments=option.none[vec[lexer.cmnt]], + comments=Option.none[vec[lexer.cmnt]], mutable cur_cmnt=0u); print_type(s, ty); ret writer.get_str(); } fn block_to_str(&ast.block blk) -> str { - auto writer = io.string_writer(); + auto writer = IO.string_writer(); auto s = @rec(s=pp.mkstate(writer.get_writer(), 78u), - comments=option.none[vec[lexer.cmnt]], + comments=Option.none[vec[lexer.cmnt]], mutable cur_cmnt=0u); print_block(s, blk); ret writer.get_str(); } fn pat_to_str(&@ast.pat p) -> str { - auto writer = io.string_writer(); + auto writer = IO.string_writer(); auto s = @rec(s=pp.mkstate(writer.get_writer(), 78u), - comments=option.none[vec[lexer.cmnt]], + comments=Option.none[vec[lexer.cmnt]], mutable cur_cmnt=0u); print_pat(s, p); ret writer.get_str(); @@ -92,7 +92,7 @@ fn commasep[IN](ps s, vec[IN] elts, fn(ps, &IN) op) { } fn commasep_cmnt[IN](ps s, vec[IN] elts, fn(ps, &IN) op, fn(&IN) -> common.span get_span) { - auto len = _vec.len[IN](elts); + auto len = Vec.len[IN](elts); auto i = 0u; for (IN elt in elts) { op(s, elt); @@ -160,7 +160,7 @@ fn print_type(ps s, &@ast.ty ty) { fn get_span(&ast.ty_field f) -> common.span { // Try to reconstruct the span for this field auto sp = f.mt.ty.span; - auto hi = sp.hi + _str.char_len(f.ident) + 1u; + auto hi = sp.hi + Str.char_len(f.ident) + 1u; ret rec(hi=hi with sp); } auto f = print_field; @@ -173,7 +173,7 @@ fn print_type(ps s, &@ast.ty ty) { bopen(s); for (ast.ty_method m in methods) { hbox(s); - print_ty_fn(s, m.proto, option.some[str](m.ident), + print_ty_fn(s, m.proto, Option.some[str](m.ident), m.inputs, m.output); wrd(s.s, ";"); end(s.s); @@ -182,7 +182,7 @@ fn print_type(ps s, &@ast.ty ty) { bclose_c(s, ty.span); } case (ast.ty_fn(?proto,?inputs,?output)) { - print_ty_fn(s, proto, option.none[str], inputs, output); + print_ty_fn(s, proto, Option.none[str], inputs, output); } case (ast.ty_path(?path,_)) { print_path(s, path); @@ -240,8 +240,8 @@ fn print_item(ps s, @ast.item item) { ?typarams,_,_)) { print_fn(s, decl, id, typarams); alt (lname) { - case (option.none[str]) {} - case (option.some[str](?ss)) { + case (Option.none[str]) {} + case (Option.some[str](?ss)) { print_string(s, ss); } } @@ -270,7 +270,7 @@ fn print_item(ps s, @ast.item item) { for (ast.variant v in variants) { maybe_print_comment(s, v.span.lo); wrd(s.s, v.node.name); - if (_vec.len[ast.variant_arg](v.node.args) > 0u) { + if (Vec.len[ast.variant_arg](v.node.args) > 0u) { popen(s); fn print_variant_arg(ps s, &ast.variant_arg arg) { print_type(s, arg.ty); @@ -314,7 +314,7 @@ fn print_item(ps s, @ast.item item) { line(s.s); } alt (_obj.dtor) { - case (option.some[@ast.method](?dtor)) { + case (Option.some[@ast.method](?dtor)) { hbox(s); wrd1(s, "close"); print_block(s, dtor.node.meth.body); @@ -344,7 +344,7 @@ fn print_block(ps s, ast.block blk) { if (!maybe_print_line_comment(s, st.span)) {line(s.s);} } alt (blk.node.expr) { - case (option.some[@ast.expr](?expr)) { + case (Option.some[@ast.expr](?expr)) { print_expr(s, expr); if (!maybe_print_line_comment(s, expr.span)) {line(s.s);} } @@ -358,7 +358,7 @@ fn print_literal(ps s, @ast.lit lit) { alt (lit.node) { case (ast.lit_str(?st)) {print_string(s, st);} case (ast.lit_char(?ch)) { - wrd(s.s, "'" + escape_str(_str.from_bytes(vec(ch as u8)), '\'') + wrd(s.s, "'" + escape_str(Str.from_bytes(vec(ch as u8)), '\'') + "'"); } case (ast.lit_int(?val)) { @@ -432,8 +432,8 @@ fn print_expr(ps s, &@ast.expr expr) { auto gs = get_span; commasep_cmnt[ast.field](s, fields, f, gs); alt (wth) { - case (option.some[@ast.expr](?expr)) { - if (_vec.len[ast.field](fields) > 0u) {space(s.s);} + case (Option.some[@ast.expr](?expr)) { + if (Vec.len[ast.field](fields) > 0u) {space(s.s);} hbox(s); wrd1(s, "with"); print_expr(s, expr); @@ -454,9 +454,9 @@ fn print_expr(ps s, &@ast.expr expr) { print_ident(s, ident); } case (ast.expr_bind(?func,?args,_)) { - fn print_opt(ps s, &option.t[@ast.expr] expr) { + fn print_opt(ps s, &Option.t[@ast.expr] expr) { alt (expr) { - case (option.some[@ast.expr](?expr)) { + case (Option.some[@ast.expr](?expr)) { print_expr(s, expr); } case (_) {wrd(s.s, "_");} @@ -466,7 +466,7 @@ fn print_expr(ps s, &@ast.expr expr) { print_expr(s, func); popen(s); auto f = print_opt; - commasep[option.t[@ast.expr]](s, args, f); + commasep[Option.t[@ast.expr]](s, args, f); pclose(s); } case (ast.expr_spawn(_,_,?e,?es,_)) { @@ -504,7 +504,7 @@ fn print_expr(ps s, &@ast.expr expr) { space(s.s); print_block(s, block); alt (elseopt) { - case (option.some[@ast.expr](?_else)) { + case (Option.some[@ast.expr](?_else)) { space(s.s); wrd1(s, "else"); print_expr(s, _else); @@ -627,7 +627,7 @@ fn print_expr(ps s, &@ast.expr expr) { case (ast.expr_ret(?result,_)) { wrd(s.s, "ret"); alt (result) { - case (option.some[@ast.expr](?expr)) { + case (Option.some[@ast.expr](?expr)) { space(s.s); print_expr(s, expr); } @@ -637,7 +637,7 @@ fn print_expr(ps s, &@ast.expr expr) { case (ast.expr_put(?result,_)) { wrd(s.s, "put"); alt (result) { - case (option.some[@ast.expr](?expr)) { + case (Option.some[@ast.expr](?expr)) { space(s.s); print_expr(s, expr); } @@ -670,7 +670,7 @@ fn print_expr(ps s, &@ast.expr expr) { case (ast.expr_ext(?path, ?args, ?body, _, _)) { wrd(s.s, "#"); print_path(s, path); - if (_vec.len[@ast.expr](args) > 0u) { + if (Vec.len[@ast.expr](args) > 0u) { popen(s); commasep_exprs(s, args); pclose(s); @@ -698,7 +698,7 @@ fn print_decl(ps s, @ast.decl decl) { alt (decl.node) { case (ast.decl_local(?loc)) { alt (loc.ty) { - case (option.some[@ast.ty](?ty)) { + case (Option.some[@ast.ty](?ty)) { wrd1(s, "let"); print_type(s, ty); space(s.s); @@ -709,7 +709,7 @@ fn print_decl(ps s, @ast.decl decl) { } wrd(s.s, loc.ident); alt (loc.init) { - case (option.some[ast.initializer](?init)) { + case (Option.some[ast.initializer](?init)) { space(s.s); alt (init.op) { case (ast.init_assign) { @@ -738,7 +738,7 @@ fn print_ident(ps s, ast.ident ident) { fn print_for_decl(ps s, @ast.decl decl) { alt (decl.node) { case (ast.decl_local(?loc)) { - print_type(s, option.get[@ast.ty](loc.ty)); + print_type(s, Option.get[@ast.ty](loc.ty)); space(s.s); wrd(s.s, loc.ident); } @@ -753,7 +753,7 @@ fn print_path(ps s, ast.path path) { else {wrd(s.s, ".");} wrd(s.s, id); } - if (_vec.len[@ast.ty](path.node.types) > 0u) { + if (Vec.len[@ast.ty](path.node.types) > 0u) { wrd(s.s, "["); auto f = print_type; commasep[@ast.ty](s, path.node.types, f); @@ -769,7 +769,7 @@ fn print_pat(ps s, &@ast.pat pat) { case (ast.pat_lit(?lit,_)) {print_literal(s, lit);} case (ast.pat_tag(?path,?args,_,_)) { print_path(s, path); - if (_vec.len[@ast.pat](args) > 0u) { + if (Vec.len[@ast.pat](args) > 0u) { popen_h(s); auto f = print_pat; commasep[@ast.pat](s, args, f); @@ -814,7 +814,7 @@ fn print_fn(ps s, ast.fn_decl decl, str name, } fn print_type_params(ps s, vec[ast.ty_param] params) { - if (_vec.len[ast.ty_param](params) > 0u) { + if (Vec.len[ast.ty_param](params) > 0u) { wrd(s.s, "["); fn printParam(ps s, &ast.ty_param param) { wrd(s.s, param); @@ -832,7 +832,7 @@ fn print_view_item(ps s, @ast.view_item item) { case (ast.view_item_use(?id,?mta,_,_)) { wrd1(s, "use"); wrd(s.s, id); - if (_vec.len[@ast.meta_item](mta) > 0u) { + if (Vec.len[@ast.meta_item](mta) > 0u) { popen(s); fn print_meta(ps s, &@ast.meta_item item) { hbox(s); @@ -848,7 +848,7 @@ fn print_view_item(ps s, @ast.view_item item) { } case (ast.view_item_import(?id,?ids,_,_)) { wrd1(s, "import"); - if (!_str.eq(id, ids.(_vec.len[str](ids)-1u))) { + if (!Str.eq(id, ids.(Vec.len[str](ids)-1u))) { wrd1(s, id); wrd1(s, "="); } @@ -898,7 +898,7 @@ fn print_maybe_parens(ps s, @ast.expr expr, int outer_prec) { fn escape_str(str st, char to_escape) -> str { let str out = ""; - auto len = _str.byte_len(st); + auto len = Str.byte_len(st); auto i = 0u; while (i < len) { alt (st.(i) as char) { @@ -908,7 +908,7 @@ fn escape_str(str st, char to_escape) -> str { case ('\\') {out += "\\\\";} case (?cur) { if (cur == to_escape) {out += "\\";} - _str.push_byte(out, cur as u8); + Str.push_byte(out, cur as u8); } } i += 1u; @@ -929,12 +929,12 @@ fn print_string(ps s, str st) { wrd(s.s, "\""); wrd(s.s, escape_str(st, '"')); wrd(s.s, "\""); } -fn print_ty_fn(ps s, ast.proto proto, option.t[str] id, +fn print_ty_fn(ps s, ast.proto proto, Option.t[str] id, vec[ast.ty_arg] inputs, @ast.ty output) { if (proto == ast.proto_fn) {wrd(s.s, "fn");} else {wrd(s.s, "iter");} alt (id) { - case (option.some[str](?id)) {space(s.s); wrd(s.s, id);} + case (Option.some[str](?id)) {space(s.s); wrd(s.s, id);} case (_) {} } popen_h(s); @@ -955,21 +955,21 @@ fn print_ty_fn(ps s, ast.proto proto, option.t[str] id, } } -fn next_comment(ps s) -> option.t[lexer.cmnt] { +fn next_comment(ps s) -> Option.t[lexer.cmnt] { alt (s.comments) { - case (option.some[vec[lexer.cmnt]](?cmnts)) { - if (s.cur_cmnt < _vec.len[lexer.cmnt](cmnts)) { - ret option.some[lexer.cmnt](cmnts.(s.cur_cmnt)); - } else {ret option.none[lexer.cmnt];} + case (Option.some[vec[lexer.cmnt]](?cmnts)) { + if (s.cur_cmnt < Vec.len[lexer.cmnt](cmnts)) { + ret Option.some[lexer.cmnt](cmnts.(s.cur_cmnt)); + } else {ret Option.none[lexer.cmnt];} } - case (_) {ret option.none[lexer.cmnt];} + case (_) {ret Option.none[lexer.cmnt];} } } fn maybe_print_comment(ps s, uint pos) { while (true) { alt (next_comment(s)) { - case (option.some[lexer.cmnt](?cmnt)) { + case (Option.some[lexer.cmnt](?cmnt)) { if (cmnt.pos < pos) { print_comment(s, cmnt.val); if (cmnt.space_after) {line(s.s);} @@ -983,7 +983,7 @@ fn maybe_print_comment(ps s, uint pos) { fn maybe_print_line_comment(ps s, common.span span) -> bool { alt (next_comment(s)) { - case (option.some[lexer.cmnt](?cmnt)) { + case (Option.some[lexer.cmnt](?cmnt)) { if (span.hi + 4u >= cmnt.pos) { wrd(s.s, " "); print_comment(s, cmnt.val); @@ -999,7 +999,7 @@ fn maybe_print_line_comment(ps s, common.span span) -> bool { fn print_remaining_comments(ps s) { while (true) { alt (next_comment(s)) { - case (option.some[lexer.cmnt](?cmnt)) { + case (Option.some[lexer.cmnt](?cmnt)) { print_comment(s, cmnt.val); if (cmnt.space_after) {line(s.s);} s.cur_cmnt += 1u; diff --git a/src/comp/util/common.rs b/src/comp/util/common.rs index b736b048..b1a39893 100644 --- a/src/comp/util/common.rs +++ b/src/comp/util/common.rs @@ -1,18 +1,18 @@ -import std.map; -import std.map.hashmap; -import std._uint; -import std._int; -import std._vec; -import std.option.none; +import std.Map; +import std.Map.hashmap; +import std.UInt; +import std.Int; +import std.Vec; +import std.Option.none; import front.ast; import util.typestate_ann.ts_ann; import middle.fold; import middle.fold.respan; -import std.io.stdout; -import std.io.str_writer; -import std.io.string_writer; +import std.IO.stdout; +import std.IO.str_writer; +import std.IO.string_writer; import pretty.pprust.print_block; import pretty.pprust.print_expr; import pretty.pprust.print_decl; @@ -56,10 +56,10 @@ fn ty_mach_to_str(ty_mach tm) -> str { } } -fn new_str_hash[V]() -> std.map.hashmap[str,V] { - let std.map.hashfn[str] hasher = std._str.hash; - let std.map.eqfn[str] eqer = std._str.eq; - ret std.map.mk_hashmap[str,V](hasher, eqer); +fn new_str_hash[V]() -> std.Map.hashmap[str,V] { + let std.Map.hashfn[str] hasher = std.Str.hash; + let std.Map.eqfn[str] eqer = std.Str.eq; + ret std.Map.mk_hashmap[str,V](hasher, eqer); } fn def_eq(&ast.def_id a, &ast.def_id b) -> bool { @@ -73,48 +73,48 @@ fn hash_def(&ast.def_id d) -> uint { ret h; } -fn new_def_hash[V]() -> std.map.hashmap[ast.def_id,V] { - let std.map.hashfn[ast.def_id] hasher = hash_def; - let std.map.eqfn[ast.def_id] eqer = def_eq; - ret std.map.mk_hashmap[ast.def_id,V](hasher, eqer); +fn new_def_hash[V]() -> std.Map.hashmap[ast.def_id,V] { + let std.Map.hashfn[ast.def_id] hasher = hash_def; + let std.Map.eqfn[ast.def_id] eqer = def_eq; + ret std.Map.mk_hashmap[ast.def_id,V](hasher, eqer); } -fn new_int_hash[V]() -> std.map.hashmap[int,V] { +fn new_int_hash[V]() -> std.Map.hashmap[int,V] { fn hash_int(&int x) -> uint { ret x as uint; } fn eq_int(&int a, &int b) -> bool { ret a == b; } auto hasher = hash_int; auto eqer = eq_int; - ret std.map.mk_hashmap[int,V](hasher, eqer); + ret std.Map.mk_hashmap[int,V](hasher, eqer); } -fn new_uint_hash[V]() -> std.map.hashmap[uint,V] { +fn new_uint_hash[V]() -> std.Map.hashmap[uint,V] { fn hash_uint(&uint x) -> uint { ret x; } fn eq_uint(&uint a, &uint b) -> bool { ret a == b; } auto hasher = hash_uint; auto eqer = eq_uint; - ret std.map.mk_hashmap[uint,V](hasher, eqer); + ret std.Map.mk_hashmap[uint,V](hasher, eqer); } fn istr(int i) -> str { - ret _int.to_str(i, 10u); + ret Int.to_str(i, 10u); } fn uistr(uint i) -> str { - ret _uint.to_str(i, 10u); + ret UInt.to_str(i, 10u); } fn elt_expr(&ast.elt e) -> @ast.expr { ret e.expr; } fn elt_exprs(&vec[ast.elt] elts) -> vec[@ast.expr] { auto f = elt_expr; - ret _vec.map[ast.elt, @ast.expr](f, elts); + ret Vec.map[ast.elt, @ast.expr](f, elts); } fn field_expr(&ast.field f) -> @ast.expr { ret f.expr; } fn field_exprs(vec[ast.field] fields) -> vec [@ast.expr] { auto f = field_expr; - ret _vec.map[ast.field, @ast.expr](f, fields); + ret Vec.map[ast.field, @ast.expr](f, fields); } fn plain_ann(middle.ty.ctxt tcx) -> ast.ann { diff --git a/src/comp/util/typestate_ann.rs b/src/comp/util/typestate_ann.rs index 9e815b46..949eaeb2 100644 --- a/src/comp/util/typestate_ann.rs +++ b/src/comp/util/typestate_ann.rs @@ -1,21 +1,21 @@ import front.ast.ident; -import std._vec; -import std.bitv; +import std.Vec; +import std.BitV; /* This says: this expression requires the idents in <pre> to be initialized, and given the precondition, it guarantees that the idents in <post> are initialized. */ -type precond = bitv.t; /* 1 means "this variable must be initialized" +type precond = BitV.t; /* 1 means "this variable must be initialized" 0 means "don't care about this variable" */ -type postcond = bitv.t; /* 1 means "this variable is initialized" +type postcond = BitV.t; /* 1 means "this variable is initialized" 0 means "don't know about this variable */ -type prestate = bitv.t; /* 1 means "this variable is definitely initialized" +type prestate = BitV.t; /* 1 means "this variable is definitely initialized" 0 means "don't know whether this variable is initialized" */ -type poststate = bitv.t; /* 1 means "this variable is definitely initialized" +type poststate = BitV.t; /* 1 means "this variable is definitely initialized" 0 means "don't know whether this variable is initialized" */ @@ -29,7 +29,7 @@ type pre_and_post_state = rec(prestate prestate, poststate poststate); type ts_ann = rec(pre_and_post conditions, pre_and_post_state states); fn true_precond(uint num_vars) -> precond { - be bitv.create(num_vars, false); + be BitV.create(num_vars, false); } fn true_postcond(uint num_vars) -> postcond { @@ -45,7 +45,7 @@ fn empty_poststate(uint num_vars) -> poststate { } fn false_postcond(uint num_vars) -> postcond { - be bitv.create(num_vars, true); + be BitV.create(num_vars, true); } fn empty_pre_post(uint num_vars) -> pre_and_post { @@ -72,15 +72,15 @@ fn get_post(&pre_and_post p) -> postcond { } fn difference(&precond p1, &precond p2) -> bool { - be bitv.difference(p1, p2); + be BitV.difference(p1, p2); } fn union(&precond p1, &precond p2) -> bool { - be bitv.union(p1, p2); + be BitV.union(p1, p2); } fn intersect(&precond p1, &precond p2) -> bool { - be bitv.intersect(p1, p2); + be BitV.intersect(p1, p2); } fn pps_len(&pre_and_post p) -> uint { @@ -91,62 +91,62 @@ fn pps_len(&pre_and_post p) -> uint { fn require_and_preserve(uint i, &pre_and_post p) -> () { // sets the ith bit in p's pre and post - bitv.set(p.precondition, i, true); - bitv.set(p.postcondition, i, true); + BitV.set(p.precondition, i, true); + BitV.set(p.postcondition, i, true); } fn set_in_postcond(uint i, &pre_and_post p) -> bool { // sets the ith bit in p's post - auto was_set = bitv.get(p.postcondition, i); - bitv.set(p.postcondition, i, true); + auto was_set = BitV.get(p.postcondition, i); + BitV.set(p.postcondition, i, true); ret !was_set; } fn set_in_poststate(uint i, &pre_and_post_state s) -> bool { // sets the ith bit in p's post - auto was_set = bitv.get(s.poststate, i); - bitv.set(s.poststate, i, true); + auto was_set = BitV.get(s.poststate, i); + BitV.set(s.poststate, i, true); ret !was_set; } // Sets all the bits in a's precondition to equal the // corresponding bit in p's precondition. fn set_precondition(&ts_ann a, &precond p) -> () { - bitv.copy(a.conditions.precondition, p); + BitV.copy(a.conditions.precondition, p); } // Sets all the bits in a's postcondition to equal the // corresponding bit in p's postcondition. fn set_postcondition(&ts_ann a, &postcond p) -> () { - bitv.copy(a.conditions.postcondition, p); + BitV.copy(a.conditions.postcondition, p); } // Sets all the bits in a's prestate to equal the // corresponding bit in p's prestate. fn set_prestate(@ts_ann a, &prestate p) -> bool { - ret bitv.copy(a.states.prestate, p); + ret BitV.copy(a.states.prestate, p); } // Sets all the bits in a's postcondition to equal the // corresponding bit in p's postcondition. fn set_poststate(@ts_ann a, &poststate p) -> bool { - ret bitv.copy(a.states.poststate, p); + ret BitV.copy(a.states.poststate, p); } // Set all the bits in p that are set in new fn extend_prestate(&prestate p, &poststate new) -> bool { - ret bitv.union(p, new); + ret BitV.union(p, new); } // Set all the bits in p that are set in new fn extend_poststate(&poststate p, &poststate new) -> bool { - ret bitv.union(p, new); + ret BitV.union(p, new); } // Clears the given bit in p fn relax_prestate(uint i, &prestate p) -> bool { - auto was_set = bitv.get(p, i); - bitv.set(p, i, false); + auto was_set = BitV.get(p, i); + BitV.set(p, i, false); ret was_set; } @@ -164,16 +164,16 @@ fn pp_clone(&pre_and_post p) -> pre_and_post { } fn clone(prestate p) -> prestate { - ret bitv.clone(p); + ret BitV.clone(p); } // returns true if a implies b // that is, returns true except if for some bits c and d, // c = 1 and d = 0 -fn implies(bitv.t a, bitv.t b) -> bool { - auto tmp = bitv.clone(b); - bitv.difference(tmp, a); - ret bitv.is_false(tmp); +fn implies(BitV.t a, BitV.t b) -> bool { + auto tmp = BitV.clone(b); + BitV.difference(tmp, a); + ret BitV.is_false(tmp); } // diff --git a/src/lib/bitv.rs b/src/lib/BitV.rs index 1002abc8..b0a4c9ea 100644 --- a/src/lib/bitv.rs +++ b/src/lib/BitV.rs @@ -21,19 +21,19 @@ fn create(uint nbits, bool init) -> t { elt = 0u; } - auto storage = _vec.init_elt_mut[uint](elt, nbits / uint_bits() + 1u); + auto storage = Vec.init_elt_mut[uint](elt, nbits / uint_bits() + 1u); ret rec(storage = storage, nbits = nbits); } fn process(&fn(uint, uint) -> uint op, &t v0, &t v1) -> bool { - auto len = _vec.len(v1.storage); + auto len = Vec.len(v1.storage); - assert (_vec.len(v0.storage) == len); + assert (Vec.len(v0.storage) == len); assert (v0.nbits == v1.nbits); auto changed = false; - for each (uint i in _uint.range(0u, len)) { + for each (uint i in UInt.range(0u, len)) { auto w0 = v0.storage.(i); auto w1 = v1.storage.(i); @@ -75,9 +75,9 @@ fn copy(&t v0, t v1) -> bool { } fn clone(t v) -> t { - auto storage = _vec.init_elt_mut[uint](0u, v.nbits / uint_bits() + 1u); - auto len = _vec.len(v.storage); - for each (uint i in _uint.range(0u, len)) { + auto storage = Vec.init_elt_mut[uint](0u, v.nbits / uint_bits() + 1u); + auto len = Vec.len(v.storage); + for each (uint i in UInt.range(0u, len)) { storage.(i) = v.storage.(i); } ret rec(storage = storage, nbits = v.nbits); @@ -97,7 +97,7 @@ fn get(&t v, uint i) -> bool { fn equal(&t v0, &t v1) -> bool { // FIXME: when we can break or return from inside an iterator loop, // we can eliminate this painful while-loop - auto len = _vec.len(v1.storage); + auto len = Vec.len(v1.storage); auto i = 0u; while (i < len) { if (v0.storage.(i) != v1.storage.(i)) { @@ -109,13 +109,13 @@ fn equal(&t v0, &t v1) -> bool { } fn clear(&t v) { - for each (uint i in _uint.range(0u, _vec.len(v.storage))) { + for each (uint i in UInt.range(0u, Vec.len(v.storage))) { v.storage.(i) = 0u; } } fn invert(&t v) { - for each (uint i in _uint.range(0u, _vec.len(v.storage))) { + for each (uint i in UInt.range(0u, Vec.len(v.storage))) { v.storage.(i) = ~v.storage.(i); } } @@ -176,13 +176,13 @@ fn init_to_vec(t v, uint i) -> uint { fn to_vec(&t v) -> vec[uint] { auto sub = bind init_to_vec(v, _); - ret _vec.init_fn[uint](sub, v.nbits); + ret Vec.init_fn[uint](sub, v.nbits); } fn to_str(&t v) -> str { auto res = ""; - for (uint i in bitv.to_vec(v)) { + for (uint i in BitV.to_vec(v)) { if (i == 1u) { res += "1"; } @@ -196,7 +196,7 @@ fn to_str(&t v) -> str { // FIXME: can we just use structural equality on to_vec? fn eq_vec(&t v0, &vec[uint] v1) -> bool { - assert (v0.nbits == _vec.len[uint](v1)); + assert (v0.nbits == Vec.len[uint](v1)); auto len = v0.nbits; auto i = 0u; while (i < len) { diff --git a/src/lib/dbg.rs b/src/lib/Dbg.rs index b63f363e..f155d119 100644 --- a/src/lib/dbg.rs +++ b/src/lib/Dbg.rs @@ -20,7 +20,7 @@ native "rust" mod rustrt { } fn debug_vec[T](vec[T] v) { - _vec.print_debug_info[T](v); + Vec.print_debug_info[T](v); } fn debug_tydesc[T]() { diff --git a/src/lib/deque.rs b/src/lib/Deque.rs index b8404a7d..a38e4fec 100644 --- a/src/lib/deque.rs +++ b/src/lib/Deque.rs @@ -19,7 +19,7 @@ type t[T] = obj { fn create[T]() -> t[T] { - type cell[T] = option.t[T]; + type cell[T] = Option.t[T]; let uint initial_capacity = 32u; // 2^5 @@ -28,25 +28,25 @@ fn create[T]() -> t[T] { * elsewhere. */ fn grow[T](uint nelts, uint lo, vec[cell[T]] elts) -> vec[cell[T]] { - assert (nelts == _vec.len[cell[T]](elts)); + assert (nelts == Vec.len[cell[T]](elts)); fn fill[T](uint i, uint nelts, uint lo, vec[cell[T]] old) -> cell[T] { if (i < nelts) { ret old.((lo + i) % nelts); } else { - ret option.none[T]; + ret Option.none[T]; } } - let uint nalloc = _uint.next_power_of_two(nelts + 1u); - let _vec.init_op[cell[T]] copy_op = bind fill[T](_, nelts, lo, elts); - ret _vec.init_fn[cell[T]](copy_op, nalloc); + let uint nalloc = UInt.next_power_of_two(nelts + 1u); + let Vec.init_op[cell[T]] copy_op = bind fill[T](_, nelts, lo, elts); + ret Vec.init_fn[cell[T]](copy_op, nalloc); } fn get[T](vec[cell[T]] elts, uint i) -> T { alt (elts.(i)) { - case (option.some[T](?t)) { ret t; } + case (Option.some[T](?t)) { ret t; } case (_) { fail; } } fail; // FIXME: remove me when exhaustiveness checking works @@ -63,18 +63,18 @@ fn create[T]() -> t[T] { let uint oldlo = lo; if (lo == 0u) { - lo = _vec.len[cell[T]](elts) - 1u; + lo = Vec.len[cell[T]](elts) - 1u; } else { lo -= 1u; } if (lo == hi) { elts = grow[T](nelts, oldlo, elts); - lo = _vec.len[cell[T]](elts) - 1u; + lo = Vec.len[cell[T]](elts) - 1u; hi = nelts; } - elts.(lo) = option.some[T](t); + elts.(lo) = Option.some[T](t); nelts += 1u; } @@ -85,8 +85,8 @@ fn create[T]() -> t[T] { hi = nelts; } - elts.(hi) = option.some[T](t); - hi = (hi + 1u) % _vec.len[cell[T]](elts); + elts.(hi) = Option.some[T](t); + hi = (hi + 1u) % Vec.len[cell[T]](elts); nelts += 1u; } @@ -96,21 +96,21 @@ fn create[T]() -> t[T] { */ fn pop_front() -> T { let T t = get[T](elts, lo); - elts.(lo) = option.none[T]; - lo = (lo + 1u) % _vec.len[cell[T]](elts); + elts.(lo) = Option.none[T]; + lo = (lo + 1u) % Vec.len[cell[T]](elts); nelts -= 1u; ret t; } fn pop_back() -> T { if (hi == 0u) { - hi = _vec.len[cell[T]](elts) - 1u; + hi = Vec.len[cell[T]](elts) - 1u; } else { hi -= 1u; } let T t = get[T](elts, hi); - elts.(hi) = option.none[T]; + elts.(hi) = Option.none[T]; nelts -= 1u; ret t; } @@ -124,12 +124,12 @@ fn create[T]() -> t[T] { } fn get(int i) -> T { - let uint idx = (lo + (i as uint)) % _vec.len[cell[T]](elts); + let uint idx = (lo + (i as uint)) % Vec.len[cell[T]](elts); ret get[T](elts, idx); } } - let vec[cell[T]] v = _vec.init_elt[cell[T]](option.none[T], + let vec[cell[T]] v = Vec.init_elt[cell[T]](Option.none[T], initial_capacity); ret deque[T](0u, 0u, 0u, v); diff --git a/src/lib/ebml.rs b/src/lib/EBML.rs index 9bad0f33..9b17bf06 100644 --- a/src/lib/ebml.rs +++ b/src/lib/EBML.rs @@ -2,8 +2,8 @@ // cursor model. See the specification here: // http://www.matroska.org/technical/specs/rfc/index.html -import option.none; -import option.some; +import Option.none; +import Option.some; type ebml_tag = rec(uint id, uint size); type ebml_state = rec(ebml_tag ebml_tag, uint tag_pos, uint data_pos); @@ -38,7 +38,7 @@ fn vint_at(vec[u8] data, uint start) -> tup(uint, uint) { } fn new_doc(vec[u8] data) -> doc { - ret rec(data=data, start=0u, end=_vec.len[u8](data)); + ret rec(data=data, start=0u, end=Vec.len[u8](data)); } fn doc_at(vec[u8] data, uint start) -> doc { @@ -48,7 +48,7 @@ fn doc_at(vec[u8] data, uint start) -> doc { ret rec(data=data, start=elt_size._1, end=end); } -fn maybe_get_doc(doc d, uint tg) -> option.t[doc] { +fn maybe_get_doc(doc d, uint tg) -> Option.t[doc] { auto pos = d.start; while (pos < d.end) { auto elt_tag = vint_at(d.data, pos); @@ -65,7 +65,7 @@ fn get_doc(doc d, uint tg) -> doc { alt (maybe_get_doc(d, tg)) { case (some[doc](?d)) {ret d;} case (none[doc]) { - log_err "failed to find block with tag " + _uint.to_str(tg, 10u); + log_err "failed to find block with tag " + UInt.to_str(tg, 10u); fail; } } @@ -94,7 +94,7 @@ iter tagged_docs(doc d, uint tg) -> doc { } fn doc_data(doc d) -> vec[u8] { - ret _vec.slice[u8](d.data, d.start, d.end); + ret Vec.slice[u8](d.data, d.start, d.end); } fn be_uint_from_bytes(vec[u8] data, uint start, uint size) -> uint { @@ -116,9 +116,9 @@ fn doc_as_uint(doc d) -> uint { // EBML writing -type writer = rec(io.buf_writer writer, mutable vec[uint] size_positions); +type writer = rec(IO.buf_writer writer, mutable vec[uint] size_positions); -fn write_sized_vint(&io.buf_writer w, uint n, uint size) { +fn write_sized_vint(&IO.buf_writer w, uint n, uint size) { let vec[u8] buf; alt (size) { case (1u) { @@ -148,7 +148,7 @@ fn write_sized_vint(&io.buf_writer w, uint n, uint size) { w.write(buf); } -fn write_vint(&io.buf_writer w, uint n) { +fn write_vint(&IO.buf_writer w, uint n) { if (n < 0x7fu) { write_sized_vint(w, n, 1u); ret; } if (n < 0x4000u) { write_sized_vint(w, n, 2u); ret; } if (n < 0x200000u) { write_sized_vint(w, n, 3u); ret; } @@ -157,7 +157,7 @@ fn write_vint(&io.buf_writer w, uint n) { fail; } -fn create_writer(&io.buf_writer w) -> writer { +fn create_writer(&IO.buf_writer w) -> writer { let vec[uint] size_positions = vec(); ret rec(writer=w, mutable size_positions=size_positions); } @@ -175,11 +175,11 @@ fn start_tag(&writer w, uint tag_id) { } fn end_tag(&writer w) { - auto last_size_pos = _vec.pop[uint](w.size_positions); + auto last_size_pos = Vec.pop[uint](w.size_positions); auto cur_pos = w.writer.tell(); - w.writer.seek(last_size_pos as int, io.seek_set); + w.writer.seek(last_size_pos as int, IO.seek_set); write_sized_vint(w.writer, cur_pos - last_size_pos - 4u, 4u); - w.writer.seek(cur_pos as int, io.seek_set); + w.writer.seek(cur_pos as int, IO.seek_set); } // TODO: optionally perform "relaxations" on end_tag to more efficiently diff --git a/src/lib/ExtFmt.rs b/src/lib/ExtFmt.rs index c71e49a3..0510a2a8 100644 --- a/src/lib/ExtFmt.rs +++ b/src/lib/ExtFmt.rs @@ -13,8 +13,8 @@ * combinations at the moment. */ -import option.none; -import option.some; +import Option.none; +import Option.some; /* * We have a CT (compile-time) module that parses format strings into a @@ -66,7 +66,7 @@ mod CT { } // A formatted conversion from an expression to a string - type conv = rec(option.t[int] param, + type conv = rec(Option.t[int] param, vec[flag] flags, count width, count precision, @@ -80,11 +80,11 @@ mod CT { fn parse_fmt_string(str s) -> vec[piece] { let vec[piece] pieces = vec(); - auto lim = _str.byte_len(s); + auto lim = Str.byte_len(s); auto buf = ""; fn flush_buf(str buf, &vec[piece] pieces) -> str { - if (_str.byte_len(buf) > 0u) { + if (Str.byte_len(buf) > 0u) { auto piece = piece_string(buf); pieces += vec(piece); } @@ -93,15 +93,15 @@ mod CT { auto i = 0u; while (i < lim) { - auto curr = _str.substr(s, i, 1u); - if (_str.eq(curr, "%")) { + auto curr = Str.substr(s, i, 1u); + if (Str.eq(curr, "%")) { i += 1u; if (i >= lim) { log_err "unterminated conversion at end of string"; fail; } - auto curr2 = _str.substr(s, i, 1u); - if (_str.eq(curr2, "%")) { + auto curr2 = Str.substr(s, i, 1u); + if (Str.eq(curr2, "%")) { i += 1u; } else { buf = flush_buf(buf, pieces); @@ -118,14 +118,14 @@ mod CT { ret pieces; } - fn peek_num(str s, uint i, uint lim) -> option.t[tup(uint, uint)] { + fn peek_num(str s, uint i, uint lim) -> Option.t[tup(uint, uint)] { if (i >= lim) { ret none[tup(uint, uint)]; } auto c = s.(i); if (!('0' as u8 <= c && c <= '9' as u8)) { - ret option.none[tup(uint, uint)]; + ret Option.none[tup(uint, uint)]; } auto n = (c - ('0' as u8)) as uint; @@ -156,7 +156,7 @@ mod CT { ty._1); } - fn parse_parameter(str s, uint i, uint lim) -> tup(option.t[int], uint) { + fn parse_parameter(str s, uint i, uint lim) -> tup(Option.t[int], uint) { if (i >= lim) { ret tup(none[int], i); } @@ -270,27 +270,27 @@ mod CT { } auto t; - auto tstr = _str.substr(s, i, 1u); - if (_str.eq(tstr, "b")) { + auto tstr = Str.substr(s, i, 1u); + if (Str.eq(tstr, "b")) { t = ty_bool; - } else if (_str.eq(tstr, "s")) { + } else if (Str.eq(tstr, "s")) { t = ty_str; - } else if (_str.eq(tstr, "c")) { + } else if (Str.eq(tstr, "c")) { t = ty_char; - } else if (_str.eq(tstr, "d") - || _str.eq(tstr, "i")) { + } else if (Str.eq(tstr, "d") + || Str.eq(tstr, "i")) { // TODO: Do we really want two signed types here? // How important is it to be printf compatible? t = ty_int(signed); - } else if (_str.eq(tstr, "u")) { + } else if (Str.eq(tstr, "u")) { t = ty_int(unsigned); - } else if (_str.eq(tstr, "x")) { + } else if (Str.eq(tstr, "x")) { t = ty_hex(case_lower); - } else if (_str.eq(tstr, "X")) { + } else if (Str.eq(tstr, "X")) { t = ty_hex(case_upper); - } else if (_str.eq(tstr, "t")) { + } else if (Str.eq(tstr, "t")) { t = ty_bits; - } else if (_str.eq(tstr, "o")) { + } else if (Str.eq(tstr, "o")) { t = ty_octal; } else { log_err "unknown type in conversion"; @@ -364,7 +364,7 @@ mod RT { res = uint_to_str_prec(u, 16u, prec); } case (ty_hex_upper) { - res = _str.to_upper(uint_to_str_prec(u, 16u, prec)); + res = Str.to_upper(uint_to_str_prec(u, 16u, prec)); } case (ty_bits) { res = uint_to_str_prec(u, 2u, prec); @@ -389,7 +389,7 @@ mod RT { } fn conv_char(&conv cv, char c) -> str { - ret pad(cv, _str.from_char(c), pad_nozero); + ret pad(cv, Str.from_char(c), pad_nozero); } fn conv_str(&conv cv, str s) -> str { @@ -399,9 +399,9 @@ mod RT { } case (count_is(?max)) { // For strings, precision is the maximum characters displayed - if (max as uint < _str.char_len(s)) { + if (max as uint < Str.char_len(s)) { // FIXME: substr works on bytes, not chars! - unpadded = _str.substr(s, 0u, max as uint); + unpadded = Str.substr(s, 0u, max as uint); } } } @@ -420,15 +420,15 @@ mod RT { // Convert a uint to string with a minimum number of digits. If precision // is 0 and num is 0 then the result is the empty string. Could move this - // to _uint, but it doesn't seem all that useful. + // to UInt. but it doesn't seem all that useful. fn uint_to_str_prec(uint num, uint radix, uint prec) -> str { auto s; if (prec == 0u && num == 0u) { s = ""; } else { - s = _uint.to_str(num, radix); - auto len = _str.char_len(s); + s = UInt.to_str(num, radix); + auto len = Str.char_len(s); if (len < prec) { auto diff = prec - len; auto pad = str_init_elt('0', diff); @@ -450,12 +450,12 @@ mod RT { } } - // FIXME: This might be useful in _str, but needs to be utf8 safe first + // FIXME: This might be useful in Str. but needs to be utf8 safe first fn str_init_elt(char c, uint n_elts) -> str { - auto svec = _vec.init_elt[u8](c as u8, n_elts); + auto svec = Vec.init_elt[u8](c as u8, n_elts); // FIXME: Using unsafe_from_bytes because rustboot // can't figure out the is_utf8 predicate on from_bytes? - ret _str.unsafe_from_bytes(svec); + ret Str.unsafe_from_bytes(svec); } tag pad_mode { @@ -476,7 +476,7 @@ mod RT { } } - auto strlen = _str.char_len(s); + auto strlen = Str.char_len(s); if (uwidth <= strlen) { ret s; } @@ -532,16 +532,16 @@ mod RT { // instead. if (signed && zero_padding - && _str.byte_len(s) > 0u) { + && Str.byte_len(s) > 0u) { auto head = s.(0); if (head == '+' as u8 || head == '-' as u8 || head == ' ' as u8) { - auto headstr = _str.unsafe_from_bytes(vec(head)); - auto bytelen = _str.byte_len(s); - auto numpart = _str.substr(s, 1u, bytelen - 1u); + auto headstr = Str.unsafe_from_bytes(vec(head)); + auto bytelen = Str.byte_len(s); + auto numpart = Str.substr(s, 1u, bytelen - 1u); ret headstr + padstr + numpart; } } diff --git a/src/lib/fs.rs b/src/lib/FS.rs index 0a951e5a..69edf247 100644 --- a/src/lib/fs.rs +++ b/src/lib/FS.rs @@ -3,25 +3,25 @@ native "rust" mod rustrt { } fn path_sep() -> str { - ret _str.from_char(os_fs.path_sep); + ret Str.from_char(OS_FS.path_sep); } type path = str; fn dirname(path p) -> path { - let int i = _str.rindex(p, os_fs.path_sep as u8); + let int i = Str.rindex(p, OS_FS.path_sep as u8); if (i == -1) { - i = _str.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; } } - ret _str.substr(p, 0u, i as uint); + ret Str.substr(p, 0u, i as uint); } fn connect(path pre, path post) -> path { - auto len = _str.byte_len(pre); - if (pre.(len - 1u) == (os_fs.path_sep as u8)) { // Trailing '/'? + auto len = Str.byte_len(pre); + if (pre.(len - 1u) == (OS_FS.path_sep as u8)) { // Trailing '/'? ret pre + post; } ret pre + path_sep() + post; @@ -32,14 +32,14 @@ fn file_is_dir(path p) -> bool { } fn list_dir(path p) -> vec[str] { - auto pl = _str.byte_len(p); - if (pl == 0u || p.(pl - 1u) as char != os_fs.path_sep) { + auto pl = Str.byte_len(p); + if (pl == 0u || p.(pl - 1u) as char != OS_FS.path_sep) { p += path_sep(); } let vec[str] full_paths = vec(); - for (str filename in os_fs.list_dir(p)) { - if (!_str.eq(filename, ".")) {if (!_str.eq(filename, "..")) { - _vec.push[str](full_paths, p + filename); + for (str filename in OS_FS.list_dir(p)) { + if (!Str.eq(filename, ".")) {if (!Str.eq(filename, "..")) { + Vec.push[str](full_paths, p + filename); }} } ret full_paths; diff --git a/src/lib/GenericOS.rs b/src/lib/GenericOS.rs index 2d375652..c60fa2b8 100644 --- a/src/lib/GenericOS.rs +++ b/src/lib/GenericOS.rs @@ -1,4 +1,4 @@ fn getenv(str n) -> str { - ret _str.str_from_cstr(os.libc.getenv(_str.buf(n))); + ret Str.str_from_cstr(OS.libc.getenv(Str.buf(n))); } diff --git a/src/lib/GetOpts.rs b/src/lib/GetOpts.rs index f85ce85c..0cacf3ff 100644 --- a/src/lib/GetOpts.rs +++ b/src/lib/GetOpts.rs @@ -7,8 +7,8 @@ * argument values out of the match object. */ -import option.some; -import option.none; +import Option.some; +import Option.none; tag name { long(str); short(char); } tag hasarg { yes; no; maybe; } @@ -17,7 +17,7 @@ tag occur { req; optional; multi; } type opt = rec(name name, hasarg hasarg, occur occur); fn mkname(str nm) -> name { - if (_str.char_len(nm) == 1u) { ret short(_str.char_at(nm, 0u)); } + if (Str.char_len(nm) == 1u) { ret short(Str.char_at(nm, 0u)); } else { ret long(nm); } } fn reqopt(str name) -> opt { @@ -41,11 +41,11 @@ tag optval { type match = rec(vec[opt] opts, vec[mutable vec[optval]] vals, vec[str] free); fn is_arg(str arg) -> bool { - ret _str.byte_len(arg) > 1u && arg.(0) == '-' as u8; + ret Str.byte_len(arg) > 1u && arg.(0) == '-' as u8; } fn name_str(name nm) -> str { alt (nm) { - case (short(?ch)) {ret _str.from_char(ch);} + case (short(?ch)) {ret Str.from_char(ch);} case (long(?s)) {ret s;} } } @@ -55,16 +55,16 @@ fn name_eq(name a, name b) -> bool { alt (a) { case (long(?a)) { alt (b) { - case (long(?b)) { ret _str.eq(a, b); } + case (long(?b)) { ret Str.eq(a, b); } case (_) { ret false; } } } case (_) { if (a == b) { ret true; } else {ret false; } } } } -fn find_opt(vec[opt] opts, name nm) -> option.t[uint] { +fn find_opt(vec[opt] opts, name nm) -> Option.t[uint] { auto i = 0u; - auto l = _vec.len[opt](opts); + auto l = Vec.len[opt](opts); while (i < l) { if (name_eq(opts.(i).name, nm)) { ret some[uint](i); } i += 1u; @@ -102,41 +102,41 @@ tag result { } fn getopts(vec[str] args, vec[opt] opts) -> result { - auto n_opts = _vec.len[opt](opts); - fn empty_(uint x) -> vec[optval]{ret _vec.empty[optval]();} + auto n_opts = Vec.len[opt](opts); + fn empty_(uint x) -> vec[optval]{ret Vec.empty[optval]();} auto f = empty_; - auto vals = _vec.init_fn_mut[vec[optval]](f, n_opts); + auto vals = Vec.init_fn_mut[vec[optval]](f, n_opts); let vec[str] free = vec(); - auto l = _vec.len[str](args); + auto l = Vec.len[str](args); auto i = 0u; while (i < l) { auto cur = args.(i); - auto curlen = _str.byte_len(cur); + auto curlen = Str.byte_len(cur); if (!is_arg(cur)) { - _vec.push[str](free, cur); - } else if (_str.eq(cur, "--")) { - free += _vec.slice[str](args, i + 1u, l); + Vec.push[str](free, cur); + } else if (Str.eq(cur, "--")) { + free += Vec.slice[str](args, i + 1u, l); break; } else { auto names; - auto i_arg = option.none[str]; + auto i_arg = Option.none[str]; if (cur.(1) == '-' as u8) { - auto tail = _str.slice(cur, 2u, curlen); - auto eq = _str.index(tail, '=' as u8); + auto tail = Str.slice(cur, 2u, curlen); + auto eq = Str.index(tail, '=' as u8); if (eq == -1) { names = vec(long(tail)); } else { - names = vec(long(_str.slice(tail, 0u, eq as uint))); - i_arg = option.some[str] - (_str.slice(tail, (eq as uint) + 1u, curlen - 2u)); + names = vec(long(Str.slice(tail, 0u, eq as uint))); + i_arg = Option.some[str] + (Str.slice(tail, (eq as uint) + 1u, curlen - 2u)); } } else { auto j = 1u; names = vec(); while (j < curlen) { - auto range = _str.char_range_at(cur, j); - _vec.push[name](names, short(range._0)); + auto range = Str.char_range_at(cur, j); + Vec.push[name](names, short(range._0)); j = range._1; } } @@ -152,29 +152,29 @@ fn getopts(vec[str] args, vec[opt] opts) -> result { } alt (opts.(optid).hasarg) { case (no) { - _vec.push[optval](vals.(optid), given); + Vec.push[optval](vals.(optid), given); } case (maybe) { - if (!option.is_none[str](i_arg)) { - _vec.push[optval](vals.(optid), - val(option.get[str](i_arg))); - } else if (name_pos < _vec.len[name](names) || + if (!Option.is_none[str](i_arg)) { + Vec.push[optval](vals.(optid), + val(Option.get[str](i_arg))); + } else if (name_pos < Vec.len[name](names) || i + 1u == l || is_arg(args.(i + 1u))) { - _vec.push[optval](vals.(optid), given); + Vec.push[optval](vals.(optid), given); } else { i += 1u; - _vec.push[optval](vals.(optid), val(args.(i))); + Vec.push[optval](vals.(optid), val(args.(i))); } } case (yes) { - if (!option.is_none[str](i_arg)) { - _vec.push[optval](vals.(optid), - val(option.get[str](i_arg))); + if (!Option.is_none[str](i_arg)) { + Vec.push[optval](vals.(optid), + val(Option.get[str](i_arg))); } else if (i + 1u == l) { ret failure(argument_missing(name_str(nm))); } else { i += 1u; - _vec.push[optval](vals.(optid), val(args.(i))); + Vec.push[optval](vals.(optid), val(args.(i))); } } } @@ -185,7 +185,7 @@ fn getopts(vec[str] args, vec[opt] opts) -> result { i = 0u; while (i < n_opts) { - auto n = _vec.len[optval](vals.(i)); + auto n = Vec.len[optval](vals.(i)); auto occ = opts.(i).occur; if (occ == req) {if (n == 0u) { ret failure(option_missing(name_str(opts.(i).name))); @@ -212,7 +212,7 @@ fn opt_val(match m, str nm) -> optval { ret opt_vals(m, nm).(0); } fn opt_present(match m, str nm) -> bool { - ret _vec.len[optval](opt_vals(m, nm)) > 0u; + ret Vec.len[optval](opt_vals(m, nm)) > 0u; } fn opt_str(match m, str nm) -> str { alt (opt_val(m, nm)) { @@ -224,15 +224,15 @@ fn opt_strs(match m, str nm) -> vec[str] { let vec[str] acc = vec(); for (optval v in opt_vals(m, nm)) { alt (v) { - case (val(?s)) { _vec.push[str](acc, s); } + case (val(?s)) { Vec.push[str](acc, s); } case (_) {} } } ret acc; } -fn opt_maybe_str(match m, str nm) -> option.t[str] { +fn opt_maybe_str(match m, str nm) -> Option.t[str] { auto vals = opt_vals(m, nm); - if (_vec.len[optval](vals) == 0u) { ret none[str]; } + if (Vec.len[optval](vals) == 0u) { ret none[str]; } alt (vals.(0)) { case (val(?s)) { ret some[str](s); } case (_) { ret none[str]; } diff --git a/src/lib/io.rs b/src/lib/IO.rs index 364810ba..60416ab1 100644 --- a/src/lib/io.rs +++ b/src/lib/IO.rs @@ -1,8 +1,8 @@ -import os.libc; +import OS.libc; native "rust" mod rustrt { - fn rust_get_stdin() -> os.libc.FILE; - fn rust_get_stdout() -> os.libc.FILE; + fn rust_get_stdin() -> OS.libc.FILE; + fn rust_get_stdout() -> OS.libc.FILE; } // Reading @@ -55,30 +55,30 @@ fn convert_whence(seek_style whence) -> int { } } -state obj FILE_buf_reader(os.libc.FILE f, bool must_close) { +state obj FILE_buf_reader(OS.libc.FILE f, bool must_close) { fn read(uint len) -> vec[u8] { - auto buf = _vec.alloc[u8](len); - auto read = os.libc.fread(_vec.buf[u8](buf), 1u, len, f); - _vec.len_set[u8](buf, read); + auto buf = Vec.alloc[u8](len); + auto read = OS.libc.fread(Vec.buf[u8](buf), 1u, len, f); + Vec.len_set[u8](buf, read); ret buf; } fn read_byte() -> int { - ret os.libc.fgetc(f); + ret OS.libc.fgetc(f); } fn unread_byte(int byte) { - os.libc.ungetc(byte, f); + OS.libc.ungetc(byte, f); } fn eof() -> bool { - ret os.libc.feof(f) != 0; + ret OS.libc.feof(f) != 0; } fn seek(int offset, seek_style whence) { - assert (os.libc.fseek(f, offset, convert_whence(whence)) == 0); + assert (OS.libc.fseek(f, offset, convert_whence(whence)) == 0); } fn tell() -> uint { - ret os.libc.ftell(f) as uint; + ret OS.libc.ftell(f) as uint; } drop { - if (must_close) { os.libc.fclose(f); } + if (must_close) { OS.libc.fclose(f); } } } @@ -100,7 +100,7 @@ state obj new_reader(buf_reader rdr) { auto c0 = rdr.read_byte(); if (c0 == -1) {ret -1 as char;} // FIXME will this stay valid? auto b0 = c0 as u8; - auto w = _str.utf8_char_width(b0); + auto w = Str.utf8_char_width(b0); assert (w > 0u); if (w == 1u) {ret b0 as char;} auto val = 0u; @@ -112,7 +112,7 @@ state obj new_reader(buf_reader rdr) { val <<= 6u; val += (next & 0x3f) as uint; } - // See _str.char_at + // See Str.char_at val += ((b0 << ((w + 1u) as u8)) as uint) << ((w - 1u) * 6u - w - 1u); ret val as char; } @@ -126,9 +126,9 @@ state obj new_reader(buf_reader rdr) { while (go_on) { auto ch = rdr.read_byte(); if (ch == -1 || ch == 10) {go_on = false;} - else {_vec.push[u8](buf, ch as u8);} + else {Vec.push[u8](buf, ch as u8);} } - ret _str.unsafe_from_bytes(buf); + ret Str.unsafe_from_bytes(buf); } fn read_c_str() -> str { let vec[u8] buf = vec(); @@ -136,9 +136,9 @@ state obj new_reader(buf_reader rdr) { while (go_on) { auto ch = rdr.read_byte(); if (ch < 1) {go_on = false;} - else {_vec.push[u8](buf, ch as u8);} + else {Vec.push[u8](buf, ch as u8);} } - ret _str.unsafe_from_bytes(buf); + ret Str.unsafe_from_bytes(buf); } // FIXME deal with eof? fn read_le_uint(uint size) -> uint { @@ -191,7 +191,7 @@ fn stdin() -> reader { } fn file_reader(str path) -> reader { - auto f = os.libc.fopen(_str.buf(path), _str.buf("r")); + auto f = OS.libc.fopen(Str.buf(path), Str.buf("r")); if (f as uint == 0u) { log_err "error opening " + path; fail; @@ -212,17 +212,17 @@ type byte_buf = @rec(vec[u8] buf, mutable uint pos); state obj byte_buf_reader(byte_buf bbuf) { fn read(uint len) -> vec[u8] { - auto rest = _vec.len[u8](bbuf.buf) - bbuf.pos; + auto rest = Vec.len[u8](bbuf.buf) - bbuf.pos; auto to_read = len; if (rest < to_read) { to_read = rest; } - auto range = _vec.slice[u8](bbuf.buf, bbuf.pos, bbuf.pos + to_read); + auto range = Vec.slice[u8](bbuf.buf, bbuf.pos, bbuf.pos + to_read); bbuf.pos += to_read; ret range; } fn read_byte() -> int { - if (bbuf.pos == _vec.len[u8](bbuf.buf)) {ret -1;} + if (bbuf.pos == Vec.len[u8](bbuf.buf)) {ret -1;} auto b = bbuf.buf.(bbuf.pos); bbuf.pos += 1u; ret b as int; @@ -234,12 +234,12 @@ state obj byte_buf_reader(byte_buf bbuf) { } fn eof() -> bool { - ret bbuf.pos == _vec.len[u8](bbuf.buf); + ret bbuf.pos == Vec.len[u8](bbuf.buf); } fn seek(int offset, seek_style whence) { auto pos = bbuf.pos; - auto len = _vec.len[u8](bbuf.buf); + auto len = Vec.len[u8](bbuf.buf); bbuf.pos = seek_in_buf(offset, pos, len, whence); } @@ -268,40 +268,40 @@ type buf_writer = state obj { fn tell() -> uint; // FIXME: eventually u64 }; -state obj FILE_writer(os.libc.FILE f, bool must_close) { +state obj FILE_writer(OS.libc.FILE f, bool must_close) { fn write(vec[u8] v) { - auto len = _vec.len[u8](v); - auto vbuf = _vec.buf[u8](v); - auto nout = os.libc.fwrite(vbuf, len, 1u, f); + auto len = Vec.len[u8](v); + auto vbuf = Vec.buf[u8](v); + auto nout = OS.libc.fwrite(vbuf, len, 1u, f); if (nout < 1u) { log_err "error dumping buffer"; } } fn seek(int offset, seek_style whence) { - assert (os.libc.fseek(f, offset, convert_whence(whence)) == 0); + assert (OS.libc.fseek(f, offset, convert_whence(whence)) == 0); } fn tell() -> uint { - ret os.libc.ftell(f) as uint; + ret OS.libc.ftell(f) as uint; } drop { - if (must_close) {os.libc.fclose(f);} + if (must_close) {OS.libc.fclose(f);} } } state obj fd_buf_writer(int fd, bool must_close) { fn write(vec[u8] v) { - auto len = _vec.len[u8](v); + auto len = Vec.len[u8](v); auto count = 0u; auto vbuf; while (count < len) { - vbuf = _vec.buf_off[u8](v, count); - auto nout = os.libc.write(fd, vbuf, len); + vbuf = Vec.buf_off[u8](v, count); + auto nout = OS.libc.write(fd, vbuf, len); if (nout < 0) { log_err "error dumping buffer"; - log_err sys.rustrt.last_os_error(); + log_err Sys.rustrt.last_os_error(); fail; } count += nout as uint; @@ -319,32 +319,32 @@ state obj fd_buf_writer(int fd, bool must_close) { } drop { - if (must_close) {os.libc.close(fd);} + if (must_close) {OS.libc.close(fd);} } } fn file_buf_writer(str path, vec[fileflag] flags) -> buf_writer { let int fflags = - os.libc_constants.O_WRONLY() | - os.libc_constants.O_BINARY(); + OS.libc_constants.O_WRONLY() | + OS.libc_constants.O_BINARY(); for (fileflag f in flags) { alt (f) { - case (append) { fflags |= os.libc_constants.O_APPEND(); } - case (create) { fflags |= os.libc_constants.O_CREAT(); } - case (truncate) { fflags |= os.libc_constants.O_TRUNC(); } + case (append) { fflags |= OS.libc_constants.O_APPEND(); } + case (create) { fflags |= OS.libc_constants.O_CREAT(); } + case (truncate) { fflags |= OS.libc_constants.O_TRUNC(); } case (none) {} } } - auto fd = os.libc.open(_str.buf(path), + auto fd = OS.libc.open(Str.buf(path), fflags, - os.libc_constants.S_IRUSR() | - os.libc_constants.S_IWUSR()); + OS.libc_constants.S_IRUSR() | + OS.libc_constants.S_IWUSR()); if (fd < 0) { log_err "error opening file for writing"; - log_err sys.rustrt.last_os_error(); + log_err Sys.rustrt.last_os_error(); fail; } ret fd_buf_writer(fd, true); @@ -390,17 +390,17 @@ state obj new_writer(buf_writer out) { ret out; } fn write_str(str s) { - out.write(_str.bytes(s)); + out.write(Str.bytes(s)); } fn write_char(char ch) { // FIXME needlessly consy - out.write(_str.bytes(_str.from_char(ch))); + out.write(Str.bytes(Str.from_char(ch))); } fn write_int(int n) { - out.write(_str.bytes(_int.to_str(n, 10u))); + out.write(Str.bytes(Int.to_str(n, 10u))); } fn write_uint(uint n) { - out.write(_str.bytes(_uint.to_str(n, 10u))); + out.write(Str.bytes(UInt.to_str(n, 10u))); } fn write_bytes(vec[u8] bytes) { out.write(bytes); @@ -427,7 +427,7 @@ fn file_writer(str path, vec[fileflag] flags) -> writer { // FIXME: fileflags fn buffered_file_buf_writer(str path) -> buf_writer { - auto f = os.libc.fopen(_str.buf(path), _str.buf("w")); + auto f = OS.libc.fopen(Str.buf(path), Str.buf("w")); if (f as uint == 0u) { log_err "error opening " + path; fail; @@ -451,21 +451,21 @@ type mutable_byte_buf = @rec(mutable vec[mutable u8] buf, mutable uint pos); state obj byte_buf_writer(mutable_byte_buf buf) { fn write(vec[u8] v) { // Fast path. - if (buf.pos == _vec.len(buf.buf)) { + if (buf.pos == Vec.len(buf.buf)) { // FIXME: Fix our type system. There's no reason you shouldn't be // able to add a mutable vector to an immutable one. - auto mv = _vec.rustrt.unsafe_vec_to_mut[u8](v); + auto mv = Vec.rustrt.unsafe_vec_to_mut[u8](v); buf.buf += mv; - buf.pos += _vec.len[u8](v); + buf.pos += Vec.len[u8](v); ret; } // FIXME: Optimize. These should be unique pointers. - auto vlen = _vec.len[u8](v); + auto vlen = Vec.len[u8](v); auto vpos = 0u; while (vpos < vlen) { auto b = v.(vpos); - if (buf.pos == _vec.len(buf.buf)) { + if (buf.pos == Vec.len(buf.buf)) { buf.buf += vec(mutable b); } else { buf.buf.(buf.pos) = b; @@ -477,7 +477,7 @@ state obj byte_buf_writer(mutable_byte_buf buf) { fn seek(int offset, seek_style whence) { auto pos = buf.pos; - auto len = _vec.len(buf.buf); + auto len = Vec.len(buf.buf); buf.pos = seek_in_buf(offset, pos, len, whence); } @@ -487,12 +487,12 @@ state obj byte_buf_writer(mutable_byte_buf buf) { fn string_writer() -> str_writer { // FIXME: yikes, this is bad. Needs fixing of mutable syntax. let vec[mutable u8] b = vec(mutable 0u8); - _vec.pop(b); + Vec.pop(b); let mutable_byte_buf buf = @rec(mutable buf = b, mutable pos = 0u); state obj str_writer_wrap(writer wr, mutable_byte_buf buf) { fn get_writer() -> writer {ret wr;} - fn get_str() -> str {ret _str.unsafe_from_mutable_bytes(buf.buf);} + fn get_str() -> str {ret Str.unsafe_from_mutable_bytes(buf.buf);} } ret str_writer_wrap(new_writer(byte_buf_writer(buf)), buf); } diff --git a/src/lib/_int.rs b/src/lib/Int.rs index 1824d142..59fb507f 100644 --- a/src/lib/_int.rs +++ b/src/lib/Int.rs @@ -29,9 +29,9 @@ fn to_str(int n, uint radix) -> str { assert (0u < radix && radix <= 16u); if (n < 0) { - ret "-" + _uint.to_str((-n) as uint, radix); + ret "-" + UInt.to_str((-n) as uint, radix); } else { - ret _uint.to_str(n as uint, radix); + ret UInt.to_str(n as uint, radix); } } diff --git a/src/lib/list.rs b/src/lib/List.rs index 33f7c060..58ea29f2 100644 --- a/src/lib/list.rs +++ b/src/lib/List.rs @@ -1,5 +1,5 @@ -import option.some; -import option.none; +import Option.some; +import Option.none; // FIXME: It would probably be more appealing to define this as // type list[T] = rec(T hd, option[@list[T]] tl), but at the moment @@ -27,7 +27,7 @@ fn foldl[T,U](&list[T] ls, &U u, fn(&T t, &U u) -> U f) -> U { } fn find[T,U](&list[T] ls, - (fn(&T) -> option.t[U]) f) -> option.t[U] { + (fn(&T) -> Option.t[U]) f) -> Option.t[U] { alt(ls) { case (cons[T](?hd, ?tl)) { alt (f(hd)) { diff --git a/src/lib/map.rs b/src/lib/Map.rs index 4ab2f076..6f1ad6d7 100644 --- a/src/lib/map.rs +++ b/src/lib/Map.rs @@ -11,8 +11,8 @@ state type hashmap[K, V] = state obj { fn insert(&K key, &V val) -> bool; fn contains_key(&K key) -> bool; fn get(&K key) -> V; - fn find(&K key) -> option.t[V]; - fn remove(&K key) -> option.t[V]; + fn find(&K key) -> Option.t[V]; + fn remove(&K key) -> Option.t[V]; fn rehash(); iter items() -> @tup(K,V); }; @@ -20,7 +20,7 @@ state type hashmap[K, V] = state obj { fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] { let uint initial_capacity = 32u; // 2^5 - let util.rational load_factor = rec(num=3, den=4); + let Util.rational load_factor = rec(num=3, den=4); tag bucket[K, V] { nil; @@ -29,7 +29,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] { } fn make_buckets[K, V](uint nbkts) -> vec[mutable bucket[K, V]] { - ret _vec.init_elt_mut[bucket[K, V]](nil[K, V], nbkts); + ret Vec.init_elt_mut[bucket[K, V]](nil[K, V], nbkts); } // Derive two hash functions from the one given by taking the upper @@ -96,7 +96,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] { vec[mutable bucket[K, V]] bkts, uint nbkts, &K key) - -> option.t[V] + -> Option.t[V] { let uint i = 0u; let uint h = hasher(key); @@ -105,17 +105,17 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] { alt (bkts.(j)) { case (some[K, V](?k, ?v)) { if (eqer(key, k)) { - ret option.some[V](v); + ret Option.some[V](v); } } case (nil[K, V]) { - ret option.none[V]; + ret Option.none[V]; } case (deleted[K, V]) { } } i += 1u; } - ret option.none[V]; + ret Option.none[V]; } @@ -140,15 +140,15 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] { mutable vec[mutable bucket[K, V]] bkts, mutable uint nbkts, mutable uint nelts, - util.rational lf) + Util.rational lf) { fn size() -> uint { ret nelts; } fn insert(&K key, &V val) -> bool { - let util.rational load = rec(num=(nelts + 1u) as int, + let Util.rational load = rec(num=(nelts + 1u) as int, den=nbkts as int); - if (!util.rational_leq(load, lf)) { - let uint nnewbkts = _uint.next_power_of_two(nbkts + 1u); + if (!Util.rational_leq(load, lf)) { + let uint nnewbkts = UInt.next_power_of_two(nbkts + 1u); let vec[mutable bucket[K, V]] newbkts = make_buckets[K, V](nnewbkts); rehash[K, V](hasher, eqer, bkts, nbkts, @@ -167,7 +167,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] { fn contains_key(&K key) -> bool { alt (find_common[K, V](hasher, eqer, bkts, nbkts, key)) { - case (option.some[V](_)) { ret true; } + case (Option.some[V](_)) { ret true; } case (_) { ret false; } } fail; // FIXME: remove me when exhaustiveness checking works @@ -175,19 +175,19 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] { fn get(&K key) -> V { alt (find_common[K, V](hasher, eqer, bkts, nbkts, key)) { - case (option.some[V](?val)) { ret val; } + case (Option.some[V](?val)) { ret val; } case (_) { fail; } } fail; // FIXME: remove me when exhaustiveness checking works } - fn find(&K key) -> option.t[V] { + fn find(&K key) -> Option.t[V] { // FIXME: should be 'be' but parametric tail-calls don't // work at the moment. ret find_common[K, V](hasher, eqer, bkts, nbkts, key); } - fn remove(&K key) -> option.t[V] { + fn remove(&K key) -> Option.t[V] { let uint i = 0u; let uint h = hasher(key); while (i < nbkts) { @@ -197,17 +197,17 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] { if (eqer(key, k)) { bkts.(j) = deleted[K, V]; nelts -= 1u; - ret option.some[V](v); + ret Option.some[V](v); } } case (deleted[K, V]) { } case (nil[K, V]) { - ret option.none[V]; + ret Option.none[V]; } } i += 1u; } - ret option.none[V]; + ret Option.none[V]; } fn rehash() { diff --git a/src/lib/option.rs b/src/lib/Option.rs index e214c774..3fb9aa3b 100644 --- a/src/lib/option.rs +++ b/src/lib/Option.rs @@ -1,4 +1,4 @@ -// lib/option.rs +// lib/Option.rs tag t[T] { none; @@ -39,7 +39,7 @@ fn is_none[T](&t[T] opt) -> bool { } fn from_maybe[T](&T def, &t[T] opt) -> T { - auto f = bind util.id[T](_); + auto f = bind Util.id[T](_); ret maybe[T, T](def, f, opt); } diff --git a/src/lib/rand.rs b/src/lib/Rand.rs index 06eb2f06..06eb2f06 100644 --- a/src/lib/rand.rs +++ b/src/lib/Rand.rs diff --git a/src/lib/run_program.rs b/src/lib/Run_Program.rs index 31758984..30c0ee9c 100644 --- a/src/lib/run_program.rs +++ b/src/lib/Run_Program.rs @@ -1,74 +1,74 @@ -import _str.sbuf; -import _vec.vbuf; +import Str.sbuf; +import Vec.vbuf; native "rust" mod rustrt { fn rust_run_program(vbuf argv, int in_fd, int out_fd, int err_fd) -> int; } fn argvec(str prog, vec[str] args) -> vec[sbuf] { - auto argptrs = vec(_str.buf(prog)); + auto argptrs = vec(Str.buf(prog)); for (str arg in args) { - _vec.push[sbuf](argptrs, _str.buf(arg)); + Vec.push[sbuf](argptrs, Str.buf(arg)); } - _vec.push[sbuf](argptrs, 0 as sbuf); + Vec.push[sbuf](argptrs, 0 as sbuf); ret argptrs; } fn run_program(str prog, vec[str] args) -> int { - auto pid = rustrt.rust_run_program(_vec.buf[sbuf](argvec(prog, args)), + auto pid = rustrt.rust_run_program(Vec.buf[sbuf](argvec(prog, args)), 0, 0, 0); - ret os.waitpid(pid); + ret OS.waitpid(pid); } type program = state obj { fn get_id() -> int; - fn input() -> io.writer; - fn output() -> io.reader; + fn input() -> IO.writer; + fn output() -> IO.reader; fn close_input(); fn finish() -> int; }; fn start_program(str prog, vec[str] args) -> @program { - auto pipe_input = os.pipe(); - auto pipe_output = os.pipe(); + auto pipe_input = OS.pipe(); + auto pipe_output = OS.pipe(); auto pid = rustrt.rust_run_program - (_vec.buf[sbuf](argvec(prog, args)), + (Vec.buf[sbuf](argvec(prog, args)), pipe_input._0, pipe_output._1, 0); if (pid == -1) {fail;} - os.libc.close(pipe_input._0); - os.libc.close(pipe_output._1); + OS.libc.close(pipe_input._0); + OS.libc.close(pipe_output._1); state obj new_program(int pid, int in_fd, - os.libc.FILE out_file, + OS.libc.FILE out_file, mutable bool finished) { fn get_id() -> int {ret pid;} - fn input() -> io.writer { - ret io.new_writer(io.fd_buf_writer(in_fd, false)); + fn input() -> IO.writer { + ret IO.new_writer(IO.fd_buf_writer(in_fd, false)); } - fn output() -> io.reader { - ret io.new_reader(io.FILE_buf_reader(out_file, false)); + fn output() -> IO.reader { + ret IO.new_reader(IO.FILE_buf_reader(out_file, false)); } fn close_input() { - os.libc.close(in_fd); + OS.libc.close(in_fd); } fn finish() -> int { if (finished) {ret 0;} finished = true; - os.libc.close(in_fd); - ret os.waitpid(pid); + OS.libc.close(in_fd); + ret OS.waitpid(pid); } drop { if (!finished) { - os.libc.close(in_fd); - os.waitpid(pid); + OS.libc.close(in_fd); + OS.waitpid(pid); } - os.libc.fclose(out_file); + OS.libc.fclose(out_file); } } ret @new_program(pid, pipe_input._1, - os.fd_FILE(pipe_output._0), + OS.fd_FILE(pipe_output._0), false); } @@ -80,7 +80,7 @@ fn program_output(str prog, vec[str] args) auto buf = ""; while (!out.eof()) { auto bytes = out.read_bytes(4096u); - buf += _str.unsafe_from_bytes(bytes); + buf += Str.unsafe_from_bytes(bytes); } ret rec(status=pr.finish(), out=buf); } diff --git a/src/lib/sha1.rs b/src/lib/SHA1.rs index e84787a2..b6ac0521 100644 --- a/src/lib/sha1.rs +++ b/src/lib/SHA1.rs @@ -67,7 +67,7 @@ fn mk_sha1() -> sha1 { fn process_msg_block(&sha1state st) { // FIXME: Make precondition - assert (_vec.len(st.h) == digest_buf_len); + assert (Vec.len(st.h) == digest_buf_len); // Constants auto k = vec(0x5A827999u32, @@ -76,7 +76,7 @@ fn mk_sha1() -> sha1 { 0xCA62C1D6u32); let int t; // Loop counter - let vec[mutable u32] w = _vec.init_elt_mut[u32](0u32, 80u); + let vec[mutable u32] w = Vec.init_elt_mut[u32](0u32, 80u); // Initialize the first 16 words of the vector w t = 0; @@ -192,7 +192,7 @@ fn mk_sha1() -> sha1 { */ fn pad_msg(&sha1state st) { // FIXME: Should be a precondition - assert (_vec.len(st.msg_block) == msg_block_len); + assert (Vec.len(st.msg_block) == msg_block_len); /* * Check to see if the current message block is too small to hold @@ -236,7 +236,7 @@ fn mk_sha1() -> sha1 { fn reset() { // FIXME: Should be typestate precondition - assert (_vec.len(st.h) == digest_buf_len); + assert (Vec.len(st.h) == digest_buf_len); st.len_low = 0u32; st.len_high = 0u32; @@ -256,7 +256,7 @@ fn mk_sha1() -> sha1 { } fn input_str(&str msg) { - add_input(st, _str.bytes(msg)); + add_input(st, Str.bytes(msg)); } fn result() -> vec[u8] { @@ -267,16 +267,16 @@ fn mk_sha1() -> sha1 { auto r = mk_result(st); auto s = ""; for (u8 b in r) { - s += _uint.to_str(b as uint, 16u); + s += UInt.to_str(b as uint, 16u); } ret s; } } - auto st = rec(h = _vec.init_elt_mut[u32](0u32, digest_buf_len), + auto st = rec(h = Vec.init_elt_mut[u32](0u32, digest_buf_len), mutable len_low = 0u32, mutable len_high = 0u32, - msg_block = _vec.init_elt_mut[u8](0u8, msg_block_len), + msg_block = Vec.init_elt_mut[u8](0u8, msg_block_len), mutable msg_block_idx = 0u, mutable computed = false); auto sh = sha1(st); diff --git a/src/lib/sort.rs b/src/lib/Sort.rs index f712d22e..7ecaaaba 100644 --- a/src/lib/sort.rs +++ b/src/lib/Sort.rs @@ -1,5 +1,5 @@ -import _vec.len; -import _vec.slice; +import Vec.len; +import Vec.slice; type lteq[T] = fn(&T a, &T b) -> bool; diff --git a/src/lib/_str.rs b/src/lib/Str.rs index 5239afb1..3886ee19 100644 --- a/src/lib/_str.rs +++ b/src/lib/Str.rs @@ -1,6 +1,6 @@ import rustrt.sbuf; -import _vec.rustrt.vbuf; +import Vec.rustrt.vbuf; native "rust" mod rustrt { type sbuf; @@ -83,7 +83,7 @@ const uint tag_six_b = 0xfc_u; fn is_utf8(vec[u8] v) -> bool { auto i = 0u; - auto total = _vec.len[u8](v); + auto total = Vec.len[u8](v); while (i < total) { auto chsize = utf8_char_width(v.(i)); if (chsize == 0u) {ret false;} @@ -261,7 +261,7 @@ fn to_chars(str s) -> vec[char] { auto len = byte_len(s); while (i < len) { auto cur = char_range_at(s, i); - _vec.push[char](buf, cur._0); + Vec.push[char](buf, cur._0); i = cur._1; } ret buf; @@ -296,7 +296,7 @@ fn unshift_char(&mutable str s, char ch) { fn refcount(str s) -> uint { auto r = rustrt.refcount[u8](s); - if (r == dbg.const_refcount) { + if (r == Dbg.const_refcount) { ret r; } else { // -1 because calling this function incremented the refcount. @@ -319,7 +319,7 @@ fn index(str s, u8 c) -> int { } fn rindex(str s, u8 c) -> int { - let int n = _str.byte_len(s) as int; + let int n = Str.byte_len(s) as int; while (n >= 0) { if (s.(n) == c) { ret n; @@ -443,7 +443,7 @@ fn split(str s, u8 sep) -> vec[str] { ends_with_sep = false; } } - if (_str.byte_len(accum) != 0u || + if (Str.byte_len(accum) != 0u || ends_with_sep) { v += vec(accum); } diff --git a/src/lib/sys.rs b/src/lib/Sys.rs index 77eab003..77eab003 100644 --- a/src/lib/sys.rs +++ b/src/lib/Sys.rs diff --git a/src/lib/_task.rs b/src/lib/Task.rs index 8eece16b..8eece16b 100644 --- a/src/lib/_task.rs +++ b/src/lib/Task.rs diff --git a/src/lib/Term.rs b/src/lib/Term.rs index 368fe217..fca04bff 100644 --- a/src/lib/Term.rs +++ b/src/lib/Term.rs @@ -21,20 +21,20 @@ const u8 color_bright_magenta = 13u8; const u8 color_bright_cyan = 14u8; const u8 color_bright_white = 15u8; -fn esc(io.buf_writer writer) { +fn esc(IO.buf_writer writer) { writer.write(vec(0x1bu8, '[' as u8)); } -fn reset(io.buf_writer writer) { +fn reset(IO.buf_writer writer) { esc(writer); writer.write(vec('0' as u8, 'm' as u8)); } fn color_supported() -> bool { - ret _str.eq(GenericOS.getenv("TERM"), "xterm-color"); + ret Str.eq(GenericOS.getenv("TERM"), "xterm-color"); } -fn set_color(io.buf_writer writer, u8 first_char, u8 color) { +fn set_color(IO.buf_writer writer, u8 first_char, u8 color) { assert (color < 16u8); esc(writer); @@ -45,11 +45,11 @@ fn set_color(io.buf_writer writer, u8 first_char, u8 color) { writer.write(vec(first_char, ('0' as u8) + color, 'm' as u8)); } -fn fg(io.buf_writer writer, u8 color) { +fn fg(IO.buf_writer writer, u8 color) { ret set_color(writer, '3' as u8, color); } -fn bg(io.buf_writer writer, u8 color) { +fn bg(IO.buf_writer writer, u8 color) { ret set_color(writer, '4' as u8, color); } diff --git a/src/lib/_u8.rs b/src/lib/U8.rs index e094e581..e094e581 100644 --- a/src/lib/_u8.rs +++ b/src/lib/U8.rs diff --git a/src/lib/UFind.rs b/src/lib/UFind.rs index 9593e787..0bb06d7c 100644 --- a/src/lib/UFind.rs +++ b/src/lib/UFind.rs @@ -1,19 +1,19 @@ -import option.none; -import option.some; +import Option.none; +import Option.some; // A very naive implementation of union-find with unsigned integer nodes. -type node = option.t[uint]; +type node = Option.t[uint]; type ufind = rec(mutable vec[mutable node] nodes); fn make() -> ufind { let vec[mutable node] v = vec(mutable none[uint]); - _vec.pop(v); // FIXME: botch + Vec.pop(v); // FIXME: botch ret rec(mutable nodes=v); } fn make_set(&ufind ufnd) -> uint { - auto idx = _vec.len(ufnd.nodes); + auto idx = Vec.len(ufnd.nodes); ufnd.nodes += vec(mutable none[uint]); ret idx; } diff --git a/src/lib/_uint.rs b/src/lib/UInt.rs index 2d373cdd..eea52325 100644 --- a/src/lib/_uint.rs +++ b/src/lib/UInt.rs @@ -23,7 +23,7 @@ iter range(uint lo, uint hi) -> uint { fn next_power_of_two(uint n) -> uint { // FIXME change |* uint(4)| below to |* uint(8) / uint(2)| and watch the // world explode. - let uint halfbits = sys.rustrt.size_of[uint]() * 4u; + let uint halfbits = Sys.rustrt.size_of[uint]() * 4u; let uint tmp = n - 1u; let uint shift = 1u; while (shift <= halfbits) { @@ -34,12 +34,12 @@ fn next_power_of_two(uint n) -> uint { } fn parse_buf(vec[u8] buf, uint radix) -> uint { - if (_vec.len[u8](buf) == 0u) { + if (Vec.len[u8](buf) == 0u) { log_err "parse_buf(): buf is empty"; fail; } - auto i = _vec.len[u8](buf) - 1u; + auto i = Vec.len[u8](buf) - 1u; auto power = 1u; auto n = 0u; while (true) { @@ -83,15 +83,15 @@ fn to_str(uint num, uint radix) -> str let str s = ""; while (n != 0u) { - s += _str.unsafe_from_byte(digit(n % radix) as u8); + s += Str.unsafe_from_byte(digit(n % radix) as u8); n /= radix; } let str s1 = ""; - let uint len = _str.byte_len(s); + let uint len = Str.byte_len(s); while (len != 0u) { len -= 1u; - s1 += _str.unsafe_from_byte(s.(len)); + s1 += Str.unsafe_from_byte(s.(len)); } ret s1; diff --git a/src/lib/util.rs b/src/lib/Util.rs index 2f797f69..a385aafd 100644 --- a/src/lib/util.rs +++ b/src/lib/Util.rs @@ -4,7 +4,7 @@ fn id[T](&T x) -> T { /* FIXME (issue #141): See test/run-pass/constrained-type.rs. Uncomment * the constraint once fixed. */ -type rational = rec(int num, int den); // : _int.positive(*.den); +type rational = rec(int num, int den); // : Int.positive(*.den); fn rational_leq(&rational x, &rational y) -> bool { // NB: Uses the fact that rationals have positive denominators WLOG. diff --git a/src/lib/_vec.rs b/src/lib/Vec.rs index 3a197ac2..28b5d018 100644 --- a/src/lib/_vec.rs +++ b/src/lib/Vec.rs @@ -1,6 +1,6 @@ -import option.none; -import option.some; -import util.orb; +import Option.none; +import Option.some; +import Util.orb; type vbuf = rustrt.vbuf; @@ -47,7 +47,7 @@ fn alloc_mut[T](uint n_elts) -> vec[mutable T] { fn refcount[T](array[T] v) -> uint { auto r = rustrt.refcount[T](v); - if (r == dbg.const_refcount) { + if (r == Dbg.const_refcount) { ret r; } else { // -1 because calling this function incremented the refcount. @@ -140,7 +140,7 @@ fn print_debug_info[T](array[T] v) { } // Returns the last element of v. -fn last[T](array[T] v) -> option.t[T] { +fn last[T](array[T] v) -> Option.t[T] { auto l = len[T](v); if (l == 0u) { ret none[T]; @@ -199,14 +199,14 @@ fn grow[T](&array[T] v, uint n, &T initval) { } fn grow_set[T](&vec[mutable T] v, uint index, &T initval, &T val) { - auto length = _vec.len(v); + auto length = Vec.len(v); if (index >= length) { grow(v, index - length + 1u, initval); } v.(index) = val; } -fn map[T, U](&option.operator[T,U] f, &array[T] v) -> vec[U] { +fn map[T, U](&Option.operator[T,U] f, &array[T] v) -> vec[U] { let vec[U] u = alloc[U](len[T](v)); for (T ve in v) { u += vec(f(ve)); @@ -230,7 +230,7 @@ fn map2[T,U,V](&operator2[T,U,V] f, &array[T] v0, &array[U] v1) -> vec[V] { ret u; } -fn find[T](fn (&T) -> bool f, &array[T] v) -> option.t[T] { +fn find[T](fn (&T) -> bool f, &array[T] v) -> Option.t[T] { for (T elt in v) { if (f(elt)) { ret some[T](elt); @@ -270,24 +270,24 @@ fn unzip[T, U](&vec[tup(T, U)] v) -> tup(vec[T], vec[U]) { fn or(&vec[bool] v) -> bool { auto f = orb; - ret _vec.foldl[bool, bool](f, false, v); + ret Vec.foldl[bool, bool](f, false, v); } fn clone[T](&vec[T] v) -> vec[T] { ret slice[T](v, 0u, len[T](v)); } -fn plus_option[T](&vec[T] v, &option.t[T] o) -> () { +fn plus_option[T](&vec[T] v, &Option.t[T] o) -> () { alt (o) { case (none[T]) {} case (some[T](?x)) { v += vec(x); } } } -fn cat_options[T](&vec[option.t[T]] v) -> vec[T] { +fn cat_options[T](&vec[Option.t[T]] v) -> vec[T] { let vec[T] res = vec(); - for (option.t[T] o in v) { + for (Option.t[T] o in v) { alt (o) { case (none[T]) { } case (some[T](?t)) { diff --git a/src/lib/linux_os.rs b/src/lib/linux_OS.rs index a37db418..02c9183b 100644 --- a/src/lib/linux_os.rs +++ b/src/lib/linux_OS.rs @@ -1,5 +1,5 @@ -import _str.sbuf; -import _vec.vbuf; +import Str.sbuf; +import Vec.vbuf; // FIXME Somehow merge stuff duplicated here and macosx_os.rs. Made difficult // by https://github.com/graydon/rust/issues#issue/268 @@ -66,17 +66,17 @@ fn dylib_filename(str base) -> str { fn pipe() -> tup(int, int) { let vec[mutable int] fds = vec(mutable 0, 0); - assert (os.libc.pipe(_vec.buf(fds)) == 0); + assert (OS.libc.pipe(Vec.buf(fds)) == 0); ret tup(fds.(0), fds.(1)); } fn fd_FILE(int fd) -> libc.FILE { - ret libc.fdopen(fd, _str.buf("r")); + ret libc.fdopen(fd, Str.buf("r")); } fn waitpid(int pid) -> int { let vec[mutable int] status = vec(mutable 0); - assert (os.libc.waitpid(pid, _vec.buf(status), 0) != -1); + assert (OS.libc.waitpid(pid, Vec.buf(status), 0) != -1); ret status.(0); } diff --git a/src/lib/macos_os.rs b/src/lib/macos_OS.rs index a52b02c5..700ac17c 100644 --- a/src/lib/macos_os.rs +++ b/src/lib/macos_OS.rs @@ -1,5 +1,5 @@ -import _str.sbuf; -import _vec.vbuf; +import Str.sbuf; +import Vec.vbuf; native mod libc = "libc.dylib" { @@ -63,17 +63,17 @@ fn dylib_filename(str base) -> str { fn pipe() -> tup(int, int) { let vec[mutable int] fds = vec(mutable 0, 0); - assert (os.libc.pipe(_vec.buf[mutable int](fds)) == 0); + assert (OS.libc.pipe(Vec.buf[mutable int](fds)) == 0); ret tup(fds.(0), fds.(1)); } fn fd_FILE(int fd) -> libc.FILE { - ret libc.fdopen(fd, _str.buf("r")); + ret libc.fdopen(fd, Str.buf("r")); } fn waitpid(int pid) -> int { let vec[mutable int] status = vec(mutable 0); - assert (os.libc.waitpid(pid, _vec.buf[mutable int](status), 0) != -1); + assert (OS.libc.waitpid(pid, Vec.buf[mutable int](status), 0) != -1); ret status.(0); } diff --git a/src/lib/posix_fs.rs b/src/lib/posix_FS.rs index 99f411e7..b1f01a66 100644 --- a/src/lib/posix_fs.rs +++ b/src/lib/posix_FS.rs @@ -1,21 +1,21 @@ native "rust" mod rustrt { - fn rust_dirent_filename(os.libc.dirent ent) -> str; + fn rust_dirent_filename(OS.libc.dirent ent) -> str; } fn list_dir(str path) -> vec[str] { // TODO ensure this is always closed - auto dir = os.libc.opendir(_str.buf(path)); + auto dir = OS.libc.opendir(Str.buf(path)); assert (dir as uint != 0u); let vec[str] result = vec(); while (true) { - auto ent = os.libc.readdir(dir); + auto ent = OS.libc.readdir(dir); if (ent as int == 0) { - os.libc.closedir(dir); + OS.libc.closedir(dir); ret result; } - _vec.push[str](result, rustrt.rust_dirent_filename(ent)); + Vec.push[str](result, rustrt.rust_dirent_filename(ent)); } - os.libc.closedir(dir); + OS.libc.closedir(dir); ret result; } diff --git a/src/lib/std.rc b/src/lib/std.rc index 44a0689c..a317b114 100644 --- a/src/lib/std.rc +++ b/src/lib/std.rc @@ -6,39 +6,38 @@ meta (name = "std", // Built-in types support modules. -mod _int; -mod _uint; -mod _u8; -mod _vec; -mod _str; +mod Int; +mod UInt; +mod U8; +mod Vec; +mod Str; // General IO and system-services modules. -mod io; -mod sys; -mod _task; +mod IO; +mod Sys; +mod Task; // Utility modules. -mod option; -mod util; +mod Option; +mod Util; // Authorize various rule-bendings. -auth io = unsafe; -auth fs = unsafe; -auth os = unsafe; -auth os_fs = unsafe; -auth run = unsafe; -auth _str = unsafe; -auth _vec = unsafe; -auth _task = unsafe; +auth IO = unsafe; +auth FS = unsafe; +auth OS_FS = unsafe; +auth Run = unsafe; +auth Str = unsafe; +auth Vec = unsafe; +auth Task = unsafe; -auth dbg = unsafe; +auth Dbg = unsafe; -auth _uint.next_power_of_two = unsafe; -auth map.mk_hashmap = unsafe; -auth rand.mk_rng = unsafe; +auth UInt.next_power_of_two = unsafe; +auth Map.mk_hashmap = unsafe; +auth Rand.mk_rng = unsafe; // Target-OS module. @@ -47,30 +46,30 @@ mod GenericOS; alt (target_os) { case ("win32") { - mod os = "win32_os.rs"; - mod os_fs = "win32_fs.rs"; + mod OS = "win32_OS.rs"; + mod OS_FS = "win32_FS.rs"; } case ("macos") { - mod os = "macos_os.rs"; - mod os_fs = "posix_fs.rs"; + mod OS = "macos_OS.rs"; + mod OS_FS = "posix_FS.rs"; } else { - mod os = "linux_os.rs"; - mod os_fs = "posix_fs.rs"; + mod OS = "linux_OS.rs"; + mod OS_FS = "posix_FS.rs"; } } -mod run = "run_program.rs"; -mod fs; +mod Run = "Run_Program.rs"; +mod FS; // FIXME: parametric -mod map; -mod deque; -mod list; -mod rand; -mod dbg; -mod bitv; -mod sort; -mod sha1; -mod ebml; +mod Map; +mod Deque; +mod List; +mod Rand; +mod Dbg; +mod BitV; +mod Sort; +mod SHA1; +mod EBML; mod UFind; mod ExtFmt; mod Box; diff --git a/src/lib/win32_fs.rs b/src/lib/win32_FS.rs index 94599e3c..94599e3c 100644 --- a/src/lib/win32_fs.rs +++ b/src/lib/win32_FS.rs diff --git a/src/lib/win32_os.rs b/src/lib/win32_OS.rs index 1c6521e3..b799287c 100644 --- a/src/lib/win32_os.rs +++ b/src/lib/win32_OS.rs @@ -1,5 +1,5 @@ -import _str.sbuf; -import _vec.vbuf; +import Str.sbuf; +import Vec.vbuf; native mod libc = "msvcrt.dll" { fn open(sbuf s, int flags, uint mode) -> int = "_open"; @@ -53,13 +53,13 @@ fn dylib_filename(str base) -> str { fn pipe() -> tup(int, int) { let vec[mutable int] fds = vec(mutable 0, 0); - assert (os.libc._pipe(_vec.buf[mutable int](fds), 1024u, + assert (OS.libc._pipe(Vec.buf[mutable int](fds), 1024u, libc_constants.O_BINARY()) == 0); ret tup(fds.(0), fds.(1)); } fn fd_FILE(int fd) -> libc.FILE { - ret libc._fdopen(fd, _str.buf("r")); + ret libc._fdopen(fd, Str.buf("r")); } native "rust" mod rustrt { diff --git a/src/test/bench/99-bottles/99bob-iter.rs b/src/test/bench/99-bottles/99bob-iter.rs index 09638941..e8cc4b4b 100644 --- a/src/test/bench/99-bottles/99bob-iter.rs +++ b/src/test/bench/99-bottles/99bob-iter.rs @@ -3,8 +3,8 @@ * http://99-bottles-of-beer.net/ */ use std; -import std._int; -import std._str; +import std.Int; +import std.Str; fn b1() -> str { ret "# of beer on the wall, # of beer."; @@ -32,15 +32,15 @@ case (1) { ns = "1 bottle"; } case (_) { - ns = _int.to_str(n, 10u) + " bottles"; + ns = Int.to_str(n, 10u) + " bottles"; } } - while (i < _str.byte_len(t)) { + while (i < Str.byte_len(t)) { if (t.(i) == ('#' as u8)) { b += ns; } else { - _str.push_byte(b, t.(i)); + Str.push_byte(b, t.(i)); } i += 1u; } diff --git a/src/test/bench/99-bottles/99bob-pattern.rs b/src/test/bench/99-bottles/99bob-pattern.rs index 58d2d2c3..fc9ddddb 100644 --- a/src/test/bench/99-bottles/99bob-pattern.rs +++ b/src/test/bench/99-bottles/99bob-pattern.rs @@ -3,8 +3,8 @@ * http://99-bottles-of-beer.net/ */ use std; -import std._int; -import std._str; +import std.Int; +import std.Str; tag bottle { none; dual; single; multiple(int);} @@ -25,8 +25,8 @@ fn show(bottle b) { log "Take one down and pass it around, 1 bottle of beer on the wall."; } case (multiple(?n)) { - let str nb = _int.to_str(n, 10u); - let str mb = _int.to_str(n - 1, 10u); + let str nb = Int.to_str(n, 10u); + let str mb = Int.to_str(n - 1, 10u); log nb + " bottles of beer on the wall, " + nb + " bottles of beer,"; log "Take one down and pass it around, " + mb + " bottles of beer on the wall."; diff --git a/src/test/bench/99-bottles/99bob-simple.rs b/src/test/bench/99-bottles/99bob-simple.rs index 3c426f51..5c0f0824 100644 --- a/src/test/bench/99-bottles/99bob-simple.rs +++ b/src/test/bench/99-bottles/99bob-simple.rs @@ -3,8 +3,8 @@ * http://99-bottles-of-beer.net/ */ use std; -import std._int; -import std._str; +import std.Int; +import std.Str; fn b1() -> str { ret "# of beer on the wall, # of beer."; @@ -31,15 +31,15 @@ case (1) { ns = "1 bottle"; } case (_) { - ns = _int.to_str(n, 10u) + " bottles"; + ns = Int.to_str(n, 10u) + " bottles"; } } - while (i < _str.byte_len(t)) { + while (i < Str.byte_len(t)) { if (t.(i) == ('#' as u8)) { b += ns; } else { - _str.push_byte(b, t.(i)); + Str.push_byte(b, t.(i)); } i += 1u; } diff --git a/src/test/bench/99-bottles/99bob-tail.rs b/src/test/bench/99-bottles/99bob-tail.rs index 16e66d33..985d9b4b 100644 --- a/src/test/bench/99-bottles/99bob-tail.rs +++ b/src/test/bench/99-bottles/99bob-tail.rs @@ -3,13 +3,13 @@ * http://99-bottles-of-beer.net/ */ use std; -import std._int; -import std._str; +import std.Int; +import std.Str; fn main() { fn multiple(int n) { - let str nb = _int.to_str(n, 10u); - let str mb = _int.to_str(n - 1, 10u); + let str nb = Int.to_str(n, 10u); + let str mb = Int.to_str(n - 1, 10u); log nb + " bottles of beer on the wall, " + nb + " bottles of beer,"; log "Take one down and pass it around, " + mb + " bottles of beer on the wall."; diff --git a/src/test/bench/shootout/binarytrees.rs b/src/test/bench/shootout/binarytrees.rs index 92bedb8b..aa81aaac 100644 --- a/src/test/bench/shootout/binarytrees.rs +++ b/src/test/bench/shootout/binarytrees.rs @@ -1,6 +1,6 @@ use std; -import std._int; +import std.Int; tag tree { nil; @@ -49,7 +49,7 @@ fn main() { auto depth = min_depth; while (depth <= max_depth) { - auto iterations = _int.pow(2, (max_depth - depth + min_depth) as uint); + auto iterations = Int.pow(2, (max_depth - depth + min_depth) as uint); auto chk = 0; auto i = 1; diff --git a/src/test/bench/shootout/fannkuchredux.rs b/src/test/bench/shootout/fannkuchredux.rs index 7853a892..ad3d7dd2 100644 --- a/src/test/bench/shootout/fannkuchredux.rs +++ b/src/test/bench/shootout/fannkuchredux.rs @@ -2,8 +2,8 @@ use std; -import std._int; -import std._vec; +import std.Int; +import std.Vec; fn fannkuch(int n) -> int { @@ -12,9 +12,9 @@ fn fannkuch(int n) -> int { } auto perm1init_ = perm1init; // Rustboot workaround - auto perm = _vec.init_elt[mutable int](0, n as uint); - auto perm1 = _vec.init_fn[mutable int](perm1init_, n as uint); - auto count = _vec.init_elt[mutable int](0, n as uint); + auto perm = Vec.init_elt[mutable int](0, n as uint); + auto perm1 = Vec.init_fn[mutable int](perm1init_, n as uint); + auto count = Vec.init_elt[mutable int](0, n as uint); auto f = 0; auto i = 0; diff --git a/src/test/bench/shootout/fasta.rs b/src/test/bench/shootout/fasta.rs index 7afa1a7a..3543c298 100644 --- a/src/test/bench/shootout/fasta.rs +++ b/src/test/bench/shootout/fasta.rs @@ -7,10 +7,10 @@ * http://shootout.alioth.debian.org/ */ use std; -import std._vec; -import std._str; -import std._uint; -import std._int; +import std.Vec; +import std.Str; +import std.UInt; +import std.Int; fn LINE_LENGTH() -> uint { ret 60u; @@ -54,21 +54,21 @@ fn select_random(u32 r, vec[aminoacids] genelist) -> char { ret v.(hi)._0; } } - ret bisect(genelist, 0u, _vec.len[aminoacids](genelist) - 1u, r); + ret bisect(genelist, 0u, Vec.len[aminoacids](genelist) - 1u, r); } fn make_random_fasta(str id, str desc, vec[aminoacids] genelist, int n) { log(">" + id + " " + desc); - auto rng = myrandom(std.rand.mk_rng().next()); + auto rng = myrandom(std.Rand.mk_rng().next()); let str op = ""; - for each (uint i in _uint.range(0u, n as uint)) { - _str.push_byte(op, select_random(rng.next(100u32), genelist) as u8); - if (_str.byte_len(op) >= LINE_LENGTH()) { + for each (uint i in UInt.range(0u, n as uint)) { + Str.push_byte(op, select_random(rng.next(100u32), genelist) as u8); + if (Str.byte_len(op) >= LINE_LENGTH()) { log(op); op = ""; } } - if (_str.byte_len(op) > 0u) { + if (Str.byte_len(op) > 0u) { log(op); } } @@ -76,16 +76,16 @@ fn make_random_fasta(str id, str desc, vec[aminoacids] genelist, int n) { fn make_repeat_fasta(str id, str desc, str s, int n) { log(">" + id + " " + desc); let str op = ""; - let uint sl = _str.byte_len(s); - for each (uint i in _uint.range(0u, n as uint)) { + let uint sl = Str.byte_len(s); + for each (uint i in UInt.range(0u, n as uint)) { - _str.push_byte(op, s.(i % sl)); - if (_str.byte_len(op) >= LINE_LENGTH()) { + Str.push_byte(op, s.(i % sl)); + if (Str.byte_len(op) >= LINE_LENGTH()) { log(op); op = ""; } } - if (_str.byte_len(op) > 0u) { + if (Str.byte_len(op) > 0u) { log(op); } } diff --git a/src/test/run-pass/alt-join.rs b/src/test/run-pass/alt-join.rs index 152fac5d..8f45e6ff 100644 --- a/src/test/run-pass/alt-join.rs +++ b/src/test/run-pass/alt-join.rs @@ -1,10 +1,10 @@ use std; -import std.option; -import std.option.t; -import std.option.none; -import std.option.some; +import std.Option; +import std.Option.t; +import std.Option.none; +import std.Option.some; -fn foo[T](&option.t[T] y) { +fn foo[T](&Option.t[T] y) { let int x; let vec[int] res = vec(); diff --git a/src/test/run-pass/alt-pattern-drop.rs b/src/test/run-pass/alt-pattern-drop.rs index b92ffd74..76e7c3aa 100644 --- a/src/test/run-pass/alt-pattern-drop.rs +++ b/src/test/run-pass/alt-pattern-drop.rs @@ -1,9 +1,9 @@ // -*- rust -*- use std; -import std._str; +import std.Str; -// FIXME: import std.dbg.const_refcount. Currently +// FIXME: import std.Dbg.const_refcount. Currently // cross-crate const references don't work. const uint const_refcount = 0x7bad_face_u; @@ -20,13 +20,13 @@ fn foo(str s) { case (_) { log "?"; fail; } } - log _str.refcount(s); - assert (_str.refcount(s) == const_refcount); + log Str.refcount(s); + assert (Str.refcount(s) == const_refcount); } fn main() { let str s = "hi"; // ref up foo(s); // ref up then down - log _str.refcount(s); - assert (_str.refcount(s) == const_refcount); + log Str.refcount(s); + assert (Str.refcount(s) == const_refcount); } diff --git a/src/test/run-pass/lib-bitv.rs b/src/test/run-pass/lib-bitv.rs index 8f2d9390..b047f47a 100644 --- a/src/test/run-pass/lib-bitv.rs +++ b/src/test/run-pass/lib-bitv.rs @@ -1,132 +1,132 @@ use std; -import std._vec; -import std.bitv; +import std.Vec; +import std.BitV; fn test_0_elements() { auto act; auto exp; - act = bitv.create(0u, false); - exp = _vec.init_elt[uint](0u, 0u); + act = BitV.create(0u, false); + exp = Vec.init_elt[uint](0u, 0u); // FIXME: why can't I write vec[uint]()? - assert (bitv.eq_vec(act, exp)); + assert (BitV.eq_vec(act, exp)); } fn test_1_element() { auto act; - act = bitv.create(1u, false); - assert (bitv.eq_vec(act, vec(0u))); + act = BitV.create(1u, false); + assert (BitV.eq_vec(act, vec(0u))); - act = bitv.create(1u, true); - assert (bitv.eq_vec(act, vec(1u))); + act = BitV.create(1u, true); + assert (BitV.eq_vec(act, vec(1u))); } fn test_10_elements() { auto act; // all 0 - act = bitv.create(10u, false); - assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u))); + act = BitV.create(10u, false); + assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u))); // all 1 - act = bitv.create(10u, true); - assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u))); + act = BitV.create(10u, true); + assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u))); // mixed - act = bitv.create(10u, false); - bitv.set(act, 0u, true); - bitv.set(act, 1u, true); - bitv.set(act, 2u, true); - bitv.set(act, 3u, true); - bitv.set(act, 4u, true); - assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u))); + act = BitV.create(10u, false); + BitV.set(act, 0u, true); + BitV.set(act, 1u, true); + BitV.set(act, 2u, true); + BitV.set(act, 3u, true); + BitV.set(act, 4u, true); + assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u))); // mixed - act = bitv.create(10u, false); - bitv.set(act, 5u, true); - bitv.set(act, 6u, true); - bitv.set(act, 7u, true); - bitv.set(act, 8u, true); - bitv.set(act, 9u, true); - assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u))); + act = BitV.create(10u, false); + BitV.set(act, 5u, true); + BitV.set(act, 6u, true); + BitV.set(act, 7u, true); + BitV.set(act, 8u, true); + BitV.set(act, 9u, true); + assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u))); // mixed - act = bitv.create(10u, false); - bitv.set(act, 0u, true); - bitv.set(act, 3u, true); - bitv.set(act, 6u, true); - bitv.set(act, 9u, true); - assert (bitv.eq_vec(act, vec(1u, 0u, 0u, 1u, 0u, 0u, 1u, 0u, 0u, 1u))); + act = BitV.create(10u, false); + BitV.set(act, 0u, true); + BitV.set(act, 3u, true); + BitV.set(act, 6u, true); + BitV.set(act, 9u, true); + assert (BitV.eq_vec(act, vec(1u, 0u, 0u, 1u, 0u, 0u, 1u, 0u, 0u, 1u))); } fn test_31_elements() { auto act; // all 0 - act = bitv.create(31u, false); - assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + act = BitV.create(31u, false); + assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u))); // all 1 - act = bitv.create(31u, true); - assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, + act = BitV.create(31u, true); + assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u))); // mixed - act = bitv.create(31u, false); - bitv.set(act, 0u, true); - bitv.set(act, 1u, true); - bitv.set(act, 2u, true); - bitv.set(act, 3u, true); - bitv.set(act, 4u, true); - bitv.set(act, 5u, true); - bitv.set(act, 6u, true); - bitv.set(act, 7u, true); - assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, + act = BitV.create(31u, false); + BitV.set(act, 0u, true); + BitV.set(act, 1u, true); + BitV.set(act, 2u, true); + BitV.set(act, 3u, true); + BitV.set(act, 4u, true); + BitV.set(act, 5u, true); + BitV.set(act, 6u, true); + BitV.set(act, 7u, true); + assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u))); // mixed - act = bitv.create(31u, false); - bitv.set(act, 16u, true); - bitv.set(act, 17u, true); - bitv.set(act, 18u, true); - bitv.set(act, 19u, true); - bitv.set(act, 20u, true); - bitv.set(act, 21u, true); - bitv.set(act, 22u, true); - bitv.set(act, 23u, true); - assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + act = BitV.create(31u, false); + BitV.set(act, 16u, true); + BitV.set(act, 17u, true); + BitV.set(act, 18u, true); + BitV.set(act, 19u, true); + BitV.set(act, 20u, true); + BitV.set(act, 21u, true); + BitV.set(act, 22u, true); + BitV.set(act, 23u, true); + assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u))); // mixed - act = bitv.create(31u, false); - bitv.set(act, 24u, true); - bitv.set(act, 25u, true); - bitv.set(act, 26u, true); - bitv.set(act, 27u, true); - bitv.set(act, 28u, true); - bitv.set(act, 29u, true); - bitv.set(act, 30u, true); - assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + act = BitV.create(31u, false); + BitV.set(act, 24u, true); + BitV.set(act, 25u, true); + BitV.set(act, 26u, true); + BitV.set(act, 27u, true); + BitV.set(act, 28u, true); + BitV.set(act, 29u, true); + BitV.set(act, 30u, true); + assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u))); // mixed - act = bitv.create(31u, false); - bitv.set(act, 3u, true); - bitv.set(act, 17u, true); - bitv.set(act, 30u, true); - assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, + act = BitV.create(31u, false); + BitV.set(act, 3u, true); + BitV.set(act, 17u, true); + BitV.set(act, 30u, true); + assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u))); @@ -136,71 +136,71 @@ fn test_32_elements() { auto act; // all 0 - act = bitv.create(32u, false); - assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + act = BitV.create(32u, false); + assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u))); // all 1 - act = bitv.create(32u, true); - assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, + act = BitV.create(32u, true); + assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u))); // mixed - act = bitv.create(32u, false); - bitv.set(act, 0u, true); - bitv.set(act, 1u, true); - bitv.set(act, 2u, true); - bitv.set(act, 3u, true); - bitv.set(act, 4u, true); - bitv.set(act, 5u, true); - bitv.set(act, 6u, true); - bitv.set(act, 7u, true); - assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, + act = BitV.create(32u, false); + BitV.set(act, 0u, true); + BitV.set(act, 1u, true); + BitV.set(act, 2u, true); + BitV.set(act, 3u, true); + BitV.set(act, 4u, true); + BitV.set(act, 5u, true); + BitV.set(act, 6u, true); + BitV.set(act, 7u, true); + assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u))); // mixed - act = bitv.create(32u, false); - bitv.set(act, 16u, true); - bitv.set(act, 17u, true); - bitv.set(act, 18u, true); - bitv.set(act, 19u, true); - bitv.set(act, 20u, true); - bitv.set(act, 21u, true); - bitv.set(act, 22u, true); - bitv.set(act, 23u, true); - assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + act = BitV.create(32u, false); + BitV.set(act, 16u, true); + BitV.set(act, 17u, true); + BitV.set(act, 18u, true); + BitV.set(act, 19u, true); + BitV.set(act, 20u, true); + BitV.set(act, 21u, true); + BitV.set(act, 22u, true); + BitV.set(act, 23u, true); + assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u))); // mixed - act = bitv.create(32u, false); - bitv.set(act, 24u, true); - bitv.set(act, 25u, true); - bitv.set(act, 26u, true); - bitv.set(act, 27u, true); - bitv.set(act, 28u, true); - bitv.set(act, 29u, true); - bitv.set(act, 30u, true); - bitv.set(act, 31u, true); - assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + act = BitV.create(32u, false); + BitV.set(act, 24u, true); + BitV.set(act, 25u, true); + BitV.set(act, 26u, true); + BitV.set(act, 27u, true); + BitV.set(act, 28u, true); + BitV.set(act, 29u, true); + BitV.set(act, 30u, true); + BitV.set(act, 31u, true); + assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u))); // mixed - act = bitv.create(32u, false); - bitv.set(act, 3u, true); - bitv.set(act, 17u, true); - bitv.set(act, 30u, true); - bitv.set(act, 31u, true); - assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, + act = BitV.create(32u, false); + BitV.set(act, 3u, true); + BitV.set(act, 17u, true); + BitV.set(act, 30u, true); + BitV.set(act, 31u, true); + assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u))); @@ -210,77 +210,77 @@ fn test_33_elements() { auto act; // all 0 - act = bitv.create(33u, false); - assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + act = BitV.create(33u, false); + assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u))); // all 1 - act = bitv.create(33u, true); - assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, + act = BitV.create(33u, true); + assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u))); // mixed - act = bitv.create(33u, false); - bitv.set(act, 0u, true); - bitv.set(act, 1u, true); - bitv.set(act, 2u, true); - bitv.set(act, 3u, true); - bitv.set(act, 4u, true); - bitv.set(act, 5u, true); - bitv.set(act, 6u, true); - bitv.set(act, 7u, true); - assert (bitv.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, + act = BitV.create(33u, false); + BitV.set(act, 0u, true); + BitV.set(act, 1u, true); + BitV.set(act, 2u, true); + BitV.set(act, 3u, true); + BitV.set(act, 4u, true); + BitV.set(act, 5u, true); + BitV.set(act, 6u, true); + BitV.set(act, 7u, true); + assert (BitV.eq_vec(act, vec(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u))); // mixed - act = bitv.create(33u, false); - bitv.set(act, 16u, true); - bitv.set(act, 17u, true); - bitv.set(act, 18u, true); - bitv.set(act, 19u, true); - bitv.set(act, 20u, true); - bitv.set(act, 21u, true); - bitv.set(act, 22u, true); - bitv.set(act, 23u, true); - assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + act = BitV.create(33u, false); + BitV.set(act, 16u, true); + BitV.set(act, 17u, true); + BitV.set(act, 18u, true); + BitV.set(act, 19u, true); + BitV.set(act, 20u, true); + BitV.set(act, 21u, true); + BitV.set(act, 22u, true); + BitV.set(act, 23u, true); + assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u))); // mixed - act = bitv.create(33u, false); - bitv.set(act, 24u, true); - bitv.set(act, 25u, true); - bitv.set(act, 26u, true); - bitv.set(act, 27u, true); - bitv.set(act, 28u, true); - bitv.set(act, 29u, true); - bitv.set(act, 30u, true); - bitv.set(act, 31u, true); - assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + act = BitV.create(33u, false); + BitV.set(act, 24u, true); + BitV.set(act, 25u, true); + BitV.set(act, 26u, true); + BitV.set(act, 27u, true); + BitV.set(act, 28u, true); + BitV.set(act, 29u, true); + BitV.set(act, 30u, true); + BitV.set(act, 31u, true); + assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u))); // mixed - act = bitv.create(33u, false); - bitv.set(act, 3u, true); - bitv.set(act, 17u, true); - bitv.set(act, 30u, true); - bitv.set(act, 31u, true); - bitv.set(act, 32u, true); - assert (bitv.eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, + act = BitV.create(33u, false); + BitV.set(act, 3u, true); + BitV.set(act, 17u, true); + BitV.set(act, 30u, true); + BitV.set(act, 31u, true); + BitV.set(act, 32u, true); + assert (BitV.eq_vec(act, vec(0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, diff --git a/src/test/run-pass/lib-deque.rs b/src/test/run-pass/lib-deque.rs index 405ab72b..9de238dc 100644 --- a/src/test/run-pass/lib-deque.rs +++ b/src/test/run-pass/lib-deque.rs @@ -1,10 +1,10 @@ // -*- rust -*- use std; -import std.deque; +import std.Deque; fn test_simple() { - let deque.t[int] d = deque.create[int](); + let Deque.t[int] d = Deque.create[int](); assert (d.size() == 0u); d.add_front(17); d.add_front(42); @@ -57,7 +57,7 @@ fn test_simple() { } fn test_boxes(@int a, @int b, @int c, @int d) { - let deque.t[@int] deq = deque.create[@int](); + let Deque.t[@int] deq = Deque.create[@int](); assert (deq.size() == 0u); deq.add_front(a); deq.add_front(b); @@ -93,7 +93,7 @@ fn test_boxes(@int a, @int b, @int c, @int d) { type eqfn[T] = fn(&T a, &T b) -> bool; fn test_parameterized[T](eqfn[T] e, &T a, &T b, &T c, &T d) { - let deque.t[T] deq = deque.create[T](); + let Deque.t[T] deq = Deque.create[T](); assert (deq.size() == 0u); deq.add_front(a); deq.add_front(b); diff --git a/src/test/run-pass/lib-int.rs b/src/test/run-pass/lib-int.rs index e4e68351..a5a9a2a1 100644 --- a/src/test/run-pass/lib-int.rs +++ b/src/test/run-pass/lib-int.rs @@ -1,25 +1,25 @@ use std; -import std._int; -import std._str.eq; +import std.Int; +import std.Str.eq; fn test_to_str() { - assert (eq(_int.to_str(0, 10u), "0")); - assert (eq(_int.to_str(1, 10u), "1")); - assert (eq(_int.to_str(-1, 10u), "-1")); - assert (eq(_int.to_str(255, 16u), "ff")); - assert (eq(_int.to_str(100, 10u), "100")); + assert (eq(Int.to_str(0, 10u), "0")); + assert (eq(Int.to_str(1, 10u), "1")); + assert (eq(Int.to_str(-1, 10u), "-1")); + assert (eq(Int.to_str(255, 16u), "ff")); + assert (eq(Int.to_str(100, 10u), "100")); } fn test_pow() { - assert (_int.pow(0, 0u) == 1); - assert (_int.pow(0, 1u) == 0); - assert (_int.pow(0, 2u) == 0); - assert (_int.pow(-1, 0u) == -1); - assert (_int.pow(1, 0u) == 1); - assert (_int.pow(-3, 2u) == 9); - assert (_int.pow(-3, 3u) == -27); - assert (_int.pow(4, 9u) == 262144); + assert (Int.pow(0, 0u) == 1); + assert (Int.pow(0, 1u) == 0); + assert (Int.pow(0, 2u) == 0); + assert (Int.pow(-1, 0u) == -1); + assert (Int.pow(1, 0u) == 1); + assert (Int.pow(-3, 2u) == 9); + assert (Int.pow(-3, 3u) == -27); + assert (Int.pow(4, 9u) == 262144); } fn main() { diff --git a/src/test/run-pass/lib-io.rs b/src/test/run-pass/lib-io.rs index 5c97c2f0..e124cde3 100644 --- a/src/test/run-pass/lib-io.rs +++ b/src/test/run-pass/lib-io.rs @@ -5,8 +5,8 @@ // -*- rust -*- use std; -import std.io; -import std._str; +import std.IO; +import std.Str; fn test_simple(str tmpfilebase) { let str tmpfile = tmpfilebase + ".tmp"; @@ -15,14 +15,14 @@ fn test_simple(str tmpfilebase) { log frood; { - let io.writer out = io.file_writer(tmpfile, vec(io.create)); + let IO.writer out = IO.file_writer(tmpfile, vec(IO.create)); out.write_str(frood); } - let io.reader inp = io.file_reader(tmpfile); + let IO.reader inp = IO.file_reader(tmpfile); let str frood2 = inp.read_c_str(); log frood2; - assert (_str.eq(frood, frood2)); + assert (Str.eq(frood, frood2)); } fn main(vec[str] argv) { diff --git a/src/test/run-pass/lib-map.rs b/src/test/run-pass/lib-map.rs index abd2041e..1f956055 100644 --- a/src/test/run-pass/lib-map.rs +++ b/src/test/run-pass/lib-map.rs @@ -1,31 +1,31 @@ // -*- rust -*- use std; -import std.map; -import std._str; -import std._uint; -import std.util; +import std.Map; +import std.Str; +import std.UInt; +import std.Util; fn test_simple() { log "*** starting test_simple"; fn eq_uint(&uint x, &uint y) -> bool { ret x == y; } fn hash_uint(&uint u) -> uint { - // FIXME: can't use std.util.id since we'd be capturing a type param, + // FIXME: can't use std.Util.id since we'd be capturing a type param, // and presently we can't close items over type params. ret u; } - let map.hashfn[uint] hasher_uint = hash_uint; - let map.eqfn[uint] eqer_uint = eq_uint; + let Map.hashfn[uint] hasher_uint = hash_uint; + let Map.eqfn[uint] eqer_uint = eq_uint; - let map.hashfn[str] hasher_str = _str.hash; - let map.eqfn[str] eqer_str = _str.eq; + let Map.hashfn[str] hasher_str = Str.hash; + let Map.eqfn[str] eqer_str = Str.eq; log "uint -> uint"; - let map.hashmap[uint, uint] hm_uu = map.mk_hashmap[uint, uint](hasher_uint, + let Map.hashmap[uint, uint] hm_uu = Map.mk_hashmap[uint, uint](hasher_uint, eqer_uint); assert (hm_uu.insert(10u, 12u)); @@ -49,7 +49,7 @@ fn test_simple() { log "str -> uint"; - let map.hashmap[str, uint] hm_su = map.mk_hashmap[str, uint](hasher_str, + let Map.hashmap[str, uint] hm_su = Map.mk_hashmap[str, uint](hasher_str, eqer_str); assert (hm_su.insert("ten", 12u)); assert (hm_su.insert(eleven, 13u)); @@ -70,42 +70,42 @@ fn test_simple() { log "uint -> str"; - let map.hashmap[uint, str] hm_us = map.mk_hashmap[uint, str](hasher_uint, + let Map.hashmap[uint, str] hm_us = Map.mk_hashmap[uint, str](hasher_uint, eqer_uint); assert (hm_us.insert(10u, "twelve")); assert (hm_us.insert(11u, "thirteen")); assert (hm_us.insert(12u, "fourteen")); - assert (_str.eq(hm_us.get(11u), "thirteen")); - assert (_str.eq(hm_us.get(12u), "fourteen")); - assert (_str.eq(hm_us.get(10u), "twelve")); + assert (Str.eq(hm_us.get(11u), "thirteen")); + assert (Str.eq(hm_us.get(12u), "fourteen")); + assert (Str.eq(hm_us.get(10u), "twelve")); assert (!hm_us.insert(12u, "fourteen")); - assert (_str.eq(hm_us.get(12u), "fourteen")); + assert (Str.eq(hm_us.get(12u), "fourteen")); assert (!hm_us.insert(12u, "twelve")); - assert (_str.eq(hm_us.get(12u), "twelve")); + assert (Str.eq(hm_us.get(12u), "twelve")); log "str -> str"; - let map.hashmap[str, str] hm_ss = map.mk_hashmap[str, str](hasher_str, + let Map.hashmap[str, str] hm_ss = Map.mk_hashmap[str, str](hasher_str, eqer_str); assert (hm_ss.insert(ten, "twelve")); assert (hm_ss.insert(eleven, "thirteen")); assert (hm_ss.insert(twelve, "fourteen")); - assert (_str.eq(hm_ss.get("eleven"), "thirteen")); - assert (_str.eq(hm_ss.get("twelve"), "fourteen")); - assert (_str.eq(hm_ss.get("ten"), "twelve")); + assert (Str.eq(hm_ss.get("eleven"), "thirteen")); + assert (Str.eq(hm_ss.get("twelve"), "fourteen")); + assert (Str.eq(hm_ss.get("ten"), "twelve")); assert (!hm_ss.insert("twelve", "fourteen")); - assert (_str.eq(hm_ss.get("twelve"), "fourteen")); + assert (Str.eq(hm_ss.get("twelve"), "fourteen")); assert (!hm_ss.insert("twelve", "twelve")); - assert (_str.eq(hm_ss.get("twelve"), "twelve")); + assert (Str.eq(hm_ss.get("twelve"), "twelve")); log "*** finished test_simple"; } @@ -120,7 +120,7 @@ fn test_growth() { fn eq_uint(&uint x, &uint y) -> bool { ret x == y; } fn hash_uint(&uint u) -> uint { - // FIXME: can't use std.util.id since we'd be capturing a type param, + // FIXME: can't use std.Util.id since we'd be capturing a type param, // and presently we can't close items over type params. ret u; } @@ -128,16 +128,16 @@ fn test_growth() { log "uint -> uint"; - let map.hashfn[uint] hasher_uint = hash_uint; - let map.eqfn[uint] eqer_uint = eq_uint; - let map.hashmap[uint, uint] hm_uu = map.mk_hashmap[uint, uint](hasher_uint, + let Map.hashfn[uint] hasher_uint = hash_uint; + let Map.eqfn[uint] eqer_uint = eq_uint; + let Map.hashmap[uint, uint] hm_uu = Map.mk_hashmap[uint, uint](hasher_uint, eqer_uint); let uint i = 0u; while (i < num_to_insert) { assert (hm_uu.insert(i, i * i)); - log "inserting " + _uint.to_str(i, 10u) - + " -> " + _uint.to_str(i * i, 10u); + log "inserting " + UInt.to_str(i, 10u) + + " -> " + UInt.to_str(i * i, 10u); i += 1u; } @@ -145,8 +145,8 @@ fn test_growth() { i = 0u; while (i < num_to_insert) { - log "get(" + _uint.to_str(i, 10u) + ") = " - + _uint.to_str(hm_uu.get(i), 10u); + log "get(" + UInt.to_str(i, 10u) + ") = " + + UInt.to_str(hm_uu.get(i), 10u); assert (hm_uu.get(i) == i * i); i += 1u; } @@ -160,8 +160,8 @@ fn test_growth() { i = 0u; while (i < num_to_insert) { - log "get(" + _uint.to_str(i, 10u) + ") = " - + _uint.to_str(hm_uu.get(i), 10u); + log "get(" + UInt.to_str(i, 10u) + ") = " + + UInt.to_str(hm_uu.get(i), 10u); assert (hm_uu.get(i) == i * i); i += 1u; } @@ -169,16 +169,16 @@ fn test_growth() { log "str -> str"; - let map.hashfn[str] hasher_str = _str.hash; - let map.eqfn[str] eqer_str = _str.eq; - let map.hashmap[str, str] hm_ss = map.mk_hashmap[str, str](hasher_str, + let Map.hashfn[str] hasher_str = Str.hash; + let Map.eqfn[str] eqer_str = Str.eq; + let Map.hashmap[str, str] hm_ss = Map.mk_hashmap[str, str](hasher_str, eqer_str); i = 0u; while (i < num_to_insert) { - assert (hm_ss.insert(_uint.to_str(i, 2u), _uint.to_str(i * i, 2u))); - log "inserting \"" + _uint.to_str(i, 2u) - + "\" -> \"" + _uint.to_str(i * i, 2u) + "\""; + assert (hm_ss.insert(UInt.to_str(i, 2u), UInt.to_str(i * i, 2u))); + log "inserting \"" + UInt.to_str(i, 2u) + + "\" -> \"" + UInt.to_str(i * i, 2u) + "\""; i += 1u; } @@ -187,20 +187,20 @@ fn test_growth() { i = 0u; while (i < num_to_insert) { log "get(\"" - + _uint.to_str(i, 2u) + + UInt.to_str(i, 2u) + "\") = \"" - + hm_ss.get(_uint.to_str(i, 2u)) + "\""; + + hm_ss.get(UInt.to_str(i, 2u)) + "\""; - assert (_str.eq(hm_ss.get(_uint.to_str(i, 2u)), - _uint.to_str(i * i, 2u))); + assert (Str.eq(hm_ss.get(UInt.to_str(i, 2u)), + UInt.to_str(i * i, 2u))); i += 1u; } - assert (hm_ss.insert(_uint.to_str(num_to_insert, 2u), - _uint.to_str(17u, 2u))); + assert (hm_ss.insert(UInt.to_str(num_to_insert, 2u), + UInt.to_str(17u, 2u))); - assert (_str.eq(hm_ss.get(_uint.to_str(num_to_insert, 2u)), - _uint.to_str(17u, 2u))); + assert (Str.eq(hm_ss.get(UInt.to_str(num_to_insert, 2u)), + UInt.to_str(17u, 2u))); log "-----"; @@ -208,10 +208,10 @@ fn test_growth() { i = 0u; while (i < num_to_insert) { - log "get(\"" + _uint.to_str(i, 2u) + "\") = \"" - + hm_ss.get(_uint.to_str(i, 2u)) + "\""; - assert (_str.eq(hm_ss.get(_uint.to_str(i, 2u)), - _uint.to_str(i * i, 2u))); + log "get(\"" + UInt.to_str(i, 2u) + "\") = \"" + + hm_ss.get(UInt.to_str(i, 2u)) + "\""; + assert (Str.eq(hm_ss.get(UInt.to_str(i, 2u)), + UInt.to_str(i * i, 2u))); i += 1u; } @@ -234,15 +234,15 @@ fn test_removal() { assert (hash(2u) == hash(3u)); assert (hash(0u) != hash(2u)); - let map.hashfn[uint] hasher = hash; - let map.eqfn[uint] eqer = eq; - let map.hashmap[uint, uint] hm = map.mk_hashmap[uint, uint](hasher, eqer); + let Map.hashfn[uint] hasher = hash; + let Map.eqfn[uint] eqer = eq; + let Map.hashmap[uint, uint] hm = Map.mk_hashmap[uint, uint](hasher, eqer); let uint i = 0u; while (i < num_to_insert) { assert (hm.insert(i, i * i)); - log "inserting " + _uint.to_str(i, 10u) - + " -> " + _uint.to_str(i * i, 10u); + log "inserting " + UInt.to_str(i, 10u) + + " -> " + UInt.to_str(i * i, 10u); i += 1u; } @@ -279,8 +279,8 @@ fn test_removal() { i = 1u; while (i < num_to_insert) { - log "get(" + _uint.to_str(i, 10u) + ") = " - + _uint.to_str(hm.get(i), 10u); + log "get(" + UInt.to_str(i, 10u) + ") = " + + UInt.to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 2u; } @@ -294,8 +294,8 @@ fn test_removal() { i = 1u; while (i < num_to_insert) { - log "get(" + _uint.to_str(i, 10u) + ") = " - + _uint.to_str(hm.get(i), 10u); + log "get(" + UInt.to_str(i, 10u) + ") = " + + UInt.to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 2u; } @@ -305,8 +305,8 @@ fn test_removal() { i = 0u; while (i < num_to_insert) { assert (hm.insert(i, i * i)); - log "inserting " + _uint.to_str(i, 10u) - + " -> " + _uint.to_str(i * i, 10u); + log "inserting " + UInt.to_str(i, 10u) + + " -> " + UInt.to_str(i * i, 10u); i += 2u; } @@ -316,8 +316,8 @@ fn test_removal() { i = 0u; while (i < num_to_insert) { - log "get(" + _uint.to_str(i, 10u) + ") = " - + _uint.to_str(hm.get(i), 10u); + log "get(" + UInt.to_str(i, 10u) + ") = " + + UInt.to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 1u; } @@ -333,8 +333,8 @@ fn test_removal() { i = 0u; while (i < num_to_insert) { - log "get(" + _uint.to_str(i, 10u) + ") = " - + _uint.to_str(hm.get(i), 10u); + log "get(" + UInt.to_str(i, 10u) + ") = " + + UInt.to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 1u; } diff --git a/src/test/run-pass/lib-option.rs b/src/test/run-pass/lib-option.rs index 922072e5..417ab482 100644 --- a/src/test/run-pass/lib-option.rs +++ b/src/test/run-pass/lib-option.rs @@ -1,5 +1,5 @@ use std; fn main() { - auto x = std.option.some[int](10); + auto x = std.Option.some[int](10); } diff --git a/src/test/run-pass/lib-qsort.rs b/src/test/run-pass/lib-qsort.rs index f7f0f997..aed5009d 100644 --- a/src/test/run-pass/lib-qsort.rs +++ b/src/test/run-pass/lib-qsort.rs @@ -1,13 +1,13 @@ use std; fn check_sort(vec[mutable int] v1, vec[mutable int] v2) { - auto len = std._vec.len[int](v1); + auto len = std.Vec.len[int](v1); fn ltequal(&int a, &int b) -> bool { ret a <= b; } auto f = ltequal; - std.sort.quick_sort[int](f, v1); + std.Sort.quick_sort[int](f, v1); auto i = 0u; while (i < len) { log v2.(i); diff --git a/src/test/run-pass/lib-rand.rs b/src/test/run-pass/lib-rand.rs index 3ef94973..e423bcba 100644 --- a/src/test/run-pass/lib-rand.rs +++ b/src/test/run-pass/lib-rand.rs @@ -4,14 +4,14 @@ // -*- rust -*- use std; -import std.rand; +import std.Rand; fn main() { - let rand.rng r1 = rand.mk_rng(); + let Rand.rng r1 = Rand.mk_rng(); log r1.next(); log r1.next(); { - auto r2 = rand.mk_rng(); + auto r2 = Rand.mk_rng(); log r1.next(); log r2.next(); log r1.next(); diff --git a/src/test/run-pass/lib-sha1.rs b/src/test/run-pass/lib-sha1.rs index 7e8efb5e..2a7e8646 100644 --- a/src/test/run-pass/lib-sha1.rs +++ b/src/test/run-pass/lib-sha1.rs @@ -2,9 +2,9 @@ use std; -import std.sha1; -import std._vec; -import std._str; +import std.SHA1; +import std.Vec; +import std.Str; fn main() { @@ -69,8 +69,8 @@ fn main() { auto tests = fips_180_1_tests + wikipedia_tests; fn check_vec_eq(vec[u8] v0, vec[u8] v1) { - assert (_vec.len[u8](v0) == _vec.len[u8](v1)); - auto len = _vec.len[u8](v0); + assert (Vec.len[u8](v0) == Vec.len[u8](v1)); + auto len = Vec.len[u8](v0); auto i = 0u; while (i < len) { auto a = v0.(i); @@ -81,7 +81,7 @@ fn main() { } // Test that it works when accepting the message all at once - auto sh = sha1.mk_sha1(); + auto sh = SHA1.mk_sha1(); for (test t in tests) { sh.input_str(t.input); auto out = sh.result(); @@ -91,11 +91,11 @@ fn main() { // Test that it works when accepting the message in pieces for (test t in tests) { - auto len = _str.byte_len(t.input); + auto len = Str.byte_len(t.input); auto left = len; while (left > 0u) { auto take = (left + 1u) / 2u; - sh.input_str(_str.substr(t.input, len - left, take)); + sh.input_str(Str.substr(t.input, len - left, take)); left = left - take; } auto out = sh.result(); diff --git a/src/test/run-pass/lib-sort.rs b/src/test/run-pass/lib-sort.rs index a342b24e..145d0175 100644 --- a/src/test/run-pass/lib-sort.rs +++ b/src/test/run-pass/lib-sort.rs @@ -1,12 +1,12 @@ use std; fn check_sort(vec[int] v1, vec[int] v2) { - auto len = std._vec.len[int](v1); + auto len = std.Vec.len[int](v1); fn lteq(&int a, &int b) -> bool { ret a <= b; } auto f = lteq; - auto v3 = std.sort.merge_sort[int](f, v1); + auto v3 = std.Sort.merge_sort[int](f, v1); auto i = 0u; while (i < len) { log v3.(i); diff --git a/src/test/run-pass/lib-str-buf.rs b/src/test/run-pass/lib-str-buf.rs index 1f25373a..cd8ba9e9 100644 --- a/src/test/run-pass/lib-str-buf.rs +++ b/src/test/run-pass/lib-str-buf.rs @@ -4,14 +4,14 @@ // -*- rust -*- use std; -import std._str; +import std.Str; fn main() { auto s = "hello"; - auto sb = _str.rustrt.str_buf(s); - auto s_cstr = _str.rustrt.str_from_cstr(sb); - assert (_str.eq(s_cstr, s)); - auto s_buf = _str.rustrt.str_from_buf(sb, 5u); - assert (_str.eq(s_buf, s)); + auto sb = Str.rustrt.str_buf(s); + auto s_cstr = Str.rustrt.str_from_cstr(sb); + assert (Str.eq(s_cstr, s)); + auto s_buf = Str.rustrt.str_from_buf(sb, 5u); + assert (Str.eq(s_buf, s)); } diff --git a/src/test/run-pass/lib-str.rs b/src/test/run-pass/lib-str.rs index 76717711..58779f67 100644 --- a/src/test/run-pass/lib-str.rs +++ b/src/test/run-pass/lib-str.rs @@ -1,36 +1,36 @@ use std; -import std._str; +import std.Str; fn test_bytes_len() { - assert (_str.byte_len("") == 0u); - assert (_str.byte_len("hello world") == 11u); - assert (_str.byte_len("\x63") == 1u); - assert (_str.byte_len("\xa2") == 2u); - assert (_str.byte_len("\u03c0") == 2u); - assert (_str.byte_len("\u2620") == 3u); - assert (_str.byte_len("\U0001d11e") == 4u); + assert (Str.byte_len("") == 0u); + assert (Str.byte_len("hello world") == 11u); + assert (Str.byte_len("\x63") == 1u); + assert (Str.byte_len("\xa2") == 2u); + assert (Str.byte_len("\u03c0") == 2u); + assert (Str.byte_len("\u2620") == 3u); + assert (Str.byte_len("\U0001d11e") == 4u); } fn test_index_and_rindex() { - assert (_str.index("hello", 'e' as u8) == 1); - assert (_str.index("hello", 'o' as u8) == 4); - assert (_str.index("hello", 'z' as u8) == -1); - assert (_str.rindex("hello", 'l' as u8) == 3); - assert (_str.rindex("hello", 'h' as u8) == 0); - assert (_str.rindex("hello", 'z' as u8) == -1); + assert (Str.index("hello", 'e' as u8) == 1); + assert (Str.index("hello", 'o' as u8) == 4); + assert (Str.index("hello", 'z' as u8) == -1); + assert (Str.rindex("hello", 'l' as u8) == 3); + assert (Str.rindex("hello", 'h' as u8) == 0); + assert (Str.rindex("hello", 'z' as u8) == -1); } fn test_split() { fn t(&str s, char c, int i, &str k) { log "splitting: " + s; log i; - auto v = _str.split(s, c as u8); + auto v = Str.split(s, c as u8); log "split to: "; for (str z in v) { log z; } log "comparing: " + v.(i) + " vs. " + k; - assert (_str.eq(v.(i), k)); + assert (Str.eq(v.(i), k)); } t("abc.hello.there", '.', 0, "abc"); t("abc.hello.there", '.', 1, "hello"); @@ -43,7 +43,7 @@ fn test_split() { fn test_find() { fn t(&str haystack, &str needle, int i) { - let int j = _str.find(haystack,needle); + let int j = Str.find(haystack,needle); log "searched for " + needle; log j; assert (i == j); @@ -57,8 +57,8 @@ fn test_find() { fn test_substr() { fn t(&str a, &str b, int start) { - assert (_str.eq(_str.substr(a, start as uint, - _str.byte_len(b)), b)); + assert (Str.eq(Str.substr(a, start as uint, + Str.byte_len(b)), b)); } t("hello", "llo", 2); @@ -68,7 +68,7 @@ fn test_substr() { fn test_concat() { fn t(&vec[str] v, &str s) { - assert (_str.eq(_str.concat(v), s)); + assert (Str.eq(Str.concat(v), s)); } t(vec("you", "know", "I'm", "no", "good"), "youknowI'mnogood"); @@ -79,7 +79,7 @@ fn test_concat() { fn test_connect() { fn t(&vec[str] v, &str sep, &str s) { - assert (_str.eq(_str.connect(v, sep), s)); + assert (Str.eq(Str.connect(v, sep), s)); } t(vec("you", "know", "I'm", "no", "good"), " ", "you know I'm no good"); @@ -94,8 +94,8 @@ fn test_to_upper() { auto unicode = "\u65e5\u672c"; auto input = "abcDEF" + unicode + "xyz:.;"; auto expected = "ABCDEF" + unicode + "XYZ:.;"; - auto actual = _str.to_upper(input); - assert (_str.eq(expected, actual)); + auto actual = Str.to_upper(input); + assert (Str.eq(expected, actual)); } diff --git a/src/test/run-pass/lib-task.rs b/src/test/run-pass/lib-task.rs index 18499f4e..8e07962c 100644 --- a/src/test/run-pass/lib-task.rs +++ b/src/test/run-pass/lib-task.rs @@ -1,6 +1,6 @@ use std; -import std._task; +import std.Task; fn main() { - _task.sleep(1000000u); + Task.sleep(1000000u); }
\ No newline at end of file diff --git a/src/test/run-pass/lib-uint.rs b/src/test/run-pass/lib-uint.rs index 64d39619..4f787745 100644 --- a/src/test/run-pass/lib-uint.rs +++ b/src/test/run-pass/lib-uint.rs @@ -1,47 +1,47 @@ // -*- rust -*- use std; -import std._uint; +import std.UInt; fn main() { - assert (_uint.next_power_of_two(0u) == 0u); - assert (_uint.next_power_of_two(1u) == 1u); - assert (_uint.next_power_of_two(2u) == 2u); - assert (_uint.next_power_of_two(3u) == 4u); - assert (_uint.next_power_of_two(4u) == 4u); - assert (_uint.next_power_of_two(5u) == 8u); - assert (_uint.next_power_of_two(6u) == 8u); - assert (_uint.next_power_of_two(7u) == 8u); - assert (_uint.next_power_of_two(8u) == 8u); - assert (_uint.next_power_of_two(9u) == 16u); - assert (_uint.next_power_of_two(10u) == 16u); - assert (_uint.next_power_of_two(11u) == 16u); - assert (_uint.next_power_of_two(12u) == 16u); - assert (_uint.next_power_of_two(13u) == 16u); - assert (_uint.next_power_of_two(14u) == 16u); - assert (_uint.next_power_of_two(15u) == 16u); - assert (_uint.next_power_of_two(16u) == 16u); - assert (_uint.next_power_of_two(17u) == 32u); - assert (_uint.next_power_of_two(18u) == 32u); - assert (_uint.next_power_of_two(19u) == 32u); - assert (_uint.next_power_of_two(20u) == 32u); - assert (_uint.next_power_of_two(21u) == 32u); - assert (_uint.next_power_of_two(22u) == 32u); - assert (_uint.next_power_of_two(23u) == 32u); - assert (_uint.next_power_of_two(24u) == 32u); - assert (_uint.next_power_of_two(25u) == 32u); - assert (_uint.next_power_of_two(26u) == 32u); - assert (_uint.next_power_of_two(27u) == 32u); - assert (_uint.next_power_of_two(28u) == 32u); - assert (_uint.next_power_of_two(29u) == 32u); - assert (_uint.next_power_of_two(30u) == 32u); - assert (_uint.next_power_of_two(31u) == 32u); - assert (_uint.next_power_of_two(32u) == 32u); - assert (_uint.next_power_of_two(33u) == 64u); - assert (_uint.next_power_of_two(34u) == 64u); - assert (_uint.next_power_of_two(35u) == 64u); - assert (_uint.next_power_of_two(36u) == 64u); - assert (_uint.next_power_of_two(37u) == 64u); - assert (_uint.next_power_of_two(38u) == 64u); - assert (_uint.next_power_of_two(39u) == 64u); + assert (UInt.next_power_of_two(0u) == 0u); + assert (UInt.next_power_of_two(1u) == 1u); + assert (UInt.next_power_of_two(2u) == 2u); + assert (UInt.next_power_of_two(3u) == 4u); + assert (UInt.next_power_of_two(4u) == 4u); + assert (UInt.next_power_of_two(5u) == 8u); + assert (UInt.next_power_of_two(6u) == 8u); + assert (UInt.next_power_of_two(7u) == 8u); + assert (UInt.next_power_of_two(8u) == 8u); + assert (UInt.next_power_of_two(9u) == 16u); + assert (UInt.next_power_of_two(10u) == 16u); + assert (UInt.next_power_of_two(11u) == 16u); + assert (UInt.next_power_of_two(12u) == 16u); + assert (UInt.next_power_of_two(13u) == 16u); + assert (UInt.next_power_of_two(14u) == 16u); + assert (UInt.next_power_of_two(15u) == 16u); + assert (UInt.next_power_of_two(16u) == 16u); + assert (UInt.next_power_of_two(17u) == 32u); + assert (UInt.next_power_of_two(18u) == 32u); + assert (UInt.next_power_of_two(19u) == 32u); + assert (UInt.next_power_of_two(20u) == 32u); + assert (UInt.next_power_of_two(21u) == 32u); + assert (UInt.next_power_of_two(22u) == 32u); + assert (UInt.next_power_of_two(23u) == 32u); + assert (UInt.next_power_of_two(24u) == 32u); + assert (UInt.next_power_of_two(25u) == 32u); + assert (UInt.next_power_of_two(26u) == 32u); + assert (UInt.next_power_of_two(27u) == 32u); + assert (UInt.next_power_of_two(28u) == 32u); + assert (UInt.next_power_of_two(29u) == 32u); + assert (UInt.next_power_of_two(30u) == 32u); + assert (UInt.next_power_of_two(31u) == 32u); + assert (UInt.next_power_of_two(32u) == 32u); + assert (UInt.next_power_of_two(33u) == 64u); + assert (UInt.next_power_of_two(34u) == 64u); + assert (UInt.next_power_of_two(35u) == 64u); + assert (UInt.next_power_of_two(36u) == 64u); + assert (UInt.next_power_of_two(37u) == 64u); + assert (UInt.next_power_of_two(38u) == 64u); + assert (UInt.next_power_of_two(39u) == 64u); } diff --git a/src/test/run-pass/lib-vec-str-conversions.rs b/src/test/run-pass/lib-vec-str-conversions.rs index 3724d627..cd8b64a8 100644 --- a/src/test/run-pass/lib-vec-str-conversions.rs +++ b/src/test/run-pass/lib-vec-str-conversions.rs @@ -1,8 +1,8 @@ // -*- rust -*- use std; -import std._str; -import std._vec; +import std.Str; +import std.Vec; fn test_simple() { let str s1 = "All mimsy were the borogoves"; @@ -14,12 +14,12 @@ fn test_simple() { * working, but we should implement is_utf8 before that happens. */ - let vec[u8] v = _str.bytes(s1); - let str s2 = _str.from_bytes(v); + let vec[u8] v = Str.bytes(s1); + let str s2 = Str.from_bytes(v); let uint i = 0u; - let uint n1 = _str.byte_len(s1); - let uint n2 = _vec.len[u8](v); + let uint n1 = Str.byte_len(s1); + let uint n2 = Vec.len[u8](v); assert (n1 == n2); @@ -33,7 +33,7 @@ fn test_simple() { } log "refcnt is"; - log _str.refcount(s1); + log Str.refcount(s1); } fn main() { diff --git a/src/test/run-pass/lib-vec.rs b/src/test/run-pass/lib-vec.rs index 51341039..0905652a 100644 --- a/src/test/run-pass/lib-vec.rs +++ b/src/test/run-pass/lib-vec.rs @@ -1,8 +1,8 @@ use std; fn test_init_elt() { - let vec[uint] v = std._vec.init_elt[uint](5u, 3u); - assert (std._vec.len[uint](v) == 3u); + let vec[uint] v = std.Vec.init_elt[uint](5u, 3u); + assert (std.Vec.len[uint](v) == 3u); assert (v.(0) == 5u); assert (v.(1) == 5u); assert (v.(2) == 5u); @@ -13,8 +13,8 @@ fn id(uint x) -> uint { } fn test_init_fn() { let fn(uint)->uint op = id; - let vec[uint] v = std._vec.init_fn[uint](op, 5u); - assert (std._vec.len[uint](v) == 5u); + let vec[uint] v = std.Vec.init_fn[uint](op, 5u); + assert (std.Vec.len[uint](v) == 5u); assert (v.(0) == 0u); assert (v.(1) == 1u); assert (v.(2) == 2u); @@ -24,17 +24,17 @@ fn test_init_fn() { fn test_slice() { let vec[int] v = vec(1,2,3,4,5); - auto v2 = std._vec.slice[int](v, 2u, 4u); - assert (std._vec.len[int](v2) == 2u); + auto v2 = std.Vec.slice[int](v, 2u, 4u); + assert (std.Vec.len[int](v2) == 2u); assert (v2.(0) == 3); assert (v2.(1) == 4); } fn test_map() { fn square(&int x) -> int { ret x * x; } - let std.option.operator[int, int] op = square; + let std.Option.operator[int, int] op = square; let vec[int] v = vec(1, 2, 3, 4, 5); - let vec[int] s = std._vec.map[int, int](op, v); + let vec[int] s = std.Vec.map[int, int](op, v); let int i = 0; while (i < 5) { assert (v.(i) * v.(i) == s.(i)); @@ -47,7 +47,7 @@ fn test_map2() { auto f = times; auto v0 = vec(1, 2, 3, 4, 5); auto v1 = vec(5, 4, 3, 2, 1); - auto u = std._vec.map2[int,int,int](f, v0, v1); + auto u = std.Vec.map2[int,int,int](f, v0, v1); auto i = 0; while (i < 5) { diff --git a/src/test/run-pass/mlist-cycle.rs b/src/test/run-pass/mlist-cycle.rs index 7c41e4b5..b5eff76f 100644 --- a/src/test/run-pass/mlist-cycle.rs +++ b/src/test/run-pass/mlist-cycle.rs @@ -16,6 +16,6 @@ fn main() { let @cell first = @tup(mutable @nil()); let @cell second = @tup(mutable @link(first)); first._0 = @link(second); - std.sys.rustrt.gc(); + std.Sys.rustrt.gc(); let @cell third = @tup(mutable @nil()); } diff --git a/src/test/run-pass/mutable-alias-vec.rs b/src/test/run-pass/mutable-alias-vec.rs index 71d4dfe9..5919abdc 100644 --- a/src/test/run-pass/mutable-alias-vec.rs +++ b/src/test/run-pass/mutable-alias-vec.rs @@ -11,7 +11,7 @@ fn main() { grow(v); grow(v); grow(v); - auto len = std._vec.len[int](v); + auto len = std.Vec.len[int](v); log len; assert (len == (3 as uint)); } diff --git a/src/test/run-pass/nested-pattern.rs b/src/test/run-pass/nested-pattern.rs index e59c2dd5..cb244cc8 100644 --- a/src/test/run-pass/nested-pattern.rs +++ b/src/test/run-pass/nested-pattern.rs @@ -1,13 +1,13 @@ // a bug was causing this to complain about leaked memory on exit use std; -import std.option; -import std.option.some; -import std.option.none; +import std.Option; +import std.Option.some; +import std.Option.none; tag t { foo(int, uint); - bar(int, option.t[int]); + bar(int, Option.t[int]); } fn nested(t o) { diff --git a/src/test/run-pass/rt-circular-buffer.rs b/src/test/run-pass/rt-circular-buffer.rs index cd808ad7..b6c545b2 100644 --- a/src/test/run-pass/rt-circular-buffer.rs +++ b/src/test/run-pass/rt-circular-buffer.rs @@ -5,9 +5,9 @@ use std; -import std.option; -import std._uint; -import std._vec; +import std.Option; +import std.UInt; +import std.Vec; // A 12-byte unit to send over the channel type record = rec(u32 val1, u32 val2, u32 val3); @@ -33,7 +33,7 @@ fn test_grow() { let record val = rec(val1=0u32, val2=0u32, val3=0u32); - for each (uint i in _uint.range(0u, 100u)) { + for each (uint i in UInt.range(0u, 100u)) { mychan <| val; } } @@ -53,11 +53,11 @@ fn test_shrink2() { let record val = rec(val1=0u32, val2=0u32, val3=0u32); - for each (uint i in _uint.range(0u, 100u)) { + for each (uint i in UInt.range(0u, 100u)) { mychan <| val; } - for each (uint i in _uint.range(0u, 100u)) { + for each (uint i in UInt.range(0u, 100u)) { auto x <- myport; } } @@ -67,7 +67,7 @@ fn test_rotate() { let port[record] myport = port(); auto mychan = chan(myport); - for each (uint i in _uint.range(0u, 100u)) { + for each (uint i in UInt.range(0u, 100u)) { auto val = rec(val1=i as u32, val2=i as u32, val3=i as u32); @@ -86,15 +86,15 @@ fn test_rotate_grow() { let port[record] myport = port(); auto mychan = chan(myport); - for each (uint j in _uint.range(0u, 10u)) { - for each (uint i in _uint.range(0u, 10u)) { + for each (uint j in UInt.range(0u, 10u)) { + for each (uint i in UInt.range(0u, 10u)) { let record val = rec(val1=i as u32, val2=i as u32, val3=i as u32); mychan <| val; } - for each (uint i in _uint.range(0u, 10u)) { + for each (uint i in UInt.range(0u, 10u)) { auto x <- myport; assert (x.val1 == i as u32); assert (x.val2 == i as u32); diff --git a/src/test/run-pass/str-append.rs b/src/test/run-pass/str-append.rs index abfbe938..afca72a8 100644 --- a/src/test/run-pass/str-append.rs +++ b/src/test/run-pass/str-append.rs @@ -1,7 +1,7 @@ // -*- rust -*- use std; -import std._str; +import std.Str; fn test1() { let str s = "hello"; @@ -20,8 +20,8 @@ fn test2() { log a; log b; - assert (_str.eq(a, "abcABCabc")); - assert (_str.eq(b, "ABCabcABC")); + assert (Str.eq(a, "abcABCabc")); + assert (Str.eq(b, "ABCabcABC")); } fn main() { diff --git a/src/test/run-pass/syntax-extension-fmt.rs b/src/test/run-pass/syntax-extension-fmt.rs index bb0c851f..08a8c499 100644 --- a/src/test/run-pass/syntax-extension-fmt.rs +++ b/src/test/run-pass/syntax-extension-fmt.rs @@ -3,12 +3,12 @@ // xfail-stage1 // xfail-stage2 use std; -import std._str; +import std.Str; fn test(str actual, str expected) { log actual; log expected; - assert (_str.eq(actual, expected)); + assert (Str.eq(actual, expected)); } fn main() { diff --git a/src/test/run-pass/task-comm-12.rs b/src/test/run-pass/task-comm-12.rs index 2f8ef985..d4a135c2 100644 --- a/src/test/run-pass/task-comm-12.rs +++ b/src/test/run-pass/task-comm-12.rs @@ -3,7 +3,7 @@ // xfail-stage1 // xfail-stage2 use std; -import std._task; +import std.Task; fn main() -> () { test00(); @@ -18,7 +18,7 @@ fn test00() { let task t = spawn thread "child" start(i); // Sleep long enough for the task to finish. - _task.sleep(10000u); + Task.sleep(10000u); // Try joining tasks that have already finished. join t; diff --git a/src/test/run-pass/task-comm-13-thread.rs b/src/test/run-pass/task-comm-13-thread.rs index e5e42010..fedc516b 100644 --- a/src/test/run-pass/task-comm-13-thread.rs +++ b/src/test/run-pass/task-comm-13-thread.rs @@ -2,7 +2,7 @@ // xfail-stage1 // xfail-stage2 use std; -import std._task; +import std.Task; fn start(chan[int] c, int start, int number_of_messages) { let int i = 0; diff --git a/src/test/run-pass/task-comm-13.rs b/src/test/run-pass/task-comm-13.rs index bcae26e5..1bf5d1f5 100644 --- a/src/test/run-pass/task-comm-13.rs +++ b/src/test/run-pass/task-comm-13.rs @@ -2,7 +2,7 @@ // xfail-stage1 // xfail-stage2 use std; -import std._task; +import std.Task; fn start(chan[int] c, int start, int number_of_messages) { let int i = 0; diff --git a/src/test/run-pass/type-sizes.rs b/src/test/run-pass/type-sizes.rs index e416e9b5..d39a2064 100644 --- a/src/test/run-pass/type-sizes.rs +++ b/src/test/run-pass/type-sizes.rs @@ -2,7 +2,7 @@ // xfail-stage1 // xfail-stage2 -import size_of = std.sys.rustrt.size_of; +import size_of = std.Sys.rustrt.size_of; use std; diff --git a/src/test/run-pass/use.rs b/src/test/run-pass/use.rs index 37cfe074..3d1a6947 100644 --- a/src/test/run-pass/use.rs +++ b/src/test/run-pass/use.rs @@ -7,8 +7,8 @@ use zed(name = "std"); use bar(name = "std", ver = "0.0.1"); // FIXME: commented out since resolve doesn't know how to handle crates yet. -// import std._str; -// import x = std._str; +// import std.Str; +// import x = std.Str; mod baz { use std; @@ -16,8 +16,8 @@ mod baz { use zed(name = "std"); use bar(name = "std", ver = "0.0.1"); - // import std._str; - // import x = std._str; + // import std.Str; + // import x = std.Str; } fn main() { diff --git a/src/test/run-pass/user.rs b/src/test/run-pass/user.rs index 679d3e48..877c416b 100644 --- a/src/test/run-pass/user.rs +++ b/src/test/run-pass/user.rs @@ -8,10 +8,10 @@ use std (name = "std", uuid = _, ver = _); fn main() { - auto s = std._str.alloc(10 as uint); + auto s = std.Str.alloc(10 as uint); s += "hello "; log s; s += "there"; log s; - auto z = std._vec.alloc[int](10 as uint); + auto z = std.Vec.alloc[int](10 as uint); } diff --git a/src/test/run-pass/utf8_chars.rs b/src/test/run-pass/utf8_chars.rs index e2df05dc..95cbc64e 100644 --- a/src/test/run-pass/utf8_chars.rs +++ b/src/test/run-pass/utf8_chars.rs @@ -2,34 +2,34 @@ // xfail-stage1 // xfail-stage2 use std; -import std._str; -import std._vec; -import std.io; +import std.Str; +import std.Vec; +import std.IO; fn main() { // Chars of 1, 2, 3, and 4 bytes let vec[char] chs = vec('e', 'é', '€', 0x10000 as char); - let str s = _str.from_chars(chs); + let str s = Str.from_chars(chs); - assert (_str.byte_len(s) == 10u); - assert (_str.char_len(s) == 4u); - assert (_vec.len[char](_str.to_chars(s)) == 4u); - assert (_str.eq(_str.from_chars(_str.to_chars(s)), s)); - assert (_str.char_at(s, 0u) == 'e'); - assert (_str.char_at(s, 1u) == 'é'); + assert (Str.byte_len(s) == 10u); + assert (Str.char_len(s) == 4u); + assert (Vec.len[char](Str.to_chars(s)) == 4u); + assert (Str.eq(Str.from_chars(Str.to_chars(s)), s)); + assert (Str.char_at(s, 0u) == 'e'); + assert (Str.char_at(s, 1u) == 'é'); - assert (_str.is_utf8(_str.bytes(s))); - assert (!_str.is_utf8(vec(0x80_u8))); - assert (!_str.is_utf8(vec(0xc0_u8))); - assert (!_str.is_utf8(vec(0xc0_u8, 0x10_u8))); + assert (Str.is_utf8(Str.bytes(s))); + assert (!Str.is_utf8(vec(0x80_u8))); + assert (!Str.is_utf8(vec(0xc0_u8))); + assert (!Str.is_utf8(vec(0xc0_u8, 0x10_u8))); auto stack = "a×c€"; - assert (_str.pop_char(stack) == '€'); - assert (_str.pop_char(stack) == 'c'); - _str.push_char(stack, 'u'); - assert (_str.eq(stack, "a×u")); - assert (_str.shift_char(stack) == 'a'); - assert (_str.shift_char(stack) == '×'); - _str.unshift_char(stack, 'ß'); - assert (_str.eq(stack, "ßu")); + assert (Str.pop_char(stack) == '€'); + assert (Str.pop_char(stack) == 'c'); + Str.push_char(stack, 'u'); + assert (Str.eq(stack, "a×u")); + assert (Str.shift_char(stack) == 'a'); + assert (Str.shift_char(stack) == '×'); + Str.unshift_char(stack, 'ß'); + assert (Str.eq(stack, "ßu")); } diff --git a/src/test/run-pass/vec-alloc-append.rs b/src/test/run-pass/vec-alloc-append.rs index 616823ae..4327e789 100644 --- a/src/test/run-pass/vec-alloc-append.rs +++ b/src/test/run-pass/vec-alloc-append.rs @@ -6,7 +6,7 @@ use std; fn slice[T](vec[T] e) { - let vec[T] result = std._vec.alloc[T](1 as uint); + let vec[T] result = std.Vec.alloc[T](1 as uint); log "alloced"; result += e; log "appended"; diff --git a/src/test/run-pass/vec-append.rs b/src/test/run-pass/vec-append.rs index e63b1d09..cd87ec23 100644 --- a/src/test/run-pass/vec-append.rs +++ b/src/test/run-pass/vec-append.rs @@ -4,11 +4,11 @@ // -*- rust -*- use std; -import std._str; -import std._vec; +import std.Str; +import std.Vec; -// FIXME: import std.dbg.const_refcount. Currently +// FIXME: import std.Dbg.const_refcount. Currently // cross-crate const references don't work. const uint const_refcount = 0x7bad_face_u; @@ -53,30 +53,30 @@ fn slow_growth2_helper(str s) { // ref up: s let vec[str] v = vec(mumble); // ref up: v, mumble let acc a = acc(v); // ref up: a, v - log _vec.refcount[str](v); - assert (_vec.refcount[str](v) == 2u); + log Vec.refcount[str](v); + assert (Vec.refcount[str](v) == 2u); a.add(s); // ref up: mumble, s. ref down: v - log _vec.refcount[str](v); - log _str.refcount(s); - log _str.refcount(mumble); + log Vec.refcount[str](v); + log Str.refcount(s); + log Str.refcount(mumble); - assert (_vec.refcount[str](v) == 1u); - assert (_str.refcount(s) == const_refcount); - assert (_str.refcount(mumble) == const_refcount); + assert (Vec.refcount[str](v) == 1u); + assert (Str.refcount(s) == const_refcount); + assert (Str.refcount(mumble) == const_refcount); log v.(0); - log _vec.len[str](v); - assert (_str.eq(v.(0), mumble)); - assert (_vec.len[str](v) == 1u); + log Vec.len[str](v); + assert (Str.eq(v.(0), mumble)); + assert (Vec.len[str](v) == 1u); } // ref down: a, mumble, s, v - log _str.refcount(s); - log _str.refcount(mumble); + log Str.refcount(s); + log Str.refcount(mumble); - assert (_str.refcount(s) == const_refcount); - assert (_str.refcount(mumble) == const_refcount); + assert (Str.refcount(s) == const_refcount); + assert (Str.refcount(mumble) == const_refcount); log mumble; log ss; @@ -85,8 +85,8 @@ fn slow_growth2_helper(str s) { // ref up: s fn slow_growth2() { let str s = "hi"; // ref up: s slow_growth2_helper(s); - log _str.refcount(s); - assert (_str.refcount(s) == const_refcount); + log Str.refcount(s); + assert (Str.refcount(s) == const_refcount); } fn main() { diff --git a/src/test/run-pass/vec-ref-count.rs b/src/test/run-pass/vec-ref-count.rs index 45f28f9b..4534a861 100644 --- a/src/test/run-pass/vec-ref-count.rs +++ b/src/test/run-pass/vec-ref-count.rs @@ -1,12 +1,12 @@ use std; -import std._vec; +import std.Vec; fn main() { auto v = vec(1, 2, 3); - log_err _vec.refcount[int](v); - log_err _vec.refcount[int](v); - log_err _vec.refcount[int](v); - assert (_vec.refcount[int](v) == 1u || _vec.refcount[int](v) == 2u); - assert (_vec.refcount[int](v) == 1u || _vec.refcount[int](v) == 2u); + log_err Vec.refcount[int](v); + log_err Vec.refcount[int](v); + log_err Vec.refcount[int](v); + assert (Vec.refcount[int](v) == 1u || Vec.refcount[int](v) == 2u); + assert (Vec.refcount[int](v) == 1u || Vec.refcount[int](v) == 2u); } |