Switch 'native' to 'extern' (or 'foreign' in some descriptions)

This commit is contained in:
Graydon Hoare 2012-07-03 16:11:00 -07:00
parent 7259195caf
commit debb7e4641
127 changed files with 249 additions and 249 deletions

View file

@ -609,7 +609,7 @@ fn link_binary(sess: session,
let ula = cstore::get_used_link_args(cstore);
for ula.each |arg| { vec::push(cc_args, arg); }
// # Native library linking
// # Extern library linking
// User-supplied library search paths (-L on the cammand line) These are
// the same paths used to find Rust crates, so some of them may have been
@ -620,7 +620,7 @@ fn link_binary(sess: session,
let addl_paths = sess.opts.addl_lib_search_paths;
for addl_paths.each |path| { vec::push(cc_args, "-L" + path); }
// The names of the native libraries
// The names of the extern libraries
let used_libs = cstore::get_used_libraries(cstore);
for used_libs.each |l| { vec::push(cc_args, "-l" + l); }
@ -673,7 +673,7 @@ fn link_binary(sess: session,
vec::push(cc_args, "-lmorestack");
// FIXME (#2397): At some point we want to rpath our guesses as to where
// native libraries might live, based on the addl_lib_search_paths
// extern libraries might live, based on the addl_lib_search_paths
vec::push_all(cc_args, rpath::get_rpath_flags(sess, output));
#debug("%s link args: %s", cc_prog, str::connect(cc_args, " "));

View file

@ -27,7 +27,7 @@ fn get_rpath_flags(sess: session::session, out_filename: str) -> ~[str] {
let sysroot = sess.filesearch.sysroot();
let output = out_filename;
let libs = cstore::get_used_crate_files(sess.cstore);
// We don't currently rpath native libraries, but we know
// We don't currently rpath extern libraries, but we know
// where rustrt is and we know every rust program needs it
let libs = vec::append_one(libs, get_sysroot_absolute_rt_lib(sess));

View file

@ -121,7 +121,7 @@ mod intrinsic {
}
#[abi = "rust-intrinsic"]
native mod rusti {
extern mod rusti {
fn visit_ty<T>(&&tv: ty_visitor);
}
}

View file

@ -191,7 +191,7 @@ type SectionIteratorRef = *SectionIterator_opaque;
#[link_args = "-Lrustllvm"]
#[link_name = "rustllvm"]
#[abi = "cdecl"]
native mod llvm {
extern mod llvm {
/* Create and destroy contexts. */
fn LLVMContextCreate() -> ContextRef;
fn LLVMGetGlobalContext() -> ContextRef;

View file

@ -1,6 +1,6 @@
#[doc = "
Validates all used crates and native libraries and loads their metadata
Validates all used crates and extern libraries and loads their metadata
"];
@ -17,7 +17,7 @@ import dvec::{dvec, extensions};
export read_crates;
// Traverses an AST, reading all the information about use'd crates and native
// Traverses an AST, reading all the information about use'd crates and extern
// libraries necessary for later resolving, typechecking, linking, etc.
fn read_crates(diag: span_handler, crate: ast::crate,
cstore: cstore::cstore, filesearch: filesearch,

View file

@ -675,14 +675,14 @@ fn item_family_to_str(fam: char) -> str {
'f' { ret "fn"; }
'u' { ret "unsafe fn"; }
'p' { ret "pure fn"; }
'F' { ret "native fn"; }
'U' { ret "unsafe native fn"; }
'P' { ret "pure native fn"; }
'F' { ret "foreign fn"; }
'U' { ret "unsafe foreign fn"; }
'P' { ret "pure foreign fn"; }
'y' { ret "type"; }
'T' { ret "native type"; }
'T' { ret "foreign type"; }
't' { ret "type"; }
'm' { ret "mod"; }
'n' { ret "native mod"; }
'n' { ret "foreign mod"; }
'v' { ret "enum"; }
'i' { ret "impl"; }
'I' { ret "iface"; }

View file

@ -87,7 +87,7 @@ fn get_lint_dict() -> lint_dict {
let v = ~[
("ctypes",
@{lint: ctypes,
desc: "proper use of core::libc types in native modules",
desc: "proper use of core::libc types in foreign modules",
default: warn}),
("unused_imports",
@ -368,14 +368,14 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
cx.sess.span_lint(
ctypes, id, fn_id,
ty.span,
"found rust type `int` in native module, while \
"found rust type `int` in foreign module, while \
libc::c_int or libc::c_long should be used");
}
ast::def_prim_ty(ast::ty_uint(ast::ty_u)) {
cx.sess.span_lint(
ctypes, id, fn_id,
ty.span,
"found rust type `uint` in native module, while \
"found rust type `uint` in foreign module, while \
libc::c_uint or libc::c_ulong should be used");
}
_ { }

View file

@ -106,7 +106,7 @@ type indexed_mod = {
path: str
};
/* native modules can't contain enums, and we don't store their ASTs because
/* foreign modules can't contain enums, and we don't store their ASTs because
we only need to look at them to determine exports, which they can't
control.*/
@ -1481,7 +1481,7 @@ fn lookup_in_local_mod(e: env, node_id: node_id, sp: span, id: ident,
module %d not in mod_map", node_id)); }
};
if dr == outside && !is_exported(e, id, inf) {
// if we're in a native mod, then dr==inside, so inf.m is some _mod
// if we're in a foreign mod, then dr==inside, so inf.m is some _mod
ret none; // name is not visible
}
alt inf.index.find(id) {

View file

@ -4913,7 +4913,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
ast::item_fn(decl, tps, body) {
if decl.purity == ast::extern_fn {
let llfndecl = get_item_val(ccx, item.id);
foreign::trans_extern_fn(ccx,
foreign::trans_foreign_fn(ccx,
vec::append(
*path,
~[path_name(item.ident)]),
@ -5194,7 +5194,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
let llfn = if decl.purity != ast::extern_fn {
register_fn(ccx, i.span, my_path, i.id)
} else {
foreign::register_extern_fn(ccx, i.span, my_path, i.id)
foreign::register_foreign_fn(ccx, i.span, my_path, i.id)
};
set_inline_hint_if_appr(i.attrs, llfn);
llfn

View file

@ -19,7 +19,7 @@ import type_of::*;
import std::map::hashmap;
import util::ppaux::ty_to_str;
export link_name, trans_foreign_mod, register_extern_fn, trans_extern_fn,
export link_name, trans_foreign_mod, register_foreign_fn, trans_foreign_fn,
trans_intrinsic;
enum x86_64_reg_class {
@ -541,7 +541,7 @@ fn build_wrap_fn_(ccx: @crate_ctxt,
Unreachable(ret_cx);
}
// For each native function F, we generate a wrapper function W and a shim
// For each foreign function F, we generate a wrapper function W and a shim
// function S that all work together. The wrapper function W is the function
// that other rust code actually invokes. Its job is to marshall the
// arguments into a struct. It then uses a small bit of assembly to switch
@ -549,7 +549,7 @@ fn build_wrap_fn_(ccx: @crate_ctxt,
// unpacks the arguments from the struct and invokes the actual function F
// according to its specified calling convention.
//
// Example: Given a native c-stack function F(x: X, y: Y) -> Z,
// Example: Given a foreign c-stack function F(x: X, y: Y) -> Z,
// we generate a wrapper function W that looks like:
//
// void W(Z* dest, void *env, X x, Y y) {
@ -984,15 +984,15 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
finish_fn(fcx, lltop);
}
fn trans_extern_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
body: ast::blk, llwrapfn: ValueRef, id: ast::node_id) {
let _icx = ccx.insn_ctxt("foreign::build_extern_fn");
let _icx = ccx.insn_ctxt("foreign::build_foreign_fn");
fn build_rust_fn(ccx: @crate_ctxt, path: ast_map::path,
decl: ast::fn_decl, body: ast::blk,
id: ast::node_id) -> ValueRef {
let _icx = ccx.insn_ctxt("foreign::extern::build_rust_fn");
let _icx = ccx.insn_ctxt("foreign::foreign::build_rust_fn");
let t = ty::node_id_to_type(ccx.tcx, id);
let ps = link::mangle_internal_name_by_path(
ccx, vec::append_one(path, ast_map::path_name(@"__rust_abi")));
@ -1005,7 +1005,7 @@ fn trans_extern_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
fn build_shim_fn(ccx: @crate_ctxt, path: ast_map::path,
llrustfn: ValueRef, tys: @c_stack_tys) -> ValueRef {
let _icx = ccx.insn_ctxt("foreign::extern::build_shim_fn");
let _icx = ccx.insn_ctxt("foreign::foreign::build_shim_fn");
fn build_args(bcx: block, tys: @c_stack_tys,
llargbundle: ValueRef) -> ~[ValueRef] {
@ -1042,11 +1042,11 @@ fn trans_extern_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
fn build_wrap_fn(ccx: @crate_ctxt, llshimfn: ValueRef,
llwrapfn: ValueRef, tys: @c_stack_tys) {
let _icx = ccx.insn_ctxt("foreign::extern::build_wrap_fn");
let _icx = ccx.insn_ctxt("foreign::foreign::build_wrap_fn");
fn build_args(bcx: block, tys: @c_stack_tys,
llwrapfn: ValueRef, llargbundle: ValueRef) {
let _icx = bcx.insn_ctxt("foreign::extern::wrap::build_args");
let _icx = bcx.insn_ctxt("foreign::foreign::wrap::build_args");
alt tys.x86_64_tys {
option::some(x86_64) {
let mut atys = x86_64.arg_tys;
@ -1100,7 +1100,7 @@ fn trans_extern_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
fn build_ret(bcx: block, tys: @c_stack_tys,
llargbundle: ValueRef) {
let _icx = bcx.insn_ctxt("foreign::extern::wrap::build_ret");
let _icx = bcx.insn_ctxt("foreign::foreign::wrap::build_ret");
alt tys.x86_64_tys {
option::some(x86_64) {
if x86_64.sret || !tys.ret_def {
@ -1137,14 +1137,14 @@ fn trans_extern_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
let llrustfn = build_rust_fn(ccx, path, decl, body, id);
// The internal shim function - runs on the Rust stack
let llshimfn = build_shim_fn(ccx, path, llrustfn, tys);
// The external C function - runs on the C stack
// The foreign C function - runs on the C stack
build_wrap_fn(ccx, llshimfn, llwrapfn, tys)
}
fn register_extern_fn(ccx: @crate_ctxt, sp: span,
fn register_foreign_fn(ccx: @crate_ctxt, sp: span,
path: ast_map::path, node_id: ast::node_id)
-> ValueRef {
let _icx = ccx.insn_ctxt("foreign::register_extern_fn");
let _icx = ccx.insn_ctxt("foreign::register_foreign_fn");
let t = ty::node_id_to_type(ccx.tcx, node_id);
let (llargtys, llretty, ret_ty) = c_arg_and_ret_lltys(ccx, node_id);
ret if ccx.sess.targ_cfg.arch == arch_x86_64 {

View file

@ -259,8 +259,8 @@ fn check_main_fn_ty(ccx: @crate_ctxt,
if !ok {
tcx.sess.span_err(main_span,
#fmt("Wrong type in main function: found `%s`, \
expecting `native fn(~[str]) -> ()` \
or `native fn() -> ()`",
expecting `extern fn(~[str]) -> ()` \
or `extern fn() -> ()`",
ty_to_str(tcx, main_t)));
}
}

View file

@ -403,7 +403,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
if (*tpt.bounds).is_not_empty() {
ccx.tcx.sess.span_err(
item.span,
#fmt["native items may not have type parameters"]);
#fmt["foreign items may not have type parameters"]);
}
}
}
@ -740,8 +740,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
// really hard due to the way that expr_bind() is
// written.
fcx.ccx.tcx.sess.span_fatal(sp, "mismatched types: \
expected function or native \
function but found "
expected function or foreign \
function but found "
+ fcx.infcx.ty_to_str(in_fty));
}
};

View file

@ -398,7 +398,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
}
fn convert_foreign(ccx: @crate_ctxt, i: @ast::foreign_item) {
// As above, this call populates the type table with the converted
// type of the native item. We simply write it into the node type
// type of the foreign item. We simply write it into the node type
// table.
let tpt = ty_of_foreign_item(ccx, i);
alt i.node {