Changed the C genOverArray function to pass the test, and removed the now-redundant C++ version
This commit is contained in:
parent
2b1603629f
commit
f3e15b6f78
|
@ -117,6 +117,7 @@ data GenOps = GenOps {
|
|||
genOutput :: GenOps -> A.Variable -> [A.OutputItem] -> CGen (),
|
||||
genOutputCase :: GenOps -> A.Variable -> A.Name -> [A.OutputItem] -> CGen (),
|
||||
genOutputItem :: GenOps -> A.Variable -> A.OutputItem -> CGen (),
|
||||
-- | Generates a loop that maps over every element in a (potentially multi-dimensional) array
|
||||
genOverArray :: GenOps -> Meta -> A.Variable -> (SubscripterFunction -> Maybe (CGen ())) -> CGen (),
|
||||
genPar :: GenOps -> A.ParMode -> A.Structured -> CGen (),
|
||||
genProcCall :: GenOps -> A.Name -> [A.Actual] -> CGen (),
|
||||
|
@ -306,18 +307,19 @@ cgenOverArray ops m var func
|
|||
let arg = (\var -> foldl (\v s -> A.SubscriptedVariable m s v) var [A.Subscript m $ A.ExprVariable m i | i <- indices])
|
||||
case func arg of
|
||||
Just p ->
|
||||
do sequence_ [do tell ["for (int "]
|
||||
do sequence_ [do tell ["for(int "]
|
||||
call genVariable ops i
|
||||
tell [" = 0; "]
|
||||
tell ["=0;"]
|
||||
call genVariable ops i
|
||||
tell [" < "]
|
||||
tell ["<"]
|
||||
call genVariable ops var
|
||||
tell ["_sizes[", show v, "]; "]
|
||||
call genSizeSuffix ops (show v)
|
||||
tell [";"]
|
||||
call genVariable ops i
|
||||
tell ["++) {\n"]
|
||||
tell ["++){"]
|
||||
| (v :: Integer, i) <- zip [0..] indices]
|
||||
p
|
||||
sequence_ [tell ["}\n"] | _ <- indices]
|
||||
sequence_ [tell ["}"] | _ <- indices]
|
||||
Nothing -> return ()
|
||||
|
||||
-- | Generate code for one of the Structured types.
|
||||
|
|
|
@ -113,7 +113,6 @@ cppgenOps = cgenOps {
|
|||
genOutput = cppgenOutput,
|
||||
genOutputCase = cppgenOutputCase,
|
||||
genOutputItem = cppgenOutputItem,
|
||||
genOverArray = cppgenOverArray,
|
||||
genPar = cppgenPar,
|
||||
genProcCall = cppgenProcCall,
|
||||
genSizeSuffix = cppgenSizeSuffix,
|
||||
|
@ -1173,33 +1172,6 @@ cppgenArraySubscript ops checkValid v es
|
|||
else call genExpression ops e
|
||||
--}}}
|
||||
|
||||
-- | Map an operation over every item of an occam array.
|
||||
--Changed from GenerateC because it uses the array sizes of Blitz++
|
||||
cppgenOverArray :: GenOps -> Meta -> A.Variable -> (SubscripterFunction -> Maybe (CGen ())) -> CGen ()
|
||||
cppgenOverArray ops m var func
|
||||
= do A.Array ds _ <- typeOfVariable var
|
||||
specs <- sequence [makeNonceVariable "i" m A.Int A.VariableName A.Original | _ <- ds]
|
||||
let indices = [A.Variable m n | A.Specification _ n _ <- specs]
|
||||
|
||||
let arg = (\var -> foldl (\v s -> A.SubscriptedVariable m s v) var [A.Subscript m $ A.ExprVariable m i | i <- indices])
|
||||
case func arg of
|
||||
Just p ->
|
||||
do sequence_ [do tell ["for (int "]
|
||||
call genVariable ops i
|
||||
tell [" = 0; "]
|
||||
call genVariable ops i
|
||||
tell [" < "]
|
||||
call genVariable ops var
|
||||
tell [".extent(", show v, "); "]
|
||||
call genVariable ops i
|
||||
tell ["++) {\n"]
|
||||
| (v :: Integer, i) <- zip [0..] indices]
|
||||
p
|
||||
sequence_ [tell ["}\n"] | _ <- indices]
|
||||
Nothing -> return ()
|
||||
|
||||
|
||||
|
||||
-- | Changed to remove array size:
|
||||
cppgenUnfoldedExpression :: GenOps -> A.Expression -> CGen ()
|
||||
cppgenUnfoldedExpression ops (A.Literal _ t lr)
|
||||
|
|
Loading…
Reference in New Issue
Block a user