typedef struct
{
- alignas (8) uint32_t _pad;
+ alignas (8)
+ // layout so that value can be upcast by reinterpreting as a fix64
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ int32_t n;
+ uint32_t _pad;
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ uint32_t _pad;
int32_t n;
+#else
+#error Unusual endianness?
+#endif
} fix32_val;
typedef struct
{
// NB. never take the address of these type-punned fields!
alignas (16) evaltype type;
opaque32 _unknown0;
- opaque64 _unknown1;
+ union
+ {
+ opaque64 _unknown1;
+ uv_val uv_val;
+ };
};
/// objects of statically known type
/// use as_X() for checked downcast
,};
}
-// TODO: take a dope_object like uvector
static inline vector_object
new_vector (heap_ptr body, uint32_t length)
{
return uv_dope (o)->type;
}
+object
+uv_get (const uvector_object * o, uint32_t i);
+
+
// Change the EVALTYPE of an object. New type must have same PRIMTYPE.
static inline void
chtype (object * o, evaltype type)
Checked downcasts.
*/
+static inline fix32_object *
+as_fix32 (object * o)
+{
+ assert (TYPEPRIM_EQ (o->type, TYPEPRIM_FIX32));
+ return &o->fix32;
+}
+
static inline list_object *
as_list (object * o)
{