From: DeaDDooMER Date: Sun, 13 Aug 2017 19:58:04 +0000 (+0300) Subject: Исправлено падение при использовании процедурного типа X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=9531d399c60190a8daf625dd99f9c141753bba5e;p=dsw-obn.git Исправлено падение при использовании процедурного типа --- diff --git a/Test.obn b/Test.obn index 8249fb7..c039f87 100644 --- a/Test.obn +++ b/Test.obn @@ -1,8 +1,11 @@ MODULE Test; -IMPORT Out; +VAR + x : PROCEDURE(i : INTEGER); + +PROCEDURE X(a : INTEGER); +END X; BEGIN - Out.Open; - Out.String("Hello World!"); Out.Ln; + x := X; END Test. diff --git a/Test18A.obn b/Test18A.obn new file mode 100644 index 0000000..06c84f6 --- /dev/null +++ b/Test18A.obn @@ -0,0 +1,13 @@ +MODULE Test18A; + +VAR + x : PROCEDURE(i : INTEGER); + +PROCEDURE X(a : INTEGER); +END X; + +BEGIN + x := X; +END Test18A. + +Проверка процедурного типа. Тест должен проходить. diff --git a/Test18B.obn b/Test18B.obn new file mode 100644 index 0000000..e963c56 --- /dev/null +++ b/Test18B.obn @@ -0,0 +1,13 @@ +MODULE Test18B; + +VAR + x : PROCEDURE(VAR i : INTEGER); + +PROCEDURE X(a : INTEGER); +END X; + +BEGIN + x := X; +END Test18B. + +Проверка процедурного типа. Тест должен проваливаться. diff --git a/Test18C.obn b/Test18C.obn new file mode 100644 index 0000000..02d960d --- /dev/null +++ b/Test18C.obn @@ -0,0 +1,10 @@ +MODULE Test18C; + +VAR + x : PROCEDURE (i : LONGREAL); + +BEGIN + x := ABS; +END Test18C. + +Проверка процедурного типа. Тест должен проваливаться. diff --git a/obn-run-tests.sh b/obn-run-tests.sh index e3e3d5a..70a1ea6 100755 --- a/obn-run-tests.sh +++ b/obn-run-tests.sh @@ -79,6 +79,7 @@ maketest Test13 maketest Test14 maketest Test15 maketest Test16 + makefail Test17A makefail Test17B makecomp Test17C @@ -86,3 +87,6 @@ makecomp Test17D makefail Test17E makefail Test17F +makecomp Test18A +makefail Test18B +makefail Test18C diff --git a/src/backends/jvm/generator-jvm-abi.c b/src/backends/jvm/generator-jvm-abi.c index 8d966cb..1d634a5 100644 --- a/src/backends/jvm/generator-jvm-abi.c +++ b/src/backends/jvm/generator-jvm-abi.c @@ -257,12 +257,17 @@ jvm_generate_var(gen_var_t * v) case JVM_STORAGE_REGISTER: case JVM_STORAGE_PARAM: case JVM_STORAGE_PARAM_VAR: + case JVM_STORAGE_FRAME: + case JVM_STORAGE_FRAME_VAR: + case JVM_STORAGE_FRAME_PARAM: + case JVM_STORAGE_FRAME_PARAM_VAR: jvm_generate(p, 0, 0, ".var %i is %s %s from start to end", reg, name, desc); break; case JVM_STORAGE_REGISTER_VAR: jvm_generate(p, 0, 0, ".var %i is %s [%s from start to end", reg, name, desc); break; case JVM_STORAGE_PARAM_VARPTR: + case JVM_STORAGE_FRAME_PARAM_VARPTR: jvm_generate(p, 0, 0, ".var %i is %s [%s from start to end", reg, name, desc); jvm_generate(p, 0, 0, ".var %i is %s$offset I from start to end", reg + 1, name); break; @@ -278,13 +283,6 @@ jvm_generate_var(gen_var_t * v) case JVM_STORAGE_FIELD_VAR: fprintf(v -> class -> fp, ".field public %s [%s\n\n", name, desc); break; - case JVM_STORAGE_FRAME: - case JVM_STORAGE_FRAME_VAR: - case JVM_STORAGE_FRAME_PARAM: - case JVM_STORAGE_FRAME_PARAM_VAR: - case JVM_STORAGE_FRAME_PARAM_VARPTR: - /* См. ниже jvm_generate_frame_class() */ - break; default: gen_error("jvm_generate_var: invalid storage %i", storage); break; diff --git a/src/backends/jvm/generator-jvm.c b/src/backends/jvm/generator-jvm.c index bf5200b..e897f6e 100644 --- a/src/backends/jvm/generator-jvm.c +++ b/src/backends/jvm/generator-jvm.c @@ -886,6 +886,7 @@ jvm_generate_local_initialization(gen_proc_t * p, oberon_object_t * x) case OBERON_CLASS_VAR_PARAM: case OBERON_CLASS_PARAM: case OBERON_CLASS_VAR: + jvm_generate_var(v); jvm_generate_var_initialization(p, v); break; case OBERON_CLASS_PROC: @@ -938,7 +939,7 @@ oberon_generate_begin_proc(oberon_context_t * ctx, oberon_object_t * proc) jvm_generate_procedure_frame(proc); - /* Создание парамеров и переменных */ + /* Создание параметров и переменных */ var = proc -> scope -> list -> next; while(var) { diff --git a/src/oberon.c b/src/oberon.c index efa6fed..3b8a6b1 100644 --- a/src/oberon.c +++ b/src/oberon.c @@ -2940,9 +2940,10 @@ oberon_initialize_type(oberon_context_t * ctx, oberon_type_t * type) oberon_object_t * field = type -> decl; for(int i = 0; i < num_fields; i++) { - oberon_initialize_object(ctx, field); + //oberon_initialize_object(ctx, field); + oberon_initialize_type(ctx, field -> type); field = field -> next; - } + } oberon_generator_init_type(ctx, type); }