| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- #ifndef _PLY_TYPE_H
- #define _PLY_TYPE_H
- #include <stddef.h>
- #include <stdio.h>
- struct ttdef {
- char *name;
- struct type *type;
- };
- struct tscalar {
- size_t size;
- int is_signed:1;
- char *name;
- };
- struct tptr {
- struct type *type;
- };
- struct tarray {
- struct type *type;
- size_t len;
- };
- struct tmap {
- struct type *vtype;
- struct type *ktype;
- size_t len;
- };
- struct tfield {
- char *name;
- struct type *type;
- /* function arguments */
- int optional:1;
- };
- struct tstruct {
- char *name;
- int packed:1;
- struct tfield *fields;
- };
- struct tfunc {
- struct type *type;
- struct tfield *args;
- };
- enum ttype {
- T_VOID,
- T_TYPEDEF,
- T_SCALAR,
- T_POINTER,
- T_ARRAY,
- T_MAP,
- T_STRUCT,
- T_UNION,
- T_FUNC,
- };
- struct type {
- enum ttype ttype;
- union {
- struct ttdef tdef;
- struct tscalar scalar;
- struct tptr ptr;
- struct tarray array;
- struct tmap map;
- struct tstruct sou;
- struct tfunc func;
- };
- };
- /* struct type *type_map_of(struct type *ktype, struct type *vtype); */
- /* struct type *type_ptr_of(struct type *type); */
- int type_equal (struct type *a, struct type *b);
- int type_compatible(struct type *a, struct type *b);
- void type_dump (struct type *t, FILE *fp);
- void type_dump_cdecl(struct type *t, FILE *fp);
- ssize_t type_alignof(struct type *t);
- ssize_t type_sizeof(struct type *t);
- /* typedef int (*twalk_fn)(struct type *, void *); */
- /* int type_walk(struct type *t, twalk_fn pre, twalk_fn post, void *ctx); */
- int type_add(struct type *t);
- int type_add_list(struct type **ts);
- /* built-in types */
- extern struct type t_void;
- extern struct type t_char;
- extern struct type t_schar;
- extern struct type t_uchar;
- extern struct type t_short;
- extern struct type t_sshort;
- extern struct type t_ushort;
- extern struct type t_int;
- extern struct type t_sint;
- extern struct type t_uint;
- extern struct type t_long;
- extern struct type t_slong;
- extern struct type t_ulong;
- extern struct type t_llong;
- extern struct type t_sllong;
- extern struct type t_ullong;
- #endif /* _PLY_TYPE_H */
|