improve install script, add debug to the linux client, update jenkins behaviour
[mTask.git] / mTaskInterpret.dcl
1 definition module mTaskInterpret
2
3 from Data.Functor.Identity import :: Identity
4 from Control.Monad.State import :: State, :: StateT
5 from Data.Monoid import class Semigroup, class Monoid
6 import mTask
7
8 :: MTaskMSGRecv
9 = MTTaskAck Int
10 | MTTaskDelAck Int
11 | MTSDSAck Int
12 | MTSDSDelAck Int
13 | MTPub Int String
14 | MTMessage String
15 | MTEmpty
16
17 :: MTaskMSGSend
18 = MTTask Int String
19 | MTSds Int String
20 | MTUpd Int String
21
22 instance toString MTaskMSGRecv
23 instance toString MTaskMSGSend
24 encode :: MTaskMSGSend -> String
25 decode :: String -> MTaskMSGRecv
26
27 :: BC
28 = BCNop
29 | BCLab Int
30 | BCPush [Char]
31 | BCPop
32 //SDS functions
33 | BCSdsStore Int
34 | BCSdsFetch Int
35 | BCSdsPublish Int
36 //Unary ops
37 | BCNot
38 //Binary Int ops
39 | BCAdd
40 | BCSub
41 | BCMul
42 | BCDiv
43 //Binary Bool ops
44 | BCAnd
45 | BCOr
46 | BCEq
47 | BCNeq
48 | BCLes
49 | BCGre
50 | BCLeq
51 | BCGeq
52 //Conditionals and jumping
53 | BCJmp Int
54 | BCJmpT Int
55 | BCJmpF Int
56 //UserLED
57 | BCLedOn [Char]
58 | BCLedOff [Char]
59 //Serial
60 | BCSerialAvail
61 | BCSerialPrint
62 | BCSerialPrintln
63 | BCSerialRead
64 | BCSerialParseInt
65 //Pins
66 | BCAnalogRead Pin
67 | BCAnalogWrite Pin
68 | BCDigitalRead Pin
69 | BCDigitalWrite Pin
70 | BCTest AnalogPin
71
72 :: ByteCode a p = BC (BCState -> ([BC], BCState))
73 instance Semigroup (ByteCode a p)
74 instance Monoid (ByteCode a p)
75
76 :: BCState = {
77 freshl :: [Int],
78 freshs :: [Int],
79 sdss :: [(Int, [Char])]
80 }
81 instance zero BCState
82
83 class toByteCode a :: a -> [Char]
84 instance toByteCode Int
85 instance toByteCode Bool
86 instance toByteCode Char
87 instance toByteCode String
88 instance toByteCode Long
89 instance toByteCode Button
90 instance toByteCode UserLED
91
92 instance toChar Pin
93 instance arith ByteCode
94 instance boolExpr ByteCode
95 instance analogIO ByteCode
96 instance digitalIO ByteCode
97 instance userLed ByteCode
98 //instance If ByteCode Stmt Stmt Stmt
99 //instance If ByteCode e Stmt Stmt
100 //instance If ByteCode Stmt e Stmt
101 instance If ByteCode x y Stmt
102 instance IF ByteCode
103 instance noOp ByteCode
104
105 instance sds ByteCode
106 instance assign ByteCode
107 instance seq ByteCode
108 instance serial ByteCode
109
110 //pub :: (ByteCode a b) -> ByteCode a b
111
112 toMessages :: Int (String, BCState) -> ([MTaskMSGSend], BCState)
113 toSDSUpdate :: Int Int -> [MTaskMSGSend]
114
115 toByteVal :: BC -> [Char]
116 toReadableByteCode :: (ByteCode a b) -> (String, BCState)
117 toRealByteCode :: (ByteCode a b) BCState -> (String, BCState)