First Import of XML reading procs --flo
[libfirm] / ir / external / read.h
1 /* -*- c -*- */
2
3 #ifndef _READ_H_
4 #define _READ_H_
5
6 #include <stdio.h>
7 #include <string.h>
8 #include <stdlib.h>
9 #include <assert.h>
10
11 #include <libxml/xmlmemory.h>
12 #include <libxml/parser.h>
13 #include <libxml/encoding.h>
14
15 # ifndef _BSD_SOURCE
16 #  define _BSD_SOURCE            /* need strdup */
17 # endif /* ! defined _BSD_SOURCE */
18
19 # define MY_ENCODING "ISO-8859-1"
20
21 # define CHECK(ptr,msg)     assert (ptr && msg)
22
23 # define NODE_NAME(n, m) (0 == xmlStrcmp (n->name, (const xmlChar*) #m))
24 # define CHECK_NAME(n, m) assert (0 == xmlStrcmp (n->name, (const xmlChar*) #m))
25
26 # define NEW(T)     (T*) malloc (sizeof (T))
27
28 /* first, the xml structures */
29
30 typedef struct type_str
31 {
32   const char *name;
33   int id;
34   void *f_tp;                   /* firm type */
35   struct type_str *prev;
36 } type_t;
37
38 typedef struct entity_str
39 {
40   const char *name;
41   const char *tp_name;
42   int id;
43   void *f_ent;                  /* firm entity */
44   struct entity_str *prev;
45 } entity_t;
46
47 /* now the xml nodes */
48 typedef enum eff_node_kind {
49   eff_arg,
50   eff_valref,
51   eff_select,
52   eff_load,
53   eff_store,
54   eff_alloc,
55   eff_call,
56   eff_unknown,
57   eff_join,
58   eff_raise,
59   eff_ret
60 } eff_node_kind_t;
61
62 /* dummy type for all other effects */
63 typedef struct eff_str
64 {
65   eff_node_kind_t kind;
66   /* struct eff_str *next; */
67 } eff_t;
68
69 typedef struct effs_str
70 {
71   char *procname;
72   int n_effs;
73   eff_t **effs;
74   struct effs_str *next;
75 } effs_t;
76
77 typedef struct arg_str
78 {
79   eff_node_kind_t kind;
80   /* struct eff_str *next; */
81   int id;
82   int num;
83 } arg_t;
84
85 typedef struct valref_str
86 {
87   eff_node_kind_t kind;
88   /* struct eff_str *next; */
89   int refid;
90 } valref_t;
91
92 typedef struct select_str
93 {
94   eff_node_kind_t kind;
95   /* struct eff_str *next; */
96   int valrefid;                 /* id of enclosed valref node, or -1 */
97   entity_t *ent;
98 } select_t;
99
100 typedef struct load_str
101 {
102   eff_node_kind_t kind;
103   /* struct eff_str *next; */
104   int id;
105   int ptrrefid;                 /* id of valref node enclosed in select, or -1 */
106   entity_t *ent;
107 } load_t;
108
109 typedef struct store_str
110 {
111   eff_node_kind_t kind;
112   /* struct eff_str *next; */
113   int ptrrefid;                 /* id of ptr valref node enclosed in select, or -1 */
114   int valrefid;                 /* id of val valref node enclosed in select, or -1 */
115   entity_t *ent;
116 } store_t;
117
118 typedef struct alloc_str
119 {
120   eff_node_kind_t kind;
121   int id;
122   int tp_id;
123 } alloc_t;
124
125 typedef struct call_str
126 {
127   eff_node_kind_t kind;
128   /* struct eff_str *next; */
129   int id;
130   int valrefid;                 /* id of enclosed valref node, or -1 */
131   entity_t *ent;                /* called entity */
132   int n_args;
133   int *args;
134 } call_t;
135
136 typedef struct unknown_str
137 {
138   eff_node_kind_t kind;
139   /* struct eff_str *next; */
140   int id;
141 } unknown_t;
142
143 typedef struct join_str
144 {
145   eff_node_kind_t kind;
146   /* struct eff_str *next; */
147   int id;
148   int n_ins;
149   int *ins;
150 } join_t;
151
152 typedef struct ret_str
153 {
154   eff_node_kind_t kind;
155   /* struct eff_str *next; */
156   int ret_id;
157 } ret_t;                     /* returned value, or -1 */
158
159 typedef struct raise_str
160 {
161   eff_node_kind_t kind;
162   /* struct eff_str *next; */
163   int valref;                   /* what was that one for? */
164   int tp_id;
165 } raise_t;
166
167 /*
168   The public interface
169 */
170
171 /** get the type entry with the given name */
172 type_t *getTypeByName (const char*);
173
174 /** get the type entry with the given Id */
175 type_t *getTypeById (const int);
176
177 /** get the entity entry that has the given names */
178 entity_t *getEntityByNames (const char*, const char*);
179
180 /** get the entity entry that has the given Id */
181 entity_t *getEntityById (const int);
182
183 /** get the effect entry for the given name */
184 effs_t *getEffectByName (const char*);
185
186 /** read in the file of the given name */
187 void read_extern (const char*);
188
189
190 #endif /* defined _READ_H_ */
191
192 /*
193   $Log$
194   Revision 1.1  2004/10/11 09:31:06  liekweg
195   First Import of XML reading procs --flo
196
197 */