00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef CUEX_TYPE_H
00019 #define CUEX_TYPE_H
00020
00021 #include <cuex/fwd.h>
00022 #include <cuex/oprdefs.h>
00023 #include <cudyn/type.h>
00024 #include <cuoo/halloc.h>
00025
00026 CU_BEGIN_DECLARATIONS
00027
00028
00029
00030 size_t cuex_type_bitsize(cuex_t type);
00031
00032 CU_SINLINE size_t cuex_type_size(cuex_t type)
00033 {
00034 size_t s = cuex_type_bitsize(type);
00035 return (s + 7)/8;
00036 }
00037
00038 cu_offset_t cuex_type_bitalign(cuex_t type);
00039
00040 CU_SINLINE cu_offset_t cuex_type_align(cuex_t type)
00041 {
00042 cu_offset_t a = cuex_type_bitalign(type);
00043 return (a + 7)/8;
00044 }
00045
00046 cu_rank_t cuex_farrow_arity(cuex_t type);
00047
00048 cuex_t cuex_typeof(cuex_t e);
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 CU_SINLINE cuex_t
00064 cuex_of_fnptr(cuex_t t, cu_fnptr_t fn)
00065 {
00066 cu_debug_assert(cuex_meta(t) == CUEX_O2_FARROW_NATIVE
00067 || cuex_meta(t) == CUEX_O2_FORALL);
00068 return cuoo_halloc(cuoo_type(t), sizeof(void *), &fn);
00069 }
00070
00071 CU_SINLINE cu_bool_t
00072 cuex_is_fnptr(cuex_t t)
00073 {
00074 cuex_meta_t m = cuex_meta(t);
00075 return cuex_meta_is_type(m)
00076 && cuex_meta(cuoo_type_as_expr(cuoo_type_from_meta(m)))
00077 == CUEX_O2_FARROW_NATIVE;
00078 }
00079
00080 CU_SINLINE cu_fnptr_t
00081 cuex_to_fnptr(cuex_t e)
00082 {
00083 return *(cu_fnptr_t *)e;
00084 }
00085
00086
00087 CU_END_DECLARATIONS
00088
00089 #endif