1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
/*
F E T C H V A R . C
Frame organization:
Low address
Local x <- Var 0xbffc = 0xbfff - x
Local ... <- Var 0xbffd = 0xbfff - ...
Local 1 <- Var 0xbffe = 0xbfff - 1
Local 0 <- Var 0xbfff = 0xbfff - 0
Old BP <- Var 0xc000
RA <- Var 0xc001
parameters: Par 0 <- Var 0xc002 = 0xc002 + 0
Par 1 <- Var 0xc003 = 0xc002 + 1
...
High Address
*/
#include "iccomp.h"
ESTRUC_ fetchvar()
{
register unsigned
index;
E_TYPE_
type = 0;
ESTRUC_
ret;
ret = stackframe(0);
/* not a local variable ? */
if ((index = looksym(&local)) == local.n_defined)
{ /* not a global variable ? */
if ((index = looksym(&global)) == global.n_defined)
{
index = 0xffff;
semantic("%s undefined", string);
}
else
type = global.symbol[index].var.type;
}
else
{
type = local.symbol[index].var.type;
if (index < n_params) /* Parameters: */
index += 0xc002;
else /* Locals: */
index = 0xbfff - (index - n_params);
}
if (index != 0xffff)
{
ret.evalue = index; /* set index and type */
ret.type = type;
}
return (ret); /* return the frame */
}
|