summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 844ae6c)
raw | patch | inline | side by side (parent: 844ae6c)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 9 Aug 2017 18:02:29 +0000 (21:02 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 9 Aug 2017 18:02:29 +0000 (21:02 +0300) |
Test.obn | patch | blob | history | |
Test3.obn | [new file with mode: 0644] | patch | blob |
obn-run-tests.sh | patch | blob | history | |
src/backends/jvm/generator-jvm.c | patch | blob | history | |
src/generator.h | patch | blob | history | |
src/main.c | patch | blob | history | |
src/oberon.c | patch | blob | history |
diff --git a/Test.obn b/Test.obn
index 682b0a049b547a2b7d2497bb118f985e1492fafa..f4deaccac3d5c739ec23505c314e13b8d333e776 100644 (file)
--- a/Test.obn
+++ b/Test.obn
Out,
System;
+TYPE
+ RBase = RECORD END;
+ R = RECORD (RBase) END;
+
BEGIN
Out.Open;
IF FALSE THEN
diff --git a/Test3.obn b/Test3.obn
--- /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 b68d4b20cfd9354a635480f0659c5bc91bb965e3..6017f7e2865044cbe86f7cb78999cbaf82ee43f0 100755 (executable)
--- a/obn-run-tests.sh
+++ b/obn-run-tests.sh
maketest Test1
maketest Test2
+maketest Test3
index 065d9634c48a73b4b3900e63a17fd3e6f5a7ff6e..9d5e1f4af7d58e970c49a0ad2665e0488ff36488 100644 (file)
}
}
- printf("direct_call == %i\n", direct_call);
-
oberon_type_t * procsig;
procsig = desig -> parent -> result;
;
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 436a0f8f01b3a3470a5681f436eb7a505f8ed074..a940dab046fb25f2376e91bc754f53b4100fa920 100644 (file)
--- a/src/generator.h
+++ b/src/generator.h
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 8029be718d08bc4823e6723657a66441b68fe651..a97f2d7d71606da039bf0ded4764654dd8b64005 100644 (file)
--- a/src/main.c
+++ b/src/main.c
if(argc != 2)
{
- printf("use: %s <source>\n", argv[0]);
+ printf("use: %s <module>\n", argv[0]);
return 1;
}
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 f1fe4518a135c6e9369e877ac2c08d13575fb12a..cf1a570f8084f96c21234f7de51ad5e1c4406676 100644 (file)
--- a/src/oberon.c
+++ b/src/oberon.c
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++)