handouts/ho08.tex
changeset 383 a6a6bf32fade
parent 382 38e368dc9b10
child 405 30dd644ba71a
equal deleted inserted replaced
382:38e368dc9b10 383:a6a6bf32fade
   130 the expression of the form \pcode{exp1 ; exp2} we need to 
   130 the expression of the form \pcode{exp1 ; exp2} we need to 
   131 generate code where after the first code chunk
   131 generate code where after the first code chunk
   132 a \pcode{pop}-instruction is needed. 
   132 a \pcode{pop}-instruction is needed. 
   133 
   133 
   134 \begin{lstlisting}[language=JVMIS, numbers=none,mathescape]
   134 \begin{lstlisting}[language=JVMIS, numbers=none,mathescape]
   135 $\textrm{\textit{estimate}}($exp1$)$
   135 $\textrm{\textit{compile}}($exp1$)$
   136 pop
   136 pop
   137 $\textrm{\textit{estimate}}($exp2$)$
   137 $\textrm{\textit{compile}}($exp2$)$
   138 \end{lstlisting}
   138 \end{lstlisting}
   139 
   139 
   140 \noindent In effect we ``forget'' about the result the first
   140 \noindent In effect we ``forget'' about the result the first
   141 expression calculates. I leave you to think about why this
   141 expression calculates. I leave you to think about why this
   142 sequence operator is still useful in the Fun-language, even 
   142 sequence operator is still useful in the Fun-language, even 
   167 \caption{The helper function for printing out integers.\label{write}}
   167 \caption{The helper function for printing out integers.\label{write}}
   168 \end{figure}
   168 \end{figure}
   169 
   169 
   170 
   170 
   171 \begin{lstlisting}[language=JVMIS, numbers=none,mathescape]
   171 \begin{lstlisting}[language=JVMIS, numbers=none,mathescape]
   172 $\textrm{\textit{estimate}}($1+2$)$
   172 $\textrm{\textit{compile}}($1+2$)$
   173 dup
   173 dup
   174 invokestatic XXX/XXX/write(I)V
   174 invokestatic XXX/XXX/write(I)V
   175 \end{lstlisting}
   175 \end{lstlisting}
   176 
   176 
   177 \noindent We also need to first generate code for the
   177 \noindent We also need to first generate code for the