2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 * Author: Ceriel J.H. Jacobs
8 /* T E M P O R A R Y V A R I A B L E S */
10 /* $Id: tmpvar.C,v 1.14 1994/06/24 12:42:58 ceriel Exp $ */
12 /* Code for the allocation and de-allocation of temporary variables,
14 The routines use "ProcScope" instead of "CurrentScope", because
15 "CurrentScope" also reflects WITH statements, and these scopes do not
35 struct tmpvar *t_next;
36 arith t_offset; /* offset from LocalBase */
39 /* STATICALLOCDEF "tmpvar" 10 */
41 static struct tmpvar *TmpInts, /* for integer temporaries */
42 *TmpPtrs; /* for pointer temporaries */
43 static t_scope *ProcScope; /* scope of procedure in which the
44 temporaries are allocated
47 TmpOpen(sc) t_scope *sc;
49 /* Initialize for temporaries in scope "sc".
58 register t_scope *sc = ProcScope;
60 sc->sc_off = - WA(align(sz - sc->sc_off, al));
65 NewTmp(plist, sz, al, regtype)
66 register struct tmpvar **plist;
69 register arith offset;
70 register struct tmpvar *tmp;
73 offset = TmpSpace(sz, al);
74 if (! options['n']) C_ms_reg(offset, sz, regtype, 0);
78 offset = tmp->t_offset;
88 return NewTmp(&TmpInts, int_size, int_align, reg_any);
94 return NewTmp(&TmpPtrs, pointer_size, pointer_align, reg_pointer);
99 struct tmpvar **plist;
102 register struct tmpvar *tmp = new_tmpvar();
104 tmp->t_next = *plist;
112 FreeTmp(&TmpInts, off);
118 FreeTmp(&TmpPtrs, off);
123 register struct tmpvar *tmp, *tmp1;
137 TmpInts = TmpPtrs = 0;