From: DeaDDooMER Date: Fri, 28 Jul 2017 13:31:04 +0000 (+0300) Subject: JVM: Добавлена инициализация глобальных переменных с типами статических массивов... X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=13d2ebdd52d42ab2e9d5f3764a9296a25fe16464;p=dsw-obn.git JVM: Добавлена инициализация глобальных переменных с типами статических массивов или записей --- diff --git a/src/backends/jvm/generator-jvm.c b/src/backends/jvm/generator-jvm.c index af45a63..9408eca 100644 --- a/src/backends/jvm/generator-jvm.c +++ b/src/backends/jvm/generator-jvm.c @@ -650,6 +650,22 @@ oberon_generate_begin_module(oberon_context_t * ctx) jvm_alloc_register_untyped(p -> rf, false); jvm_generate(p, 0, 1, "aload_0"); jvm_generate(p, 1, 0, "invokespecial java/lang/Object/()V"); + + /* Инициализация переменных объявленных в модуле */ + oberon_object_t * x = ctx -> mod -> decl -> list -> next; + while(x != NULL) + { + if(x -> class == OBERON_CLASS_VAR) + { + if(x -> type -> class == OBERON_TYPE_ARRAY + || x -> type -> class == OBERON_TYPE_RECORD) + { + jvm_generate_new_static(p, x -> type); + jvm_generate_store(p, x -> type, x -> gen_var); + } + } + x = x -> next; + } } void diff --git a/src/test.c b/src/test.c index 2419c3b..92223cd 100644 --- a/src/test.c +++ b/src/test.c @@ -7,17 +7,12 @@ static char source_test[] = "(* Main module *)" "MODULE Test;" - "TYPE" - " Packed = ARRAY 16, 32 OF RECORD a : INTEGER; r : RECORD x : INTEGER; END; END;" - " IArray = ARRAY 16, 32, 666 OF INTEGER;" "VAR" - " k : POINTER TO Packed;" - " ii : POINTER TO IArray;" + " g : ARRAY 4 OF INTEGER;" + " r : RECORD x : INTEGER; END;" "BEGIN" - " NEW(k);" - " k[1, 2].a := 666;" - " k[5, 2].r.x := 456;" - " NEW(ii);" + " g[3] := 4;" + " r.x := 4546;" "END Test." ;