Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follows up #24423, needed more refactoring than I expected, sorry for ugly diff.
With this pretty much all of the raw C code generating parts of the codegen are abstracted into the cbuilder API (to my knowledge at least). The current design of NIFC does not implement everything the codegen generates, such things have mostly not been adapted, they are the following along with how I'm guessing they could be implemented:
codegenDecl
pragma: Could be passed as a pragma to NIFCnimln_(123)
: Just inline them when generating NIFC#line
: Maybe as NIFC directives or line infos?#ifndef
when generating headers but NIFC shouldn't need italignof
/offsetof
: Is incbuilder
but not implemented in NIFC, should be easy Edit: Done nifc: add alignof & offsetof, make sizeof only take type nif#120For now we can disable C++ and the
codegenDecl
pragma when generating NIFC but since cbuilder is mostly designed to generate NIFC as a flag when booting the compiler, this hinders the ability to run the CI against NIFC. Maybe we could also make cbuilder able to generate both C and NIFC at runtime, this would be a large refactor but wouldn't be too difficult.Other missing abstractions before being able to generate NIFC are:
int
,void*
,NI
,NIM_NULL
are currently still constant string literals,NU8
,NU16
etc are also sometimes generated like"NU" & $bits
..c
to imported symbols and properly mangling generated ones. Not sure how difficult this is going to be.