Fixed a bug relating to not initialising C channel arrays properly (an over-enthusiastic trimming earlier)

This commit is contained in:
Neil Brown 2008-03-08 13:42:36 +00:00
parent 10effbf8f5
commit e1fd001322
2 changed files with 11 additions and 4 deletions

View File

@ -230,12 +230,15 @@ cgenOverArray m var func
tell ["=0;"]
call genVariable i
tell ["<"]
call genVariable var
call genSizeSuffix (show v)
case d of
A.UnknownDimension ->
do call genVariable var
call genSizeSuffix (show v)
A.Dimension n -> tell [show n]
tell [";"]
call genVariable i
tell ["++){"]
| (v :: Integer, i) <- zip [0..] indices]
| (v :: Integer, i, d) <- zip3 [0..] indices ds]
p
sequence_ [tell ["}"] | _ <- indices]
Nothing -> return ()
@ -1126,6 +1129,9 @@ cdeclareInit m t@(A.Array ds t') var _
sequence_ $ intersperse (tell ["*"]) [case dim of A.Dimension d -> tell [show d] | dim <- ds]
tell [");"]
_ -> return ()
fdeclareInit <- fget declareInit
init <- return (\sub -> fdeclareInit m t' (sub var) Nothing)
call genOverArray m var init
cdeclareInit m rt@(A.Record _) var _
= Just $ do fs <- recordFields m rt
sequence_ [initField t (A.SubscriptedVariable m (A.SubscriptField m n) var)

View File

@ -370,6 +370,7 @@ testArraySlice = TestList
checkSlice s e sub = "occam_check_slice(" ++ s ++ "," ++ e ++ "," ++ sub ++ "," ++ m ++ ")"
-- TODO fix this test so that it tests fixed dimensions properly
testOverArray :: Test
testOverArray = TestList $ map testOverArray'
[(cSize,cIndex,"", cgenOps)
@ -491,7 +492,7 @@ testDeclareInitFree = TestLabel "testDeclareInitFree" $ TestList
-- Records containing an array:
,testAllR 101 ("","") ("","") (A.Array [A.Dimension 4,A.Dimension 5] A.Int) id
-- Arrays of records containing an array:
,testAllRA 200 ("^^","") ("^^","") (A.Array [A.Dimension 4,A.Dimension 5] A.Int) id
,testAllRA 200 ("^^","") ("","") (A.Array [A.Dimension 4,A.Dimension 5] A.Int) id
-- Mobile versions
,testAllSame 1003 ("","") $ A.Mobile $ A.Array [A.Dimension 4] A.Int