mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 13:07:48 +00:00
The only remaining explicit use of `typedef` in the codegen (from my search) is in `addForwardStructFormat` which from what I understand won't do anything in NIFC.
27 lines
869 B
Nim
27 lines
869 B
Nim
# XXX make complex ones like bitOr use builder instead
|
|
# XXX add stuff like NI, NIM_NIL as constants
|
|
|
|
proc ptrType(t: Snippet): Snippet =
|
|
t & "*"
|
|
|
|
const
|
|
CallingConvToStr: array[TCallingConvention, string] = ["N_NIMCALL",
|
|
"N_STDCALL", "N_CDECL", "N_SAFECALL",
|
|
"N_SYSCALL", # this is probably not correct for all platforms,
|
|
# but one can #define it to what one wants
|
|
"N_INLINE", "N_NOINLINE", "N_FASTCALL", "N_THISCALL", "N_CLOSURE", "N_NOCONV",
|
|
"N_NOCONV" #ccMember is N_NOCONV
|
|
]
|
|
|
|
proc procPtrType(conv: TCallingConvention, rettype: Snippet, name: string): Snippet =
|
|
CallingConvToStr[conv] & "_PTR(" & rettype & ", " & name & ")"
|
|
|
|
proc cCast(typ, value: Snippet): Snippet =
|
|
"((" & typ & ") " & value & ")"
|
|
|
|
proc cAddr(value: Snippet): Snippet =
|
|
"&" & value
|
|
|
|
proc bitOr(a, b: Snippet): Snippet =
|
|
"(" & a & " | " & b & ")"
|