From: DeaDDooMER Date: Tue, 25 Jul 2017 18:28:01 +0000 (+0300) Subject: JVM: Реализован вызов процедур-функций X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=7fc270e5b2a09d5c11b01c48c279c4920d427b0f;p=dsw-obn.git JVM: Реализован вызов процедур-функций --- diff --git a/src/backends/jvm/generator-jvm.c b/src/backends/jvm/generator-jvm.c index 9812f0a..dc04ffe 100644 --- a/src/backends/jvm/generator-jvm.c +++ b/src/backends/jvm/generator-jvm.c @@ -478,12 +478,15 @@ void oberon_generate_return(oberon_context_t * ctx, oberon_expr_t * expr) { gen_module_t * m; + char prefix; m = ctx -> mod -> gen_mod; if(expr) { - oberon_error(ctx, "oberon_generate_return: TODO return expr"); + push_expr(ctx, m -> fp, expr); + prefix = get_prefix(ctx, expr -> result); + fprintf(m -> fp, " %creturn\n", prefix); } else { @@ -559,8 +562,6 @@ push_float(FILE * fp, double f, int size) } } -static void push_expr(oberon_context_t * ctx, FILE * fp, oberon_expr_t * expr); - static void push_var(oberon_context_t * ctx, FILE * fp, oberon_object_t * var) { @@ -593,7 +594,7 @@ push_item(oberon_context_t * ctx, FILE * fp, oberon_item_t * item) push_int(fp, item -> boolean); break; case MODE_CALL: - oberon_error(ctx, "push_item: TODO call"); + oberon_generate_call_proc(ctx, (oberon_expr_t *) item); break; case MODE_INDEX: oberon_error(ctx, "push_item: TODO index"); diff --git a/src/test.c b/src/test.c index 0c80e4b..e042f24 100644 --- a/src/test.c +++ b/src/test.c @@ -9,15 +9,14 @@ static char source_test[] = "MODULE Test;" "VAR" " x : INTEGER;" - " z : BOOLEAN;" "" - "PROCEDURE Tier(x : INTEGER);" + "PROCEDURE Tier(x : INTEGER) : INTEGER;" + "BEGIN" + " RETURN x * x;" "END Tier;" "" "BEGIN;" - " x := x + 1;" - " z := TRUE;" - " Tier(666);" + " x := Tier(666);" "END Test." ;