From 7bff9378302d5e23c6e9eabe7e6edc8034dcd562 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Mon, 24 Jul 2017 22:29:35 +0300 Subject: [PATCH] =?utf8?q?=D0=A7=D1=82=D0=BE-=D1=82=D0=BE=20=D1=82=D0=B0?= =?utf8?q?=D0=BC=20=D1=82=D0=B5=D1=81=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?utf8?q?=D0=BB=D0=BE=D1=81=D1=8C=20=D1=81=20=D0=BC=D0=B0=D1=81=D1=81?= =?utf8?q?=D0=B8=D0=B2=D0=B0=D0=BC=D0=B8...?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- generator.c | 6 ------ notes | 2 ++ oberon.c | 20 ++++++++++---------- oberon.h | 2 -- test.c | 32 +++++++++++++++++++++----------- 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/generator.c b/generator.c index a802a96..673ac33 100644 --- a/generator.c +++ b/generator.c @@ -81,14 +81,8 @@ oberon_generator_init_type(oberon_context_t * ctx, oberon_type_t * type) } else if(type -> class == OBERON_TYPE_ARRAY) { - if(type -> dim != 1) - { - oberon_error(ctx, "multidimension and open arrays not supported"); - } - gen_type_t * gen_base = type -> base -> gen_type; gcc_jit_type * gcc_base = gen_base -> gcc_type; - gcc_type = gcc_jit_context_new_array_type(gcc_context, NULL, gcc_base, type -> size); } else if(type -> class == OBERON_TYPE_RECORD) diff --git a/notes b/notes index d895de7..3e23e6b 100644 --- a/notes +++ b/notes @@ -11,3 +11,5 @@ - не реализована свёртка констант - не реализован автокаст (libgccjit сам разруливает) - не протестированы типы разнных размеров + +- похоже record инициализируется дважды в некоторых случаях diff --git a/oberon.c b/oberon.c index 847e9c7..f4a711f 100644 --- a/oberon.c +++ b/oberon.c @@ -758,11 +758,11 @@ oberon_make_array_selector(oberon_context_t * ctx, oberon_expr_t * desig, int nu oberon_error(ctx, "not array"); } - int dim = desig -> item.var -> type -> dim; - if(num_indexes != dim) - { - oberon_error(ctx, "dimesions not matched"); - } +// int dim = desig -> item.var -> type -> dim; +// if(num_indexes != dim) +// { +// oberon_error(ctx, "dimesions not matched"); +// } oberon_type_t * base = desig -> item.var -> type -> base; @@ -1399,9 +1399,8 @@ oberon_const_decl(oberon_context_t * ctx) } static void -oberon_make_array_type(oberon_context_t * ctx, int dim, oberon_item_t * size, oberon_type_t * base, oberon_type_t ** type) +oberon_make_array_type(oberon_context_t * ctx, oberon_item_t * size, oberon_type_t * base, oberon_type_t ** type) { - assert(dim == 1); if(size -> mode != MODE_INTEGER) { oberon_error(ctx, "requires integer constant"); @@ -1410,7 +1409,6 @@ oberon_make_array_type(oberon_context_t * ctx, int dim, oberon_item_t * size, ob oberon_type_t * arr; arr = *type; arr -> class = OBERON_TYPE_ARRAY; - arr -> dim = dim; arr -> size = size -> integer; arr -> base = base; } @@ -1482,7 +1480,7 @@ oberon_type(oberon_context_t * ctx, oberon_type_t ** type) base = oberon_new_type_ptr(OBERON_TYPE_VOID); oberon_type(ctx, &base); - oberon_make_array_type(ctx, 1, size, base, type); + oberon_make_array_type(ctx, size, base, type); } else if(ctx -> token == RECORD) { @@ -1523,8 +1521,10 @@ oberon_type(oberon_context_t * ctx, oberon_type_t ** type) } else if(ctx -> token == PROCEDURE) { + oberon_open_scope(ctx); oberon_assert_token(ctx, PROCEDURE); oberon_opt_formal_pars(ctx, type); + oberon_close_scope(ctx -> decl); } else { @@ -1786,8 +1786,8 @@ oberon_initialize_type(oberon_context_t * ctx, oberon_type_t * type) } else if(type -> class == OBERON_TYPE_ARRAY) { - oberon_generator_init_type(ctx, type); oberon_initialize_type(ctx, type -> base); + oberon_generator_init_type(ctx, type); } else if(type -> class == OBERON_TYPE_RECORD) { diff --git a/oberon.h b/oberon.h index 41cec62..93f80a8 100644 --- a/oberon.h +++ b/oberon.h @@ -98,8 +98,6 @@ struct oberon_type_s int class; int size; - int dim; - int num_decl; oberon_type_t * base; oberon_object_t * decl; diff --git a/test.c b/test.c index 960bef8..432307f 100644 --- a/test.c +++ b/test.c @@ -5,18 +5,28 @@ static const char source[] = "MODULE Test;" "TYPE" - " MyArr = ARRAY 3 OF INTEGER;" - " MyArrPtr = POINTER TO MyArr;" - " MyRec = POINTER TO MyRecDesc;" - " MyRecDesc = RECORD next : POINTER TO MyRecDesc END;" - "" + " Int = INTEGER;" + " PArray2D = POINTER TO Array2D;" + " Array2D = ARRAY 3 OF ARRAY 3 OF INTEGER;" + " PAP2D = ARRAY 4 OF POINTER TO ARRAY 5 OF INTEGER;" + " Object = POINTER TO ObjectDesc;" + " ObjectDesc = RECORD" + " value : Array2D;" + " value2 : PArray2D;" + " doStuff : Proc;" + " next : Object;" + " END;" + " Proc = PROCEDURE(self : Object; i : Int);" "VAR" - " a : MyArr;" - " b : MyArrPtr;" - " c : MyRec;" - " d : MyRecDesc;" - "" - "BEGIN" + " i : Int;" + " a2 : Array2D;" + " p2 : PArray2D;" + " po : Object;" + " do : ObjectDesc;" + " stuffProc : Proc;" + " pap2 : PAP2D;" + " " + "BEGIN;" "END Test." ; -- 2.29.2