| What do trees look like? | ||
| for some simple programs | ||
| Examine Translate/Translate.java | ||
| for loops and array indexing | ||
| Write | ||
| while loop & record field dereference translation | ||
| Note – these slides are available on the web | ||
Compile this with Translate.Main
| SEQ( | |
| MOVE( | |
| TEMP t2, | |
| CONST 3), | |
| MOVE | |
| TEMP t2, | |
| BINOP( PLUS, | |
| TEMP t2, | |
| CONST 1 ))) |
in Translate
Translate.java - ForExp
in Translate
Translate.java - SubscriptVar
| You might notice that the code for WhileExp and FieldVar is missing – you are to write these | |
| Consider what code you need to construct for each first | |
| With reference to what we’ve looked at, write the translation code for these two constructs |