DEADSOFTWARE

05873d1303fa9bb214a3add0bf3374a3b408196d
[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 static void printcontext(oberon_context_t * ctx, char * s)
12 {
13 /*
14 gen_context_t * gen_context = ctx -> gen_context;
15 gcc_jit_context * gcc_context = gen_context -> gcc_context;
16 gcc_jit_block * gcc_block = gen_context -> gcc_block;
18 printf("%s:\n", s);
19 printf(" ctx = %p:\n", ctx);
20 printf(" gctx = %p:\n", gctx);
21 printf(" context = %p:\n", context);
22 printf(" block = %p:\n", block);
23 */
24 }
26 // =======================================================================
27 // ALLOC
28 // =======================================================================
30 static void
31 oberon_generator_open_block(gen_context_t * gen_context, gcc_jit_block * gcc_block)
32 {
33 gen_block_t * block = malloc(sizeof *block);
34 memset(block, 0, sizeof *block);
36 block -> gcc_block = gcc_block;
37 block -> up = gen_context -> block;
39 gen_context -> block = block;
40 }
42 static void
43 oberon_generator_close_block(gen_context_t * gen_context)
44 {
45 gen_context -> block = gen_context -> block -> up;
46 }
48 void
49 oberon_generator_init_context(oberon_context_t * ctx)
50 {
51 gen_context_t * gen_context = malloc(sizeof *gen_context);
52 memset(gen_context, 0, sizeof *gen_context);
54 gcc_jit_context * gcc_context;
55 gcc_context = gcc_jit_context_acquire();
57 ctx -> gen_context = gen_context;
58 gen_context -> gcc_context = gcc_context;
60 printcontext(ctx, "oberon_generator_init_context");
61 }
63 void
64 oberon_generator_destroy_context(oberon_context_t * ctx)
65 {
66 printcontext(ctx, "oberon_generator_destroy_context");
68 gen_context_t * gen_context = ctx -> gen_context;
69 gcc_jit_context * gcc_context = gen_context -> gcc_context;
71 gcc_jit_context_release(gcc_context);
72 }
74 void
75 oberon_generator_init_type(oberon_context_t * ctx, oberon_type_t * type)
76 {
77 gen_type_t * gen_type = malloc(sizeof *gen_type);
78 memset(gen_type, 0, sizeof *gen_type);
79 type -> gen_type = gen_type;
81 gen_context_t * gen_context = ctx -> gen_context;
82 gcc_jit_context * gcc_context = gen_context -> gcc_context;
84 gcc_jit_type * gcc_type = NULL;
85 gcc_jit_struct * gcc_struct = NULL;
86 if(type -> class == OBERON_TYPE_VOID)
87 {
88 gcc_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_VOID);
89 }
90 else if(type -> class == OBERON_TYPE_INTEGER)
91 {
92 gcc_type = gcc_jit_context_get_int_type(gcc_context, type -> size, 1);
93 }
94 else if(type -> class == OBERON_TYPE_BOOLEAN)
95 {
96 gcc_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_BOOL);
97 }
98 else if(type -> class == OBERON_TYPE_ARRAY)
99 {
100 gen_type_t * gen_base = type -> base -> gen_type;
101 gcc_jit_type * gcc_base = gen_base -> gcc_type;
102 gcc_type = gcc_jit_context_new_array_type(gcc_context, NULL, gcc_base, type -> size);
104 else if(type -> class == OBERON_TYPE_RECORD)
106 char name[32];
107 snprintf(name, 32, "RECORD%u", gen_context -> record_count);
108 gen_context -> record_count += 1;
110 gcc_struct = gcc_jit_context_new_opaque_struct(gcc_context, NULL, name);
111 gcc_type = gcc_jit_struct_as_type(gcc_struct);
113 else if(type -> class == OBERON_TYPE_POINTER)
115 gen_type_t * gen_base = type -> base -> gen_type;
116 gcc_jit_type * gcc_base = gen_base -> gcc_type;
117 gcc_type = gcc_jit_type_get_pointer(gcc_base);
119 else if(type -> class == OBERON_TYPE_PROCEDURE)
121 int num_params = type -> num_decl;
122 gcc_jit_type * params[num_params];
123 oberon_object_t * o = type -> decl;
124 for(int i = 0; i < num_params; i++)
126 gen_type_t * gen_type = o -> type -> gen_type;
127 params[i] = gen_type -> gcc_type;
128 o = o -> next;
131 gen_type_t * base = type -> base -> gen_type;
132 gcc_jit_type * result_type = base -> gcc_type;
134 gcc_type = gcc_jit_context_new_function_ptr_type(
135 gcc_context, NULL, result_type, num_params, params, 0
136 );
138 else
140 oberon_error(ctx, "oberon_generator_init_type: invalid type class %i", type -> class);
143 assert(gcc_type);
144 gen_type -> gcc_type = gcc_type;
145 gen_type -> gcc_struct = gcc_struct;
148 void
149 oberon_generator_init_record(oberon_context_t * ctx, oberon_type_t * type)
151 assert(type -> class == OBERON_TYPE_RECORD);
153 gen_type_t * gen_type = type -> gen_type;
154 gcc_jit_struct * gcc_struct = gen_type -> gcc_struct;
156 // TODO type exstension
158 int num_fields = type -> num_decl;
159 gcc_jit_field * fields[num_fields];
160 oberon_object_t * o = type -> decl;
161 for(int i = 0; i < num_fields; i++)
163 assert(o -> class == OBERON_CLASS_FIELD);
164 gen_var_t * var = o -> gen_var;
165 fields[i] = var -> gcc_field;
166 o = o -> next;
169 gcc_jit_struct_set_fields (gcc_struct, NULL, num_fields, fields);
171 //gcc_struct = gcc_jit_context_new_struct_type(gcc_context, NULL, "", num_fields, fields);
174 void
175 oberon_generator_init_var(oberon_context_t * ctx, oberon_object_t * var)
177 gen_context_t * gen_context = ctx -> gen_context;
178 gen_type_t * gen_type = var -> type -> gen_type;
180 gen_var_t * gen_var = malloc(sizeof *gen_var);
181 memset(gen_var, 0, sizeof *gen_var);
182 var -> gen_var = gen_var;
184 gcc_jit_context * gcc_context = gen_context -> gcc_context;
185 gcc_jit_type * gcc_type = gen_type -> gcc_type;
186 const char * name = var -> name;
188 gcc_jit_lvalue * gcc_lvalue = NULL;
189 gcc_jit_param * gcc_param = NULL;
190 gcc_jit_field * gcc_field = NULL;
191 if(var -> class == OBERON_CLASS_VAR)
193 if(var -> local)
195 gen_proc_t * gen_func = var -> parent -> gen_proc;
196 gcc_jit_function * func = gen_func -> gcc_func;
198 gcc_lvalue = gcc_jit_function_new_local(func, NULL, gcc_type, name);
200 else
202 gcc_lvalue = gcc_jit_context_new_global(
203 gcc_context, NULL, GCC_JIT_GLOBAL_INTERNAL, gcc_type, name
204 );
207 else if(var -> class == OBERON_CLASS_PARAM)
209 gcc_param = gcc_jit_context_new_param(gcc_context, NULL, gcc_type, name);
210 gcc_lvalue = gcc_jit_param_as_lvalue(gcc_param);
212 else if(var -> class == OBERON_CLASS_VAR_PARAM)
214 gcc_type = gcc_jit_type_get_pointer(gcc_type);
215 gcc_param = gcc_jit_context_new_param(gcc_context, NULL, gcc_type, name);
216 gcc_lvalue = gcc_jit_param_as_lvalue(gcc_param);
218 else if(var -> class == OBERON_CLASS_FIELD)
220 gcc_field = gcc_jit_context_new_field(gcc_context, NULL, gcc_type, name);
222 else
224 oberon_error(ctx, "oberon_generator_init_var: invalid class %i", var -> class);
227 gen_var -> gcc_lvalue = gcc_lvalue;
228 gen_var -> gcc_param = gcc_param;
229 gen_var -> gcc_field = gcc_field;
232 void
233 oberon_generator_init_proc(oberon_context_t * ctx, oberon_object_t * proc)
235 if(proc -> local)
237 oberon_error(ctx, "generator: local procedures not supported");
240 gen_context_t * gen_context = ctx -> gen_context;
241 gcc_jit_context * gcc_context = gen_context -> gcc_context;
243 gen_proc_t * gen_proc = malloc(sizeof *gen_proc);
244 memset(gen_proc, 0, sizeof *gen_proc);
245 proc -> gen_proc = gen_proc;
247 const char * name = proc -> name;
248 gen_type_t * gen_result_type = proc -> type -> base -> gen_type;
249 gcc_jit_type * result_type = gen_result_type -> gcc_type;
251 /* Строим список параметров */
252 int num_param = proc -> type -> num_decl;
253 oberon_object_t * o = proc -> type -> decl;
254 gcc_jit_param * params[num_param];
255 for(int i = 0; i < num_param; i++)
257 gen_var_t * param_var = o -> gen_var;
258 params[i] = param_var -> gcc_param;
259 o = o -> next;
262 gcc_jit_function * gcc_func;
263 gcc_func = gcc_jit_context_new_function(
264 gcc_context, NULL, GCC_JIT_FUNCTION_EXPORTED, result_type, name, num_param, params, 0
265 );
267 gen_proc -> gcc_func = gcc_func;
270 // =======================================================================
271 // GENERATOR
272 // =======================================================================
274 static gcc_jit_rvalue * rvalue_from_item(oberon_context_t * ctx, oberon_item_t * item);
275 static gcc_jit_rvalue * rvalue_from_expr(oberon_context_t * ctx, oberon_expr_t * expr);
277 void
278 oberon_generate_begin_module(oberon_context_t * ctx)
280 printcontext(ctx, "oberon_generate_begin_module");
282 gen_context_t * gen_context = ctx -> gen_context;
283 gcc_jit_context * gcc_context = gen_context -> gcc_context;
285 gcc_jit_type * void_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_VOID);
286 gcc_jit_function * func = gcc_jit_context_new_function(
287 gcc_context, NULL, GCC_JIT_FUNCTION_EXPORTED, void_type, "BEGIN", 0, NULL, 0
288 );
289 gcc_jit_block * gcc_block = gcc_jit_function_new_block(func, NULL);
291 oberon_generator_open_block(gen_context, gcc_block);
294 void
295 oberon_generate_end_module(oberon_context_t * ctx)
297 printcontext(ctx, "oberon_generate_end_module");
299 gen_context_t * gen_context = ctx -> gen_context;
300 gcc_jit_block * gcc_block = gen_context -> block -> gcc_block;
302 gcc_jit_block_end_with_void_return(gcc_block, NULL);
304 oberon_generator_close_block(gen_context);
307 void
308 oberon_generate_begin_proc(oberon_context_t * ctx, oberon_object_t * proc)
310 gen_context_t * gen_context = ctx -> gen_context;
311 gen_proc_t * gen_proc = proc -> gen_proc;
313 gcc_jit_function * func = gen_proc -> gcc_func;
314 gcc_jit_block * gcc_block = gcc_jit_function_new_block(func, NULL);
316 oberon_generator_open_block(gen_context, gcc_block);
319 void
320 oberon_generate_call_proc(oberon_context_t * ctx, oberon_expr_t * desig)
322 gen_context_t * gen_context = ctx -> gen_context;
323 gen_block_t * gen_block = gen_context -> block;
324 gcc_jit_block * block = gen_block -> gcc_block;
326 gcc_jit_rvalue * return_value;
327 return_value = rvalue_from_expr(ctx, desig);
328 gcc_jit_block_add_eval(block, NULL, return_value);
331 void
332 oberon_generate_end_proc(oberon_context_t * ctx)
334 gen_context_t * gen_context = ctx -> gen_context;
335 oberon_generator_close_block(gen_context);
338 void
339 oberon_generate_return(oberon_context_t * ctx, oberon_expr_t * expr)
341 gen_context_t * gen_context = ctx -> gen_context;
342 gen_block_t * gen_block = gen_context -> block;
343 gcc_jit_block * gcc_block = gen_block -> gcc_block;
345 if(expr == NULL)
347 gcc_jit_block_end_with_void_return(gcc_block, NULL);
349 else
351 gcc_jit_rvalue * r = rvalue_from_expr(ctx, expr);
352 gcc_jit_block_end_with_return(gcc_block, NULL, r);
356 static gcc_jit_lvalue *
357 lvalue_from_item(oberon_context_t * ctx, oberon_item_t * item)
359 gen_context_t * gen_context = ctx -> gen_context;
360 gcc_jit_context * gcc_context = gen_context -> gcc_context;
362 gcc_jit_lvalue * left;
364 if(item -> mode == MODE_VAR)
366 if(item -> var -> class == OBERON_CLASS_PROC)
368 oberon_error(ctx, "casting static procedure to pointer not supported by generator");
371 gen_var_t * gen_var = item -> var -> gen_var;
372 left = gen_var -> gcc_lvalue;
373 if(item -> var -> class == OBERON_CLASS_VAR_PARAM)
375 gcc_jit_rvalue * r = gcc_jit_lvalue_as_rvalue(left);
376 left = gcc_jit_rvalue_dereference(r, NULL);
379 else if(item -> mode == MODE_INDEX)
381 assert(item -> num_args == 1);
382 gcc_jit_rvalue * parent = rvalue_from_item(ctx, item -> parent);
383 gcc_jit_rvalue * index = rvalue_from_expr(ctx, item -> args);
384 left = gcc_jit_context_new_array_access(gcc_context, NULL, parent, index);
386 else if(item -> mode == MODE_FIELD)
388 printf("lvalue_from_item: %s\n", item -> var -> name);
389 gen_var_t * gen_var = item -> var -> gen_var;
390 gcc_jit_field * gcc_field = gen_var -> gcc_field;
392 gcc_jit_lvalue * parent = lvalue_from_item(ctx, item -> parent);
393 left = gcc_jit_lvalue_access_field(parent, NULL, gcc_field);
395 else if(item -> mode == MODE_DEREF)
397 gcc_jit_rvalue * parent = rvalue_from_item(ctx, item -> parent);
398 left = gcc_jit_rvalue_dereference(parent, NULL);
400 else
402 oberon_error(ctx, "invalid lvalue expression");
405 return left;
408 static gcc_jit_lvalue *
409 lvalue_from_expr(oberon_context_t *ctx, oberon_expr_t * expr)
411 gcc_jit_lvalue * left;
412 oberon_item_t * item;
414 if(expr -> is_item)
416 item = (oberon_item_t *) expr;
417 left = lvalue_from_item(ctx, item);
419 else
421 oberon_error(ctx, "invalid lvalue expression");
424 return left;
427 static gcc_jit_rvalue *
428 rvalue_from_item(oberon_context_t * ctx, oberon_item_t * item)
430 gen_context_t * gen_context = ctx -> gen_context;
431 gcc_jit_context * gcc_context = gen_context -> gcc_context;
433 gcc_jit_rvalue * right;
434 if(item -> mode == MODE_VAR)
436 gcc_jit_lvalue * left = lvalue_from_item(ctx, item);
437 right = gcc_jit_lvalue_as_rvalue(left);
439 else if(item -> mode == MODE_INTEGER)
441 gcc_jit_type * int_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_INT);
442 right = gcc_jit_context_new_rvalue_from_int(gcc_context, int_type, item -> integer);
444 else if(item -> mode == MODE_BOOLEAN)
446 gcc_jit_type * bool_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_BOOL);
447 if(item -> boolean)
449 right = gcc_jit_context_one(gcc_context, bool_type);
451 else
453 right = gcc_jit_context_zero(gcc_context, bool_type);
456 else if(item -> mode == MODE_CALL)
458 oberon_type_t * signature = item -> var -> type;
459 gen_proc_t * gen_proc = item -> var -> gen_proc;
461 int num_args = item -> num_args;
462 gcc_jit_rvalue *args[num_args];
464 oberon_expr_t * expr = item -> args;
465 oberon_object_t * arg_param = signature -> decl;
466 for(int i = 0; i < num_args; i++)
468 if(arg_param -> class == OBERON_CLASS_VAR_PARAM)
470 gcc_jit_lvalue * left = lvalue_from_expr(ctx, expr);
471 args[i] = gcc_jit_lvalue_get_address(left, NULL);
473 else
475 args[i] = rvalue_from_expr(ctx, expr);
477 expr = expr -> next;
478 arg_param = arg_param -> next;
481 gcc_jit_rvalue * fnptr;
482 gcc_jit_function * func;
483 switch(item -> var -> class)
485 case OBERON_CLASS_PROC:
486 func = gen_proc -> gcc_func;
487 right = gcc_jit_context_new_call(
488 gcc_context, NULL, func, num_args, args
489 );
490 break;
491 case OBERON_CLASS_VAR:
492 case OBERON_CLASS_VAR_PARAM:
493 case OBERON_CLASS_PARAM:
494 fnptr = gcc_jit_lvalue_as_rvalue(item -> var -> gen_var -> gcc_lvalue);
495 right = gcc_jit_context_new_call_through_ptr(
496 gcc_context, NULL, fnptr, num_args, args
497 );
498 break;
499 default:
500 assert(0);
501 break;
504 else if(item -> mode == MODE_INDEX)
506 gcc_jit_lvalue * left = lvalue_from_item(ctx, item);
507 right = gcc_jit_lvalue_as_rvalue(left);
509 else if(item -> mode == MODE_FIELD)
511 gen_var_t * gen_var = item -> var -> gen_var;
512 gcc_jit_field * gcc_field = gen_var -> gcc_field;
514 gcc_jit_rvalue * parent = rvalue_from_item(ctx, item -> parent);
515 right = gcc_jit_rvalue_access_field(parent, NULL, gcc_field);
517 else if(item -> mode == MODE_DEREF)
519 gcc_jit_lvalue * left = lvalue_from_item(ctx, item);
520 right = gcc_jit_lvalue_as_rvalue(left);
522 else if(item -> mode == MODE_NIL)
524 gcc_jit_type * type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_VOID_PTR);
525 right = gcc_jit_context_null(gcc_context, type);
527 else
529 oberon_error(ctx, "rvalue_from_item: invalid mode %i", item -> mode);
532 return right;
535 struct {
536 int type; // 0 - unary, 1 - binary, 2 - comp
537 union {
538 enum gcc_jit_unary_op unary_op;
539 enum gcc_jit_binary_op binary_op;
540 enum gcc_jit_comparison comp_op;
541 };
542 } op_table[] = {
543 { 0, .unary_op = GCC_JIT_UNARY_OP_MINUS },
544 { 0, .unary_op = GCC_JIT_UNARY_OP_BITWISE_NEGATE },
545 { 0, .unary_op = GCC_JIT_UNARY_OP_LOGICAL_NEGATE },
546 { 0, .unary_op = GCC_JIT_UNARY_OP_ABS },
548 { 1, .binary_op = GCC_JIT_BINARY_OP_PLUS },
549 { 1, .binary_op = GCC_JIT_BINARY_OP_MINUS },
550 { 1, .binary_op = GCC_JIT_BINARY_OP_MULT },
551 { 1, .binary_op = GCC_JIT_BINARY_OP_DIVIDE },
552 { 1, .binary_op = GCC_JIT_BINARY_OP_MODULO },
553 { 1, .binary_op = GCC_JIT_BINARY_OP_BITWISE_AND },
554 { 1, .binary_op = GCC_JIT_BINARY_OP_BITWISE_XOR },
555 { 1, .binary_op = GCC_JIT_BINARY_OP_BITWISE_OR },
556 { 1, .binary_op = GCC_JIT_BINARY_OP_LOGICAL_AND },
557 { 1, .binary_op = GCC_JIT_BINARY_OP_LOGICAL_OR },
559 { 2, .comp_op = GCC_JIT_COMPARISON_EQ },
560 { 2, .comp_op = GCC_JIT_COMPARISON_NE },
561 { 2, .comp_op = GCC_JIT_COMPARISON_LT },
562 { 2, .comp_op = GCC_JIT_COMPARISON_LE },
563 { 2, .comp_op = GCC_JIT_COMPARISON_GT },
564 { 2, .comp_op = GCC_JIT_COMPARISON_GE }
565 };
567 static gcc_jit_rvalue *
568 rvalue_from_operator(oberon_context_t * ctx, oberon_oper_t * operator)
570 gcc_jit_rvalue * right;
572 gen_context_t * gen_context = ctx -> gen_context;
573 gen_type_t * gen_type = operator -> result -> gen_type;
574 gcc_jit_context * gcc_context = gen_context -> gcc_context;
575 gcc_jit_type * result_type = gen_type -> gcc_type;
577 int expr_type = op_table[operator -> op].type;
578 if(expr_type == 0)
580 enum gcc_jit_unary_op op = op_table[operator -> op].unary_op;
581 gcc_jit_rvalue * l = rvalue_from_expr(ctx, operator -> left);
582 right = gcc_jit_context_new_unary_op(gcc_context, NULL, op, result_type, l);
584 else if(expr_type == 1)
586 enum gcc_jit_unary_op op = op_table[operator -> op].binary_op;
587 gcc_jit_rvalue * l = rvalue_from_expr(ctx, operator -> left);
588 gcc_jit_rvalue * r = rvalue_from_expr(ctx, operator -> right);
589 right = gcc_jit_context_new_binary_op(gcc_context, NULL, op, result_type, l, r);
591 else if(expr_type == 2)
593 enum gcc_jit_comparison op = op_table[operator -> op].comp_op;
594 gcc_jit_rvalue * l = rvalue_from_expr(ctx, operator -> left);
595 gcc_jit_rvalue * r = rvalue_from_expr(ctx, operator -> right);
596 right = gcc_jit_context_new_comparison(gcc_context, NULL, op, l, r);
598 else
600 oberon_error(ctx, "rvalue_from_operator: wat");
603 return right;
606 static gcc_jit_rvalue *
607 rvalue_from_expr(oberon_context_t * ctx, oberon_expr_t * expr)
609 gcc_jit_rvalue * right;
611 if(expr -> is_item)
613 oberon_item_t * item = (oberon_item_t *) expr;
614 right = rvalue_from_item(ctx, item);
616 else
618 oberon_oper_t * operator = (oberon_oper_t *) expr;
619 right = rvalue_from_operator(ctx, operator);
622 return right;
625 void
626 oberon_generate_assign(oberon_context_t * ctx, oberon_expr_t * src, oberon_expr_t * dst)
628 gcc_jit_lvalue * left;
629 left = lvalue_from_expr(ctx, dst);
631 gcc_jit_rvalue * right;
632 right = rvalue_from_expr(ctx, src);
634 if(src -> is_item)
636 if(src -> item.mode == MODE_NIL)
638 gen_context_t * gen_context = ctx -> gen_context;
639 gcc_jit_context * gcc_context = gen_context -> gcc_context;
640 gen_type_t * gen_type = dst -> result -> gen_type;
641 gcc_jit_type * cast_to_type = gen_type -> gcc_type;
642 right = gcc_jit_context_new_cast(gcc_context, NULL, right, cast_to_type);
646 printf("oberon_generate_assign: class %i := class %i\n", dst -> result -> class, src -> result -> class);
648 gen_context_t * gen_context = ctx -> gen_context;
649 gen_block_t * gen_block = gen_context -> block;
650 gcc_jit_block * gcc_block = gen_block -> gcc_block;
651 gcc_jit_block_add_assignment(gcc_block, NULL, left, right);
654 void
655 oberon_generate_code(oberon_context_t * ctx)
657 gen_context_t * gen_context = ctx -> gen_context;
658 gcc_jit_context * gcc_context = gen_context -> gcc_context;
660 gcc_jit_result * gcc_result;
661 gcc_result = gcc_jit_context_compile(gcc_context);
663 gen_context -> gcc_result = gcc_result;
664 ctx -> mod -> begin = gcc_jit_result_get_code(gcc_result, "BEGIN");
667 void
668 oberon_generator_dump(oberon_context_t * ctx, char * path)
670 gen_context_t * gen_context = ctx -> gen_context;
671 gcc_jit_context * gcc_context = gen_context -> gcc_context;
672 gcc_jit_context_dump_to_file(gcc_context, path, 0);
675 void *
676 oberon_generator_get_procedure(oberon_context_t * ctx, const char * name)
678 gen_context_t * gen_context = ctx -> gen_context;
679 gcc_jit_result * gcc_result = gen_context -> gcc_result;
681 return gcc_jit_result_get_code(gcc_result, name);
684 void *
685 oberon_generator_get_var(oberon_context_t * ctx, const char * name)
687 gen_context_t * gen_context = ctx -> gen_context;
688 gcc_jit_result * gcc_result = gen_context -> gcc_result;
690 return gcc_jit_result_get_global(gcc_result, name);