From: Mart Lubbers Date: Sat, 24 Jun 2017 18:22:26 +0000 (+0200) Subject: add return X-Git-Tag: hand-in~58 X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=fa4a40715e0b78ee616b98a1c1d889406a31435a;p=msc-thesis1617.git add return --- diff --git a/results.mtask.tex b/results.mtask.tex index 92e0782..50cd1d6 100644 --- a/results.mtask.tex +++ b/results.mtask.tex @@ -224,11 +224,29 @@ BCIfStmt (BC b) (BC t) (BC e) = BC ( t >>| tell [BCJmp endif, BCLab else] >>| e >>| tell [BCLab endif] ) + instance noOp ByteCode where noOp = tell` [BCNop] \end{lstlisting} -\todo{Add return instruction} +The semantics for the \glspl{mTask} bytecode view are different than the +semantics for the \gls{C} view. \glspl{Task} in the \gls{C} view can start new +\gls{Task} or themselves to continue, while in the bytecode view, \gls{Task} +run idefinitly, one-shot or on interrupt. To allow interval and interrupt +\glspl{Task} to terminate, a return instruction is added. This class was not +available in the original system and is thus added. It just writes a single +instruction so that the interpreter knows to stop execution. +Listing~\ref{lst:return} shows the classes and implementation for the return +expression. + +\begin{lstlisting}[label={lst:return},% + caption={Bytecode view for the return instruction}] +class retrn v where + retrn :: v () Expr + +instance retrn ByteCode where + retrn = tell` [BCReturn] +\end{lstlisting} \subsection{Shared Data Sources \& Assignment} Shared data sources must be acquired from the state and constructing one