DEADSOFTWARE

Изменение структуры проекта
[dsw-obn.git] / src / oberon-internals.h
1 #ifndef OBERON_INTERNALS_H
2 #define OBERON_INTERNALS_H
4 typedef struct gen_proc_t gen_proc_t;
5 typedef struct gen_type_t gen_type_t;
6 typedef struct gen_var_t gen_var_t;
7 typedef struct gen_block_t gen_block_t;
8 typedef struct gen_context_t gen_context_t;
10 typedef struct oberon_type_t oberon_type_t;
11 typedef struct oberon_object_t oberon_object_t;
12 typedef struct oberon_module_t oberon_module_t;
13 typedef struct oberon_context_t oberon_context_t;
14 typedef struct oberon_scope_t oberon_scope_t;
16 typedef struct oberon_item_t oberon_item_t;
17 typedef struct oberon_oper_t oberon_oper_t;
18 typedef union oberon_expr_t oberon_expr_t;
20 struct oberon_scope_t
21 {
22 oberon_context_t * ctx;
23 oberon_object_t * list;
24 oberon_scope_t * up;
26 oberon_object_t * parent;
27 int local;
28 };
30 enum
31 {
32 OBERON_TYPE_VOID,
33 OBERON_TYPE_INTEGER,
34 OBERON_TYPE_BOOLEAN,
35 OBERON_TYPE_PROCEDURE,
36 OBERON_TYPE_ARRAY,
37 OBERON_TYPE_RECORD,
38 OBERON_TYPE_POINTER,
39 OBERON_TYPE_REAL
40 };
42 struct oberon_type_t
43 {
44 int class;
45 int size;
47 int num_decl;
48 oberon_type_t * base;
49 oberon_object_t * decl;
51 oberon_module_t * module;
53 int recursive;
54 int initialized;
55 gen_type_t * gen_type;
56 };
58 enum
59 {
60 OBERON_CLASS_VAR,
61 OBERON_CLASS_TYPE,
62 OBERON_CLASS_PROC,
63 OBERON_CLASS_PARAM,
64 OBERON_CLASS_VAR_PARAM,
65 OBERON_CLASS_CONST,
66 OBERON_CLASS_FIELD,
67 OBERON_CLASS_MODULE
68 };
70 typedef oberon_expr_t * (*GenerateFuncCallback)(oberon_context_t *, int, oberon_expr_t *);
71 typedef void (*GenerateProcCallback)(oberon_context_t *, int, oberon_expr_t *);
73 struct oberon_object_t
74 {
75 char * name;
76 int class;
77 int export;
78 int read_only;
80 int local;
81 int linked;
82 int initialized;
84 oberon_object_t * parent;
86 oberon_scope_t * scope; // for proc
87 int has_return; // for proc
88 int sysproc;
89 GenerateFuncCallback genfunc;
90 GenerateProcCallback genproc;
92 oberon_type_t * type;
93 oberon_item_t * value;
94 oberon_object_t * next;
96 oberon_module_t * module;
98 gen_var_t * gen_var;
99 gen_proc_t * gen_proc;
100 };
102 struct oberon_module_t
104 char * name;
105 int ready;
107 oberon_scope_t * decl;
109 oberon_module_t * next;
110 };
112 typedef const char * (*ModuleImportCallback)(const char * name);
114 struct oberon_context_t
116 /*** SCANER DATA ***/
117 const char * code;
118 int code_index;
120 char c;
121 int token;
122 char * string;
123 long integer;
124 double real;
125 /*** END SCANER DATA ***/
127 /*** PARSER DATA ***/
128 oberon_scope_t * decl;
129 oberon_module_t * mod;
130 /*** END PARSER DATA ***/
132 oberon_type_t * int_type;
133 oberon_type_t * bool_type;
134 oberon_type_t * real_type;
135 oberon_type_t * void_type;
136 oberon_type_t * void_ptr_type;
137 oberon_scope_t * world_scope;
138 oberon_module_t * module_list;
139 ModuleImportCallback import_module;
140 gen_context_t * gen_context;
141 };
143 enum
145 MODE_VAR,
146 MODE_INTEGER,
147 MODE_BOOLEAN,
148 MODE_CALL,
149 MODE_INDEX,
150 MODE_FIELD,
151 MODE_DEREF,
152 MODE_NIL,
153 MODE_NEW,
154 MODE_REAL
155 };
157 enum
159 OP_UNARY_MINUS,
160 OP_BITWISE_NOT,
161 OP_LOGIC_NOT,
162 OP_ABS,
164 OP_ADD,
165 OP_SUB,
166 OP_MUL,
167 OP_DIV,
168 OP_MOD,
169 OP_BITWISE_AND,
170 OP_BITWISE_XOR,
171 OP_BITWISE_OP,
172 OP_LOGIC_AND,
173 OP_LOGIC_OR,
175 OP_EQ,
176 OP_NEQ,
177 OP_LSS,
178 OP_LEQ,
179 OP_GRT,
180 OP_GEQ
181 };
183 struct oberon_item_t
185 int is_item; // == 1
186 oberon_type_t * result;
187 oberon_expr_t * next;
188 int read_only;
190 int mode;
191 long integer;
192 double real;
193 int boolean;
194 oberon_object_t * var;
196 oberon_item_t * parent;
198 int num_args;
199 oberon_expr_t * args;
200 };
202 struct oberon_oper_t
204 int is_item; // == 0
205 oberon_type_t * result;
206 oberon_expr_t * next;
207 int read_only;
209 int op;
210 oberon_expr_t * left;
211 oberon_expr_t * right;
212 };
214 union oberon_expr_t
216 struct {
217 int is_item;
218 oberon_type_t * result;
219 oberon_expr_t * next;
220 int read_only;
221 };
223 oberon_item_t item;
224 oberon_oper_t oper;
225 };
227 extern void
228 oberon_error(oberon_context_t * ctx, const char * fmt, ...);
230 #endif // OBERON_INTERNALS_H