started with interpret and bytecode classes
[mTask.git] / mTaskSimulation.icl
index 180d7e1..3a94811 100644 (file)
@@ -5,7 +5,7 @@ import gdynamic, gCons, GenEq, StdMisc, StdArray
 import mTask
 
 eval :: (Main (Eval t p)) -> [String] | toString t
-eval {main=(E f)} = [toString (fst (f Rd state0))]
+eval {main=(E f)} = [toString (fst (f Rd zero))]
 
 :: State = 
   { tasks :: [(Int, State->State)]
@@ -16,8 +16,8 @@ eval {main=(E f)} = [toString (fst (f Rd state0))]
   , millis:: Int
   }
 
-state0 :: State
-state0 = {store = [], tasks = [], serial = [], millis = 0, dpins = [] , apins = []}
+instance zero State where
+       zero = {store = [], tasks = [], serial = [], millis = 0, dpins = [] , apins = []}
 
 //:: TaskSim :== (Int, State->State)
 :: Eval t p = E ((ReadWrite t) State -> (t, State))
@@ -153,7 +153,7 @@ instance writePinD AnalogPin where
 derive class iTask DigitalPin, AnalogPin, Dyn, StateInterface, DisplayVar, Pin
 
 simulate :: (Main (Eval a p)) -> Task ()
-simulate {main=(E f)} = setup state0 where
+simulate {main=(E f)} = setup zero where
   setup s =
          updateInformation "State" [] (toView s)
          >>* [ OnAction ActionFinish (always shutDown)
@@ -164,7 +164,7 @@ simulate {main=(E f)} = setup state0 where
          updateInformation "State" [] (toView s)
          >>* [ OnAction ActionFinish (always shutDown)
            , OnAction (Action "clear serial" []) (always (simloop {s & serial = []}))
-           , OnAction ActionNew (always (setup state0))
+           , OnAction ActionNew (always (setup zero))
            : if (isEmpty s.tasks)
                []
                [OnAction (Action "loop" []) (hasValue