From affe94d7d6708fa81a70cae47277cea2a45ee790 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Mon, 21 Nov 2016 19:38:09 +0100 Subject: [PATCH] Started generating real bytecode --- mTaskInterpret.icl | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) 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 -- 2.20.1