Content deleted Content added
Algorithm step 1 corrected. |
No edit summary |
||
Line 8:
# Traverse the [[abstract syntax tree]] in pre- or postorder
## For every non-constant leaf node, assign a 1 (i.e. 1 register is needed to hold the variable/field/etc.) if it
## For every non-leaf node ''n'', assign the number of registers needed to evaluate the respective subtrees of ''n''. If the number of registers needed in the left subtree (''l'') are not equal to the number of registers needed in the right subtree (''r''), the number of registers needed for the current node ''n'' is max(l, r). If ''l == r'', then the number of registers needed for the current node is ''r'' + 1.
# Code emission
|