Cthulhu  0.2.10
Cthulhu compiler collection
util.c File Reference
#include "cthulhu/util/util.h"
#include "cthulhu/events/events.h"
#include "cthulhu/util/types.h"
#include "cthulhu/tree/query.h"
#include "memory/memory.h"
#include "std/str.h"
#include "base/panic.h"
#include <stdint.h>
Include dependency graph for util.c:

Go to the source code of this file.

Functions

void * util_select_decl (tree_t *sema, search_t search, const char *name)
 search for a declaration by name in a set of tags More...
 
bool util_types_equal (const tree_t *lhs, const tree_t *rhs)
 compare two types for strict equality compares two types for exact equality, does not follow typedefs More...
 
bool util_types_comparable (tree_cookie_t *cookie, const tree_t *lhs, const tree_t *rhs)
 query two types for comparability in binary logic operations More...
 
tree_tutil_type_cast (const tree_t *dst, tree_t *expr)
 attempt to cast an expression to a type More...
 
bool util_eval_digit (mpz_t value, const tree_t *expr)
 evaluate a digit expression More...
 
bool util_length_bounded (size_t length)
 check if the length of an array is bounded More...
 
const char * util_length_name (size_t length)
 get the pretty name of a length return either the length as a string or "unbounded" if the length is unbounded More...
 
bool util_type_is_aggregate (const tree_t *type)
 
bool util_type_is_pointer (const tree_t *type)
 
bool util_type_is_array (const tree_t *type)
 
bool util_type_is_opaque (const tree_t *type)
 
bool util_type_is_reference (const tree_t *type)
 
bool util_type_is_digit (const tree_t *type)
 

Function Documentation

◆ util_length_bounded()

bool util_length_bounded ( size_t  length)

check if the length of an array is bounded

Parameters
lengththe length of the array
Returns
true if the length is bounded, false otherwise

Definition at line 312 of file util.c.

◆ util_length_name()

const char* util_length_name ( size_t  length)

get the pretty name of a length return either the length as a string or "unbounded" if the length is unbounded

Parameters
lengththe length to get the name of
Returns
the name of the length

Definition at line 317 of file util.c.

◆ util_type_cast()

tree_t* util_type_cast ( const tree_t dst,
tree_t expr 
)

attempt to cast an expression to a type

Parameters
dstthe desired type
exprthe expression to try and cast
Returns
tree_t* the casted expression or tree_error if the cast could not be done

Definition at line 212 of file util.c.

◆ util_type_is_aggregate()

bool util_type_is_aggregate ( const tree_t type)

Definition at line 323 of file util.c.

◆ util_type_is_array()

bool util_type_is_array ( const tree_t type)

Definition at line 335 of file util.c.

◆ util_type_is_digit()

bool util_type_is_digit ( const tree_t type)

Definition at line 353 of file util.c.

◆ util_type_is_opaque()

bool util_type_is_opaque ( const tree_t type)

Definition at line 341 of file util.c.

◆ util_type_is_pointer()

bool util_type_is_pointer ( const tree_t type)

Definition at line 329 of file util.c.

◆ util_type_is_reference()

bool util_type_is_reference ( const tree_t type)

Definition at line 347 of file util.c.

◆ util_types_comparable()

bool util_types_comparable ( tree_cookie_t cookie,
const tree_t lhs,
const tree_t rhs 
)

query two types for comparability in binary logic operations

Parameters
lhsthe left hand side type
rhsthe right hand side type
Returns
true if the types are comparable, false otherwise

Definition at line 69 of file util.c.