Rizin
unix-like reverse engineering framework and cli tools
typeclass.c File Reference
#include <rz_util.h>
#include <rz_type.h>
#include <string.h>

Go to the source code of this file.

Classes

struct  list_typeclass
 
struct  list_typeclass_size
 

Functions

static bool typeclass_is_num (RzTypeTypeclass t)
 
static bool typeclass_is_integal (RzTypeTypeclass t)
 
RZ_API RZ_BORROW const char * rz_type_typeclass_as_string (RzTypeTypeclass typeclass)
 Returns the string representation of a typeclass. More...
 
RZ_API RzTypeTypeclass rz_type_typeclass_from_string (RZ_NONNULL const char *typeclass)
 Returns the typeclass from the string name of it. More...
 
static bool get_base_type_typeclass (const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type, RZ_NONNULL RzTypeTypeclass *typeclass)
 
static bool get_type_typeclass (const RzTypeDB *typedb, RZ_NONNULL const RzType *type, RzTypeTypeclass *typeclass)
 
static bool check_base_type_typeclass (const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type, RzTypeTypeclass typeclass)
 
static bool check_type_typeclass (const RzTypeDB *typedb, RZ_NONNULL const RzType *type, RzTypeTypeclass typeclass)
 
RZ_API RzTypeTypeclass rz_base_type_typeclass (const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type)
 Gets the base type class. More...
 
RZ_API RzTypeTypeclass rz_type_typeclass (const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
 Gets the type class. More...
 
RZ_API bool rz_base_type_is_num (const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type)
 Checks if the RzBaseType is Num typeclass. More...
 
RZ_API bool rz_type_is_num (const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
 Checks if the RzType is Num typeclass. More...
 
RZ_API bool rz_base_type_is_integral (const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type)
 Checks if the RzBaseType is Integral typeclass. More...
 
RZ_API bool rz_type_is_integral (const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
 Checks if the RzType is Integral typeclass. More...
 
RZ_API bool rz_base_type_is_floating (const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type)
 Checks if the RzBaseType is Floating typeclass. More...
 
RZ_API bool rz_type_is_floating (const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
 Checks if the RzType is Floating typeclass. More...
 
RZ_API bool rz_base_type_is_integral_signed (const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type)
 Checks if the RzBaseType is Integral and Signed typeclass. More...
 
RZ_API bool rz_type_is_integral_signed (const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
 Checks if the RzType is Integral and Signed typeclass. More...
 
RZ_API bool rz_base_type_is_integral_unsigned (const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type)
 Checks if the RzBaseType is Integral and Unsigned typeclass. More...
 
RZ_API bool rz_type_is_integral_unsigned (const RzTypeDB *typedb, RZ_NONNULL const RzType *type)
 Checks if the RzType is Integral and Unsigned typeclass. More...
 
static bool base_type_typeclass_collect_cb (void *user, const void *k, const void *v)
 
static bool base_type_typeclass_sized_collect_cb (void *user, const void *k, const void *v)
 
RZ_API RZ_OWN RzListrz_type_typeclass_get_all (const RzTypeDB *typedb, RzTypeTypeclass typeclass)
 Returns the list of all base types given the typeclass. More...
 
RZ_API RZ_OWN RzListrz_type_typeclass_get_all_sized (const RzTypeDB *typedb, RzTypeTypeclass typeclass, size_t size)
 Returns the list of all base types given the typeclass and size. More...
 
RZ_API RZ_OWN RzBaseTyperz_type_typeclass_get_default_sized (const RzTypeDB *typedb, RzTypeTypeclass typeclass, size_t size)
 Returns the default base type given the typeclass and size. More...
 

Detailed Description

Atomic types are split into the various type classes

None < A default value and includes all types |

  • Num < Every numeric type |
    • Integral < Every integral (integer) type | | | - Signed Integral < Every signed integral type | - Unsigned Integral < Every unsigned integral type | - Address < Every integral type that used for memory addressing |
    • Floating < Every floating point type

Definition in file typeclass.c.

Function Documentation

◆ base_type_typeclass_collect_cb()

static bool base_type_typeclass_collect_cb ( void *  user,
const void *  k,
const void *  v 
)
static

Definition at line 299 of file typeclass.c.

299  {
300  struct list_typeclass *l = user;
301  RzBaseType *btype = (RzBaseType *)v;
303  if (!get_base_type_typeclass(l->typedb, btype, &typeclass)) {
304  return false;
305  }
306  if (l->typeclass == typeclass) {
307  rz_list_append(l->types, btype);
308  }
309  return true;
310 }
const char * v
Definition: dsignal.c:12
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
RzTypeTypeclass
Definition: rz_type.h:61
const RzTypeDB * typedb
Definition: typeclass.c:294
RzTypeTypeclass typeclass
Definition: typeclass.c:296
RzList * types
Definition: typeclass.c:295
static bool get_base_type_typeclass(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type, RZ_NONNULL RzTypeTypeclass *typeclass)
Definition: typeclass.c:85

References get_base_type_typeclass(), rz_list_append(), list_typeclass::typeclass, list_typeclass::typedb, list_typeclass::types, and v.

Referenced by rz_type_typeclass_get_all().

◆ base_type_typeclass_sized_collect_cb()

static bool base_type_typeclass_sized_collect_cb ( void *  user,
const void *  k,
const void *  v 
)
static

Definition at line 319 of file typeclass.c.

319  {
320  struct list_typeclass_size *l = user;
321  RzBaseType *btype = (RzBaseType *)v;
323  if (!get_base_type_typeclass(l->typedb, btype, &typeclass)) {
324  return false;
325  }
326  if (l->typeclass == typeclass && l->size == btype->size) {
327  rz_list_append(l->types, btype);
328  }
329  return true;
330 }
RzTypeTypeclass typeclass
Definition: typeclass.c:315
const RzTypeDB * typedb
Definition: typeclass.c:313

References get_base_type_typeclass(), rz_list_append(), rz_base_type_t::size, list_typeclass_size::size, list_typeclass_size::typeclass, list_typeclass_size::typedb, list_typeclass_size::types, and v.

Referenced by rz_type_typeclass_get_all_sized().

◆ check_base_type_typeclass()

static bool check_base_type_typeclass ( const RzTypeDB typedb,
RZ_NONNULL const RzBaseType type,
RzTypeTypeclass  typeclass 
)
inlinestatic

Definition at line 123 of file typeclass.c.

123  {
124  rz_return_val_if_fail(type, false);
125  RzTypeTypeclass tclass;
126  if (!get_base_type_typeclass(typedb, type, &tclass)) {
127  return false;
128  }
129  return tclass == typeclass;
130 }
int type
Definition: mipsasm.c:17
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108

References get_base_type_typeclass(), rz_return_val_if_fail, and type.

Referenced by rz_base_type_is_floating(), rz_base_type_is_integral_signed(), and rz_base_type_is_integral_unsigned().

◆ check_type_typeclass()

static bool check_type_typeclass ( const RzTypeDB typedb,
RZ_NONNULL const RzType type,
RzTypeTypeclass  typeclass 
)
inlinestatic

Definition at line 132 of file typeclass.c.

132  {
133  rz_return_val_if_fail(type, false);
134  RzTypeTypeclass tclass;
135  if (!get_type_typeclass(typedb, type, &tclass)) {
136  return false;
137  }
138  return tclass == typeclass;
139 }
static bool get_type_typeclass(const RzTypeDB *typedb, RZ_NONNULL const RzType *type, RzTypeTypeclass *typeclass)
Definition: typeclass.c:110

References get_type_typeclass(), rz_return_val_if_fail, and type.

Referenced by rz_type_is_floating(), rz_type_is_integral_signed(), and rz_type_is_integral_unsigned().

◆ get_base_type_typeclass()

static bool get_base_type_typeclass ( const RzTypeDB typedb,
RZ_NONNULL const RzBaseType type,
RZ_NONNULL RzTypeTypeclass typeclass 
)
inlinestatic

Definition at line 85 of file typeclass.c.

85  {
86  rz_return_val_if_fail(type && typeclass, false);
87  *typeclass = type->attrs & RZ_TYPE_ATTRIBUTE_TYPECLASS_MASK;
88  if (*typeclass < RZ_TYPE_TYPECLASS_INVALID) {
89  return true;
90  }
91  // If the type is typedef, we check the underlying type all the way down
92  if (*typeclass == 0 && type->kind == RZ_BASE_TYPE_KIND_TYPEDEF) {
93  // We do not treat pointers and arrays as the same typeclass
94  if (type->type->kind != RZ_TYPE_KIND_IDENTIFIER) {
95  return false;
96  }
97  const char *identifier = rz_type_identifier(type->type);
98  if (!identifier) {
99  return false;
100  }
101  RzBaseType *t = rz_type_db_get_base_type(typedb, identifier);
102  if (!t) {
103  return false;
104  }
105  return get_base_type_typeclass(typedb, t, typeclass);
106  }
107  return false;
108 }
RZ_API RZ_BORROW RzBaseType * rz_type_db_get_base_type(const RzTypeDB *typedb, RZ_NONNULL const char *name)
Searches for the RzBaseType in the types database given the name.
Definition: base.c:57
@ RZ_BASE_TYPE_KIND_TYPEDEF
Definition: rz_type.h:76
@ RZ_TYPE_ATTRIBUTE_TYPECLASS_MASK
Definition: rz_type.h:56
@ RZ_TYPE_TYPECLASS_INVALID
Definition: rz_type.h:69
@ RZ_TYPE_KIND_IDENTIFIER
Definition: rz_type.h:128
RZ_API RZ_BORROW const char * rz_type_identifier(RZ_NONNULL const RzType *type)
Returns the type C identifier.
Definition: type.c:1155

References RZ_BASE_TYPE_KIND_TYPEDEF, rz_return_val_if_fail, RZ_TYPE_ATTRIBUTE_TYPECLASS_MASK, rz_type_db_get_base_type(), rz_type_identifier(), RZ_TYPE_KIND_IDENTIFIER, RZ_TYPE_TYPECLASS_INVALID, and type.

Referenced by base_type_typeclass_collect_cb(), base_type_typeclass_sized_collect_cb(), check_base_type_typeclass(), get_type_typeclass(), rz_base_type_is_integral(), rz_base_type_is_num(), and rz_base_type_typeclass().

◆ get_type_typeclass()

static bool get_type_typeclass ( const RzTypeDB typedb,
RZ_NONNULL const RzType type,
RzTypeTypeclass typeclass 
)
inlinestatic

Definition at line 110 of file typeclass.c.

110  {
111  rz_return_val_if_fail(type && typeclass, false);
112  const char *identifier = rz_type_identifier(type);
113  if (!identifier) {
114  return false;
115  }
116  RzBaseType *t = rz_type_db_get_base_type(typedb, identifier);
117  if (!t) {
118  return false;
119  }
120  return get_base_type_typeclass(typedb, t, typeclass);
121 }

References get_base_type_typeclass(), rz_return_val_if_fail, rz_type_db_get_base_type(), rz_type_identifier(), and type.

Referenced by check_type_typeclass(), rz_type_is_integral(), rz_type_is_num(), and rz_type_typeclass().

◆ rz_base_type_is_floating()

RZ_API bool rz_base_type_is_floating ( const RzTypeDB typedb,
RZ_NONNULL const RzBaseType type 
)

Checks if the RzBaseType is Floating typeclass.

Parameters
typedbType Database instance
typeRzBaseType type pointer

Definition at line 233 of file typeclass.c.

233  {
234  rz_return_val_if_fail(type, false);
236 }
@ RZ_TYPE_TYPECLASS_FLOATING
Definition: rz_type.h:65
static bool check_base_type_typeclass(const RzTypeDB *typedb, RZ_NONNULL const RzBaseType *type, RzTypeTypeclass typeclass)
Definition: typeclass.c:123

References check_base_type_typeclass(), rz_return_val_if_fail, RZ_TYPE_TYPECLASS_FLOATING, and type.

◆ rz_base_type_is_integral()

RZ_API bool rz_base_type_is_integral ( const RzTypeDB typedb,
RZ_NONNULL const RzBaseType type 
)

Checks if the RzBaseType is Integral typeclass.

Parameters
typedbType Database instance
typeRzBaseType type pointer

Definition at line 203 of file typeclass.c.

203  {
204  rz_return_val_if_fail(type, false);
205  RzTypeTypeclass tclass;
206  if (!get_base_type_typeclass(typedb, type, &tclass)) {
207  return false;
208  }
209  return typeclass_is_integal(tclass);
210 }
static bool typeclass_is_integal(RzTypeTypeclass t)
Definition: typeclass.c:30

References get_base_type_typeclass(), rz_return_val_if_fail, type, and typeclass_is_integal().

◆ rz_base_type_is_integral_signed()

RZ_API bool rz_base_type_is_integral_signed ( const RzTypeDB typedb,
RZ_NONNULL const RzBaseType type 
)

Checks if the RzBaseType is Integral and Signed typeclass.

Parameters
typedbType Database instance
typeRzBaseType type pointer

Definition at line 255 of file typeclass.c.

255  {
256  rz_return_val_if_fail(type, false);
258 }
@ RZ_TYPE_TYPECLASS_INTEGRAL_SIGNED
Definition: rz_type.h:67

References check_base_type_typeclass(), rz_return_val_if_fail, RZ_TYPE_TYPECLASS_INTEGRAL_SIGNED, and type.

◆ rz_base_type_is_integral_unsigned()

RZ_API bool rz_base_type_is_integral_unsigned ( const RzTypeDB typedb,
RZ_NONNULL const RzBaseType type 
)

Checks if the RzBaseType is Integral and Unsigned typeclass.

Parameters
typedbType Database instance
typeRzBaseType type pointer

Definition at line 277 of file typeclass.c.

277  {
278  rz_return_val_if_fail(type, false);
280 }
@ RZ_TYPE_TYPECLASS_INTEGRAL_UNSIGNED
Definition: rz_type.h:68

References check_base_type_typeclass(), rz_return_val_if_fail, RZ_TYPE_TYPECLASS_INTEGRAL_UNSIGNED, and type.

◆ rz_base_type_is_num()

RZ_API bool rz_base_type_is_num ( const RzTypeDB typedb,
RZ_NONNULL const RzBaseType type 
)

Checks if the RzBaseType is Num typeclass.

Parameters
typedbType Database instance
typeRzBaseType type pointer

Definition at line 173 of file typeclass.c.

173  {
174  rz_return_val_if_fail(type, false);
175  RzTypeTypeclass tclass;
176  if (!get_base_type_typeclass(typedb, type, &tclass)) {
177  return false;
178  }
179  return typeclass_is_num(tclass);
180 }
static bool typeclass_is_num(RzTypeTypeclass t)
Definition: typeclass.c:26

References get_base_type_typeclass(), rz_return_val_if_fail, type, and typeclass_is_num().

◆ rz_base_type_typeclass()

RZ_API RzTypeTypeclass rz_base_type_typeclass ( const RzTypeDB typedb,
RZ_NONNULL const RzBaseType type 
)

Gets the base type class.

Parameters
typedbType Database instance
typeRzBaseType type pointer

Definition at line 147 of file typeclass.c.

147  {
148  rz_return_val_if_fail(type, false);
150  get_base_type_typeclass(typedb, type, &tclass);
151  return tclass;
152 }

References get_base_type_typeclass(), rz_return_val_if_fail, RZ_TYPE_TYPECLASS_INVALID, and type.

Referenced by rz_type_integral_set_sign().

◆ rz_type_is_floating()

RZ_API bool rz_type_is_floating ( const RzTypeDB typedb,
RZ_NONNULL const RzType type 
)

Checks if the RzType is Floating typeclass.

Parameters
typedbType Database instance
typeRzType type pointer

Definition at line 244 of file typeclass.c.

244  {
245  rz_return_val_if_fail(type, false);
247 }
static bool check_type_typeclass(const RzTypeDB *typedb, RZ_NONNULL const RzType *type, RzTypeTypeclass typeclass)
Definition: typeclass.c:132

References check_type_typeclass(), rz_return_val_if_fail, RZ_TYPE_TYPECLASS_FLOATING, and type.

◆ rz_type_is_integral()

RZ_API bool rz_type_is_integral ( const RzTypeDB typedb,
RZ_NONNULL const RzType type 
)

Checks if the RzType is Integral typeclass.

Parameters
typedbType Database instance
typeRzType type pointer

Definition at line 218 of file typeclass.c.

218  {
219  rz_return_val_if_fail(type, false);
220  RzTypeTypeclass tclass;
221  if (!get_type_typeclass(typedb, type, &tclass)) {
222  return false;
223  }
224  return typeclass_is_integal(tclass);
225 }

References get_type_typeclass(), rz_return_val_if_fail, type, and typeclass_is_integal().

Referenced by rz_type_integral_set_sign(), var_type_set_sign(), and var_type_simple_to_complex().

◆ rz_type_is_integral_signed()

RZ_API bool rz_type_is_integral_signed ( const RzTypeDB typedb,
RZ_NONNULL const RzType type 
)

Checks if the RzType is Integral and Signed typeclass.

Parameters
typedbType Database instance
typeRzType type pointer

Definition at line 266 of file typeclass.c.

266  {
267  rz_return_val_if_fail(type, false);
269 }

References check_type_typeclass(), rz_return_val_if_fail, RZ_TYPE_TYPECLASS_INTEGRAL_SIGNED, and type.

◆ rz_type_is_integral_unsigned()

RZ_API bool rz_type_is_integral_unsigned ( const RzTypeDB typedb,
RZ_NONNULL const RzType type 
)

Checks if the RzType is Integral and Unsigned typeclass.

Parameters
typedbType Database instance
typeRzType type pointer

Definition at line 288 of file typeclass.c.

288  {
289  rz_return_val_if_fail(type, false);
291 }

References check_type_typeclass(), rz_return_val_if_fail, RZ_TYPE_TYPECLASS_INTEGRAL_UNSIGNED, and type.

◆ rz_type_is_num()

RZ_API bool rz_type_is_num ( const RzTypeDB typedb,
RZ_NONNULL const RzType type 
)

Checks if the RzType is Num typeclass.

Parameters
typedbType Database instance
typeRzType type pointer

Definition at line 188 of file typeclass.c.

188  {
189  rz_return_val_if_fail(type, false);
190  RzTypeTypeclass tclass;
191  if (!get_type_typeclass(typedb, type, &tclass)) {
192  return false;
193  }
194  return typeclass_is_num(tclass);
195 }

References get_type_typeclass(), rz_return_val_if_fail, type, and typeclass_is_num().

◆ rz_type_typeclass()

RZ_API RzTypeTypeclass rz_type_typeclass ( const RzTypeDB typedb,
RZ_NONNULL const RzType type 
)

Gets the type class.

Parameters
typedbType Database instance
typeRzBaseType type pointer

Definition at line 160 of file typeclass.c.

160  {
161  rz_return_val_if_fail(type, false);
163  get_type_typeclass(typedb, type, &tclass);
164  return tclass;
165 }

References get_type_typeclass(), rz_return_val_if_fail, RZ_TYPE_TYPECLASS_INVALID, and type.

◆ rz_type_typeclass_as_string()

RZ_API RZ_BORROW const char* rz_type_typeclass_as_string ( RzTypeTypeclass  typeclass)

Returns the string representation of a typeclass.

Parameters
typeclassA typeclass

Definition at line 39 of file typeclass.c.

39  {
40  switch (typeclass) {
42  return "Num";
44  return "Integral";
46  return "Floating";
48  return "Address";
50  return "Signed Integral";
52  return "Unsigned Integral";
54  return "None";
55  default:
57  }
58  return "None";
59 }
#define rz_warn_if_reached()
Definition: rz_assert.h:29
@ RZ_TYPE_TYPECLASS_NONE
Definition: rz_type.h:62
@ RZ_TYPE_TYPECLASS_ADDRESS
Definition: rz_type.h:66
@ RZ_TYPE_TYPECLASS_NUM
Definition: rz_type.h:63
@ RZ_TYPE_TYPECLASS_INTEGRAL
Definition: rz_type.h:64

References RZ_TYPE_TYPECLASS_ADDRESS, RZ_TYPE_TYPECLASS_FLOATING, RZ_TYPE_TYPECLASS_INTEGRAL, RZ_TYPE_TYPECLASS_INTEGRAL_SIGNED, RZ_TYPE_TYPECLASS_INTEGRAL_UNSIGNED, RZ_TYPE_TYPECLASS_NONE, RZ_TYPE_TYPECLASS_NUM, and rz_warn_if_reached.

Referenced by save_atomic_type().

◆ rz_type_typeclass_from_string()

RZ_API RzTypeTypeclass rz_type_typeclass_from_string ( RZ_NONNULL const char *  typeclass)

Returns the typeclass from the string name of it.

Parameters
typeclassA typeclass name

Definition at line 66 of file typeclass.c.

66  {
68 
69  if (!strcmp(typeclass, "Integral")) {
71  } else if (!strcmp(typeclass, "Signed Integral")) {
73  } else if (!strcmp(typeclass, "Unsigned Integral")) {
75  } else if (!strcmp(typeclass, "Floating")) {
77  } else if (!strcmp(typeclass, "Address")) {
79  } else if (!strcmp(typeclass, "Num")) {
80  return RZ_TYPE_TYPECLASS_NUM;
81  }
83 }
#define RZ_STR_ISNOTEMPTY(x)
Definition: rz_str.h:68

References rz_return_val_if_fail, RZ_STR_ISNOTEMPTY, RZ_TYPE_TYPECLASS_ADDRESS, RZ_TYPE_TYPECLASS_FLOATING, RZ_TYPE_TYPECLASS_INTEGRAL, RZ_TYPE_TYPECLASS_INTEGRAL_SIGNED, RZ_TYPE_TYPECLASS_INTEGRAL_UNSIGNED, RZ_TYPE_TYPECLASS_NONE, and RZ_TYPE_TYPECLASS_NUM.

Referenced by get_atomic_type().

◆ rz_type_typeclass_get_all()

RZ_API RZ_OWN RzList* rz_type_typeclass_get_all ( const RzTypeDB typedb,
RzTypeTypeclass  typeclass 
)

Returns the list of all base types given the typeclass.

Parameters
typedbType Database instance
typeclasstypeclass (cannot be None)

Definition at line 338 of file typeclass.c.

338  {
339  rz_return_val_if_fail(typedb && typeclass != RZ_TYPE_TYPECLASS_NONE, NULL);
341  RzList *types = rz_list_new();
342  struct list_typeclass lt = { typedb, types, typeclass };
343  ht_pp_foreach(typedb->types, base_type_typeclass_collect_cb, &lt);
344  return types;
345 }
#define NULL
Definition: cris-opc.c:27
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
Definition: list.c:235
insn_type_descr_t types[]
Definition: or1k_disas.c:7
HtPP * types
Definition: rz_type.h:33
static bool base_type_typeclass_collect_cb(void *user, const void *k, const void *v)
Definition: typeclass.c:299

References base_type_typeclass_collect_cb(), lt, NULL, rz_list_new(), rz_return_val_if_fail, RZ_TYPE_TYPECLASS_INVALID, RZ_TYPE_TYPECLASS_NONE, list_typeclass::typeclass, list_typeclass_size::typeclass, list_typeclass::typedb, list_typeclass_size::typedb, types, and rz_type_db_t::types.

◆ rz_type_typeclass_get_all_sized()

RZ_API RZ_OWN RzList* rz_type_typeclass_get_all_sized ( const RzTypeDB typedb,
RzTypeTypeclass  typeclass,
size_t  size 
)

Returns the list of all base types given the typeclass and size.

Parameters
typedbType Database instance
typeclasstypeclass (cannot be None)
sizeThe bitsize of a type to select from

Definition at line 354 of file typeclass.c.

354  {
355  rz_return_val_if_fail(typedb && typeclass != RZ_TYPE_TYPECLASS_NONE, NULL);
357  RzList *types = rz_list_new();
360  return types;
361 }
voidpf void uLong size
Definition: ioapi.h:138
static bool base_type_typeclass_sized_collect_cb(void *user, const void *k, const void *v)
Definition: typeclass.c:319

References base_type_typeclass_sized_collect_cb(), lt, NULL, rz_list_new(), rz_return_val_if_fail, RZ_TYPE_TYPECLASS_INVALID, RZ_TYPE_TYPECLASS_NONE, list_typeclass::typeclass, list_typeclass_size::typeclass, list_typeclass::typedb, list_typeclass_size::typedb, types, and rz_type_db_t::types.

Referenced by rz_type_typeclass_get_default_sized().

◆ rz_type_typeclass_get_default_sized()

RZ_API RZ_OWN RzBaseType* rz_type_typeclass_get_default_sized ( const RzTypeDB typedb,
RzTypeTypeclass  typeclass,
size_t  size 
)

Returns the default base type given the typeclass and size.

Parameters
typedbType Database instance
typeclasstypeclass (cannot be None)
sizeThe bitsize of a type to select from

Definition at line 370 of file typeclass.c.

370  {
371  rz_return_val_if_fail(typedb && typeclass != RZ_TYPE_TYPECLASS_NONE, NULL);
373  RzList *l = rz_type_typeclass_get_all_sized(typedb, typeclass, size);
374  if (!l || rz_list_empty(l)) {
375  return NULL;
376  }
377  RzBaseType *ret = rz_list_pop(l);
378  rz_list_free(l);
379  return ret;
380 }
RZ_API RZ_OWN void * rz_list_pop(RZ_NONNULL RzList *list)
Removes and returns the last element of the list.
Definition: list.c:376
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
RZ_API RZ_OWN RzList * rz_type_typeclass_get_all_sized(const RzTypeDB *typedb, RzTypeTypeclass typeclass, size_t size)
Returns the list of all base types given the typeclass and size.
Definition: typeclass.c:354

References NULL, rz_list_free(), rz_list_pop(), rz_return_val_if_fail, rz_type_typeclass_get_all_sized(), RZ_TYPE_TYPECLASS_INVALID, RZ_TYPE_TYPECLASS_NONE, list_typeclass_size::typeclass, and list_typeclass_size::typedb.

Referenced by rz_type_integral_set_sign().

◆ typeclass_is_integal()

◆ typeclass_is_num()