.p
[mTask.git] / mTaskInterpret.icl
index d689b5f..6c9fd52 100644 (file)
@@ -22,7 +22,6 @@ toByteVal a = undef
 derive gPrint BC, AnalogPin
 derive consIndex BC
 derive consName BC
-derive conses BC, AnalogPin
 
 toReadableByteVal :: BC -> String
 toReadableByteVal a = printToString a
@@ -46,12 +45,16 @@ instance boolExpr ByteCode where
        (>=.) x y = x <++> y <+-> [BCGeq]
 
 instance analogIO ByteCode where
-       analogRead p = BC [BCAnalogRead p]
-       analogWrite p b = b <+-> [BCAnalogWrite p]
+       analogRead p = BC [BCAnalogRead $ toCode p]
+       analogWrite p b = b <+-> [BCAnalogWrite $ toCode p]
+
+instance digitalIO ByteCode where
+       digitalRead p = BC [BCDigitalRead $ toCode p]
+       digitalWrite p b = b <+-> [BCDigitalWrite $ toCode p]
 
 instance If ByteCode Stmt Stmt Stmt where If b t e = BCIfStmt b t e
 instance If ByteCode Stmt e Stmt where If b t e = BCIfStmt b t e
-//instance If ByteCode Stmt Stmt e where If b t e = BCIfStmt b t e
+instance If ByteCode Stmt Stmt e where If b t e = BCIfStmt b t e
 instance If ByteCode x y Expr where If b t e = BCIfStmt b t e
 instance IF ByteCode where
        IF b t e = BCIfStmt b t e
@@ -84,12 +87,9 @@ instance zero BCState where
 //Start :: ByteCode Int Expr
 //Start = (lit 36 +. lit 42) +. lit 84
 
-(<+) infixr 5 :: a b -> String | toString a & toString b
-(<+) a b = toString a +++ toString b
-
 //Run test programma en pretty print
 Start :: ByteCode Int Expr
-Start = analogRead A0
+Start = If (lit True) (analogRead A1) (analogRead A0)
 //Start = If ((lit 36) ==. (lit 42)) (noOp) (noOp)
 
 //Generate header file