
Type Checking 147
FIGURE 4.7 The stages of the symbol table in analyzing Locals.foo().
Analysis proceeds as follows:
(a) The analyze() method for JMethodDeclaration creates a new MethodContext. Be-
cause foo() is an instance method, location 0 is allocated to this, and the next available
stack frame location (nextOffset) is 1.
(b) It declares the first formal parameter t in this MethodContext, allocating it the offset
1 (and incrementing nextOffset to 2).
(c) It declares the second formal parameter u in this MethodContext, allocating it the offset
2 (and incrementing nextOffset to 3). Analysis is then delegated to the method’s block
(a JBlock).
(d) The