X-Git-Url: http://deadsoftware.ru/gitweb?p=dsw-obn.git;a=blobdiff_plain;f=generator.c;h=f65b066d1fab3fe1f26df2430f6869126ee98390;hp=e4970fd995b0e5af87d12cb93f5c6d36bfe24359;hb=8520fd72cf3c1daeabbb8da91290dae85fc39c91;hpb=342c8f1a44765e744c64e14a3b8f1aa4031c5f62 diff --git a/generator.c b/generator.c index e4970fd..f65b066 100644 --- a/generator.c +++ b/generator.c @@ -79,25 +79,6 @@ oberon_generator_init_type(oberon_context_t * ctx, oberon_type_t * type) { gcc_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_BOOL); } - else if(type -> class == OBERON_TYPE_PROCEDURE) - { - int num_params = type -> num_decl; - gcc_jit_type * params[num_params]; - oberon_object_t * o = type -> decl; - for(int i = 0; i < num_params; i++) - { - gen_type_t * gen_type = o -> type -> gen_type; - params[i] = gen_type -> gcc_type; - o = o -> next; - } - - gen_type_t * base = type -> base -> gen_type; - gcc_jit_type * result_type = base -> gcc_type; - - gcc_type = gcc_jit_context_new_function_ptr_type( - gcc_context, NULL, result_type, num_params, params, 0 - ); - } else if(type -> class == OBERON_TYPE_ARRAY) { if(type -> dim != 1) @@ -128,11 +109,37 @@ oberon_generator_init_type(oberon_context_t * ctx, oberon_type_t * type) gcc_struct = gcc_jit_context_new_struct_type(gcc_context, NULL, "", num_fields, fields); gcc_type = gcc_jit_struct_as_type(gcc_struct); } + else if(type -> class == OBERON_TYPE_POINTER) + { + gen_type_t * gen_base = type -> base -> gen_type; + gcc_jit_type * gcc_base = gen_base -> gcc_type; + gcc_type = gcc_jit_type_get_pointer(gcc_base); + } + else if(type -> class == OBERON_TYPE_PROCEDURE) + { + int num_params = type -> num_decl; + gcc_jit_type * params[num_params]; + oberon_object_t * o = type -> decl; + for(int i = 0; i < num_params; i++) + { + gen_type_t * gen_type = o -> type -> gen_type; + params[i] = gen_type -> gcc_type; + o = o -> next; + } + + gen_type_t * base = type -> base -> gen_type; + gcc_jit_type * result_type = base -> gcc_type; + + gcc_type = gcc_jit_context_new_function_ptr_type( + gcc_context, NULL, result_type, num_params, params, 0 + ); + } else { oberon_error(ctx, "oberon_generator_init_type: invalid type class %i", type -> class); } + assert(gcc_type); gen_type -> gcc_type = gcc_type; gen_type -> gcc_struct = gcc_struct; }