use if else

This commit is contained in:
Kyryl Melekhin
2021-10-23 15:42:00 +00:00
parent 1afa19fb10
commit d22f2c719d

70
pike.c
View File

@@ -473,19 +473,20 @@ plist[plistidx++] = npc; \
#define onclist(nn) \ #define onclist(nn) \
#define endnlist() if (*npc == MATCH) nmatch = sp; \ #define endnlist() if (spc == MATCH) nmatch = sp; \
#define endclist() \ #define endclist() \
#define fastrec(nn, list, listidx) \ #define fastrec(nn, list, listidx) \
nsub->ref++; \ nsub->ref++; \
if (*npc < WBEG) { \ spc = *npc; \
if (spc < WBEG) { \
list[listidx].sub = nsub; \ list[listidx].sub = nsub; \
list[listidx++].pc = npc; \ list[listidx++].pc = npc; \
npc = pcs[i]; \ npc = pcs[si]; \
goto rec##nn; \ goto rec##nn; \
} \ } \
subs[i++] = nsub; \ subs[si++] = nsub; \
goto next##nn; \ goto next##nn; \
#define saveclist() \ #define saveclist() \
@@ -497,49 +498,44 @@ newsub(/*nop*/, /*nop*/) \
memcpy(s1->sub, nsub->sub, osubp); \ memcpy(s1->sub, nsub->sub, osubp); \
#define instclist(nn) \ #define instclist(nn) \
case BOL: \ else if (spc == BOL) { \
if (_sp != s) { \ if (_sp != s) { \
if (!i && !clistidx) \ if (!si && !clistidx) \
return 0; \ return 0; \
deccheck(nn) \ deccheck(nn) \
} \ } \
npc++; goto rec##nn; \ npc++; goto rec##nn; \
} \
#define instnlist(nn) \ #define instnlist(nn) \
case JMP: \ else if (spc == JMP) { \
npc += 2 + npc[1]; \ npc += 2 + npc[1]; \
goto rec##nn; \ goto rec##nn; \
} \
#define addthread(nn, list, listidx) \ #define addthread(nn, list, listidx) \
{ \ si = 0; \
int i = 0; \ rec##nn: \
rec##nn: \ spc = *npc; \
if (*npc < WBEG) { \ if (spc < WBEG) { \
list[listidx].sub = nsub; \ list[listidx].sub = nsub; \
list[listidx++].pc = npc; \ list[listidx++].pc = npc; \
rec_check##nn: \ rec_check##nn: \
if (i) { \ if (si) { \
npc = pcs[--i]; \ npc = pcs[--si]; \
nsub = subs[i]; \ nsub = subs[si]; \
goto rec##nn; \ goto rec##nn; \
} \ } \
end##list() \ end##list() \
continue; \ continue; \
} \ } \
next##nn: \ next##nn: \
switch(*npc) { \ if (spc == SPLIT) { \
case SPLIT: \
on##list(nn) \ on##list(nn) \
npc += 2; \ npc += 2; \
pcs[i] = npc + npc[-1]; \ pcs[si] = npc + npc[-1]; \
fastrec(nn, list, listidx) \ fastrec(nn, list, listidx) \
case RSPLIT: \ } else if (spc == SAVE) { \
on##list(nn) \
npc += 2; \
pcs[i] = npc; \
npc += npc[-1]; \
fastrec(nn, list, listidx) \
case SAVE: \
if (nsub->ref > 1) { \ if (nsub->ref > 1) { \
nsub->ref--; \ nsub->ref--; \
save##list() \ save##list() \
@@ -549,29 +545,33 @@ case JMP: \
nsub->sub[npc[1]] = _sp; \ nsub->sub[npc[1]] = _sp; \
npc += 2; \ npc += 2; \
goto rec##nn; \ goto rec##nn; \
case WBEG: \ } else if (spc == WBEG) { \
if (((sp != s || sp != _sp) && isword(sp)) \ if (((sp != s || sp != _sp) && isword(sp)) \
|| !isword(_sp)) \ || !isword(_sp)) \
deccheck(nn) \ deccheck(nn) \
npc++; goto rec##nn; \ npc++; goto rec##nn; \
case WEND: \ } else if (spc == RSPLIT) { \
on##list(nn) \
npc += 2; \
pcs[si] = npc; \
npc += npc[-1]; \
fastrec(nn, list, listidx) \
} else if (spc == WEND) { \
if (isword(_sp)) \ if (isword(_sp)) \
deccheck(nn) \ deccheck(nn) \
npc++; goto rec##nn; \ npc++; goto rec##nn; \
case EOL: \ } else if (spc == EOL) { \
if (*_sp) \ if (*_sp) \
deccheck(nn) \ deccheck(nn) \
npc++; goto rec##nn; \ npc++; goto rec##nn; \
inst##list(nn) \ } inst##list(nn) \
} \ deccheck(nn) \
deccheck(nn) \
} \
int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp) int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
{ {
int rsubsize = sizeof(rsub)+(sizeof(char*)*nsubp); int rsubsize = sizeof(rsub)+(sizeof(char*)*nsubp);
int i, j, c, suboff = rsubsize, *npc, osubp = nsubp * sizeof(char*); int si, i, j, c, suboff = rsubsize, *npc, osubp = nsubp * sizeof(char*);
int clistidx = 0, nlistidx, plistidx; int clistidx = 0, nlistidx, plistidx, spc;
const char *sp = s, *_sp = s, *nmatch = NULL; const char *sp = s, *_sp = s, *nmatch = NULL;
int *insts = prog->insts; int *insts = prog->insts;
int *pcs[prog->splits], *plist[prog->splits]; int *pcs[prog->splits], *plist[prog->splits];