00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef CUEX_EX_H
00019 #define CUEX_EX_H
00020
00021 #include <cuex/fwd.h>
00022 #include <cuoo/meta.h>
00023
00024 CU_BEGIN_DECLARATIONS
00025
00026
00027
00028
00029
00030 #define cuex_opr(index, arity) \
00031 (((cuex_meta_t)(index) << CUEX_OPR_SELECT_SHIFT) | \
00032 ((cuex_meta_t)(arity) << CUEX_OPR_ARITY_SHIFT) | 1)
00033 #define cuex_opr_with_ctor(index, arity) \
00034 (cuex_opr(index, arity) | CUEX_OPRFLAG_CTOR)
00035 #define cuex_opr_index(opr) \
00036 (((opr) & CUEX_OPR_SELECT_MASK) >> CUEX_OPR_SELECT_SHIFT)
00037 #define cuex_opr_sans_arity(opr) ((opr) & ~CUEX_OPR_ARITY_MASK)
00038 #define cuex_opr_flags(opr) ((opr) & CUEX_OPR_FLAGS_MASK)
00039 #define cuex_opr_sans_flags(opr) ((opr) & ~CUEX_OPR_FLAGS_MASK)
00040 #define cuex_opr_has_ctor(opr) ((opr) & CUEX_OPRFLAG_CTOR)
00041
00042
00043
00044
00045
00046
00047 #define cuex_opr_null cuex_opr(0, 0)
00048
00049 extern cuex_t cuexP_null;
00050 extern cuex_t cuexP_unknown;
00051
00052 #define cuex_opn_to_ex(opn) ((cuex_t)(opn))
00053 #define cuex_opn_from_ex(ex) ((cuex_opn_t)(ex))
00054
00055
00056 CU_SINLINE cu_bool_t cuex_is_opn(cuex_t ex)
00057 { return cuex_meta_kind(cuex_meta(ex)) == cuex_meta_kind_opr; }
00058
00059
00060 CU_SINLINE cu_bool_t cuex_is_obj(cuex_t ex)
00061 { return cuex_meta_kind(cuex_meta(ex)) == cuex_meta_kind_type; }
00062
00063
00064 CU_SINLINE cu_rank_t cuex_opn_r(cuex_opn_t opn)
00065 { return cuex_opr_r(cuex_meta(opn)); }
00066
00067
00068 CU_SINLINE cuex_t cuex_null() { return cuexP_null; }
00069
00070
00071 CU_SINLINE cu_bool_t cuex_is_null(cuex_t ex)
00072 { return cuex_meta(ex) == cuex_opr_null; }
00073
00074
00075 CU_SINLINE cuex_t cuex_unknown() { return cuexP_unknown; }
00076
00077
00078 CU_SINLINE cu_bool_t cuex_is_unknown(cuex_t ex)
00079 { return ex == cuexP_unknown; }
00080
00081
00082
00083
00084 CU_SINLINE cu_bool_t cuex_eq(cuex_t ex0, cuex_t ex1) { return ex0 == ex1; }
00085
00086
00087
00088
00089
00090
00091 CU_SINLINE int cuex_cmp(cuex_t lhs, cuex_t rhs)
00092 { return lhs < rhs ? -1 : lhs == rhs ? 0 : 1; }
00093
00094
00095 CU_SINLINE cu_bool_t cuex_leq(cuex_t lhs, cuex_t rhs)
00096 { return cuex_cmp(lhs, rhs) <= 0; }
00097
00098
00099 CU_SINLINE cu_bool_t cuex_lt(cuex_t lhs, cuex_t rhs)
00100 { return cuex_cmp(lhs, rhs) < 0; }
00101
00102
00103 CU_SINLINE cu_bool_t cuex_geq(cuex_t lhs, cuex_t rhs)
00104 { return cuex_cmp(lhs, rhs) >= 0; }
00105
00106
00107 CU_SINLINE cu_bool_t cuex_gt(cuex_t lhs, cuex_t rhs)
00108 { return cuex_cmp(lhs, rhs) > 0; }
00109
00110
00111 CU_SINLINE cuex_t cuex_min(cuex_t lhs, cuex_t rhs)
00112 { return cuex_leq(lhs, rhs)? lhs : rhs; }
00113
00114
00115 CU_SINLINE cuex_t cuex_max(cuex_t lhs, cuex_t rhs)
00116 { return cuex_leq(lhs, rhs)? rhs : lhs; }
00117
00118
00119
00120
00121 CU_SINLINE cuex_t cuex_uniq(cuex_t ex) { return ex; }
00122
00123
00124 CU_END_DECLARATIONS
00125
00126 #endif