Renamed one of the array functions in the function table to be clearer
This commit is contained in:
parent
01ac2ef21d
commit
60daa07b93
|
@ -67,7 +67,7 @@ cgenOps = GenOps {
|
||||||
genAlt = cgenAlt,
|
genAlt = cgenAlt,
|
||||||
genAllocMobile = cgenAllocMobile,
|
genAllocMobile = cgenAllocMobile,
|
||||||
genArrayLiteralElems = cgenArrayLiteralElems,
|
genArrayLiteralElems = cgenArrayLiteralElems,
|
||||||
genArraySize = cgenArraySize,
|
genArraySizeDecl = cgenArraySizeDecl,
|
||||||
genArraySizesLiteral = cgenArraySizesLiteral,
|
genArraySizesLiteral = cgenArraySizesLiteral,
|
||||||
genArrayStoreName = genName,
|
genArrayStoreName = genName,
|
||||||
genArraySubscript = cgenArraySubscript,
|
genArraySubscript = cgenArraySubscript,
|
||||||
|
@ -1003,7 +1003,7 @@ cgenSlice v@(A.SubscriptedVariable _ _ (A.Variable _ on)) start count ds
|
||||||
-- We need to disable the index check here because we might be taking
|
-- We need to disable the index check here because we might be taking
|
||||||
-- element 0 of a 0-length array -- which is valid.
|
-- element 0 of a 0-length array -- which is valid.
|
||||||
= (tell ["&"] >> call genVariableUnchecked v,
|
= (tell ["&"] >> call genVariableUnchecked v,
|
||||||
call genArraySize False
|
call genArraySizeDecl False
|
||||||
(do genLeftB
|
(do genLeftB
|
||||||
tell ["occam_check_slice("]
|
tell ["occam_check_slice("]
|
||||||
call genExpression start
|
call genExpression start
|
||||||
|
@ -1021,8 +1021,8 @@ cgenSlice v@(A.SubscriptedVariable _ _ (A.Variable _ on)) start count ds
|
||||||
genRightB
|
genRightB
|
||||||
))
|
))
|
||||||
|
|
||||||
cgenArraySize :: Bool -> CGen () -> A.Name -> CGen ()
|
cgenArraySizeDecl :: Bool -> CGen () -> A.Name -> CGen ()
|
||||||
cgenArraySize isPtr size n
|
cgenArraySizeDecl isPtr size n
|
||||||
= if isPtr
|
= if isPtr
|
||||||
then do tell ["const int*"]
|
then do tell ["const int*"]
|
||||||
genName n
|
genName n
|
||||||
|
@ -1052,7 +1052,7 @@ abbrevVariable am (A.Array _ _) v@(A.SubscriptedVariable _ (A.Subscript _ _) _)
|
||||||
genAASize (A.SubscriptedVariable _ (A.Subscript _ _) v) arg
|
genAASize (A.SubscriptedVariable _ (A.Subscript _ _) v) arg
|
||||||
= genAASize v (arg + 1)
|
= genAASize v (arg + 1)
|
||||||
genAASize (A.Variable _ on) arg
|
genAASize (A.Variable _ on) arg
|
||||||
= call genArraySize True
|
= call genArraySizeDecl True
|
||||||
(tell ["&"] >> genName on >> tell ["_sizes[", show arg, "]"])
|
(tell ["&"] >> genName on >> tell ["_sizes[", show arg, "]"])
|
||||||
genAASize (A.DirectedVariable _ _ v) arg
|
genAASize (A.DirectedVariable _ _ v) arg
|
||||||
= const $ call genMissing "Cannot abbreviate a directed variable as an array"
|
= const $ call genMissing "Cannot abbreviate a directed variable as an array"
|
||||||
|
@ -1064,7 +1064,7 @@ abbrevVariable am (A.Array ds _) v@(A.SubscriptedVariable m (A.SubscriptFrom _ s
|
||||||
abbrevVariable am (A.Array ds _) v@(A.SubscriptedVariable m (A.SubscriptFor _ count) _)
|
abbrevVariable am (A.Array ds _) v@(A.SubscriptedVariable m (A.SubscriptFor _ count) _)
|
||||||
= call genSlice v (makeConstant m 0) count ds
|
= call genSlice v (makeConstant m 0) count ds
|
||||||
abbrevVariable am (A.Array _ _) v
|
abbrevVariable am (A.Array _ _) v
|
||||||
= (call genVariable v, call genArraySize True (call genVariable v >> tell ["_sizes"]))
|
= (call genVariable v, call genArraySizeDecl True (call genVariable v >> tell ["_sizes"]))
|
||||||
abbrevVariable am (A.Chan {}) v
|
abbrevVariable am (A.Chan {}) v
|
||||||
= (call genVariable v, noSize)
|
= (call genVariable v, noSize)
|
||||||
abbrevVariable am (A.Record _) v
|
abbrevVariable am (A.Record _) v
|
||||||
|
@ -1106,7 +1106,7 @@ cgenRetypeSizes m destT destN srcT srcV
|
||||||
dieP m "genRetypeSizes expecting free dimension"
|
dieP m "genRetypeSizes expecting free dimension"
|
||||||
A.Dimension n -> tell [show n]
|
A.Dimension n -> tell [show n]
|
||||||
| d <- destDS]
|
| d <- destDS]
|
||||||
call genArraySize False (genLeftB >> seqComma dims >> genRightB) destN
|
call genArraySizeDecl False (genLeftB >> seqComma dims >> genRightB) destN
|
||||||
|
|
||||||
-- Not array; just check the size is 1.
|
-- Not array; just check the size is 1.
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -1181,7 +1181,7 @@ cgenFlatArraySize ds
|
||||||
-- | Declare an _sizes array for a variable.
|
-- | Declare an _sizes array for a variable.
|
||||||
cdeclareArraySizes :: A.Type -> A.Name -> CGen ()
|
cdeclareArraySizes :: A.Type -> A.Name -> CGen ()
|
||||||
cdeclareArraySizes t name
|
cdeclareArraySizes t name
|
||||||
= call genArraySize False (call genArraySizesLiteral name t) name
|
= call genArraySizeDecl False (call genArraySizesLiteral name t) name
|
||||||
|
|
||||||
-- | Generate a C literal to initialise an _sizes array with, where all the
|
-- | Generate a C literal to initialise an _sizes array with, where all the
|
||||||
-- dimensions are fixed.
|
-- dimensions are fixed.
|
||||||
|
|
|
@ -87,7 +87,7 @@ data GenOps = GenOps {
|
||||||
-- | Generates the given array element expressions as a flattened (one-dimensional) list of literals
|
-- | Generates the given array element expressions as a flattened (one-dimensional) list of literals
|
||||||
genArrayLiteralElems :: [A.ArrayElem] -> CGen (),
|
genArrayLiteralElems :: [A.ArrayElem] -> CGen (),
|
||||||
-- | Declares a constant array for the sizes (dimensions) of a C array.
|
-- | Declares a constant array for the sizes (dimensions) of a C array.
|
||||||
genArraySize :: Bool -> CGen () -> A.Name -> CGen (),
|
genArraySizeDecl :: Bool -> CGen () -> A.Name -> CGen (),
|
||||||
-- | Writes out the dimensions of an array, that can be used to initialise the sizes of an array. Fails if there is an 'A.UnknownDimension' present.
|
-- | Writes out the dimensions of an array, that can be used to initialise the sizes of an array. Fails if there is an 'A.UnknownDimension' present.
|
||||||
genArraySizesLiteral :: A.Name -> A.Type -> CGen (),
|
genArraySizesLiteral :: A.Name -> A.Type -> CGen (),
|
||||||
-- | Writes out the actual data storage array name.
|
-- | Writes out the actual data storage array name.
|
||||||
|
|
|
@ -293,8 +293,8 @@ testArraySizes = TestList
|
||||||
testBoth "genArraySizesLiteral 0" "{3}" "tockArrayView<int,1>(foo_actual,tockDims(3))" (tcall2 genArraySizesLiteral foo $ A.Array [A.Dimension 3] A.Int)
|
testBoth "genArraySizesLiteral 0" "{3}" "tockArrayView<int,1>(foo_actual,tockDims(3))" (tcall2 genArraySizesLiteral foo $ A.Array [A.Dimension 3] A.Int)
|
||||||
,testBoth "genArraySizesLiteral 1" "{3,6,8}" "tockArrayView<int,3>(foo_actual,tockDims(3,6,8))" (tcall2 genArraySizesLiteral foo $ A.Array [A.Dimension 3, A.Dimension 6, A.Dimension 8] A.Int)
|
,testBoth "genArraySizesLiteral 1" "{3,6,8}" "tockArrayView<int,3>(foo_actual,tockDims(3,6,8))" (tcall2 genArraySizesLiteral foo $ A.Array [A.Dimension 3, A.Dimension 6, A.Dimension 8] A.Int)
|
||||||
,testBothFail "genArraySizesLiteral 2" (tcall2 genArraySizesLiteral foo $ A.Array [A.Dimension 6, A.UnknownDimension] A.Int)
|
,testBothFail "genArraySizesLiteral 2" (tcall2 genArraySizesLiteral foo $ A.Array [A.Dimension 6, A.UnknownDimension] A.Int)
|
||||||
,testBothSame "genArraySize 0" "const int*foo_sizes=@;" (tcall3 genArraySize True at foo)
|
,testBothSame "genArraySizeDecl 0" "const int*foo_sizes=@;" (tcall3 genArraySizeDecl True at foo)
|
||||||
,testBothSame "genArraySize 1" "const int foo_sizes[]=@;" (tcall3 genArraySize False at foo)
|
,testBothSame "genArraySizeDecl 1" "const int foo_sizes[]=@;" (tcall3 genArraySizeDecl False at foo)
|
||||||
,testBothSame "genArrayLiteralElems 0" "$" $ unfolded (tcall genArrayLiteralElems [A.ArrayElemExpr undefined])
|
,testBothSame "genArrayLiteralElems 0" "$" $ unfolded (tcall genArrayLiteralElems [A.ArrayElemExpr undefined])
|
||||||
,testBothSame "genArrayLiteralElems 1" "$,$,$" $ unfolded (tcall genArrayLiteralElems [A.ArrayElemExpr undefined, A.ArrayElemExpr undefined, A.ArrayElemExpr undefined])
|
,testBothSame "genArrayLiteralElems 1" "$,$,$" $ unfolded (tcall genArrayLiteralElems [A.ArrayElemExpr undefined, A.ArrayElemExpr undefined, A.ArrayElemExpr undefined])
|
||||||
,testBothSame "genArrayLiteralElems 2" "$,$,$" $ unfolded (tcall genArrayLiteralElems [A.ArrayElemExpr undefined, A.ArrayElemArray [A.ArrayElemExpr undefined, A.ArrayElemExpr undefined]])
|
,testBothSame "genArrayLiteralElems 2" "$,$,$" $ unfolded (tcall genArrayLiteralElems [A.ArrayElemExpr undefined, A.ArrayElemArray [A.ArrayElemExpr undefined, A.ArrayElemExpr undefined]])
|
||||||
|
@ -737,7 +737,7 @@ testRetypeSizes = TestList
|
||||||
showBytesInParams _ t v = tell ["$(" ++ show t ++ " " ++ show v ++ ")"]
|
showBytesInParams _ t v = tell ["$(" ++ show t ++ " " ++ show v ++ ")"]
|
||||||
showArrSize _ sz _ = tell ["^("] >> sz >> tell [")"]
|
showArrSize _ sz _ = tell ["^("] >> sz >> tell [")"]
|
||||||
over :: Override
|
over :: Override
|
||||||
over = local $ \ops -> ops {genBytesIn = showBytesInParams, genStop = override2 at, genArraySize = showArrSize}
|
over = local $ \ops -> ops {genBytesIn = showBytesInParams, genStop = override2 at, genArraySizeDecl = showArrSize}
|
||||||
|
|
||||||
defRecord :: String -> String -> A.Type -> State CompState ()
|
defRecord :: String -> String -> A.Type -> State CompState ()
|
||||||
defRecord rec mem t = defineName (simpleName rec) $ A.NameDef emptyMeta rec rec A.RecordName (A.RecordType emptyMeta False [(simpleName mem,t)]) A.Original A.Unplaced
|
defRecord rec mem t = defineName (simpleName rec) $ A.NameDef emptyMeta rec rec A.RecordName (A.RecordType emptyMeta False [(simpleName mem,t)]) A.Original A.Unplaced
|
||||||
|
|
Loading…
Reference in New Issue
Block a user