next up previous contents index
Next: while statements Up: Applying the simplify algorithm Previous: Interfaces.   Contents   Index


if, switch, and synchronized statements

Consider the statement

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
\verb$if($$e$\verb$) $$S$\end{tabbing}\end{minipage}\end{displaymath}

where $e$ is an expression and $S$ is a statement. As usual, $\mbox{\it INITS}$ and $e'$ are the results of applying the simplify algorithm to $e$. If $e' = e$, i.e. no simplification is required, the transformed version is just

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
\verb$if($$e$\verb$) $$S'$\end{tabbing}\end{minipage}\end{displaymath}

where $S'$ is the pre-translated version of $S$. Otherwise the transformed version is

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
\verb${$ \\
...
...if($$e'$\verb$) $$S'$ \\
\verb$}$
\end{tabbing}\end{minipage}\end{displaymath}

The if-else, switch and synchronized statements follow exactly the same pattern.



Bryan Carpenter 2003-04-15