aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.c
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-04-17 12:01:04 +0100
committerGinger Bill <bill@gingerbill.org>2017-04-17 12:01:04 +0100
commit6d9fadf351d2e21e0afc357d698882c2c3198374 (patch)
tree5c517d91e470a35582b79789da83b4b4136fa886 /src/check_expr.c
parenta213061f333bdf3481d7b2c7d4bb29eacda5fb1a (diff)
Make the ABI changes only affect windows
TODO: decide upon rules for *nix systems
Diffstat (limited to 'src/check_expr.c')
-rw-r--r--src/check_expr.c76
1 files changed, 41 insertions, 35 deletions
diff --git a/src/check_expr.c b/src/check_expr.c
index c8a994426..afb8ce0c4 100644
--- a/src/check_expr.c
+++ b/src/check_expr.c
@@ -1016,44 +1016,50 @@ Type *check_get_results(Checker *c, Scope *scope, AstNode *_results) {
Type *type_to_abi_compat_param_type(gbAllocator a, Type *original_type) {
Type *new_type = original_type;
- // NOTE(bill): Changing the passing parameter value type is to match C's ABI
- // IMPORTANT TODO(bill): This only matches the ABI on MSVC at the moment
- // SEE: https://msdn.microsoft.com/en-us/library/zthk2dkh.aspx
- Type *bt = core_type(original_type);
- switch (bt->kind) {
- // Okay to pass by value
- // Especially the only Odin types
- case Type_Basic: break;
- case Type_Pointer: break;
- case Type_Proc: break; // NOTE(bill): Just a pointer
-
- // Odin only types
- case Type_Slice:
- case Type_DynamicArray:
- case Type_Map:
- break;
- // Odin specific
- case Type_Array:
- case Type_Vector:
- // Could be in C too
- case Type_Record: {
- i64 size = type_size_of(a, original_type);
- switch (8*size) {
- case 8: new_type = t_u8; break;
- case 16: new_type = t_u16; break;
- case 32: new_type = t_u32; break;
- case 64: new_type = t_u64; break;
- default:
- // NOTE(bill): It could be an empty struct that is passed
- // and if that is the case, no need to pass by pointer
- // (I think..)
- if (size > 0) {
- new_type = make_type_pointer(a, original_type);
- }
+ if (str_eq(build_context.ODIN_OS, str_lit("windows"))) {
+ // NOTE(bill): Changing the passing parameter value type is to match C's ABI
+ // IMPORTANT TODO(bill): This only matches the ABI on MSVC at the moment
+ // SEE: https://msdn.microsoft.com/en-us/library/zthk2dkh.aspx
+ Type *bt = core_type(original_type);
+ switch (bt->kind) {
+ // Okay to pass by value
+ // Especially the only Odin types
+ case Type_Basic: break;
+ case Type_Pointer: break;
+ case Type_Proc: break; // NOTE(bill): Just a pointer
+
+ // Odin only types
+ case Type_Slice:
+ case Type_DynamicArray:
+ case Type_Map:
break;
+
+ // Odin specific
+ case Type_Array:
+ case Type_Vector:
+ // Could be in C too
+ case Type_Record: {
+ i64 size = type_size_of(a, original_type);
+ switch (8*size) {
+ case 8: new_type = t_u8; break;
+ case 16: new_type = t_u16; break;
+ case 32: new_type = t_u32; break;
+ case 64: new_type = t_u64; break;
+ default:
+ // NOTE(bill): It could be an empty struct that is passed
+ // and if that is the case, no need to pass by pointer
+ // (I think..)
+ if (size > 0) {
+ new_type = make_type_pointer(a, original_type);
+ }
+ break;
+ }
+ } break;
}
- } break;
+ } else {
+ // IMPORTANT TODO(bill): figure out the ABI settings for Linux, OSX etc. for
+ // their architectures
}
return new_type;