DEADSOFTWARE

JVM: Реализован доступ к полям записей и NEW для записей(без инициализации полей)
[dsw-obn.git] / src / oberon-internals.h
1 #ifndef OBERON_INTERNALS_H
2 #define OBERON_INTERNALS_H
4 typedef struct gen_module_t gen_module_t;
5 typedef struct gen_proc_t gen_proc_t;
6 typedef struct gen_type_t gen_type_t;
7 typedef struct gen_var_t gen_var_t;
8 typedef struct gen_block_t gen_block_t;
9 typedef struct gen_context_t gen_context_t;
11 typedef struct oberon_type_t oberon_type_t;
12 typedef struct oberon_object_t oberon_object_t;
13 typedef struct oberon_module_t oberon_module_t;
14 typedef struct oberon_context_t oberon_context_t;
15 typedef struct oberon_scope_t oberon_scope_t;
17 typedef struct oberon_item_t oberon_item_t;
18 typedef struct oberon_oper_t oberon_oper_t;
19 typedef union oberon_expr_t oberon_expr_t;
21 struct oberon_scope_t
22 {
23 oberon_context_t * ctx;
24 oberon_object_t * list;
25 oberon_scope_t * up;
27 int local;
28 oberon_object_t * parent;
29 oberon_type_t * parent_type;
30 };
32 enum
33 {
34 OBERON_TYPE_VOID,
35 OBERON_TYPE_INTEGER,
36 OBERON_TYPE_BOOLEAN,
37 OBERON_TYPE_PROCEDURE,
38 OBERON_TYPE_ARRAY,
39 OBERON_TYPE_RECORD,
40 OBERON_TYPE_POINTER,
41 OBERON_TYPE_REAL
42 };
44 struct oberon_type_t
45 {
46 int class;
47 int size;
49 int num_decl;
50 oberon_type_t * base;
51 oberon_object_t * decl;
53 oberon_module_t * module;
55 int recursive;
56 int initialized;
57 gen_type_t * gen_type;
58 };
60 enum
61 {
62 OBERON_CLASS_VAR,
63 OBERON_CLASS_TYPE,
64 OBERON_CLASS_PROC,
65 OBERON_CLASS_PARAM,
66 OBERON_CLASS_VAR_PARAM,
67 OBERON_CLASS_CONST,
68 OBERON_CLASS_FIELD,
69 OBERON_CLASS_MODULE
70 };
72 typedef oberon_expr_t * (*GenerateFuncCallback)(oberon_context_t *, int, oberon_expr_t *);
73 typedef void (*GenerateProcCallback)(oberon_context_t *, int, oberon_expr_t *);
75 struct oberon_object_t
76 {
77 char * name;
78 int class;
79 int export;
80 int read_only;
82 int local;
83 int linked;
84 int initialized;
86 oberon_object_t * parent;
87 oberon_type_t * parent_type;
89 oberon_scope_t * scope; // for proc
90 int has_return; // for proc
91 int sysproc;
92 GenerateFuncCallback genfunc;
93 GenerateProcCallback genproc;
95 oberon_type_t * type;
96 oberon_item_t * value;
97 oberon_object_t * next;
99 oberon_module_t * module;
101 gen_var_t * gen_var;
102 gen_proc_t * gen_proc;
103 };
105 struct oberon_module_t
107 char * name;
108 int ready;
110 oberon_scope_t * decl;
112 oberon_module_t * next;
114 gen_module_t * gen_mod;
115 };
117 typedef const char * (*ModuleImportCallback)(const char * name);
119 struct oberon_context_t
121 /*** SCANER DATA ***/
122 const char * code;
123 int code_index;
125 char c;
126 int token;
127 char * string;
128 long integer;
129 double real;
130 /*** END SCANER DATA ***/
132 /*** PARSER DATA ***/
133 oberon_scope_t * decl;
134 oberon_module_t * mod;
135 /*** END PARSER DATA ***/
137 oberon_type_t * int_type;
138 oberon_type_t * bool_type;
139 oberon_type_t * real_type;
140 oberon_type_t * void_type;
141 oberon_type_t * void_ptr_type;
142 oberon_scope_t * world_scope;
143 oberon_module_t * module_list;
144 ModuleImportCallback import_module;
145 gen_context_t * gen_context;
146 };
148 enum
150 MODE_VAR,
151 MODE_INTEGER,
152 MODE_BOOLEAN,
153 MODE_CALL,
154 MODE_INDEX,
155 MODE_FIELD,
156 MODE_DEREF,
157 MODE_NIL,
158 MODE_NEW,
159 MODE_REAL
160 };
162 enum
164 OP_UNARY_MINUS,
165 OP_BITWISE_NOT,
166 OP_LOGIC_NOT,
167 OP_ABS,
169 OP_ADD,
170 OP_SUB,
171 OP_MUL,
172 OP_DIV,
173 OP_MOD,
174 OP_BITWISE_AND,
175 OP_BITWISE_XOR,
176 OP_BITWISE_OR,
177 OP_LOGIC_AND,
178 OP_LOGIC_OR,
180 OP_EQ,
181 OP_NEQ,
182 OP_LSS,
183 OP_LEQ,
184 OP_GRT,
185 OP_GEQ
186 };
188 struct oberon_item_t
190 int is_item; // == 1
191 oberon_type_t * result;
192 oberon_expr_t * next;
193 int read_only;
195 int mode;
196 long integer;
197 double real;
198 int boolean;
199 oberon_object_t * var;
201 oberon_item_t * parent;
203 int num_args;
204 oberon_expr_t * args;
205 };
207 struct oberon_oper_t
209 int is_item; // == 0
210 oberon_type_t * result;
211 oberon_expr_t * next;
212 int read_only;
214 int op;
215 oberon_expr_t * left;
216 oberon_expr_t * right;
217 };
219 union oberon_expr_t
221 struct {
222 int is_item;
223 oberon_type_t * result;
224 oberon_expr_t * next;
225 int read_only;
226 };
228 oberon_item_t item;
229 oberon_oper_t oper;
230 };
232 extern void
233 oberon_error(oberon_context_t * ctx, const char * fmt, ...);
235 #endif // OBERON_INTERNALS_H