Stopped mobile arrays being allocated after declaration (with random size!)

This commit is contained in:
Neil Brown 2009-03-23 15:56:04 +00:00
parent 919781eabc
commit e8fec8585b

View File

@ -1278,10 +1278,12 @@ cdeclareInit m rt@(A.Record _) var
initField :: A.Type -> A.Variable -> CGen ()
initField t v = do fdeclareInit <- fget declareInit
doMaybe $ fdeclareInit m t v
cdeclareInit m t@(A.Mobile _) var
cdeclareInit m t@(A.Mobile t') var
= Just $ do call genVariableUnchecked var A.Original
tell ["=NULL;"]
call genAssign m [var] $ A.ExpressionList m [A.AllocMobile m t Nothing]
case t' of
A.Array {} -> return ()
_ -> call genAssign m [var] $ A.ExpressionList m [A.AllocMobile m t Nothing]
cdeclareInit _ _ _ = Nothing
-- | Free a declared item that's going out of scope.