Modify native_item_fn to handle trailing linkage names that differ from the item name (used in win32 build of std.dll)
This commit is contained in:
parent
0c7545c1ce
commit
4b946cea35
8 changed files with 33 additions and 18 deletions
|
@ -367,7 +367,8 @@ tag item_ {
|
|||
type native_item = spanned[native_item_];
|
||||
tag native_item_ {
|
||||
native_item_ty(ident, def_id);
|
||||
native_item_fn(ident, fn_decl, vec[ty_param], def_id, ann);
|
||||
native_item_fn(ident, option.t[str],
|
||||
fn_decl, vec[ty_param], def_id, ann);
|
||||
}
|
||||
|
||||
// TODO: Actually store something here.
|
||||
|
@ -426,7 +427,7 @@ fn index_native_item(native_mod_index index, @native_item it) {
|
|||
case (ast.native_item_ty(?id, _)) {
|
||||
index.insert(id, ast.nmie_item(it));
|
||||
}
|
||||
case (ast.native_item_fn(?id, _, _, _, _)) {
|
||||
case (ast.native_item_fn(?id, _, _, _, _, _)) {
|
||||
index.insert(id, ast.nmie_item(it));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1859,9 +1859,15 @@ impure fn parse_item_native_fn(parser p, ast.effect eff) -> @ast.native_item {
|
|||
expect(p, token.FN);
|
||||
auto t = parse_fn_header(p);
|
||||
auto decl = parse_fn_decl(p, eff);
|
||||
auto link_name = none[str];
|
||||
if (p.peek() == token.EQ) {
|
||||
p.bump();
|
||||
link_name = some[str](parse_str_lit_or_env_ident(p));
|
||||
}
|
||||
auto hi = p.get_span();
|
||||
expect(p, token.SEMI);
|
||||
auto item = ast.native_item_fn(t._0, decl, t._1, p.next_def_id(),
|
||||
auto item = ast.native_item_fn(t._0, link_name, decl,
|
||||
t._1, p.next_def_id(),
|
||||
ast.ann_none);
|
||||
ret @spanned(lo, hi, item);
|
||||
}
|
||||
|
|
|
@ -233,6 +233,7 @@ type ast_fold[ENV] =
|
|||
def_id id, ann a) -> @item) fold_item_fn,
|
||||
|
||||
(fn(&ENV e, &span sp, ident ident,
|
||||
option.t[str] link_name,
|
||||
&ast.fn_decl decl,
|
||||
vec[ast.ty_param] ty_params,
|
||||
def_id id, ann a) -> @native_item) fold_native_item_fn,
|
||||
|
@ -990,9 +991,10 @@ fn fold_native_item[ENV](&ENV env, ast_fold[ENV] fld,
|
|||
case (ast.native_item_ty(?ident, ?id)) {
|
||||
ret fld.fold_native_item_ty(env_, i.span, ident, id);
|
||||
}
|
||||
case (ast.native_item_fn(?ident, ?fn_decl, ?ty_params, ?id, ?ann)) {
|
||||
case (ast.native_item_fn(?ident, ?lname, ?fn_decl,
|
||||
?ty_params, ?id, ?ann)) {
|
||||
auto d = fold_fn_decl[ENV](env_, fld, fn_decl);
|
||||
ret fld.fold_native_item_fn(env_, i.span, ident, d,
|
||||
ret fld.fold_native_item_fn(env_, i.span, ident, lname, d,
|
||||
ty_params, id, ann);
|
||||
}
|
||||
}
|
||||
|
@ -1346,10 +1348,11 @@ fn identity_fold_item_fn[ENV](&ENV e, &span sp, ident i,
|
|||
}
|
||||
|
||||
fn identity_fold_native_item_fn[ENV](&ENV e, &span sp, ident i,
|
||||
option.t[str] link_name,
|
||||
&ast.fn_decl decl,
|
||||
vec[ast.ty_param] ty_params,
|
||||
def_id id, ann a) -> @native_item {
|
||||
ret @respan(sp, ast.native_item_fn(i, decl, ty_params, id, a));
|
||||
ret @respan(sp, ast.native_item_fn(i, link_name, decl, ty_params, id, a));
|
||||
}
|
||||
|
||||
fn identity_fold_item_mod[ENV](&ENV e, &span sp, ident i,
|
||||
|
@ -1576,7 +1579,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
|
|||
fold_item_const= bind identity_fold_item_const[ENV](_,_,_,_,_,_,_),
|
||||
fold_item_fn = bind identity_fold_item_fn[ENV](_,_,_,_,_,_,_),
|
||||
fold_native_item_fn =
|
||||
bind identity_fold_native_item_fn[ENV](_,_,_,_,_,_,_),
|
||||
bind identity_fold_native_item_fn[ENV](_,_,_,_,_,_,_,_),
|
||||
fold_item_mod = bind identity_fold_item_mod[ENV](_,_,_,_,_),
|
||||
fold_item_native_mod =
|
||||
bind identity_fold_item_native_mod[ENV](_,_,_,_,_),
|
||||
|
|
|
@ -240,7 +240,7 @@ fn lookup_name_wrapped(&env e, ast.ident i) -> option.t[tup(@env, def_wrap)] {
|
|||
case (ast.native_item_ty(_, ?id)) {
|
||||
ret def_wrap_other(ast.def_native_ty(id));
|
||||
}
|
||||
case (ast.native_item_fn(_, _, _, ?id, _)) {
|
||||
case (ast.native_item_fn(_, _, _, _, ?id, _)) {
|
||||
ret def_wrap_other(ast.def_native_fn(id));
|
||||
}
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ fn lookup_name_wrapped(&env e, ast.ident i) -> option.t[tup(@env, def_wrap)] {
|
|||
|
||||
case (scope_native_item(?it)) {
|
||||
alt (it.node) {
|
||||
case (ast.native_item_fn(_, ?decl, ?ty_params, _, _)) {
|
||||
case (ast.native_item_fn(_, _, ?decl, ?ty_params, _, _)) {
|
||||
ret handle_fn_decl(i, decl, ty_params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5409,7 +5409,7 @@ fn native_fn_ty_param_count(@crate_ctxt cx, &ast.def_id id) -> uint {
|
|||
"actually a fn?!");
|
||||
fail;
|
||||
}
|
||||
case (ast.native_item_fn(_, _, ?tps, _, _)) {
|
||||
case (ast.native_item_fn(_, _, _, ?tps, _, _)) {
|
||||
count = _vec.len[ast.ty_param](tps);
|
||||
}
|
||||
}
|
||||
|
@ -5499,7 +5499,7 @@ fn decl_native_fn_and_pair(@crate_ctxt cx,
|
|||
|
||||
fn collect_native_item(&@crate_ctxt cx, @ast.native_item i) -> @crate_ctxt {
|
||||
alt (i.node) {
|
||||
case (ast.native_item_fn(?name, _, _, ?fid, ?ann)) {
|
||||
case (ast.native_item_fn(?name, _, _, _, ?fid, ?ann)) {
|
||||
cx.native_items.insert(fid, i);
|
||||
if (! cx.obj_methods.contains_key(fid)) {
|
||||
decl_native_fn_and_pair(cx, name, ann, fid);
|
||||
|
|
|
@ -645,7 +645,7 @@ fn native_item_ty(@ast.native_item it) -> ty_params_and_ty {
|
|||
auto ty_params;
|
||||
auto result_ty;
|
||||
alt (it.node) {
|
||||
case (ast.native_item_fn(_, _, ?tps, _, ?ann)) {
|
||||
case (ast.native_item_fn(_, _, _, ?tps, _, ?ann)) {
|
||||
ty_params = tps;
|
||||
result_ty = ann_to_type(ann);
|
||||
}
|
||||
|
|
|
@ -442,7 +442,7 @@ fn ty_params_of_item(@ast.item item) -> vec[ast.ty_param] {
|
|||
|
||||
fn ty_params_of_native_item(@ast.native_item item) -> vec[ast.ty_param] {
|
||||
alt (item.node) {
|
||||
case (ast.native_item_fn(_, _, ?p, _, _)) {
|
||||
case (ast.native_item_fn(_, _, _, ?p, _, _)) {
|
||||
ret p;
|
||||
}
|
||||
case (_) {
|
||||
|
@ -623,7 +623,8 @@ fn collect_item_types(session.session sess, @ast.crate crate)
|
|||
@ast.native_item it,
|
||||
ast.native_abi abi) -> @ty.t {
|
||||
alt (it.node) {
|
||||
case (ast.native_item_fn(?ident, ?fn_decl, ?params, ?def_id, _)) {
|
||||
case (ast.native_item_fn(?ident, ?lname, ?fn_decl,
|
||||
?params, ?def_id, _)) {
|
||||
auto get = bind getter(id_to_ty_item, item_to_ty, _);
|
||||
auto convert = bind ast_ty_to_ty(get, _);
|
||||
auto f = bind ty_of_arg(id_to_ty_item, item_to_ty, _);
|
||||
|
@ -800,14 +801,14 @@ fn collect_item_types(session.session sess, @ast.crate crate)
|
|||
ret @fold.respan[ast.item_](sp, item);
|
||||
}
|
||||
|
||||
fn fold_native_item_fn(&@env e, &span sp, ast.ident i,
|
||||
fn fold_native_item_fn(&@env e, &span sp, ast.ident i, option.t[str] ln,
|
||||
&ast.fn_decl d, vec[ast.ty_param] ty_params,
|
||||
ast.def_id id, ast.ann a) -> @ast.native_item {
|
||||
collect_ty_params(e, id, ty_params);
|
||||
|
||||
check (e.item_to_ty.contains_key(id));
|
||||
auto typ = e.item_to_ty.get(id);
|
||||
auto item = ast.native_item_fn(i, d, ty_params, id,
|
||||
auto item = ast.native_item_fn(i, ln, d, ty_params, id,
|
||||
ast.ann_type(typ, none[vec[@ty.t]]));
|
||||
ret @fold.respan[ast.native_item_](sp, item);
|
||||
}
|
||||
|
@ -912,7 +913,7 @@ fn collect_item_types(session.session sess, @ast.crate crate)
|
|||
update_env_for_native_item = bind convert_native(_,_),
|
||||
fold_item_const = bind fold_item_const(_,_,_,_,_,_,_),
|
||||
fold_item_fn = bind fold_item_fn(_,_,_,_,_,_,_),
|
||||
fold_native_item_fn = bind fold_native_item_fn(_,_,_,_,_,_,_),
|
||||
fold_native_item_fn = bind fold_native_item_fn(_,_,_,_,_,_,_,_),
|
||||
fold_item_obj = bind fold_item_obj(_,_,_,_,_,_,_),
|
||||
fold_item_ty = bind fold_item_ty(_,_,_,_,_,_,_),
|
||||
fold_item_tag = bind fold_item_tag(_,_,_,_,_,_)
|
||||
|
|
|
@ -163,8 +163,12 @@ impure fn print_item(ps s, @ast.item item) {
|
|||
wrd1(s, "type");
|
||||
wrd(s, id);
|
||||
}
|
||||
case (ast.native_item_fn(?id,?decl,?typarams,_,_)) {
|
||||
case (ast.native_item_fn(?id,?lname,?decl,?typarams,_,_)) {
|
||||
print_fn(s, decl, id, typarams);
|
||||
alt (lname) {
|
||||
case (option.none[str]) {}
|
||||
case (option.some[str](?ss)) {print_string(s,ss);}
|
||||
}
|
||||
}
|
||||
}
|
||||
wrd(s, ";");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue