Accessing and Storing Variables

Local Variables

Instructions to load and store local variables:

Assigning indices (called slots) to local variables:

Function $slot : Var \to Int$

  • maps variable ocurrence, not name (part of symbol table)

Translation Rules for Local Variables

If $x$ is local variable and we translate expression, then

   [\![ x ]\!] = \textbf{iload}(slot(x))

For assignment to local variable $x=e$, we have

  [\![x=e]\!] = [\![e]\!] ::: \textbf{istore}(slot(x))

Static Variables

Instance Variables (Fields)