diff options
| author | Haitao Li <lihaitao@gmail.com> | 2011-11-21 02:15:40 +0800 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-11-21 13:49:52 +0100 |
| commit | 5ca83553bc499e677a49b97075938abb5c70b4fd (patch) | |
| tree | 014110df635577ae09e5df641e869f8b61daf43d /src/comp/middle | |
| parent | 7a7f0604f4aff935f2b2ad4ad9c66f77c581dc93 (diff) | |
| download | rust-5ca83553bc499e677a49b97075938abb5c70b4fd.tar.gz rust-5ca83553bc499e677a49b97075938abb5c70b4fd.zip | |
rustc: Remove abi from ast::native_mod
Diffstat (limited to 'src/comp/middle')
| -rw-r--r-- | src/comp/middle/alias.rs | 2 | ||||
| -rw-r--r-- | src/comp/middle/gc.rs | 2 | ||||
| -rw-r--r-- | src/comp/middle/shape.rs | 2 | ||||
| -rw-r--r-- | src/comp/middle/trans.rs | 68 | ||||
| -rw-r--r-- | src/comp/middle/tstate/auxiliary.rs | 2 | ||||
| -rw-r--r-- | src/comp/middle/ty.rs | 52 | ||||
| -rw-r--r-- | src/comp/middle/typeck.rs | 40 |
7 files changed, 88 insertions, 80 deletions
diff --git a/src/comp/middle/alias.rs b/src/comp/middle/alias.rs index 89efd15ef29..7e05e9186c3 100644 --- a/src/comp/middle/alias.rs +++ b/src/comp/middle/alias.rs @@ -651,7 +651,7 @@ fn copy_is_expensive(tcx: ty::ctxt, ty: ty::t) -> bool { ty::ty_ptr(_) { 1u } ty::ty_box(_) { 3u } ty::ty_constr(t, _) | ty::ty_res(_, t, _) { score_ty(tcx, t) } - ty::ty_fn(_, _, _, _, _) | ty::ty_native_fn(_, _, _) | + ty::ty_fn(_, _, _, _, _) | ty::ty_native_fn(_, _) | ty::ty_obj(_) { 4u } ty::ty_str. | ty::ty_vec(_) | ty::ty_param(_, _) { 50u } ty::ty_uniq(mt) { 1u + score_ty(tcx, mt.ty) } diff --git a/src/comp/middle/gc.rs b/src/comp/middle/gc.rs index 8f77011b562..fcdbb8be29f 100644 --- a/src/comp/middle/gc.rs +++ b/src/comp/middle/gc.rs @@ -151,7 +151,7 @@ fn type_is_gc_relevant(cx: ty::ctxt, ty: ty::t) -> bool { ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_fn(_, _, _, _, _) | - ty::ty_native_fn(_, _, _) | ty::ty_obj(_) | ty::ty_param(_, _) | + ty::ty_native_fn(_, _) | ty::ty_obj(_) | ty::ty_param(_, _) | ty::ty_res(_, _, _) { ret true; } diff --git a/src/comp/middle/shape.rs b/src/comp/middle/shape.rs index de12ea36b93..9321e30f494 100644 --- a/src/comp/middle/shape.rs +++ b/src/comp/middle/shape.rs @@ -419,7 +419,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint], ty::ty_fn(_, _, _, _, _) { s += [shape_fn]; } - ty::ty_native_fn(_, _, _) { s += [shape_u32]; } + ty::ty_native_fn(_, _) { s += [shape_u32]; } ty::ty_obj(_) { s += [shape_obj]; } diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index d20794b15df..9da71ee8e14 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -12,7 +12,7 @@ // pcwalton). You can, instead, find out its TypeRef by calling val_ty, // but many TypeRefs correspond to one ty::t; for instance, tup(int, int, // int) and rec(x=int, y=int, z=int) will have the same TypeRef. -import std::{str, uint, map, option, time, vec}; +import std::{either, str, uint, map, option, time, vec}; import std::map::hashmap; import std::map::{new_int_hash, new_str_hash}; import std::option::{some, none}; @@ -182,7 +182,7 @@ fn type_of_inner(cx: @crate_ctxt, sp: span, t: ty::t) check returns_non_ty_var(cx, t); T_fn_pair(cx, type_of_fn_from_ty(cx, sp, t, 0u)) } - ty::ty_native_fn(abi, args, out) { + ty::ty_native_fn(args, out) { let nft = native_fn_wrapper_type(cx, sp, 0u, t); T_fn_pair(cx, nft) } @@ -235,7 +235,7 @@ fn type_of_ty_param_kinds_and_ty(lcx: @local_ctxt, sp: span, let cx = lcx.ccx; let t = tpt.ty; alt ty::struct(cx.tcx, t) { - ty::ty_fn(_, _, _, _, _) | ty::ty_native_fn(_, _, _) { + ty::ty_fn(_, _, _, _, _) | ty::ty_native_fn(_, _) { check returns_non_ty_var(cx, t); ret type_of_fn_from_ty(cx, sp, t, std::vec::len(tpt.kinds)); } @@ -1727,7 +1727,7 @@ fn iter_structural_ty(cx: @block_ctxt, av: ValueRef, t: ty::t, } ret next_cx; } - ty::ty_fn(_, _, _, _, _) | ty::ty_native_fn(_, _, _) { + ty::ty_fn(_, _, _, _, _) | ty::ty_native_fn(_, _) { let box_cell_a = GEPi(cx, av, [0, abi::fn_field_box]); ret iter_boxpp(cx, box_cell_a, f); } @@ -5305,7 +5305,7 @@ fn c_stack_tys(ccx: @crate_ctxt, sp: span, id: ast::node_id) -> @c_stack_tys { alt ty::struct(ccx.tcx, ty::node_id_to_type(ccx.tcx, id)) { - ty::ty_native_fn(_, arg_tys, ret_ty) { + ty::ty_native_fn(arg_tys, ret_ty) { let tcx = ccx.tcx; let llargtys = type_of_explicit_args(ccx, sp, arg_tys); check non_ty_var(ccx, ret_ty); // NDM does this truly hold? @@ -5365,7 +5365,8 @@ fn c_stack_tys(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(lcx: @local_ctxt, native_mod: ast::native_mod) { +fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod, + abi: ast::native_abi) { fn build_shim_fn(lcx: @local_ctxt, native_item: @ast::native_item, tys: @c_stack_tys, @@ -5448,7 +5449,7 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod) { let ccx = lcx_ccx(lcx); let cc: uint = lib::llvm::LLVMCCallConv; - alt native_mod.abi { + alt abi { ast::native_abi_rust_intrinsic. { ret; } ast::native_abi_cdecl. { cc = lib::llvm::LLVMCCallConv; } ast::native_abi_stdcall. { cc = lib::llvm::LLVMX86StdcallCallConv; } @@ -5529,13 +5530,16 @@ fn trans_item(cx: @local_ctxt, item: ast::item) { } ast::item_const(_, expr) { trans_const(cx.ccx, expr, item.id); } ast::item_native_mod(native_mod) { - trans_native_mod(cx, native_mod); + let abi = alt attr::native_abi(item.attrs) { + either::right(abi_) { abi_ } + either::left(msg) { cx.ccx.sess.span_fatal(item.span, msg) } + }; + trans_native_mod(cx, native_mod, abi); } _ {/* fall through */ } } } - // Translate a module. Doing this amounts to translating the items in the // module; there ends up being no artifact (aside from linkage names) of // separate modules in the compiled program. That's because modules exist @@ -5697,7 +5701,7 @@ fn native_fn_ty_param_count(cx: @crate_ctxt, id: ast::node_id) -> uint { fn native_fn_wrapper_type(cx: @crate_ctxt, sp: span, ty_param_count: uint, x: ty::t) -> TypeRef { alt ty::struct(cx.tcx, x) { - ty::ty_native_fn(abi, args, out) { + ty::ty_native_fn(args, out) { check non_ty_var(cx, out); ret type_of_fn(cx, sp, false, false, args, out, ty_param_count); } @@ -5719,7 +5723,10 @@ fn link_name(i: @ast::native_item) -> str { } } -fn collect_native_item(ccx: @crate_ctxt, i: @ast::native_item, &&pt: [str], +fn collect_native_item(ccx: @crate_ctxt, + abi: @mutable option::t<ast::native_abi>, + i: @ast::native_item, + &&pt: [str], _v: vt<[str]>) { alt i.node { ast::native_item_fn(_, tps) { @@ -5727,10 +5734,21 @@ fn collect_native_item(ccx: @crate_ctxt, i: @ast::native_item, &&pt: [str], let sp = i.span; let id = i.id; let node_type = node_id_type(ccx, id); - // FIXME NDM abi should come from attr - let abi = ty::ty_fn_abi(ccx.tcx, node_type); - - alt abi { + let fn_abi = + alt attr::get_meta_item_value_str_by_name(i.attrs, "abi") { + option::none. { + // if abi isn't specified for this function, inherit from + // its enclosing native module + option::get(*abi) + } + _ { + alt attr::native_abi(i.attrs) { + either::right(abi_) { abi_ } + either::left(msg) { ccx.sess.span_fatal(i.span, msg) } + } + } + }; + alt fn_abi { ast::native_abi_rust_intrinsic. { // For intrinsics: link the function directly to the intrinsic // function itself. @@ -5760,9 +5778,8 @@ fn collect_native_item(ccx: @crate_ctxt, i: @ast::native_item, &&pt: [str], } } -fn collect_item_1(ccx: @crate_ctxt, i: @ast::item, &&pt: [str], - v: vt<[str]>) { - visit::visit_item(i, pt + item_path(i), v); +fn collect_item_1(ccx: @crate_ctxt, abi: @mutable option::t<ast::native_abi>, + i: @ast::item, &&pt: [str], v: vt<[str]>) { alt i.node { ast::item_const(_, _) { let typ = node_id_type(ccx, i.id); @@ -5778,8 +5795,18 @@ fn collect_item_1(ccx: @crate_ctxt, i: @ast::item, &&pt: [str], ccx.item_symbols.insert(i.id, s); ccx.consts.insert(i.id, g); } + ast::item_native_mod(native_mod) { + // Propagate the native ABI down to collect_native_item(), + alt attr::native_abi(i.attrs) { + either::left(msg) { ccx.sess.span_fatal(i.span, msg); } + either::right(abi_) { + *abi = option::some(abi_); + } + } + } _ { } } + visit::visit_item(i, pt + item_path(i), v); } fn collect_item_2(ccx: @crate_ctxt, i: @ast::item, &&pt: [str], @@ -5814,10 +5841,11 @@ fn collect_item_2(ccx: @crate_ctxt, i: @ast::item, &&pt: [str], } fn collect_items(ccx: @crate_ctxt, crate: @ast::crate) { + let abi = @mutable none::<ast::native_abi>; let visitor0 = visit::default_visitor(); let visitor1 = - @{visit_native_item: bind collect_native_item(ccx, _, _, _), - visit_item: bind collect_item_1(ccx, _, _, _) with *visitor0}; + @{visit_native_item: bind collect_native_item(ccx, abi, _, _, _), + visit_item: bind collect_item_1(ccx, abi, _, _, _) with *visitor0}; let visitor2 = @{visit_item: bind collect_item_2(ccx, _, _, _) with *visitor0}; visit::visit_crate(*crate, [], visit::mk_vt(visitor1)); diff --git a/src/comp/middle/tstate/auxiliary.rs b/src/comp/middle/tstate/auxiliary.rs index a7179dada35..6e35aabf032 100644 --- a/src/comp/middle/tstate/auxiliary.rs +++ b/src/comp/middle/tstate/auxiliary.rs @@ -1070,7 +1070,7 @@ fn callee_modes(fcx: fn_ctxt, callee: node_id) -> [ty::mode] { ty::type_autoderef(fcx.ccx.tcx, ty::node_id_to_type(fcx.ccx.tcx, callee)); alt ty::struct(fcx.ccx.tcx, ty) { - ty::ty_fn(_, args, _, _, _) | ty::ty_native_fn(_, args, _) { + ty::ty_fn(_, args, _, _, _) | ty::ty_native_fn(args, _) { let modes = []; for arg: ty::arg in args { modes += [arg.mode]; } ret modes; diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index dc7394f0571..9471c4e01c5 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -113,7 +113,6 @@ export ty_constr; export ty_constr_arg; export ty_float; export ty_fn; -export ty_fn_abi; export ty_fn_proto; export ty_fn_ret; export ty_fn_ret_style; @@ -259,7 +258,7 @@ tag sty { ty_ptr(mt); ty_rec([field]); ty_fn(ast::proto, [arg], t, ret_style, [@constr]); - ty_native_fn(ast::native_abi, [arg], t); + ty_native_fn([arg], t); ty_obj([method]); ty_res(def_id, t, [t]); ty_tup([t]); @@ -465,7 +464,7 @@ fn mk_raw_ty(cx: ctxt, st: sty, _in_cname: option::t<str>) -> @raw_t { ty_fn(_, args, tt, _, _) { derive_flags_sig(cx, has_params, has_vars, args, tt); } - ty_native_fn(_, args, tt) { + ty_native_fn(args, tt) { derive_flags_sig(cx, has_params, has_vars, args, tt); } ty_obj(meths) { @@ -568,8 +567,8 @@ fn mk_fn(cx: ctxt, proto: ast::proto, args: [arg], ty: t, cf: ret_style, ret gen_ty(cx, ty_fn(proto, args, ty, cf, constrs)); } -fn mk_native_fn(cx: ctxt, abi: ast::native_abi, args: [arg], ty: t) -> t { - ret gen_ty(cx, ty_native_fn(abi, args, ty)); +fn mk_native_fn(cx: ctxt, args: [arg], ty: t) -> t { + ret gen_ty(cx, ty_native_fn(args, ty)); } fn mk_obj(cx: ctxt, meths: [method]) -> t { ret gen_ty(cx, ty_obj(meths)); } @@ -628,7 +627,7 @@ fn walk_ty(cx: ctxt, walker: ty_walk, ty: t) { for a: arg in args { walk_ty(cx, walker, a.ty); } walk_ty(cx, walker, ret_ty); } - ty_native_fn(abi, args, ret_ty) { + ty_native_fn(args, ret_ty) { for a: arg in args { walk_ty(cx, walker, a.ty); } walk_ty(cx, walker, ret_ty); } @@ -719,7 +718,7 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t { mk_fn(cx, proto, new_args, fold_ty(cx, fld, ret_ty), cf, constrs), ty); } - ty_native_fn(abi, args, ret_ty) { + ty_native_fn(args, ret_ty) { let new_args: [arg] = []; for a: arg in args { let new_ty = fold_ty(cx, fld, a.ty); @@ -727,7 +726,7 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t { } ty = copy_cname(cx, - mk_native_fn(cx, abi, new_args, + mk_native_fn(cx, new_args, fold_ty(cx, fld, ret_ty)), ty); } ty_obj(methods) { @@ -802,7 +801,7 @@ fn type_is_structural(cx: ctxt, ty: t) -> bool { ty_tup(_) { ret true; } ty_tag(_, _) { ret true; } ty_fn(_, _, _, _, _) { ret true; } - ty_native_fn(_, _, _) { ret true; } + ty_native_fn(_, _) { ret true; } ty_obj(_) { ret true; } ty_res(_, _, _) { ret true; } _ { ret false; } @@ -1008,7 +1007,7 @@ fn type_kind(cx: ctxt, ty: t) -> ast::kind { // Scalar and unique types are sendable ty_nil. | ty_bot. | ty_bool. | ty_int. | ty_uint. | ty_float. | ty_machine(_) | ty_char. | ty_native(_) | - ty_type. | ty_str. | ty_native_fn(_, _, _) { ast::kind_sendable } + ty_type. | ty_str. | ty_native_fn(_, _) { ast::kind_sendable } // FIXME: obj is broken for now, since we aren't asserting // anything about its fields. ty_obj(_) { kind_copyable } @@ -1221,7 +1220,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool { } // Boxed types ty_str. | ty_box(_) | ty_uniq(_) | ty_vec(_) | ty_fn(_, _, _, _, _) | - ty_native_fn(_, _, _) | ty_obj(_) { + ty_native_fn(_, _) | ty_obj(_) { result = false; } // Structural types @@ -1390,7 +1389,7 @@ fn hash_type_structure(st: sty) -> uint { ty_fn(_, args, rty, _, _) { ret hash_fn(27u, args, rty); } - ty_native_fn(_, args, rty) { ret hash_fn(28u, args, rty); } + ty_native_fn(args, rty) { ret hash_fn(28u, args, rty); } ty_obj(methods) { let h = 29u; for m: method in methods { h += h << 5u + str::hash(m.ident); } @@ -1584,7 +1583,7 @@ fn type_contains_params(cx: ctxt, typ: t) -> bool { fn ty_fn_args(cx: ctxt, fty: t) -> [arg] { alt struct(cx, fty) { ty::ty_fn(_, a, _, _, _) { ret a; } - ty::ty_native_fn(_, a, _) { ret a; } + ty::ty_native_fn(a, _) { ret a; } _ { cx.sess.bug("ty_fn_args() called on non-fn type"); } } } @@ -1592,7 +1591,7 @@ fn ty_fn_args(cx: ctxt, fty: t) -> [arg] { fn ty_fn_proto(cx: ctxt, fty: t) -> ast::proto { alt struct(cx, fty) { ty::ty_fn(p, _, _, _, _) { ret p; } - ty::ty_native_fn(_, _, _) { + ty::ty_native_fn(_, _) { // FIXME: This should probably be proto_bare ret ast::proto_shared(ast::sugar_normal); } @@ -1600,18 +1599,11 @@ fn ty_fn_proto(cx: ctxt, fty: t) -> ast::proto { } } -fn ty_fn_abi(cx: ctxt, fty: t) -> ast::native_abi { - alt struct(cx, fty) { - ty::ty_native_fn(a, _, _) { ret a; } - _ { cx.sess.bug("ty_fn_abi() called on non-native-fn type"); } - } -} - pure fn ty_fn_ret(cx: ctxt, fty: t) -> t { let sty = struct(cx, fty); alt sty { ty::ty_fn(_, _, r, _, _) { ret r; } - ty::ty_native_fn(_, _, r) { ret r; } + ty::ty_native_fn(_, r) { ret r; } _ { // Unchecked is ok since we diverge here // (might want to change the typechecker to allow @@ -1626,7 +1618,7 @@ pure fn ty_fn_ret(cx: ctxt, fty: t) -> t { fn ty_fn_ret_style(cx: ctxt, fty: t) -> ast::ret_style { alt struct(cx, fty) { ty::ty_fn(_, _, _, rs, _) { rs } - ty::ty_native_fn(_, _, _) { ast::return_val } + ty::ty_native_fn(_, _) { ast::return_val } _ { cx.sess.bug("ty_fn_ret_style() called on non-fn type"); } } } @@ -1634,7 +1626,7 @@ fn ty_fn_ret_style(cx: ctxt, fty: t) -> ast::ret_style { fn is_fn_ty(cx: ctxt, fty: t) -> bool { alt struct(cx, fty) { ty::ty_fn(_, _, _, _, _) { ret true; } - ty::ty_native_fn(_, _, _) { ret true; } + ty::ty_native_fn(_, _) { ret true; } _ { ret false; } } } @@ -2097,12 +2089,10 @@ mod unify { } } } - fn unify_native_fn(cx: @ctxt, e_abi: ast::native_abi, - a_abi: ast::native_abi, expected: t, actual: t, + fn unify_native_fn(cx: @ctxt, expected: t, actual: t, expected_inputs: [arg], expected_output: t, actual_inputs: [arg], actual_output: t, variance: variance) -> result { - if e_abi != a_abi { ret ures_err(terr_mismatch); } let t = unify_fn_common(cx, expected, actual, expected_inputs, expected_output, actual_inputs, actual_output, @@ -2110,7 +2100,7 @@ mod unify { alt t { fn_common_res_err(r) { ret r; } fn_common_res_ok(result_ins, result_out) { - let t2 = mk_native_fn(cx.tcx, e_abi, result_ins, result_out); + let t2 = mk_native_fn(cx.tcx, result_ins, result_out); ret ures_ok(t2); } } @@ -2521,10 +2511,10 @@ mod unify { _ { ret ures_err(terr_mismatch); } } } - ty::ty_native_fn(e_abi, expected_inputs, expected_output) { + ty::ty_native_fn(expected_inputs, expected_output) { alt struct(cx.tcx, actual) { - ty::ty_native_fn(a_abi, actual_inputs, actual_output) { - ret unify_native_fn(cx, e_abi, a_abi, expected, actual, + ty::ty_native_fn(actual_inputs, actual_output) { + ret unify_native_fn(cx, expected, actual, expected_inputs, expected_output, actual_inputs, actual_output, variance); } diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 35509c75496..156c1cf1138 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -524,14 +524,14 @@ mod collect { } fn ty_of_native_fn_decl(cx: @ctxt, convert: fn@(&&@ast::ty) -> ty::t, ty_of_arg: fn@(ast::arg) -> arg, - decl: ast::fn_decl, abi: ast::native_abi, + decl: ast::fn_decl, ty_params: [ast::ty_param], def_id: ast::def_id) -> ty::ty_param_kinds_and_ty { let input_tys = []; for a: ast::arg in decl.inputs { input_tys += [ty_of_arg(a)]; } let output_ty = convert(decl.output); - let t_fn = ty::mk_native_fn(cx.tcx, abi, input_tys, output_ty); + let t_fn = ty::mk_native_fn(cx.tcx, input_tys, output_ty); let tpt = {kinds: ty_param_kinds(ty_params), ty: t_fn}; cx.tcx.tcache.insert(def_id, tpt); ret tpt; @@ -546,8 +546,7 @@ mod collect { alt it { some(ast_map::node_item(item)) { tpt = ty_of_item(cx, item); } some(ast_map::node_native_item(native_item)) { - tpt = ty_of_native_item(cx, native_item, - ast::native_abi_cdecl); + tpt = ty_of_native_item(cx, native_item); } _ { cx.tcx.sess.fatal("internal error " + std::int::str(id.node)); } } @@ -661,15 +660,15 @@ mod collect { ast::item_native_mod(_) { fail; } } } - fn ty_of_native_item(cx: @ctxt, it: @ast::native_item, - abi: ast::native_abi) -> ty::ty_param_kinds_and_ty { + fn ty_of_native_item(cx: @ctxt, it: @ast::native_item) + -> ty::ty_param_kinds_and_ty { let no_kinds: [ast::kind] = []; alt it.node { ast::native_item_fn(fn_decl, params) { let get = bind getter(cx, _); let convert = bind ast_ty_to_ty(cx.tcx, get, _); let f = bind ty_of_arg(cx, _); - ret ty_of_native_fn_decl(cx, convert, f, fn_decl, abi, params, + ret ty_of_native_fn_decl(cx, convert, f, fn_decl, params, ast_util::local_def(it.id)); } ast::native_item_ty. { @@ -726,16 +725,13 @@ mod collect { } ret meths; } - fn convert(cx: @ctxt, abi: @mutable option::t<ast::native_abi>, - it: @ast::item) { + fn convert(cx: @ctxt, it: @ast::item) { alt it.node { ast::item_mod(_) { // ignore item_mod, it has no type. } ast::item_native_mod(native_mod) { - // Propagate the native ABI down to convert_native() below, - // but otherwise do nothing, as native modules have no types. - *abi = some::<ast::native_abi>(native_mod.abi); + // do nothing, as native modules have no types. } ast::item_tag(variants, ty_params) { let tpt = ty_of_item(cx, it); @@ -804,14 +800,11 @@ mod collect { } } } - fn convert_native(cx: @ctxt, abi: @mutable option::t<ast::native_abi>, - i: @ast::native_item) { + fn convert_native(cx: @ctxt, i: @ast::native_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(cx, i, - option::get::<ast::native_abi>({ *abi })); + let tpt = ty_of_native_item(cx, i); alt i.node { ast::native_item_ty. { // FIXME: Native types have no annotation. Should they? --pcw @@ -822,14 +815,11 @@ mod collect { } } fn collect_item_types(tcx: ty::ctxt, crate: @ast::crate) { - // We have to propagate the surrounding ABI to the native items - // contained within the native module. - let abi = @mutable none::<ast::native_abi>; let cx = @{tcx: tcx}; let visit = - visit::mk_simple_visitor(@{visit_item: bind convert(cx, abi, _), + visit::mk_simple_visitor(@{visit_item: bind convert(cx, _), visit_native_item: - bind convert_native(cx, abi, _) + bind convert_native(cx, _) with *visit::default_simple_visitor()}); visit::visit_crate(*crate, (), visit); @@ -1567,7 +1557,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier, // Grab the argument types let arg_tys = alt sty { - ty::ty_fn(_, arg_tys, _, _, _) | ty::ty_native_fn(_, arg_tys, _) + ty::ty_fn(_, arg_tys, _, _, _) | ty::ty_native_fn(arg_tys, _) { arg_tys } @@ -1676,7 +1666,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier, bot |= cf == ast::noreturn; rt_1 = rt; } - ty::ty_native_fn(_, _, rt) { rt_1 = rt; } + ty::ty_native_fn(_, rt) { rt_1 = rt; } _ { fcx.ccx.tcx.sess.span_fatal(sp, "calling non-function"); } } write::ty_only_fixup(fcx, id, rt_1); @@ -2031,7 +2021,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier, cf = cf_; constrs = constrs_; } - ty::ty_native_fn(_, arg_tys_, rt_) { + ty::ty_native_fn(arg_tys_, rt_) { proto = ast::proto_bare; arg_tys = arg_tys_; rt = rt_; |
