Data Structures | |
struct | cuex_xvarops |
Modules | |
cuex_ivar, cuex_rvar: Indexed Variables | |
Defines | |
#define | CUEXP_VARMETA_QCODE_WIDTH 2 |
#define | CUEXP_VARMETA_KIND_WIDTH 3 |
#define | CUEXP_VARMETA_QCODE_SHIFT (CUEXP_VARMETA_WSIZE_SHIFT + CUEXP_VARMETA_WSIZE_WIDTH) |
#define | CUEXP_VARMETA_KIND_SHIFT (CUEXP_VARMETA_QCODE_SHIFT + CUEXP_VARMETA_QCODE_WIDTH) |
#define | CUEXP_VARMETA_INDEX_SHIFT (CUEXP_VARMETA_KIND_SHIFT + CUEXP_VARMETA_KIND_WIDTH) |
#define | CUEXP_VARMETA_QCODE_MASK CUEX_META_MASK(CUEXP_VARMETA_QCODE_SHIFT, CUEXP_VARMETA_QCODE_WIDTH) |
#define | CUEXP_VARMETA_KIND_MASK CUEX_META_MASK(CUEXP_VARMETA_KIND_SHIFT, CUEXP_VARMETA_KIND_WIDTH) |
#define | CUEXP_VARMETA_INDEX_MASK CUEX_META_MASK(CUEXP_VARMETA_INDEX_SHIFT, CUEXP_VARMETA_INDEX_WIDTH) |
#define | cuex_varmeta_kqis(kind, qcode, index, wsize) |
#define | cuex_varmeta_kqi(kind, qcode, index) cuex_varmeta_kqis(kind, qcode, index, 0) |
#define | cuex_is_varmeta_kqis(meta, kind, qcode, index, wsize) ((meta) == cuex_varmeta_kqis(kind, qcode, index, wsize)) |
#define | cuex_is_varmeta_kqi(meta, kind, qcode, index) ((meta) == cuex_varmeta_kqi(kind, qcode, index)) |
#define | cuex_is_varmeta_kq(meta, kind, qcode) |
#define | cuex_is_varmeta_ki(meta, kind, index) |
#define | cuex_is_varmeta_k(meta, kind) |
#define | cuex_is_varmeta_q(meta, qcode) |
#define | cuex_is_varmeta(meta) (((CUEXP_VARMETA_SELECT_MASK) & (meta)) == cuex_varmeta_kqi(0, 0, 0)) |
#define | cuex_varmeta_qcode(meta) |
#define | cuex_varmeta_index(meta) (((meta) & CUEXP_VARMETA_INDEX_MASK ) >> CUEXP_VARMETA_INDEX_SHIFT) |
#define | cuex_is_varmeta_u(meta) cuex_is_varmeta_q(meta, cuex_qcode_u) |
#define | cuex_is_varmeta_e(meta) cuex_is_varmeta_q(meta, cuex_qcode_e) |
#define | cuex_is_varmeta_w(meta) cuex_is_varmeta_q(meta, cuex_qcode_w) |
#define | cuex_is_varmeta_n(meta) cuex_is_varmeta_q(meta, cuex_qcode_n) |
#define | cuex_var_to_ex(var) ((cuex_t)(var)) |
#define | cuex_var_from_ex(ex) ((cuex_var_t)(ex)) |
#define | cuex_var_qcode(var) cuex_varmeta_qcode(cuex_meta(var)) |
#define | cuex_var_new_e() cuex_var_new(cuex_qcode_e) |
#define | cuex_var_new_u() cuex_var_new(cuex_qcode_u) |
#define | cuex_var_new_w() cuex_var_new(cuex_qcode_w) |
#define | cuex_var_new_n() cuex_var_new(cuex_qcode_n) |
#define | cuex_xvarmeta(qcode, subkind, wsize) cuex_varmeta_kqis(cuex_varkind_xvar, qcode, subkind, wsize) |
Typedefs | |
typedef struct cuex_xvarops * | cuex_xvarops_t |
Enumerations | |
enum | cuex_varkind_t { cuex_varkind_svar, cuex_varkind_tvar, cuex_varkind_tpvar, cuex_varkind_fpvar, cuex_varkind_pvar, cuex_varkind_ivar, cuex_varkind_rvar, cuex_varkind_xvar } |
Functions | |
cu_bool_t | cuex_is_var (cuex_t ex) |
cuex_var_t | cuex_var_new (cuex_qcode_t qcode) |
cuex_meta_t | cuex_register_xvarkind (cuex_meta_t subkind, unsigned int wsize, cuex_xvarops_t ops) |
cu_bool_t | cuex_is_xvarmeta (cuex_meta_t meta) |
cu_bool_t | cuex_is_xvarmeta_k (cuex_meta_t meta, cuex_varkind_t subkind) |
cu_bool_t | cuex_is_xvarmeta_kq (cuex_meta_t meta, cuex_varkind_t subkind, cuex_qcode_t qcode) |
cuex_meta_t | cuex_xvarmeta_subkind (cuex_meta_t meta) |
cuex_t | cuex_xvar_alloc (cuex_meta_t xvarmeta) |
Variables | |
struct cucon_umap | cuexP_xvarops |
Variables are structureless expressions. They have no properties except for pointer equality, quantisation, and their type. Their main use is as placeholders for values to be substituted or as to express patterns (cf cuex/ssfn.h: Syntactic/Semantic Functions).
Quantisation can not be changed once a variable is created. Instead, after analysis, create new variables of the correct quantisation, optionally put the in a cucon_pmap_t
or cuex_subst_t
, and transform the expressions accordingly.
#define cuex_is_varmeta | ( | meta | ) | (((CUEXP_VARMETA_SELECT_MASK) & (meta)) == cuex_varmeta_kqi(0, 0, 0)) |
The meta of a simple variable quantified as qcode.
#define cuex_is_varmeta_k | ( | meta, | |||
kind | ) |
((( CUEXP_VARMETA_SELECT_MASK \ | CUEXP_VARMETA_KIND_MASK ) & (meta)) \ == cuex_varmeta_kqi(kind, 0, 0))
#define cuex_is_varmeta_ki | ( | meta, | |||
kind, | |||||
index | ) |
((( CUEXP_VARMETA_SELECT_MASK \ | CUEXP_VARMETA_KIND_MASK \ | CUEXP_VARMETA_INDEX_MASK ) & (meta)) \ == cuex_varmeta_kqi(kind, 0, index))
#define cuex_is_varmeta_kq | ( | meta, | |||
kind, | |||||
qcode | ) |
((( CUEXP_VARMETA_SELECT_MASK \ | CUEXP_VARMETA_KIND_MASK \ | CUEXP_VARMETA_QCODE_MASK ) & (meta)) \ == cuex_varmeta_kqi(kind, qcode, 0))
#define cuex_is_varmeta_q | ( | meta, | |||
qcode | ) |
((( CUEXP_VARMETA_SELECT_MASK \ | CUEXP_VARMETA_QCODE_MASK ) & (meta)) \ == cuex_varmeta_kqi(0, qcode, 0))
#define cuex_var_new_e | ( | ) | cuex_var_new(cuex_qcode_e) |
Creates an existential variable.
#define cuex_var_new_n | ( | ) | cuex_var_new(cuex_qcode_n) |
Create an unquantified variable. Used before quantisation is analysed or in cases where it does not apply.
#define cuex_var_new_u | ( | ) | cuex_var_new(cuex_qcode_u) |
Creates a universal variable.
#define cuex_var_new_w | ( | ) | cuex_var_new(cuex_qcode_w) |
Creates a weak universal (or parametric) variable. Roughly, this is a variable which is quantified to the extent that the expression it occurs in do not contradict more specialised expressions. The precise definition may be application dependent.
#define cuex_var_qcode | ( | var | ) | cuex_varmeta_qcode(cuex_meta(var)) |
Returns the quantisation of var.
#define cuex_varmeta_kqis | ( | kind, | |||
qcode, | |||||
index, | |||||
wsize | ) |
(CUEXP_VARMETA_SELECT_VALUE \ | ((wsize) << CUEXP_VARMETA_WSIZE_SHIFT) \ | ((kind) << CUEXP_VARMETA_KIND_SHIFT) \ | ((qcode) << CUEXP_VARMETA_QCODE_SHIFT) \ | ((index) << CUEXP_VARMETA_INDEX_SHIFT) )
#define cuex_varmeta_qcode | ( | meta | ) |
((cuex_qcode_t) \ (((meta) & CUEXP_VARMETA_QCODE_MASK) >> CUEXP_VARMETA_QCODE_SHIFT))
The quantification of variables of meta.
#define cuex_xvarmeta | ( | qcode, | |||
subkind, | |||||
wsize | ) | cuex_varmeta_kqis(cuex_varkind_xvar, qcode, subkind, wsize) |
Compose a meta for an extended variable kind from the given quantisation, subkind and slot size. The slot size wsize is in words (cu_word_t).
cu_bool_t cuex_is_xvarmeta | ( | cuex_meta_t | meta | ) |
True iff meta is describes an extended variable kind.
cu_bool_t cuex_is_xvarmeta_k | ( | cuex_meta_t | meta, | |
cuex_varkind_t | subkind | |||
) |
True iff meta is an extended variable kind meta of with the given subkind.
cu_bool_t cuex_is_xvarmeta_kq | ( | cuex_meta_t | meta, | |
cuex_varkind_t | subkind, | |||
cuex_qcode_t | qcode | |||
) |
True iff meta is an extended variable kind meta of the given subkind and quantification.
cuex_meta_t cuex_register_xvarkind | ( | cuex_meta_t | subkind, | |
unsigned int | wsize, | |||
cuex_xvarops_t | ops | |||
) |
Call this at startup to register new variable subkinds. This checks that subkind is unique and registers the callbacks ops for variables of this kind. It is up to the client to ensure that subkind is unique across the codebase. Alternatively, pass subkind = (cuex_meta_t)(-1) to dynamically allocate a free subkind. The registered subkind is returned.
This shall be called from the main thread.
cuex_var_t cuex_var_new | ( | cuex_qcode_t | qcode | ) |
Returns a new variable with quantisation qcode. The variable has no properties besides its type, and pointer equality.
cuex_t cuex_xvar_alloc | ( | cuex_meta_t | xvarmeta | ) |
Allocate a variable of extended kind with meta xvarmeta.
cuex_meta_t cuex_xvarmeta_subkind | ( | cuex_meta_t | meta | ) |
Extracts the subkind of meta which is assumed to describe an extended variable kind.