summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d3438ae)
raw | patch | inline | side by side (parent: d3438ae)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 24 Jul 2017 19:47:00 +0000 (22:47 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 24 Jul 2017 19:47:00 +0000 (22:47 +0300) |
generator.c | patch | blob | history | |
generator.h | patch | blob | history | |
oberon.c | patch | blob | history | |
oberon.h | patch | blob | history | |
test.c | patch | blob | history |
diff --git a/generator.c b/generator.c
index 244296228ae3335b5de1b12047c3d90a8c7777b3..05873d1303fa9bb214a3add0bf3374a3b408196d 100644 (file)
--- a/generator.c
+++ b/generator.c
gcc_jit_context * gcc_context = gen_context -> gcc_context;
gcc_jit_context_dump_to_file(gcc_context, path, 0);
}
+
+void *
+oberon_generator_get_procedure(oberon_context_t * ctx, const char * name)
+{
+ gen_context_t * gen_context = ctx -> gen_context;
+ gcc_jit_result * gcc_result = gen_context -> gcc_result;
+
+ return gcc_jit_result_get_code(gcc_result, name);
+}
+
+void *
+oberon_generator_get_var(oberon_context_t * ctx, const char * name)
+{
+ gen_context_t * gen_context = ctx -> gen_context;
+ gcc_jit_result * gcc_result = gen_context -> gcc_result;
+
+ return gcc_jit_result_get_global(gcc_result, name);
+}
diff --git a/generator.h b/generator.h
index 085c2cacd37f49aee8a6cc2fbe12f77d08722c12..08df5c892abb414e4f376e6829a697554a5b6398 100644 (file)
--- a/generator.h
+++ b/generator.h
void oberon_generate_code(oberon_context_t * ctx);
void oberon_generator_dump(oberon_context_t * ctx, char * path);
-
+void * oberon_generator_get_procedure(oberon_context_t * ctx, const char * name);
+void * oberon_generator_get_var(oberon_context_t * ctx, const char * name);
diff --git a/oberon.c b/oberon.c
index b0bb6aa6fa3ba13a60fe7f956fc8dc820d683501..28a351a6fdbfd4e315d4b2959b40a3b440a85f1e 100644 (file)
--- a/oberon.c
+++ b/oberon.c
}
static void
-oberon_new_intrinsic_function(oberon_context_t * ctx, char * name, GenerateFuncCallback generate)
+oberon_new_intrinsic(oberon_context_t * ctx, char * name, GenerateFuncCallback f, GenerateProcCallback p)
{
oberon_object_t * proc;
proc = oberon_define_object(ctx -> decl, name, OBERON_CLASS_PROC);
proc -> sysproc = 1;
- proc -> genfunc = generate;
+ proc -> genfunc = f;
+ proc -> genproc = p;
proc -> type = oberon_new_type_ptr(OBERON_TYPE_PROCEDURE);
}
-/*
-static void
-oberon_new_intrinsic_procedure(oberon_context_t * ctx, char * name, GenerateProcCallback generate)
-{
- oberon_object_t * proc;
- proc = oberon_define_object(ctx -> decl, name, OBERON_CLASS_PROC);
- proc -> sysproc = 1;
- proc -> genproc = generate;
- proc -> type = oberon_new_type_ptr(OBERON_TYPE_PROCEDURE);
-}
-*/
-
static oberon_expr_t *
oberon_make_abs_call(oberon_context_t * ctx, int num_args, oberon_expr_t * list_args)
{
oberon_generator_init_context(ctx);
register_default_types(ctx);
- oberon_new_intrinsic_function(ctx, "ABS", oberon_make_abs_call);
+ oberon_new_intrinsic(ctx, "ABS", oberon_make_abs_call, NULL);
return ctx;
}
diff --git a/oberon.h b/oberon.h
index 09a24c98caeaa08f59b50e8b562035b261acd9d7..d481e130b6e89c06e8b3227cc882e2be2339ecbc 100644 (file)
--- a/oberon.h
+++ b/oberon.h
struct gen_proc_s
{
- gcc_jit_function * gcc_func;
+ gcc_jit_function * gcc_func;
};
struct gen_type_s
{
- gcc_jit_type * gcc_type;
- gcc_jit_struct * gcc_struct;
+ gcc_jit_type * gcc_type;
+ gcc_jit_struct * gcc_struct;
};
struct gen_var_s
{
- gcc_jit_lvalue * gcc_lvalue;
- gcc_jit_param * gcc_param;
- gcc_jit_field * gcc_field;
+ gcc_jit_lvalue * gcc_lvalue;
+ gcc_jit_param * gcc_param;
+ gcc_jit_field * gcc_field;
};
struct gen_block_s
{
- gcc_jit_block * gcc_block;
+ gcc_jit_block * gcc_block;
gen_block_t * up;
};
struct gen_context_s
{
- gcc_jit_context * gcc_context;
- gcc_jit_result * gcc_result;
+ gcc_jit_context * gcc_context;
+ gcc_jit_result * gcc_result;
gen_block_t * block;
unsigned record_count;
};