From: Mart Lubbers Date: Mon, 21 Nov 2016 18:38:09 +0000 (+0100) Subject: Started generating real bytecode X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=affe94d7d6708fa81a70cae47277cea2a45ee790;p=mTask.git Started generating real bytecode --- diff --git a/mTaskInterpret.icl b/mTaskInterpret.icl index 6c9fd52..9a51e0c 100644 --- a/mTaskInterpret.icl +++ b/mTaskInterpret.icl @@ -14,10 +14,10 @@ import StdTuple import Data.Tuple import StdList from Data.Func import $ -from Text import class Text(join,toUpperCase), instance Text String +from Text import class Text(concat,join,toUpperCase), instance Text String toByteVal :: BC -> String -toByteVal a = undef +toByteVal a = toString $ toChar $ consIndex{|*|} a derive gPrint BC, AnalogPin derive consIndex BC @@ -84,22 +84,14 @@ instance serial ByteCode where instance zero BCState where zero = {a=()} +toRealByteCode :: (ByteCode a Expr) -> String +toRealByteCode (BC x) = concat $ map toByteVal x + //Start :: ByteCode Int Expr //Start = (lit 36 +. lit 42) +. lit 84 //Run test programma en pretty print -Start :: ByteCode Int Expr -Start = If (lit True) (analogRead A1) (analogRead A0) +Start = toRealByteCode $ If (lit True) (analogRead A1) (analogRead A0) +//Start :: ByteCode Int Expr +//Start = If (lit True) (analogRead A1) (analogRead A0) //Start = If ((lit 36) ==. (lit 42)) (noOp) (noOp) - -//Generate header file -//Start w -//# (io, w) = stdio w -//# io = io <<< "#ifndef MTASK_H\n#define MTASK_H\n" -//# io = io <<< join "\n" ["#define " <+ toUpperCase (consName{|*|} x) <+ " " <+ consIndex{|*|} x\\x<-allBC] -// with -// allBC :: [BC] -// allBC = conses{|*|} -//# (ok, w) = fclose (io <<< "\n#endif\n") w -//| not ok = abort "Couldn't close stdio" -//= w