X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=mtaskext.bytecode.tex;h=e0da38a041a59bcc18bc3664a14a73e0345a67e3;hb=2498dced580be1e7af31a662dadee26c4fd159ed;hp=1a365be810403606f6b0974e21b78a5b6c340d86;hpb=ce72d1f8bb05ef88c3b8dcf2a3a4dd81c5c01557;p=msc-thesis1617.git diff --git a/mtaskext.bytecode.tex b/mtaskext.bytecode.tex index 1a365be..e0da38a 100644 --- a/mtaskext.bytecode.tex +++ b/mtaskext.bytecode.tex @@ -29,7 +29,7 @@ quantified type variables and therefore it is not possible to derive class instances such as \CI{iTasks}. Tailor-made instances for these functions have been made. -\begin{lstlisting}[label={lst:bcview},caption={Bytecode view}] +\begin{lstlisting}[language=Clean,label={lst:bcview},caption={Bytecode view}] :: ByteCode a p = BC (RWS () [BC] BCState ()) :: BCValue = E.e: BCValue e & mTaskType, TC e :: BCShare = @@ -66,7 +66,7 @@ However, this is not a real instruction and the labels are resolved to actual program memory addresses in the final step of compilation to save instructions and avoid label lookups at runtime. -\begin{lstlisting}[label={bc:instr},% +\begin{lstlisting}[language=Clean,label={bc:instr},% caption={Bytecode instruction set}] :: BC = BCNop | BCLab Int | BCPush BCValue | BCPop @@ -108,7 +108,7 @@ to make operators that pop one or two values off the stack respectively. The \CI{tell`} function is a wrapper around the \gls{RWST} function \CI{tell} that appends the argument to the \emph{Writer} value. -\begin{lstlisting}[label={lst:helpers},caption={Some helper functions}] +\begin{lstlisting}[language=Clean,label={lst:helpers},caption={Some helper functions}] op2 :: (ByteCode a p1) (ByteCode a p2) BC -> ByteCode b Expr op2 (BC x) (BC y) bc = BC (x >>| y >>| tell [bc]) @@ -128,7 +128,7 @@ functions. Listing~\ref{lst:arithview} shows some implementations. The \CI{boolExpr} class and the classes for the peripherals are implemented using the same strategy. -\begin{lstlisting}[label={lst:arithview},caption={% +\begin{lstlisting}[language=Clean,label={lst:arithview},caption={% Bytecode view implementation for arithmetic and peripheral classes}] instance arith ByteCode where lit x = tell` [BCPush (BCValue x)] @@ -149,7 +149,7 @@ they are placed in the correct order in the bytecode sequence. It can happen that multiple labels appear consecutively in the code. This is not a problem since the labels are resolved to real addresses later on anyway. -\begin{lstlisting}[label={lst:controlflow},% +\begin{lstlisting}[language=Clean,label={lst:controlflow},% caption={Bytecode view for the \texttt{IF} class}] freshlabel = get >>= \st=:{freshl}->put {st & freshl=freshl+1} >>| tell freshl @@ -178,7 +178,7 @@ 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},% +\begin{lstlisting}[language=Clean,label={lst:return},% caption={Bytecode view for the return instruction}] class retrn v where retrn :: v () Expr @@ -197,7 +197,7 @@ implementation is shown in Listing~\ref{lst:shareview}. The implementation for the \CI{namedsds} class is exactly the same other than that it stores the given name in the \CI{BCShare} structure as well. -\begin{lstlisting}[label={lst:shareview},% +\begin{lstlisting}[language=Clean,label={lst:shareview},% caption={Bytecode view for \texttt{arith}}] freshshare = get >>= \st=:{freshs}->put {st & freshs=freshs+1} >>| pure freshs @@ -225,7 +225,7 @@ instruction(s) will be rewritten accordingly. This results in a %chktex 36 \CI{BCSdsStore} or \CI{BCAnalogWrite} instruction respectively. The implementation for this is given in Listing~\ref{lst:assignmentview}. -\begin{lstlisting}[label={lst:assignmentview},% +\begin{lstlisting}[language=Clean,label={lst:assignmentview},% caption={Bytecode view implementation for assignment.}] instance assign ByteCode where (=.) (BC v) (BC e) = BC (e >>| censor makeStore v) @@ -257,7 +257,7 @@ one to find new instantiated \glspl{SDS}. The compilation concludes with converting the bytecode and \glspl{SDS} to actual messages ready to send to the client. -\begin{lstlisting}[label={lst:compilation},% +\begin{lstlisting}[language=Clean,label={lst:compilation},% caption={Actual compilation.}] bclength :: BC -> Int bclength (BCPush s) = 1 + size (toByteCode s)