tests
[mTask.git] / mTaskInterpret.icl
index eecea1d..52d7fd4 100644 (file)
@@ -1,10 +1,17 @@
 implementation module mTaskInterpret
 
-import iTasks
+//import iTasks
 import gdynamic, gCons, GenEq, StdMisc, StdArray
 import GenPrint
 import mTask
 
+from StdFunc import o
+import StdTuple
+import Data.Tuple
+import Control.Monad
+import Control.Monad.State
+from Data.Func import $
+
 
 toByteVal :: BC -> String
 toByteVal a = undef
@@ -14,19 +21,28 @@ derive gPrint BC
 toReadableByteVal :: BC -> String
 toReadableByteVal a = printToString a
 
+//:: ByteCode a p = BC (BCState -> ([BC], BCState))
 instance arith ByteCode where
-  lit _ = undef
-  (+.) _ _ = undef
-  (-.) _ _ = undef
-  (*.) _ _ = undef
-  (/.) _ _ = undef
+       lit a = BC \_ s->([BCPush $ toCode a], s)
+       (+.) _ _ = undef
+       (-.) _ _ = undef
+       (*.) _ _ = undef
+       (/.) _ _ = undef
 
 instance serial ByteCode where
-  serialAvailable = undef
-  serialPrint _ = undef
-  serialPrintln _ = undef
-  serialRead = undef
-  serialParseInt = undef
-
-Start :: Main (ByteCode Int Expr)
-Start = {main=serialPrint (lit 36)}
+       serialAvailable = undef
+       serialPrint _ = undef
+       serialPrintln _ = undef
+       serialRead = undef
+       serialParseInt = undef
+
+instance zero BCState where
+       zero = {a=()}
+
+runByteCode :: (ByteCode Int Expr) BCState -> [BC]
+runByteCode (BC f) s = fst (f Rd s)
+
+//Start :: Main (ByteCode Int Expr)
+Start :: [BC]
+//Start :: ByteCode Int Expr
+Start = runByteCode (lit 36) zero