more text
[ri1617.git] / architecture / mtasks.tex
index f7197f2..be43d3c 100644 (file)
@@ -1,13 +1,47 @@
-\emph{mTask}s are written in a shallowly embedded class-based DSL that due to
+\subsection{mTask}
+\mTask{}s are written in a shallowly embedded class-based DSL that due to
 the nature of it can be easily extended in language and in view. Currently
 there is a view for generating \emph{C}-code and a view for simulating
-\emph{mTasks} using \iTasks{}. Currently  the \emph{mTask} code includes
+\mTask{}s using \iTasks{}. Currently  the \mTask{} code includes
 functionality for running a small task server on the embedded device. These
 features will not be used in this project as the microcontroller will serve a
 slightly different purpose, namely serve as a task executioner instead of a
 server. The bytecode compilation also adds a class that represents all things
 compilable in bytecode to make sure all the basic types can be compiled. Both
-signatures are shown in Listing~\ref{lst:bytecode}.
+signatures are shown in Listing~\ref{lst:bytecode}. We only use a subset of the
+original \mTask{} definitions because we do not use the functionality for
+managing tasks.
+
+\subsection{Classes}
+To make the DSL easily extendable with functionality without losing
+extendability of views it as a set of classes that can be implemented by any
+data type. 
+
+Arithmetic operations and boolean operators are defined respectively in the
+\CI{arith} and \CI{boolExpr} class. Note that the functions defined by the
+class have some restrictions for specific views. This is basically the
+translation from Clean basic type to the representation in the data type.
+
+\begin{lstlisting}[language=Clean,label={lst:arith}]
+class arith v where
+       lit :: t -> v t Expr | toCode t & toByteCode t
+       (+.) infixl 6 :: (v t p) (v t q) -> v t Expr | type, +, zero t & isExpr p & isExpr q
+       (-.) infixl 6 :: (v t p) (v t q) -> v t Expr | type, -, zero t & isExpr p & isExpr q
+       (*.) infixl 7 :: (v t p) (v t q) -> v t Expr | type, *, zero, one t & isExpr p & isExpr q
+       (/.) infixl 7 :: (v t p) (v t q) -> v t Expr | type, / t & isExpr p & isExpr q
+
+class boolExpr v where
+       (&.) infixr 3 :: (v Bool p) (v Bool q) -> v Bool Expr | isExpr p & isExpr q
+       (|.) infixr 2 :: (v Bool p) (v Bool q) -> v Bool Expr | isExpr p & isExpr q
+       Not :: (v Bool p) -> v Bool Expr | isExpr p
+       (==.) infix 4 :: (v a p) (v a q) -> v Bool Expr | ==, toCode a & isExpr p & isExpr q
+       (!=.) infix 4 :: (v a p) (v a q) -> v Bool Expr | ==, toCode a & isExpr p & isExpr q
+       (<.) infix 4 :: (v a p) (v a q) -> v Bool Expr | <, Ord,  toCode a & isExpr p & isExpr q
+       (>.) infix 4 :: (v a p) (v a q) -> v Bool Expr | <, Ord,  toCode a & isExpr p & isExpr q
+       (<=.) infix 4 :: (v a p) (v a q) -> v Bool Expr | <, Ord,  toCode a & isExpr p & isExpr q
+       (>=.) infix 4 :: (v a p) (v a q) -> v Bool Expr | <, Ord,  toCode a & isExpr p & isExpr q
+\end{lstlisting}
+
 
 In the future a state will probably need to be added to the \CI{Bytecode}
 type to keep track of some information during bytecode compilation.