fixed some problems: ADS was generated with size > pointer_size;

some (most) backends dont implement that.
Unstacking of macros did not quite work properly, but I dont know why
This commit is contained in:
ceriel 1987-10-20 09:36:34 +00:00
parent e2c9a1a96f
commit a24c90f5a9
4 changed files with 33 additions and 13 deletions

View file

@ -78,7 +78,7 @@
!File: debug.h !File: debug.h
#undef DEBUG 1 /* perform various self-tests */ #define DEBUG 1 /* perform various self-tests */
!File: use_tmp.h !File: use_tmp.h

View file

@ -122,7 +122,10 @@ EVAL(expr, val, code, true_label, false_label)
C_adi(tp->tp_size); C_adi(tp->tp_size);
break; break;
case POINTER: case POINTER:
C_ads(right->ex_type->tp_size); C_loc(right->ex_type->tp_size);
C_loc(pointer_size);
C_ciu();
C_ads(pointer_size);
break; break;
#ifndef NOFLOAT #ifndef NOFLOAT
case DOUBLE: case DOUBLE:
@ -176,7 +179,10 @@ EVAL(expr, val, code, true_label, false_label)
C_sbs(pointer_size); C_sbs(pointer_size);
else { else {
C_ngi(right->ex_type->tp_size); C_ngi(right->ex_type->tp_size);
C_ads(right->ex_type->tp_size); C_loc(right->ex_type->tp_size);
C_loc(pointer_size);
C_ciu();
C_ads(pointer_size);
} }
break; break;
#ifndef NOFLOAT #ifndef NOFLOAT
@ -748,7 +754,10 @@ assop(type, oper)
case POINTER: case POINTER:
if (oper == MINAB || oper == MINMIN || oper == POSTDECR) if (oper == MINAB || oper == MINMIN || oper == POSTDECR)
C_ngi(size); C_ngi(size);
C_ads(size); C_loc(size);
C_loc(pointer_size);
C_ciu();
C_ads(pointer_size);
break; break;
case ERRONEOUS: case ERRONEOUS:
break; break;

View file

@ -37,6 +37,7 @@ struct mlist {
struct mlist *next; struct mlist *next;
struct macro *m_mac; struct macro *m_mac;
char *m_repl; char *m_repl;
char m_unstack;
}; };
/* ALLOCDEF "mlist" 20 */ /* ALLOCDEF "mlist" 20 */

View file

@ -190,26 +190,36 @@ macro2buffer(idef, actpars, siztext)
EXPORT EXPORT
DoUnstack() DoUnstack()
{ {
register struct mlist *p = ReplaceList;
while (p->m_unstack) p = p->next;
p->m_unstack = 1;
Unstacked++; Unstacked++;
} }
EXPORT EXPORT
EnableMacros() EnableMacros()
{ {
register struct mlist *p = ReplaceList; register struct mlist *p = ReplaceList, *prev = 0;
int cnt = 0;
ASSERT(Unstacked > 0); ASSERT(Unstacked > 0);
while (Unstacked > 0) { while (p) {
struct mlist *nxt = p->next; struct mlist *nxt = p->next;
ASSERT(p != 0); if (p->m_unstack) {
p->m_mac->mc_flag &= ~NOREPLACE; p->m_mac->mc_flag &= ~NOREPLACE;
if (p->m_mac->mc_count) p->m_mac->mc_count--; if (p->m_mac->mc_count) p->m_mac->mc_count--;
if (p->m_repl) free(p->m_repl); if (p->m_repl) free(p->m_repl);
free_mlist(p); if (! prev) ReplaceList = nxt;
else prev->next = nxt;
free_mlist(p);
cnt++;
}
else prev = p;
p = nxt; p = nxt;
Unstacked--;
} }
ReplaceList = p; ASSERT(cnt == Unstacked);
Unstacked = 0;
} }
#endif NOPP #endif NOPP