DEADSOFTWARE

Реализованы неявные объявления типов наперёд
[dsw-obn.git] / generator.c
index f65b066d1fab3fe1f26df2430f6869126ee98390..a802a96f4e071c64496e5df09f6d28cbfad24a58 100644 (file)
@@ -93,20 +93,7 @@ oberon_generator_init_type(oberon_context_t * ctx, oberon_type_t * type)
        }
        else if(type -> class == OBERON_TYPE_RECORD)
        {
-               // TODO type exstension
-
-               int num_fields = type -> num_decl;
-               gcc_jit_field * fields[num_fields];
-               oberon_object_t * o = type -> decl;
-               for(int i = 0; i < num_fields; i++)
-               {
-                       assert(o -> class == OBERON_CLASS_FIELD);
-                       gen_var_t * var = o -> gen_var;
-                       fields[i] = var -> gcc_field;
-                       o = o -> next;
-               }
-
-               gcc_struct = gcc_jit_context_new_struct_type(gcc_context, NULL, "", num_fields, fields);
+               gcc_struct = gcc_jit_context_new_opaque_struct(gcc_context, NULL, "");
                gcc_type = gcc_jit_struct_as_type(gcc_struct);
        }
        else if(type -> class == OBERON_TYPE_POINTER)
@@ -144,6 +131,32 @@ oberon_generator_init_type(oberon_context_t * ctx, oberon_type_t * type)
        gen_type -> gcc_struct = gcc_struct;
 }
 
+void
+oberon_generator_init_record(oberon_context_t * ctx, oberon_type_t * type)
+{
+       assert(type -> class == OBERON_TYPE_RECORD);
+
+       gen_type_t * gen_type = type -> gen_type;
+       gcc_jit_struct * gcc_struct = gen_type -> gcc_struct;
+
+       // TODO type exstension
+
+       int num_fields = type -> num_decl;
+       gcc_jit_field * fields[num_fields];
+       oberon_object_t * o = type -> decl;
+       for(int i = 0; i < num_fields; i++)
+       {
+               assert(o -> class == OBERON_CLASS_FIELD);
+               gen_var_t * var = o -> gen_var;
+               fields[i] = var -> gcc_field;
+               o = o -> next;
+       }
+
+       gcc_jit_struct_set_fields (gcc_struct, NULL, num_fields, fields);
+
+       //gcc_struct = gcc_jit_context_new_struct_type(gcc_context, NULL, "", num_fields, fields);
+}
+
 void
 oberon_generator_init_var(oberon_context_t * ctx, oberon_object_t * var)
 {