diff options
author | Liran Ringel <liranringel@gmail.com> | 2017-10-09 02:38:29 +0200 |
---|---|---|
committer | Liran Ringel <liranringel@gmail.com> | 2017-10-10 01:43:01 +0200 |
commit | 9b95ce6a76d32a1c152bd3719d6cf46dd872b630 (patch) | |
tree | d3bcd25976112d1284367d7f8b93970fc1ed19c3 /src/codegen/mod.rs | |
parent | 745d60610ec6979368fc240472f7c04a3e04f282 (diff) |
Add support for the thiscall ABI
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r-- | src/codegen/mod.rs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index ea9fec41..ca982b6b 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -1945,6 +1945,10 @@ impl MethodCodegen for Method { _ => panic!("How in the world?"), }; + if let (Abi::ThisCall, false) = (signature.abi(), ctx.options().rust_features().thiscall_abi()) { + return; + } + // Do not generate variadic methods, since rust does not allow // implementing them, and we don't do a good job at it anyway. if signature.is_variadic() { @@ -3058,9 +3062,17 @@ impl TryToRustTy for FunctionSig { let arguments = utils::fnsig_arguments(ctx, &self); let abi = self.abi(); - Ok(quote! { - unsafe extern #abi fn ( #( #arguments ),* ) #ret - }) + match abi { + Abi::ThisCall if !ctx.options().rust_features().thiscall_abi() => { + warn!("Skipping function with thiscall ABI that isn't supported by the configured Rust target"); + Ok(quote::Tokens::new()) + } + _ => { + Ok(quote! { + unsafe extern #abi fn ( #( #arguments ),* ) #ret + }) + } + } } } @@ -3132,6 +3144,10 @@ impl CodeGenerator for Function { } let abi = match signature.abi() { + Abi::ThisCall if !ctx.options().rust_features().thiscall_abi() => { + warn!("Skipping function with thiscall ABI that isn't supported by the configured Rust target"); + return; + } Abi::Unknown(unknown_abi) => { panic!( "Invalid or unknown abi {:?} for function {:?} ({:?})", |