Question: For the final project, you generate code for expressions as discussed in class: the codeGen method for each kind of expression will generate code to

 For the final project, you generate code for expressions as discussed

For the final project, you generate code for expressions as discussed in class: the codeGen method for each kind of expression will generate code to evaluate the expression, leaving the value on the stack. While this kind of code is easy to generate, storing intermediate values on the stack rather than in registers is inefficient. You might think we could instead require that the codeGen method for an expression should work as follows: Each expression node's codeGen method would have 1 parameter: a register number N, which would be either 0 or 1 For literals or identifiers, the codeGen method would simply load the appropriate value in register N. For expressions involving non short-circuited binary operators (+, *,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!