Dead Variable Elimination
Stratego -- Strategies for Program Transformation
The
dead-var-elim
component of the
Stratego optimizer eliminates variables from a strategy expression if they are not used in a build.
For example, in the expression
{ x, y, z :
?F(x, y)
; !y
; ?G(z)
; !H(z, z)
}
the variable
z
is used in the final build (not dead), and
y
is used in the build needed for the match with
G
(not dead).
However,
x
is dead since it does not contribute to the final result.
Dead variable elimination removes dead variables by
- eliminating them from the scope, and
- replacing occurrences in matches with a wildcard
Thus, the example reduces to
{ y, z :
?F(_, y)
; !y
; ?G(z)
; !H(z, z)
}
Variable only matches (
?x
) with dead variables are turned into wildcard matches (
?_
) and can
be cleaned up by a subsequent simplification.
--
EelcoVisser - 17 Aug 2003