popped of the stack and the value in \tt{RR} (for functions which do not return
\tt{Void}) is placed on the stack.
-\begin{SPLCode} \label{lst:stackFunCall}
+\begin{lstlisting}[
+ label={lst:stackFunCall},
+ caption={Stack layout during function calls},
+ language=SPLCode]
plus(x, y}{ return x + y; }
main(){ var a = plus(3, 4); }
117 | 003 ;x, loaded by ldl -3
118 | 004 ;y, loaded by ldl -2
*/
-\end{SPLCode}
+\end{lstlisting}
\subsection{Generation}
The code generation phase transforms a well typed \AST{} to either an error,
in the scope in which they are declared. This could be solved by adding all
free variables in the lambda expression as parameters to the lifted function.
-\begin{lstlisting}[
- label={lst:lambdaLift},
- caption={SPLC types},
- language=SPLCode]
+\begin{lstlisting}[label={lst:lambdaLift},caption={\SPLC{} types},language=SPLCode]
main() {
var x = \a b -> a + b;
}
}
\end{equation}
-\begin{equation} \label{eq:inferAppN}
- \infer[AppN]
- {\Gamma \vdash \textit{id}(e^*).\textit{fs}^* \Rightarrow
- ((\Gamma^\star, \star, \tau^r,
- \textit{id}({e^*}').\textit{fs}^*)}
- {\Gamma(id) = \lfloor \tau^e \rfloor
- &\Gamma \vdash e^* \Rightarrow
- (\Gamma^{\star_1}, \star_1, \tau^*, {e^*}')
- &(\texttt{fold } (\rightarrow) \texttt{ } \alpha \texttt{ } \tau^*)
- \unif \tau^e = \star_2
- &\star = \star_2 \cdot \star_1
- &\texttt{fold apfs } \tau \textit{ fs}^* = \tau^e
+\begin{equation}\label{eq:inferAppN}
+ \resizebox{\linewidth}{!}{%
+ \infer[AppN]
+ {\Gamma \vdash \textit{id}(e^*).\textit{fs}^* \Rightarrow
+ ((\Gamma^\star, \star, \tau^r,
+ \textit{id}({e^*}').\textit{fs}^*)}
+ {\Gamma(id) = \lfloor \tau^e \rfloor
+ &\Gamma \vdash e^* \Rightarrow
+ (\Gamma^{\star_1}, \star_1, \tau^*, {e^*}')
+ &(\texttt{fold } (\rightarrow) \texttt{ } \alpha \texttt{ } \tau^*)
+ \unif \tau^e = \star_2
+ &\star = \star_2 \cdot \star_1
+ &\texttt{fold apfs } \tau \textit{ fs}^* = \tau^e
}
+ }
\end{equation}
\paragraph{Return statements}
and returns the type of the variable needed to assign to that fieldselector,
i.e. \CI{unapfs a FieldHd = ListType a}
\begin{equation}
- \infer[Ass]
- {\Gamma \vdash \textit{id.fs}^* \underline{=} e \Rightarrow
- (\Gamma^\star.k:\tau_r^\star, \star, \textrm{Void},
- \textit{id.fs}^* \underline{=} e')
- }
- {\Gamma(\textit{id}) = \lfloor \tau_e \rfloor
- &\Gamma \vdash e \Rightarrow (\Gamma^{\star_1}, \star_1, \tau_g, e')
- &\texttt{fold unapfs } \tau_g \textit{ reverse fs} = \tau^r
- &\tau_e \unif \tau_g = \star_2
- &\star = \star_2 \cdot \star_1
+ \resizebox{\linewidth}{!}{%
+ \infer[Ass]
+ {\Gamma \vdash \textit{id.fs}^* \underline{=} e \Rightarrow
+ (\Gamma^\star.k:\tau_r^\star, \star, \textrm{Void},
+ \textit{id.fs}^* \underline{=} e')
+ }
+ {\Gamma(\textit{id}) = \lfloor \tau_e \rfloor
+ &\Gamma \vdash e \Rightarrow (\Gamma^{\star_1}, \star_1, \tau_g, e')
+ &\texttt{fold unapfs } \tau_g \textit{ reverse fs} = \tau^r
+ &\tau_e \unif \tau_g = \star_2
+ &\star = \star_2 \cdot \star_1
}
+ }
\end{equation}