| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- #ifndef _PLY_TYPE_H
- #define _PLY_TYPE_H
- #include <stddef.h>
- #include <stdio.h>
- typedef struct type type_t;
- struct t_tdef {
- char *name;
- type_t *type;
- };
- struct t_scalar {
- char *name;
- };
- struct t_pointer {
- type_t *type;
- };
- struct t_array {
- type_t *type;
- size_t len;
- };
- struct t_map {
- type_t *vtype;
- type_t *ktype;
- size_t len;
- };
- typedef struct field {
- char *name;
- type_t *type;
- size_t offset;
- } field_t;
- struct t_sou {
- char *name;
- int packed:1;
- field_t *fields;
- };
- struct t_func {
- char *name;
- type_t *type;
- field_t *args;
- };
- typedef enum ttype {
- T_TYPEDEF,
- T_SCALAR,
- T_POINTER,
- T_ARRAY,
- T_MAP,
- T_STRUCT,
- T_UNION,
- T_FUNC,
- } ttype_t;
- struct type {
- size_t size;
- ttype_t ttype;
- union {
- struct t_tdef tdef;
- struct t_scalar scalar;
- struct t_pointer pointer;
- struct t_array array;
- struct t_map map;
- struct t_sou sou;
- struct t_func func;
- } t;
- };
- extern type_t t_void;
- extern type_t t_char;
- extern type_t t_uchar;
- extern type_t t_short;
- extern type_t t_ushort;
- extern type_t t_int;
- extern type_t t_uint;
- extern type_t t_long;
- extern type_t t_ulong;
- extern type_t t_llong;
- extern type_t t_ullong;
- type_t *type_map_of(type_t *ktype, type_t *vtype);
- type_t *type_ptr_of(type_t *type);
- int type_equal(type_t *a, type_t *b);
- int type_add(type_t *t);
- int type_add_list(type_t **ts);
- void type_dump (type_t *t, FILE *fp);
- void type_dump_cdecl(type_t *t, FILE *fp);
- void types_dump_cdecl(FILE *fp);
- #endif /* _PLY_TYPE_H */
|