| CSC448: Code Generation: Code Generation for Assignment Statements II [73/133] | ![]() ![]() ![]() |
Corin did not show
After the final source-to-source transformation, we know
that every StatExp contains an
ExpAssign.
In addition, every proper subexpression on the left and right hand side expressions of the assignment is either null or a variable.
The method codeGenExp generates code for an
ExpAssign in a StatExp.
private void codeGenExp (Exp exp, Frame frame) {
ExpAssign expA = (ExpAssign) exp;
// Generate code to load the value of expA.right into register eax.
// Have to perform case analysis on expA.right, but recursion is not
// necessary because the right hand side has a simple form.
// Generate code to load the value of register eax into expA.left.
// Only have to deal with the cases where expA.left is an ExpFieldAccess
// or an ExpVar.
}