From 0d7dc6966d2f428cd7543708e220aa4315d64978 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Wed, 21 Dec 2016 20:44:17 +0100 Subject: [PATCH] fix bugs for uireorg --- mTask.dcl | 1 - mTaskCode.dcl | 2 +- mTaskCode.icl | 23 +++-------------------- mTaskSimulation.dcl | 3 +++ mTaskSimulation.icl | 31 ++++++++++++++++--------------- 5 files changed, 23 insertions(+), 37 deletions(-) diff --git a/mTask.dcl b/mTask.dcl index d71ba44..7d9e976 100644 --- a/mTask.dcl +++ b/mTask.dcl @@ -18,7 +18,6 @@ todo: import iTasks._Framework.Generic from iTasks._Framework.Task import :: Task import StdClass -from iTasks.API.Core.Types import :: Display import gdynamic, gCons, GenEq, StdMisc, StdArray import mTaskCode, mTaskSimulation, mTaskInterpret diff --git a/mTaskCode.dcl b/mTaskCode.dcl index 068de00..47aff54 100644 --- a/mTaskCode.dcl +++ b/mTaskCode.dcl @@ -98,7 +98,7 @@ instance noOp Code , iloop :: Int , includes :: [String] , def :: Def - , mode :: Mode + , mode` :: Mode , binds :: [String] } diff --git a/mTaskCode.icl b/mTaskCode.icl index 8402abe..6360b5a 100644 --- a/mTaskCode.icl +++ b/mTaskCode.icl @@ -352,23 +352,6 @@ instance analogIO Code where instance noOp Code where noOp = C \rw c.c :: Code a p = C ((ReadWrite (Code a Expr)) CODE -> CODE) -:: CODE = - { fresh :: Int - , freshMTask :: Int - , funs :: [String] - , ifuns :: Int - , vars :: [String] - , ivars :: Int - , setup :: [String] - , isetup :: Int - , loop :: [String] - , iloop :: Int - , includes :: [String] - , def :: Def - , mode :: Mode - , binds :: [String] - } - unC :: (Code a p) -> ((ReadWrite (Code a Expr)) CODE -> CODE) unC (C f) = f @@ -376,10 +359,10 @@ unC (C f) = f :: Mode = /*MainMode |*/ NoReturn | Return String | SubExp | Assign String setMode :: Mode -> Code a p -setMode m = C \rw c.{c & mode = m} +setMode m = C \rw c.{CODE|c & mode` = m} getMode :: (Mode -> Code a p) -> Code a p -getMode f = C \rw c.unC (f c.mode) rw c +getMode f = C \rw c.unC (f c.mode`) rw c embed :: (Code a p) -> Code a p embed e = @@ -608,7 +591,7 @@ newCode = , iloop = 4 , includes = [] , def = Setup - , mode = NoReturn + , mode` = NoReturn , binds = [] } diff --git a/mTaskSimulation.dcl b/mTaskSimulation.dcl index 5e502e2..525498f 100644 --- a/mTaskSimulation.dcl +++ b/mTaskSimulation.dcl @@ -2,6 +2,9 @@ definition module mTaskSimulation import mTask +:: Display a = Display a + +derive class iTask Display instance zero State` eval :: (Main (Eval t p)) -> [String] | toString t diff --git a/mTaskSimulation.icl b/mTaskSimulation.icl index 6fed084..d52fa9a 100644 --- a/mTaskSimulation.icl +++ b/mTaskSimulation.icl @@ -3,6 +3,7 @@ implementation module mTaskSimulation import iTasks import gdynamic, gCons, GenEq, StdMisc, StdArray import mTask +derive class iTask Display eval :: (Main (Eval t p)) -> [String] | toString t eval {main=(E f)} = [toString (fst (f Rd zero))] @@ -155,22 +156,22 @@ derive class iTask DigitalPin, AnalogPin, Dyn, StateInterface, DisplayVar, Pin simulate :: (Main (Eval a p)) -> Task () simulate {main=(E f)} = setup zero where setup s = - updateInformation "State" [] (toView s) - >>* [ OnAction ActionFinish (always shutDown) - , OnAction (Action "setup" []) (hasValue - (\si.simloop (snd (f Rd (mergeView s si))))) - ] + updateInformation "State" [] (toView s) @! () +// >>* [ OnAction ActionFinish (always shutDown) +// , OnAction (Action "setup" []) (hasValue +// (\si.simloop (snd (f Rd (mergeView s si))))) +// ] simloop s = - updateInformation "State" [] (toView s) - >>* [ OnAction ActionFinish (always shutDown) - , OnAction (Action "clear serial" []) (always (simloop {s & serial = []})) - , OnAction ActionNew (always (setup zero)) - : if (isEmpty s.tasks) - [] - [OnAction (Action "loop" []) (hasValue - \si.simloop (step` (mergeView s si))) - ] - ] + updateInformation "State" [] (toView s) @!() +// >>* [ OnAction ActionFinish (always shutDown) +// , OnAction (Action "clear serial" []) (always (simloop {s & serial = []})) +// , OnAction ActionNew (always (setup zero)) +// : if (isEmpty s.tasks) +// [] +// [OnAction (Action "loop" []) (hasValue +// \si.simloop (step` (mergeView s si))) +// ] +// ] toView :: State` -> StateInterface toView s = -- 2.20.1