mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 04:02:25 +00:00
Restore result variable just for issue #40 using same fix as J. Templ.
This commit is contained in:
parent
6a4748e2af
commit
03556336ce
22 changed files with 171 additions and 5 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue