6 static struct obstack _type_obst;
7 struct obstack *type_obst = &_type_obst;
9 void init_type_module()
11 obstack_init(type_obst);
14 void exit_type_module()
16 obstack_free(type_obst, NULL);
20 void print_atomic_type(FILE *out, const atomic_type_t *type)
23 case ATOMIC_TYPE_INVALID: fputs("INVALIDATOMIC", out); break;
24 case ATOMIC_TYPE_BOOL: fputs("bool", out); break;
25 case ATOMIC_TYPE_CHAR: fputs("char", out); break;
26 case ATOMIC_TYPE_SCHAR: fputs("signed char", out); break;
27 case ATOMIC_TYPE_UCHAR: fputs("unsigned char", out); break;
28 case ATOMIC_TYPE_INT: fputs("int", out); break;
29 case ATOMIC_TYPE_UINT: fputs("unsigned int", out); break;
30 case ATOMIC_TYPE_SHORT: fputs("short", out); break;
31 case ATOMIC_TYPE_USHORT: fputs("unsigned short", out); break;
32 case ATOMIC_TYPE_LONG: fputs("long", out); break;
33 case ATOMIC_TYPE_ULONG: fputs("unsigned long", out); break;
34 case ATOMIC_TYPE_LONGLONG: fputs("long long", out); break;
35 case ATOMIC_TYPE_ULONGLONG: fputs("unsigned long long", out); break;
36 case ATOMIC_TYPE_FLOAT: fputs("float", out); break;
37 case ATOMIC_TYPE_DOUBLE: fputs("double", out); break;
38 default: fputs("UNKNOWNATOMIC", out); break;
43 void print_method_type(FILE *out, const method_type_t *type)
46 print_type(out, type->result_type);
49 if(type->abi_style != NULL) {
50 fprintf(out, "\"%s\" ", type->abi_style);
52 fputs("method(", out);
53 method_parameter_type_t *param_type = type->parameter_types;
55 while(param_type != NULL) {
61 print_type(out, param_type->type);
62 param_type = param_type->next;
68 void print_pointer_type(FILE *out, const pointer_type_t *type)
70 print_type(out, type->points_to);
74 void print_type(FILE *out, const type_t *type)
77 fputs("nil type", out);
83 fputs("invalid", out);
90 print_atomic_type(out, (const atomic_type_t*) type);
92 case TYPE_COMPOUND_STRUCT:
93 case TYPE_COMPOUND_UNION:
94 fprintf(out, "%s", ((const compound_type_t*) type)->symbol->string);
97 print_method_type(out, (const method_type_t*) type);
100 print_pointer_type(out, (const pointer_type_t*) type);
103 fputs("unknown", out);
106 int type_valid(const type_t *type)
108 return type->type != TYPE_INVALID;
111 int is_type_int(const type_t *type)
113 if(type->type != TYPE_ATOMIC)
116 atomic_type_t *atomic_type = (atomic_type_t*) type;
117 switch(atomic_type->atype) {
118 case ATOMIC_TYPE_CHAR:
119 case ATOMIC_TYPE_SCHAR:
120 case ATOMIC_TYPE_UCHAR:
121 case ATOMIC_TYPE_SHORT:
122 case ATOMIC_TYPE_USHORT:
123 case ATOMIC_TYPE_INT:
124 case ATOMIC_TYPE_UINT:
125 case ATOMIC_TYPE_LONG:
126 case ATOMIC_TYPE_ULONG:
127 case ATOMIC_TYPE_LONGLONG:
128 case ATOMIC_TYPE_ULONGLONG:
135 static __attribute__((unused))
136 void dbg_type(const type_t *type)
138 print_type(stdout,type);