Professional Documents
Culture Documents
Entry contains
Type : .type attribute
Relative address in procedure's activation record (e.g, Java
int takes four bytes, double takes eight) : .width attribute
Code-generating part of compiler uses a global variable offset
that is reset to zero as new procedures are declared
Code-generator proc. enter (name, type, width) creates symboltable entry with this info
Consider just declarations part of program....
P
D
D
T
T
D
D;D
id : T
integer
double
{ offset := 0 } // initializaion
Abstractly:
P
D
P
M
MD
{ offset := 0 }
D
D , D | id : T | fun id ( D ) = S
nil
f:
x
g
g:
x
y
MD
M
D
{ addwidth(top(tblptr), top(offset));
pop(tblptr); pop(offset); } // done after M's
// actions
{ t := mktable(nil);
push(t, tblptr); push (0, offset) }
N
id : T
D,D
fun id N ( D1 ) = S
{ t := top (tblptr);
addwidth (t, top ( offset ));
pop(tblptr); pop(offset);
enterproc( top ( tblptr), id.name, t ) }
continues ...
+ y