DEADSOFTWARE

991b6dd83c416be4d19a81a0722c30f29d6e12d5
[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 char parent[256];
165 parent[0] = 0;
167 switch(x -> class)
169 case OBERON_CLASS_FIELD:
170 case OBERON_CLASS_PARAM:
171 case OBERON_CLASS_VAR_PARAM:
172 /* В локальных областях префиксы излишни */
173 break;
174 default:
175 oberon_generator_get_full_name(parent, 256, x -> parent);
176 break;
179 if(strlen(parent) > 0)
181 snprintf(name, max_len, "%s_%s", parent, x -> name);
183 else
185 snprintf(name, max_len, "%s", x -> name);
189 void
190 oberon_generator_init_var(oberon_context_t * ctx, oberon_object_t * var)
192 gen_context_t * gen_context = ctx -> gen_context;
193 gen_type_t * gen_type = var -> type -> gen_type;
195 gen_var_t * gen_var = malloc(sizeof *gen_var);
196 memset(gen_var, 0, sizeof *gen_var);
197 var -> gen_var = gen_var;
199 gcc_jit_context * gcc_context = gen_context -> gcc_context;
200 gcc_jit_type * gcc_type = gen_type -> gcc_type;
202 char name[256];
203 oberon_generator_get_full_name(name, 256, var);
205 gcc_jit_lvalue * gcc_lvalue = NULL;
206 gcc_jit_param * gcc_param = NULL;
207 gcc_jit_field * gcc_field = NULL;
208 if(var -> class == OBERON_CLASS_VAR)
210 if(var -> local)
212 gen_proc_t * gen_func = var -> parent -> gen_proc;
213 gcc_jit_function * func = gen_func -> gcc_func;
215 gcc_lvalue = gcc_jit_function_new_local(func, NULL, gcc_type, name);
217 else
219 gcc_lvalue = gcc_jit_context_new_global(
220 gcc_context, NULL, GCC_JIT_GLOBAL_INTERNAL, gcc_type, name
221 );
224 else if(var -> class == OBERON_CLASS_PARAM)
226 gcc_param = gcc_jit_context_new_param(gcc_context, NULL, gcc_type, name);
227 gcc_lvalue = gcc_jit_param_as_lvalue(gcc_param);
229 else if(var -> class == OBERON_CLASS_VAR_PARAM)
231 gcc_type = gcc_jit_type_get_pointer(gcc_type);
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_FIELD)
237 gcc_field = gcc_jit_context_new_field(gcc_context, NULL, gcc_type, name);
239 else
241 oberon_error(ctx, "oberon_generator_init_var: invalid class %i", var -> class);
244 gen_var -> gcc_lvalue = gcc_lvalue;
245 gen_var -> gcc_param = gcc_param;
246 gen_var -> gcc_field = gcc_field;
249 void
250 oberon_generator_init_proc(oberon_context_t * ctx, oberon_object_t * proc)
252 if(proc -> local)
254 oberon_error(ctx, "generator: local procedures not supported");
257 gen_context_t * gen_context = ctx -> gen_context;
258 gcc_jit_context * gcc_context = gen_context -> gcc_context;
260 gen_proc_t * gen_proc = malloc(sizeof *gen_proc);
261 memset(gen_proc, 0, sizeof *gen_proc);
262 proc -> gen_proc = gen_proc;
264 char name[256];
265 oberon_generator_get_full_name(name, 256, proc);
267 gen_type_t * gen_result_type = proc -> type -> base -> gen_type;
268 gcc_jit_type * result_type = gen_result_type -> gcc_type;
270 /* Строим список параметров */
271 int num_param = proc -> type -> num_decl;
272 oberon_object_t * o = proc -> type -> decl;
273 gcc_jit_param * params[num_param];
274 for(int i = 0; i < num_param; i++)
276 gen_var_t * param_var = o -> gen_var;
277 params[i] = param_var -> gcc_param;
278 o = o -> next;
281 gcc_jit_function * gcc_func;
282 gcc_func = gcc_jit_context_new_function(
283 gcc_context, NULL, GCC_JIT_FUNCTION_EXPORTED, result_type, name, num_param, params, 0
284 );
286 gen_proc -> gcc_func = gcc_func;
289 // =======================================================================
290 // GENERATOR
291 // =======================================================================
293 static gcc_jit_rvalue * rvalue_from_item(oberon_context_t * ctx, oberon_item_t * item);
294 static gcc_jit_rvalue * rvalue_from_expr(oberon_context_t * ctx, oberon_expr_t * expr);
296 void
297 oberon_generate_begin_module(oberon_context_t * ctx)
299 gen_context_t * gen_context = ctx -> gen_context;
300 gcc_jit_context * gcc_context = gen_context -> gcc_context;
302 char name[256];
303 snprintf(name, 256, "%s_BEGIN", ctx -> mod -> name);
305 gcc_jit_type * void_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_VOID);
306 gcc_jit_function * func = gcc_jit_context_new_function(
307 gcc_context, NULL, GCC_JIT_FUNCTION_EXPORTED, void_type, name, 0, NULL, 0
308 );
309 gcc_jit_block * gcc_block = gcc_jit_function_new_block(func, NULL);
311 oberon_generator_open_block(gen_context, gcc_block);
314 void
315 oberon_generate_end_module(oberon_context_t * ctx)
317 gen_context_t * gen_context = ctx -> gen_context;
318 gcc_jit_block * gcc_block = gen_context -> block -> gcc_block;
320 gcc_jit_block_end_with_void_return(gcc_block, NULL);
322 oberon_generator_close_block(gen_context);
325 void
326 oberon_generate_begin_proc(oberon_context_t * ctx, oberon_object_t * proc)
328 gen_context_t * gen_context = ctx -> gen_context;
329 gen_proc_t * gen_proc = proc -> gen_proc;
331 gcc_jit_function * func = gen_proc -> gcc_func;
332 gcc_jit_block * gcc_block = gcc_jit_function_new_block(func, NULL);
334 oberon_generator_open_block(gen_context, gcc_block);
337 void
338 oberon_generate_call_proc(oberon_context_t * ctx, oberon_expr_t * desig)
340 gen_context_t * gen_context = ctx -> gen_context;
341 gen_block_t * gen_block = gen_context -> block;
342 gcc_jit_block * block = gen_block -> gcc_block;
344 gcc_jit_rvalue * return_value;
345 return_value = rvalue_from_expr(ctx, desig);
346 gcc_jit_block_add_eval(block, NULL, return_value);
349 void
350 oberon_generate_end_proc(oberon_context_t * ctx)
352 gen_context_t * gen_context = ctx -> gen_context;
353 oberon_generator_close_block(gen_context);
356 void
357 oberon_generate_return(oberon_context_t * ctx, oberon_expr_t * expr)
359 gen_context_t * gen_context = ctx -> gen_context;
360 gen_block_t * gen_block = gen_context -> block;
361 gcc_jit_block * gcc_block = gen_block -> gcc_block;
363 if(expr == NULL)
365 gcc_jit_block_end_with_void_return(gcc_block, NULL);
367 else
369 gcc_jit_rvalue * r = rvalue_from_expr(ctx, expr);
370 gcc_jit_block_end_with_return(gcc_block, NULL, r);
374 static gcc_jit_lvalue *
375 lvalue_from_item(oberon_context_t * ctx, oberon_item_t * item)
377 gen_context_t * gen_context = ctx -> gen_context;
378 gcc_jit_context * gcc_context = gen_context -> gcc_context;
380 gcc_jit_lvalue * left;
382 if(item -> mode == MODE_VAR)
384 if(item -> var -> class == OBERON_CLASS_PROC)
386 oberon_error(ctx, "casting static procedure to pointer not supported by generator");
389 gen_var_t * gen_var = item -> var -> gen_var;
390 left = gen_var -> gcc_lvalue;
391 if(item -> var -> class == OBERON_CLASS_VAR_PARAM)
393 gcc_jit_rvalue * r = gcc_jit_lvalue_as_rvalue(left);
394 left = gcc_jit_rvalue_dereference(r, NULL);
397 else if(item -> mode == MODE_INDEX)
399 assert(item -> num_args == 1);
400 gcc_jit_rvalue * parent = rvalue_from_item(ctx, item -> parent);
401 gcc_jit_rvalue * index = rvalue_from_expr(ctx, item -> args);
402 left = gcc_jit_context_new_array_access(gcc_context, NULL, parent, index);
404 else if(item -> mode == MODE_FIELD)
406 printf("lvalue_from_item: %s\n", item -> var -> name);
407 gen_var_t * gen_var = item -> var -> gen_var;
408 gcc_jit_field * gcc_field = gen_var -> gcc_field;
410 gcc_jit_lvalue * parent = lvalue_from_item(ctx, item -> parent);
411 left = gcc_jit_lvalue_access_field(parent, NULL, gcc_field);
413 else if(item -> mode == MODE_DEREF)
415 gcc_jit_rvalue * parent = rvalue_from_item(ctx, item -> parent);
416 left = gcc_jit_rvalue_dereference(parent, NULL);
418 else
420 oberon_error(ctx, "invalid lvalue expression");
423 return left;
426 static gcc_jit_lvalue *
427 lvalue_from_expr(oberon_context_t *ctx, oberon_expr_t * expr)
429 gcc_jit_lvalue * left;
430 oberon_item_t * item;
432 if(expr -> is_item)
434 item = (oberon_item_t *) expr;
435 left = lvalue_from_item(ctx, item);
437 else
439 oberon_error(ctx, "invalid lvalue expression");
442 return left;
445 static gcc_jit_rvalue *
446 rvalue_from_item(oberon_context_t * ctx, oberon_item_t * item)
448 gen_context_t * gen_context = ctx -> gen_context;
449 gcc_jit_context * gcc_context = gen_context -> gcc_context;
451 gcc_jit_rvalue * right;
452 if(item -> mode == MODE_VAR)
454 gcc_jit_lvalue * left = lvalue_from_item(ctx, item);
455 right = gcc_jit_lvalue_as_rvalue(left);
457 else if(item -> mode == MODE_INTEGER)
459 gcc_jit_type * int_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_INT);
460 right = gcc_jit_context_new_rvalue_from_int(gcc_context, int_type, item -> integer);
462 else if(item -> mode == MODE_BOOLEAN)
464 gcc_jit_type * bool_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_BOOL);
465 if(item -> boolean)
467 right = gcc_jit_context_one(gcc_context, bool_type);
469 else
471 right = gcc_jit_context_zero(gcc_context, bool_type);
474 else if(item -> mode == MODE_CALL)
476 oberon_type_t * signature = item -> var -> type;
477 gen_proc_t * gen_proc = item -> var -> gen_proc;
479 int num_args = item -> num_args;
480 gcc_jit_rvalue *args[num_args];
482 oberon_expr_t * expr = item -> args;
483 oberon_object_t * arg_param = signature -> decl;
484 for(int i = 0; i < num_args; i++)
486 if(arg_param -> class == OBERON_CLASS_VAR_PARAM)
488 gcc_jit_lvalue * left = lvalue_from_expr(ctx, expr);
489 args[i] = gcc_jit_lvalue_get_address(left, NULL);
491 else
493 args[i] = rvalue_from_expr(ctx, expr);
495 expr = expr -> next;
496 arg_param = arg_param -> next;
499 gcc_jit_rvalue * fnptr;
500 gcc_jit_function * func;
501 switch(item -> var -> class)
503 case OBERON_CLASS_PROC:
504 func = gen_proc -> gcc_func;
505 right = gcc_jit_context_new_call(
506 gcc_context, NULL, func, num_args, args
507 );
508 break;
509 case OBERON_CLASS_VAR:
510 case OBERON_CLASS_VAR_PARAM:
511 case OBERON_CLASS_PARAM:
512 fnptr = gcc_jit_lvalue_as_rvalue(item -> var -> gen_var -> gcc_lvalue);
513 right = gcc_jit_context_new_call_through_ptr(
514 gcc_context, NULL, fnptr, num_args, args
515 );
516 break;
517 default:
518 assert(0);
519 break;
522 else if(item -> mode == MODE_INDEX)
524 gcc_jit_lvalue * left = lvalue_from_item(ctx, item);
525 right = gcc_jit_lvalue_as_rvalue(left);
527 else if(item -> mode == MODE_FIELD)
529 gen_var_t * gen_var = item -> var -> gen_var;
530 gcc_jit_field * gcc_field = gen_var -> gcc_field;
532 gcc_jit_rvalue * parent = rvalue_from_item(ctx, item -> parent);
533 right = gcc_jit_rvalue_access_field(parent, NULL, gcc_field);
535 else if(item -> mode == MODE_DEREF)
537 gcc_jit_lvalue * left = lvalue_from_item(ctx, item);
538 right = gcc_jit_lvalue_as_rvalue(left);
540 else if(item -> mode == MODE_NIL)
542 gcc_jit_type * type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_VOID_PTR);
543 right = gcc_jit_context_null(gcc_context, type);
545 else
547 oberon_error(ctx, "rvalue_from_item: invalid mode %i", item -> mode);
550 return right;
553 struct {
554 int type; // 0 - unary, 1 - binary, 2 - comp
555 union {
556 enum gcc_jit_unary_op unary_op;
557 enum gcc_jit_binary_op binary_op;
558 enum gcc_jit_comparison comp_op;
559 };
560 } op_table[] = {
561 { 0, .unary_op = GCC_JIT_UNARY_OP_MINUS },
562 { 0, .unary_op = GCC_JIT_UNARY_OP_BITWISE_NEGATE },
563 { 0, .unary_op = GCC_JIT_UNARY_OP_LOGICAL_NEGATE },
564 { 0, .unary_op = GCC_JIT_UNARY_OP_ABS },
566 { 1, .binary_op = GCC_JIT_BINARY_OP_PLUS },
567 { 1, .binary_op = GCC_JIT_BINARY_OP_MINUS },
568 { 1, .binary_op = GCC_JIT_BINARY_OP_MULT },
569 { 1, .binary_op = GCC_JIT_BINARY_OP_DIVIDE },
570 { 1, .binary_op = GCC_JIT_BINARY_OP_MODULO },
571 { 1, .binary_op = GCC_JIT_BINARY_OP_BITWISE_AND },
572 { 1, .binary_op = GCC_JIT_BINARY_OP_BITWISE_XOR },
573 { 1, .binary_op = GCC_JIT_BINARY_OP_BITWISE_OR },
574 { 1, .binary_op = GCC_JIT_BINARY_OP_LOGICAL_AND },
575 { 1, .binary_op = GCC_JIT_BINARY_OP_LOGICAL_OR },
577 { 2, .comp_op = GCC_JIT_COMPARISON_EQ },
578 { 2, .comp_op = GCC_JIT_COMPARISON_NE },
579 { 2, .comp_op = GCC_JIT_COMPARISON_LT },
580 { 2, .comp_op = GCC_JIT_COMPARISON_LE },
581 { 2, .comp_op = GCC_JIT_COMPARISON_GT },
582 { 2, .comp_op = GCC_JIT_COMPARISON_GE }
583 };
585 static gcc_jit_rvalue *
586 rvalue_from_operator(oberon_context_t * ctx, oberon_oper_t * operator)
588 gcc_jit_rvalue * right;
590 gen_context_t * gen_context = ctx -> gen_context;
591 gen_type_t * gen_type = operator -> result -> gen_type;
592 gcc_jit_context * gcc_context = gen_context -> gcc_context;
593 gcc_jit_type * result_type = gen_type -> gcc_type;
595 int expr_type = op_table[operator -> op].type;
596 if(expr_type == 0)
598 enum gcc_jit_unary_op op = op_table[operator -> op].unary_op;
599 gcc_jit_rvalue * l = rvalue_from_expr(ctx, operator -> left);
600 right = gcc_jit_context_new_unary_op(gcc_context, NULL, op, result_type, l);
602 else if(expr_type == 1)
604 enum gcc_jit_unary_op op = op_table[operator -> op].binary_op;
605 gcc_jit_rvalue * l = rvalue_from_expr(ctx, operator -> left);
606 gcc_jit_rvalue * r = rvalue_from_expr(ctx, operator -> right);
607 right = gcc_jit_context_new_binary_op(gcc_context, NULL, op, result_type, l, r);
609 else if(expr_type == 2)
611 enum gcc_jit_comparison op = op_table[operator -> op].comp_op;
612 gcc_jit_rvalue * l = rvalue_from_expr(ctx, operator -> left);
613 gcc_jit_rvalue * r = rvalue_from_expr(ctx, operator -> right);
614 right = gcc_jit_context_new_comparison(gcc_context, NULL, op, l, r);
616 else
618 oberon_error(ctx, "rvalue_from_operator: wat");
621 return right;
624 static gcc_jit_rvalue *
625 rvalue_from_expr(oberon_context_t * ctx, oberon_expr_t * expr)
627 gcc_jit_rvalue * right;
629 if(expr -> is_item)
631 oberon_item_t * item = (oberon_item_t *) expr;
632 right = rvalue_from_item(ctx, item);
634 else
636 oberon_oper_t * operator = (oberon_oper_t *) expr;
637 right = rvalue_from_operator(ctx, operator);
640 return right;
643 void
644 oberon_generate_assign(oberon_context_t * ctx, oberon_expr_t * src, oberon_expr_t * dst)
646 gcc_jit_lvalue * left;
647 left = lvalue_from_expr(ctx, dst);
649 gcc_jit_rvalue * right;
650 right = rvalue_from_expr(ctx, src);
652 if(src -> is_item)
654 if(src -> item.mode == MODE_NIL)
656 gen_context_t * gen_context = ctx -> gen_context;
657 gcc_jit_context * gcc_context = gen_context -> gcc_context;
658 gen_type_t * gen_type = dst -> result -> gen_type;
659 gcc_jit_type * cast_to_type = gen_type -> gcc_type;
660 right = gcc_jit_context_new_cast(gcc_context, NULL, right, cast_to_type);
664 printf("oberon_generate_assign: class %i := class %i\n", dst -> result -> class, src -> result -> class);
666 gen_context_t * gen_context = ctx -> gen_context;
667 gen_block_t * gen_block = gen_context -> block;
668 gcc_jit_block * gcc_block = gen_block -> gcc_block;
669 gcc_jit_block_add_assignment(gcc_block, NULL, left, right);
672 void
673 oberon_generate_code(oberon_context_t * ctx)
675 gen_context_t * gen_context = ctx -> gen_context;
676 gcc_jit_context * gcc_context = gen_context -> gcc_context;
678 gcc_jit_result * gcc_result;
679 gcc_result = gcc_jit_context_compile(gcc_context);
681 gen_context -> gcc_result = gcc_result;
683 // ctx -> mod -> begin = gcc_jit_result_get_code(gcc_result, "BEGIN");
686 void
687 oberon_generator_dump(oberon_context_t * ctx, char * path)
689 gen_context_t * gen_context = ctx -> gen_context;
690 gcc_jit_context * gcc_context = gen_context -> gcc_context;
691 gcc_jit_context_dump_to_file(gcc_context, path, 0);
694 void *
695 oberon_generator_get_procedure(oberon_context_t * ctx, const char * name)
697 gen_context_t * gen_context = ctx -> gen_context;
698 gcc_jit_result * gcc_result = gen_context -> gcc_result;
700 return gcc_jit_result_get_code(gcc_result, name);
703 void *
704 oberon_generator_get_var(oberon_context_t * ctx, const char * name)
706 gen_context_t * gen_context = ctx -> gen_context;
707 gcc_jit_result * gcc_result = gen_context -> gcc_result;
709 return gcc_jit_result_get_global(gcc_result, name);