Commit 77d47f7f authored by Katharina Brandl's avatar Katharina Brandl
Browse files

renaming in Memory

parent 22fc028f
......@@ -54,16 +54,22 @@ instance ArrowTrans MemoryT where
instance (ArrowChoice c, Profunctor c) => ArrowMemory Word32 (Vector Word8) (MemoryT c) where
type Join y (MemoryT c) = ()
memread (MemoryT sCont) (MemoryT eCont) = MemoryT $ proc (index,addr,size,x) -> do
memread (MemoryT sCont) (MemoryT eCont) = MemoryT $ proc (memIndex,addr,size,x) -> do
let addrI = fromIntegral addr
mems <- get -< ()
let (MemInst _ vec) = mems ! index
case (addrI+size <= length vec) of
True -> do
let content = Vec.slice addrI size vec
sCont -< (content,x)
False -> do
eCont -< x
let (MemInst _ vec) = mems ! memIndex
if (addrI+size <= length vec)
then do
let bytes = Vec.slice addrI size vec
sCont -< (bytes,x)
else
eCont -< x
-- case (addrI+size <= length vec) of
-- True -> do
-- let content = Vec.slice addrI size vec
-- sCont -< (content,x)
-- False -> do
-- eCont -< x
memstore (MemoryT sCont) (MemoryT eCont) = MemoryT $ proc (index,addr, content, x) -> do
let addrI = fromIntegral addr
......
......@@ -44,6 +44,36 @@
call $fac-rec
i64.mul)))
(func (export "fac-iter") (param i64) (result i64) (local i64 i64)
get_local 0
set_local 1
i64.const 1
set_local 2
(block
(loop
get_local 1
i64.const 0
i64.eq
(if
(then
br 2)
(else
get_local 1
get_local 2
i64.mul
set_local 2
get_local 1
i64.const 1
i64.sub
set_local 1
)
)
br 0
)
)
get_local 2
)
(func (export "half-fac") (param i32) (result i32)
(if (result i32) (i32.eq (get_local 0) (i32.const 0))
(then (i32.const 1))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment