gencpp/test/c_library/test_cuik.c

49 lines
1.5 KiB
C
Raw Normal View History

2024-12-16 15:28:26 -08:00
#define GEN_IMPLEMENTATION
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
#include "gen_singleheader.h"
#define gen_iterator( Type, container, iter ) \
gen_begin_ ## Type(container); \
iter != gen_end_ ## Type(container); \
code = gen_next_ ## Type(container, iter)
int main()
{
gen_Context ctx = {0};
gen_init(& ctx);
gen_register_macros( args(
((gen_Macro){ txt("USERN"), MT_Expression, MF_Functional }),
((gen_Macro){ txt("USERI"), MT_Expression, MF_Functional }),
((gen_Macro){ txt("USERI"), MT_Expression, MF_Functional }),
((gen_Macro){ txt("FOR_USERS"), MT_Statement, MF_Functional }),
((gen_Macro){ txt("FOR_SUCC"), MT_Statement, MF_Functional })
));
2024-12-16 17:54:19 -08:00
gen_CodeBody h_passes = gen_parse_file("Cuik/tb/opt/passes.h");
2024-12-16 15:28:26 -08:00
for (gen_Code code = gen_iterator(CodeBody, h_passes, code)) switch (code->Type) {
2024-12-16 17:54:19 -08:00
case CT_Function_Fwd:
2024-12-16 15:28:26 -08:00
case CT_Function:
2024-12-16 17:54:19 -08:00
gen_log_fmt("%S:\t%S RETURN_TYPE: %S PARAMS:%S\n"
2024-12-16 17:53:49 -08:00
, gen_codetype_to_str(code->Type)
, code->Name
, gen_strbuilder_to_str( gen_typename_to_strbuilder((gen_CodeTypename) code->ReturnType))
2024-12-16 17:54:19 -08:00
, gen_strbuilder_to_str( gen_params_to_strbuilder( (gen_CodeParams) code->Params))
2024-12-16 17:53:49 -08:00
);
break;
2024-12-16 15:28:26 -08:00
case CT_Variable:
2024-12-16 17:54:19 -08:00
gen_log_fmt("%S:\t%S Type:%S\n", gen_codetype_to_str(code->Type), code->Name, code->ValueType);
2024-12-16 17:53:49 -08:00
break;
2024-12-16 17:54:19 -08:00
case CT_Struct_Fwd:
2024-12-16 17:53:49 -08:00
case CT_Struct:
2024-12-16 15:28:26 -08:00
case CT_Typedef:
2024-12-16 17:54:19 -08:00
gen_log_fmt("%S: %S\n", gen_codetype_to_str(code->Type), code->Name);
2024-12-16 15:28:26 -08:00
break;
}
gen_deinit(& ctx);
return 0;
}