repositories
/
mTask.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
884b2d1
)
sds thing
author
Mart Lubbers
<mart@martlubbers.net>
Fri, 16 Dec 2016 16:23:41 +0000
(17:23 +0100)
committer
Mart Lubbers
<mart@martlubbers.net>
Fri, 16 Dec 2016 16:23:41 +0000
(17:23 +0100)
mTaskInterpret.icl
patch
|
blob
|
history
diff --git
a/mTaskInterpret.icl
b/mTaskInterpret.icl
index
993fa74
..
ab86aed
100644
(file)
--- a/
mTaskInterpret.icl
+++ b/
mTaskInterpret.icl
@@
-21,7
+21,7
@@
from Text import class Text(concat,join,toUpperCase), instance Text String
toByteVal :: BC -> [Char]
toByteVal b
toByteVal :: BC -> [Char]
toByteVal b
-# bt = to
BC b
+# bt = to
Char $ consIndex{|*|} b + 1
= [bt:case b of
(BCPush i) = i
(BCAnalogRead i) = [toChar i]
= [bt:case b of
(BCPush i) = i
(BCAnalogRead i) = [toChar i]
@@
-32,8
+32,6
@@
toByteVal b
(BCJmpT i) = [toChar i]
(BCJmpF i) = [toChar i]
_ = []]
(BCJmpT i) = [toChar i]
(BCJmpF i) = [toChar i]
_ = []]
- where
- toBC b = toChar $ consIndex{|*|} b + 1
instance Semigroup (ByteCode a p) where
mappend m n = BC \s->let (b1, (b2, t)) = runBC m <$> runBC m s in (b1 ++ b2, t)
instance Semigroup (ByteCode a p) where
mappend m n = BC \s->let (b1, (b2, t)) = runBC m <$> runBC m s in (b1 ++ b2, t)
@@
-65,7
+63,7
@@
instance toChar Pin where
toChar (Digital p) = toChar $ consIndex{|*|} p + 1
toChar (Analog p) = toChar $ consIndex{|*|} p + 1
toChar (Digital p) = toChar $ consIndex{|*|} p + 1
toChar (Analog p) = toChar $ consIndex{|*|} p + 1
-derive gPrint BC, AnalogPin, Pin, DigitalPin
+derive gPrint BC, AnalogPin, Pin, DigitalPin
, BCState
derive consIndex BC, Pin, Button
derive consName BC, Pin, Button
derive consIndex BC, Pin, Button
derive consName BC, Pin, Button
@@
-117,15
+115,18
@@
withSDS f = BC \s->let [fresh:fs] = s.freshs
in runBC (f fresh) {s & freshs=fs}
instance sds ByteCode where
in runBC (f fresh) {s & freshs=fs}
instance sds ByteCode where
-// sds f = {main = withSDS \sds->
-// let (v In body) = f sds
-// in retrn [BCSdsStore sds]
-// }
- sds f = abort "undef on sds"
+ sds f = {main = withSDS \sds->
+ let (v In body) = f $ retrn [BCSdsStore sds]
+ in unMain body <++> retrn [BCSdsStore sds]
+ }
con f = undef
instance assign ByteCode where
con f = undef
instance assign ByteCode where
- (=.) v e = e <++> v
+ (=.) v e = e <++> abort (printToString $ fst $ runBC v zero)
+
+instance seq ByteCode where
+ (>>=.) _ _ = abort "undef on >>=."
+ (:.) x y = x <++> y
instance serial ByteCode where
serialAvailable = retrn [BCSerialAvail]
instance serial ByteCode where
serialAvailable = retrn [BCSerialAvail]
@@
-161,7
+162,9
@@
Start :: String
Start = toReadableByteCode $ unMain bc
where
bc :: Main (ByteCode Int Expr)
Start = toReadableByteCode $ unMain bc
where
bc :: Main (ByteCode Int Expr)
- bc = sds \x=46 In {main = x =. x +. lit 31}
+ bc = sds \x=46 In
+ sds \y=46 In
+ {main = y =. x +. y}
//to16bit :: Int -> String
//to16bit i = toString (toChar (i/265)) +++ toString (toChar (i rem 265))
//to16bit :: Int -> String
//to16bit i = toString (toChar (i/265)) +++ toString (toChar (i rem 265))