diff --git a/bootstrap/unix-44/OPC.c b/bootstrap/unix-44/OPC.c index 9401b9a7..27ab3d15 100644 --- a/bootstrap/unix-44/OPC.c +++ b/bootstrap/unix-44/OPC.c @@ -69,6 +69,7 @@ export void OPC_IntLiteral (int64 n, int32 size); export void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); static void OPC_LenList (OPT_Object par, BOOLEAN ansiDefine, BOOLEAN showParamName); static int16 OPC_Length (CHAR *s, LONGINT s__len); +export BOOLEAN OPC_NeedsRetval (OPT_Object proc); export int32 OPC_NofPtrs (OPT_Struct typ); static int16 OPC_PerfectHash (CHAR *s, LONGINT s__len); static BOOLEAN OPC_Prefixed (OPT_ConstExt x, CHAR *y, LONGINT y__len); @@ -1428,6 +1429,11 @@ void OPC_DefineInter (OPT_Object proc) OPM_WriteLn(); } +BOOLEAN OPC_NeedsRetval (OPT_Object proc) +{ + return (proc->typ != OPT_notyp && !proc->scope->leaf); +} + void OPC_EnterProc (OPT_Object proc) { OPT_Object var = NIL, scope = NIL; @@ -1448,6 +1454,12 @@ void OPC_EnterProc (OPT_Object proc) OPM_WriteString((CHAR*)"_s", 3); OPC_EndStat(); } + if (OPC_NeedsRetval(proc)) { + OPC_BegStat(); + OPC_Ident(proc->typ->strobj); + OPM_WriteString((CHAR*)" __retval", 10); + OPC_EndStat(); + } var = proc->link; while (var != NIL) { if ((var->typ->comp == 2 && var->mode == 1)) { diff --git a/bootstrap/unix-44/OPC.h b/bootstrap/unix-44/OPC.h index c09a1524..bbfd1911 100644 --- a/bootstrap/unix-44/OPC.h +++ b/bootstrap/unix-44/OPC.h @@ -37,6 +37,7 @@ import void OPC_Init (void); import void OPC_InitTDesc (OPT_Struct typ); import void OPC_IntLiteral (int64 n, int32 size); import void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); +import BOOLEAN OPC_NeedsRetval (OPT_Object proc); import int32 OPC_NofPtrs (OPT_Struct typ); import void OPC_SetInclude (BOOLEAN exclude); import void OPC_TDescDecl (OPT_Struct typ); diff --git a/bootstrap/unix-44/OPV.c b/bootstrap/unix-44/OPV.c index 787ce143..f44318ed 100644 --- a/bootstrap/unix-44/OPV.c +++ b/bootstrap/unix-44/OPV.c @@ -1490,6 +1490,20 @@ static void OPV_stat (OPT_Node n, OPT_Object outerProc) } else { OPM_WriteString((CHAR*)"__ENDMOD", 9); } + } else if (OPC_NeedsRetval(outerProc)) { + OPM_WriteString((CHAR*)"__retval = ", 12); + if ((n->left->typ->form == 11 && n->obj->typ != n->left->typ)) { + OPM_WriteString((CHAR*)"(void*)", 8); + OPV_expr(n->left, 10); + } else { + OPV_expr(n->left, -1); + } + OPC_EndStat(); + OPC_BegStat(); + OPC_ExitProc(outerProc, 0, 0); + OPC_EndStat(); + OPC_BegStat(); + OPM_WriteString((CHAR*)"return __retval", 16); } else { OPC_ExitProc(outerProc, 0, 0); OPM_WriteString((CHAR*)"return", 7); diff --git a/bootstrap/unix-44/Strings.c b/bootstrap/unix-44/Strings.c index 000c09c8..104a0fb7 100644 --- a/bootstrap/unix-44/Strings.c +++ b/bootstrap/unix-44/Strings.c @@ -223,14 +223,17 @@ static BOOLEAN M__8 (CHAR *name, LONGINT name__len, CHAR *mask, LONGINT mask__le BOOLEAN Strings_Match (CHAR *string, LONGINT string__len, CHAR *pattern, LONGINT pattern__len) { struct Match__7 _s; + BOOLEAN __retval; __DUP(string, string__len, CHAR); __DUP(pattern, pattern__len, CHAR); _s.lnk = Match__7_s; Match__7_s = &_s; + __retval = M__8((void*)string, string__len, (void*)pattern, pattern__len, Strings_Length(string, string__len) - 1, Strings_Length(pattern, pattern__len) - 1); Match__7_s = _s.lnk; __DEL(string); __DEL(pattern); - return M__8((void*)string, string__len, (void*)pattern, pattern__len, Strings_Length(string, string__len) - 1, Strings_Length(pattern, pattern__len) - 1); + ; + return __retval; } diff --git a/bootstrap/unix-48/OPC.c b/bootstrap/unix-48/OPC.c index 9401b9a7..27ab3d15 100644 --- a/bootstrap/unix-48/OPC.c +++ b/bootstrap/unix-48/OPC.c @@ -69,6 +69,7 @@ export void OPC_IntLiteral (int64 n, int32 size); export void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); static void OPC_LenList (OPT_Object par, BOOLEAN ansiDefine, BOOLEAN showParamName); static int16 OPC_Length (CHAR *s, LONGINT s__len); +export BOOLEAN OPC_NeedsRetval (OPT_Object proc); export int32 OPC_NofPtrs (OPT_Struct typ); static int16 OPC_PerfectHash (CHAR *s, LONGINT s__len); static BOOLEAN OPC_Prefixed (OPT_ConstExt x, CHAR *y, LONGINT y__len); @@ -1428,6 +1429,11 @@ void OPC_DefineInter (OPT_Object proc) OPM_WriteLn(); } +BOOLEAN OPC_NeedsRetval (OPT_Object proc) +{ + return (proc->typ != OPT_notyp && !proc->scope->leaf); +} + void OPC_EnterProc (OPT_Object proc) { OPT_Object var = NIL, scope = NIL; @@ -1448,6 +1454,12 @@ void OPC_EnterProc (OPT_Object proc) OPM_WriteString((CHAR*)"_s", 3); OPC_EndStat(); } + if (OPC_NeedsRetval(proc)) { + OPC_BegStat(); + OPC_Ident(proc->typ->strobj); + OPM_WriteString((CHAR*)" __retval", 10); + OPC_EndStat(); + } var = proc->link; while (var != NIL) { if ((var->typ->comp == 2 && var->mode == 1)) { diff --git a/bootstrap/unix-48/OPC.h b/bootstrap/unix-48/OPC.h index c09a1524..bbfd1911 100644 --- a/bootstrap/unix-48/OPC.h +++ b/bootstrap/unix-48/OPC.h @@ -37,6 +37,7 @@ import void OPC_Init (void); import void OPC_InitTDesc (OPT_Struct typ); import void OPC_IntLiteral (int64 n, int32 size); import void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); +import BOOLEAN OPC_NeedsRetval (OPT_Object proc); import int32 OPC_NofPtrs (OPT_Struct typ); import void OPC_SetInclude (BOOLEAN exclude); import void OPC_TDescDecl (OPT_Struct typ); diff --git a/bootstrap/unix-48/OPV.c b/bootstrap/unix-48/OPV.c index 787ce143..f44318ed 100644 --- a/bootstrap/unix-48/OPV.c +++ b/bootstrap/unix-48/OPV.c @@ -1490,6 +1490,20 @@ static void OPV_stat (OPT_Node n, OPT_Object outerProc) } else { OPM_WriteString((CHAR*)"__ENDMOD", 9); } + } else if (OPC_NeedsRetval(outerProc)) { + OPM_WriteString((CHAR*)"__retval = ", 12); + if ((n->left->typ->form == 11 && n->obj->typ != n->left->typ)) { + OPM_WriteString((CHAR*)"(void*)", 8); + OPV_expr(n->left, 10); + } else { + OPV_expr(n->left, -1); + } + OPC_EndStat(); + OPC_BegStat(); + OPC_ExitProc(outerProc, 0, 0); + OPC_EndStat(); + OPC_BegStat(); + OPM_WriteString((CHAR*)"return __retval", 16); } else { OPC_ExitProc(outerProc, 0, 0); OPM_WriteString((CHAR*)"return", 7); diff --git a/bootstrap/unix-48/Strings.c b/bootstrap/unix-48/Strings.c index 000c09c8..104a0fb7 100644 --- a/bootstrap/unix-48/Strings.c +++ b/bootstrap/unix-48/Strings.c @@ -223,14 +223,17 @@ static BOOLEAN M__8 (CHAR *name, LONGINT name__len, CHAR *mask, LONGINT mask__le BOOLEAN Strings_Match (CHAR *string, LONGINT string__len, CHAR *pattern, LONGINT pattern__len) { struct Match__7 _s; + BOOLEAN __retval; __DUP(string, string__len, CHAR); __DUP(pattern, pattern__len, CHAR); _s.lnk = Match__7_s; Match__7_s = &_s; + __retval = M__8((void*)string, string__len, (void*)pattern, pattern__len, Strings_Length(string, string__len) - 1, Strings_Length(pattern, pattern__len) - 1); Match__7_s = _s.lnk; __DEL(string); __DEL(pattern); - return M__8((void*)string, string__len, (void*)pattern, pattern__len, Strings_Length(string, string__len) - 1, Strings_Length(pattern, pattern__len) - 1); + ; + return __retval; } diff --git a/bootstrap/unix-88/OPC.c b/bootstrap/unix-88/OPC.c index 9401b9a7..27ab3d15 100644 --- a/bootstrap/unix-88/OPC.c +++ b/bootstrap/unix-88/OPC.c @@ -69,6 +69,7 @@ export void OPC_IntLiteral (int64 n, int32 size); export void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); static void OPC_LenList (OPT_Object par, BOOLEAN ansiDefine, BOOLEAN showParamName); static int16 OPC_Length (CHAR *s, LONGINT s__len); +export BOOLEAN OPC_NeedsRetval (OPT_Object proc); export int32 OPC_NofPtrs (OPT_Struct typ); static int16 OPC_PerfectHash (CHAR *s, LONGINT s__len); static BOOLEAN OPC_Prefixed (OPT_ConstExt x, CHAR *y, LONGINT y__len); @@ -1428,6 +1429,11 @@ void OPC_DefineInter (OPT_Object proc) OPM_WriteLn(); } +BOOLEAN OPC_NeedsRetval (OPT_Object proc) +{ + return (proc->typ != OPT_notyp && !proc->scope->leaf); +} + void OPC_EnterProc (OPT_Object proc) { OPT_Object var = NIL, scope = NIL; @@ -1448,6 +1454,12 @@ void OPC_EnterProc (OPT_Object proc) OPM_WriteString((CHAR*)"_s", 3); OPC_EndStat(); } + if (OPC_NeedsRetval(proc)) { + OPC_BegStat(); + OPC_Ident(proc->typ->strobj); + OPM_WriteString((CHAR*)" __retval", 10); + OPC_EndStat(); + } var = proc->link; while (var != NIL) { if ((var->typ->comp == 2 && var->mode == 1)) { diff --git a/bootstrap/unix-88/OPC.h b/bootstrap/unix-88/OPC.h index c09a1524..bbfd1911 100644 --- a/bootstrap/unix-88/OPC.h +++ b/bootstrap/unix-88/OPC.h @@ -37,6 +37,7 @@ import void OPC_Init (void); import void OPC_InitTDesc (OPT_Struct typ); import void OPC_IntLiteral (int64 n, int32 size); import void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); +import BOOLEAN OPC_NeedsRetval (OPT_Object proc); import int32 OPC_NofPtrs (OPT_Struct typ); import void OPC_SetInclude (BOOLEAN exclude); import void OPC_TDescDecl (OPT_Struct typ); diff --git a/bootstrap/unix-88/OPV.c b/bootstrap/unix-88/OPV.c index c7a907db..452a1182 100644 --- a/bootstrap/unix-88/OPV.c +++ b/bootstrap/unix-88/OPV.c @@ -1490,6 +1490,20 @@ static void OPV_stat (OPT_Node n, OPT_Object outerProc) } else { OPM_WriteString((CHAR*)"__ENDMOD", 9); } + } else if (OPC_NeedsRetval(outerProc)) { + OPM_WriteString((CHAR*)"__retval = ", 12); + if ((n->left->typ->form == 11 && n->obj->typ != n->left->typ)) { + OPM_WriteString((CHAR*)"(void*)", 8); + OPV_expr(n->left, 10); + } else { + OPV_expr(n->left, -1); + } + OPC_EndStat(); + OPC_BegStat(); + OPC_ExitProc(outerProc, 0, 0); + OPC_EndStat(); + OPC_BegStat(); + OPM_WriteString((CHAR*)"return __retval", 16); } else { OPC_ExitProc(outerProc, 0, 0); OPM_WriteString((CHAR*)"return", 7); diff --git a/bootstrap/unix-88/Strings.c b/bootstrap/unix-88/Strings.c index 000c09c8..104a0fb7 100644 --- a/bootstrap/unix-88/Strings.c +++ b/bootstrap/unix-88/Strings.c @@ -223,14 +223,17 @@ static BOOLEAN M__8 (CHAR *name, LONGINT name__len, CHAR *mask, LONGINT mask__le BOOLEAN Strings_Match (CHAR *string, LONGINT string__len, CHAR *pattern, LONGINT pattern__len) { struct Match__7 _s; + BOOLEAN __retval; __DUP(string, string__len, CHAR); __DUP(pattern, pattern__len, CHAR); _s.lnk = Match__7_s; Match__7_s = &_s; + __retval = M__8((void*)string, string__len, (void*)pattern, pattern__len, Strings_Length(string, string__len) - 1, Strings_Length(pattern, pattern__len) - 1); Match__7_s = _s.lnk; __DEL(string); __DEL(pattern); - return M__8((void*)string, string__len, (void*)pattern, pattern__len, Strings_Length(string, string__len) - 1, Strings_Length(pattern, pattern__len) - 1); + ; + return __retval; } diff --git a/bootstrap/windows-48/OPC.c b/bootstrap/windows-48/OPC.c index 9401b9a7..27ab3d15 100644 --- a/bootstrap/windows-48/OPC.c +++ b/bootstrap/windows-48/OPC.c @@ -69,6 +69,7 @@ export void OPC_IntLiteral (int64 n, int32 size); export void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); static void OPC_LenList (OPT_Object par, BOOLEAN ansiDefine, BOOLEAN showParamName); static int16 OPC_Length (CHAR *s, LONGINT s__len); +export BOOLEAN OPC_NeedsRetval (OPT_Object proc); export int32 OPC_NofPtrs (OPT_Struct typ); static int16 OPC_PerfectHash (CHAR *s, LONGINT s__len); static BOOLEAN OPC_Prefixed (OPT_ConstExt x, CHAR *y, LONGINT y__len); @@ -1428,6 +1429,11 @@ void OPC_DefineInter (OPT_Object proc) OPM_WriteLn(); } +BOOLEAN OPC_NeedsRetval (OPT_Object proc) +{ + return (proc->typ != OPT_notyp && !proc->scope->leaf); +} + void OPC_EnterProc (OPT_Object proc) { OPT_Object var = NIL, scope = NIL; @@ -1448,6 +1454,12 @@ void OPC_EnterProc (OPT_Object proc) OPM_WriteString((CHAR*)"_s", 3); OPC_EndStat(); } + if (OPC_NeedsRetval(proc)) { + OPC_BegStat(); + OPC_Ident(proc->typ->strobj); + OPM_WriteString((CHAR*)" __retval", 10); + OPC_EndStat(); + } var = proc->link; while (var != NIL) { if ((var->typ->comp == 2 && var->mode == 1)) { diff --git a/bootstrap/windows-48/OPC.h b/bootstrap/windows-48/OPC.h index c09a1524..bbfd1911 100644 --- a/bootstrap/windows-48/OPC.h +++ b/bootstrap/windows-48/OPC.h @@ -37,6 +37,7 @@ import void OPC_Init (void); import void OPC_InitTDesc (OPT_Struct typ); import void OPC_IntLiteral (int64 n, int32 size); import void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); +import BOOLEAN OPC_NeedsRetval (OPT_Object proc); import int32 OPC_NofPtrs (OPT_Struct typ); import void OPC_SetInclude (BOOLEAN exclude); import void OPC_TDescDecl (OPT_Struct typ); diff --git a/bootstrap/windows-48/OPV.c b/bootstrap/windows-48/OPV.c index 787ce143..f44318ed 100644 --- a/bootstrap/windows-48/OPV.c +++ b/bootstrap/windows-48/OPV.c @@ -1490,6 +1490,20 @@ static void OPV_stat (OPT_Node n, OPT_Object outerProc) } else { OPM_WriteString((CHAR*)"__ENDMOD", 9); } + } else if (OPC_NeedsRetval(outerProc)) { + OPM_WriteString((CHAR*)"__retval = ", 12); + if ((n->left->typ->form == 11 && n->obj->typ != n->left->typ)) { + OPM_WriteString((CHAR*)"(void*)", 8); + OPV_expr(n->left, 10); + } else { + OPV_expr(n->left, -1); + } + OPC_EndStat(); + OPC_BegStat(); + OPC_ExitProc(outerProc, 0, 0); + OPC_EndStat(); + OPC_BegStat(); + OPM_WriteString((CHAR*)"return __retval", 16); } else { OPC_ExitProc(outerProc, 0, 0); OPM_WriteString((CHAR*)"return", 7); diff --git a/bootstrap/windows-48/Strings.c b/bootstrap/windows-48/Strings.c index 000c09c8..104a0fb7 100644 --- a/bootstrap/windows-48/Strings.c +++ b/bootstrap/windows-48/Strings.c @@ -223,14 +223,17 @@ static BOOLEAN M__8 (CHAR *name, LONGINT name__len, CHAR *mask, LONGINT mask__le BOOLEAN Strings_Match (CHAR *string, LONGINT string__len, CHAR *pattern, LONGINT pattern__len) { struct Match__7 _s; + BOOLEAN __retval; __DUP(string, string__len, CHAR); __DUP(pattern, pattern__len, CHAR); _s.lnk = Match__7_s; Match__7_s = &_s; + __retval = M__8((void*)string, string__len, (void*)pattern, pattern__len, Strings_Length(string, string__len) - 1, Strings_Length(pattern, pattern__len) - 1); Match__7_s = _s.lnk; __DEL(string); __DEL(pattern); - return M__8((void*)string, string__len, (void*)pattern, pattern__len, Strings_Length(string, string__len) - 1, Strings_Length(pattern, pattern__len) - 1); + ; + return __retval; } diff --git a/bootstrap/windows-88/OPC.c b/bootstrap/windows-88/OPC.c index 9401b9a7..27ab3d15 100644 --- a/bootstrap/windows-88/OPC.c +++ b/bootstrap/windows-88/OPC.c @@ -69,6 +69,7 @@ export void OPC_IntLiteral (int64 n, int32 size); export void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); static void OPC_LenList (OPT_Object par, BOOLEAN ansiDefine, BOOLEAN showParamName); static int16 OPC_Length (CHAR *s, LONGINT s__len); +export BOOLEAN OPC_NeedsRetval (OPT_Object proc); export int32 OPC_NofPtrs (OPT_Struct typ); static int16 OPC_PerfectHash (CHAR *s, LONGINT s__len); static BOOLEAN OPC_Prefixed (OPT_ConstExt x, CHAR *y, LONGINT y__len); @@ -1428,6 +1429,11 @@ void OPC_DefineInter (OPT_Object proc) OPM_WriteLn(); } +BOOLEAN OPC_NeedsRetval (OPT_Object proc) +{ + return (proc->typ != OPT_notyp && !proc->scope->leaf); +} + void OPC_EnterProc (OPT_Object proc) { OPT_Object var = NIL, scope = NIL; @@ -1448,6 +1454,12 @@ void OPC_EnterProc (OPT_Object proc) OPM_WriteString((CHAR*)"_s", 3); OPC_EndStat(); } + if (OPC_NeedsRetval(proc)) { + OPC_BegStat(); + OPC_Ident(proc->typ->strobj); + OPM_WriteString((CHAR*)" __retval", 10); + OPC_EndStat(); + } var = proc->link; while (var != NIL) { if ((var->typ->comp == 2 && var->mode == 1)) { diff --git a/bootstrap/windows-88/OPC.h b/bootstrap/windows-88/OPC.h index c09a1524..bbfd1911 100644 --- a/bootstrap/windows-88/OPC.h +++ b/bootstrap/windows-88/OPC.h @@ -37,6 +37,7 @@ import void OPC_Init (void); import void OPC_InitTDesc (OPT_Struct typ); import void OPC_IntLiteral (int64 n, int32 size); import void OPC_Len (OPT_Object obj, OPT_Struct array, int64 dim); +import BOOLEAN OPC_NeedsRetval (OPT_Object proc); import int32 OPC_NofPtrs (OPT_Struct typ); import void OPC_SetInclude (BOOLEAN exclude); import void OPC_TDescDecl (OPT_Struct typ); diff --git a/bootstrap/windows-88/OPV.c b/bootstrap/windows-88/OPV.c index c7a907db..452a1182 100644 --- a/bootstrap/windows-88/OPV.c +++ b/bootstrap/windows-88/OPV.c @@ -1490,6 +1490,20 @@ static void OPV_stat (OPT_Node n, OPT_Object outerProc) } else { OPM_WriteString((CHAR*)"__ENDMOD", 9); } + } else if (OPC_NeedsRetval(outerProc)) { + OPM_WriteString((CHAR*)"__retval = ", 12); + if ((n->left->typ->form == 11 && n->obj->typ != n->left->typ)) { + OPM_WriteString((CHAR*)"(void*)", 8); + OPV_expr(n->left, 10); + } else { + OPV_expr(n->left, -1); + } + OPC_EndStat(); + OPC_BegStat(); + OPC_ExitProc(outerProc, 0, 0); + OPC_EndStat(); + OPC_BegStat(); + OPM_WriteString((CHAR*)"return __retval", 16); } else { OPC_ExitProc(outerProc, 0, 0); OPM_WriteString((CHAR*)"return", 7); diff --git a/bootstrap/windows-88/Strings.c b/bootstrap/windows-88/Strings.c index 000c09c8..104a0fb7 100644 --- a/bootstrap/windows-88/Strings.c +++ b/bootstrap/windows-88/Strings.c @@ -223,14 +223,17 @@ static BOOLEAN M__8 (CHAR *name, LONGINT name__len, CHAR *mask, LONGINT mask__le BOOLEAN Strings_Match (CHAR *string, LONGINT string__len, CHAR *pattern, LONGINT pattern__len) { struct Match__7 _s; + BOOLEAN __retval; __DUP(string, string__len, CHAR); __DUP(pattern, pattern__len, CHAR); _s.lnk = Match__7_s; Match__7_s = &_s; + __retval = M__8((void*)string, string__len, (void*)pattern, pattern__len, Strings_Length(string, string__len) - 1, Strings_Length(pattern, pattern__len) - 1); Match__7_s = _s.lnk; __DEL(string); __DEL(pattern); - return M__8((void*)string, string__len, (void*)pattern, pattern__len, Strings_Length(string, string__len) - 1, Strings_Length(pattern, pattern__len) - 1); + ; + return __retval; } diff --git a/src/compiler/OPC.Mod b/src/compiler/OPC.Mod index d30cb712..ba59ef22 100644 --- a/src/compiler/OPC.Mod +++ b/src/compiler/OPC.Mod @@ -950,6 +950,11 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *) OPM.WriteLn; END DefineInter; + PROCEDURE NeedsRetval*(proc: OPT.Object): BOOLEAN; (* aux. variable __retval needed for return *) + BEGIN (* simple rule; ignores DUPlicated value arrays because they use alloca. *) + RETURN (proc^.typ # OPT.notyp) & ~proc^.scope^.leaf + END NeedsRetval; + PROCEDURE EnterProc* (proc: OPT.Object); VAR var, scope: OPT.Object; typ: OPT.Struct; dim: INTEGER; BEGIN @@ -962,6 +967,7 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *) BegStat; OPM.WriteString('struct '); OPM.WriteStringVar (scope^.name); OPM.Write(' '); OPM.WriteString(LocalScope); EndStat END ; + IF NeedsRetval(proc) THEN BegStat; Ident(proc^.typ^.strobj); OPM.WriteString(" __retval"); EndStat END; var := proc^.link; WHILE var # NIL DO (* declare copy of fixed size value array parameters *) IF (var^.typ^.comp = OPT.Array) & (var^.mode = OPT.Var) THEN diff --git a/src/compiler/OPV.Mod b/src/compiler/OPV.Mod index 83c451c3..cc3c93ef 100644 --- a/src/compiler/OPV.Mod +++ b/src/compiler/OPV.Mod @@ -875,6 +875,16 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96 END | OPT.Nreturn: IF OPM.level = 0 THEN IF OPM.mainprog IN OPM.Options THEN OPM.WriteString("__FINI") ELSE OPM.WriteString("__ENDMOD") END + ELSIF OPC.NeedsRetval(outerProc) THEN + OPM.WriteString("__retval = "); + IF (n^.left^.typ^.form = OPT.Pointer) & (n^.obj^.typ # n^.left^.typ) THEN + OPM.WriteString("(void*)"); expr(n^.left, 10) + ELSE + expr(n^.left, MinPrec) + END ; + OPC.EndStat; + OPC.BegStat; OPC.ExitProc(outerProc, FALSE, FALSE); OPC.EndStat; + OPC.BegStat; OPM.WriteString("return __retval"); ELSE OPC.ExitProc(outerProc, FALSE, FALSE); OPM.WriteString("return");