X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=mTaskInterpret.icl;h=dca53d44eb9b0f53f34686ae6c3f54c097b60d11;hb=3698f150b0c5e5ebed23b0885ced2711ef16d9f5;hp=0ab4508c6fbf006aa1aa48b6cf5aad5c212af3fc;hpb=8449be73c124cdccd37500c0d67d9404b94fc9c8;p=mTask.git diff --git a/mTaskInterpret.icl b/mTaskInterpret.icl index 0ab4508..dca53d4 100644 --- a/mTaskInterpret.icl +++ b/mTaskInterpret.icl @@ -27,6 +27,7 @@ encode (MTSds i v) = "s" +++ to16bit i +++ v +++ "\n" encode (MTTask to data) = "t" +++ to16bit to +++ to16bit (size data) +++ data +++ "\n" encode (MTUpd i v) = "u" +++ to16bit i +++ v +++ "\n" +import StdDebug decode :: String -> MTaskMSGRecv decode x | size x == 0 = MTEmpty @@ -34,6 +35,7 @@ decode x '\0' = MTEmpty '\n' = MTEmpty 'm' = MTMessage x + 't' = MTTaskAdded (from16bit (x % (1,3))) 'u' = MTPub (from16bit (x % (1,3))) (x % (3,5)) _ = MTMessage x//abort ("Didn't understand message: " +++ join " " [toString (toInt c)\\c<-: x] +++ "\n") @@ -50,6 +52,7 @@ instance toString MTaskMSGSend where instance toString MTaskMSGRecv where toString (MTPub i v) = "Publish id: " +++ toString i +++ " value " +++ safePrint v + toString (MTTaskAdded i) = "Task added with id: " +++ toString i toString MTEmpty = "Empty message" bclength :: BC -> Int @@ -69,7 +72,7 @@ bclength _ = 1 toByteVal :: BC -> [Char] toByteVal b -# bt = toChar $ consIndex{|*|} b + 1 +# bt = toChar $ consIndex{|*|} b = [bt:case b of (BCPush i) = i (BCLab i) = [toChar i] @@ -159,7 +162,7 @@ BCIfStmt b t e = b <++> retrn [BCJmpF else] <++> t <++> retrn [BCJmp endif,BCLab else] <++> e <++> retrn [BCLab endif] -instance noOp ByteCode where noOp = mempty +instance noOp ByteCode where noOp = retrn [BCNop] withLabel :: (Int -> (ByteCode b q)) -> ByteCode b q withLabel f = BC \s->let [fresh:fs] = s.freshl