2.3.6 Reflection API

C Function: gcc_jit_type * gcc_jit_type_dyncast_array (gcc_jit_type *type)

Get the element type of an array type or NULL if it’s not an array.

C Function: int gcc_jit_type_is_bool (gcc_jit_type *type)

Return non-zero if the type is a bool.

C Function: gcc_jit_function_type * gcc_jit_type_dyncast_function_ptr_type (gcc_jit_type *type)

Return the function type if it is one or NULL.

C Function: gcc_jit_type * gcc_jit_function_type_get_return_type (gcc_jit_function_type *function_type)

Given a function type, return its return type.

C Function: size_t gcc_jit_function_type_get_param_count (gcc_jit_function_type *function_type)

Given a function type, return its number of parameters.

C Function: gcc_jit_type * gcc_jit_function_type_get_param_type (gcc_jit_function_type *function_type, size_t index)

Given a function type, return the type of the specified parameter.

C Function: int gcc_jit_type_is_integral (gcc_jit_type *type)

Return non-zero if the type is an integral.

C Function: gcc_jit_type * gcc_jit_type_is_pointer (gcc_jit_type *type)

Return the type pointed by the pointer type or NULL if it’s not a pointer.

C Function: gcc_jit_vector_type * gcc_jit_type_dyncast_vector (gcc_jit_type *type)

Given a type, return a dynamic cast to a vector type or NULL.

C Function: gcc_jit_struct * gcc_jit_type_is_struct (gcc_jit_type *type)

Given a type, return a dynamic cast to a struct type or NULL.

C Function: size_t gcc_jit_vector_type_get_num_units (gcc_jit_vector_type *vector_type)

Given a vector type, return the number of units it contains.

C Function: gcc_jit_type * gcc_jit_vector_type_get_element_type (gcc_jit_vector_type * vector_type)

Given a vector type, return the type of its elements.

C Function: gcc_jit_type * gcc_jit_type_unqualified (gcc_jit_type *type)

Given a type, return the unqualified type, removing “const”, “volatile” and alignment qualifiers.

C Function: gcc_jit_field * gcc_jit_struct_get_field (gcc_jit_struct *struct_type, size_t index)

Get a struct field by index.

C Function: size_t gcc_jit_struct_get_field_count (gcc_jit_struct *struct_type)

Get the number of fields in the struct.

The API entrypoints related to the reflection API:

were added in LIBGCCJIT_ABI_16; you can test for their presence using

#ifdef LIBGCCJIT_HAVE_REFLECTION
C Type: gcc_jit_case
C Function: int gcc_jit_compatible_types (gcc_jit_type *ltype, gcc_jit_type *rtype)

Return non-zero if the two types are compatible. For instance, if GCC_JIT_TYPE_UINT64_T and GCC_JIT_TYPE_UNSIGNED_LONG are the same size on the target, this will return non-zero. The parameters ltype and rtype must be non-NULL. Return 0 on errors.

This entrypoint was added in LIBGCCJIT_ABI_20; you can test for its presence using

#ifdef LIBGCCJIT_HAVE_SIZED_INTEGERS
C Function: ssize_t gcc_jit_type_get_size (gcc_jit_type *type)

Return the size of a type, in bytes. It only works on integer types for now. The parameter type must be non-NULL. Return -1 on errors.

This entrypoint was added in LIBGCCJIT_ABI_20; you can test for its presence using

#ifdef LIBGCCJIT_HAVE_SIZED_INTEGERS