We are using the Visitor pattern to traverse ASTs in this course. In writing your code generator, you are not confined to using a single visitor.
Recall that the Visitor pattern performs a double dispatch: the method that executes is a function of the visitor and the object being visited. Thus, the code for a given Visitor should not try to do too much, but should perform a specialized function for the visitor and AST node involved.
When specialized processing is needed, say for
See, here you want to intercept LocalDeclaring but what you do for register assignment is different than in the rest of code generation. So use another visitor.