From f7d0c1cec3d65131cf4da273e6909ee97682dc42 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 28 Sep 2011 12:58:03 -0700 Subject: [PATCH] rustc: Add a new "C stack cdecl" native ABI --- src/comp/metadata/tydecode.rs | 1 + src/comp/metadata/tyencode.rs | 1 + src/comp/middle/trans.rs | 3 +++ src/comp/syntax/ast.rs | 1 + src/comp/syntax/parse/parser.rs | 6 +++++- src/comp/syntax/print/pprust.rs | 3 +++ 6 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/comp/metadata/tydecode.rs b/src/comp/metadata/tydecode.rs index 0e1a01b0e159..710fcc363d82 100644 --- a/src/comp/metadata/tydecode.rs +++ b/src/comp/metadata/tydecode.rs @@ -263,6 +263,7 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t { 'c' { abi = ast::native_abi_cdecl; } 'l' { abi = ast::native_abi_llvm; } 's' { abi = ast::native_abi_x86stdcall; } + 'C' { abi = ast::native_abi_c_stack_cdecl; } } let func = parse_ty_fn(st, sd); ret ty::mk_native_fn(st.tcx, abi, func.args, func.ty); diff --git a/src/comp/metadata/tyencode.rs b/src/comp/metadata/tyencode.rs index 7c3c396ec353..6f6da15a2c65 100644 --- a/src/comp/metadata/tyencode.rs +++ b/src/comp/metadata/tyencode.rs @@ -147,6 +147,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { native_abi_cdecl. { w.write_char('c'); } native_abi_llvm. { w.write_char('l'); } 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, []); } diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index d033c2334a7d..a74f358795e2 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -5715,6 +5715,9 @@ fn register_native_fn(ccx: @crate_ctxt, sp: span, path: [str], name: str, uses_retptr = false; cast_to_i32 = true; } + ast::native_abi_c_stack_cdecl. { + fail "C stack cdecl ABI shouldn't have a wrapper"; + } } let lltaskptr; diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs index 6dced2bf32a6..87d417d57013 100644 --- a/src/comp/syntax/ast.rs +++ b/src/comp/syntax/ast.rs @@ -419,6 +419,7 @@ tag native_abi { native_abi_llvm; native_abi_rust_intrinsic; native_abi_x86stdcall; + native_abi_c_stack_cdecl; } type native_mod = diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index b2a89a43ec53..8fa705d6418d 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -2012,7 +2012,11 @@ fn parse_item_native_mod(p: parser, attrs: [ast::attribute]) -> @ast::item { abi = ast::native_abi_rust_intrinsic; } else if str::eq(t, "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"); let id = parse_ident(p); diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index 458af7e9b12e..2b0bff104cdb 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -408,6 +408,9 @@ fn print_item(s: ps, item: @ast::item) { word_nbsp(s, "\"rust-intrinsic\""); } 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, item.ident);