From fa4a40715e0b78ee616b98a1c1d889406a31435a Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Sat, 24 Jun 2017 20:22:26 +0200 Subject: [PATCH] add return --- results.mtask.tex | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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 -- 2.20.1