add return statement and todo
authorMart Lubbers <mart@martlubbers.net>
Thu, 11 May 2017 12:54:42 +0000 (14:54 +0200)
committerMart Lubbers <mart@martlubbers.net>
Thu, 11 May 2017 12:54:42 +0000 (14:54 +0200)
client/interpret.c
client/mTaskSymbols.h
mTask.dcl
mTaskInterpret.dcl
mTaskInterpret.icl
mTaskMakeSymbols.icl
todo.txt

index 92e58d1..0f65888 100644 (file)
@@ -162,6 +162,10 @@ void run_task(struct task *t)
                        sp--;
                        break;
 #endif
+               case BCRETURN: trace("Return");
+                       pc = plen;
+                       t = stack[sp-1];
+                       break;
                default:
                        trace("unrecognized");
                        die("Unrecognized command: %d", program[pc-1]);
index 57959af..7532067 100644 (file)
@@ -34,5 +34,5 @@
 #define BCANALOGWRITE 31
 #define BCDIGITALREAD 32
 #define BCDIGITALWRITE 33
-#define BCTEST 34
+#define BCRETURN 34
 #endif
index b1510af..9eb93da 100644 (file)
--- a/mTask.dcl
+++ b/mTask.dcl
@@ -94,6 +94,8 @@ class sds v where
 class seq v where
   (>>=.) infixr 0 :: (v t p) ((v t Expr) -> (v u q)) -> (v u Stmt) | type t & type u
   (:.) infixr 0 :: (v t p) (v u q) -> v u Stmt | type t & type u
+class retrn v where
+  retrn :: (v t p) -> (v t Stmt) | type t
 class step` v where
     (>>*.) infixl 1 :: (v t p) ((v t Expr) -> [Step v u]) -> v u Stmt | type t & type u
 :: Step v t = E.p.q: Cond (v Bool q) (v t p) | E.p: Ever (v t p)
index 578d335..8f4bd40 100644 (file)
@@ -91,7 +91,8 @@ decode :: String -> MTaskMSGRecv
        | BCAnalogWrite Pin
        | BCDigitalRead Pin
        | BCDigitalWrite Pin
-       | BCTest AnalogPin
+       //Return
+       | BCReturn
 
 derive gPrint BCValue, MTaskDeviceSpec
 derive consIndex BCValue
@@ -143,6 +144,7 @@ instance If ByteCode Stmt e Stmt
 instance If ByteCode x y Stmt
 instance IF ByteCode
 instance noOp ByteCode
+instance retrn ByteCode
 
 instance sds ByteCode
 instance assign ByteCode
index 27d4c43..c81476a 100644 (file)
@@ -282,6 +282,9 @@ instance userLed ByteCode where
        ledOn  (BC l) = BC $ l >>| tell [BCLedOn]
        ledOff (BC l) = BC $ l >>| tell [BCLedOff]
 
+instance retrn ByteCode where
+  retrn (BC l) = BC $ tell [BCReturn]
+
 instance zero BCState where
        zero = {freshl=[1..], freshs=[1..], sdss=[]}
 
index 6781ce8..fc1fe5e 100644 (file)
@@ -20,6 +20,9 @@ from Data.Func import $
 import Data.List
 from Text import class Text(join,toUpperCase), instance Text String
 
+derive consName BC
+derive conses BC
+
 (<+) infixr 5 :: a b -> String | toString a & toString b
 (<+) a b = toString a +++ toString b
 
index 4647ddd..030fb00 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -1,2 +1,3 @@
 delete tasks when deleting device
 let tasks have a unique name
+check addition and equality for numbers and bools