You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is currently possible to e.g. make an array of references, but this doesn't do the right thing when generating code. The array will contain the values of the references, not the references themselves.
Example:
import qualified Prelude
import Feldspar
import Feldspar.Mutable
import Feldspar.Compiler
import Feldspar.SimpleVector
test x = runMutable $ do
r1 <- newRef 1
r2 <- newRef 2
let arr :: Vector (Ref (Data Int32))
arr = save $ indexed x $ \i -> (i<1) ? r1 $ r2
setRef (arr ! 0) 33
getRef $ arr ! 0
The code generator (wrongly?) assumes that references and arrays can be treated as imperative variables inside a runMutable.
Obviously, that assumption does not hold when references are stored or returned outside the context.
Having slept on this I think the code appears fishy in more than one way. The storage in the array should be at(int32_t,e8,v3) = &v1. Are we missing a AddrOf somewhere in fromCore?
The variable e8 is an array of int32_t and not int32_t*.
However, it is not straightforward to change the type. We need to be careful that references does not escape the mutable context. Maybe it is time to change Mut from IO to ST s.
(Copied from #144@feldspar-language.)
It is currently possible to e.g. make an array of references, but this doesn't do the right thing when generating code. The array will contain the values of the references, not the references themselves.
Example:
Generated code:
The assignment
v7 = 33
doesn't update the original referencev1
.The text was updated successfully, but these errors were encountered: