Refactored some of the tested functions in the C and C++ backends to use genSizeSuffix rather than using _sizes/.extent directly

This commit is contained in:
Neil Brown 2007-10-04 00:07:15 +00:00
parent 366504c301
commit b8556bfe6d
2 changed files with 6 additions and 3 deletions

View File

@ -62,6 +62,7 @@ instance Die CGen where
-- These are in a structure so that we can reuse operations in other
-- backends without breaking the mutual recursion.
data GenOps = GenOps {
-- | Declares the C array of sizes for an occam array.
declareArraySizes :: GenOps -> [A.Dimension] -> A.Name -> CGen (),
declareFree :: GenOps -> Meta -> A.Type -> A.Variable -> Maybe (CGen ()),
declareInit :: GenOps -> Meta -> A.Type -> A.Variable -> Maybe (CGen ()),
@ -784,11 +785,12 @@ cgenArraySubscript ops checkValid v es
call genExpression ops e
tell [","]
call genVariable ops v
tell ["_sizes[", show sub, "],"]
call genSizeSuffix ops (show sub)
tell [","]
genMeta (findMeta e)
tell [")"]
else call genExpression ops e
genChunks = [call genVariable ops v >> tell ["_sizes[", show i, "]"] | i <- subs]
genChunks = [call genVariable ops v >> call genSizeSuffix ops (show i) | i <- subs]
--}}}
--{{{ expressions

View File

@ -1166,7 +1166,8 @@ cppgenArraySubscript ops checkValid v es
call genExpression ops e
tell [","]
call genVariable ops v
tell [".extent(", show sub, "),"]
call genSizeSuffix ops (show sub)
tell [","]
genMeta (findMeta e)
tell [")"]
else call genExpression ops e