{
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)
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;
}
-- нету автокаста в присвоении и передачи параметров
-- нету локальных объявлений в процедурах
-- нету свёртки констант
-- нету не работает присваивание к переменным-процедурам.
-- нету указателей
-- нету расширения типа
-- нету var-параметров в генераторе
+- нету процедуры NEW
+- не реализовано расширение типа record
+- не реализовано преждевременное объявление типа
+- не реализованы многомерные массивы
+
+- не реализованы локальные объявления в процедурах
+- не работает присваивание к переменным-процедурам.
+- не понятен результат присваивания статических структур (* reca := recb; *)
+- не реализованы var-параметры в генераторе
+- не реализованы процедуры "наперёд"
+
+- не реализована свёртка констант
+- не реализован автокаст (libgccjit сам разруливает)
+- не протестированы типы разнных размеров
OF,
LBRACE,
RBRACE,
- RECORD
+ RECORD,
+ POINTER,
+ TO
};
// =======================================================================
{
ctx -> token = RECORD;
}
+ else if(strcmp(ident, "POINTER") == 0)
+ {
+ ctx -> token = POINTER;
+ }
+ else if(strcmp(ident, "TO") == 0)
+ {
+ ctx -> token = TO;
+ }
}
static void
}
}
+static oberon_type_t *
+oberon_make_pointer(oberon_context_t * ctx, oberon_type_t * type)
+{
+ if(type -> class == OBERON_TYPE_POINTER)
+ {
+ return type;
+ }
+
+ if(type -> class == OBERON_TYPE_INTEGER
+ || type -> class == OBERON_TYPE_BOOLEAN
+ || type -> class == OBERON_TYPE_PROCEDURE
+ || type -> class == OBERON_TYPE_VOID)
+ {
+ oberon_error(ctx, "oberon not support pointers to non structure types");
+ }
+
+ oberon_type_t * newtype;
+ newtype = oberon_new_type_ptr(OBERON_TYPE_POINTER);
+ newtype -> base = type;
+
+ oberon_generator_init_type(ctx, newtype);
+
+ return newtype;
+}
+
static oberon_type_t * oberon_opt_formal_pars(oberon_context_t * ctx, int class);
static oberon_type_t *
type -> decl = type -> decl -> next;
oberon_generator_init_type(ctx, type);
}
+ else if(ctx -> token == POINTER)
+ {
+ oberon_assert_token(ctx, POINTER);
+ oberon_assert_token(ctx, TO);
+ type = oberon_type(ctx);
+ type = oberon_make_pointer(ctx, type);
+ }
else if(ctx -> token == PROCEDURE)
{
oberon_assert_token(ctx, PROCEDURE);
OBERON_TYPE_PROCEDURE,
OBERON_TYPE_ARRAY,
OBERON_TYPE_RECORD,
+ OBERON_TYPE_POINTER
};
/*
""
"TYPE"
" MyInt = INTEGER;"
- " MyRec = RECORD"
+ " MyRec = POINTER TO RECORD"
" a : MyInt;"
+ " next : MyRec;"
" END;"
- " MyRecPtr = POINTER TO MyRec;"
+ ""
+ "VAR"
+ " r : MyRec;"
""
"BEGIN"
" "