DEADSOFTWARE

Исправлен экспорт полей и экспорт для "только чтения"
[dsw-obn.git] / generator.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdarg.h>
4 #include <ctype.h>
5 #include <string.h>
6 #include <assert.h>
8 #include "oberon.h"
9 #include "generator.h"
11 // =======================================================================
12 // ALLOC
13 // =======================================================================
15 static void
16 oberon_generator_open_block(gen_context_t * gen_context, gcc_jit_block * gcc_block)
17 {
18 gen_block_t * block = malloc(sizeof *block);
19 memset(block, 0, sizeof *block);
21 block -> gcc_block = gcc_block;
22 block -> up = gen_context -> block;
24 gen_context -> block = block;
25 }
27 static void
28 oberon_generator_close_block(gen_context_t * gen_context)
29 {
30 gen_context -> block = gen_context -> block -> up;
31 }
33 void
34 oberon_generator_init_context(oberon_context_t * ctx)
35 {
36 gen_context_t * gen_context = malloc(sizeof *gen_context);
37 memset(gen_context, 0, sizeof *gen_context);
39 gcc_jit_context * gcc_context;
40 gcc_context = gcc_jit_context_acquire();
42 ctx -> gen_context = gen_context;
43 gen_context -> gcc_context = gcc_context;
44 }
46 void
47 oberon_generator_destroy_context(oberon_context_t * ctx)
48 {
49 gen_context_t * gen_context = ctx -> gen_context;
50 gcc_jit_context * gcc_context = gen_context -> gcc_context;
52 gcc_jit_context_release(gcc_context);
53 }
55 void
56 oberon_generator_init_type(oberon_context_t * ctx, oberon_type_t * type)
57 {
58 gen_type_t * gen_type = malloc(sizeof *gen_type);
59 memset(gen_type, 0, sizeof *gen_type);
60 type -> gen_type = gen_type;
62 gen_context_t * gen_context = ctx -> gen_context;
63 gcc_jit_context * gcc_context = gen_context -> gcc_context;
65 gcc_jit_type * gcc_type = NULL;
66 gcc_jit_struct * gcc_struct = NULL;
67 if(type -> class == OBERON_TYPE_VOID)
68 {
69 gcc_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_VOID);
70 }
71 else if(type -> class == OBERON_TYPE_INTEGER)
72 {
73 gcc_type = gcc_jit_context_get_int_type(gcc_context, type -> size, 1);
74 }
75 else if(type -> class == OBERON_TYPE_BOOLEAN)
76 {
77 gcc_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_BOOL);
78 }
79 else if(type -> class == OBERON_TYPE_ARRAY)
80 {
81 gen_type_t * gen_base = type -> base -> gen_type;
82 gcc_jit_type * gcc_base = gen_base -> gcc_type;
83 gcc_type = gcc_jit_context_new_array_type(gcc_context, NULL, gcc_base, type -> size);
84 }
85 else if(type -> class == OBERON_TYPE_RECORD)
86 {
87 char name[32];
88 snprintf(name, 32, "RECORD%u", gen_context -> record_count);
89 gen_context -> record_count += 1;
91 gcc_struct = gcc_jit_context_new_opaque_struct(gcc_context, NULL, name);
92 gcc_type = gcc_jit_struct_as_type(gcc_struct);
93 }
94 else if(type -> class == OBERON_TYPE_POINTER)
95 {
96 gen_type_t * gen_base = type -> base -> gen_type;
97 gcc_jit_type * gcc_base = gen_base -> gcc_type;
98 gcc_type = gcc_jit_type_get_pointer(gcc_base);
99 }
100 else if(type -> class == OBERON_TYPE_PROCEDURE)
102 int num_params = type -> num_decl;
103 gcc_jit_type * params[num_params];
104 oberon_object_t * o = type -> decl;
105 for(int i = 0; i < num_params; i++)
107 gen_type_t * gen_type = o -> type -> gen_type;
108 params[i] = gen_type -> gcc_type;
109 o = o -> next;
112 gen_type_t * base = type -> base -> gen_type;
113 gcc_jit_type * result_type = base -> gcc_type;
115 gcc_type = gcc_jit_context_new_function_ptr_type(
116 gcc_context, NULL, result_type, num_params, params, 0
117 );
119 else
121 oberon_error(ctx, "oberon_generator_init_type: invalid type class %i", type -> class);
124 assert(gcc_type);
125 gen_type -> gcc_type = gcc_type;
126 gen_type -> gcc_struct = gcc_struct;
129 void
130 oberon_generator_init_record(oberon_context_t * ctx, oberon_type_t * type)
132 assert(type -> class == OBERON_TYPE_RECORD);
134 gen_type_t * gen_type = type -> gen_type;
135 gcc_jit_struct * gcc_struct = gen_type -> gcc_struct;
137 // TODO type exstension
139 int num_fields = type -> num_decl;
140 gcc_jit_field * fields[num_fields];
141 oberon_object_t * o = type -> decl;
142 for(int i = 0; i < num_fields; i++)
144 assert(o -> class == OBERON_CLASS_FIELD);
145 gen_var_t * var = o -> gen_var;
146 fields[i] = var -> gcc_field;
147 o = o -> next;
150 gcc_jit_struct_set_fields (gcc_struct, NULL, num_fields, fields);
152 //gcc_struct = gcc_jit_context_new_struct_type(gcc_context, NULL, "", num_fields, fields);
155 static void
156 oberon_generator_get_full_name(char * name, int max_len, oberon_object_t * x)
158 if(!x)
160 name[0] = 0;
161 return;
164 int add_module_prefix;
165 switch(x -> class)
167 case OBERON_CLASS_FIELD:
168 case OBERON_CLASS_PARAM:
169 case OBERON_CLASS_VAR_PARAM:
170 /* В локальных областях префиксы излишни */
171 add_module_prefix = 0;
172 break;
173 default:
174 add_module_prefix = 1;
175 break;
178 char parent[256];
179 oberon_generator_get_full_name(parent, 256, x -> parent);
181 if(strlen(parent) > 0)
183 snprintf(name, max_len, "%s_%s", parent, x -> name);
185 else if(add_module_prefix)
187 snprintf(name, max_len, "%s_%s", x -> module -> name, x -> name);
189 else
191 snprintf(name, max_len, "%s", x -> name);
195 void
196 oberon_generator_init_var(oberon_context_t * ctx, oberon_object_t * var)
198 gen_context_t * gen_context = ctx -> gen_context;
199 gen_type_t * gen_type = var -> type -> gen_type;
201 gen_var_t * gen_var = malloc(sizeof *gen_var);
202 memset(gen_var, 0, sizeof *gen_var);
203 var -> gen_var = gen_var;
205 gcc_jit_context * gcc_context = gen_context -> gcc_context;
206 gcc_jit_type * gcc_type = gen_type -> gcc_type;
208 char name[256];
209 oberon_generator_get_full_name(name, 256, var);
211 gcc_jit_lvalue * gcc_lvalue = NULL;
212 gcc_jit_param * gcc_param = NULL;
213 gcc_jit_field * gcc_field = NULL;
214 if(var -> class == OBERON_CLASS_VAR)
216 if(var -> local)
218 gen_proc_t * gen_func = var -> parent -> gen_proc;
219 gcc_jit_function * func = gen_func -> gcc_func;
221 gcc_lvalue = gcc_jit_function_new_local(func, NULL, gcc_type, name);
223 else
225 gcc_lvalue = gcc_jit_context_new_global(
226 gcc_context, NULL, GCC_JIT_GLOBAL_INTERNAL, gcc_type, name
227 );
230 else if(var -> class == OBERON_CLASS_PARAM)
232 gcc_param = gcc_jit_context_new_param(gcc_context, NULL, gcc_type, name);
233 gcc_lvalue = gcc_jit_param_as_lvalue(gcc_param);
235 else if(var -> class == OBERON_CLASS_VAR_PARAM)
237 gcc_type = gcc_jit_type_get_pointer(gcc_type);
238 gcc_param = gcc_jit_context_new_param(gcc_context, NULL, gcc_type, name);
239 gcc_lvalue = gcc_jit_param_as_lvalue(gcc_param);
241 else if(var -> class == OBERON_CLASS_FIELD)
243 gcc_field = gcc_jit_context_new_field(gcc_context, NULL, gcc_type, name);
245 else
247 oberon_error(ctx, "oberon_generator_init_var: invalid class %i", var -> class);
250 gen_var -> gcc_lvalue = gcc_lvalue;
251 gen_var -> gcc_param = gcc_param;
252 gen_var -> gcc_field = gcc_field;
255 void
256 oberon_generator_init_proc(oberon_context_t * ctx, oberon_object_t * proc)
258 if(proc -> local)
260 oberon_error(ctx, "generator: local procedures not supported");
263 gen_context_t * gen_context = ctx -> gen_context;
264 gcc_jit_context * gcc_context = gen_context -> gcc_context;
266 gen_proc_t * gen_proc = malloc(sizeof *gen_proc);
267 memset(gen_proc, 0, sizeof *gen_proc);
268 proc -> gen_proc = gen_proc;
270 char name[256];
271 oberon_generator_get_full_name(name, 256, proc);
273 gen_type_t * gen_result_type = proc -> type -> base -> gen_type;
274 gcc_jit_type * result_type = gen_result_type -> gcc_type;
276 /* Строим список параметров */
277 int num_param = proc -> type -> num_decl;
278 oberon_object_t * o = proc -> type -> decl;
279 gcc_jit_param * params[num_param];
280 for(int i = 0; i < num_param; i++)
282 gen_var_t * param_var = o -> gen_var;
283 params[i] = param_var -> gcc_param;
284 o = o -> next;
287 gcc_jit_function * gcc_func;
288 gcc_func = gcc_jit_context_new_function(
289 gcc_context, NULL, GCC_JIT_FUNCTION_EXPORTED, result_type, name, num_param, params, 0
290 );
292 gen_proc -> gcc_func = gcc_func;
295 // =======================================================================
296 // GENERATOR
297 // =======================================================================
299 static gcc_jit_rvalue * rvalue_from_item(oberon_context_t * ctx, oberon_item_t * item);
300 static gcc_jit_rvalue * rvalue_from_expr(oberon_context_t * ctx, oberon_expr_t * expr);
302 void
303 oberon_generate_begin_module(oberon_context_t * ctx)
305 gen_context_t * gen_context = ctx -> gen_context;
306 gcc_jit_context * gcc_context = gen_context -> gcc_context;
308 char name[256];
309 snprintf(name, 256, "%s_BEGIN", ctx -> mod -> name);
311 gcc_jit_type * void_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_VOID);
312 gcc_jit_function * func = gcc_jit_context_new_function(
313 gcc_context, NULL, GCC_JIT_FUNCTION_EXPORTED, void_type, name, 0, NULL, 0
314 );
315 gcc_jit_block * gcc_block = gcc_jit_function_new_block(func, NULL);
317 oberon_generator_open_block(gen_context, gcc_block);
320 void
321 oberon_generate_end_module(oberon_context_t * ctx)
323 gen_context_t * gen_context = ctx -> gen_context;
324 gcc_jit_block * gcc_block = gen_context -> block -> gcc_block;
326 gcc_jit_block_end_with_void_return(gcc_block, NULL);
328 oberon_generator_close_block(gen_context);
331 void
332 oberon_generate_begin_proc(oberon_context_t * ctx, oberon_object_t * proc)
334 gen_context_t * gen_context = ctx -> gen_context;
335 gen_proc_t * gen_proc = proc -> gen_proc;
337 gcc_jit_function * func = gen_proc -> gcc_func;
338 gcc_jit_block * gcc_block = gcc_jit_function_new_block(func, NULL);
340 oberon_generator_open_block(gen_context, gcc_block);
343 void
344 oberon_generate_call_proc(oberon_context_t * ctx, oberon_expr_t * desig)
346 gen_context_t * gen_context = ctx -> gen_context;
347 gen_block_t * gen_block = gen_context -> block;
348 gcc_jit_block * block = gen_block -> gcc_block;
350 gcc_jit_rvalue * return_value;
351 return_value = rvalue_from_expr(ctx, desig);
352 gcc_jit_block_add_eval(block, NULL, return_value);
355 void
356 oberon_generate_end_proc(oberon_context_t * ctx)
358 gen_context_t * gen_context = ctx -> gen_context;
359 oberon_generator_close_block(gen_context);
362 void
363 oberon_generate_return(oberon_context_t * ctx, oberon_expr_t * expr)
365 gen_context_t * gen_context = ctx -> gen_context;
366 gen_block_t * gen_block = gen_context -> block;
367 gcc_jit_block * gcc_block = gen_block -> gcc_block;
369 if(expr == NULL)
371 gcc_jit_block_end_with_void_return(gcc_block, NULL);
373 else
375 gcc_jit_rvalue * r = rvalue_from_expr(ctx, expr);
376 gcc_jit_block_end_with_return(gcc_block, NULL, r);
380 static gcc_jit_lvalue *
381 lvalue_from_item(oberon_context_t * ctx, oberon_item_t * item)
383 gen_context_t * gen_context = ctx -> gen_context;
384 gcc_jit_context * gcc_context = gen_context -> gcc_context;
386 gcc_jit_lvalue * left;
388 if(item -> mode == MODE_VAR)
390 if(item -> var -> class == OBERON_CLASS_PROC)
392 oberon_error(ctx, "casting static procedure to pointer not supported by generator");
395 gen_var_t * gen_var = item -> var -> gen_var;
396 left = gen_var -> gcc_lvalue;
397 if(item -> var -> class == OBERON_CLASS_VAR_PARAM)
399 gcc_jit_rvalue * r = gcc_jit_lvalue_as_rvalue(left);
400 left = gcc_jit_rvalue_dereference(r, NULL);
403 else if(item -> mode == MODE_INDEX)
405 assert(item -> num_args == 1);
406 gcc_jit_rvalue * parent = rvalue_from_item(ctx, item -> parent);
407 gcc_jit_rvalue * index = rvalue_from_expr(ctx, item -> args);
408 left = gcc_jit_context_new_array_access(gcc_context, NULL, parent, index);
410 else if(item -> mode == MODE_FIELD)
412 printf("lvalue_from_item: %s\n", item -> var -> name);
413 gen_var_t * gen_var = item -> var -> gen_var;
414 gcc_jit_field * gcc_field = gen_var -> gcc_field;
416 gcc_jit_lvalue * parent = lvalue_from_item(ctx, item -> parent);
417 left = gcc_jit_lvalue_access_field(parent, NULL, gcc_field);
419 else if(item -> mode == MODE_DEREF)
421 gcc_jit_rvalue * parent = rvalue_from_item(ctx, item -> parent);
422 left = gcc_jit_rvalue_dereference(parent, NULL);
424 else
426 oberon_error(ctx, "invalid lvalue expression");
429 return left;
432 static gcc_jit_lvalue *
433 lvalue_from_expr(oberon_context_t *ctx, oberon_expr_t * expr)
435 gcc_jit_lvalue * left;
436 oberon_item_t * item;
438 if(expr -> is_item)
440 item = (oberon_item_t *) expr;
441 left = lvalue_from_item(ctx, item);
443 else
445 oberon_error(ctx, "invalid lvalue expression");
448 return left;
451 static gcc_jit_rvalue *
452 rvalue_from_item(oberon_context_t * ctx, oberon_item_t * item)
454 gen_context_t * gen_context = ctx -> gen_context;
455 gcc_jit_context * gcc_context = gen_context -> gcc_context;
457 gcc_jit_rvalue * right;
458 if(item -> mode == MODE_VAR)
460 gcc_jit_lvalue * left = lvalue_from_item(ctx, item);
461 right = gcc_jit_lvalue_as_rvalue(left);
463 else if(item -> mode == MODE_INTEGER)
465 gcc_jit_type * int_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_INT);
466 right = gcc_jit_context_new_rvalue_from_int(gcc_context, int_type, item -> integer);
468 else if(item -> mode == MODE_BOOLEAN)
470 gcc_jit_type * bool_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_BOOL);
471 if(item -> boolean)
473 right = gcc_jit_context_one(gcc_context, bool_type);
475 else
477 right = gcc_jit_context_zero(gcc_context, bool_type);
480 else if(item -> mode == MODE_CALL)
482 oberon_type_t * signature = item -> var -> type;
483 gen_proc_t * gen_proc = item -> var -> gen_proc;
485 int num_args = item -> num_args;
486 gcc_jit_rvalue *args[num_args];
488 oberon_expr_t * expr = item -> args;
489 oberon_object_t * arg_param = signature -> decl;
490 for(int i = 0; i < num_args; i++)
492 if(arg_param -> class == OBERON_CLASS_VAR_PARAM)
494 gcc_jit_lvalue * left = lvalue_from_expr(ctx, expr);
495 args[i] = gcc_jit_lvalue_get_address(left, NULL);
497 else
499 args[i] = rvalue_from_expr(ctx, expr);
501 expr = expr -> next;
502 arg_param = arg_param -> next;
505 gcc_jit_rvalue * fnptr;
506 gcc_jit_function * func;
507 switch(item -> var -> class)
509 case OBERON_CLASS_PROC:
510 func = gen_proc -> gcc_func;
511 right = gcc_jit_context_new_call(
512 gcc_context, NULL, func, num_args, args
513 );
514 break;
515 case OBERON_CLASS_VAR:
516 case OBERON_CLASS_VAR_PARAM:
517 case OBERON_CLASS_PARAM:
518 fnptr = gcc_jit_lvalue_as_rvalue(item -> var -> gen_var -> gcc_lvalue);
519 right = gcc_jit_context_new_call_through_ptr(
520 gcc_context, NULL, fnptr, num_args, args
521 );
522 break;
523 default:
524 assert(0);
525 break;
528 else if(item -> mode == MODE_INDEX)
530 gcc_jit_lvalue * left = lvalue_from_item(ctx, item);
531 right = gcc_jit_lvalue_as_rvalue(left);
533 else if(item -> mode == MODE_FIELD)
535 gen_var_t * gen_var = item -> var -> gen_var;
536 gcc_jit_field * gcc_field = gen_var -> gcc_field;
538 gcc_jit_rvalue * parent = rvalue_from_item(ctx, item -> parent);
539 right = gcc_jit_rvalue_access_field(parent, NULL, gcc_field);
541 else if(item -> mode == MODE_DEREF)
543 gcc_jit_lvalue * left = lvalue_from_item(ctx, item);
544 right = gcc_jit_lvalue_as_rvalue(left);
546 else if(item -> mode == MODE_NIL)
548 gcc_jit_type * type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_VOID_PTR);
549 right = gcc_jit_context_null(gcc_context, type);
551 else
553 oberon_error(ctx, "rvalue_from_item: invalid mode %i", item -> mode);
556 return right;
559 struct {
560 int type; // 0 - unary, 1 - binary, 2 - comp
561 union {
562 enum gcc_jit_unary_op unary_op;
563 enum gcc_jit_binary_op binary_op;
564 enum gcc_jit_comparison comp_op;
565 };
566 } op_table[] = {
567 { 0, .unary_op = GCC_JIT_UNARY_OP_MINUS },
568 { 0, .unary_op = GCC_JIT_UNARY_OP_BITWISE_NEGATE },
569 { 0, .unary_op = GCC_JIT_UNARY_OP_LOGICAL_NEGATE },
570 { 0, .unary_op = GCC_JIT_UNARY_OP_ABS },
572 { 1, .binary_op = GCC_JIT_BINARY_OP_PLUS },
573 { 1, .binary_op = GCC_JIT_BINARY_OP_MINUS },
574 { 1, .binary_op = GCC_JIT_BINARY_OP_MULT },
575 { 1, .binary_op = GCC_JIT_BINARY_OP_DIVIDE },
576 { 1, .binary_op = GCC_JIT_BINARY_OP_MODULO },
577 { 1, .binary_op = GCC_JIT_BINARY_OP_BITWISE_AND },
578 { 1, .binary_op = GCC_JIT_BINARY_OP_BITWISE_XOR },
579 { 1, .binary_op = GCC_JIT_BINARY_OP_BITWISE_OR },
580 { 1, .binary_op = GCC_JIT_BINARY_OP_LOGICAL_AND },
581 { 1, .binary_op = GCC_JIT_BINARY_OP_LOGICAL_OR },
583 { 2, .comp_op = GCC_JIT_COMPARISON_EQ },
584 { 2, .comp_op = GCC_JIT_COMPARISON_NE },
585 { 2, .comp_op = GCC_JIT_COMPARISON_LT },
586 { 2, .comp_op = GCC_JIT_COMPARISON_LE },
587 { 2, .comp_op = GCC_JIT_COMPARISON_GT },
588 { 2, .comp_op = GCC_JIT_COMPARISON_GE }
589 };
591 static gcc_jit_rvalue *
592 rvalue_from_operator(oberon_context_t * ctx, oberon_oper_t * operator)
594 gcc_jit_rvalue * right;
596 gen_context_t * gen_context = ctx -> gen_context;
597 gen_type_t * gen_type = operator -> result -> gen_type;
598 gcc_jit_context * gcc_context = gen_context -> gcc_context;
599 gcc_jit_type * result_type = gen_type -> gcc_type;
601 int expr_type = op_table[operator -> op].type;
602 if(expr_type == 0)
604 enum gcc_jit_unary_op op = op_table[operator -> op].unary_op;
605 gcc_jit_rvalue * l = rvalue_from_expr(ctx, operator -> left);
606 right = gcc_jit_context_new_unary_op(gcc_context, NULL, op, result_type, l);
608 else if(expr_type == 1)
610 enum gcc_jit_unary_op op = op_table[operator -> op].binary_op;
611 gcc_jit_rvalue * l = rvalue_from_expr(ctx, operator -> left);
612 gcc_jit_rvalue * r = rvalue_from_expr(ctx, operator -> right);
613 right = gcc_jit_context_new_binary_op(gcc_context, NULL, op, result_type, l, r);
615 else if(expr_type == 2)
617 enum gcc_jit_comparison op = op_table[operator -> op].comp_op;
618 gcc_jit_rvalue * l = rvalue_from_expr(ctx, operator -> left);
619 gcc_jit_rvalue * r = rvalue_from_expr(ctx, operator -> right);
620 right = gcc_jit_context_new_comparison(gcc_context, NULL, op, l, r);
622 else
624 oberon_error(ctx, "rvalue_from_operator: wat");
627 return right;
630 static gcc_jit_rvalue *
631 rvalue_from_expr(oberon_context_t * ctx, oberon_expr_t * expr)
633 gcc_jit_rvalue * right;
635 if(expr -> is_item)
637 oberon_item_t * item = (oberon_item_t *) expr;
638 right = rvalue_from_item(ctx, item);
640 else
642 oberon_oper_t * operator = (oberon_oper_t *) expr;
643 right = rvalue_from_operator(ctx, operator);
646 return right;
649 void
650 oberon_generate_assign(oberon_context_t * ctx, oberon_expr_t * src, oberon_expr_t * dst)
652 gcc_jit_lvalue * left;
653 left = lvalue_from_expr(ctx, dst);
655 gcc_jit_rvalue * right;
656 right = rvalue_from_expr(ctx, src);
658 if(src -> is_item)
660 if(src -> item.mode == MODE_NIL)
662 gen_context_t * gen_context = ctx -> gen_context;
663 gcc_jit_context * gcc_context = gen_context -> gcc_context;
664 gen_type_t * gen_type = dst -> result -> gen_type;
665 gcc_jit_type * cast_to_type = gen_type -> gcc_type;
666 right = gcc_jit_context_new_cast(gcc_context, NULL, right, cast_to_type);
670 printf("oberon_generate_assign: class %i := class %i\n", dst -> result -> class, src -> result -> class);
672 gen_context_t * gen_context = ctx -> gen_context;
673 gen_block_t * gen_block = gen_context -> block;
674 gcc_jit_block * gcc_block = gen_block -> gcc_block;
675 gcc_jit_block_add_assignment(gcc_block, NULL, left, right);
678 void
679 oberon_generate_code(oberon_context_t * ctx)
681 gen_context_t * gen_context = ctx -> gen_context;
682 gcc_jit_context * gcc_context = gen_context -> gcc_context;
684 gcc_jit_result * gcc_result;
685 gcc_result = gcc_jit_context_compile(gcc_context);
687 gen_context -> gcc_result = gcc_result;
689 // ctx -> mod -> begin = gcc_jit_result_get_code(gcc_result, "BEGIN");
692 void
693 oberon_generator_dump(oberon_context_t * ctx, char * path)
695 gen_context_t * gen_context = ctx -> gen_context;
696 gcc_jit_context * gcc_context = gen_context -> gcc_context;
697 gcc_jit_context_dump_to_file(gcc_context, path, 0);
700 void *
701 oberon_generator_get_procedure(oberon_context_t * ctx, const char * name)
703 gen_context_t * gen_context = ctx -> gen_context;
704 gcc_jit_result * gcc_result = gen_context -> gcc_result;
706 return gcc_jit_result_get_code(gcc_result, name);
709 void *
710 oberon_generator_get_var(oberon_context_t * ctx, const char * name)
712 gen_context_t * gen_context = ctx -> gen_context;
713 gcc_jit_result * gcc_result = gen_context -> gcc_result;
715 return gcc_jit_result_get_global(gcc_result, name);