• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/lib/ffi/uc_ctype.h

  1 /*
  2 ** C type management.
  3 ** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice below.
  4 **
  5 ** This header contains derived work from LuaJIT's FFI type system.
  6 **
  7 ** Modifications:
  8 ** - Adapted for ucode VM integration (uc_vm_t, uc_value_t, etc.)
  9 ** - Adapted type registry for ucode resource system
 10 ** - Removed JIT-specific dependencies
 11 **
 12 ** See NOTICE and ATTRIBUTION.md for complete attribution details.
 13 */
 14 
 15 #ifndef _UC_CTYPE_H
 16 #define _UC_CTYPE_H
 17 
 18 #include <ucode/types.h>
 19 #include <ucode/vm.h>
 20 
 21 #include "uc_def.h"
 22 
 23 /* C data object - FFI specific */
 24 typedef struct GCcdata {
 25   uint16_t ctypeid;
 26   uint8_t isvla;
 27   uc_value_t *refs;
 28 } GCcdata;
 29 
 30 typedef struct GCcdataVar {
 31   uint16_t offset;
 32   uint16_t extra;
 33         size_t len;
 34 } GCcdataVar;
 35 
 36 #define cdataptr(cd)    ((void *)((cd)+1))
 37 #define cdataisv(cd)    ((cd)->isvla)
 38 #define cdatav(cd)      ((GCcdataVar *)((char *)(cd) - sizeof(GCcdataVar)))
 39 #define cdatavlen(cd)   check_exp(cdataisv(cd), cdatav(cd)->len)
 40 #define sizecdatav(cd)  (cdatavlen(cd) + cdatav(cd)->extra)
 41 #define memcdatav(cd)   ((void *)((char *)(cd) - cdatav(cd)->offset))
 42 
 43 /* -- C type definitions -------------------------------------------------- */
 44 
 45 /* C type numbers. Highest 4 bits of C type info. ORDER CT. */
 46 enum {
 47         /* Externally visible types. */
 48         CT_NUM,         /* Integer or floating-point numbers. */
 49         CT_STRUCT,              /* Struct or union. */
 50         CT_PTR,         /* Pointer or reference. */
 51         CT_ARRAY,               /* Array or complex type. */
 52         CT_MAYCONVERT = CT_ARRAY,
 53         CT_VOID,                /* Void type. */
 54         CT_ENUM,                /* Enumeration. */
 55         CT_HASSIZE = CT_ENUM,  /* Last type where ct->size holds the actual size. */
 56         CT_FUNC,                /* Function. */
 57         CT_TYPEDEF,             /* Typedef. */
 58         CT_ATTRIB,              /* Miscellaneous attributes. */
 59         /* Internal element types. */
 60         CT_FIELD,               /* Struct/union field or function parameter. */
 61         CT_BITFIELD,            /* Struct/union bitfield. */
 62         CT_CONSTVAL,            /* Constant value. */
 63         CT_EXTERN,              /* External reference. */
 64         CT_KW                   /* Keyword. */
 65 };
 66 
 67 UC_STATIC_ASSERT(((int)CT_PTR & (int)CT_ARRAY) == CT_PTR);
 68 UC_STATIC_ASSERT(((int)CT_STRUCT & (int)CT_ARRAY) == CT_STRUCT);
 69 
 70 /*
 71 **  ---------- info ------------
 72 ** |type      flags...  A   cid | size   |  sib  | next  | name  |
 73 ** +----------------------------+--------+-------+-------+-------+--
 74 ** |NUM       BFcvUL..  A       | size   |       | type  |       |
 75 ** |STRUCT    ..cvU..V  A       | size   | field | name? | name? |
 76 ** |PTR       ..cvR...  A   cid | size   |       | type  |       |
 77 ** |ARRAY     VCcv...V  A   cid | size   |       | type  |       |
 78 ** |VOID      ..cv....  A       | size   |       | type  |       |
 79 ** |ENUM                A   cid | size   | const | name? | name? |
 80 ** |FUNC      ....VS.. cc   cid | nargs  | field | name? | name? |
 81 ** |TYPEDEF                 cid |        |       | name  | name  |
 82 ** |ATTRIB        attrnum   cid | attr   | sib?  | type? |       |
 83 ** |FIELD                   cid | offset | field |       | name? |
 84 ** |BITFIELD  B.cvU csz bsz pos | offset | field |       | name? |
 85 ** |CONSTVAL    c           cid | value  | const | name  | name  |
 86 ** |EXTERN                  cid |        | sib?  | name  | name  |
 87 ** |KW                      tok | size   |       | name  | name  |
 88 ** +----------------------------+--------+-------+-------+-------+--
 89 **        ^^  ^^--- bits used for C type conversion dispatch
 90 */
 91 
 92 /* C type info flags.     TFFArrrr  */
 93 #define CTF_BOOL        0x08000000u     /* Boolean: NUM, BITFIELD. */
 94 #define CTF_FP          0x04000000u     /* Floating-point: NUM. */
 95 #define CTF_CONST       0x02000000u     /* Const qualifier. */
 96 #define CTF_VOLATILE    0x01000000u     /* Volatile qualifier. */
 97 #define CTF_UNSIGNED    0x00800000u     /* Unsigned: NUM, BITFIELD. */
 98 #define CTF_LONG        0x00400000u     /* Long: NUM. */
 99 #define CTF_VLA         0x00100000u     /* Variable-length: ARRAY, STRUCT. */
100 #define CTF_REF         0x00800000u     /* Reference: PTR. */
101 #define CTF_VECTOR      0x08000000u     /* Vector: ARRAY. */
102 #define CTF_COMPLEX     0x04000000u     /* Complex: ARRAY. */
103 #define CTF_UNION       0x00800000u     /* Union: STRUCT. */
104 #define CTF_VARARG      0x00800000u     /* Vararg: FUNC. */
105 #define CTF_SSEREGPARM  0x00400000u     /* SSE register parameters: FUNC. */
106 
107 #define CTF_QUAL        (CTF_CONST|CTF_VOLATILE)
108 #define CTF_ALIGN       (CTMASK_ALIGN<<CTSHIFT_ALIGN)
109 #define CTF_UCHAR       ((char)-1 > 0 ? CTF_UNSIGNED : 0)
110 
111 /* Flags used in parser.  .F.Ammvf   cp->attr  */
112 #define CTFP_ALIGNED    0x00000001u     /* cp->attr + ALIGN */
113 #define CTFP_PACKED     0x00000002u     /* cp->attr */
114 /*                        ...C...f   cp->fattr */
115 #define CTFP_CCONV      0x00000001u     /* cp->fattr + CCONV/[SSE]REGPARM */
116 
117 /* C type info bitfields. */
118 #define CTMASK_CID      0x0000ffffu     /* Max. 65536 type IDs. */
119 #define CTMASK_NUM      0xf0000000u     /* Max. 16 type numbers. */
120 #define CTSHIFT_NUM     28
121 #define CTMASK_ALIGN    15              /* Max. alignment is 2^15. */
122 #define CTSHIFT_ALIGN   16
123 #define CTMASK_ATTRIB   255             /* Max. 256 attributes. */
124 #define CTSHIFT_ATTRIB  16
125 #define CTMASK_CCONV    3               /* Max. 4 calling conventions. */
126 #define CTSHIFT_CCONV   16
127 #define CTMASK_REGPARM  3               /* Max. 0-3 regparms. */
128 #define CTSHIFT_REGPARM 18
129 /* Bitfields only used in parser. */
130 #define CTMASK_VSIZEP   15              /* Max. vector size is 2^15. */
131 #define CTSHIFT_VSIZEP  4
132 #define CTMASK_MSIZEP   255             /* Max. type size (via mode) is 128. */
133 #define CTSHIFT_MSIZEP  8
134 
135 /* Info bits for BITFIELD. Max. size of bitfield is 64 bits. */
136 #define CTBSZ_MAX       32              /* Max. size of bitfield is 32 bit. */
137 #define CTBSZ_FIELD     127             /* Temp. marker for regular field. */
138 #define CTMASK_BITPOS   127
139 #define CTMASK_BITBSZ   127
140 #define CTMASK_BITCSZ   127
141 #define CTSHIFT_BITPOS  0
142 #define CTSHIFT_BITBSZ  8
143 #define CTSHIFT_BITCSZ  16
144 
145 #define CTF_INSERT(info, field, val) \
146         info = (info & ~(CTMASK_##field<<CTSHIFT_##field)) | \
147           (((CTSize)(val) & CTMASK_##field) << CTSHIFT_##field)
148 
149 /* Calling conventions. ORDER CC */
150 enum { CTCC_CDECL, CTCC_THISCALL, CTCC_FASTCALL, CTCC_STDCALL };
151 
152 /* Attribute numbers. */
153 enum {
154         CTA_NONE,               /* Ignored attribute. Must be zero. */
155         CTA_QUAL,               /* Unmerged qualifiers. */
156         CTA_ALIGN,              /* Alignment override. */
157         CTA_SUBTYPE,            /* Transparent sub-type. */
158         CTA_REDIR,              /* Redirected symbol name. */
159         CTA_BAD,                /* To catch bad IDs. */
160         CTA__MAX
161 };
162 
163 /* Special sizes. */
164 #define CTSIZE_INVALID  0xffffffffu
165 
166 typedef uint32_t CTInfo;        /* Type info. */
167 typedef uint32_t CTSize;        /* Type size. */
168 typedef uint32_t CTypeID;       /* Type ID. */
169 typedef uint16_t CTypeID1;      /* Minimum-sized type ID. */
170 
171 /* C type table element. */
172 typedef struct CType {
173         CTInfo info;            /* Type info. */
174         CTSize size;            /* Type size or other info. */
175         CTypeID1 sib;           /* Sibling element. */
176         CTypeID1 next;  /* Next element in hash chain. */
177         uc_value_t *uv_name;
178 } CType;
179 
180 #define CTHASH_SIZE     128     /* Number of hash anchors. */
181 #define CTHASH_MASK     (CTHASH_SIZE-1)
182 
183 /* C callback state - only vcbid is used for ffi.import() tracking */
184 typedef struct {
185   CTypeID1 *entries;
186   size_t count;
187 } vcbid_t;
188 
189 /* C type state. */
190 typedef struct CTState {
191         CTypeID1 hash[CTHASH_SIZE];  /* Hash anchors for C type table. */
192         struct {
193           size_t count;
194           CType *entries;
195         } vtab;
196         vcbid_t vcbid;          /* Callback type table (used by ffi.import) */
197         uc_vm_t *vm;
198 } CTState;
199 
200 #define CTINFO(ct, flags)       (((CTInfo)(ct) << CTSHIFT_NUM) + (flags))
201 #define CTALIGN(al)             ((CTSize)(al) << CTSHIFT_ALIGN)
202 #define CTATTRIB(at)            ((CTInfo)(at) << CTSHIFT_ATTRIB)
203 
204 #define ctype_type(info)        ((info) >> CTSHIFT_NUM)
205 #define ctype_cid(info)         ((CTypeID)((info) & CTMASK_CID))
206 #define ctype_align(info)       (((info) >> CTSHIFT_ALIGN) & CTMASK_ALIGN)
207 #define ctype_attrib(info)      (((info) >> CTSHIFT_ATTRIB) & CTMASK_ATTRIB)
208 #define ctype_bitpos(info)      (((info) >> CTSHIFT_BITPOS) & CTMASK_BITPOS)
209 #define ctype_bitbsz(info)      (((info) >> CTSHIFT_BITBSZ) & CTMASK_BITBSZ)
210 #define ctype_bitcsz(info)      (((info) >> CTSHIFT_BITCSZ) & CTMASK_BITCSZ)
211 #define ctype_vsizeP(info)      (((info) >> CTSHIFT_VSIZEP) & CTMASK_VSIZEP)
212 #define ctype_msizeP(info)      (((info) >> CTSHIFT_MSIZEP) & CTMASK_MSIZEP)
213 #define ctype_cconv(info)       (((info) >> CTSHIFT_CCONV) & CTMASK_CCONV)
214 
215 /* Simple type checks. */
216 #define ctype_isnum(info)       (ctype_type((info)) == CT_NUM)
217 #define ctype_isvoid(info)      (ctype_type((info)) == CT_VOID)
218 #define ctype_isptr(info)       (ctype_type((info)) == CT_PTR)
219 #define ctype_isarray(info)     (ctype_type((info)) == CT_ARRAY)
220 #define ctype_isstruct(info)    (ctype_type((info)) == CT_STRUCT)
221 #define ctype_isfunc(info)      (ctype_type((info)) == CT_FUNC)
222 #define ctype_isenum(info)      (ctype_type((info)) == CT_ENUM)
223 #define ctype_istypedef(info)   (ctype_type((info)) == CT_TYPEDEF)
224 #define ctype_isattrib(info)    (ctype_type((info)) == CT_ATTRIB)
225 #define ctype_isfield(info)     (ctype_type((info)) == CT_FIELD)
226 #define ctype_isbitfield(info)  (ctype_type((info)) == CT_BITFIELD)
227 #define ctype_isconstval(info)  (ctype_type((info)) == CT_CONSTVAL)
228 #define ctype_isextern(info)    (ctype_type((info)) == CT_EXTERN)
229 #define ctype_hassize(info)     (ctype_type((info)) <= CT_HASSIZE)
230 
231 /* Combined type and flag checks. */
232 #define ctype_isinteger(info) \
233         (((info) & (CTMASK_NUM|CTF_BOOL|CTF_FP)) == CTINFO(CT_NUM, 0))
234 #define ctype_isinteger_or_bool(info) \
235         (((info) & (CTMASK_NUM|CTF_FP)) == CTINFO(CT_NUM, 0))
236 #define ctype_isbool(info) \
237         (((info) & (CTMASK_NUM|CTF_BOOL)) == CTINFO(CT_NUM, CTF_BOOL))
238 #define ctype_isfp(info) \
239         (((info) & (CTMASK_NUM|CTF_FP)) == CTINFO(CT_NUM, CTF_FP))
240 
241 #define ctype_ispointer(info) \
242         ((ctype_type(info) >> 1) == (CT_PTR >> 1))  /* Pointer or array. */
243 #define ctype_isref(info) \
244         (((info) & (CTMASK_NUM|CTF_REF)) == CTINFO(CT_PTR, CTF_REF))
245 
246 #define ctype_isrefarray(info) \
247         (((info) & (CTMASK_NUM|CTF_VECTOR|CTF_COMPLEX)) == CTINFO(CT_ARRAY, 0))
248 #define ctype_isvector(info) \
249         (((info) & (CTMASK_NUM|CTF_VECTOR)) == CTINFO(CT_ARRAY, CTF_VECTOR))
250 #define ctype_iscomplex(info) \
251         (((info) & (CTMASK_NUM|CTF_COMPLEX)) == CTINFO(CT_ARRAY, CTF_COMPLEX))
252 
253 #define ctype_isvltype(info) \
254         (((info) & ((CTMASK_NUM|CTF_VLA) - (2u<<CTSHIFT_NUM))) == \
255          CTINFO(CT_STRUCT, CTF_VLA))  /* VL array or VL struct. */
256 #define ctype_isvlarray(info) \
257         (((info) & (CTMASK_NUM|CTF_VLA)) == CTINFO(CT_ARRAY, CTF_VLA))
258 
259 #define ctype_isxattrib(info, at) \
260         (((info) & (CTMASK_NUM|CTATTRIB(CTMASK_ATTRIB))) == \
261          CTINFO(CT_ATTRIB, CTATTRIB(at)))
262 
263 /* Target-dependent sizes and alignments. */
264 #if UC_64
265 #define CTSIZE_PTR      8
266 #define CTALIGN_PTR     CTALIGN(3)
267 #else
268 #define CTSIZE_PTR      4
269 #define CTALIGN_PTR     CTALIGN(2)
270 #endif
271 
272 #define CTINFO_REF(ref) \
273         CTINFO(CT_PTR, (CTF_CONST|CTF_REF|CTALIGN_PTR) + (ref))
274 
275 #define CT_MEMALIGN     3       /* Alignment guaranteed by memory allocator. */
276 
277 #ifdef LUA_USE_ASSERT
278 #define uc_assertCTS(c, ...)    (uc_assertG_(cts->g, (c), __VA_ARGS__))
279 #else
280 #define uc_assertCTS(c, ...)    ((void)cts)
281 #endif
282 
283 /* -- Predefined types ---------------------------------------------------- */
284 
285 /* Target-dependent types. */
286 #if UC_TARGET_PPC
287 #define CTTYDEFP(_) \
288         _(LINT32,               4,      CT_NUM, CTF_LONG|CTALIGN(2))
289 #else
290 #define CTTYDEFP(_)
291 #endif
292 
293 #define CTF_LONG_IF8            (CTF_LONG * (sizeof(long) == 8))
294 
295 /* Common types. */
296 #define CTTYDEF(_) \
297         _(NONE,         0,      CT_ATTRIB, CTATTRIB(CTA_BAD)) \
298         _(VOID,         -1,     CT_VOID, CTALIGN(0)) \
299         _(CVOID,                -1,     CT_VOID, CTF_CONST|CTALIGN(0)) \
300         _(BOOL,         1,      CT_NUM, CTF_BOOL|CTF_UNSIGNED|CTALIGN(0)) \
301         _(CCHAR,                1,      CT_NUM, CTF_CONST|CTF_UCHAR|CTALIGN(0)) \
302         _(INT8,         1,      CT_NUM, CTALIGN(0)) \
303         _(UINT8,                1,      CT_NUM, CTF_UNSIGNED|CTALIGN(0)) \
304         _(INT16,                2,      CT_NUM, CTALIGN(1)) \
305         _(UINT16,               2,      CT_NUM, CTF_UNSIGNED|CTALIGN(1)) \
306         _(INT32,                4,      CT_NUM, CTALIGN(2)) \
307         _(UINT32,               4,      CT_NUM, CTF_UNSIGNED|CTALIGN(2)) \
308         _(INT64,                8,      CT_NUM, CTF_LONG_IF8|CTALIGN(3)) \
309         _(UINT64,               8,      CT_NUM, CTF_UNSIGNED|CTF_LONG_IF8|CTALIGN(3)) \
310         _(FLOAT,                4,      CT_NUM, CTF_FP|CTALIGN(2)) \
311         _(DOUBLE,               8,      CT_NUM, CTF_FP|CTALIGN(3)) \
312         _(COMPLEX_FLOAT,        8,      CT_ARRAY, CTF_COMPLEX|CTALIGN(2)|CTID_FLOAT) \
313         _(COMPLEX_DOUBLE,       16,     CT_ARRAY, CTF_COMPLEX|CTALIGN(3)|CTID_DOUBLE) \
314         _(P_VOID,       CTSIZE_PTR,     CT_PTR, CTALIGN_PTR|CTID_VOID) \
315         _(P_CVOID,      CTSIZE_PTR,     CT_PTR, CTALIGN_PTR|CTID_CVOID) \
316         _(P_CCHAR,      CTSIZE_PTR,     CT_PTR, CTALIGN_PTR|CTID_CCHAR) \
317         _(P_UINT8,      CTSIZE_PTR,     CT_PTR, CTALIGN_PTR|CTID_UINT8) \
318         _(A_CCHAR,              -1,     CT_ARRAY, CTF_CONST|CTALIGN(0)|CTID_CCHAR) \
319         _(CTYPEID,              4,      CT_ENUM, CTALIGN(2)|CTID_INT32) \
320         CTTYDEFP(_) \
321         /* End of type list. */
322 
323 /* Public predefined type IDs. */
324 enum {
325 #define CTTYIDDEF(id, sz, ct, info)     CTID_##id,
326 CTTYDEF(CTTYIDDEF)
327 #undef CTTYIDDEF
328         /* Predefined typedefs and keywords follow. */
329         CTID_MAX = 65536
330 };
331 
332 /* Target-dependent type IDs. */
333 #if UC_64
334 #define CTID_INT_PSZ    CTID_INT64
335 #define CTID_UINT_PSZ   CTID_UINT64
336 #else
337 #define CTID_INT_PSZ    CTID_INT32
338 #define CTID_UINT_PSZ   CTID_UINT32
339 #endif
340 
341 #if UC_ABI_WIN
342 #define CTID_WCHAR      CTID_UINT16
343 #elif UC_TARGET_PPC
344 #define CTID_WCHAR      CTID_LINT32
345 #else
346 #define CTID_WCHAR      CTID_INT32
347 #endif
348 
349 /* -- C tokens and keywords ----------------------------------------------- */
350 
351 /* C lexer keywords. */
352 #define CTOKDEF(_) \
353         _(IDENT, "<identifier>") _(STRING, "<string>") \
354         _(INTEGER, "<integer>") _(EOF, "<eof>") \
355         _(OROR, "||") _(ANDAND, "&&") _(EQ, "==") _(NE, "!=") \
356         _(LE, "<=") _(GE, ">=") _(SHL, "<<") _(SHR, ">>") _(DEREF, "->")
357 
358 /* Simple declaration specifiers. */
359 #define CDSDEF(_) \
360         _(VOID) _(BOOL) _(CHAR) _(INT) _(FP) \
361         _(LONG) _(LONGLONG) _(SHORT) _(COMPLEX) _(SIGNED) _(UNSIGNED) \
362         _(CONST) _(VOLATILE) _(RESTRICT) _(INLINE) \
363         _(TYPEDEF) _(EXTERN) _(STATIC) _(AUTO) _(REGISTER)
364 
365 /* C keywords. */
366 #define CKWDEF(_) \
367         CDSDEF(_) _(EXTENSION) _(ASM) _(ATTRIBUTE) \
368         _(DECLSPEC) _(CCDECL) _(PTRSZ) \
369         _(STRUCT) _(UNION) _(ENUM) \
370         _(SIZEOF) _(ALIGNOF)
371 
372 /* C token numbers. */
373 enum {
374         CTOK_OFS = 255,
375 #define CTOKNUM(name, sym)      CTOK_##name,
376 #define CKWNUM(name)            CTOK_##name,
377 CTOKDEF(CTOKNUM)
378 CKWDEF(CKWNUM)
379 #undef CTOKNUM
380 #undef CKWNUM
381         CTOK_FIRSTDECL = CTOK_VOID,
382         CTOK_FIRSTSCL = CTOK_TYPEDEF,
383         CTOK_LASTDECLFLAG = CTOK_REGISTER,
384         CTOK_LASTDECL = CTOK_ENUM
385 };
386 
387 /* Declaration specifier flags. */
388 enum {
389 #define CDSFLAG(name)   CDF_##name = (1u << (CTOK_##name - CTOK_FIRSTDECL)),
390 CDSDEF(CDSFLAG)
391 #undef CDSFLAG
392         CDF__END
393 };
394 
395 #define CDF_SCL  (CDF_TYPEDEF|CDF_EXTERN|CDF_STATIC|CDF_AUTO|CDF_REGISTER)
396 
397 /* -- C type management --------------------------------------------------- */
398 
399 /* Get C type state. */
400 static UC_AINLINE CTState *ctype_cts(uc_vm_t *vm)
401 {
402         return ucv_resource_data(uc_vm_registry_get(vm, "ffi.types"), NULL);
403 }
404 
405 /* Save and restore state of C type table. */
406 #define UC_CTYPE_SAVE(cts)      CTState savects_ = *(cts)
407 #define UC_CTYPE_RESTORE(cts) \
408         ((cts)->top = savects_.top, \
409          memcpy((cts)->hash, savects_.hash, sizeof(savects_.hash)))
410 
411 /* Check C type ID for validity when assertions are enabled. */
412 static UC_AINLINE CTypeID ctype_check(unused CTState *cts, CTypeID id)
413 {
414         uc_assertCTS(id > 0 && id < cts->top, "bad CTID %d", id);
415         return id;
416 }
417 
418 /* Get C type for C type ID. */
419 static UC_AINLINE CType *ctype_get(CTState *cts, CTypeID id)
420 {
421         return &cts->vtab.entries[ctype_check(cts, id)];
422 }
423 
424 /* Get C type ID for a C type. */
425 #define ctype_typeid(cts, ct)   ((CTypeID)((ct) - (cts)->vtab.entries))
426 
427 /* Get child C type. */
428 static UC_AINLINE CType *ctype_child(CTState *cts, CType *ct)
429 {
430         uc_assertCTS(!(ctype_isvoid(ct->info) || ctype_isstruct(ct->info) ||
431                ctype_isbitfield(ct->info)),
432                "ctype %08x has no children", ct->info);
433         return ctype_get(cts, ctype_cid(ct->info));
434 }
435 
436 /* Get raw type for a C type ID. */
437 static UC_AINLINE CType *ctype_raw(CTState *cts, CTypeID id)
438 {
439         CType *ct = ctype_get(cts, id);
440         while (ctype_isattrib(ct->info)) ct = ctype_child(cts, ct);
441         return ct;
442 }
443 
444 /* Get raw type of the child of a C type. */
445 static UC_AINLINE CType *ctype_rawchild(CTState *cts, CType *ct)
446 {
447         do { ct = ctype_child(cts, ct); } while (ctype_isattrib(ct->info));
448         return ct;
449 }
450 
451 /* Set the name of a C type table element. */
452 static UC_AINLINE void ctype_setname(CType *ct, uc_value_t *s)
453 {
454         ucv_put(ct->uv_name);
455         ct->uv_name = ucv_get(s);
456 }
457 
458 UC_NOAPI CTypeID uc_ctype_new(CTState *cts, CType **ctp);
459 UC_NOAPI CTypeID uc_ctype_intern(CTState *cts, CTInfo info, CTSize size);
460 UC_NOAPI void uc_ctype_addname(CTState *cts, CType *ct, CTypeID id);
461 UC_NOAPI CTypeID uc_ctype_getname(CTState *cts, CType **ctp, uc_value_t *name,
462                                  uint32_t tmask);
463 UC_NOAPI CType *uc_ctype_getfieldq(CTState *cts, CType *ct, uc_value_t *name,
464                                   CTSize *ofs, CTInfo *qual);
465 #define uc_ctype_getfield(cts, ct, name, ofs) \
466         uc_ctype_getfieldq((cts), (ct), (name), (ofs), NULL)
467 UC_NOAPI CType *uc_ctype_rawref(CTState *cts, CTypeID id);
468 UC_NOAPI CTSize uc_ctype_size(CTState *cts, CTypeID id);
469 UC_NOAPI CTSize uc_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem);
470 UC_NOAPI CTInfo uc_ctype_info(CTState *cts, CTypeID id, CTSize *szp);
471 UC_NOAPI CTInfo uc_ctype_info_raw(CTState *cts, CTypeID id, CTSize *szp);
472 UC_NOAPI uc_value_t *uc_ctype_repr(uc_vm_t *vm, CTypeID id, uc_value_t *name);
473 UC_NOAPI uc_value_t *uc_ctype_repr_int64(uint64_t n, int isunsigned);
474 UC_NOAPI uc_value_t *uc_ctype_repr_complex(void *sp, CTSize size);
475 UC_NOAPI CTState *uc_ctype_init(uc_vm_t *vm);
476 
477 #endif
478 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt