infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
types.c
Go to the documentation of this file.
1
37#include "common/utility.h"
38#include <limits.h>
39#include <stdio.h>
40#include <stdlib.h>
41#include <string.h>
42// Static Descriptors for Primitive and Built-in Types
56#define INFIX_TYPE_INIT(id, T) \
57 {.name = nullptr, \
58 .category = INFIX_TYPE_PRIMITIVE, \
59 .size = sizeof(T), \
60 .alignment = _Alignof(T), \
61 .is_arena_allocated = false, \
62 .arena = nullptr, \
63 .meta.primitive_id = id}
69static infix_type _infix_type_void = {.name = nullptr,
70 .category = INFIX_TYPE_VOID,
71 .size = 0,
72 .alignment = 0,
73 .is_arena_allocated = false,
74 .arena = nullptr,
75 .meta = {0}};
81static infix_type _infix_type_pointer = {.name = nullptr,
82 .category = INFIX_TYPE_POINTER,
83 .size = sizeof(void *),
84 .alignment = _Alignof(void *),
85 .is_arena_allocated = false,
86 .arena = nullptr,
87 .meta.pointer_info = {.pointee_type = &_infix_type_void}};
106#if !defined(INFIX_COMPILER_MSVC)
111#endif
116#if defined(INFIX_COMPILER_MSVC) || (defined(INFIX_OS_WINDOWS) && defined(INFIX_COMPILER_CLANG)) || \
117 defined(INFIX_OS_MACOS)
118// On these platforms, long double is just an alias for double, so no separate singleton is needed.
119#else
122#endif
123// Public API: Type Creation Functions
131 switch (id) {
133 return &_infix_type_bool;
135 return &_infix_type_uint8;
137 return &_infix_type_sint8;
139 return &_infix_type_uint16;
141 return &_infix_type_sint16;
143 return &_infix_type_uint32;
145 return &_infix_type_sint32;
147 return &_infix_type_uint64;
149 return &_infix_type_sint64;
150#if !defined(INFIX_COMPILER_MSVC)
152 return &_infix_type_uint128;
154 return &_infix_type_sint128;
155#endif
157 return &_infix_type_float;
159 return &_infix_type_double;
161#if defined(INFIX_COMPILER_MSVC) || (defined(INFIX_OS_WINDOWS) && defined(INFIX_COMPILER_CLANG)) || \
162 defined(INFIX_OS_MACOS)
163 // On platforms where long double is just an alias for double, return the double singleton
164 // to maintain consistent type representation.
165 return &_infix_type_double;
166#else
168#endif
169 default:
170 // Return null for any invalid primitive ID.
171 return nullptr;
172 }
173}
191infix_struct_member infix_type_create_member(const char * name, infix_type * type, size_t offset) {
192 return (infix_struct_member){name, type, offset, 0, 0, false};
193}
203 infix_type * type,
204 size_t offset,
205 uint8_t bit_width) {
206 return (infix_struct_member){name, type, offset, bit_width, 0, true};
207}
208
214static bool _layout_struct(infix_type * type) {
215 size_t current_byte_offset = 0;
216 uint8_t current_bit_offset = 0; // 0-7 bits used in the current byte
217 size_t max_alignment = 1;
218
219 for (size_t i = 0; i < type->meta.aggregate_info.num_members; ++i) {
220 infix_struct_member * member = &type->meta.aggregate_info.members[i];
221
222 // 1. Handle Flexible Array Members (FAM)
223 if (member->type->category == INFIX_TYPE_ARRAY && member->type->meta.array_info.is_flexible) {
224 // Flush any pending bits to the next byte
225 if (current_bit_offset > 0) {
226 if (current_byte_offset == SIZE_MAX) {
228 return false;
229 }
230 current_byte_offset++;
231 current_bit_offset = 0;
232 }
233
234 // FAM aligns according to its element type.
235 size_t member_align = member->type->alignment;
236 if (member_align == 0)
237 member_align = 1;
238
239 size_t aligned = _infix_align_up(current_byte_offset, member_align);
240 if (aligned < current_byte_offset) {
242 return false;
243 }
244 current_byte_offset = aligned;
245 member->offset = current_byte_offset;
246
247 if (member_align > max_alignment)
248 max_alignment = member_align;
249 continue; // FAM logic done
250 }
251
252 // 2. Handle Bitfields
253 if (member->is_bitfield) {
254 // Zero-width bitfield: force alignment to the next boundary of the declared type.
255 if (member->bit_width == 0) {
256 if (current_bit_offset > 0) {
257 if (current_byte_offset == SIZE_MAX) {
259 return false;
260 }
261 current_byte_offset++;
262 current_bit_offset = 0;
263 }
264 size_t align = member->type->alignment;
265 if (align == 0)
266 align = 1;
267
268 size_t aligned = _infix_align_up(current_byte_offset, align);
269 if (aligned < current_byte_offset) {
271 return false;
272 }
273 current_byte_offset = aligned;
274 member->offset = current_byte_offset;
275 member->bit_offset = 0;
276
277 if (align > max_alignment)
278 max_alignment = align;
279 continue;
280 }
281
282 // Standard Bitfield
283 // Simplified System V packing: pack into current byte if it fits.
284 if (current_bit_offset + member->bit_width > 8) {
285 // Overflow: move to start of next byte
286 if (current_byte_offset == SIZE_MAX) {
288 return false;
289 }
290 current_byte_offset++;
291 current_bit_offset = 0;
292 }
293
294 member->offset = current_byte_offset;
295 member->bit_offset = current_bit_offset;
296 current_bit_offset += member->bit_width;
297
298 // If we filled the byte exactly, advance to next byte
299 if (current_bit_offset == 8) {
300 if (current_byte_offset == SIZE_MAX) {
302 return false;
303 }
304 current_byte_offset++;
305 current_bit_offset = 0;
306 }
307
308 // Update struct alignment. Bitfields typically impose the alignment of their base type.
309 size_t align = member->type->alignment;
310 if (align == 0)
311 align = 1;
312 if (align > max_alignment)
313 max_alignment = align;
314 }
315 else {
316 // 3. Standard Member
317
318 // Flush bits first
319 if (current_bit_offset > 0) {
320 if (current_byte_offset == SIZE_MAX) {
322 return false;
323 }
324 current_byte_offset++;
325 current_bit_offset = 0;
326 }
327
328 size_t member_align = member->type->alignment;
329 if (member_align == 0)
330 member_align = 1;
331
332 if (member_align > max_alignment)
333 max_alignment = member_align;
334
335 size_t aligned = _infix_align_up(current_byte_offset, member_align);
336 if (aligned < current_byte_offset) {
338 return false;
339 }
340 current_byte_offset = aligned;
341 member->offset = current_byte_offset;
342
343 if (current_byte_offset > SIZE_MAX - member->type->size) {
345 return false;
346 }
347 current_byte_offset += member->type->size;
348 }
349 }
350
351 // Final flush
352 if (current_bit_offset > 0)
353 current_byte_offset++;
354
355 // If it is packed, the alignment is explicitly determined by the user (defaulting to 1
356 // if not specified in the syntax). We must respect this value absolutely, ignoring
357 // the natural alignment of members.
358 if (type->meta.aggregate_info.is_packed)
359 max_alignment = type->alignment;
360
361 type->alignment = max_alignment;
362 type->size = _infix_align_up(current_byte_offset, max_alignment);
363 return true;
364}
383 infix_type ** out_type,
384 infix_struct_member ** out_arena_members,
386 size_t num_members) {
387 if (out_type == nullptr)
389 // Pre-flight check: ensure all provided member types are valid.
390 for (size_t i = 0; i < num_members; ++i) {
391 if (members[i].type == nullptr) {
392 *out_type = nullptr;
395 }
396 }
397 infix_type * type = infix_arena_calloc(arena, 1, sizeof(infix_type), _Alignof(infix_type));
398 if (type == nullptr) {
399 *out_type = nullptr;
402 }
403 infix_struct_member * arena_members = nullptr;
404 if (num_members > 0) {
405 arena_members =
406 infix_arena_alloc(arena, sizeof(infix_struct_member) * num_members, _Alignof(infix_struct_member));
407 if (arena_members == nullptr) {
408 *out_type = nullptr;
411 }
412 infix_memcpy(arena_members, members, sizeof(infix_struct_member) * num_members);
413 }
414 *out_type = type;
415 *out_arena_members = arena_members;
416 return INFIX_SUCCESS;
417}
426 infix_type ** out_type,
427 infix_type * pointee_type) {
428 if (!out_type || !pointee_type) {
431 }
432 infix_type * type = infix_arena_calloc(arena, 1, sizeof(infix_type), _Alignof(infix_type));
433 if (type == nullptr) {
434 *out_type = nullptr;
437 }
438 // Start by copying the layout of a generic pointer.
439 *type = *infix_type_create_pointer();
440 // Mark it as arena-allocated so it can be deep-copied and freed correctly.
441 type->is_arena_allocated = true;
442 // Set the specific pointee type.
443 type->meta.pointer_info.pointee_type = pointee_type;
444 *out_type = type;
445 return INFIX_SUCCESS;
446}
456 infix_type ** out_type,
457 infix_type * element_type,
458 size_t num_elements) {
459 if (out_type == nullptr || element_type == nullptr) {
462 }
463 if (element_type->size > 0 && num_elements > SIZE_MAX / element_type->size) {
464 *out_type = nullptr;
467 }
468 infix_type * type = infix_arena_calloc(arena, 1, sizeof(infix_type), _Alignof(infix_type));
469 if (type == nullptr) {
470 *out_type = nullptr;
473 }
474 type->is_arena_allocated = true;
476 type->meta.array_info.element_type = element_type;
477 type->meta.array_info.num_elements = num_elements;
478 type->meta.array_info.is_flexible = false;
479 // An array's alignment is the same as its element's alignment.
480 type->alignment = element_type->alignment;
481 type->size = element_type->size * num_elements;
482 *out_type = type;
483 return INFIX_SUCCESS;
484}
485
494 infix_type ** out_type,
495 infix_type * element_type) {
496 if (out_type == nullptr || element_type == nullptr) {
499 }
500 // Flexible arrays of incomplete types (size 0) are generally not allowed.
501 if (element_type->category == INFIX_TYPE_VOID || element_type->size == 0) {
502 *out_type = nullptr;
505 }
506
507 infix_type * type = infix_arena_calloc(arena, 1, sizeof(infix_type), _Alignof(infix_type));
508 if (type == nullptr) {
509 *out_type = nullptr;
512 }
513 type->is_arena_allocated = true;
515 type->meta.array_info.element_type = element_type;
516 type->meta.array_info.num_elements = 0;
517 type->meta.array_info.is_flexible = true; // Mark as flexible
518
519 // A flexible array member itself has size 0 within the struct (it hangs off the end).
520 // However, its alignment requirement affects the struct.
521 type->alignment = element_type->alignment;
522 type->size = 0;
523
524 *out_type = type;
525 return INFIX_SUCCESS;
526}
527
537 infix_type ** out_type,
538 infix_type * underlying_type) {
539 if (out_type == nullptr || underlying_type == nullptr) {
542 }
543 if (underlying_type->category != INFIX_TYPE_PRIMITIVE ||
544 underlying_type->meta.primitive_id > INFIX_PRIMITIVE_SINT128) {
547 }
548 infix_type * type = infix_arena_calloc(arena, 1, sizeof(infix_type), _Alignof(infix_type));
549 if (type == nullptr) {
550 *out_type = nullptr;
553 }
554 type->is_arena_allocated = true;
556 // An enum has the same memory layout as its underlying integer type.
557 type->size = underlying_type->size;
558 type->alignment = underlying_type->alignment;
559 type->meta.enum_info.underlying_type = underlying_type;
560 *out_type = type;
561 return INFIX_SUCCESS;
562}
571 infix_type ** out_type,
572 infix_type * base_type) {
573 if (out_type == nullptr || base_type == nullptr || (!is_float(base_type) && !is_double(base_type))) {
576 }
577 infix_type * type = infix_arena_calloc(arena, 1, sizeof(infix_type), _Alignof(infix_type));
578 if (type == nullptr) {
579 *out_type = nullptr;
582 }
583 type->is_arena_allocated = true;
585 // A complex number is simply two floating-point numbers back-to-back.
586 type->size = base_type->size * 2;
587 type->alignment = base_type->alignment;
588 type->meta.complex_info.base_type = base_type;
589 *out_type = type;
590 return INFIX_SUCCESS;
591}
601 infix_type ** out_type,
602 infix_type * element_type,
603 size_t num_elements) {
604 if (out_type == nullptr || element_type == nullptr || element_type->category != INFIX_TYPE_PRIMITIVE) {
607 }
608 if (element_type->size > 0 && num_elements > SIZE_MAX / element_type->size) {
609 *out_type = nullptr;
612 }
613 infix_type * type = infix_arena_calloc(arena, 1, sizeof(infix_type), _Alignof(infix_type));
614 if (type == nullptr) {
615 *out_type = nullptr;
618 }
619 type->is_arena_allocated = true;
621 type->meta.vector_info.element_type = element_type;
622 type->meta.vector_info.num_elements = num_elements;
623 type->size = element_type->size * num_elements;
624 // Vector alignment is typically its total size, up to a platform-specific maximum (e.g., 16 on x64).
625 // This is a simplification; the ABI-specific classifiers will handle the true alignment rules.
626 type->alignment = type->size > 8 ? 16 : type->size;
627 *out_type = type;
628 return INFIX_SUCCESS;
629}
639 infix_type ** out_type,
641 size_t num_members) {
642 infix_type * type = nullptr;
643 infix_struct_member * arena_members = nullptr;
644 infix_status status = _create_aggregate_setup(arena, &type, &arena_members, members, num_members);
645 if (status != INFIX_SUCCESS) {
646 *out_type = nullptr;
647 return status;
648 }
649 type->is_arena_allocated = true;
651 type->meta.aggregate_info.members = arena_members;
652 type->meta.aggregate_info.num_members = num_members;
653 type->meta.aggregate_info.is_packed = false; // Unions don't use this flag currently
654 // A union's size is the size of its largest member, and its alignment is the
655 // alignment of its most-aligned member.
656 size_t max_size = 0;
657 size_t max_alignment = 1;
658 for (size_t i = 0; i < num_members; ++i) {
659 arena_members[i].offset = 0; // All union members have an offset of 0.
660 if (arena_members[i].type->size > max_size)
661 max_size = arena_members[i].type->size;
662 if (arena_members[i].type->alignment > max_alignment)
663 max_alignment = arena_members[i].type->alignment;
664 }
665 type->alignment = max_alignment;
666 // The total size is the size of the largest member, padded up to the required alignment.
667 type->size = _infix_align_up(max_size, max_alignment);
668 // Overflow check
669 if (type->size < max_size) {
670 *out_type = nullptr;
673 }
674 *out_type = type;
675 return INFIX_SUCCESS;
676}
686 infix_type ** out_type,
688 size_t num_members) {
690 infix_type * type = nullptr;
691 infix_struct_member * arena_members = nullptr;
692 infix_status status = _create_aggregate_setup(arena, &type, &arena_members, members, num_members);
693 if (status != INFIX_SUCCESS) {
694 *out_type = nullptr;
695 return status;
696 }
697 type->is_arena_allocated = true;
699 type->meta.aggregate_info.members = arena_members;
700 type->meta.aggregate_info.num_members = num_members;
701 type->meta.aggregate_info.is_packed = false;
702
703 // This performs a preliminary layout calculation.
704 // Note: This layout may be incomplete if it contains unresolved named references or flexible arrays.
705 // The final, correct layout will be computed by `_infix_type_recalculate_layout`.
706 // However, we must set a preliminary size/alignment here.
707
708 // We use the recalculate logic to do the heavy lifting, assuming a temporary arena can be made.
709 // But we can't create an arena here easily if we are in a strict context.
710 // So we do a simplified pass just like the old logic, ignoring complex bitfield rules for now.
711 // The proper bitfield layout happens in `_infix_type_recalculate_layout`.
712
713 for (size_t i = 0; i < num_members; ++i) {
714 infix_struct_member * member = &arena_members[i];
715 if (member->type->alignment == 0 && member->type->category != INFIX_TYPE_NAMED_REFERENCE &&
716 !(member->type->category == INFIX_TYPE_ARRAY && member->type->meta.array_info.is_flexible)) {
717 if (member->type->category != INFIX_TYPE_ARRAY) {
718 *out_type = nullptr;
721 }
722 }
723 }
724
725 // Calculate Layout (including bitfields and FAMs)
726 if (!_layout_struct(type)) {
727 *out_type = nullptr;
729 }
730
731 *out_type = type;
732 return INFIX_SUCCESS;
733}
745 infix_type ** out_type,
746 size_t total_size,
747 size_t alignment,
749 size_t num_members) {
750 if (out_type == nullptr || (num_members > 0 && members == nullptr) || alignment == 0) {
753 }
754 infix_type * type = infix_arena_calloc(arena, 1, sizeof(infix_type), _Alignof(infix_type));
755 if (type == nullptr) {
756 *out_type = nullptr;
759 }
760 infix_struct_member * arena_members = nullptr;
761 if (num_members > 0) {
762 arena_members =
763 infix_arena_alloc(arena, sizeof(infix_struct_member) * num_members, _Alignof(infix_struct_member));
764 if (arena_members == nullptr) {
765 *out_type = nullptr;
768 }
769 infix_memcpy(arena_members, members, sizeof(infix_struct_member) * num_members);
770 }
771 type->is_arena_allocated = true;
772 type->size = total_size;
773 type->alignment = alignment;
774 type->category = INFIX_TYPE_STRUCT; // Packed structs are still fundamentally structs.
775 type->meta.aggregate_info.members = arena_members;
776 type->meta.aggregate_info.num_members = num_members;
777 type->meta.aggregate_info.is_packed = true; // Marked as packed
778 *out_type = type;
779 return INFIX_SUCCESS;
780}
793 infix_type ** out_type,
794 const char * name,
796 if (out_type == nullptr || name == nullptr) {
799 }
800 infix_type * type = infix_arena_calloc(arena, 1, sizeof(infix_type), _Alignof(infix_type));
801 if (type == nullptr) {
802 *out_type = nullptr;
805 }
806 // The name must be copied into the arena to ensure its lifetime matches the type's.
807 size_t name_len = strlen(name) + 1;
808 char * arena_name = infix_arena_alloc(arena, name_len, 1);
809 if (arena_name == nullptr) {
810 *out_type = nullptr;
813 }
814 infix_memcpy(arena_name, name, name_len);
815 type->is_arena_allocated = true;
817 type->size = 0; // Size and alignment are unknown until resolution.
818 type->alignment = 1; // Default to 1 to be safe in preliminary layout calculations.
819 type->meta.named_reference.name = arena_name;
821 *out_type = type;
822 return INFIX_SUCCESS;
823}
824// Internal Type Graph Management
865 recalc_visited_node_t ** visited_head) {
866 if (!type || !type->is_arena_allocated)
867 return; // Base case: Don't modify static singleton types.
868 // Cycle detection: If we have already visited this node in the current recursion
869 // path, we are in a cycle. Return immediately to break the loop. The layout of
870 // this node will be calculated when the recursion unwinds to its first visit.
871 for (recalc_visited_node_t * v = *visited_head; v != nullptr; v = v->next)
872 if (v->type == type)
873 return;
874 // Allocate the memoization node from a stable temporary arena.
875 recalc_visited_node_t * visited_node =
876 infix_arena_alloc(temp_arena, sizeof(recalc_visited_node_t), _Alignof(recalc_visited_node_t));
877 if (!visited_node)
878 return; // Cannot proceed without memory.
879 visited_node->type = type;
880 visited_node->next = *visited_head;
881 *visited_head = visited_node;
882 // Recurse into child types first (post-order traversal).
883 switch (type->category) {
886 break;
887 case INFIX_TYPE_ARRAY:
889 break;
891 case INFIX_TYPE_UNION:
892 for (size_t i = 0; i < type->meta.aggregate_info.num_members; ++i) {
894 temp_arena, type->meta.aggregate_info.members[i].type, visited_head);
895 }
896 break;
897 default:
898 break; // Other types have no child types to recurse into.
899 }
900 // After children are updated, recalculate this type's layout.
903 else if (type->category == INFIX_TYPE_UNION) {
904 size_t max_size = 0;
905 size_t max_alignment = 1;
906 for (size_t i = 0; i < type->meta.aggregate_info.num_members; ++i) {
907 infix_type * member_type = type->meta.aggregate_info.members[i].type;
908 if (member_type->size > max_size)
909 max_size = member_type->size;
910 if (member_type->alignment > max_alignment)
911 max_alignment = member_type->alignment;
912 }
913 type->alignment = max_alignment;
914 type->size = _infix_align_up(max_size, max_alignment);
915 }
916 else if (type->category == INFIX_TYPE_ARRAY) {
917 // Flexible arrays have size 0 but inherit alignment.
918 // Fixed arrays calculate size normally.
921 type->size = 0;
922 }
923 else {
926 }
927 }
928}
939 // Create a temporary arena solely for the visited list's lifetime.
940 infix_arena_t * temp_arena = infix_arena_create(1024);
941 if (!temp_arena)
942 return;
943 recalc_visited_node_t * visited_head = nullptr;
944 _infix_type_recalculate_layout_recursive(temp_arena, type, &visited_head);
945 infix_arena_destroy(temp_arena);
946}
975 const infix_type * src_type,
976 memo_node_t ** memo_head) {
977 if (src_type == nullptr)
978 return nullptr;
979 // If the source type lives in the same arena as our destination, we can safely share the pointer instead of
980 // performing a deep copy.
981 if (src_type->arena == dest_arena)
982 return (infix_type *)src_type;
983 // Base case: Static types don't need to be copied; return the singleton pointer.
984 if (!src_type->is_arena_allocated)
985 return (infix_type *)src_type;
986 // Check memoization table: if we've already copied this node, return the existing copy.
987 // This correctly handles cycles and shared sub-graphs.
988 for (memo_node_t * node = *memo_head; node != NULL; node = node->next)
989 if (node->src == src_type)
990 return node->dest;
991 // Allocate the new type object in the destination arena.
992 infix_type * dest_type = infix_arena_calloc(dest_arena, 1, sizeof(infix_type), _Alignof(infix_type));
993 if (dest_type == nullptr)
994 return nullptr;
995 // Add this new pair to the memoization table BEFORE recursing. This is crucial
996 // for handling cycles: the recursive call will find this entry and return `dest_type`.
997 memo_node_t * new_memo_node = infix_arena_alloc(dest_arena, sizeof(memo_node_t), _Alignof(memo_node_t));
998 if (!new_memo_node)
999 return nullptr;
1000 new_memo_node->src = src_type;
1001 new_memo_node->dest = dest_type;
1002 new_memo_node->next = *memo_head;
1003 *memo_head = new_memo_node;
1004 // Perform a shallow copy of the main struct, then recurse to deep copy child pointers.
1005 *dest_type = *src_type;
1006 dest_type->is_arena_allocated = true;
1007 dest_type->arena = dest_arena; // The new type now belongs to the destination arena.
1008 // Deep copy the semantic name string, if it exists.
1009 if (src_type->name) {
1010 size_t name_len = strlen(src_type->name) + 1;
1011 char * dest_name = infix_arena_alloc(dest_arena, name_len, 1);
1012 if (!dest_name)
1013 return nullptr; // Allocation failed
1014 infix_memcpy((void *)dest_name, src_type->name, name_len);
1015 dest_type->name = dest_name;
1016 }
1017 switch (src_type->category) {
1018 case INFIX_TYPE_POINTER:
1019 dest_type->meta.pointer_info.pointee_type =
1020 _copy_type_graph_to_arena_recursive(dest_arena, src_type->meta.pointer_info.pointee_type, memo_head);
1021 break;
1022 case INFIX_TYPE_ARRAY:
1023 dest_type->meta.array_info.element_type =
1024 _copy_type_graph_to_arena_recursive(dest_arena, src_type->meta.array_info.element_type, memo_head);
1025 // Explicitly copy the flexible flag to ensure it persists.
1026 dest_type->meta.array_info.is_flexible = src_type->meta.array_info.is_flexible;
1027 break;
1028 case INFIX_TYPE_STRUCT:
1029 case INFIX_TYPE_UNION:
1030 if (src_type->meta.aggregate_info.num_members > 0) {
1031 // Copy the members array itself.
1032 size_t members_size = sizeof(infix_struct_member) * src_type->meta.aggregate_info.num_members;
1033 dest_type->meta.aggregate_info.members =
1034 infix_arena_alloc(dest_arena, members_size, _Alignof(infix_struct_member));
1035 if (dest_type->meta.aggregate_info.members == nullptr)
1036 return nullptr;
1037 dest_type->meta.aggregate_info.is_packed = src_type->meta.aggregate_info.is_packed; // Copy packed flag
1038 // Now, recurse for each member's type and copy its name.
1039 for (size_t i = 0; i < src_type->meta.aggregate_info.num_members; ++i) {
1040 dest_type->meta.aggregate_info.members[i] = src_type->meta.aggregate_info.members[i];
1042 dest_arena, src_type->meta.aggregate_info.members[i].type, memo_head);
1043 const char * src_name = src_type->meta.aggregate_info.members[i].name;
1044 if (src_name) {
1045 size_t name_len = strlen(src_name) + 1;
1046 char * dest_name = infix_arena_alloc(dest_arena, name_len, 1);
1047 if (!dest_name)
1048 return nullptr;
1049 infix_memcpy((void *)dest_name, src_name, name_len);
1050 dest_type->meta.aggregate_info.members[i].name = dest_name;
1051 }
1052 // Copy bitfield properties
1053 dest_type->meta.aggregate_info.members[i].bit_width =
1054 src_type->meta.aggregate_info.members[i].bit_width;
1055 dest_type->meta.aggregate_info.members[i].bit_offset =
1057 dest_type->meta.aggregate_info.members[i].is_bitfield =
1059 }
1060 }
1061 break;
1063 {
1064 const char * src_name = src_type->meta.named_reference.name;
1065 if (src_name) {
1066 size_t name_len = strlen(src_name) + 1;
1067 char * dest_name = infix_arena_alloc(dest_arena, name_len, 1);
1068 if (!dest_name)
1069 return nullptr;
1070 infix_memcpy((void *)dest_name, src_name, name_len);
1071 dest_type->meta.named_reference.name = dest_name;
1072 }
1073 break;
1074 }
1076 dest_type->meta.func_ptr_info.return_type =
1077 _copy_type_graph_to_arena_recursive(dest_arena, src_type->meta.func_ptr_info.return_type, memo_head);
1078 if (src_type->meta.func_ptr_info.num_args > 0) {
1079 size_t args_size = sizeof(infix_function_argument) * src_type->meta.func_ptr_info.num_args;
1080 dest_type->meta.func_ptr_info.args =
1081 infix_arena_alloc(dest_arena, args_size, _Alignof(infix_function_argument));
1082 if (dest_type->meta.func_ptr_info.args == nullptr)
1083 return nullptr;
1084 for (size_t i = 0; i < src_type->meta.func_ptr_info.num_args; ++i) {
1085 dest_type->meta.func_ptr_info.args[i] = src_type->meta.func_ptr_info.args[i];
1087 dest_arena, src_type->meta.func_ptr_info.args[i].type, memo_head);
1088 const char * src_name = src_type->meta.func_ptr_info.args[i].name;
1089 if (src_name) {
1090 size_t name_len = strlen(src_name) + 1;
1091 char * dest_name = infix_arena_alloc(dest_arena, name_len, 1);
1092 if (!dest_name)
1093 return nullptr;
1094 infix_memcpy((void *)dest_name, src_name, name_len);
1095 dest_type->meta.func_ptr_info.args[i].name = dest_name;
1096 }
1097 }
1098 }
1099 break;
1100 case INFIX_TYPE_ENUM:
1101 dest_type->meta.enum_info.underlying_type =
1102 _copy_type_graph_to_arena_recursive(dest_arena, src_type->meta.enum_info.underlying_type, memo_head);
1103 break;
1104 case INFIX_TYPE_COMPLEX:
1105 dest_type->meta.complex_info.base_type =
1106 _copy_type_graph_to_arena_recursive(dest_arena, src_type->meta.complex_info.base_type, memo_head);
1107 break;
1108 case INFIX_TYPE_VECTOR:
1109 dest_type->meta.vector_info.element_type =
1110 _copy_type_graph_to_arena_recursive(dest_arena, src_type->meta.vector_info.element_type, memo_head);
1111 break;
1112 default:
1113 // Other types like primitives have no child pointers to copy.
1114 break;
1115 }
1116 return dest_type;
1117}
1126 memo_node_t * memo_head = nullptr;
1127 return _copy_type_graph_to_arena_recursive(dest_arena, src_type, &memo_head);
1128}
1151 const infix_type * type,
1152 estimate_visited_node_t ** visited_head) {
1153 if (!type || !type->is_arena_allocated)
1154 return 0;
1155 // Cycle detection: if we've seen this node, it's already accounted for.
1156 for (estimate_visited_node_t * v = *visited_head; v != NULL; v = v->next)
1157 if (v->type == type)
1158 return 0;
1159 // Add this node to the visited list before recursing.
1160 estimate_visited_node_t * visited_node =
1162 if (!visited_node) {
1163 // On allocation failure, we can't proceed with estimation. Return a large
1164 // number to ensure the caller allocates a fallback-sized arena.
1165 return 65536;
1166 }
1167 visited_node->type = type;
1168 visited_node->next = *visited_head;
1169 *visited_head = visited_node;
1170 // The size includes the type object itself, a memoization node, and the name string if it exists.
1171 size_t total_size = sizeof(infix_type) + sizeof(memo_node_t);
1172 if (type->name)
1173 total_size += strlen(type->name) + 1;
1174 switch (type->category) {
1175 case INFIX_TYPE_POINTER:
1176 total_size += _estimate_graph_size_recursive(temp_arena, type->meta.pointer_info.pointee_type, visited_head);
1177 break;
1178 case INFIX_TYPE_ARRAY:
1179 total_size += _estimate_graph_size_recursive(temp_arena, type->meta.array_info.element_type, visited_head);
1180 break;
1181 case INFIX_TYPE_STRUCT:
1182 case INFIX_TYPE_UNION:
1184 total_size += sizeof(infix_struct_member) * type->meta.aggregate_info.num_members;
1185 for (size_t i = 0; i < type->meta.aggregate_info.num_members; ++i) {
1186 const infix_struct_member * member = &type->meta.aggregate_info.members[i];
1187 if (member->name)
1188 total_size += strlen(member->name) + 1;
1189 total_size += _estimate_graph_size_recursive(temp_arena, member->type, visited_head);
1190 }
1191 }
1192 break;
1195 total_size += strlen(type->meta.named_reference.name) + 1;
1196 break;
1198 total_size += _estimate_graph_size_recursive(temp_arena, type->meta.func_ptr_info.return_type, visited_head);
1199 if (type->meta.func_ptr_info.num_args > 0) {
1200 total_size += sizeof(infix_function_argument) * type->meta.func_ptr_info.num_args;
1201 for (size_t i = 0; i < type->meta.func_ptr_info.num_args; ++i) {
1203 if (arg->name)
1204 total_size += strlen(arg->name) + 1;
1205 total_size += _estimate_graph_size_recursive(temp_arena, arg->type, visited_head);
1206 }
1207 }
1208 break;
1209 case INFIX_TYPE_ENUM:
1210 total_size += _estimate_graph_size_recursive(temp_arena, type->meta.enum_info.underlying_type, visited_head);
1211 break;
1212 case INFIX_TYPE_COMPLEX:
1213 total_size += _estimate_graph_size_recursive(temp_arena, type->meta.complex_info.base_type, visited_head);
1214 break;
1215 case INFIX_TYPE_VECTOR:
1216 total_size += _estimate_graph_size_recursive(temp_arena, type->meta.vector_info.element_type, visited_head);
1217 break;
1218 default:
1219 break;
1220 }
1221 return total_size;
1222}
1231 if (!temp_arena || !type)
1232 return 0;
1233 estimate_visited_node_t * visited_head = NULL;
1234 return _estimate_graph_size_recursive(temp_arena, type, &visited_head);
1235}
1236// Public API: Introspection Functions
1244 if (type == nullptr)
1245 return nullptr;
1246 return type->name;
1247}
1288 return nullptr;
1289 return &type->meta.aggregate_info.members[index];
1290}
1298c23_nodiscard const char * infix_type_get_arg_name(const infix_type * func_type, size_t index) {
1299 if (!func_type || func_type->category != INFIX_TYPE_REVERSE_TRAMPOLINE ||
1300 index >= func_type->meta.func_ptr_info.num_args)
1301 return nullptr;
1302 return func_type->meta.func_ptr_info.args[index].name;
1303}
1310c23_nodiscard const infix_type * infix_type_get_arg_type(const infix_type * func_type, size_t index) {
1311 if (!func_type || func_type->category != INFIX_TYPE_REVERSE_TRAMPOLINE ||
1312 index >= func_type->meta.func_ptr_info.num_args)
1313 return nullptr;
1314 return func_type->meta.func_ptr_info.args[index].type;
1315}
1322 return trampoline ? trampoline->num_args : 0;
1323}
1330 return trampoline ? trampoline->num_fixed_args : 0;
1331}
1338 return trampoline ? trampoline->return_type : nullptr;
1339}
1346c23_nodiscard const infix_type * infix_forward_get_arg_type(const infix_forward_t * trampoline, size_t index) {
1347 if (!trampoline || index >= trampoline->num_args)
1348 return nullptr;
1349 return trampoline->arg_types[index];
1350}
1357 return trampoline ? trampoline->num_args : 0;
1358}
1365 return trampoline ? trampoline->num_fixed_args : 0;
1366}
1373 return trampoline ? trampoline->return_type : nullptr;
1374}
1381c23_nodiscard const infix_type * infix_reverse_get_arg_type(const infix_reverse_t * trampoline, size_t index) {
1382 if (!trampoline || index >= trampoline->num_args)
1383 return nullptr;
1384 return trampoline->arg_types[index];
1385}
infix_arena_t * arena
Definition 005_layouts.c:60
infix_status status
Definition 103_unions.c:59
infix_struct_member * members
Definition 103_unions.c:53
#define c23_nodiscard
A compatibility macro for the C23 [[nodiscard]] attribute.
Definition compat_c23.h:106
@ INFIX_CODE_INVALID_MEMBER_TYPE
Definition infix.h:1243
@ INFIX_CODE_INTEGER_OVERFLOW
Definition infix.h:1236
@ INFIX_CODE_UNKNOWN
Definition infix.h:1226
@ INFIX_CODE_OUT_OF_MEMORY
Definition infix.h:1228
@ INFIX_CATEGORY_ALLOCATION
Definition infix.h:1216
@ INFIX_CATEGORY_GENERAL
Definition infix.h:1215
@ INFIX_CATEGORY_PARSER
Definition infix.h:1217
struct infix_type_t::@0::@1 pointer_info
Metadata for INFIX_TYPE_POINTER.
union infix_type_t::@0 meta
A union containing metadata specific to the type's category.
bool is_packed
Definition infix.h:213
struct infix_type_t::@0::@7 vector_info
Metadata for INFIX_TYPE_VECTOR.
infix_type * type
Definition infix.h:266
struct infix_type_t::@0::@4 func_ptr_info
Metadata for INFIX_TYPE_REVERSE_TRAMPOLINE.
size_t num_elements
Definition infix.h:218
infix_arena_t * arena
Definition infix.h:200
size_t size
Definition infix.h:197
size_t alignment
Definition infix.h:198
uint8_t bit_offset
Definition infix.h:257
infix_struct_member * members
Definition infix.h:211
bool is_bitfield
Definition infix.h:258
struct infix_type_t::@0::@6 complex_info
Metadata for INFIX_TYPE_COMPLEX.
const char * name
Definition infix.h:195
infix_function_argument * args
Definition infix.h:224
infix_aggregate_category_t aggregate_category
Definition infix.h:244
infix_status
Enumerates the possible status codes returned by infix API functions.
Definition infix.h:352
const char * name
Definition infix.h:265
const char * name
Definition infix.h:253
infix_type_category category
Definition infix.h:196
struct infix_type_t::@0::@2 aggregate_info
Metadata for INFIX_TYPE_STRUCT and INFIX_TYPE_UNION.
struct infix_type_t::@0::@3 array_info
Metadata for INFIX_TYPE_ARRAY.
struct infix_type_t * pointee_type
Definition infix.h:207
infix_type * type
Definition infix.h:254
struct infix_type_t * element_type
Definition infix.h:217
bool is_flexible
Definition infix.h:219
struct infix_type_t * return_type
Definition infix.h:223
size_t offset
Definition infix.h:255
struct infix_type_t::@0::@5 enum_info
Metadata for INFIX_TYPE_ENUM.
struct infix_type_t * base_type
Definition infix.h:234
uint8_t bit_width
Definition infix.h:256
size_t num_members
Definition infix.h:212
struct infix_type_t * underlying_type
Definition infix.h:230
struct infix_type_t::@0::@8 named_reference
Metadata for INFIX_TYPE_NAMED_REFERENCE.
infix_primitive_type_id primitive_id
Metadata for INFIX_TYPE_PRIMITIVE.
Definition infix.h:204
size_t num_args
Definition infix.h:225
bool is_arena_allocated
Definition infix.h:199
@ INFIX_ERROR_ALLOCATION_FAILED
Definition infix.h:354
@ INFIX_SUCCESS
Definition infix.h:353
@ INFIX_ERROR_INVALID_ARGUMENT
Definition infix.h:355
c23_nodiscard size_t infix_forward_get_num_args(const infix_forward_t *trampoline)
Gets the total number of arguments for a forward trampoline.
Definition types.c:1321
void infix_arena_destroy(infix_arena_t *)
Destroys an arena and frees all memory allocated from it.
Definition arena.c:83
#define infix_memcpy
A macro that can be defined to override the default memcpy function.
Definition infix.h:305
c23_nodiscard void * infix_arena_calloc(infix_arena_t *, size_t, size_t, size_t)
Allocates and zero-initializes a block of memory from an arena.
Definition arena.c:179
c23_nodiscard void * infix_arena_alloc(infix_arena_t *, size_t, size_t)
Allocates a block of memory from an arena.
Definition arena.c:117
c23_nodiscard infix_arena_t * infix_arena_create(size_t)
Creates a new memory arena.
Definition arena.c:52
c23_nodiscard infix_status infix_type_create_packed_struct(infix_arena_t *arena, infix_type **out_type, size_t total_size, size_t alignment, infix_struct_member *members, size_t num_members)
Creates a new packed struct type with a user-specified layout.
Definition types.c:744
struct infix_type_t infix_type
A semi-opaque object describing a C type's memory layout and calling convention. See infix_type_t for...
Definition infix.h:128
c23_nodiscard size_t infix_type_get_size(const infix_type *type)
Gets the size of a type in bytes.
Definition types.c:1261
c23_nodiscard infix_status infix_type_create_flexible_array(infix_arena_t *arena, infix_type **out_type, infix_type *element_type)
Creates a new flexible array member type ([?:type]).
Definition types.c:493
c23_nodiscard const infix_type * infix_type_get_arg_type(const infix_type *func_type, size_t index)
Gets the type of a specific argument from a function type.
Definition types.c:1310
c23_nodiscard infix_type * infix_type_create_void(void)
Creates a static descriptor for the void type.
Definition types.c:183
c23_nodiscard size_t infix_type_get_alignment(const infix_type *type)
Gets the alignment requirement of a type in bytes.
Definition types.c:1267
c23_nodiscard size_t infix_forward_get_num_fixed_args(const infix_forward_t *trampoline)
Gets the number of fixed (non-variadic) arguments for a forward trampoline.
Definition types.c:1329
c23_nodiscard const char * infix_type_get_name(const infix_type *type)
Gets the semantic alias of a type, if one exists.
Definition types.c:1243
c23_nodiscard const infix_type * infix_forward_get_return_type(const infix_forward_t *trampoline)
Gets the return type for a forward trampoline.
Definition types.c:1337
infix_primitive_type_id
Enumerates the supported primitive C types.
Definition infix.h:164
c23_nodiscard const infix_type * infix_forward_get_arg_type(const infix_forward_t *trampoline, size_t index)
Gets the type of a specific argument for a forward trampoline.
Definition types.c:1346
c23_nodiscard infix_status infix_type_create_union(infix_arena_t *arena, infix_type **out_type, infix_struct_member *members, size_t num_members)
Creates a new union type from an array of members.
Definition types.c:638
c23_nodiscard infix_status infix_type_create_enum(infix_arena_t *arena, infix_type **out_type, infix_type *underlying_type)
Creates a new enum type with a specified underlying integer type.
Definition types.c:536
c23_nodiscard infix_status infix_type_create_vector(infix_arena_t *arena, infix_type **out_type, infix_type *element_type, size_t num_elements)
Creates a new SIMD vector type.
Definition types.c:600
c23_nodiscard const infix_type * infix_reverse_get_return_type(const infix_reverse_t *trampoline)
Gets the return type for a reverse trampoline.
Definition types.c:1372
struct infix_struct_member_t infix_struct_member
A semi-opaque object describing a member of a C struct or union. See infix_struct_member_t for detail...
Definition infix.h:130
c23_nodiscard infix_type * infix_type_create_pointer(void)
Creates a static descriptor for a generic pointer (void*).
Definition types.c:178
c23_nodiscard infix_status infix_type_create_complex(infix_arena_t *arena, infix_type **out_type, infix_type *base_type)
Creates a new _Complex number type.
Definition types.c:570
c23_nodiscard size_t infix_reverse_get_num_args(const infix_reverse_t *trampoline)
Gets the total number of arguments for a reverse trampoline.
Definition types.c:1356
c23_nodiscard size_t infix_type_get_member_count(const infix_type *type)
Gets the number of members in a struct or union type.
Definition types.c:1274
struct infix_function_argument_t infix_function_argument
A semi-opaque object describing an argument to a C function. See infix_function_argument_t for detail...
Definition infix.h:132
c23_nodiscard const char * infix_type_get_arg_name(const infix_type *func_type, size_t index)
Gets the name of a specific argument from a function type.
Definition types.c:1298
infix_type_category
Enumerates the fundamental categories of types that infix can represent.
Definition infix.h:148
c23_nodiscard infix_type_category infix_type_get_category(const infix_type *type)
Gets the fundamental category of a type.
Definition types.c:1253
c23_nodiscard infix_status infix_type_create_array(infix_arena_t *arena, infix_type **out_type, infix_type *element_type, size_t num_elements)
Creates a new fixed-size array type.
Definition types.c:455
c23_nodiscard infix_status infix_type_create_pointer_to(infix_arena_t *arena, infix_type **out_type, infix_type *pointee_type)
Creates a new pointer type that points to a specific type.
Definition types.c:425
infix_aggregate_category_t
Specifies whether a named type reference refers to a struct or a union.
Definition infix.h:184
infix_struct_member infix_type_create_bitfield_member(const char *name, infix_type *type, size_t offset, uint8_t bit_width)
A factory function to create a bitfield infix_struct_member.
Definition types.c:202
c23_nodiscard infix_status infix_type_create_struct(infix_arena_t *arena, infix_type **out_type, infix_struct_member *members, size_t num_members)
Creates a new struct type from an array of members, calculating layout automatically.
Definition types.c:685
c23_nodiscard infix_status infix_type_create_named_reference(infix_arena_t *arena, infix_type **out_type, const char *name, infix_aggregate_category_t agg_cat)
Creates a placeholder for a named type that will be resolved later by a type registry.
Definition types.c:792
c23_nodiscard const infix_type * infix_reverse_get_arg_type(const infix_reverse_t *trampoline, size_t index)
Gets the type of a specific argument for a reverse trampoline.
Definition types.c:1381
c23_nodiscard size_t infix_reverse_get_num_fixed_args(const infix_reverse_t *trampoline)
Gets the number of fixed (non-variadic) arguments for a reverse trampoline.
Definition types.c:1364
c23_nodiscard infix_type * infix_type_create_primitive(infix_primitive_type_id id)
Creates a static descriptor for a primitive C type.
Definition types.c:130
infix_struct_member infix_type_create_member(const char *name, infix_type *type, size_t offset)
A factory function to create an infix_struct_member.
Definition types.c:191
c23_nodiscard const infix_struct_member * infix_type_get_member(const infix_type *type, size_t index)
Gets a specific member from a struct or union type.
Definition types.c:1285
@ INFIX_PRIMITIVE_UINT16
Definition infix.h:168
@ INFIX_PRIMITIVE_UINT32
Definition infix.h:170
@ INFIX_PRIMITIVE_LONG_DOUBLE
Definition infix.h:178
@ INFIX_PRIMITIVE_FLOAT
Definition infix.h:176
@ INFIX_PRIMITIVE_DOUBLE
Definition infix.h:177
@ INFIX_PRIMITIVE_SINT16
Definition infix.h:169
@ INFIX_PRIMITIVE_SINT64
Definition infix.h:173
@ INFIX_PRIMITIVE_SINT32
Definition infix.h:171
@ INFIX_PRIMITIVE_UINT8
Definition infix.h:166
@ INFIX_PRIMITIVE_UINT128
Definition infix.h:174
@ INFIX_PRIMITIVE_BOOL
Definition infix.h:165
@ INFIX_PRIMITIVE_UINT64
Definition infix.h:172
@ INFIX_PRIMITIVE_SINT128
Definition infix.h:175
@ INFIX_PRIMITIVE_SINT8
Definition infix.h:167
@ INFIX_TYPE_UNION
Definition infix.h:152
@ INFIX_TYPE_PRIMITIVE
Definition infix.h:149
@ INFIX_TYPE_COMPLEX
Definition infix.h:156
@ INFIX_TYPE_ARRAY
Definition infix.h:153
@ INFIX_TYPE_VECTOR
Definition infix.h:157
@ INFIX_TYPE_VOID
Definition infix.h:159
@ INFIX_TYPE_POINTER
Definition infix.h:150
@ INFIX_TYPE_NAMED_REFERENCE
Definition infix.h:158
@ INFIX_TYPE_REVERSE_TRAMPOLINE
Definition infix.h:154
@ INFIX_TYPE_ENUM
Definition infix.h:155
@ INFIX_TYPE_STRUCT
Definition infix.h:151
Internal data structures, function prototypes, and constants.
void _infix_set_error(infix_error_category_t category, infix_error_code_t code, size_t position)
Sets the thread-local error state with detailed information.
Definition error.c:165
static size_t _infix_align_up(size_t value, size_t alignment)
Aligns a value up to the next multiple of a power-of-two alignment.
Definition infix_internals.h:727
static bool is_double(const infix_type *type)
A fast inline check to determine if an infix_type is a double.
Definition infix_internals.h:743
void _infix_clear_error(void)
Clears the thread-local error state.
Definition error.c:258
static bool is_float(const infix_type *type)
A fast inline check to determine if an infix_type is a float.
Definition infix_internals.h:735
Definition types.c:1134
struct estimate_visited_node_t * next
Definition types.c:1136
const infix_type * type
Definition types.c:1135
Internal definition of a memory arena.
Definition infix_internals.h:138
Internal definition of a forward trampoline handle.
Definition infix_internals.h:88
size_t num_args
Definition infix_internals.h:95
size_t num_fixed_args
Definition infix_internals.h:96
infix_type ** arg_types
Definition infix_internals.h:94
infix_type * return_type
Definition infix_internals.h:93
Describes a single argument to a C function.
Definition infix.h:264
Internal definition of a reverse trampoline (callback/closure) handle.
Definition infix_internals.h:114
infix_type * return_type
Definition infix_internals.h:118
size_t num_args
Definition infix_internals.h:120
size_t num_fixed_args
Definition infix_internals.h:121
infix_type ** arg_types
Definition infix_internals.h:119
Describes a single member of a C struct or union.
Definition infix.h:252
A semi-opaque structure that describes a C type.
Definition infix.h:194
Definition types.c:955
infix_type * dest
Definition types.c:957
struct memo_node_t * next
Definition types.c:958
const infix_type * src
Definition types.c:956
Definition types.c:837
struct recalc_visited_node_t * next
Definition types.c:839
infix_type * type
Definition types.c:838
static size_t _estimate_graph_size_recursive(infix_arena_t *temp_arena, const infix_type *type, estimate_visited_node_t **visited_head)
Definition types.c:1150
static infix_type _infix_type_sint128
Definition types.c:110
void _infix_type_recalculate_layout(infix_type *type)
Recalculates the layout of a fully resolved type graph.
Definition types.c:938
static infix_type _infix_type_double
Definition types.c:115
static infix_type _infix_type_uint32
Definition types.c:99
static infix_type _infix_type_bool
Definition types.c:89
static infix_type _infix_type_float
Definition types.c:113
infix_type * _copy_type_graph_to_arena(infix_arena_t *dest_arena, const infix_type *src_type)
Performs a deep copy of a type graph into a destination arena.
Definition types.c:1125
static infix_type _infix_type_sint64
Definition types.c:105
#define INFIX_TYPE_INIT(id, T)
Definition types.c:56
size_t _infix_estimate_graph_size(infix_arena_t *temp_arena, const infix_type *type)
Estimates the total memory required to deep-copy a complete type graph.
Definition types.c:1230
static infix_type _infix_type_sint16
Definition types.c:97
static infix_type _infix_type_uint16
Definition types.c:95
static infix_type _infix_type_long_double
Definition types.c:121
static infix_type _infix_type_pointer
Definition types.c:81
static infix_type _infix_type_uint128
Definition types.c:108
static infix_type _infix_type_void
Definition types.c:69
static infix_type _infix_type_sint32
Definition types.c:101
static infix_type * _copy_type_graph_to_arena_recursive(infix_arena_t *dest_arena, const infix_type *src_type, memo_node_t **memo_head)
Definition types.c:974
static infix_type _infix_type_uint64
Definition types.c:103
static infix_status _create_aggregate_setup(infix_arena_t *arena, infix_type **out_type, infix_struct_member **out_arena_members, infix_struct_member *members, size_t num_members)
Definition types.c:382
static void _infix_type_recalculate_layout_recursive(infix_arena_t *temp_arena, infix_type *type, recalc_visited_node_t **visited_head)
Definition types.c:863
static bool _layout_struct(infix_type *type)
Definition types.c:214
static infix_type _infix_type_uint8
Definition types.c:91
static infix_type _infix_type_sint8
Definition types.c:93
A header for conditionally compiled debugging utilities.