update
[mTask.git] / mTaskInterpret.dcl
index 17034be..f853c65 100644 (file)
@@ -34,7 +34,8 @@ decode :: String -> MTaskMSGRecv
 :: BC
        = BCNop
        | BCLab Int
-       | BCPush [Char]
+//     | E.e: BCPush e & toByteCode e
+       | BCPush String
        | BCPop
        //SDS functions
        | BCSdsStore Int
@@ -61,8 +62,8 @@ decode :: String -> MTaskMSGRecv
        | BCJmpT Int
        | BCJmpF Int
        //UserLED
-       | BCLedOn [Char]
-       | BCLedOff [Char]
+       | BCLedOn UserLED
+       | BCLedOff UserLED
        //Serial
        | BCSerialAvail
        | BCSerialPrint
@@ -76,6 +77,9 @@ decode :: String -> MTaskMSGRecv
        | 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)
@@ -83,7 +87,7 @@ instance Monoid (ByteCode a p)
 :: BCShare = {
                sdsi :: Int,
                sdspub :: Bool,
-               sdsval :: [Char]
+               sdsval :: String
        }
 
 :: BCState = {
@@ -93,15 +97,14 @@ instance Monoid (ByteCode a p)
        }
 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
-instance toByteCode UserLED
-//instance toByteCode MTaskInterval
+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
@@ -109,9 +112,9 @@ 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 Stmt
+instance If ByteCode e Stmt Stmt
+instance If ByteCode Stmt e Stmt
 instance If ByteCode x y Stmt
 instance IF ByteCode
 instance noOp ByteCode
@@ -124,6 +127,6 @@ instance serial ByteCode
 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) BCState -> (String, BCState)