diff --git a/generator.c b/generator.c
index b17a8cd977cf450733a38fe9510b01db8754bd6f..05873d1303fa9bb214a3add0bf3374a3b408196d 100644 (file)
--- a/generator.c
+++ b/generator.c
if(item -> mode == MODE_VAR)
{
if(item -> mode == MODE_VAR)
{
+ if(item -> var -> class == OBERON_CLASS_PROC)
+ {
+ oberon_error(ctx, "casting static procedure to pointer not supported by generator");
+ }
+
gen_var_t * gen_var = item -> var -> gen_var;
left = gen_var -> gcc_lvalue;
if(item -> var -> class == OBERON_CLASS_VAR_PARAM)
gen_var_t * gen_var = item -> var -> gen_var;
left = gen_var -> gcc_lvalue;
if(item -> var -> class == OBERON_CLASS_VAR_PARAM)
}
else if(item -> mode == MODE_CALL)
{
}
else if(item -> mode == MODE_CALL)
{
- assert(item -> var -> class == OBERON_CLASS_PROC);
-
oberon_type_t * signature = item -> var -> type;
gen_proc_t * gen_proc = item -> var -> gen_proc;
oberon_type_t * signature = item -> var -> type;
gen_proc_t * gen_proc = item -> var -> gen_proc;
arg_param = arg_param -> next;
}
arg_param = arg_param -> next;
}
- gcc_jit_function * func = gen_proc -> gcc_func;
- right = gcc_jit_context_new_call(
- gcc_context, NULL, func, num_args, args
- );
+ gcc_jit_rvalue * fnptr;
+ gcc_jit_function * func;
+ switch(item -> var -> class)
+ {
+ case OBERON_CLASS_PROC:
+ func = gen_proc -> gcc_func;
+ right = gcc_jit_context_new_call(
+ gcc_context, NULL, func, num_args, args
+ );
+ break;
+ case OBERON_CLASS_VAR:
+ case OBERON_CLASS_VAR_PARAM:
+ case OBERON_CLASS_PARAM:
+ fnptr = gcc_jit_lvalue_as_rvalue(item -> var -> gen_var -> gcc_lvalue);
+ right = gcc_jit_context_new_call_through_ptr(
+ gcc_context, NULL, fnptr, num_args, args
+ );
+ break;
+ default:
+ assert(0);
+ break;
+ }
}
else if(item -> mode == MODE_INDEX)
{
}
else if(item -> mode == MODE_INDEX)
{
enum gcc_jit_comparison comp_op;
};
} op_table[] = {
enum gcc_jit_comparison comp_op;
};
} op_table[] = {
- { 0, .unary_op = GCC_JIT_UNARY_OP_LOGICAL_NEGATE },
{ 0, .unary_op = GCC_JIT_UNARY_OP_MINUS },
{ 0, .unary_op = GCC_JIT_UNARY_OP_MINUS },
+ { 0, .unary_op = GCC_JIT_UNARY_OP_BITWISE_NEGATE },
+ { 0, .unary_op = GCC_JIT_UNARY_OP_LOGICAL_NEGATE },
+ { 0, .unary_op = GCC_JIT_UNARY_OP_ABS },
{ 1, .binary_op = GCC_JIT_BINARY_OP_PLUS },
{ 1, .binary_op = GCC_JIT_BINARY_OP_MINUS },
{ 1, .binary_op = GCC_JIT_BINARY_OP_MULT },
{ 1, .binary_op = GCC_JIT_BINARY_OP_DIVIDE },
{ 1, .binary_op = GCC_JIT_BINARY_OP_MODULO },
{ 1, .binary_op = GCC_JIT_BINARY_OP_PLUS },
{ 1, .binary_op = GCC_JIT_BINARY_OP_MINUS },
{ 1, .binary_op = GCC_JIT_BINARY_OP_MULT },
{ 1, .binary_op = GCC_JIT_BINARY_OP_DIVIDE },
{ 1, .binary_op = GCC_JIT_BINARY_OP_MODULO },
+ { 1, .binary_op = GCC_JIT_BINARY_OP_BITWISE_AND },
+ { 1, .binary_op = GCC_JIT_BINARY_OP_BITWISE_XOR },
+ { 1, .binary_op = GCC_JIT_BINARY_OP_BITWISE_OR },
{ 1, .binary_op = GCC_JIT_BINARY_OP_LOGICAL_AND },
{ 1, .binary_op = GCC_JIT_BINARY_OP_LOGICAL_OR },
{ 1, .binary_op = GCC_JIT_BINARY_OP_LOGICAL_AND },
{ 1, .binary_op = GCC_JIT_BINARY_OP_LOGICAL_OR },
@@ -617,6 +643,8 @@ oberon_generate_assign(oberon_context_t * ctx, oberon_expr_t * src, oberon_expr_
}
}
}
}
+ printf("oberon_generate_assign: class %i := class %i\n", dst -> result -> class, src -> result -> class);
+
gen_context_t * gen_context = ctx -> gen_context;
gen_block_t * gen_block = gen_context -> block;
gcc_jit_block * gcc_block = gen_block -> gcc_block;
gen_context_t * gen_context = ctx -> gen_context;
gen_block_t * gen_block = gen_context -> block;
gcc_jit_block * gcc_block = gen_block -> gcc_block;
gcc_jit_context * gcc_context = gen_context -> gcc_context;
gcc_jit_context_dump_to_file(gcc_context, path, 0);
}
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);
+}