Change 'native' and 'crust' to 'extern'.

This comes with a terminology change. All linkage-symbols are 'extern'
now, including rust syms in other crates. Some extern ABIs are
merely "foreign". The term "native" is retired, not clear/useful.

What was "crust" is now "extern" applied to a _definition_. This
is a bit of an overloading, but should be unambiguous: it means
that the definition should be made available to some non-rust ABI.
This commit is contained in:
Graydon Hoare 2012-06-26 16:18:37 -07:00
parent 999b567e2a
commit 697f1e38d6
60 changed files with 377 additions and 353 deletions

View File

@ -167,8 +167,8 @@ mod global_env {
sched: some({
mode: task::single_threaded,
// FIXME (#2621): This would be a good place to use a
// very small native stack
native_stack_size: none
// very small foreign stack
foreign_stack_size: none
})
with task::get_opts(builder)
});

View File

@ -104,17 +104,17 @@ Scheduler configuration options
* sched_mode - The operating mode of the scheduler
* native_stack_size - The size of the native stack, in bytes
* foreign_stack_size - The size of the foreign stack, in bytes
Rust code runs on Rust-specific stacks. When Rust code calls native code
(via functions in native modules) it switches to a typical, large stack
Rust code runs on Rust-specific stacks. When Rust code calls foreign code
(via functions in foreign modules) it switches to a typical, large stack
appropriate for running code written in languages like C. By default these
native stacks have unspecified size, but with this option their size can
foreign stacks have unspecified size, but with this option their size can
be precisely specified.
"]
type sched_opts = {
mode: sched_mode,
native_stack_size: option<uint>
foreign_stack_size: option<uint>
};
#[doc = "
@ -140,7 +140,7 @@ Task configuration options
into a new scheduler with the specific properties required.
This is of particular importance for libraries which want to call
into native code that blocks. Without doing so in a different
into foreign code that blocks. Without doing so in a different
scheduler other tasks will be impeded or even blocked indefinitely.
"]
@ -408,7 +408,7 @@ fn spawn_sched(mode: sched_mode, +f: fn~()) {
set_opts(builder, {
sched: some({
mode: mode,
native_stack_size: none
foreign_stack_size: none
})
with get_opts(builder)
});
@ -542,8 +542,8 @@ fn spawn_raw(opts: task_opts, +f: fn~()) {
}
fn new_task_in_new_sched(opts: sched_opts) -> *rust_task {
if opts.native_stack_size != none {
fail "native_stack_size scheduler option unimplemented";
if opts.foreign_stack_size != none {
fail "foreign_stack_size scheduler option unimplemented";
}
let num_threads = alt opts.mode {
@ -804,7 +804,7 @@ native mod testrt {
#[test]
fn test_spawn_sched_blocking() {
// Testing that a task in one scheduler can block natively
// Testing that a task in one scheduler can block in foreign code
// without affecting other schedulers
iter::repeat(20u) {||
@ -947,7 +947,7 @@ fn test_osmain() {
let opts = {
sched: some({
mode: osmain,
native_stack_size: none
foreign_stack_size: none
})
with get_opts(buildr)
};

View File

@ -46,7 +46,7 @@ fn get_monitor_task_gl() -> iotask unsafe {
supervise: false,
sched: some({
mode: task::single_threaded,
native_stack_size: none
foreign_stack_size: none
})
with task::get_opts(builder)
});

View File

@ -34,7 +34,7 @@ fn spawn_iotask(-builder: task::builder) -> iotask {
set_opts(builder, {
sched: some({
mode: single_threaded,
native_stack_size: none
foreign_stack_size: none
})
with get_opts(builder)
});

View File

@ -1314,80 +1314,80 @@ mod test {
#[test]
#[ignore(cfg(target_os = "freebsd"))]
fn test_uv_ll_struct_size_uv_tcp_t() {
let native_handle_size = rustrt::rust_uv_helper_uv_tcp_t_size();
let foreign_handle_size = rustrt::rust_uv_helper_uv_tcp_t_size();
let rust_handle_size = sys::size_of::<uv_tcp_t>();
let output = #fmt("uv_tcp_t -- native: %u rust: %u",
native_handle_size as uint, rust_handle_size);
foreign_handle_size as uint, rust_handle_size);
log(debug, output);
assert native_handle_size as uint == rust_handle_size;
assert foreign_handle_size as uint == rust_handle_size;
}
#[test]
#[ignore(cfg(target_os = "freebsd"))]
fn test_uv_ll_struct_size_uv_connect_t() {
let native_handle_size =
let foreign_handle_size =
rustrt::rust_uv_helper_uv_connect_t_size();
let rust_handle_size = sys::size_of::<uv_connect_t>();
let output = #fmt("uv_connect_t -- native: %u rust: %u",
native_handle_size as uint, rust_handle_size);
foreign_handle_size as uint, rust_handle_size);
log(debug, output);
assert native_handle_size as uint == rust_handle_size;
assert foreign_handle_size as uint == rust_handle_size;
}
#[test]
#[ignore(cfg(target_os = "freebsd"))]
fn test_uv_ll_struct_size_uv_buf_t() {
let native_handle_size =
let foreign_handle_size =
rustrt::rust_uv_helper_uv_buf_t_size();
let rust_handle_size = sys::size_of::<uv_buf_t>();
let output = #fmt("uv_buf_t -- native: %u rust: %u",
native_handle_size as uint, rust_handle_size);
foreign_handle_size as uint, rust_handle_size);
log(debug, output);
assert native_handle_size as uint == rust_handle_size;
assert foreign_handle_size as uint == rust_handle_size;
}
#[test]
#[ignore(cfg(target_os = "freebsd"))]
fn test_uv_ll_struct_size_uv_write_t() {
let native_handle_size =
let foreign_handle_size =
rustrt::rust_uv_helper_uv_write_t_size();
let rust_handle_size = sys::size_of::<uv_write_t>();
let output = #fmt("uv_write_t -- native: %u rust: %u",
native_handle_size as uint, rust_handle_size);
foreign_handle_size as uint, rust_handle_size);
log(debug, output);
assert native_handle_size as uint == rust_handle_size;
assert foreign_handle_size as uint == rust_handle_size;
}
#[test]
#[ignore(cfg(target_os = "freebsd"))]
fn test_uv_ll_struct_size_sockaddr_in() {
let native_handle_size =
let foreign_handle_size =
rustrt::rust_uv_helper_sockaddr_in_size();
let rust_handle_size = sys::size_of::<sockaddr_in>();
let output = #fmt("sockaddr_in -- native: %u rust: %u",
native_handle_size as uint, rust_handle_size);
foreign_handle_size as uint, rust_handle_size);
log(debug, output);
assert native_handle_size as uint == rust_handle_size;
assert foreign_handle_size as uint == rust_handle_size;
}
#[test]
#[ignore(cfg(target_os = "freebsd"))]
fn test_uv_ll_struct_size_uv_async_t() {
let native_handle_size =
let foreign_handle_size =
rustrt::rust_uv_helper_uv_async_t_size();
let rust_handle_size = sys::size_of::<uv_async_t>();
let output = #fmt("uv_async_t -- native: %u rust: %u",
native_handle_size as uint, rust_handle_size);
foreign_handle_size as uint, rust_handle_size);
log(debug, output);
assert native_handle_size as uint == rust_handle_size;
assert foreign_handle_size as uint == rust_handle_size;
}
#[test]
#[ignore(cfg(target_os = "freebsd"))]
fn test_uv_ll_struct_size_uv_timer_t() {
let native_handle_size =
let foreign_handle_size =
rustrt::rust_uv_helper_uv_timer_t_size();
let rust_handle_size = sys::size_of::<uv_timer_t>();
let output = #fmt("uv_timer_t -- native: %u rust: %u",
native_handle_size as uint, rust_handle_size);
foreign_handle_size as uint, rust_handle_size);
log(debug, output);
assert native_handle_size as uint == rust_handle_size;
assert foreign_handle_size as uint == rust_handle_size;
}
}

View File

@ -73,7 +73,7 @@ enum def {
def_fn(def_id, purity),
def_self(node_id),
def_mod(def_id),
def_native_mod(def_id),
def_foreign_mod(def_id),
def_const(def_id),
def_arg(node_id, mode),
def_local(node_id, bool /* is_mutbl */),
@ -563,7 +563,7 @@ enum purity {
pure_fn, // declared with "pure fn"
unsafe_fn, // declared with "unsafe fn"
impure_fn, // declared with "fn"
crust_fn, // declared with "crust fn"
extern_fn, // declared with "crust fn"
}
#[auto_serialize]
@ -584,16 +584,16 @@ type method = {ident: ident, attrs: [attribute]/~,
type _mod = {view_items: [@view_item]/~, items: [@item]/~};
#[auto_serialize]
enum native_abi {
native_abi_rust_intrinsic,
native_abi_cdecl,
native_abi_stdcall,
enum foreign_abi {
foreign_abi_rust_intrinsic,
foreign_abi_cdecl,
foreign_abi_stdcall,
}
#[auto_serialize]
type native_mod =
type foreign_mod =
{view_items: [@view_item]/~,
items: [@native_item]/~};
items: [@foreign_item]/~};
#[auto_serialize]
type variant_arg = {ty: @ty, id: node_id};
@ -681,7 +681,7 @@ enum item_ {
item_const(@ty, @expr),
item_fn(fn_decl, [ty_param]/~, blk),
item_mod(_mod),
item_native_mod(native_mod),
item_foreign_mod(foreign_mod),
item_ty(@ty, [ty_param]/~, region_param),
item_enum([variant]/~, [ty_param]/~, region_param),
item_class([ty_param]/~, /* ty params for class */
@ -728,16 +728,16 @@ type class_dtor_ = {id: node_id,
body: blk};
#[auto_serialize]
type native_item =
type foreign_item =
{ident: ident,
attrs: [attribute]/~,
node: native_item_,
node: foreign_item_,
id: node_id,
span: span};
#[auto_serialize]
enum native_item_ {
native_item_fn(fn_decl, [ty_param]/~),
enum foreign_item_ {
foreign_item_fn(fn_decl, [ty_param]/~),
}
// The data we save and restore about an inlined item or method. This is not
@ -747,7 +747,7 @@ enum native_item_ {
enum inlined_item {
ii_item(@item),
ii_method(def_id /* impl id */, @method),
ii_native(@native_item),
ii_foreign(@foreign_item),
ii_ctor(class_ctor, ident, [ty_param]/~, def_id /* parent id */),
ii_dtor(class_dtor, ident, [ty_param]/~, def_id /* parent id */)
}

View File

@ -34,7 +34,7 @@ fn path_to_str(p: path) -> str {
enum ast_node {
node_item(@item, @path),
node_native_item(@native_item, native_abi, @path),
node_foreign_item(@foreign_item, foreign_abi, @path),
node_method(@method, def_id /* impl did */, @path /* path to the impl */),
node_variant(variant, @item, @path),
node_expr(@expr),
@ -104,8 +104,8 @@ fn map_decoded_item(diag: span_handler,
// add it to the table now:
alt ii {
ii_item(*) | ii_ctor(*) | ii_dtor(*) { /* fallthrough */ }
ii_native(i) {
cx.map.insert(i.id, node_native_item(i, native_abi_rust_intrinsic,
ii_foreign(i) {
cx.map.insert(i.id, node_foreign_item(i, foreign_abi_rust_intrinsic,
@path));
}
ii_method(impl_did, m) {
@ -202,14 +202,14 @@ fn map_item(i: @item, cx: ctx, v: vt) {
extend(cx, i.ident)));
}
}
item_native_mod(nm) {
let abi = alt attr::native_abi(i.attrs) {
item_foreign_mod(nm) {
let abi = alt attr::foreign_abi(i.attrs) {
either::left(msg) { cx.diag.span_fatal(i.span, msg); }
either::right(abi) { abi }
};
for nm.items.each {|nitem|
cx.map.insert(nitem.id,
node_native_item(nitem, abi,
node_foreign_item(nitem, abi,
/* FIXME (#2543) */
@copy cx.path));
}
@ -228,7 +228,7 @@ fn map_item(i: @item, cx: ctx, v: vt) {
_ { }
}
alt i.node {
item_mod(_) | item_native_mod(_) {
item_mod(_) | item_foreign_mod(_) {
vec::push(cx.path, path_mod(i.ident));
}
_ { vec::push(cx.path, path_name(i.ident)); }
@ -269,7 +269,7 @@ fn node_id_to_str(map: map, id: node_id) -> str {
some(node_item(item, path)) {
#fmt["item %s (id=%?)", path_ident_to_str(*path, item.ident), id]
}
some(node_native_item(item, abi, path)) {
some(node_foreign_item(item, abi, path)) {
#fmt["native item %s with abi %? (id=%?)",
path_ident_to_str(*path, item.ident), abi, id]
}

View File

@ -51,7 +51,7 @@ fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} {
pure fn def_id_of_def(d: def) -> def_id {
alt d {
def_fn(id, _) | def_mod(id) |
def_native_mod(id) | def_const(id) |
def_foreign_mod(id) | def_const(id) |
def_variant(_, id) | def_ty(id) | def_ty_param(id, _) |
def_use(id) | def_class(id) { id }
def_arg(id, _) | def_local(id, _) | def_self(id) |
@ -321,7 +321,7 @@ impl inlined_item_methods for inlined_item {
fn ident() -> ident {
alt self {
ii_item(i) { /* FIXME (#2543) */ copy i.ident }
ii_native(i) { /* FIXME (#2543) */ copy i.ident }
ii_foreign(i) { /* FIXME (#2543) */ copy i.ident }
ii_method(_, m) { /* FIXME (#2543) */ copy m.ident }
ii_ctor(_, nm, _, _) { /* FIXME (#2543) */ copy nm }
ii_dtor(_, nm, _, _) { /* FIXME (#2543) */ copy nm }
@ -331,7 +331,7 @@ impl inlined_item_methods for inlined_item {
fn id() -> ast::node_id {
alt self {
ii_item(i) { i.id }
ii_native(i) { i.id }
ii_foreign(i) { i.id }
ii_method(_, m) { m.id }
ii_ctor(ctor, _, _, _) { ctor.node.id }
ii_dtor(dtor, _, _, _) { dtor.node.id }
@ -341,7 +341,7 @@ impl inlined_item_methods for inlined_item {
fn accept<E>(e: E, v: visit::vt<E>) {
alt self {
ii_item(i) { v.visit_item(i, e, v) }
ii_native(i) { v.visit_native_item(i, e, v) }
ii_foreign(i) { v.visit_foreign_item(i, e, v) }
ii_method(_, m) { visit::visit_method_helper(m, e, v) }
ii_ctor(ctor, nm, tps, parent_id) {
visit::visit_class_ctor_helper(ctor, nm, tps, parent_id, e, v);
@ -419,7 +419,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
}
},
visit_native_item: fn@(ni: @native_item) {
visit_foreign_item: fn@(ni: @foreign_item) {
vfn(ni.id)
},

View File

@ -39,7 +39,7 @@ export sort_meta_items;
export remove_meta_items_by_name;
export find_linkage_attrs;
export find_linkage_metas;
export native_abi;
export foreign_abi;
export inline_attr;
export find_inline_attr;
export require_unique_names;
@ -322,19 +322,19 @@ fn find_linkage_metas(attrs: [ast::attribute]/~) -> [@ast::meta_item]/~ {
}
}
fn native_abi(attrs: [ast::attribute]/~) -> either<str, ast::native_abi> {
fn foreign_abi(attrs: [ast::attribute]/~) -> either<str, ast::foreign_abi> {
ret alt attr::first_attr_value_str_by_name(attrs, "abi") {
option::none {
either::right(ast::native_abi_cdecl)
either::right(ast::foreign_abi_cdecl)
}
option::some(@"rust-intrinsic") {
either::right(ast::native_abi_rust_intrinsic)
either::right(ast::foreign_abi_rust_intrinsic)
}
option::some(@"cdecl") {
either::right(ast::native_abi_cdecl)
either::right(ast::foreign_abi_cdecl)
}
option::some(@"stdcall") {
either::right(ast::native_abi_stdcall)
either::right(ast::foreign_abi_stdcall)
}
option::some(t) {
either::left("unsupported abi: " + *t)

View File

@ -129,7 +129,7 @@ fn expand_item(cx: ext_ctxt, &&it: @ast::item, fld: ast_fold,
-> @ast::item
{
let is_mod = alt it.node {
ast::item_mod(_) | ast::item_native_mod(_) {true}
ast::item_mod(_) | ast::item_foreign_mod(_) {true}
_ {false}
};
if is_mod { cx.mod_push(it.ident); }

View File

@ -21,7 +21,7 @@ iface ast_fold {
fn fold_crate(crate) -> crate;
fn fold_crate_directive(&&@crate_directive) -> @crate_directive;
fn fold_view_item(&&@view_item) -> @view_item;
fn fold_native_item(&&@native_item) -> @native_item;
fn fold_foreign_item(&&@foreign_item) -> @foreign_item;
fn fold_item(&&@item) -> @item;
fn fold_class_item(&&@class_member) -> @class_member;
fn fold_item_underscore(item_) -> item_;
@ -36,7 +36,7 @@ iface ast_fold {
fn fold_constr(&&@constr) -> @constr;
fn fold_ty_constr(&&@ty_constr) -> @ty_constr;
fn fold_mod(_mod) -> _mod;
fn fold_native_mod(native_mod) -> native_mod;
fn fold_foreign_mod(foreign_mod) -> foreign_mod;
fn fold_variant(variant) -> variant;
fn fold_ident(&&ident) -> ident;
fn fold_path(&&@path) -> @path;
@ -54,7 +54,7 @@ type ast_fold_precursor = @{
fold_crate_directive: fn@(crate_directive_, span,
ast_fold) -> (crate_directive_, span),
fold_view_item: fn@(view_item_, ast_fold) -> view_item_,
fold_native_item: fn@(&&@native_item, ast_fold) -> @native_item,
fold_foreign_item: fn@(&&@foreign_item, ast_fold) -> @foreign_item,
fold_item: fn@(&&@item, ast_fold) -> @item,
fold_class_item: fn@(&&@class_member, ast_fold) -> @class_member,
fold_item_underscore: fn@(item_, ast_fold) -> item_,
@ -70,7 +70,7 @@ type ast_fold_precursor = @{
fold_ty_constr: fn@(ast::ty_constr_, span, ast_fold)
-> (ty_constr_, span),
fold_mod: fn@(_mod, ast_fold) -> _mod,
fold_native_mod: fn@(native_mod, ast_fold) -> native_mod,
fold_foreign_mod: fn@(foreign_mod, ast_fold) -> foreign_mod,
fold_variant: fn@(variant_, span, ast_fold) -> (variant_, span),
fold_ident: fn@(&&ident, ast_fold) -> ident,
fold_path: fn@(path, ast_fold) -> path,
@ -105,7 +105,7 @@ fn fold_attribute_(at: attribute, fld: ast_fold) ->
value: *fold_meta_item_(@at.node.value, fld)},
span: fld.new_span(at.span)};
}
//used in noop_fold_native_item and noop_fold_fn_decl
//used in noop_fold_foreign_item and noop_fold_fn_decl
fn fold_arg_(a: arg, fld: ast_fold) -> arg {
ret {mode: a.mode,
ty: fld.fold_ty(a.ty),
@ -186,7 +186,8 @@ fn noop_fold_view_item(vi: view_item_, _fld: ast_fold) -> view_item_ {
}
fn noop_fold_native_item(&&ni: @native_item, fld: ast_fold) -> @native_item {
fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold)
-> @foreign_item {
let fold_arg = {|x|fold_arg_(x, fld)};
let fold_attribute = {|x|fold_attribute_(x, fld)};
@ -194,8 +195,8 @@ fn noop_fold_native_item(&&ni: @native_item, fld: ast_fold) -> @native_item {
attrs: vec::map(ni.attrs, fold_attribute),
node:
alt ni.node {
native_item_fn(fdec, typms) {
native_item_fn({inputs: vec::map(fdec.inputs, fold_arg),
foreign_item_fn(fdec, typms) {
foreign_item_fn({inputs: vec::map(fdec.inputs, fold_arg),
output: fld.fold_ty(fdec.output),
purity: fdec.purity,
cf: fdec.cf,
@ -241,7 +242,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
fld.fold_block(body))
}
item_mod(m) { item_mod(fld.fold_mod(m)) }
item_native_mod(nm) { item_native_mod(fld.fold_native_mod(nm)) }
item_foreign_mod(nm) { item_foreign_mod(fld.fold_foreign_mod(nm)) }
item_ty(t, typms, rp) { item_ty(fld.fold_ty(t),
fold_ty_params(typms, fld),
rp) }
@ -517,9 +518,9 @@ fn noop_fold_mod(m: _mod, fld: ast_fold) -> _mod {
items: vec::map(m.items, fld.fold_item)};
}
fn noop_fold_native_mod(nm: native_mod, fld: ast_fold) -> native_mod {
fn noop_fold_foreign_mod(nm: foreign_mod, fld: ast_fold) -> foreign_mod {
ret {view_items: vec::map(nm.view_items, fld.fold_view_item),
items: vec::map(nm.items, fld.fold_native_item)}
items: vec::map(nm.items, fld.fold_foreign_item)}
}
fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
@ -583,7 +584,7 @@ fn default_ast_fold() -> ast_fold_precursor {
ret @{fold_crate: wrap(noop_fold_crate),
fold_crate_directive: wrap(noop_fold_crate_directive),
fold_view_item: noop_fold_view_item,
fold_native_item: noop_fold_native_item,
fold_foreign_item: noop_fold_foreign_item,
fold_item: noop_fold_item,
fold_class_item: noop_fold_class_item,
fold_item_underscore: noop_fold_item_underscore,
@ -598,7 +599,7 @@ fn default_ast_fold() -> ast_fold_precursor {
fold_constr: wrap(noop_fold_constr),
fold_ty_constr: wrap(noop_fold_ty_constr),
fold_mod: noop_fold_mod,
fold_native_mod: noop_fold_native_mod,
fold_foreign_mod: noop_fold_foreign_mod,
fold_variant: wrap(noop_fold_variant),
fold_ident: noop_fold_ident,
fold_path: noop_fold_path,
@ -628,9 +629,9 @@ impl of ast_fold for ast_fold_precursor {
vis: x.vis,
span: self.new_span(x.span)};
}
fn fold_native_item(&&x: @native_item)
-> @native_item {
ret self.fold_native_item(x, self as ast_fold);
fn fold_foreign_item(&&x: @foreign_item)
-> @foreign_item {
ret self.fold_foreign_item(x, self as ast_fold);
}
fn fold_item(&&i: @item) -> @item {
ret self.fold_item(i, self as ast_fold);
@ -699,9 +700,9 @@ impl of ast_fold for ast_fold_precursor {
fn fold_mod(x: _mod) -> _mod {
ret self.fold_mod(x, self as ast_fold);
}
fn fold_native_mod(x: native_mod) ->
native_mod {
ret self.fold_native_mod(x, self as ast_fold);
fn fold_foreign_mod(x: foreign_mod) ->
foreign_mod {
ret self.fold_foreign_mod(x, self as ast_fold);
}
fn fold_variant(x: variant) ->
variant {

View File

@ -147,7 +147,8 @@ class parser {
fn get_id() -> node_id { next_node_id(self.sess) }
fn parse_ty_fn(purity: ast::purity) -> ty_ {
let proto = if self.eat_keyword("native") {
let proto = if self.eat_keyword("native") ||
self.eat_keyword("extern") {
self.expect_keyword("fn");
ast::proto_bare
} else {
@ -413,7 +414,8 @@ class parser {
self.parse_ty_fn(ast::unsafe_fn)
} else if self.is_keyword("fn") {
self.parse_ty_fn(ast::impure_fn)
} else if self.eat_keyword("native") {
} else if self.eat_keyword("native") ||
self.eat_keyword("extern") {
self.expect_keyword("fn");
ty_fn(proto_bare, self.parse_ty_fn_decl(ast::impure_fn))
} else if self.token == token::MOD_SEP || is_ident(self.token) {
@ -2165,8 +2167,8 @@ class parser {
(id, item_mod(m), some(inner_attrs.inner))
}
fn parse_item_native_fn(+attrs: [attribute]/~,
purity: purity) -> @native_item {
fn parse_item_foreign_fn(+attrs: [attribute]/~,
purity: purity) -> @foreign_item {
let lo = self.last_span.lo;
let t = self.parse_fn_header();
let (decl, _) = self.parse_fn_decl(purity, {|p| p.parse_arg()});
@ -2174,7 +2176,7 @@ class parser {
self.expect(token::SEMI);
ret @{ident: t.ident,
attrs: attrs,
node: native_item_fn(decl, t.tps),
node: foreign_item_fn(decl, t.tps),
id: self.get_id(),
span: mk_sp(lo, hi)};
}
@ -2191,35 +2193,35 @@ class parser {
else { self.unexpected(); }
}
fn parse_native_item(+attrs: [attribute]/~) ->
@native_item {
self.parse_item_native_fn(attrs, self.parse_fn_purity())
fn parse_foreign_item(+attrs: [attribute]/~) ->
@foreign_item {
self.parse_item_foreign_fn(attrs, self.parse_fn_purity())
}
fn parse_native_mod_items(+first_item_attrs: [attribute]/~) ->
native_mod {
fn parse_foreign_mod_items(+first_item_attrs: [attribute]/~) ->
foreign_mod {
// Shouldn't be any view items since we've already parsed an item attr
let {attrs_remaining, view_items} =
self.parse_view(first_item_attrs, false);
let mut items: [@native_item]/~ = []/~;
let mut items: [@foreign_item]/~ = []/~;
let mut initial_attrs = attrs_remaining;
while self.token != token::RBRACE {
let attrs = initial_attrs + self.parse_outer_attributes();
initial_attrs = []/~;
vec::push(items, self.parse_native_item(attrs));
vec::push(items, self.parse_foreign_item(attrs));
}
ret {view_items: view_items,
items: items};
}
fn parse_item_native_mod() -> item_info {
fn parse_item_foreign_mod() -> item_info {
self.expect_keyword("mod");
let id = self.parse_ident();
self.expect(token::LBRACE);
let more_attrs = self.parse_inner_attrs_and_next();
let m = self.parse_native_mod_items(more_attrs.next);
let m = self.parse_foreign_mod_items(more_attrs.next);
self.expect(token::RBRACE);
(id, item_native_mod(m), some(more_attrs.inner))
(id, item_foreign_mod(m), some(more_attrs.inner))
}
fn parse_type_decl() -> {lo: uint, ident: ident} {
@ -2355,13 +2357,19 @@ class parser {
self.bump();
self.expect_keyword("fn");
self.parse_item_fn(unsafe_fn)
} else if self.eat_keyword("extern") {
if self.eat_keyword("fn") {
self.parse_item_fn(extern_fn)
} else {
self.parse_item_foreign_mod()
}
} else if self.eat_keyword("crust") {
self.expect_keyword("fn");
self.parse_item_fn(crust_fn)
self.parse_item_fn(extern_fn)
} else if self.eat_keyword("mod") {
self.parse_item_mod()
} else if self.eat_keyword("native") {
self.parse_item_native_mod()
self.parse_item_foreign_mod()
} else if self.eat_keyword("type") {
self.parse_item_type()
} else if self.eat_keyword("enum") {

View File

@ -288,7 +288,7 @@ fn restricted_keyword_table() -> hashmap<str, ()> {
"be", "break",
"check", "claim", "class", "const", "cont", "copy", "crust",
"do", "drop",
"else", "enum", "export",
"else", "enum", "export", "extern",
"fail", "false", "fn", "for",
"if", "iface", "impl", "import",
"let", "log", "loop",

View File

@ -297,12 +297,13 @@ fn print_mod(s: ps, _mod: ast::_mod, attrs: [ast::attribute]/~) {
for _mod.items.each {|item| print_item(s, item); }
}
fn print_native_mod(s: ps, nmod: ast::native_mod, attrs: [ast::attribute]/~) {
fn print_foreign_mod(s: ps, nmod: ast::foreign_mod,
attrs: [ast::attribute]/~) {
print_inner_attributes(s, attrs);
for nmod.view_items.each {|vitem|
print_view_item(s, vitem);
}
for nmod.items.each {|item| print_native_item(s, item); }
for nmod.items.each {|item| print_foreign_item(s, item); }
}
fn print_region(s: ps, region: @ast::region) {
@ -388,12 +389,12 @@ fn print_type_ex(s: ps, &&ty: @ast::ty, print_colons: bool) {
end(s);
}
fn print_native_item(s: ps, item: @ast::native_item) {
fn print_foreign_item(s: ps, item: @ast::foreign_item) {
hardbreak_if_not_bol(s);
maybe_print_comment(s, item.span.lo);
print_outer_attributes(s, item.attrs);
alt item.node {
ast::native_item_fn(decl, typarams) {
ast::foreign_item_fn(decl, typarams) {
print_fn(s, decl, item.ident, typarams);
end(s); // end head-ibox
word(s.s, ";");
@ -434,12 +435,12 @@ fn print_item(s: ps, &&item: @ast::item) {
print_mod(s, _mod, item.attrs);
bclose(s, item.span);
}
ast::item_native_mod(nmod) {
head(s, "native");
ast::item_foreign_mod(nmod) {
head(s, "extern");
word_nbsp(s, "mod");
word_nbsp(s, *item.ident);
bopen(s);
print_native_mod(s, nmod, item.attrs);
print_foreign_mod(s, nmod, item.attrs);
bclose(s, item.span);
}
ast::item_ty(ty, params, rp) {
@ -1753,7 +1754,7 @@ fn purity_to_str(p: ast::purity) -> str {
ast::impure_fn {"impure"}
ast::unsafe_fn {"unsafe"}
ast::pure_fn {"pure"}
ast::crust_fn {"crust"}
ast::extern_fn {"extern"}
}
}
@ -1766,7 +1767,7 @@ fn print_purity(s: ps, p: ast::purity) {
fn proto_to_str(p: ast::proto) -> str {
ret alt p {
ast::proto_bare { "native fn" }
ast::proto_bare { "extern fn" }
ast::proto_any { "fn" }
ast::proto_block { "fn&" }
ast::proto_uniq { "fn~" }

View File

@ -48,7 +48,7 @@ type visitor<E> =
// generic over constr and ty_constr
@{visit_mod: fn@(_mod, span, node_id, E, vt<E>),
visit_view_item: fn@(@view_item, E, vt<E>),
visit_native_item: fn@(@native_item, E, vt<E>),
visit_foreign_item: fn@(@foreign_item, E, vt<E>),
visit_item: fn@(@item, E, vt<E>),
visit_local: fn@(@local, E, vt<E>),
visit_block: fn@(ast::blk, E, vt<E>),
@ -66,7 +66,7 @@ type visitor<E> =
fn default_visitor<E>() -> visitor<E> {
ret @{visit_mod: {|a,b,c,d,e|visit_mod::<E>(a, b, c, d, e)},
visit_view_item: {|a,b,c|visit_view_item::<E>(a, b, c)},
visit_native_item: {|a,b,c|visit_native_item::<E>(a, b, c)},
visit_foreign_item: {|a,b,c|visit_foreign_item::<E>(a, b, c)},
visit_item: {|a,b,c|visit_item::<E>(a, b, c)},
visit_local: {|a,b,c|visit_local::<E>(a, b, c)},
visit_block: {|a,b,c|visit_block::<E>(a, b, c)},
@ -121,9 +121,9 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
i.span, i.id, e, v);
}
item_mod(m) { v.visit_mod(m, i.span, i.id, e, v); }
item_native_mod(nm) {
item_foreign_mod(nm) {
for nm.view_items.each {|vi| v.visit_view_item(vi, e, v); }
for nm.items.each {|ni| v.visit_native_item(ni, e, v); }
for nm.items.each {|ni| v.visit_foreign_item(ni, e, v); }
}
item_ty(t, tps, rp) {
v.visit_ty(t, e, v);
@ -247,9 +247,9 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
}
}
fn visit_native_item<E>(ni: @native_item, e: E, v: vt<E>) {
fn visit_foreign_item<E>(ni: @foreign_item, e: E, v: vt<E>) {
alt ni.node {
native_item_fn(fd, tps) {
foreign_item_fn(fd, tps) {
v.visit_ty_params(tps, e, v);
visit_fn_decl(fd, e, v);
}
@ -444,7 +444,7 @@ type simple_visitor =
// generic over constr and ty_constr
@{visit_mod: fn@(_mod, span, node_id),
visit_view_item: fn@(@view_item),
visit_native_item: fn@(@native_item),
visit_foreign_item: fn@(@foreign_item),
visit_item: fn@(@item),
visit_local: fn@(@local),
visit_block: fn@(ast::blk),
@ -464,7 +464,7 @@ fn simple_ignore_ty(_t: @ty) {}
fn default_simple_visitor() -> simple_visitor {
ret @{visit_mod: fn@(_m: _mod, _sp: span, _id: node_id) { },
visit_view_item: fn@(_vi: @view_item) { },
visit_native_item: fn@(_ni: @native_item) { },
visit_foreign_item: fn@(_ni: @foreign_item) { },
visit_item: fn@(_i: @item) { },
visit_local: fn@(_l: @local) { },
visit_block: fn@(_b: ast::blk) { },
@ -492,10 +492,10 @@ fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
f(vi);
visit_view_item(vi, e, v);
}
fn v_native_item(f: fn@(@native_item), ni: @native_item, &&e: (),
fn v_foreign_item(f: fn@(@foreign_item), ni: @foreign_item, &&e: (),
v: vt<()>) {
f(ni);
visit_native_item(ni, e, v);
visit_foreign_item(ni, e, v);
}
fn v_item(f: fn@(@item), i: @item, &&e: (), v: vt<()>) {
f(i);
@ -565,8 +565,8 @@ fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
visit_view_item: {|a,b,c|
v_view_item(v.visit_view_item, a, b, c)
},
visit_native_item:
{|a,b,c|v_native_item(v.visit_native_item, a, b, c)},
visit_foreign_item:
{|a,b,c|v_foreign_item(v.visit_foreign_item, a, b, c)},
visit_item: {|a,b,c|v_item(v.visit_item, a, b, c)},
visit_local: {|a,b,c|v_local(v.visit_local, a, b, c)},
visit_block: {|a,b,c|v_block(v.visit_block, a, b, c)},

View File

@ -26,7 +26,7 @@ fn strip_items(crate: @ast::crate, in_cfg: in_cfg_pred)
let precursor =
@{fold_mod: {|a,b|fold_mod(ctxt, a, b)},
fold_block: fold::wrap({|a,b|fold_block(ctxt, a, b)}),
fold_native_mod: {|a,b|fold_native_mod(ctxt, a, b)}
fold_foreign_mod: {|a,b|fold_foreign_mod(ctxt, a, b)}
with *fold::default_ast_fold()};
let fold = fold::make_fold(precursor);
@ -47,16 +47,16 @@ fn fold_mod(cx: ctxt, m: ast::_mod, fld: fold::ast_fold) ->
items: vec::map(filtered_items, fld.fold_item)};
}
fn filter_native_item(cx: ctxt, &&item: @ast::native_item) ->
option<@ast::native_item> {
if native_item_in_cfg(cx, item) {
fn filter_foreign_item(cx: ctxt, &&item: @ast::foreign_item) ->
option<@ast::foreign_item> {
if foreign_item_in_cfg(cx, item) {
option::some(item)
} else { option::none }
}
fn fold_native_mod(cx: ctxt, nm: ast::native_mod,
fld: fold::ast_fold) -> ast::native_mod {
let filter = {|a|filter_native_item(cx, a)};
fn fold_foreign_mod(cx: ctxt, nm: ast::foreign_mod,
fld: fold::ast_fold) -> ast::foreign_mod {
let filter = {|a|filter_foreign_item(cx, a)};
let filtered_items = vec::filter_map(nm.items, filter);
ret {view_items: vec::map(nm.view_items, fld.fold_view_item),
items: filtered_items};
@ -94,7 +94,7 @@ fn item_in_cfg(cx: ctxt, item: @ast::item) -> bool {
ret cx.in_cfg(item.attrs);
}
fn native_item_in_cfg(cx: ctxt, item: @ast::native_item) -> bool {
fn foreign_item_in_cfg(cx: ctxt, item: @ast::foreign_item) -> bool {
ret cx.in_cfg(item.attrs);
}

View File

@ -241,8 +241,8 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
ast::ii_method(d, m) {
ast::ii_method(d, fld.fold_method(m))
}
ast::ii_native(i) {
ast::ii_native(fld.fold_native_item(i))
ast::ii_foreign(i) {
ast::ii_foreign(fld.fold_foreign_item(i))
}
ast::ii_ctor(ctor, nm, tps, parent_id) {
let ctor_body = fld.fold_block(ctor.node.body);
@ -275,8 +275,8 @@ fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item)
ast::ii_method(d, m) {
ast::ii_method(xcx.tr_def_id(d), fld.fold_method(m))
}
ast::ii_native(i) {
ast::ii_native(fld.fold_native_item(i))
ast::ii_foreign(i) {
ast::ii_foreign(fld.fold_foreign_item(i))
}
ast::ii_ctor(ctor, nm, tps, parent_id) {
let ctor_body = fld.fold_block(ctor.node.body);
@ -310,7 +310,7 @@ impl of tr for ast::def {
ast::def_fn(did, p) { ast::def_fn(did.tr(xcx), p) }
ast::def_self(nid) { ast::def_self(xcx.tr_id(nid)) }
ast::def_mod(did) { ast::def_mod(did.tr(xcx)) }
ast::def_native_mod(did) { ast::def_native_mod(did.tr(xcx)) }
ast::def_foreign_mod(did) { ast::def_foreign_mod(did.tr(xcx)) }
ast::def_const(did) { ast::def_const(did.tr(xcx)) }
ast::def_arg(nid, m) { ast::def_arg(xcx.tr_id(nid), m) }
ast::def_local(nid, b) { ast::def_local(xcx.tr_id(nid), b) }

View File

@ -116,17 +116,17 @@ fn visit_view_item(e: env, i: @ast::view_item) {
fn visit_item(e: env, i: @ast::item) {
alt i.node {
ast::item_native_mod(m) {
alt attr::native_abi(i.attrs) {
ast::item_foreign_mod(m) {
alt attr::foreign_abi(i.attrs) {
either::right(abi) {
if abi != ast::native_abi_cdecl &&
abi != ast::native_abi_stdcall { ret; }
if abi != ast::foreign_abi_cdecl &&
abi != ast::foreign_abi_stdcall { ret; }
}
either::left(msg) { e.diag.span_fatal(i.span, msg); }
}
let cstore = e.cstore;
let native_name =
let foreign_name =
alt attr::first_attr_value_str_by_name(i.attrs, "link_name") {
some(nn) {
if *nn == "" {
@ -140,11 +140,11 @@ fn visit_item(e: env, i: @ast::item) {
};
let mut already_added = false;
if vec::len(attr::find_attrs_by_name(i.attrs, "nolink")) == 0u {
already_added = !cstore::add_used_library(cstore, *native_name);
already_added = !cstore::add_used_library(cstore, *foreign_name);
}
let link_args = attr::find_attrs_by_name(i.attrs, "link_args");
if vec::len(link_args) > 0u && already_added {
e.diag.span_fatal(i.span, "library '" + *native_name +
e.diag.span_fatal(i.span, "library '" + *foreign_name +
"' already added: can't specify link_args.");
}
for link_args.each {|a|

View File

@ -271,7 +271,7 @@ fn lookup_def(cnum: ast::crate_num, data: @[u8]/~, did_: ast::def_id) ->
'y' { ast::def_ty(did) }
't' { ast::def_ty(did) }
'm' { ast::def_mod(did) }
'n' { ast::def_native_mod(did) }
'n' { ast::def_foreign_mod(did) }
'v' {
let mut tid = option::get(item_parent_item(item));
tid = {crate: cnum, node: tid.node};

View File

@ -126,8 +126,8 @@ fn add_to_index(ebml_w: ebml::writer, path: [ident]/~, &index: [entry<str>]/~,
pos: ebml_w.writer.tell()});
}
fn encode_native_module_item_paths(ebml_w: ebml::writer, nmod: native_mod,
path: [ident]/~, &index: [entry<str>]/~) {
fn encode_foreign_module_item_paths(ebml_w: ebml::writer, nmod: foreign_mod,
path: [ident]/~, &index: [entry<str>]/~) {
for nmod.items.each {|nitem|
add_to_index(ebml_w, path, index, nitem.ident);
encode_named_def_id(ebml_w, nitem.ident, local_def(nitem.id));
@ -175,10 +175,10 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
index);
}
}
item_native_mod(nmod) {
item_foreign_mod(nmod) {
ebml_w.wr_tag(tag_paths_data_mod) {||
encode_name_and_def_id(ebml_w, it.ident, it.id);
encode_native_module_item_paths(ebml_w, nmod,
encode_foreign_module_item_paths(ebml_w, nmod,
path + [it.ident]/~, index);
}
}
@ -517,7 +517,7 @@ fn purity_fn_family(p: purity) -> char {
unsafe_fn { 'u' }
pure_fn { 'p' }
impure_fn { 'f' }
crust_fn { 'c' }
extern_fn { 'c' }
}
}
@ -574,7 +574,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
add_to_index();
encode_info_for_mod(ecx, ebml_w, m, item.id, path, item.ident);
}
item_native_mod(_) {
item_foreign_mod(_) {
add_to_index();
ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, local_def(item.id));
@ -741,23 +741,23 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
}
}
fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
nitem: @native_item,
index: @mut [entry<int>]/~,
path: ast_map::path, abi: native_abi) {
fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
nitem: @foreign_item,
index: @mut [entry<int>]/~,
path: ast_map::path, abi: foreign_abi) {
if !reachable(ecx, nitem.id) { ret; }
vec::push(*index, {val: nitem.id, pos: ebml_w.writer.tell()});
ebml_w.start_tag(tag_items_data_item);
alt nitem.node {
native_item_fn(fn_decl, tps) {
foreign_item_fn(fn_decl, tps) {
encode_def_id(ebml_w, local_def(nitem.id));
encode_family(ebml_w, purity_fn_family(fn_decl.purity));
encode_type_param_bounds(ebml_w, ecx, tps);
encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, nitem.id));
if abi == native_abi_rust_intrinsic {
if abi == foreign_abi_rust_intrinsic {
ecx.encode_inlined_item(ecx, ebml_w, path,
ii_native(nitem));
ii_foreign(nitem));
} else {
encode_symbol(ecx, ebml_w, nitem.id);
}
@ -799,11 +799,12 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
}
}
},
visit_native_item: {|ni, cx, v, copy ebml_w|
visit::visit_native_item(ni, cx, v);
visit_foreign_item: {|ni, cx, v, copy ebml_w|
visit::visit_foreign_item(ni, cx, v);
alt check ecx.tcx.items.get(ni.id) {
ast_map::node_native_item(_, abi, pt) {
encode_info_for_native_item(ecx, ebml_w, ni, index, *pt, abi);
ast_map::node_foreign_item(_, abi, pt) {
encode_info_for_foreign_item(ecx, ebml_w, ni,
index, *pt, abi);
}
}
}

View File

@ -438,7 +438,7 @@ fn parse_purity(c: char) -> purity {
'u' {unsafe_fn}
'p' {pure_fn}
'i' {impure_fn}
'c' {crust_fn}
'c' {extern_fn}
}
}

View File

@ -333,7 +333,7 @@ fn enc_purity(w: io::writer, p: purity) {
pure_fn { w.write_char('p'); }
impure_fn { w.write_char('i'); }
unsafe_fn { w.write_char('u'); }
crust_fn { w.write_char('c'); }
extern_fn { w.write_char('c'); }
}
}

View File

@ -250,8 +250,8 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
ast::ii_method(d, m) {
ast::ii_method(d, fld.fold_method(m))
}
ast::ii_native(i) {
ast::ii_native(fld.fold_native_item(i))
ast::ii_foreign(i) {
ast::ii_foreign(fld.fold_foreign_item(i))
}
ast::ii_ctor(ctor, nm, tps, parent_id) {
let ctor_body = fld.fold_block(ctor.node.body);
@ -290,8 +290,8 @@ fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item)
ast::ii_method(d, m) {
ast::ii_method(xcx.tr_def_id(d), fld.fold_method(m))
}
ast::ii_native(i) {
ast::ii_native(fld.fold_native_item(i))
ast::ii_foreign(i) {
ast::ii_foreign(fld.fold_foreign_item(i))
}
ast::ii_ctor(ctor, nm, tps, parent_id) {
let ctor_body = fld.fold_block(ctor.node.body);
@ -335,7 +335,7 @@ impl of tr for ast::def {
ast::def_fn(did, p) { ast::def_fn(did.tr(xcx), p) }
ast::def_self(nid) { ast::def_self(xcx.tr_id(nid)) }
ast::def_mod(did) { ast::def_mod(did.tr(xcx)) }
ast::def_native_mod(did) { ast::def_native_mod(did.tr(xcx)) }
ast::def_foreign_mod(did) { ast::def_foreign_mod(did.tr(xcx)) }
ast::def_const(did) { ast::def_const(did.tr(xcx)) }
ast::def_arg(nid, m) { ast::def_arg(xcx.tr_id(nid), m) }
ast::def_local(nid, b) { ast::def_local(xcx.tr_id(nid), b) }

View File

@ -189,7 +189,7 @@ impl public_methods for borrowck_ctxt {
def: ast::def) -> cmt {
alt def {
ast::def_fn(_, _) | ast::def_mod(_) |
ast::def_native_mod(_) | ast::def_const(_) |
ast::def_foreign_mod(_) | ast::def_const(_) |
ast::def_use(_) | ast::def_variant(_, _) |
ast::def_ty(_) | ast::def_prim_ty(_) |
ast::def_ty_param(_, _) | ast::def_class(_) |

View File

@ -91,7 +91,7 @@ impl methods for check_loan_ctxt {
// default, but we must scan for requirements
// imposed by the borrow check
ast::pure_fn { some(pc_pure_fn) }
ast::crust_fn | ast::impure_fn { none }
ast::extern_fn | ast::impure_fn { none }
};
// scan to see if this scope or any enclosing scope requires
@ -199,7 +199,7 @@ impl methods for check_loan_ctxt {
ty::ty_fn(fn_ty) {
alt fn_ty.purity {
ast::pure_fn { ret; } // case (c) above
ast::impure_fn | ast::unsafe_fn | ast::crust_fn {
ast::impure_fn | ast::unsafe_fn | ast::extern_fn {
self.report_purity_error(
pc, callee_span,
#fmt["access to %s function",

View File

@ -355,7 +355,7 @@ fn check_item_while_true(cx: ty::ctxt, it: @ast::item) {
fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
fn check_native_fn(cx: ty::ctxt, fn_id: ast::node_id,
fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id,
decl: ast::fn_decl) {
let tys = vec::map(decl.inputs) {|a| a.ty };
for vec::each(tys + [decl.output]/~) {|ty|
@ -385,12 +385,12 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
}
alt it.node {
ast::item_native_mod(nmod) if attr::native_abi(it.attrs) !=
either::right(ast::native_abi_rust_intrinsic) {
ast::item_foreign_mod(nmod) if attr::foreign_abi(it.attrs) !=
either::right(ast::foreign_abi_rust_intrinsic) {
for nmod.items.each {|ni|
alt ni.node {
ast::native_item_fn(decl, tps) {
check_native_fn(cx, it.id, decl);
ast::foreign_item_fn(decl, tps) {
check_foreign_fn(cx, it.id, decl);
}
}
}

View File

@ -36,7 +36,7 @@ enum scope {
scope_item(@ast::item),
scope_bare_fn(ast::fn_decl, node_id, [ast::ty_param]/~),
scope_fn_expr(ast::fn_decl, node_id, [ast::ty_param]/~),
scope_native_item(@ast::native_item),
scope_foreign_item(@ast::foreign_item),
scope_loop(@ast::local), // there's only 1 decl per loop.
scope_block(ast::blk, @mut uint, @mut uint),
scope_arm(ast::arm),
@ -86,7 +86,7 @@ enum mod_index_entry {
mie_view_item(ident, node_id, span),
mie_import_ident(node_id, span),
mie_item(@ast::item),
mie_native_item(@ast::native_item),
mie_foreign_item(@ast::foreign_item),
mie_enum_variant(/* variant index */uint,
/*parts of enum item*/ [variant]/~,
node_id, span),
@ -275,7 +275,7 @@ fn map_crate(e: @env, c: @ast::crate) {
glob_imported_names: box_str_hash(),
path: path_from_scope(sc, *i.ident)});
}
ast::item_native_mod(nmd) {
ast::item_foreign_mod(nmd) {
e.mod_map.insert(i.id,
@{m: none::<ast::_mod>,
index: index_nmod(nmd),
@ -413,7 +413,7 @@ fn resolve_iface_ref(p: @iface_ref, sc: scopes, e: @env) {
fn resolve_names(e: @env, c: @ast::crate) {
e.used_imports.track = true;
let v =
@{visit_native_item: visit_native_item_with_scope,
@{visit_foreign_item: visit_foreign_item_with_scope,
visit_item: {|a,b,c|walk_item(e, a, b, c)},
visit_block: visit_block_with_scope,
visit_decl: visit_decl_with_scope,
@ -615,9 +615,9 @@ fn visit_item_with_scope(e: @env, i: @ast::item,
e.resolve_unexported = old_resolve_unexported;
}
fn visit_native_item_with_scope(ni: @ast::native_item, &&sc: scopes,
fn visit_foreign_item_with_scope(ni: @ast::foreign_item, &&sc: scopes,
v: vt<scopes>) {
visit::visit_native_item(ni, @cons(scope_native_item(ni), sc), v);
visit::visit_foreign_item(ni, @cons(scope_foreign_item(ni), sc), v);
}
fn visit_fn_with_scope(e: @env, fk: visit::fn_kind, decl: ast::fn_decl,
@ -733,7 +733,7 @@ fn follow_import(e: env, &&sc: scopes, path: [ident]/~, sp: span) ->
}
if i == path_len {
alt dcur {
some(ast::def_mod(_)) | some(ast::def_native_mod(_)) { ret dcur; }
some(ast::def_mod(_)) | some(ast::def_foreign_mod(_)) { ret dcur; }
_ {
e.sess.span_err(sp, str::connect(path.map({|x|*x}), "::") +
" does not name a module.");
@ -799,7 +799,7 @@ fn resolve_import(e: env, n_id: node_id, name: ast::ident,
cons(scope_item(@{node: item_mod(m), _}), _) {
lst(id, m.view_items)
}
cons(scope_item(@{node: item_native_mod(m), _}), _) {
cons(scope_item(@{node: item_foreign_mod(m), _}), _) {
lst(id, m.view_items)
}
cons(scope_block(b, _, _), _) {
@ -969,7 +969,7 @@ fn lookup_in_scope_strict(e: env, &&sc: scopes, sp: span, name: ident,
fn scope_is_fn(sc: scope) -> bool {
ret alt sc {
scope_bare_fn(_, _, _) | scope_native_item(_) { true }
scope_bare_fn(_, _, _) | scope_foreign_item(_) { true }
_ { false }
};
}
@ -1055,8 +1055,8 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace,
ast::item_mod(_) {
ret lookup_in_local_mod(e, it.id, sp, name, ns, inside);
}
ast::item_native_mod(m) {
ret lookup_in_local_native_mod(e, it.id, sp, name, ns);
ast::item_foreign_mod(m) {
ret lookup_in_local_foreign_mod(e, it.id, sp, name, ns);
}
ast::item_class(tps, _, members, ctor, _, _) {
if ns == ns_type {
@ -1077,9 +1077,9 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace,
ret lookup_in_ty_params(e, name, tps);
}
}
scope_native_item(it) {
scope_foreign_item(it) {
alt check it.node {
ast::native_item_fn(decl, ty_params) {
ast::foreign_item_fn(decl, ty_params) {
ret lookup_in_fn(e, name, decl, ty_params, ns);
}
}
@ -1327,8 +1327,10 @@ fn found_def_item(i: @ast::item, ns: namespace) -> option<def> {
ast::item_mod(_) {
if ns == ns_module { ret some(ast::def_mod(local_def(i.id))); }
}
ast::item_native_mod(_) {
if ns == ns_module { ret some(ast::def_native_mod(local_def(i.id))); }
ast::item_foreign_mod(_) {
if ns == ns_module {
ret some(ast::def_foreign_mod(local_def(i.id)));
}
}
ast::item_ty(*) | item_iface(*) | item_enum(*) {
if ns == ns_type { ret some(ast::def_ty(local_def(i.id))); }
@ -1384,8 +1386,8 @@ fn lookup_in_mod(e: env, m: def, sp: span, name: ident, ns: namespace,
ast::def_mod(defid) {
ret lookup_in_local_mod(e, defid.node, sp, name, ns, dr);
}
ast::def_native_mod(defid) {
ret lookup_in_local_native_mod(e, defid.node, sp, name, ns);
ast::def_foreign_mod(defid) {
ret lookup_in_local_foreign_mod(e, defid.node, sp, name, ns);
}
_ {
// Precondition
@ -1431,7 +1433,7 @@ fn lookup_import(e: env, n_id: node_id, ns: namespace) -> option<def> {
}
}
fn lookup_in_local_native_mod(e: env, node_id: node_id, sp: span, id: ident,
fn lookup_in_local_foreign_mod(e: env, node_id: node_id, sp: span, id: ident,
ns: namespace) -> option<def> {
ret lookup_in_local_mod(e, node_id, sp, id, ns, inside);
}
@ -1572,11 +1574,11 @@ fn lookup_in_mie(e: env, mie: mod_index_entry, ns: namespace) ->
_ { ret none; }
}
}
mie_native_item(native_item) {
alt native_item.node {
ast::native_item_fn(decl, _) {
mie_foreign_item(foreign_item) {
alt foreign_item.node {
ast::foreign_item_fn(decl, _) {
if ns == ns_val {
ret some(ast::def_fn(local_def(native_item.id),
ret some(ast::def_fn(local_def(foreign_item.id),
decl.purity));
}
}
@ -1634,7 +1636,7 @@ fn index_mod(md: ast::_mod) -> mod_index {
for md.items.each {|it|
alt it.node {
ast::item_const(_, _) | ast::item_fn(_, _, _) | ast::item_mod(_) |
ast::item_native_mod(_) | ast::item_ty(_, _, _) |
ast::item_foreign_mod(_) | ast::item_ty(_, _, _) |
ast::item_impl(*) | ast::item_iface(*) {
add_to_index(index, it.ident, mie_item(it));
}
@ -1658,13 +1660,13 @@ fn index_mod(md: ast::_mod) -> mod_index {
}
fn index_nmod(md: ast::native_mod) -> mod_index {
fn index_nmod(md: ast::foreign_mod) -> mod_index {
let index = box_str_hash::<@list<mod_index_entry>>();
index_view_items(md.view_items, index);
for md.items.each {|it|
add_to_index(index, it.ident, mie_native_item(it));
add_to_index(index, it.ident, mie_foreign_item(it));
}
ret index;
}
@ -1677,7 +1679,7 @@ fn ns_for_def(d: def) -> namespace {
ast::def_fn(_, _) | ast::def_self(_) |
ast::def_const(_) | ast::def_arg(_, _) | ast::def_local(_, _) |
ast::def_upvar(_, _, _) { ns_val }
ast::def_mod(_) | ast::def_native_mod(_) { ns_module }
ast::def_mod(_) | ast::def_foreign_mod(_) { ns_module }
ast::def_ty(_) | ast::def_binding(_) | ast::def_use(_) |
ast::def_ty_param(_, _) | ast::def_prim_ty(_) | ast::def_class(_)
{ ns_type }
@ -1753,7 +1755,7 @@ fn mie_span(mie: mod_index_entry) -> span {
mie_import_ident(_, span) { span }
mie_item(item) { item.span }
mie_enum_variant(_, _, _, span) { span }
mie_native_item(item) { item.span }
mie_foreign_item(item) { item.span }
};
}
@ -1850,7 +1852,7 @@ fn check_block(e: @env, b: ast::blk, &&x: (), v: vt<()>) {
add_name(values, v.span, v.node.name);
}
}
ast::item_mod(_) | ast::item_native_mod(_) {
ast::item_mod(_) | ast::item_foreign_mod(_) {
add_name(mods, it.span, it.ident);
}
ast::item_const(_, _) | ast::item_fn(*) {
@ -2009,7 +2011,7 @@ fn check_exports(e: @env) {
_ { e.sess.span_bug(vi.span, "unresolved export"); }
}
}
mie_item(@{id, _}) | mie_native_item(@{id, _}) |
mie_item(@{id, _}) | mie_foreign_item(@{id, _}) |
mie_enum_variant(_, _, id, _) {
add_export(e, export_id, local_def(id), false);
}

View File

@ -221,18 +221,18 @@ fn get_simple_extern_fn(cx: block,
ret get_extern_fn(externs, llmod, name, lib::llvm::CCallConv, t);
}
fn trans_native_call(cx: block, externs: hashmap<str, ValueRef>,
llmod: ModuleRef, name: str, args: [ValueRef]/~) ->
fn trans_foreign_call(cx: block, externs: hashmap<str, ValueRef>,
llmod: ModuleRef, name: str, args: [ValueRef]/~) ->
ValueRef {
let _icx = cx.insn_ctxt("trans_native_call");
let _icx = cx.insn_ctxt("trans_foreign_call");
let n = args.len() as int;
let llnative: ValueRef =
let llforeign: ValueRef =
get_simple_extern_fn(cx, externs, llmod, name, n);
let mut call_args: [ValueRef]/~ = []/~;
for vec::each(args) {|a|
vec::push(call_args, a);
}
ret Call(cx, llnative, call_args);
ret Call(cx, llforeign, call_args);
}
fn trans_free(cx: block, v: ValueRef) -> block {
@ -2169,10 +2169,10 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id,
ast_map::node_item(i, pt) { (pt, i.ident, i.span) }
ast_map::node_variant(v, enm, pt) { (pt, v.node.name, enm.span) }
ast_map::node_method(m, _, pt) { (pt, m.ident, m.span) }
ast_map::node_native_item(i, ast::native_abi_rust_intrinsic, pt)
ast_map::node_foreign_item(i, ast::foreign_abi_rust_intrinsic, pt)
{ (pt, i.ident, i.span) }
ast_map::node_native_item(_, abi, _) {
// Natives don't have to be monomorphized.
ast_map::node_foreign_item(_, abi, _) {
// Foreign externs don't have to be monomorphized.
ret {val: get_item_val(ccx, fn_id.node),
must_cast: true};
}
@ -2223,9 +2223,9 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id,
ast_map::node_item(*) {
ccx.tcx.sess.bug("Can't monomorphize this kind of item")
}
ast_map::node_native_item(i, _, _) {
ast_map::node_foreign_item(i, _, _) {
let d = mk_lldecl();
native::trans_intrinsic(ccx, d, i, pt, option::get(psubsts),
foreign::trans_intrinsic(ccx, d, i, pt, option::get(psubsts),
ref_id);
d
}
@ -2316,7 +2316,7 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id)
ccx.external.insert(fn_id, some(ctor.node.id));
local_def(ctor.node.id)
}
csearch::found(ast::ii_native(item)) {
csearch::found(ast::ii_foreign(item)) {
ccx.external.insert(fn_id, some(item.id));
local_def(item.id)
}
@ -2406,11 +2406,11 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id,
ccx, node_id_type(bcx, id))));
}
// FIXME: Need to support external crust functions (#1840)
// FIXME: Need to support extern-ABI functions (#1840)
if fn_id.crate == ast::local_crate {
alt bcx.tcx().def_map.find(id) {
some(ast::def_fn(_, ast::crust_fn)) {
// Crust functions are just opaque pointers
some(ast::def_fn(_, ast::extern_fn)) {
// Extern functions are just opaque pointers
let val = PointerCast(bcx, val, T_ptr(T_i8()));
ret lval_no_env(bcx, val, owned_imm);
}
@ -4899,10 +4899,10 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
};
alt item.node {
ast::item_fn(decl, tps, body) {
if decl.purity == ast::crust_fn {
if decl.purity == ast::extern_fn {
let llfndecl = get_item_val(ccx, item.id);
native::trans_crust_fn(ccx, *path + [path_name(item.ident)]/~,
decl, body, llfndecl, item.id);
foreign::trans_extern_fn(ccx, *path + [path_name(item.ident)]/~,
decl, body, llfndecl, item.id);
} else if tps.len() == 0u {
let llfndecl = get_item_val(ccx, item.id);
trans_fn(ccx, *path + [path_name(item.ident)]/~, decl, body,
@ -4941,12 +4941,12 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
}
}
ast::item_const(_, expr) { trans_const(ccx, expr, item.id); }
ast::item_native_mod(native_mod) {
let abi = alt attr::native_abi(item.attrs) {
ast::item_foreign_mod(foreign_mod) {
let abi = alt attr::foreign_abi(item.attrs) {
either::right(abi_) { abi_ }
either::left(msg) { ccx.sess.span_fatal(item.span, msg) }
};
native::trans_native_mod(ccx, native_mod, abi);
foreign::trans_foreign_mod(ccx, foreign_mod, abi);
}
ast::item_class(tps, _ifaces, items, ctor, m_dtor, _) {
if tps.len() == 0u {
@ -5169,10 +5169,10 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
g
}
ast::item_fn(decl, _, _) {
let llfn = if decl.purity != ast::crust_fn {
let llfn = if decl.purity != ast::extern_fn {
register_fn(ccx, i.span, my_path, i.id)
} else {
native::register_crust_fn(ccx, i.span, my_path, i.id)
foreign::register_extern_fn(ccx, i.span, my_path, i.id)
};
set_inline_hint_if_appr(i.attrs, llfn);
llfn
@ -5188,7 +5188,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
set_inline_hint_if_appr(m.attrs, llfn);
llfn
}
ast_map::node_native_item(ni, _, pth) {
ast_map::node_foreign_item(ni, _, pth) {
exprt = true;
register_fn(ccx, ni.span, *pth + [path_name(ni.ident)]/~, ni.id)
}

View File

@ -38,18 +38,28 @@ type tydesc_info =
mut visit_glue: option<ValueRef>};
/*
* A note on nomenclature of linking: "upcall", "extern" and "native".
* A note on nomenclature of linking: "extern", "foreign", and "upcall".
*
* An "extern" is an LLVM symbol we wind up emitting an undefined external
* reference to. This means "we don't have the thing in this compilation unit,
* please make sure you link it in at runtime". This could be a reference to
* C code found in a C library, or rust code found in a rust crate.
*
* A "native" is an extern that references C code. Called with cdecl.
* Most "externs" are implicitly declared (automatically) as a result of a
* user declaring an extern _module_ dependency; this causes the rust driver
* to locate an extern crate, scan its compilation metadata, and emit extern
* declarations for any symbols used by the declaring crate.
*
* An upcall is a native call generated by the compiler (not corresponding to
* any user-written call in the code) into librustrt, to perform some helper
* task such as bringing a task to life, allocating memory, etc.
* A "foreign" is an extern that references C (or other non-rust ABI) code.
* There is no metadata to scan for extern references so in these cases either
* a header-digester like bindgen, or manual function prototypes, have to
* serve as declarators. So these are usually given explicitly as prototype
* declarations, in rust code, with ABI attributes on them noting which ABI to
* link via.
*
* An "upcall" is a foreign call generated by the compiler (not corresponding
* to any user-written call in the code) into the runtime library, to perform
* some helper task such as bringing a task to life, allocating memory, etc.
*
*/

View File

@ -18,7 +18,7 @@ import type_of::*;
import std::map::hashmap;
import util::ppaux::ty_to_str;
export link_name, trans_native_mod, register_crust_fn, trans_crust_fn,
export link_name, trans_foreign_mod, register_extern_fn, trans_extern_fn,
trans_intrinsic;
enum x86_64_reg_class {
@ -419,7 +419,7 @@ fn decl_x86_64_fn(tys: x86_64_tys,
ret llfn;
}
fn link_name(i: @ast::native_item) -> str {
fn link_name(i: @ast::foreign_item) -> str {
alt attr::first_attr_value_str_by_name(i.attrs, "link_name") {
none { ret *i.ident; }
option::some(ln) { ret *ln; }
@ -518,7 +518,7 @@ fn build_wrap_fn_(ccx: @crate_ctxt,
arg_builder: wrap_arg_builder,
ret_builder: wrap_ret_builder) {
let _icx = ccx.insn_ctxt("native::build_wrap_fn_");
let _icx = ccx.insn_ctxt("foreign::build_wrap_fn_");
let fcx = new_fn_ctxt(ccx, []/~, llwrapfn, none);
let bcx = top_scope_block(fcx, none);
let lltop = bcx.llbb;
@ -575,21 +575,21 @@ fn build_wrap_fn_(ccx: @crate_ctxt,
// stack pointer appropriately to avoid a round of copies. (In fact, the shim
// function itself is unnecessary). We used to do this, in fact, and will
// perhaps do so in the future.
fn trans_native_mod(ccx: @crate_ctxt,
native_mod: ast::native_mod, abi: ast::native_abi) {
fn trans_foreign_mod(ccx: @crate_ctxt,
foreign_mod: ast::foreign_mod, abi: ast::foreign_abi) {
let _icx = ccx.insn_ctxt("native::trans_native_mod");
let _icx = ccx.insn_ctxt("foreign::trans_foreign_mod");
fn build_shim_fn(ccx: @crate_ctxt,
native_item: @ast::native_item,
foreign_item: @ast::foreign_item,
tys: @c_stack_tys,
cc: lib::llvm::CallConv) -> ValueRef {
let _icx = ccx.insn_ctxt("native::build_shim_fn");
let _icx = ccx.insn_ctxt("foreign::build_shim_fn");
fn build_args(bcx: block, tys: @c_stack_tys,
llargbundle: ValueRef) -> [ValueRef]/~ {
let _icx = bcx.insn_ctxt("native::shim::build_args");
let _icx = bcx.insn_ctxt("foreign::shim::build_args");
let mut llargvals = []/~;
let mut i = 0u;
let n = vec::len(tys.arg_tys);
@ -635,7 +635,7 @@ fn trans_native_mod(ccx: @crate_ctxt,
fn build_ret(bcx: block, tys: @c_stack_tys,
llargbundle: ValueRef, llretval: ValueRef) {
let _icx = bcx.insn_ctxt("native::shim::build_ret");
let _icx = bcx.insn_ctxt("foreign::shim::build_ret");
alt tys.x86_64_tys {
some(x86_64) {
vec::iteri(x86_64.attrs) {|i, a|
@ -676,7 +676,7 @@ fn trans_native_mod(ccx: @crate_ctxt,
}
}
let lname = link_name(native_item);
let lname = link_name(foreign_item);
let llbasefn = base_fn(ccx, lname, tys, cc);
// Name the shim function
let shim_name = lname + "__c_stack_shim";
@ -703,7 +703,7 @@ fn trans_native_mod(ccx: @crate_ctxt,
// FIXME (#2535): this is very shaky and probably gets ABIs wrong all
// over the place
fn build_direct_fn(ccx: @crate_ctxt, decl: ValueRef,
item: @ast::native_item, tys: @c_stack_tys,
item: @ast::foreign_item, tys: @c_stack_tys,
cc: lib::llvm::CallConv) {
let fcx = new_fn_ctxt(ccx, []/~, decl, none);
let bcx = top_scope_block(fcx, none), lltop = bcx.llbb;
@ -726,11 +726,11 @@ fn trans_native_mod(ccx: @crate_ctxt,
llshimfn: ValueRef,
llwrapfn: ValueRef) {
let _icx = ccx.insn_ctxt("native::build_wrap_fn");
let _icx = ccx.insn_ctxt("foreign::build_wrap_fn");
fn build_args(bcx: block, tys: @c_stack_tys,
llwrapfn: ValueRef, llargbundle: ValueRef) {
let _icx = bcx.insn_ctxt("native::wrap::build_args");
let _icx = bcx.insn_ctxt("foreign::wrap::build_args");
let mut i = 0u;
let n = vec::len(tys.arg_tys);
let implicit_args = first_real_arg; // ret + env
@ -745,7 +745,7 @@ fn trans_native_mod(ccx: @crate_ctxt,
fn build_ret(bcx: block, _tys: @c_stack_tys,
_llargbundle: ValueRef) {
let _icx = bcx.insn_ctxt("native::wrap::build_ret");
let _icx = bcx.insn_ctxt("foreign::wrap::build_ret");
RetVoid(bcx);
}
@ -755,22 +755,22 @@ fn trans_native_mod(ccx: @crate_ctxt,
}
let mut cc = alt abi {
ast::native_abi_rust_intrinsic |
ast::native_abi_cdecl { lib::llvm::CCallConv }
ast::native_abi_stdcall { lib::llvm::X86StdcallCallConv }
ast::foreign_abi_rust_intrinsic |
ast::foreign_abi_cdecl { lib::llvm::CCallConv }
ast::foreign_abi_stdcall { lib::llvm::X86StdcallCallConv }
};
for vec::each(native_mod.items) {|native_item|
alt native_item.node {
ast::native_item_fn(fn_decl, typarams) {
let id = native_item.id;
if abi != ast::native_abi_rust_intrinsic {
for vec::each(foreign_mod.items) {|foreign_item|
alt foreign_item.node {
ast::foreign_item_fn(fn_decl, typarams) {
let id = foreign_item.id;
if abi != ast::foreign_abi_rust_intrinsic {
let llwrapfn = get_item_val(ccx, id);
let tys = c_stack_tys(ccx, id);
if attr::attrs_contains_name(native_item.attrs, "rust_stack") {
build_direct_fn(ccx, llwrapfn, native_item, tys, cc);
if attr::attrs_contains_name(foreign_item.attrs, "rust_stack") {
build_direct_fn(ccx, llwrapfn, foreign_item, tys, cc);
} else {
let llshimfn = build_shim_fn(ccx, native_item, tys, cc);
let llshimfn = build_shim_fn(ccx, foreign_item, tys, cc);
build_wrap_fn(ccx, tys, llshimfn, llwrapfn);
}
} else {
@ -779,9 +779,9 @@ fn trans_native_mod(ccx: @crate_ctxt,
if typarams.is_empty() {
let llwrapfn = get_item_val(ccx, id);
let path = alt ccx.tcx.items.find(id) {
some(ast_map::node_native_item(_, _, pt)) { pt }
some(ast_map::node_foreign_item(_, _, pt)) { pt }
_ {
ccx.sess.span_bug(native_item.span,
ccx.sess.span_bug(foreign_item.span,
"can't find intrinsic path")
}
};
@ -790,7 +790,7 @@ fn trans_native_mod(ccx: @crate_ctxt,
vtables: none,
bounds: @[]/~
};
trans_intrinsic(ccx, llwrapfn, native_item,
trans_intrinsic(ccx, llwrapfn, foreign_item,
*path, psubsts, none);
}
}
@ -799,7 +799,7 @@ fn trans_native_mod(ccx: @crate_ctxt,
}
}
fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item,
fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
path: ast_map::path, substs: param_substs,
ref_id: option<ast::node_id>) {
let fcx = new_fn_ctxt_w_id(ccx, path, decl, item.id,
@ -922,15 +922,15 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item,
finish_fn(fcx, lltop);
}
fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
fn trans_extern_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("native::build_crust_fn");
let _icx = ccx.insn_ctxt("foreign::build_extern_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("native::crust::build_rust_fn");
let _icx = ccx.insn_ctxt("foreign::extern::build_rust_fn");
let t = ty::node_id_to_type(ccx.tcx, id);
let ps = link::mangle_internal_name_by_path(
ccx, path + [ast_map::path_name(@"__rust_abi")]/~);
@ -943,11 +943,11 @@ fn trans_crust_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("native::crust::build_shim_fn");
let _icx = ccx.insn_ctxt("foreign::extern::build_shim_fn");
fn build_args(bcx: block, tys: @c_stack_tys,
llargbundle: ValueRef) -> [ValueRef]/~ {
let _icx = bcx.insn_ctxt("native::crust::shim::build_args");
let _icx = bcx.insn_ctxt("foreign::crust::shim::build_args");
let mut llargvals = []/~;
let mut i = 0u;
let n = vec::len(tys.arg_tys);
@ -979,11 +979,11 @@ fn trans_crust_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("native::crust::build_wrap_fn");
let _icx = ccx.insn_ctxt("foreign::extern::build_wrap_fn");
fn build_args(bcx: block, tys: @c_stack_tys,
llwrapfn: ValueRef, llargbundle: ValueRef) {
let _icx = bcx.insn_ctxt("native::crust::wrap::build_args");
let _icx = bcx.insn_ctxt("foreign::extern::wrap::build_args");
alt tys.x86_64_tys {
option::some(x86_64) {
let mut atys = x86_64.arg_tys;
@ -1037,7 +1037,7 @@ fn trans_crust_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("native::crust::wrap::build_ret");
let _icx = bcx.insn_ctxt("foreign::extern::wrap::build_ret");
alt tys.x86_64_tys {
option::some(x86_64) {
if x86_64.sret || !tys.ret_def {
@ -1078,10 +1078,10 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
build_wrap_fn(ccx, llshimfn, llwrapfn, tys)
}
fn register_crust_fn(ccx: @crate_ctxt, sp: span,
fn register_extern_fn(ccx: @crate_ctxt, sp: span,
path: ast_map::path, node_id: ast::node_id)
-> ValueRef {
let _icx = ccx.insn_ctxt("native::register_crust_fn");
let _icx = ccx.insn_ctxt("foreign::register_extern_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 {
@ -1098,16 +1098,16 @@ fn register_crust_fn(ccx: @crate_ctxt, sp: span,
}
}
fn abi_of_native_fn(ccx: @crate_ctxt, i: @ast::native_item)
-> ast::native_abi {
fn abi_of_foreign_fn(ccx: @crate_ctxt, i: @ast::foreign_item)
-> ast::foreign_abi {
alt attr::first_attr_value_str_by_name(i.attrs, "abi") {
none {
alt check ccx.tcx.items.get(i.id) {
ast_map::node_native_item(_, abi, _) { abi }
ast_map::node_foreign_item(_, abi, _) { abi }
}
}
some(_) {
alt attr::native_abi(i.attrs) {
alt attr::foreign_abi(i.attrs) {
either::right(abi) { abi }
either::left(msg) { ccx.sess.span_fatal(i.span, msg); }
}

View File

@ -67,7 +67,7 @@ fn traverse_def_id(cx: ctx, did: def_id) {
alt n {
ast_map::node_item(item, _) { traverse_public_item(cx, item); }
ast_map::node_method(_, impl_id, _) { traverse_def_id(cx, impl_id); }
ast_map::node_native_item(item, _, _) { cx.rmap.insert(item.id, ()); }
ast_map::node_foreign_item(item, _, _) { cx.rmap.insert(item.id, ()); }
ast_map::node_variant(v, _, _) { cx.rmap.insert(v.node.id, ()); }
// If it's a ctor, consider the parent reachable
ast_map::node_ctor(_, _, _, parent_id, _) {
@ -89,7 +89,7 @@ fn traverse_public_item(cx: ctx, item: @item) {
cx.rmap.insert(item.id, ());
alt item.node {
item_mod(m) { traverse_public_mod(cx, m); }
item_native_mod(nm) {
item_foreign_mod(nm) {
if !traverse_exports(cx, nm.view_items) {
for vec::each(nm.items) {|item| cx.rmap.insert(item.id, ()); }
}

View File

@ -170,7 +170,7 @@ impl methods for reflector {
ast::pure_fn { 0u }
ast::unsafe_fn { 1u }
ast::impure_fn { 2u }
ast::crust_fn { 3u }
ast::extern_fn { 3u }
};
let protoval = alt fty.proto {
ast::proto_bare { 0u }

View File

@ -72,8 +72,9 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
ast_map::node_variant(_, _, _) {
for uint::range(0u, n_tps) {|n| cx.uses[n] |= use_repr;}
}
ast_map::node_native_item(i@@{node: native_item_fn(_, _), _}, abi, _) {
if abi == native_abi_rust_intrinsic {
ast_map::node_foreign_item(i@@{node: foreign_item_fn(_, _), _},
abi, _) {
if abi == foreign_abi_rust_intrinsic {
let flags = alt check *i.ident {
"visit_ty" { 3u }
"size_of" | "pref_align_of" | "min_align_of" |

View File

@ -20,8 +20,8 @@ fn find_pre_post_mod(_m: _mod) -> _mod {
fail;
}
fn find_pre_post_native_mod(_m: native_mod) -> native_mod {
#debug("implement find_pre_post_native_mod");
fn find_pre_post_foreign_mod(_m: foreign_mod) -> foreign_mod {
#debug("implement find_pre_post_foreign_mod");
fail;
}
@ -47,7 +47,7 @@ fn find_pre_post_item(ccx: crate_ctxt, i: item) {
find_pre_post_fn(fcx, body);
}
item_mod(m) { find_pre_post_mod(m); }
item_native_mod(nm) { find_pre_post_native_mod(nm); }
item_foreign_mod(nm) { find_pre_post_foreign_mod(nm); }
item_ty(*) | item_enum(*) | item_iface(*) { ret; }
item_class(*) {
fail "find_pre_post_item: shouldn't be called on item_class";

View File

@ -2611,7 +2611,7 @@ fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
alt node {
ast_map::node_item(item, path) {
let item_elt = alt item.node {
item_mod(_) | item_native_mod(_) {
item_mod(_) | item_foreign_mod(_) {
ast_map::path_mod(item.ident)
}
_ {
@ -2621,7 +2621,7 @@ fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
*path + [item_elt]/~
}
ast_map::node_native_item(nitem, _, path) {
ast_map::node_foreign_item(nitem, _, path) {
*path + [ast_map::path_name(nitem.ident)]/~
}

View File

@ -391,9 +391,9 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
let tpt_ty = ty::node_id_to_type(ccx.tcx, it.id);
check_bounds_are_used(ccx, t.span, tps, rp, tpt_ty);
}
ast::item_native_mod(m) {
if syntax::attr::native_abi(it.attrs) ==
either::right(ast::native_abi_rust_intrinsic) {
ast::item_foreign_mod(m) {
if syntax::attr::foreign_abi(it.attrs) ==
either::right(ast::foreign_abi_rust_intrinsic) {
for m.items.each { |item|
check_intrinsic_type(ccx, item);
}
@ -2016,7 +2016,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
}
}
}
ast::def_fn(id, ast::crust_fn) {
ast::def_fn(id, ast::extern_fn) {
// Crust functions are just u8 pointers
ret {
bounds: @[]/~,
@ -2054,7 +2054,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
ast::def_ty_param(did, n) {
ret no_params(ty::mk_param(fcx.ccx.tcx, n, did));
}
ast::def_mod(*) | ast::def_native_mod(*) {
ast::def_mod(*) | ast::def_foreign_mod(*) {
fcx.ccx.tcx.sess.span_fatal(sp, "expected value but found module");
}
ast::def_use(*) {
@ -2210,7 +2210,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt,
}
}
fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::native_item) {
fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) {
fn param(ccx: @crate_ctxt, n: uint) -> ty::t {
ty::mk_param(ccx.tcx, n, local_def(0))
}

View File

@ -197,7 +197,7 @@ fn region_of(fcx: @fn_ctxt, expr: @ast::expr) -> ty::region {
}
}
ast::def_fn(_, _) | ast::def_mod(_) |
ast::def_native_mod(_) | ast::def_const(_) |
ast::def_foreign_mod(_) | ast::def_const(_) |
ast::def_use(_) | ast::def_variant(_, _) |
ast::def_ty(_) | ast::def_prim_ty(_) |
ast::def_ty_param(_, _) | ast::def_class(_) |

View File

@ -54,7 +54,7 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) {
visit::visit_crate(*crate, (), visit::mk_simple_visitor(@{
visit_item: {|a|convert(ccx, a)},
visit_native_item: {|a|convert_native(ccx, a)}
visit_foreign_item: {|a|convert_foreign(ccx, a)}
with *visit::default_simple_visitor()
}));
}
@ -77,8 +77,8 @@ impl of ast_conv for @crate_ctxt {
some(ast_map::node_item(item, _)) {
ty_of_item(self, item)
}
some(ast_map::node_native_item(native_item, _, _)) {
ty_of_native_item(self, native_item)
some(ast_map::node_foreign_item(foreign_item, _, _)) {
ty_of_foreign_item(self, foreign_item)
}
x {
self.tcx.sess.bug(#fmt["unexpected sort of item \
@ -296,7 +296,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
let tcx = ccx.tcx;
alt it.node {
// These don't define types.
ast::item_native_mod(_) | ast::item_mod(_) {}
ast::item_foreign_mod(_) | ast::item_mod(_) {}
ast::item_enum(variants, ty_params, rp) {
let tpt = ty_of_item(ccx, it);
write_ty_to_tcx(tcx, it.id, tpt.ty);
@ -396,13 +396,13 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
}
}
}
fn convert_native(ccx: @crate_ctxt, i: @ast::native_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
// table.
let tpt = ty_of_native_item(ccx, i);
let tpt = ty_of_foreign_item(ccx, i);
alt i.node {
ast::native_item_fn(_, _) {
ast::foreign_item_fn(_, _) {
write_ty_to_tcx(ccx.tcx, i.id, tpt.ty);
ccx.tcx.tcache.insert(local_def(i.id), tpt);
}
@ -535,15 +535,15 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item)
ret tpt;
}
ast::item_impl(*) | ast::item_mod(_) |
ast::item_native_mod(_) { fail; }
ast::item_foreign_mod(_) { fail; }
}
}
fn ty_of_native_item(ccx: @crate_ctxt, it: @ast::native_item)
fn ty_of_foreign_item(ccx: @crate_ctxt, it: @ast::foreign_item)
-> ty::ty_param_bounds_and_ty {
alt it.node {
ast::native_item_fn(fn_decl, params) {
ret ty_of_native_fn_decl(ccx, fn_decl, params,
ast::foreign_item_fn(fn_decl, params) {
ret ty_of_foreign_fn_decl(ccx, fn_decl, params,
local_def(it.id));
}
}
@ -588,7 +588,7 @@ fn ty_param_bounds(ccx: @crate_ctxt,
}
}
fn ty_of_native_fn_decl(ccx: @crate_ctxt,
fn ty_of_foreign_fn_decl(ccx: @crate_ctxt,
decl: ast::fn_decl,
ty_params: [ast::ty_param]/~,
def_id: ast::def_id) -> ty::ty_param_bounds_and_ty {

View File

@ -179,7 +179,7 @@ import ty::{mk_fn, type_is_bot};
import check::regionmanip::{replace_bound_regions_in_fn_ty};
import driver::session::session;
import util::common::{indent, indenter};
import ast::{unsafe_fn, impure_fn, pure_fn, crust_fn};
import ast::{unsafe_fn, impure_fn, pure_fn, extern_fn};
import ast::{m_const, m_imm, m_mutbl};
export infer_ctxt;
@ -2132,7 +2132,7 @@ impl of combine for lub {
alt (f1, f2) {
(unsafe_fn, _) | (_, unsafe_fn) {ok(unsafe_fn)}
(impure_fn, _) | (_, impure_fn) {ok(impure_fn)}
(crust_fn, _) | (_, crust_fn) {ok(crust_fn)}
(extern_fn, _) | (_, extern_fn) {ok(extern_fn)}
(pure_fn, pure_fn) {ok(pure_fn)}
}
}
@ -2332,7 +2332,7 @@ impl of combine for glb {
fn purities(f1: purity, f2: purity) -> cres<purity> {
alt (f1, f2) {
(pure_fn, _) | (_, pure_fn) {ok(pure_fn)}
(crust_fn, _) | (_, crust_fn) {ok(crust_fn)}
(extern_fn, _) | (_, extern_fn) {ok(extern_fn)}
(impure_fn, _) | (_, impure_fn) {ok(impure_fn)}
(unsafe_fn, unsafe_fn) {ok(unsafe_fn)}
}

View File

@ -43,7 +43,7 @@ mod middle {
mod closure;
mod tvec;
mod impl;
mod native;
mod foreign;
mod reflect;
mod shape;
mod debuginfo;

View File

@ -94,7 +94,7 @@ fn parse_item_attrs<T:send>(
astsrv::exec(srv) {|ctxt|
let attrs = alt ctxt.ast_map.get(id) {
ast_map::node_item(item, _) { item.attrs }
ast_map::node_native_item(item, _, _) { item.attrs }
ast_map::node_foreign_item(item, _, _) { item.attrs }
_ {
fail "parse_item_attrs: not an item";
}
@ -116,13 +116,13 @@ fn should_extract_top_mod_attributes() {
}
#[test]
fn should_extract_native_mod_attributes() {
fn should_extract_foreign_mod_attributes() {
let doc = test::mk_doc("#[doc = \"test\"] native mod a { }");
assert doc.cratemod().nmods()[0].desc() == some("test");
}
#[test]
fn should_extract_native_fn_attributes() {
fn should_extract_foreign_fn_attributes() {
let doc = test::mk_doc("native mod a { #[doc = \"test\"] fn a(); }");
assert doc.cratemod().nmods()[0].fns[0].desc() == some("test");
}

View File

@ -63,7 +63,7 @@ fn moddoc_from_mod(
moddoc_from_mod(itemdoc, m)
))
}
ast::item_native_mod(nm) {
ast::item_foreign_mod(nm) {
some(doc::nmodtag(
nmoddoc_from_mod(itemdoc, nm)
))
@ -109,14 +109,14 @@ fn moddoc_from_mod(
fn nmoddoc_from_mod(
itemdoc: doc::itemdoc,
module: ast::native_mod
module: ast::foreign_mod
) -> doc::nmoddoc {
{
item: itemdoc,
fns: par::seqmap(module.items) {|item|
let itemdoc = mk_itemdoc(item.id, item.ident);
alt item.node {
ast::native_item_fn(_, _) {
ast::foreign_item_fn(_, _) {
fndoc_from_fn(itemdoc)
}
}
@ -290,13 +290,13 @@ mod test {
}
#[test]
fn extract_native_mods() {
fn extract_foreign_mods() {
let doc = mk_doc("native mod a { }");
assert doc.cratemod().nmods()[0].name() == "a";
}
#[test]
fn extract_fns_from_native_mods() {
fn extract_fns_from_foreign_mods() {
let doc = mk_doc("native mod a { fn a(); }");
assert doc.cratemod().nmods()[0].fns[0].name() == "a";
}

View File

@ -176,7 +176,7 @@ fn should_index_mod_contents_multi_page() {
}
#[test]
fn should_index_native_mod_pages() {
fn should_index_foreign_mod_pages() {
let doc = test::mk_doc(
config::doc_per_mod,
"native mod a { }"
@ -199,7 +199,7 @@ fn should_add_brief_desc_to_index() {
}
#[test]
fn should_index_native_mod_contents() {
fn should_index_foreign_mod_contents() {
let doc = test::mk_doc(
config::doc_per_crate,
"native mod a { fn b(); }"

View File

@ -413,7 +413,7 @@ fn should_not_write_index_if_no_entries() {
}
#[test]
fn should_write_index_for_native_mods() {
fn should_write_index_for_foreign_mods() {
let markdown = test::render("native mod a { fn a(); }");
assert str::contains(
markdown,
@ -434,20 +434,20 @@ fn write_nmod(ctxt: ctxt, doc: doc::nmoddoc) {
}
#[test]
fn should_write_native_mods() {
fn should_write_foreign_mods() {
let markdown = test::render("#[doc = \"test\"] native mod a { }");
assert str::contains(markdown, "Native module `a`");
assert str::contains(markdown, "test");
}
#[test]
fn should_write_native_fns() {
fn should_write_foreign_fns() {
let markdown = test::render("native mod a { #[doc = \"test\"] fn a(); }");
assert str::contains(markdown, "test");
}
#[test]
fn should_write_native_fn_headers() {
fn should_write_foreign_fn_headers() {
let markdown = test::render("native mod a { #[doc = \"test\"] fn a(); }");
assert str::contains(markdown, "## Function `a`");
}

View File

@ -149,13 +149,13 @@ fn should_remove_mods_from_containing_mods() {
}
#[test]
fn should_make_a_page_for_every_native_mod() {
fn should_make_a_page_for_every_foreign_mod() {
let doc = test::mk_doc("native mod a { }");
assert doc.pages.nmods()[0].name() == "a";
}
#[test]
fn should_remove_native_mods_from_containing_mods() {
fn should_remove_foreign_mods_from_containing_mods() {
let doc = test::mk_doc("native mod a { }");
assert vec::is_empty(doc.cratemod().nmods());
}

View File

@ -87,7 +87,7 @@ fn should_record_fn_paths() {
}
#[test]
fn should_record_native_mod_paths() {
fn should_record_foreign_mod_paths() {
let source = "mod a { native mod b { } }";
astsrv::from_str(source) {|srv|
let doc = extract::from_srv(srv, "");
@ -97,7 +97,7 @@ fn should_record_native_mod_paths() {
}
#[test]
fn should_record_native_fn_paths() {
fn should_record_foreign_fn_paths() {
let source = "native mod a { fn b(); }";
astsrv::from_str(source) {|srv|
let doc = extract::from_srv(srv, "");

View File

@ -445,7 +445,7 @@ fn should_duplicate_reexported_impls_crate() {
}
#[test]
fn should_duplicate_reexported_native_fns() {
fn should_duplicate_reexported_foreign_fns() {
let source = "native mod a { fn b(); } \
mod c { import a::b; export b; }";
let doc = test::mk_doc(source);

View File

@ -51,9 +51,9 @@ fn get_fn_sig(srv: astsrv::srv, fn_id: doc::ast_id) -> option<str> {
ident: ident,
node: ast::item_fn(decl, tys, _), _
}, _) |
ast_map::node_native_item(@{
ast_map::node_foreign_item(@{
ident: ident,
node: ast::native_item_fn(decl, tys), _
node: ast::foreign_item_fn(decl, tys), _
}, _, _) {
some(pprust::fun_to_str(decl, ident, tys))
}
@ -68,7 +68,7 @@ fn should_add_fn_sig() {
}
#[test]
fn should_add_native_fn_sig() {
fn should_add_foreign_fn_sig() {
let doc = test::mk_doc("native mod a { fn a<T>() -> int; }");
assert doc.cratemod().nmods()[0].fns[0].sig == some("fn a<T>() -> int");
}

View File

@ -1,4 +1,4 @@
#[link(name="native_lib", vers="0.0")];
#[link(name="foreign_lib", vers="0.0")];
native mod rustrt {
fn last_os_error() -> str;

View File

@ -9,5 +9,5 @@ fn main() {
}
f(g);
//!^ ERROR mismatched types: expected `native fn(native fn(native fn()))`
//!^ ERROR mismatched types: expected `extern fn(extern fn(extern fn()))`
}

View File

@ -6,7 +6,7 @@ fn coerce(b: fn()) -> native fn() {
g: fn()) -> native fn() { ret f(g); }
fn fn_id(f: native fn()) -> native fn() { ret f }
ret lol(fn_id, b);
//!^ ERROR mismatched types: expected `native fn(fn()) -> native fn()`
//!^ ERROR mismatched types: expected `extern fn(fn()) -> extern fn()`
}
fn main() {

View File

@ -2,5 +2,5 @@ fn main() {
fn f() { }
fn g(i: int) { }
let x = f == g;
//!^ ERROR expected `native fn()` but found `native fn(int)`
//!^ ERROR expected `extern fn()` but found `extern fn(int)`
}

View File

@ -1,3 +1,3 @@
fn main() -> char {
//!^ ERROR Wrong type in main function: found `native fn() -> char`
//!^ ERROR Wrong type in main function: found `extern fn() -> char`
}

View File

@ -1,3 +1,3 @@
fn main(foo: {x: int, y: int}) {
//!^ ERROR Wrong type in main function: found `native fn({x: int,y: int})`
//!^ ERROR Wrong type in main function: found `extern fn({x: int,y: int})`
}

View File

@ -1,6 +1,6 @@
// pp-exact
fn from_native_fn(x: native fn()) { }
fn from_foreign_fn(x: extern fn()) { }
fn from_closure(x: fn()) { }
fn from_stack_closure(x: fn&()) { }
fn from_box_closure(x: fn@()) { }

View File

@ -120,7 +120,7 @@ native mod test {
fn get_task_id();
}
fn test_native_fn() {
fn test_foreign_fn() {
assert test::unsupervise != test::get_task_id;
assert test::unsupervise == test::unsupervise;
}
@ -157,6 +157,6 @@ fn main() {
test_chan();
test_ptr();
test_fn();
test_native_fn();
test_foreign_fn();
test_class();
}

View File

@ -79,7 +79,7 @@ fn test_in_fn_ctxt() {
assert (i == 1);
}
mod test_native_items {
mod test_foreign_items {
#[abi = "cdecl"]
native mod rustrt {
#[cfg(bogus)]

View File

@ -1,12 +1,12 @@
// xfail-fast
// aux-build:native_lib.rs
// aux-build:foreign_lib.rs
// The purpose of this test is to check that we can
// successfully (and safely) invoke external, cdecl
// functions from outside the crate.
use native_lib;
use foreign_lib;
fn main() {
let foo = native_lib::rustrt::last_os_error();
let foo = foreign_lib::rustrt::last_os_error();
}

View File

@ -157,7 +157,7 @@ mod test_other_forms {
fn f() { }
}
mod test_native_items {
mod test_foreign_items {
#[abi = "cdecl"]
native mod rustrt {
#[attr];

View File

@ -18,7 +18,7 @@ fn run(i: int) {
let opts = {
sched: some({
mode: task::osmain,
native_stack_size: none
foreign_stack_size: none
})
with task::get_opts(builder)
};
@ -30,7 +30,7 @@ fn run(i: int) {
let opts = {
sched: some({
mode: task::single_threaded,
native_stack_size: none
foreign_stack_size: none
})
with task::get_opts(builder)
};