X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=mTaskInterpret.icl;h=52d7fd40666bb7ccd2a0168214eafeef8d5ac4a3;hb=7a67ef5e2af69cb14011be201fe67f755b91a788;hp=eecea1d7612ca5b3d0d9d03c97a02cd204555695;hpb=34dfa724f02cd36ff31057ab71ba53ad57fabcb5;p=mTask.git diff --git a/mTaskInterpret.icl b/mTaskInterpret.icl index eecea1d..52d7fd4 100644 --- a/mTaskInterpret.icl +++ b/mTaskInterpret.icl @@ -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