From bc1691627adee054210acf7e801361fa574f8086 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Wed, 9 Aug 2017 21:02:29 +0300 Subject: [PATCH] =?utf8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?utf8?q?=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0=20?= =?utf8?q?=D0=B1=D0=B0=D0=B7=D1=8B=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D0=B8?= =?utf8?q?=20=D0=BD=D0=B0=20=D1=80=D0=B5=D0=BA=D1=83=D1=80=D1=81=D0=B8?= =?utf8?q?=D0=B2=D0=BD=D0=BE=D0=B5=20=D1=80=D0=B0=D1=81=D1=88=D0=B8=D1=80?= =?utf8?q?=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Test.obn | 4 ++++ Test3.obn | 13 +++++++++++ obn-run-tests.sh | 1 + src/backends/jvm/generator-jvm.c | 37 +++----------------------------- src/generator.h | 9 -------- src/main.c | 3 +-- src/oberon.c | 14 +++++------- 7 files changed, 27 insertions(+), 54 deletions(-) create mode 100644 Test3.obn diff --git a/Test.obn b/Test.obn index 682b0a0..f4deacc 100644 --- a/Test.obn +++ b/Test.obn @@ -4,6 +4,10 @@ IMPORT Out, System; +TYPE + RBase = RECORD END; + R = RECORD (RBase) END; + BEGIN Out.Open; IF FALSE THEN diff --git a/Test3.obn b/Test3.obn new file mode 100644 index 0000000..5cb5b6d --- /dev/null +++ b/Test3.obn @@ -0,0 +1,13 @@ +MODULE Test3; + +(* + Тест вложенных комментариев + (* + Уровень 2 + (* + Уровень 3 + *) + *) +*) + +END Test3. diff --git a/obn-run-tests.sh b/obn-run-tests.sh index b68d4b2..6017f7e 100755 --- a/obn-run-tests.sh +++ b/obn-run-tests.sh @@ -29,3 +29,4 @@ compile_false_positive() maketest Test1 maketest Test2 +maketest Test3 diff --git a/src/backends/jvm/generator-jvm.c b/src/backends/jvm/generator-jvm.c index 065d963..9d5e1f4 100644 --- a/src/backends/jvm/generator-jvm.c +++ b/src/backends/jvm/generator-jvm.c @@ -1036,8 +1036,6 @@ jvm_generate_call_proc(gen_proc_t * p, oberon_item_t * desig) } } - printf("direct_call == %i\n", direct_call); - oberon_type_t * procsig; procsig = desig -> parent -> result; @@ -1187,20 +1185,17 @@ push_item(gen_proc_t * p, oberon_item_t * item) ; char postfix = jvm_get_postfix(item -> result); int cell_size = jvm_cell_size_for_postfix(postfix); - assert(item -> parent -> is_item); - push_item(p, (oberon_item_t *) item -> parent); + push_item(p, item -> parent); push_expr(p, item -> args); jvm_generate(p, 1 + 1, cell_size, "%caload", postfix); break; case MODE_FIELD: - assert(item -> parent -> is_item); - push_item(p, (oberon_item_t *) item -> parent); + push_item(p, item -> parent); jvm_generate_load(p, item -> var -> gen_var); break; case MODE_DEREF: /* Все объекты в jvm представляются как указатели */ - assert(item -> parent -> is_item); - push_item(p, (oberon_item_t *) item -> parent); + push_item(p, item -> parent); break; case MODE_NIL: jvm_generate(p, 0, 1, "aconst_null"); @@ -1641,29 +1636,3 @@ oberon_generate_assign(oberon_context_t * ctx, oberon_expr_t * src, oberon_expr_ store_expr(p, dst, src); } - -void -oberon_generate_code(oberon_context_t * ctx) -{ - printf("generate code\n"); -} - -void -oberon_generator_dump(oberon_context_t * ctx, char * path) -{ - printf("jit: dump code\n"); -} - -void * -oberon_generator_get_procedure(oberon_context_t * ctx, const char * name) -{ - printf("jit: get pointer to procedure %s\n", name); - return NULL; -} - -void * -oberon_generator_get_var(oberon_context_t * ctx, const char * name) -{ - printf("jit: get pointer to var %s\n", name); - return NULL; -} diff --git a/src/generator.h b/src/generator.h index 436a0f8..a940dab 100644 --- a/src/generator.h +++ b/src/generator.h @@ -39,12 +39,3 @@ void oberon_generate_goto(oberon_context_t * ctx, gen_label_t * l); void oberon_generate_assign(oberon_context_t * ctx, oberon_expr_t * src, oberon_expr_t * dst); void oberon_generate_return(oberon_context_t * ctx, oberon_expr_t * expr); - -/* - * Функции генерации кода - */ - -void oberon_generate_code(oberon_context_t * ctx); -void oberon_generator_dump(oberon_context_t * ctx, char * path); -void * oberon_generator_get_procedure(oberon_context_t * ctx, const char * name); -void * oberon_generator_get_var(oberon_context_t * ctx, const char * name); diff --git a/src/main.c b/src/main.c index 8029be7..a97f2d7 100644 --- a/src/main.c +++ b/src/main.c @@ -44,7 +44,7 @@ main(int argc, char ** argv) if(argc != 2) { - printf("use: %s \n", argv[0]); + printf("use: %s \n", argv[0]); return 1; } @@ -53,7 +53,6 @@ main(int argc, char ** argv) ctx = oberon_create_context(import_module); mod = oberon_compile_module(ctx, code); - oberon_generate_code(ctx); oberon_destroy_context(ctx); return 0; } diff --git a/src/oberon.c b/src/oberon.c index f1fe451..cf1a570 100644 --- a/src/oberon.c +++ b/src/oberon.c @@ -690,8 +690,6 @@ static void oberon_read_string(oberon_context_t * ctx) ctx -> token = STRING; ctx -> string = string; - - printf("oberon_read_string: string ((%s))\n", string); } static void oberon_read_token(oberon_context_t * ctx); @@ -986,11 +984,8 @@ oberno_make_record_cast(oberon_context_t * ctx, oberon_expr_t * expr, oberon_typ oberon_type_t * from = expr -> result; oberon_type_t * to = rec; - printf("oberno_make_record_cast: from class %i to class %i\n", from -> class, to -> class); - if(from -> class == OBERON_TYPE_POINTER && to -> class == OBERON_TYPE_POINTER) { - printf("oberno_make_record_cast: pointers\n"); from = from -> base; to = to -> base; } @@ -1107,9 +1102,6 @@ oberon_autocast_to(oberon_context_t * ctx, oberon_expr_t * expr, oberon_type_t * bool error = false; if(pref -> class != expr -> result -> class) { - printf("expr class %i\n", expr -> result -> class); - printf("pref class %i\n", pref -> class); - if(expr -> result -> class == OBERON_TYPE_STRING) { if(pref -> class == OBERON_TYPE_CHAR) @@ -1359,7 +1351,6 @@ oberon_make_call_proc(oberon_context_t * ctx, oberon_item_t * item, int num_args static oberon_expr_t * oberno_make_dereferencing(oberon_context_t * ctx, oberon_expr_t * expr) { - printf("oberno_make_dereferencing\n"); if(expr -> result -> class != OBERON_TYPE_POINTER) { oberon_error(ctx, "not a pointer"); @@ -2883,6 +2874,11 @@ oberon_prevent_recursive_record(oberon_context_t * ctx, oberon_type_t * type) type -> recursive = 1; + if(type -> base) + { + oberon_prevent_recursive_record(ctx, type -> base); + } + int num_fields = type -> num_decl; oberon_object_t * field = type -> decl; for(int i = 0; i < num_fields; i++) -- 2.29.2