rustc: Add a new "C stack cdecl" native ABI

This commit is contained in:
Patrick Walton 2011-09-28 12:58:03 -07:00
parent 657e3ffaf5
commit f7d0c1cec3
6 changed files with 14 additions and 1 deletions

View file

@ -263,6 +263,7 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t {
'c' { abi = ast::native_abi_cdecl; } 'c' { abi = ast::native_abi_cdecl; }
'l' { abi = ast::native_abi_llvm; } 'l' { abi = ast::native_abi_llvm; }
's' { abi = ast::native_abi_x86stdcall; } 's' { abi = ast::native_abi_x86stdcall; }
'C' { abi = ast::native_abi_c_stack_cdecl; }
} }
let func = parse_ty_fn(st, sd); let func = parse_ty_fn(st, sd);
ret ty::mk_native_fn(st.tcx, abi, func.args, func.ty); ret ty::mk_native_fn(st.tcx, abi, func.args, func.ty);

View file

@ -147,6 +147,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
native_abi_cdecl. { w.write_char('c'); } native_abi_cdecl. { w.write_char('c'); }
native_abi_llvm. { w.write_char('l'); } native_abi_llvm. { w.write_char('l'); }
native_abi_x86stdcall. { w.write_char('s'); } native_abi_x86stdcall. { w.write_char('s'); }
native_abi_c_stack_cdecl. { w.write_char('C'); }
} }
enc_ty_fn(w, cx, args, out, return_val, []); enc_ty_fn(w, cx, args, out, return_val, []);
} }

View file

@ -5715,6 +5715,9 @@ fn register_native_fn(ccx: @crate_ctxt, sp: span, path: [str], name: str,
uses_retptr = false; uses_retptr = false;
cast_to_i32 = true; cast_to_i32 = true;
} }
ast::native_abi_c_stack_cdecl. {
fail "C stack cdecl ABI shouldn't have a wrapper";
}
} }
let lltaskptr; let lltaskptr;

View file

@ -419,6 +419,7 @@ tag native_abi {
native_abi_llvm; native_abi_llvm;
native_abi_rust_intrinsic; native_abi_rust_intrinsic;
native_abi_x86stdcall; native_abi_x86stdcall;
native_abi_c_stack_cdecl;
} }
type native_mod = type native_mod =

View file

@ -2012,7 +2012,11 @@ fn parse_item_native_mod(p: parser, attrs: [ast::attribute]) -> @ast::item {
abi = ast::native_abi_rust_intrinsic; abi = ast::native_abi_rust_intrinsic;
} else if str::eq(t, "x86stdcall") { } else if str::eq(t, "x86stdcall") {
abi = ast::native_abi_x86stdcall; abi = ast::native_abi_x86stdcall;
} else { p.fatal("unsupported abi: " + t); } } else if str::eq(t, "c-stack-cdecl") {
abi = ast::native_abi_c_stack_cdecl;
} else {
p.fatal("unsupported abi: " + t);
}
} }
expect_word(p, "mod"); expect_word(p, "mod");
let id = parse_ident(p); let id = parse_ident(p);

View file

@ -408,6 +408,9 @@ fn print_item(s: ps, item: @ast::item) {
word_nbsp(s, "\"rust-intrinsic\""); word_nbsp(s, "\"rust-intrinsic\"");
} }
ast::native_abi_x86stdcall. { word_nbsp(s, "\"x86stdcall\""); } ast::native_abi_x86stdcall. { word_nbsp(s, "\"x86stdcall\""); }
ast::native_abi_c_stack_cdecl. {
word_nbsp(s, "\"c-stack-cdecl\"");
}
} }
word_nbsp(s, "mod"); word_nbsp(s, "mod");
word_nbsp(s, item.ident); word_nbsp(s, item.ident);