diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index cdb43b19811..375e9239d63 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -141,7 +141,7 @@ priv impl DList { // Link two nodes together. If either of them are 'none', also sets // the head and/or tail pointers appropriately. #[inline(always)] - fn link_nodes(+before: DListLink, +after: DListLink) { + fn link(+before: DListLink, +after: DListLink) { match before { Some(neighbour) => neighbour.next = after, None => self.hd = after @@ -155,7 +155,7 @@ priv impl DList { fn unlink(nobe: DListNode) { self.assert_mine(nobe); assert self.size > 0; - self.link_nodes(nobe.prev, nobe.next); + self.link(nobe.prev, nobe.next); nobe.prev = None; // Release extraneous references. nobe.next = None; nobe.linked = false; @@ -163,27 +163,27 @@ priv impl DList { } fn add_head(+nobe: DListLink) { - self.link_nodes(nobe, self.hd); // Might set tail too. + self.link(nobe, self.hd); // Might set tail too. self.hd = nobe; self.size += 1; } fn add_tail(+nobe: DListLink) { - self.link_nodes(self.tl, nobe); // Might set head too. + self.link(self.tl, nobe); // Might set head too. self.tl = nobe; self.size += 1; } fn insert_left(nobe: DListLink, neighbour: DListNode) { self.assert_mine(neighbour); assert self.size > 0; - self.link_nodes(neighbour.prev, nobe); - self.link_nodes(nobe, Some(neighbour)); + self.link(neighbour.prev, nobe); + self.link(nobe, Some(neighbour)); self.size += 1; } fn insert_right(neighbour: DListNode, nobe: DListLink) { self.assert_mine(neighbour); assert self.size > 0; - self.link_nodes(nobe, neighbour.next); - self.link_nodes(Some(neighbour), nobe); + self.link(nobe, neighbour.next); + self.link(Some(neighbour), nobe); self.size += 1; } } @@ -315,7 +315,7 @@ impl DList { fail ~"Cannot append a dlist to itself!" } if them.len() > 0 { - self.link_nodes(self.tl, them.hd); + self.link(self.tl, them.hd); self.tl = them.tl; self.size += them.size; them.size = 0; @@ -332,7 +332,7 @@ impl DList { fail ~"Cannot prepend a dlist to itself!" } if them.len() > 0 { - self.link_nodes(them.tl, self.hd); + self.link(them.tl, self.hd); self.hd = them.hd; self.size += them.size; them.size = 0; @@ -366,11 +366,11 @@ impl DList { /// Iterate over nodes. pure fn each_node(f: fn(DListNode) -> bool) { - let mut link_node = self.peek_n(); - while link_node.is_some() { - let nobe = link_node.get(); + let mut link = self.peek_n(); + while link.is_some() { + let nobe = link.get(); if !f(nobe) { break; } - link_node = nobe.next_link(); + link = nobe.next_link(); } } @@ -381,10 +381,10 @@ impl DList { } // iterate forwards let mut count = 0; - let mut link_node = self.peek_n(); - let mut rabbit = link_node; - while option::is_some(link_node) { - let nobe = option::get(link_node); + let mut link = self.peek_n(); + let mut rabbit = link; + while option::is_some(link) { + let nobe = option::get(link); assert nobe.linked; // check cycle if option::is_some(rabbit) { rabbit = option::get(rabbit).next; } @@ -393,15 +393,15 @@ impl DList { assert !box::ptr_eq(*option::get(rabbit), *nobe); } // advance - link_node = nobe.next_link(); + link = nobe.next_link(); count += 1; } assert count == self.len(); // iterate backwards - some of this is probably redundant. - link_node = self.peek_tail_n(); - rabbit = link_node; - while option::is_some(link_node) { - let nobe = option::get(link_node); + link = self.peek_tail_n(); + rabbit = link; + while option::is_some(link) { + let nobe = option::get(link); assert nobe.linked; // check cycle if option::is_some(rabbit) { rabbit = option::get(rabbit).prev; } @@ -410,7 +410,7 @@ impl DList { assert !box::ptr_eq(*option::get(rabbit), *nobe); } // advance - link_node = nobe.prev_link(); + link = nobe.prev_link(); count -= 1; } assert count == 0; diff --git a/src/libcore/iter-trait/dlist.rs b/src/libcore/iter-trait/dlist.rs index 966cd138d4c..ae6265409ca 100644 --- a/src/libcore/iter-trait/dlist.rs +++ b/src/libcore/iter-trait/dlist.rs @@ -9,9 +9,9 @@ type IMPL_T = dlist::DList; * node is forbidden. */ pure fn EACH(self: IMPL_T, f: fn(A) -> bool) { - let mut link_node = self.peek_n(); - while option::is_some(link_node) { - let nobe = option::get(link_node); + let mut link = self.peek_n(); + while option::is_some(link) { + let nobe = option::get(link); assert nobe.linked; if !f(nobe.data) { break; } // Check (weakly) that the user didn't do a remove. @@ -25,7 +25,7 @@ pure fn EACH(self: IMPL_T, f: fn(A) -> bool) { || box::ptr_eq(*self.tl.expect(~"tailless dlist?"), *nobe)))) { fail ~"Removing a dlist node during iteration is forbidden!" } - link_node = nobe.next_link(); + link = nobe.next_link(); } } diff --git a/src/libcore/libc.rs b/src/libcore/libc.rs index f06a2c75889..491fe02ec31 100644 --- a/src/libcore/libc.rs +++ b/src/libcore/libc.rs @@ -1033,8 +1033,7 @@ mod funcs { fn getppid() -> pid_t; fn getuid() -> uid_t; fn isatty(fd: c_int) -> c_int; - #[link_name="link"] - fn lnk(src: *c_char, dst: *c_char) -> c_int; + fn link(src: *c_char, dst: *c_char) -> c_int; fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; fn pathconf(path: *c_char, name: c_int) -> c_long; fn pause() -> c_int; diff --git a/src/rustc/back/linkage.rs b/src/rustc/back/link.rs similarity index 100% rename from src/rustc/back/linkage.rs rename to src/rustc/back/link.rs diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index b476fa5217b..44d62e8d926 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -7,7 +7,7 @@ use syntax::attr; use middle::{trans, freevars, kind, ty, typeck, lint}; use syntax::print::{pp, pprust}; use util::ppaux; -use back::linkage; +use back::link; use result::{Ok, Err}; use std::getopts; use io::WriterUtil; @@ -258,20 +258,20 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, exp_map, exp_map2, maps)); time(time_passes, ~"LLVM passes", || - linkage::write::run_passes(sess, llmod, - &outputs.obj_filename)); + link::write::run_passes(sess, llmod, + &outputs.obj_filename)); let stop_after_codegen = - sess.opts.output_type != linkage::output_type_exe || - (sess.opts.static && sess.building_library) || + sess.opts.output_type != link::output_type_exe || + (sess.opts.static && sess.building_library) || sess.opts.jit; if stop_after_codegen { return {crate: crate, tcx: Some(ty_cx)}; } time(time_passes, ~"linking", || - linkage::link_binary(sess, - &outputs.obj_filename, - &outputs.out_filename, link_meta)); + link::link_binary(sess, + &outputs.obj_filename, + &outputs.out_filename, link_meta)); return {crate: crate, tcx: Some(ty_cx)}; } @@ -492,19 +492,17 @@ fn build_session_options(binary: ~str, let jit = opt_present(matches, ~"jit"); let output_type = if parse_only || no_trans { - linkage::output_type_none + link::output_type_none } else if opt_present(matches, ~"S") && opt_present(matches, ~"emit-llvm") { - linkage::output_type_llvm_assembly + link::output_type_llvm_assembly } else if opt_present(matches, ~"S") { - linkage::output_type_assembly + link::output_type_assembly } else if opt_present(matches, ~"c") { - linkage::output_type_object + link::output_type_object } else if opt_present(matches, ~"emit-llvm") { - linkage::output_type_bitcode - } else { - linkage::output_type_exe - }; + link::output_type_bitcode + } else { link::output_type_exe }; let extra_debuginfo = opt_present(matches, ~"xg"); let debuginfo = opt_present(matches, ~"g") || extra_debuginfo; let sysroot_opt = getopts::opt_maybe_str(matches, ~"sysroot"); @@ -513,8 +511,7 @@ fn build_session_options(binary: ~str, let save_temps = getopts::opt_present(matches, ~"save-temps"); match output_type { // unless we're emitting huamn-readable assembly, omit comments. - linkage::output_type_llvm_assembly | - linkage::output_type_assembly => (), + link::output_type_llvm_assembly | link::output_type_assembly => (), _ => debugging_opts |= session::no_asm_comments } let opt_level = { @@ -660,18 +657,18 @@ fn build_output_filenames(input: input, let out_path; let sopts = sess.opts; let stop_after_codegen = - sopts.output_type != linkage::output_type_exe || + sopts.output_type != link::output_type_exe || sopts.static && sess.building_library; let obj_suffix = match sopts.output_type { - linkage::output_type_none => ~"none", - linkage::output_type_bitcode => ~"bc", - linkage::output_type_assembly => ~"s", - linkage::output_type_llvm_assembly => ~"ll", + link::output_type_none => ~"none", + link::output_type_bitcode => ~"bc", + link::output_type_assembly => ~"s", + link::output_type_llvm_assembly => ~"ll", // Object and exe output both use the '.o' extension here - linkage::output_type_object | linkage::output_type_exe => ~"o" + link::output_type_object | link::output_type_exe => ~"o" }; match *ofile { diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index c4dde985bdb..70e717aa6d9 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -6,7 +6,7 @@ use syntax::ast::{int_ty, uint_ty, float_ty}; use syntax::parse::parse_sess; use metadata::filesearch; use back::target_strs; -use back::linkage; +use back::link; use middle::lint; @@ -113,7 +113,7 @@ type options = lint_opts: ~[(lint::lint, lint::level)], save_temps: bool, jit: bool, - output_type: back::linkage::output_type, + output_type: back::link::output_type, addl_lib_search_paths: ~[Path], maybe_sysroot: Option, target_triple: ~str, @@ -256,7 +256,7 @@ fn basic_options() -> @options { lint_opts: ~[], save_temps: false, jit: false, - output_type: linkage::output_type_exe, + output_type: link::output_type_exe, addl_lib_search_paths: ~[], maybe_sysroot: None, target_triple: driver::host_triple(), diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index f72b4214abe..ef791cd5020 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -20,7 +20,7 @@ use std::map::{int_hash, str_hash}; use driver::session; use session::session; use syntax::attr; -use back::{linkage, abi, upcall}; +use back::{link, abi, upcall}; use syntax::{ast, ast_util, codemap, ast_map}; use ast_util::{local_def, path_to_ident}; use syntax::visit; @@ -32,7 +32,7 @@ use util::common::is_main_name; use lib::llvm::{llvm, mk_target_data, mk_type_names}; use lib::llvm::{ModuleRef, ValueRef, TypeRef, BasicBlockRef}; use lib::llvm::{True, False}; -use linkage::{mangle_internal_name_by_type_only, +use link::{mangle_internal_name_by_type_only, mangle_internal_name_by_seq, mangle_internal_name_by_path, mangle_internal_name_by_path_and_seq, @@ -2571,7 +2571,7 @@ fn trans_crate(sess: session::session, let symbol_hasher = @hash::default_state(); let link_meta = - linkage::build_link_meta(sess, *crate, output, symbol_hasher); + link::build_link_meta(sess, *crate, output, symbol_hasher); let reachable = reachable::find_reachable(crate.node.module, emap, tcx, maps.method_map); diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index abc9cfecfd6..1ba8e22607a 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -10,7 +10,7 @@ use type_of::*; use back::abi; use syntax::codemap::span; use syntax::print::pprust::expr_to_str; -use back::linkage::{ +use back::link::{ mangle_internal_name_by_path, mangle_internal_name_by_path_and_seq}; use util::ppaux::ty_to_str; diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index f3fc4bfaa26..b0ac8d920bc 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -10,7 +10,7 @@ use syntax::{ast, ast_map}; use driver::session; use session::session; use middle::ty; -use back::{linkage, abi, upcall}; +use back::{link, abi, upcall}; use syntax::codemap::span; use lib::llvm::{llvm, target_data, type_names, associate_type, name_has_type}; diff --git a/src/rustc/middle/trans/controlflow.rs b/src/rustc/middle/trans/controlflow.rs index 7eda33fb2fb..1affa18a683 100644 --- a/src/rustc/middle/trans/controlflow.rs +++ b/src/rustc/middle/trans/controlflow.rs @@ -165,7 +165,7 @@ fn trans_log(log_ex: @ast::expr, let global = if ccx.module_data.contains_key(modname) { ccx.module_data.get(modname) } else { - let s = linkage::mangle_internal_name_by_path_and_seq( + let s = link::mangle_internal_name_by_path_and_seq( ccx, modpath, ~"loglevel"); let global = str::as_c_str(s, |buf| { llvm::LLVMAddGlobal(ccx.llmod, T_i32(), buf) diff --git a/src/rustc/middle/trans/foreign.rs b/src/rustc/middle/trans/foreign.rs index d267599095a..b97fa54588c 100644 --- a/src/rustc/middle/trans/foreign.rs +++ b/src/rustc/middle/trans/foreign.rs @@ -10,7 +10,7 @@ use lib::llvm::{ llvm, TypeRef, ValueRef, Integer, Pointer, Float, Double, StructRetAttribute, ByValAttribute, SequentiallyConsistent, Acquire, Release, Xchg }; use syntax::{ast, ast_util}; -use back::{linkage, abi}; +use back::{link, abi}; use common::*; use build::*; use base::*; @@ -1007,7 +1007,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, id: ast::node_id) -> ValueRef { let _icx = ccx.insn_ctxt("foreign::foreign::build_rust_fn"); let t = ty::node_id_to_type(ccx.tcx, id); - let ps = linkage::mangle_internal_name_by_path( + let ps = link::mangle_internal_name_by_path( ccx, vec::append_one(path, ast_map::path_name( syntax::parse::token::special_idents::clownshoe_abi ))); @@ -1046,7 +1046,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, // is wired directly into the return slot in the shim struct } - let shim_name = linkage::mangle_internal_name_by_path( + let shim_name = link::mangle_internal_name_by_path( ccx, vec::append_one(path, ast_map::path_name( syntax::parse::token::special_idents::clownshoe_stack_shim ))); diff --git a/src/rustc/middle/trans/meth.rs b/src/rustc/middle/trans/meth.rs index ddb79f8cd4a..a87ae02f8d2 100644 --- a/src/rustc/middle/trans/meth.rs +++ b/src/rustc/middle/trans/meth.rs @@ -8,7 +8,7 @@ use syntax::{ast, ast_map}; use ast_map::{path, path_mod, path_name, node_id_to_str}; use syntax::ast_util::local_def; use metadata::csearch; -use back::abi; +use back::{link, abi}; use lib::llvm::llvm; use lib::llvm::{ValueRef, TypeRef}; use lib::llvm::llvm::LLVMGetParam; diff --git a/src/rustc/middle/trans/monomorphize.rs b/src/rustc/middle/trans/monomorphize.rs index 239988c06e5..243b0b96fa3 100644 --- a/src/rustc/middle/trans/monomorphize.rs +++ b/src/rustc/middle/trans/monomorphize.rs @@ -9,7 +9,7 @@ use base::{trans_item, get_item_val, no_self, self_arg, trans_fn, get_insn_ctxt}; use syntax::parse::token::special_idents; use type_of::type_of_fn_from_ty; -use back::linkage::mangle_exported_name; +use back::link::mangle_exported_name; use middle::ty::{FnTyBase, FnMeta, FnSig}; fn monomorphic_fn(ccx: @crate_ctxt, diff --git a/src/rustc/rustc.rc b/src/rustc/rustc.rc index 46b2ff1fa50..501192d3ced 100644 --- a/src/rustc/rustc.rc +++ b/src/rustc/rustc.rc @@ -121,7 +121,7 @@ mod front { } mod back { - mod linkage; + mod link; mod abi; mod upcall; mod x86; diff --git a/src/rustdoc/astsrv.rs b/src/rustdoc/astsrv.rs index 1f6ba5ed907..cda89e3b083 100644 --- a/src/rustdoc/astsrv.rs +++ b/src/rustdoc/astsrv.rs @@ -17,6 +17,7 @@ use syntax::diagnostic::handler; use syntax::ast; use syntax::codemap; use syntax::ast_map; +use rustc::back::link; use rustc::metadata::filesearch; use rustc::front; diff --git a/src/rustdoc/doc.rs b/src/rustdoc/doc.rs index 154a7f1c6d0..5161fdff270 100644 --- a/src/rustdoc/doc.rs +++ b/src/rustdoc/doc.rs @@ -334,13 +334,13 @@ impl index : cmp::Eq { * * kind - The type of thing being indexed, e.g. 'Module' * * name - The name of the thing * * brief - The brief description - * * lnk - A format-specific string representing the link target + * * link - A format-specific string representing the link target */ type index_entry = { kind: ~str, name: ~str, brief: Option<~str>, - lnk: ~str + link: ~str }; impl index_entry : cmp::Eq { @@ -348,7 +348,7 @@ impl index_entry : cmp::Eq { self.kind == other.kind && self.name == other.name && self.brief == other.brief && - self.lnk == other.lnk + self.link == other.link } pure fn ne(&&other: index_entry) -> bool { !self.eq(other) } } diff --git a/src/rustdoc/markdown_index_pass.rs b/src/rustdoc/markdown_index_pass.rs index 067951ef6f9..172147b1f24 100644 --- a/src/rustdoc/markdown_index_pass.rs +++ b/src/rustdoc/markdown_index_pass.rs @@ -78,7 +78,7 @@ fn item_to_entry( doc: doc::itemtag, config: config::config ) -> doc::index_entry { - let lnk = match doc { + let link = match doc { doc::modtag(_) | doc::nmodtag(_) if config.output_style == config::doc_per_mod => { markdown_writer::make_filename(config, doc::itempage(doc)).to_str() @@ -92,7 +92,7 @@ fn item_to_entry( kind: markdown_pass::header_kind(doc), name: markdown_pass::header_name(doc), brief: doc.brief(), - lnk: lnk + link: link } } @@ -156,13 +156,13 @@ fn should_index_mod_contents() { kind: ~"Module", name: ~"a", brief: None, - lnk: ~"#module-a" + link: ~"#module-a" }; assert option::get(doc.cratemod().index).entries[1] == { kind: ~"Function", name: ~"b", brief: None, - lnk: ~"#function-b" + link: ~"#function-b" }; } @@ -176,13 +176,13 @@ fn should_index_mod_contents_multi_page() { kind: ~"Module", name: ~"a", brief: None, - lnk: ~"a.html" + link: ~"a.html" }; assert option::get(doc.cratemod().index).entries[1] == { kind: ~"Function", name: ~"b", brief: None, - lnk: ~"#function-b" + link: ~"#function-b" }; } @@ -196,7 +196,7 @@ fn should_index_foreign_mod_pages() { kind: ~"Foreign module", name: ~"a", brief: None, - lnk: ~"a.html" + link: ~"a.html" }; } @@ -220,7 +220,7 @@ fn should_index_foreign_mod_contents() { kind: ~"Function", name: ~"b", brief: None, - lnk: ~"#function-b" + link: ~"#function-b" }; } diff --git a/src/rustdoc/markdown_pass.rs b/src/rustdoc/markdown_pass.rs index 726bbc56237..03726ca0188 100644 --- a/src/rustdoc/markdown_pass.rs +++ b/src/rustdoc/markdown_pass.rs @@ -398,7 +398,7 @@ fn write_index(ctxt: ctxt, index: doc::index) { for index.entries.each |entry| { let header = header_text_(entry.kind, entry.name); - let id = entry.lnk; + let id = entry.link; if option::is_some(entry.brief) { ctxt.w.write_line(fmt!("* [%s](%s) - %s", header, id, option::get(entry.brief))); diff --git a/src/test/run-pass/mlist-cycle.rs b/src/test/run-pass/mlist-cycle.rs index e07c066f9c9..0fcb95fb73b 100644 --- a/src/test/run-pass/mlist-cycle.rs +++ b/src/test/run-pass/mlist-cycle.rs @@ -2,14 +2,14 @@ // -*- rust -*- extern mod std; -type Cell = {mut c: @List}; +type cell = {mut c: @list}; -enum List { Link(@Cell), Nil, } +enum list { link(@cell), nil, } fn main() { - let first: @Cell = @{mut c: @Nil()}; - let second: @Cell = @{mut c: @Link(first)}; - first._0 = @Link(second); + let first: @cell = @{mut c: @nil()}; + let second: @cell = @{mut c: @link(first)}; + first._0 = @link(second); sys.rustrt.gc(); - let third: @Cell = @{mut c: @Nil()}; -} + let third: @cell = @{mut c: @nil()}; +} \ No newline at end of file