Rizin
unix-like reverse engineering framework and cli tools
types_storage.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 Anton Kochkov <anton.kochkov@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_types.h>
5 #include <rz_list.h>
6 #include <rz_util/rz_str.h>
7 #include <rz_util/rz_assert.h>
8 #include <rz_type.h>
9 #include <tree_sitter/api.h>
10 
11 #include <types_parser.h>
12 
13 // Searching and storing types in the context of the parser (types and callables hashables)
14 
15 // Base types
16 
18  bool found = false;
19  RzBaseType *base_type = ht_pp_find(state->types, name, &found);
20  if (!found || !base_type) {
21  return NULL;
22  }
23  return base_type;
24 }
25 
27  bool found = false;
28  ht_pp_find(state->forward, name, &found);
29  return found;
30 }
31 
34 }
35 
37  rz_return_val_if_fail(state && name && tpair && tpair->btype, -1);
38 
40  // We don't create the type if it exists already in the parser
41  // state with the same name
42  return false;
43  }
44 
45  // We store only RzBaseType part of the type pair
46  ht_pp_insert(state->types, name, tpair->btype);
47  return true;
48 }
49 
52 
54  // We don't create the forward definition if it exists already in the parser
55  // types table state with the same name
56  return false;
57  }
58 
60  // We don't create the forward definition if it already stored
61  // as the forward definition with the same name
62  return false;
63  }
64 
65  // We store only the type name
66  ht_pp_insert(state->forward, name, NULL);
67  return true;
68 }
69 
72 
74  // We don't create the forward definition if it exists already in the parser
75  // types table state with the same name
76  return false;
77  }
78 
79  ht_pp_delete(state->forward, name);
80  return true;
81 }
82 
83 // Callable types
84 
86  bool found = false;
87  RzCallable *callable = ht_pp_find(state->callables, name, &found);
88  if (!found || !callable) {
89  return NULL;
90  }
91  return callable;
92 }
93 
96 }
97 
101  rz_return_val_if_fail(type->callable, -1);
102 
104  // We don't create the type if it exists already in the parser
105  // state with the same name
106  return false;
107  }
108 
109  ht_pp_insert(state->callables, name, type->callable);
110  parser_debug(state, "Stored \"%s\" callable type\n", name);
111  return true;
112 }
113 
123 
125  if (!type) {
126  return NULL;
127  }
129  type->identifier.is_const = is_const;
130  type->identifier.name = strdup(name);
131  type->identifier.kind = RZ_TYPE_IDENTIFIER_KIND_UNSPECIFIED;
132 
134  if (!tpair) {
136  return NULL;
137  }
138  tpair->btype = NULL;
139  tpair->type = type;
140  return tpair;
141 }
142 
152 
154  // We don't create the type if it exists already in the parser
155  // state with the same name
156  parser_error(state, "Primitive type \"%s\" already exists\n", name);
157  return NULL;
158  }
159 
161  if (!type) {
162  return NULL;
163  }
165  type->identifier.is_const = is_const;
166  type->identifier.name = strdup(name);
167  if (!type->identifier.name) {
168  free(type);
169  return NULL;
170  }
171  type->identifier.kind = RZ_TYPE_IDENTIFIER_KIND_UNSPECIFIED;
172 
174  if (!base_type) {
176  return NULL;
177  }
178  base_type->name = strdup(name);
179  if (!base_type->name) {
181  rz_type_base_type_free(base_type);
182  return NULL;
183  }
184 
186  if (!tpair) {
188  rz_type_base_type_free(base_type);
189  return NULL;
190  }
191  tpair->btype = base_type;
192  tpair->type = type;
193 
194  return tpair;
195 }
196 
211 
213  if (!base_type || base_type->kind != RZ_BASE_TYPE_KIND_ATOMIC) {
214  return NULL;
215  }
216 
218  if (!type) {
219  return NULL;
220  }
222  type->identifier.is_const = is_const;
223  type->identifier.name = strdup(name);
224  type->identifier.kind = RZ_TYPE_IDENTIFIER_KIND_UNSPECIFIED;
225 
227  if (!tpair) {
229  return NULL;
230  }
231  tpair->btype = base_type;
232  tpair->type = type;
233  return tpair;
234 }
235 
244 
246  if (!type) {
247  return NULL;
248  }
250  type->identifier.is_const = false;
251  type->identifier.name = strdup(name);
252  type->identifier.kind = RZ_TYPE_IDENTIFIER_KIND_STRUCT;
253 
255  if (!tpair) {
257  return NULL;
258  }
259  tpair->btype = NULL;
260  tpair->type = type;
261  return tpair;
262 }
263 
273 
275  // We don't create the structure if it exists already in the parser
276  // state with the same name
277  parser_error(state, "Structure type \"%s\" already exists\n", name);
278  return NULL;
279  }
280 
282  if (!tpair) {
283  return NULL;
284  }
285 
287  if (!base_type) {
288  rz_type_free(tpair->type);
289  free(tpair);
290  return NULL;
291  }
292  base_type->name = strdup(name);
293  base_type->type = NULL;
294  tpair->btype = base_type;
295 
296  RzVector *members = &base_type->struct_data.members;
297  if (members_count > 0 && !rz_vector_reserve(members, members_count)) {
298  rz_type_free(tpair->type);
300  free(tpair);
301  return NULL;
302  }
303  return tpair;
304 }
305 
319 
321  if (!base_type || base_type->kind != RZ_BASE_TYPE_KIND_STRUCT) {
322  return NULL;
323  }
324 
326  if (!tpair) {
327  return NULL;
328  }
329 
330  tpair->btype = base_type;
331  return tpair;
332 }
333 
342 
344  // We don't create the structure if it exists already in the parser
345  // state with the same name
346  return NULL;
347  }
348 
350  // We don't create the structure if it exists already in the forward
351  // definitions table with the same name
352  return NULL;
353  }
354 
356  if (!tpair) {
357  return NULL;
358  }
359 
360  return tpair;
361 }
362 
371 
373  if (!type) {
374  return NULL;
375  }
377  type->identifier.is_const = false;
378  type->identifier.name = strdup(name);
379  type->identifier.kind = RZ_TYPE_IDENTIFIER_KIND_UNION;
380 
382  if (!tpair) {
384  return NULL;
385  }
386  tpair->btype = NULL;
387  tpair->type = type;
388  return tpair;
389 }
390 
400 
402  // We don't create the structure if it exists already in the parser
403  // state with the same name
404  parser_error(state, "Union type \"%s\" already exists\n", name);
405  return NULL;
406  }
407 
409  if (!tpair) {
410  return NULL;
411  }
412 
414  if (!base_type) {
415  rz_type_free(tpair->type);
416  free(tpair);
417  return NULL;
418  }
419 
420  base_type->name = strdup(name);
421  base_type->type = NULL;
422  tpair->btype = base_type;
423 
424  RzVector *members = &base_type->union_data.members;
425  if (members_count > 0 && !rz_vector_reserve(members, members_count)) {
426  rz_type_free(tpair->type);
428  free(tpair);
429  return NULL;
430  }
431  return tpair;
432 }
433 
447 
449  if (!base_type || base_type->kind != RZ_BASE_TYPE_KIND_UNION) {
450  return NULL;
451  }
452 
454  if (!tpair) {
455  return NULL;
456  }
457 
458  tpair->btype = base_type;
459  return tpair;
460 }
461 
470 
472  // We don't create the union if it exists already in the parser
473  // state with the same name
474  return NULL;
475  }
476 
478  // We don't create the union if it exists already in the forward
479  // definitions table with the same name
480  return NULL;
481  }
482 
484  if (!tpair) {
485  return NULL;
486  }
487 
488  return tpair;
489 }
490 
499 
501  if (!type) {
502  return NULL;
503  }
505  type->identifier.is_const = false;
506  type->identifier.name = strdup(name);
507  type->identifier.kind = RZ_TYPE_IDENTIFIER_KIND_ENUM;
508 
510  if (!tpair) {
512  return NULL;
513  }
514  tpair->btype = NULL;
515  tpair->type = type;
516  return tpair;
517 }
518 
528 
530  // We don't create the structure if it exists already in the parser
531  // state with the same name
532  parser_error(state, "Enum type \"%s\" already exists\n", name);
533  return NULL;
534  }
535 
537  if (!tpair) {
538  return NULL;
539  }
540 
542  if (!base_type) {
543  rz_type_free(tpair->type);
544  free(tpair);
545  return NULL;
546  }
547 
548  base_type->name = strdup(name);
549  base_type->type = NULL;
550  tpair->btype = base_type;
551 
552  RzVector *cases = &base_type->enum_data.cases;
553  if (cases_count > 0 && !rz_vector_reserve(cases, cases_count)) {
554  rz_type_free(tpair->type);
556  free(tpair);
557  return NULL;
558  }
559  return tpair;
560 }
561 
575 
577  if (!base_type || base_type->kind != RZ_BASE_TYPE_KIND_ENUM) {
578  return NULL;
579  }
580 
582  if (!tpair) {
583  return NULL;
584  }
585 
586  tpair->btype = base_type;
587  return tpair;
588 }
589 
598 
600  // We don't create the enum if it exists already in the parser
601  // state with the same name
602  return NULL;
603  }
604 
606  // We don't create the enum if it exists already in the forward
607  // definitions table with the same name
608  return NULL;
609  }
610 
612  if (!tpair) {
613  return NULL;
614  }
615 
616  return tpair;
617 }
618 
627 
629  if (!type) {
630  return NULL;
631  }
633  type->identifier.is_const = false;
634  type->identifier.name = strdup(name);
635  type->identifier.kind = RZ_TYPE_IDENTIFIER_KIND_UNSPECIFIED;
636 
638  if (!tpair) {
640  return NULL;
641  }
642  tpair->btype = NULL;
643  tpair->type = type;
644  return tpair;
645 }
646 
655 
657  // We don't create the typedef if it exists already in the parser
658  // state with the same name
659  return NULL;
660  }
661 
663  // We don't create the typedef if it exists already in the forward
664  // definitions table with the same name
665  return NULL;
666  }
667 
669  if (!tpair) {
670  return NULL;
671  }
672 
673  return tpair;
674 }
675 
685 
687  // We don't create the type alias if it exists already in the parser
688  // state with the same name
689  parser_error(state, "Typedef \"%s\" already exists\n", name);
690  return NULL;
691  }
692 
694  if (!tpair) {
695  return NULL;
696  }
697 
699  if (!base_type) {
700  rz_type_free(tpair->type);
701  free(tpair);
702  return NULL;
703  }
704  base_type->name = strdup(name);
705 
706  if (!c_parser_base_type_exists(state, base)) {
707  // If it not exists already in the parser
708  // we create a forward type
709  base_type->type = NULL;
711  } else {
713  if (!type) {
714  rz_type_base_type_free(base_type);
715  free(tpair);
716  return NULL;
717  }
719  type->identifier.name = strdup(base);
720  type->identifier.is_const = false;
721  base_type->type = type;
722  }
723 
724  tpair->btype = base_type;
725  return tpair;
726 }
727 
741 
743  if (!base_type || base_type->kind != RZ_BASE_TYPE_KIND_TYPEDEF) {
744  return NULL;
745  }
746 
748  if (!type) {
749  return NULL;
750  }
752  type->identifier.is_const = false;
753  type->identifier.name = strdup(name);
754  type->identifier.kind = RZ_TYPE_IDENTIFIER_KIND_UNSPECIFIED;
755 
757  if (!tpair) {
759  return NULL;
760  }
761  tpair->btype = base_type;
762  tpair->type = type;
763  return tpair;
764 }
765 
774  if (!type) {
775  return NULL;
776  }
777  RzCallable *callable = RZ_NEW0(RzCallable);
778  if (!callable) {
779  free(type);
780  return NULL;
781  }
782  callable->name = NULL;
784  type->kind = RZ_TYPE_KIND_CALLABLE;
785  type->callable = callable;
786  return type;
787 }
788 
805  if (!type) {
806  return NULL;
807  }
808  // We check if there is already a callable in the hashtable with the same name
809  bool found = false;
810  RzCallable *callable = ht_pp_find(state->callables, name, &found);
811  if (!found || !callable) {
812  // If not found - create a new one
813  callable = RZ_NEW0(RzCallable);
814  if (!callable) {
815  free(type);
816  return NULL;
817  }
818  callable->name = strdup(name);
820  }
821  type->kind = RZ_TYPE_KIND_CALLABLE;
822  type->callable = callable;
823  return type;
824 }
825 
835  rz_return_val_if_fail(state && callable && name && type, false);
836  // At first we check if there is an argument with the same name already - error if yes
837  void **it;
838  rz_pvector_foreach (callable->args, it) {
839  RzCallableArg *arg = *it;
840  if (!strcmp(arg->name, name)) {
841  return false;
842  }
843  }
844  // And only if there is no argument with the same name - proceed to insert it
846  if (!arg) {
847  return false;
848  }
849  arg->name = strdup(name);
850  arg->type = type;
851  rz_pvector_push(callable->args, arg);
852  return true;
853 }
854 
855 // Helpers to wrap the ParserTypePair into the pointer or the array complex types
856 
858  rz_return_val_if_fail(state && tpair, NULL);
860  type->kind = RZ_TYPE_KIND_POINTER;
861  type->pointer.is_const = is_const;
862  type->pointer.type = tpair->type;
864  newtpair->btype = tpair->btype;
865  newtpair->type = type;
866  return newtpair;
867 }
868 
870  rz_return_val_if_fail(state && tpair, NULL);
872  type->kind = RZ_TYPE_KIND_ARRAY;
873  type->array.count = size;
874  type->array.type = tpair->type;
876  newtpair->btype = tpair->btype;
877  newtpair->type = type;
878  return newtpair;
879 }
880 
882  rz_return_val_if_fail(state && tpair, false);
883  rz_return_val_if_fail(tpair->type->kind == RZ_TYPE_KIND_POINTER, false);
884  tpair->type->pointer.type = subpair->type;
885  tpair->btype = subpair->btype;
886  return true;
887 }
888 
890  rz_return_val_if_fail(state && tpair, false);
891  rz_return_val_if_fail(tpair->type->kind == RZ_TYPE_KIND_ARRAY, false);
892  tpair->type->array.type = subpair->type;
893  tpair->btype = subpair->btype;
894  return true;
895 }
896 
898  char *name = rz_str_newf("anonymous struct %zu", state->anon.structs);
899  state->anon.structs++;
900  return name;
901 }
902 
904  char *name = rz_str_newf("anonymous union %zu", state->anon.unions);
905  state->anon.unions++;
906  return name;
907 }
908 
910  char *name = rz_str_newf("anonymous enum %zu", state->anon.enums);
911  state->anon.enums++;
912  return name;
913 }
914 
916  char *name = rz_str_newf("anonymous function %zu", state->anon.callables);
917  state->anon.enums++;
918  return name;
919 }
RZ_API void rz_type_base_type_free(RzBaseType *type)
Frees the RzBaseType instance and all of its members.
Definition: base.c:132
RZ_API RZ_OWN RzBaseType * rz_type_base_type_new(RzBaseTypeKind kind)
Allocates a new instance of RzBaseType given the kind.
Definition: base.c:162
#define NULL
Definition: cris-opc.c:27
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
RZ_API const KEY_TYPE bool * found
Definition: ht_inc.h:130
voidpf void uLong size
Definition: ioapi.h:138
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
int type
Definition: mipsasm.c:17
const char * name
Definition: op.c:541
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
@ RZ_BASE_TYPE_KIND_TYPEDEF
Definition: rz_type.h:76
@ RZ_BASE_TYPE_KIND_ATOMIC
Definition: rz_type.h:77
@ RZ_BASE_TYPE_KIND_UNION
Definition: rz_type.h:74
@ RZ_BASE_TYPE_KIND_STRUCT
Definition: rz_type.h:73
@ RZ_BASE_TYPE_KIND_ENUM
Definition: rz_type.h:75
@ RZ_TYPE_IDENTIFIER_KIND_STRUCT
Definition: rz_type.h:136
@ RZ_TYPE_IDENTIFIER_KIND_UNSPECIFIED
Definition: rz_type.h:135
@ RZ_TYPE_IDENTIFIER_KIND_ENUM
Definition: rz_type.h:138
@ RZ_TYPE_IDENTIFIER_KIND_UNION
Definition: rz_type.h:137
@ RZ_TYPE_KIND_ARRAY
Definition: rz_type.h:130
@ RZ_TYPE_KIND_CALLABLE
Definition: rz_type.h:131
@ RZ_TYPE_KIND_IDENTIFIER
Definition: rz_type.h:128
@ RZ_TYPE_KIND_POINTER
Definition: rz_type.h:129
#define RZ_OWN
Definition: rz_types.h:62
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define RZ_NONNULL
Definition: rz_types.h:64
#define RZ_BORROW
Definition: rz_types.h:63
RZ_API void * rz_vector_reserve(RzVector *vec, size_t capacity)
Definition: vector.c:214
RZ_API RzPVector * rz_pvector_new(RzPVectorFree free)
Definition: vector.c:302
void(* RzPVectorFree)(void *e)
Definition: rz_vector.h:43
static void ** rz_pvector_push(RzPVector *vec, void *x)
Definition: rz_vector.h:300
#define rz_pvector_foreach(vec, it)
Definition: rz_vector.h:334
RzType * type
Definition: types_parser.h:24
RzBaseType * btype
Definition: types_parser.h:23
const char * name
Definition: sparc-opc.c:1838
Definition: z80asm.h:102
RzVector cases
Definition: rz_type.h:108
RzBaseTypeStruct struct_data
Definition: rz_type.h:118
char * name
Definition: rz_type.h:112
RzType * type
Definition: rz_type.h:113
RzBaseTypeEnum enum_data
Definition: rz_type.h:119
RzBaseTypeUnion union_data
Definition: rz_type.h:120
RzBaseTypeKind kind
Definition: rz_type.h:115
RzVector members
Definition: rz_type.h:104
RzPVector * args
optional for the time being
Definition: rz_type.h:149
RZ_NULLABLE char * name
Definition: rz_type.h:147
Definition: dis.h:43
RZ_API void rz_type_callable_arg_free(RzCallableArg *arg)
Frees the RzCallableArg.
Definition: function.c:101
RZ_API void rz_type_free(RZ_NULLABLE RzType *type)
Frees the RzType.
Definition: type.c:1273
void parser_debug(CParserState *state, const char *fmt,...)
Definition: types_parser.c:37
void parser_error(CParserState *state, const char *fmt,...)
Definition: types_parser.c:47
RZ_OWN ParserTypePair * c_parser_new_union_naked_type(CParserState *state, RZ_NONNULL const char *name)
Creates new union naked type (without base type) based on the name.
bool c_parser_pointer_set_subtype(CParserState *state, RZ_BORROW ParserTypePair *tpair, RZ_OWN ParserTypePair *subpair)
RzBaseType * c_parser_base_type_find(CParserState *state, RZ_NONNULL const char *name)
Definition: types_storage.c:17
bool c_parser_base_type_exists(CParserState *state, RZ_NONNULL const char *name)
Definition: types_storage.c:32
bool c_parser_forward_definition_remove(CParserState *state, RZ_NONNULL const char *name)
Definition: types_storage.c:70
bool c_parser_base_type_is_forward_definition(CParserState *state, RZ_NONNULL const char *name)
Definition: types_storage.c:26
RZ_OWN ParserTypePair * c_parser_new_unspecified_naked_type(CParserState *state, RZ_NONNULL const char *name, bool is_const)
Creates new unspecified naked type (without base type) based on the name.
bool c_parser_array_set_subtype(CParserState *state, RZ_BORROW ParserTypePair *tpair, RZ_OWN ParserTypePair *subpair)
RZ_OWN ParserTypePair * c_parser_new_enum_type(CParserState *state, RZ_NONNULL const char *name, size_t cases_count)
Creates new enumeration type based on the name.
bool c_parser_base_type_store(CParserState *state, RZ_NONNULL const char *name, ParserTypePair *tpair)
Definition: types_storage.c:36
RZ_OWN ParserTypePair * c_parser_new_structure_type(CParserState *state, RZ_NONNULL const char *name, size_t members_count)
Creates new structure "type + base type" pair based on the name.
RZ_OWN ParserTypePair * c_parser_get_structure_type(CParserState *state, RZ_NONNULL const char *name)
Returns the structure type if matching in the types hashtable.
RZ_OWN ParserTypePair * c_parser_new_primitive_type(CParserState *state, RZ_NONNULL const char *name, bool is_const)
Creates new primitive type based on the name.
RZ_OWN RzType * c_parser_new_callable(CParserState *state, RZ_NONNULL const char *name)
Creates new callable based on the name.
RZ_OWN ParserTypePair * c_parser_new_typedef(CParserState *state, RZ_NONNULL const char *name, RZ_NONNULL const char *base)
Creates new type alias based on the name.
bool c_parser_forward_definition_store(CParserState *state, RZ_NONNULL const char *name)
Definition: types_storage.c:50
RZ_OWN ParserTypePair * c_parser_type_wrap_to_array(CParserState *state, ParserTypePair *tpair, size_t size)
RZ_OWN char * c_parser_new_anonymous_callable_name(CParserState *state)
RZ_OWN ParserTypePair * c_parser_new_enum_naked_type(CParserState *state, RZ_NONNULL const char *name)
Creates new enum naked type (without base type) based on the name.
RZ_OWN ParserTypePair * c_parser_new_structure_naked_type(CParserState *state, RZ_NONNULL const char *name)
Creates new structure naked type (without base type) based on the name.
RZ_OWN char * c_parser_new_anonymous_enum_name(CParserState *state)
RZ_OWN ParserTypePair * c_parser_new_typedef_forward_definition(CParserState *state, RZ_NONNULL const char *name)
Creates new type alias forward definition.
RZ_OWN ParserTypePair * c_parser_get_typedef(CParserState *state, RZ_NONNULL const char *name)
Returns the type if matching in the types hashtable.
RZ_OWN ParserTypePair * c_parser_new_enum_forward_definition(CParserState *state, RZ_NONNULL const char *name)
Creates new enum forward definition.
RZ_OWN char * c_parser_new_anonymous_structure_name(CParserState *state)
bool c_parser_new_callable_argument(CParserState *state, RZ_NONNULL RzCallable *callable, RZ_NONNULL const char *name, RZ_OWN RZ_NONNULL RzType *type)
Adds a new argument to the callable.
RZ_OWN ParserTypePair * c_parser_new_typedef_naked_type(CParserState *state, RZ_NONNULL const char *name)
Creates new type alias naked type (without base type) based on the name.
RZ_OWN ParserTypePair * c_parser_get_enum_type(CParserState *state, RZ_NONNULL const char *name)
Returns the enum type if matching in the types hashtable.
RZ_OWN char * c_parser_new_anonymous_union_name(CParserState *state)
bool c_parser_callable_type_exists(CParserState *state, RZ_NONNULL const char *name)
Definition: types_storage.c:94
RzCallable * c_parser_callable_type_find(CParserState *state, RZ_NONNULL const char *name)
Definition: types_storage.c:85
RZ_OWN ParserTypePair * c_parser_get_union_type(CParserState *state, RZ_NONNULL const char *name)
Returns the union type if matching in the types hashtable.
RZ_OWN ParserTypePair * c_parser_get_primitive_type(CParserState *state, RZ_NONNULL const char *name, bool is_const)
Returns the primitive type if matching in the types hashtable.
RZ_OWN ParserTypePair * c_parser_new_union_type(CParserState *state, RZ_NONNULL const char *name, size_t members_count)
Creates new union "type + base type" pair based on the name.
RZ_OWN ParserTypePair * c_parser_new_union_forward_definition(CParserState *state, RZ_NONNULL const char *name)
Creates new union forward definition.
RZ_OWN ParserTypePair * c_parser_type_wrap_to_pointer(CParserState *state, ParserTypePair *tpair, bool is_const)
RZ_OWN RzType * c_parser_new_naked_callable(CParserState *state)
Creates new naked callable without storing it.
RZ_OWN ParserTypePair * c_parser_new_structure_forward_definition(CParserState *state, RZ_NONNULL const char *name)
Creates new structure forward definition.
bool c_parser_callable_type_store(CParserState *state, RZ_NONNULL const char *name, RZ_NONNULL RzType *type)
Definition: types_storage.c:98