237 lines
5.9 KiB
TeX
237 lines
5.9 KiB
TeX
\partthing{\texttt{Code1}, $Trans_{Cond}(Cond_0, \texttt{label2}, \texttt{label3}, vtable, ftable)$}{!(b == 0) \&\& (1 < a/b)}{$Cond_1$ \texttt{\&\&} $Cond_2$}
|
|
|
|
$\texttt{label4} = newlabel()$
|
|
|
|
$\texttt{code3} = Trans_{Cond}(Cond_1, \texttt{label4}, \texttt{label3}, vtable, ftable)$
|
|
|
|
$\texttt{code4} = Trans_{Cond}(Cond_2, \texttt{label2}, \texttt{label3}, vtable, ftable)$
|
|
|
|
\begin{lstlisting}
|
|
code3++
|
|
[LABEL label4]++
|
|
code4
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{Code2}, $Trans_{Stat}(Stat_1, vtable, ftable)$}{if b < a then \{ a := a - b \} else \{ b := b - a \}}{\texttt{if} $Cond_3$ \texttt{then} $Stat_2$ \texttt{else} $Stat_3$}
|
|
|
|
$\texttt{label5} = newlabel()$
|
|
|
|
$\texttt{label6} = newlabel()$
|
|
|
|
$\texttt{label7} = newlabel()$
|
|
|
|
$\texttt{code5} = Trans_{Cond}(Cond_3, \texttt{label6}, \texttt{label7}, vtable, ftable)$
|
|
|
|
$\texttt{code6} = Trans_{Stat}(Stat_2, vtable, ftable)$
|
|
|
|
$\texttt{code7} = Trans_{Stat}(Stat_3, vtable, ftable)$
|
|
|
|
\begin{lstlisting}
|
|
code5++
|
|
[LABEL label5]++
|
|
code6++
|
|
[
|
|
GOTO label7
|
|
LABEL label6
|
|
]++
|
|
code7++
|
|
[
|
|
GOTO label5
|
|
LABEL label7
|
|
]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{Code3}, $Trans_{Cond}(Cond_1, \texttt{label4}, \texttt{label3}, vtable, ftable)$}{!(b == 0)}{\texttt{!(}$Cond_4$\texttt{)}}
|
|
|
|
$\texttt{code8} = Trans_{Cond}(Cond_4, \texttt{label3}, \texttt{label4}, vtable, ftable)$
|
|
|
|
\begin{lstlisting}
|
|
code8
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code4}, $Trans_{Cond}(Cond_2, \texttt{label2}, \texttt{label3}, vtable, ftable)$}{1 < a/b}{$Exp_0$ \texttt{<} $Exp_1$}
|
|
|
|
$\texttt{t0} = newvar()$
|
|
|
|
$\texttt{t1} = newvar()$
|
|
|
|
$\texttt{code9} = Trans_{Exp}(Exp_0, vtable, ftable, \texttt{t0})$
|
|
|
|
$\texttt{code10} = Trans_{Exp}(Exp_1, vtable, ftable, \texttt{t1})$
|
|
|
|
\begin{lstlisting}
|
|
code9++
|
|
code10++
|
|
[IF t0 < t1 THEN label2 ELSE label3]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code5}, $Trans_{Cond}(Cond_3, \texttt{label6}, \texttt{label7}, vtable, ftable)$}{b < a}{$Exp_2$ \texttt{<} $Exp_3$}
|
|
|
|
$\texttt{t2} = newvar()$
|
|
|
|
$\texttt{t3} = newvar()$
|
|
|
|
$\texttt{code11} = Trans_{Exp}(Exp_2, vtable, ftable, \texttt{t2})$
|
|
|
|
$\texttt{code12} = Trans_{Exp}(Exp_3, vtable, ftable, \texttt{t3})$
|
|
|
|
\begin{lstlisting}
|
|
code11++
|
|
code12++
|
|
[IF t2 < t3 THEN label6 ELSE label7]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code6}, $Trans_{Stat}(Stat_2, vtable, ftable)$}{a := a - b}{\texttt{a :=} $Exp_4$}
|
|
|
|
$\texttt{place0} = newvar()$
|
|
|
|
$\texttt{code13} = Trans_{Exp}(Exp_4, vtable, ftable, \texttt{place0})$
|
|
|
|
\begin{lstlisting}
|
|
code13++
|
|
[v0 := place0]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code7}, $Trans_{Stat}(Stat_3, vtable, ftable)$}{b := b - a}{\texttt{b :=} $Exp_5$}
|
|
|
|
$\texttt{place1} = newvar()$
|
|
|
|
$\texttt{code14} = Trans_{Exp}(Exp_5, vtable, ftable, \texttt{place1})$
|
|
|
|
\begin{lstlisting}
|
|
code14++
|
|
[v1 := place1]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code8}, $Trans_{Cond}(Cond_4, \texttt{label3}, \texttt{label4}, vtable, ftable)$}{b == 0}{$Exp_6$ \texttt{==} $Exp_7$}
|
|
|
|
$\texttt{t4} = newvar()$
|
|
|
|
$\texttt{t5} = newvar()$
|
|
|
|
$\texttt{code15} = Trans_{Exp}(Exp_6, vtable, ftable, \texttt{t4})$
|
|
|
|
$\texttt{code16} = Trans_{Exp}(Exp_7, vtable, ftable, \texttt{t5})$
|
|
|
|
\begin{lstlisting}
|
|
code15++
|
|
code16++
|
|
[IF t4 == t5 THEN label3 ELSE label4]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code9}, $Trans_{Exp}(Exp_0, vtable, ftable, \texttt{t0})$}{1}{\texttt{1}}
|
|
|
|
\begin{lstlisting}
|
|
[t0 := 1]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code10}, $Trans_{Exp}(Exp_1, vtable, ftable, \texttt{t1})$}{a/b}{$Exp_8$ \texttt{/} $Exp_9$}
|
|
|
|
$\texttt{place2} = newvar()$
|
|
|
|
$\texttt{place3} = newvar()$
|
|
|
|
$\texttt{code17} = Trans_{Exp}(Exp_8, vtable, ftable, \texttt{place2})$
|
|
|
|
$\texttt{code18} = Trans_{Exp}(Exp_9, vtable, ftable, \texttt{place3})$
|
|
|
|
\begin{lstlisting}
|
|
code17++
|
|
code18++
|
|
[t1 := place2 / place3]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code11}, $Trans_{Exp}(Exp_2, vtable, ftable, \texttt{t2})$}{b}{\texttt{b}}
|
|
|
|
\begin{lstlisting}
|
|
[t0 := v1]
|
|
\end{lstlisting}
|
|
|
|
\newpage
|
|
|
|
\partthing{\texttt{code12}, $Trans_{Exp}(Exp_3, vtable, ftable, \texttt{t3})$}{a}{\texttt{a}}
|
|
|
|
\begin{lstlisting}
|
|
[t3 := v0]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code13}, $Trans_{Exp}(Exp_4, vtable, ftable, \texttt{place0})$}{a - b}{$Exp_{10}$ \texttt{-} $Exp_{11}$}
|
|
|
|
$\texttt{place4} = newvar()$
|
|
|
|
$\texttt{place5} = newvar()$
|
|
|
|
$\texttt{code19} = Trans_{Exp}(Exp_{10}, vtable, ftable, \texttt{place4})$
|
|
|
|
$\texttt{code20} = Trans_{Exp}(Exp_{11}, vtable, ftable, \texttt{place5})$
|
|
|
|
\begin{lstlisting}
|
|
code19++
|
|
code20++
|
|
[place0 := place4 - place5]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code14}, $Trans_{Exp}(Exp_5, vtable, ftable, \texttt{place1})$}{b - a}{$Exp_{12}$ \texttt{-} $Exp_{13}$}
|
|
|
|
$\texttt{place6} = newvar()$
|
|
|
|
$\texttt{place7} = newvar()$
|
|
|
|
$\texttt{code21} = Trans_{Exp}(Exp_{12}, vtable, ftable, \texttt{place6})$
|
|
|
|
$\texttt{code22} = Trans_{Exp}(Exp_{13}, vtable, ftable, \texttt{place7})$
|
|
|
|
\begin{lstlisting}
|
|
code21++
|
|
code22++
|
|
[place1 := place6 - place7]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code15}, $Trans_{Exp}(Exp_6, vtable, ftable, \texttt{t4})$}{b}{\texttt{b}}
|
|
|
|
\begin{lstlisting}
|
|
[t4 := v1]
|
|
\end{lstlisting}
|
|
|
|
\newpage
|
|
\partthing{\texttt{code16}, $Trans_{Exp}(Exp_7, vtable, ftable, \texttt{t5})$}{0}{\texttt{0}}
|
|
|
|
\begin{lstlisting}
|
|
[t5 := 1]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code17}, $Trans_{Exp}(Exp_8, vtable, ftable, \texttt{place2})$}{a}{\texttt{a}}
|
|
|
|
\begin{lstlisting}
|
|
[place2 := v0]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code18}, $Trans_{Exp}(Exp_9, vtable, ftable, \texttt{place3})$}{b}{\texttt{b}}
|
|
|
|
\begin{lstlisting}
|
|
[place3 := v1]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code19}, $Trans_{Exp}(Exp_{10}, vtable, ftable, \texttt{place4})$}{a}{\texttt{a}}
|
|
|
|
\begin{lstlisting}
|
|
[place4 := v0]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code20}, $Trans_{Exp}(Exp_{11}, vtable, ftable, \texttt{place5})$}{b}{\texttt{b}}
|
|
|
|
\begin{lstlisting}
|
|
[place5 := v1]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code21}, $Trans_{Exp}(Exp_{12}, vtable, ftable, \texttt{place6})$}{b}{\texttt{b}}
|
|
|
|
\begin{lstlisting}
|
|
[place6 := v1]
|
|
\end{lstlisting}
|
|
|
|
\partthing{\texttt{code22}, $Trans_{Exp}(Exp_{13}, vtable, ftable, \texttt{place7})$}{a}{\texttt{a}}
|
|
|
|
\begin{lstlisting}
|
|
[place7 := v0]
|
|
\end{lstlisting} |