X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;ds=inline;f=mTaskInterpret.dcl;h=f853c651649678d14f91c491d56593f68fa4f046;hb=ff7049a99f7fdd701d49222019df65a9aee8f05a;hp=0deb6652f642afca08fbda26c3635ff72a81ecd0;hpb=93cabbcd5d18b7b45d6f43a6ff39f94cfcb95522;p=mTask.git diff --git a/mTaskInterpret.dcl b/mTaskInterpret.dcl index 0deb665..f853c65 100644 --- a/mTaskInterpret.dcl +++ b/mTaskInterpret.dcl @@ -5,10 +5,37 @@ from Control.Monad.State import :: State, :: StateT from Data.Monoid import class Semigroup, class Monoid import mTask +:: MTaskMSGRecv + = MTTaskAck Int + | MTTaskDelAck Int + | MTSDSAck Int + | MTSDSDelAck Int + | MTPub Int String + | MTMessage String + | MTEmpty + +:: MTaskMSGSend + = MTTask MTaskInterval String + | MTTaskDel Int + | MTSds Int String + | MTUpd Int String + +:: MTaskInterval + = OneShot + | OnInterval Int + | OnInterrupt Int + +instance toString MTaskInterval +instance toString MTaskMSGRecv +instance toString MTaskMSGSend +encode :: MTaskMSGSend -> String +decode :: String -> MTaskMSGRecv + :: BC = BCNop | BCLab Int - | BCPush [Char] +// | E.e: BCPush e & toByteCode e + | BCPush String | BCPop //SDS functions | BCSdsStore Int @@ -34,6 +61,9 @@ import mTask | BCJmp Int | BCJmpT Int | BCJmpF Int + //UserLED + | BCLedOn UserLED + | BCLedOff UserLED //Serial | BCSerialAvail | BCSerialPrint @@ -47,34 +77,45 @@ import mTask | BCDigitalWrite Pin | BCTest AnalogPin +derive gPrint BC +derive class gCons BC + :: ByteCode a p = BC (BCState -> ([BC], BCState)) instance Semigroup (ByteCode a p) instance Monoid (ByteCode a p) +:: BCShare = { + sdsi :: Int, + sdspub :: Bool, + sdsval :: String + } + :: BCState = { freshl :: [Int], freshs :: [Int], - sdss :: [(Int, [Char])] + sdss :: [BCShare] } instance zero BCState -class toByteCode a :: a -> [Char] -instance toByteCode Int -instance toByteCode Bool -instance toByteCode Char -instance toByteCode String -instance toByteCode Long -instance toByteCode Button +class toByteCode a :: a -> String +class fromByteCode a :: String -> a +class mTaskType a | toByteCode, fromByteCode, zero a + +instance toByteCode Int, Bool, Char, Long, String, Button, UserLED +instance fromByteCode Int, Bool, Char, Long, String, Button, UserLED +instance toByteCode MTaskInterval +instance fromByteCode MTaskInterval instance toChar Pin instance arith ByteCode instance boolExpr ByteCode instance analogIO ByteCode instance digitalIO ByteCode +instance userLed ByteCode instance If ByteCode Stmt Stmt Stmt +instance If ByteCode e Stmt Stmt instance If ByteCode Stmt e Stmt -instance If ByteCode Stmt Stmt e -instance If ByteCode x y Expr +instance If ByteCode x y Stmt instance IF ByteCode instance noOp ByteCode @@ -83,9 +124,9 @@ instance assign ByteCode instance seq ByteCode instance serial ByteCode -getSDSBytes :: BCState -> String -getTaskBytes :: Int String -> String +toMessages :: MTaskInterval (String, BCState) -> ([MTaskMSGSend], BCState) +toSDSUpdate :: Int Int -> [MTaskMSGSend] -toByteVal :: BC -> [Char] +toByteVal :: BC -> String toReadableByteCode :: (ByteCode a b) -> (String, BCState) -toRealByteCode :: (ByteCode a b) -> (String, BCState) +toRealByteCode :: (ByteCode a b) BCState -> (String, BCState)