X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=mtaskext.examples.tex;h=05c1d9bbfa8d68205bdb0fe7ef394a8d0a78e192;hb=4bb4ae51e1199aa618d8765b0bc429fba9055140;hp=57782d85ec7ed32632881147a196f5d3c49a2c30;hpb=d66b8c6bae6fde77e7ba53759f862364a9505ace;p=msc-thesis1617.git diff --git a/mtaskext.examples.tex b/mtaskext.examples.tex index 57782d8..05c1d9b 100644 --- a/mtaskext.examples.tex +++ b/mtaskext.examples.tex @@ -22,7 +22,7 @@ factorial after which is will return. The following listings shows the actual \gls{mTask} and the generated messages followed by the actual bytecode in a readable form. -\begin{lstlisting}[caption={Faculty as an \gls{mTask}-\gls{Task}}] +\begin{lstlisting}[caption={Factorial as an \gls{mTask}-\gls{Task}}] factorial :: Int -> Main (ByteCode () Stmt) factorial i = sds \y=i In namedsds \x=1 Named "result" In @@ -34,14 +34,16 @@ factorial i = sds \y=i In )} //Generating the actual messages with: -//toMessages (OnInterval 500) (factorial 5) zero +Start = fst $ toMessages (OnInterval 500) (factorial 5) zero + +//The output will be //[MTSds 2 (BCValue 5), MTSds 1 (BCValue 1), MTTask (OnInterval 500) ...] \end{lstlisting} \begin{lstlisting}[label={lst:actualbc},% - caption={The resulting bytecode for the factorial function},language=c] + caption={The resulting bytecode for the factorial function},language=C] 0-2 : BCSdsFetch 1 - 3-6 : BCPush i\d0\d1 + 3-6 : BCPush (Int 1) 7 : BCLeq 8-9 : BCJmpF 16 //Jump to else 10-12: BCSdsPublish 2 ("result") @@ -52,7 +54,7 @@ factorial i = sds \y=i In 22 : BCMul 23-25: BCSdsStore 2 ("result") 26-28: BCSdsFetch 1 -29-32: BCPush i\d0\d1 +29-32: BCPush (Int 1) 33 : BCSub 34-36: BCSdsStore 1 37 : //Endif label