c variadic calls

This commit is contained in:
2026-06-14 15:53:45 +02:00
parent 638ca57f5c
commit 2d3d0bd266
21 changed files with 409 additions and 35 deletions
+28
View File
@@ -432,6 +432,34 @@ is_c_signature_type :: proc(value: Type, store: ^Store, allow_void := false) ->
return is_concrete_scalar(value) || is_pointer(value, store) || is_optional_pointer(value, store)
}
is_c_integer_promotion_candidate :: proc(value: Type) -> bool {
return value >= C_CHAR && value <= C_USHORT
}
c_vararg_promotion :: proc(value: Type, selected := target.DEFAULT) -> Type {
if !is_concrete_scalar(value) {
return value
}
if is_float(value, selected) && bits(value, selected) < bits(C_DOUBLE, selected) {
return C_DOUBLE
}
if is_concrete_integer(value) {
value_bits := bits(value, selected)
int_bits := bits(C_INT, selected)
if value_bits < int_bits {
return C_INT
}
if is_c_integer_promotion_candidate(value) && value_bits == int_bits {
return C_INT if is_signed(value, selected) else C_UINT
}
}
return value
}
is_c_vararg_type :: proc(value: Type, store: ^Store) -> bool {
return is_concrete_scalar(value) || is_pointer(value, store) || is_optional_pointer(value, store)
}
child_type :: proc(value: Type, store: ^Store) -> Type {
item, ok := node(store, value)
return item.child if ok else INVALID