public class ScopeManager
extends java.lang.Object
When a variable is declared so that it shadows an outer variable those two get different slots, even though they have the same name.
The slot number combines two values in one: which stack frame the variable resolves to, and its position in that frame. The first bit says which frame, and the rest of the bits are left for the slot number.
Basically:
| Modifier and Type | Field and Description |
|---|---|
static int |
UNFOUND |
| Constructor and Description |
|---|
ScopeManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
enterFunction()
Called when we enter a new function.
|
void |
enterScope()
Called when we enter a new lexical scope in which variables can
be declared, hiding those declared further out.
|
java.util.Map<java.lang.String,java.lang.Integer> |
getParameterSlots() |
int |
getStackFrameSize() |
void |
leaveFunction() |
void |
leaveScope() |
int |
registerParameter(java.lang.String parameter,
Location loc)
Registers a parameter to a function.
|
VariableInfo |
registerVariable(LetExpression let)
Registers a variable.
|
VariableInfo |
resolveVariable(VariableExpression variable) |
public static final int UNFOUND
public int getStackFrameSize()
public java.util.Map<java.lang.String,java.lang.Integer> getParameterSlots()
public void enterFunction()
public void leaveFunction()
public void enterScope()
public void leaveScope()
public VariableInfo registerVariable(LetExpression let)
public int registerParameter(java.lang.String parameter,
Location loc)
public VariableInfo resolveVariable(VariableExpression variable)