Added some code to allocate a mobile before a dereferenced input

This commit is contained in:
Neil Brown 2009-03-22 18:28:19 +00:00
parent 20f2fb2c14
commit d12d630de1

View File

@ -1010,7 +1010,20 @@ cgenInputItem c (A.InCounted m cv av)
call genBytesIn m subT (Right av)
tell [");"]
cgenInputItem c (A.InVariable m v)
= do t <- astTypeOf v
= do case v of
-- If we are reading into a dereferenced mobile, we must make sure
-- that something is in that mobile first:
A.DerefVariable _ v' -> do
tell ["if ("]
call genVariable v' A.Original
tell ["==NULL){"]
call genVariable v' A.Original
tell ["="]
t <- astTypeOf v'
call genAllocMobile m t Nothing
tell [";}"]
_ -> return ()
t <- astTypeOf v
isMobile <- isMobileType t
let rhs = genDest v
case (t, isMobile) of