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 * o)
158 if(!o)
160 name[0] = 0;
161 return;
164 char parent[256];
165 oberon_generator_get_full_name(parent, 256, o -> parent);
167 char * xname;
168 // if(o -> class == OBERON_CLASS_MODULE)
169 // {
170 // xname = o -> module -> name;
171 // }
172 // else
173 // {
174 xname = o -> name;
175 // }
177 if(strlen(parent) > 0)
179 snprintf(name, max_len, "%s_%s", parent, xname);
181 else
183 snprintf(name, max_len, "%s", xname);
187 void
188 oberon_generator_init_var(oberon_context_t * ctx, oberon_object_t * var)
190 gen_context_t * gen_context = ctx -> gen_context;
191 gen_type_t * gen_type = var -> type -> gen_type;
193 gen_var_t * gen_var = malloc(sizeof *gen_var);
194 memset(gen_var, 0, sizeof *gen_var);
195 var -> gen_var = gen_var;
197 gcc_jit_context * gcc_context = gen_context -> gcc_context;
198 gcc_jit_type * gcc_type = gen_type -> gcc_type;
200 char name[256];
201 oberon_generator_get_full_name(name, 256, var);
203 gcc_jit_lvalue * gcc_lvalue = NULL;
204 gcc_jit_param * gcc_param = NULL;
205 gcc_jit_field * gcc_field = NULL;
206 if(var -> class == OBERON_CLASS_VAR)
208 if(var -> local)
210 gen_proc_t * gen_func = var -> parent -> gen_proc;
211 gcc_jit_function * func = gen_func -> gcc_func;
213 gcc_lvalue = gcc_jit_function_new_local(func, NULL, gcc_type, name);
215 else
217 gcc_lvalue = gcc_jit_context_new_global(
218 gcc_context, NULL, GCC_JIT_GLOBAL_INTERNAL, gcc_type, name
219 );
222 else if(var -> class == OBERON_CLASS_PARAM)
224 gcc_param = gcc_jit_context_new_param(gcc_context, NULL, gcc_type, name);
225 gcc_lvalue = gcc_jit_param_as_lvalue(gcc_param);
227 else if(var -> class == OBERON_CLASS_VAR_PARAM)
229 gcc_type = gcc_jit_type_get_pointer(gcc_type);
230 gcc_param = gcc_jit_context_new_param(gcc_context, NULL, gcc_type, name);
231 gcc_lvalue = gcc_jit_param_as_lvalue(gcc_param);
233 else if(var -> class == OBERON_CLASS_FIELD)
235 gcc_field = gcc_jit_context_new_field(gcc_context, NULL, gcc_type, name);
237 else
239 oberon_error(ctx, "oberon_generator_init_var: invalid class %i", var -> class);
242 gen_var -> gcc_lvalue = gcc_lvalue;
243 gen_var -> gcc_param = gcc_param;
244 gen_var -> gcc_field = gcc_field;
247 void
248 oberon_generator_init_proc(oberon_context_t * ctx, oberon_object_t * proc)
250 if(proc -> local)
252 oberon_error(ctx, "generator: local procedures not supported");
255 gen_context_t * gen_context = ctx -> gen_context;
256 gcc_jit_context * gcc_context = gen_context -> gcc_context;
258 gen_proc_t * gen_proc = malloc(sizeof *gen_proc);
259 memset(gen_proc, 0, sizeof *gen_proc);
260 proc -> gen_proc = gen_proc;
262 char name[256];
263 oberon_generator_get_full_name(name, 256, proc);
265 gen_type_t * gen_result_type = proc -> type -> base -> gen_type;
266 gcc_jit_type * result_type = gen_result_type -> gcc_type;
268 /* Строим список параметров */
269 int num_param = proc -> type -> num_decl;
270 oberon_object_t * o = proc -> type -> decl;
271 gcc_jit_param * params[num_param];
272 for(int i = 0; i < num_param; i++)
274 gen_var_t * param_var = o -> gen_var;
275 params[i] = param_var -> gcc_param;
276 o = o -> next;
279 gcc_jit_function * gcc_func;
280 gcc_func = gcc_jit_context_new_function(
281 gcc_context, NULL, GCC_JIT_FUNCTION_EXPORTED, result_type, name, num_param, params, 0
282 );
284 gen_proc -> gcc_func = gcc_func;
287 // =======================================================================
288 // GENERATOR
289 // =======================================================================
291 static gcc_jit_rvalue * rvalue_from_item(oberon_context_t * ctx, oberon_item_t * item);
292 static gcc_jit_rvalue * rvalue_from_expr(oberon_context_t * ctx, oberon_expr_t * expr);
294 void
295 oberon_generate_begin_module(oberon_context_t * ctx)
297 gen_context_t * gen_context = ctx -> gen_context;
298 gcc_jit_context * gcc_context = gen_context -> gcc_context;
300 char name[256];
301 snprintf(name, 256, "%s_BEGIN", ctx -> mod -> name);
303 gcc_jit_type * void_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_VOID);
304 gcc_jit_function * func = gcc_jit_context_new_function(
305 gcc_context, NULL, GCC_JIT_FUNCTION_EXPORTED, void_type, name, 0, NULL, 0
306 );
307 gcc_jit_block * gcc_block = gcc_jit_function_new_block(func, NULL);
309 oberon_generator_open_block(gen_context, gcc_block);
312 void
313 oberon_generate_end_module(oberon_context_t * ctx)
315 gen_context_t * gen_context = ctx -> gen_context;
316 gcc_jit_block * gcc_block = gen_context -> block -> gcc_block;
318 gcc_jit_block_end_with_void_return(gcc_block, NULL);
320 oberon_generator_close_block(gen_context);
323 void
324 oberon_generate_begin_proc(oberon_context_t * ctx, oberon_object_t * proc)
326 gen_context_t * gen_context = ctx -> gen_context;
327 gen_proc_t * gen_proc = proc -> gen_proc;
329 gcc_jit_function * func = gen_proc -> gcc_func;
330 gcc_jit_block * gcc_block = gcc_jit_function_new_block(func, NULL);
332 oberon_generator_open_block(gen_context, gcc_block);
335 void
336 oberon_generate_call_proc(oberon_context_t * ctx, oberon_expr_t * desig)
338 gen_context_t * gen_context = ctx -> gen_context;
339 gen_block_t * gen_block = gen_context -> block;
340 gcc_jit_block * block = gen_block -> gcc_block;
342 gcc_jit_rvalue * return_value;
343 return_value = rvalue_from_expr(ctx, desig);
344 gcc_jit_block_add_eval(block, NULL, return_value);
347 void
348 oberon_generate_end_proc(oberon_context_t * ctx)
350 gen_context_t * gen_context = ctx -> gen_context;
351 oberon_generator_close_block(gen_context);
354 void
355 oberon_generate_return(oberon_context_t * ctx, oberon_expr_t * expr)
357 gen_context_t * gen_context = ctx -> gen_context;
358 gen_block_t * gen_block = gen_context -> block;
359 gcc_jit_block * gcc_block = gen_block -> gcc_block;
361 if(expr == NULL)
363 gcc_jit_block_end_with_void_return(gcc_block, NULL);
365 else
367 gcc_jit_rvalue * r = rvalue_from_expr(ctx, expr);
368 gcc_jit_block_end_with_return(gcc_block, NULL, r);
372 static gcc_jit_lvalue *
373 lvalue_from_item(oberon_context_t * ctx, oberon_item_t * item)
375 gen_context_t * gen_context = ctx -> gen_context;
376 gcc_jit_context * gcc_context = gen_context -> gcc_context;
378 gcc_jit_lvalue * left;
380 if(item -> mode == MODE_VAR)
382 if(item -> var -> class == OBERON_CLASS_PROC)
384 oberon_error(ctx, "casting static procedure to pointer not supported by generator");
387 gen_var_t * gen_var = item -> var -> gen_var;
388 left = gen_var -> gcc_lvalue;
389 if(item -> var -> class == OBERON_CLASS_VAR_PARAM)
391 gcc_jit_rvalue * r = gcc_jit_lvalue_as_rvalue(left);
392 left = gcc_jit_rvalue_dereference(r, NULL);
395 else if(item -> mode == MODE_INDEX)
397 assert(item -> num_args == 1);
398 gcc_jit_rvalue * parent = rvalue_from_item(ctx, item -> parent);
399 gcc_jit_rvalue * index = rvalue_from_expr(ctx, item -> args);
400 left = gcc_jit_context_new_array_access(gcc_context, NULL, parent, index);
402 else if(item -> mode == MODE_FIELD)
404 printf("lvalue_from_item: %s\n", item -> var -> name);
405 gen_var_t * gen_var = item -> var -> gen_var;
406 gcc_jit_field * gcc_field = gen_var -> gcc_field;
408 gcc_jit_lvalue * parent = lvalue_from_item(ctx, item -> parent);
409 left = gcc_jit_lvalue_access_field(parent, NULL, gcc_field);
411 else if(item -> mode == MODE_DEREF)
413 gcc_jit_rvalue * parent = rvalue_from_item(ctx, item -> parent);
414 left = gcc_jit_rvalue_dereference(parent, NULL);
416 else
418 oberon_error(ctx, "invalid lvalue expression");
421 return left;
424 static gcc_jit_lvalue *
425 lvalue_from_expr(oberon_context_t *ctx, oberon_expr_t * expr)
427 gcc_jit_lvalue * left;
428 oberon_item_t * item;
430 if(expr -> is_item)
432 item = (oberon_item_t *) expr;
433 left = lvalue_from_item(ctx, item);
435 else
437 oberon_error(ctx, "invalid lvalue expression");
440 return left;
443 static gcc_jit_rvalue *
444 rvalue_from_item(oberon_context_t * ctx, oberon_item_t * item)
446 gen_context_t * gen_context = ctx -> gen_context;
447 gcc_jit_context * gcc_context = gen_context -> gcc_context;
449 gcc_jit_rvalue * right;
450 if(item -> mode == MODE_VAR)
452 gcc_jit_lvalue * left = lvalue_from_item(ctx, item);
453 right = gcc_jit_lvalue_as_rvalue(left);
455 else if(item -> mode == MODE_INTEGER)
457 gcc_jit_type * int_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_INT);
458 right = gcc_jit_context_new_rvalue_from_int(gcc_context, int_type, item -> integer);
460 else if(item -> mode == MODE_BOOLEAN)
462 gcc_jit_type * bool_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_BOOL);
463 if(item -> boolean)
465 right = gcc_jit_context_one(gcc_context, bool_type);
467 else
469 right = gcc_jit_context_zero(gcc_context, bool_type);
472 else if(item -> mode == MODE_CALL)
474 oberon_type_t * signature = item -> var -> type;
475 gen_proc_t * gen_proc = item -> var -> gen_proc;
477 int num_args = item -> num_args;
478 gcc_jit_rvalue *args[num_args];
480 oberon_expr_t * expr = item -> args;
481 oberon_object_t * arg_param = signature -> decl;
482 for(int i = 0; i < num_args; i++)
484 if(arg_param -> class == OBERON_CLASS_VAR_PARAM)
486 gcc_jit_lvalue * left = lvalue_from_expr(ctx, expr);
487 args[i] = gcc_jit_lvalue_get_address(left, NULL);
489 else
491 args[i] = rvalue_from_expr(ctx, expr);
493 expr = expr -> next;
494 arg_param = arg_param -> next;
497 gcc_jit_rvalue * fnptr;
498 gcc_jit_function * func;
499 switch(item -> var -> class)
501 case OBERON_CLASS_PROC:
502 func = gen_proc -> gcc_func;
503 right = gcc_jit_context_new_call(
504 gcc_context, NULL, func, num_args, args
505 );
506 break;
507 case OBERON_CLASS_VAR:
508 case OBERON_CLASS_VAR_PARAM:
509 case OBERON_CLASS_PARAM:
510 fnptr = gcc_jit_lvalue_as_rvalue(item -> var -> gen_var -> gcc_lvalue);
511 right = gcc_jit_context_new_call_through_ptr(
512 gcc_context, NULL, fnptr, num_args, args
513 );
514 break;
515 default:
516 assert(0);
517 break;
520 else if(item -> mode == MODE_INDEX)
522 gcc_jit_lvalue * left = lvalue_from_item(ctx, item);
523 right = gcc_jit_lvalue_as_rvalue(left);
525 else if(item -> mode == MODE_FIELD)
527 gen_var_t * gen_var = item -> var -> gen_var;
528 gcc_jit_field * gcc_field = gen_var -> gcc_field;
530 gcc_jit_rvalue * parent = rvalue_from_item(ctx, item -> parent);
531 right = gcc_jit_rvalue_access_field(parent, NULL, gcc_field);
533 else if(item -> mode == MODE_DEREF)
535 gcc_jit_lvalue * left = lvalue_from_item(ctx, item);
536 right = gcc_jit_lvalue_as_rvalue(left);
538 else if(item -> mode == MODE_NIL)
540 gcc_jit_type * type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_VOID_PTR);
541 right = gcc_jit_context_null(gcc_context, type);
543 else
545 oberon_error(ctx, "rvalue_from_item: invalid mode %i", item -> mode);
548 return right;
551 struct {
552 int type; // 0 - unary, 1 - binary, 2 - comp
553 union {
554 enum gcc_jit_unary_op unary_op;
555 enum gcc_jit_binary_op binary_op;
556 enum gcc_jit_comparison comp_op;
557 };
558 } op_table[] = {
559 { 0, .unary_op = GCC_JIT_UNARY_OP_MINUS },
560 { 0, .unary_op = GCC_JIT_UNARY_OP_BITWISE_NEGATE },
561 { 0, .unary_op = GCC_JIT_UNARY_OP_LOGICAL_NEGATE },
562 { 0, .unary_op = GCC_JIT_UNARY_OP_ABS },
564 { 1, .binary_op = GCC_JIT_BINARY_OP_PLUS },
565 { 1, .binary_op = GCC_JIT_BINARY_OP_MINUS },
566 { 1, .binary_op = GCC_JIT_BINARY_OP_MULT },
567 { 1, .binary_op = GCC_JIT_BINARY_OP_DIVIDE },
568 { 1, .binary_op = GCC_JIT_BINARY_OP_MODULO },
569 { 1, .binary_op = GCC_JIT_BINARY_OP_BITWISE_AND },
570 { 1, .binary_op = GCC_JIT_BINARY_OP_BITWISE_XOR },
571 { 1, .binary_op = GCC_JIT_BINARY_OP_BITWISE_OR },
572 { 1, .binary_op = GCC_JIT_BINARY_OP_LOGICAL_AND },
573 { 1, .binary_op = GCC_JIT_BINARY_OP_LOGICAL_OR },
575 { 2, .comp_op = GCC_JIT_COMPARISON_EQ },
576 { 2, .comp_op = GCC_JIT_COMPARISON_NE },
577 { 2, .comp_op = GCC_JIT_COMPARISON_LT },
578 { 2, .comp_op = GCC_JIT_COMPARISON_LE },
579 { 2, .comp_op = GCC_JIT_COMPARISON_GT },
580 { 2, .comp_op = GCC_JIT_COMPARISON_GE }
581 };
583 static gcc_jit_rvalue *
584 rvalue_from_operator(oberon_context_t * ctx, oberon_oper_t * operator)
586 gcc_jit_rvalue * right;
588 gen_context_t * gen_context = ctx -> gen_context;
589 gen_type_t * gen_type = operator -> result -> gen_type;
590 gcc_jit_context * gcc_context = gen_context -> gcc_context;
591 gcc_jit_type * result_type = gen_type -> gcc_type;
593 int expr_type = op_table[operator -> op].type;
594 if(expr_type == 0)
596 enum gcc_jit_unary_op op = op_table[operator -> op].unary_op;
597 gcc_jit_rvalue * l = rvalue_from_expr(ctx, operator -> left);
598 right = gcc_jit_context_new_unary_op(gcc_context, NULL, op, result_type, l);
600 else if(expr_type == 1)
602 enum gcc_jit_unary_op op = op_table[operator -> op].binary_op;
603 gcc_jit_rvalue * l = rvalue_from_expr(ctx, operator -> left);
604 gcc_jit_rvalue * r = rvalue_from_expr(ctx, operator -> right);
605 right = gcc_jit_context_new_binary_op(gcc_context, NULL, op, result_type, l, r);
607 else if(expr_type == 2)
609 enum gcc_jit_comparison op = op_table[operator -> op].comp_op;
610 gcc_jit_rvalue * l = rvalue_from_expr(ctx, operator -> left);
611 gcc_jit_rvalue * r = rvalue_from_expr(ctx, operator -> right);
612 right = gcc_jit_context_new_comparison(gcc_context, NULL, op, l, r);
614 else
616 oberon_error(ctx, "rvalue_from_operator: wat");
619 return right;
622 static gcc_jit_rvalue *
623 rvalue_from_expr(oberon_context_t * ctx, oberon_expr_t * expr)
625 gcc_jit_rvalue * right;
627 if(expr -> is_item)
629 oberon_item_t * item = (oberon_item_t *) expr;
630 right = rvalue_from_item(ctx, item);
632 else
634 oberon_oper_t * operator = (oberon_oper_t *) expr;
635 right = rvalue_from_operator(ctx, operator);
638 return right;
641 void
642 oberon_generate_assign(oberon_context_t * ctx, oberon_expr_t * src, oberon_expr_t * dst)
644 gcc_jit_lvalue * left;
645 left = lvalue_from_expr(ctx, dst);
647 gcc_jit_rvalue * right;
648 right = rvalue_from_expr(ctx, src);
650 if(src -> is_item)
652 if(src -> item.mode == MODE_NIL)
654 gen_context_t * gen_context = ctx -> gen_context;
655 gcc_jit_context * gcc_context = gen_context -> gcc_context;
656 gen_type_t * gen_type = dst -> result -> gen_type;
657 gcc_jit_type * cast_to_type = gen_type -> gcc_type;
658 right = gcc_jit_context_new_cast(gcc_context, NULL, right, cast_to_type);
662 printf("oberon_generate_assign: class %i := class %i\n", dst -> result -> class, src -> result -> class);
664 gen_context_t * gen_context = ctx -> gen_context;
665 gen_block_t * gen_block = gen_context -> block;
666 gcc_jit_block * gcc_block = gen_block -> gcc_block;
667 gcc_jit_block_add_assignment(gcc_block, NULL, left, right);
670 void
671 oberon_generate_code(oberon_context_t * ctx)
673 gen_context_t * gen_context = ctx -> gen_context;
674 gcc_jit_context * gcc_context = gen_context -> gcc_context;
676 gcc_jit_result * gcc_result;
677 gcc_result = gcc_jit_context_compile(gcc_context);
679 gen_context -> gcc_result = gcc_result;
681 // ctx -> mod -> begin = gcc_jit_result_get_code(gcc_result, "BEGIN");
684 void
685 oberon_generator_dump(oberon_context_t * ctx, char * path)
687 gen_context_t * gen_context = ctx -> gen_context;
688 gcc_jit_context * gcc_context = gen_context -> gcc_context;
689 gcc_jit_context_dump_to_file(gcc_context, path, 0);
692 void *
693 oberon_generator_get_procedure(oberon_context_t * ctx, const char * name)
695 gen_context_t * gen_context = ctx -> gen_context;
696 gcc_jit_result * gcc_result = gen_context -> gcc_result;
698 return gcc_jit_result_get_code(gcc_result, name);
701 void *
702 oberon_generator_get_var(oberon_context_t * ctx, const char * name)
704 gen_context_t * gen_context = ctx -> gen_context;
705 gcc_jit_result * gcc_result = gen_context -> gcc_result;
707 return gcc_jit_result_get_global(gcc_result, name);