Removed genSizeSuffix and turned most uses of it into calls to genDynamicDim

This commit is contained in:
Neil Brown 2009-03-31 09:29:55 +00:00
parent b8daebfbc3
commit 298ba6465a
3 changed files with 6 additions and 20 deletions

View File

@ -26,6 +26,7 @@ module GenerateC
, cPreReq
, cremoveSpec
, genCPasses
, genDynamicDim
, generate
, generateC
, genLeftB
@ -134,7 +135,6 @@ cgenOps = GenOps {
genSeq = cgenSeq,
genSimpleDyadic = cgenSimpleDyadic,
genSimpleMonadic = cgenSimpleMonadic,
genSizeSuffix = cgenSizeSuffix,
genSpec = cgenSpec,
genSpecMode = cgenSpecMode,
genStop = cgenStop,
@ -278,15 +278,12 @@ cgenOverArray m var func
call genVariable i A.Original
tell ["<"]
case d of
A.UnknownDimension ->
do call genVariable var A.Original
t <- astTypeOf var
call genSizeSuffix m t (show v)
A.UnknownDimension -> genDynamicDim var v
A.Dimension n -> call genExpression n
tell [";"]
call genVariable i A.Original
tell ["++){"]
| (v :: Integer, i, d) <- zip3 [0..] indices ds]
| (v :: Int, i, d) <- zip3 [0..] indices ds]
p
sequence_ [tell ["}"] | _ <- indices]
Nothing -> return ()
@ -396,9 +393,7 @@ cgenBytesIn m t v
genBytesInArrayDim (A.UnknownDimension, i)
= case v of
Right rv ->
do call genVariable rv A.Original
t <- astTypeOf rv
call genSizeSuffix (findMeta rv) t (show i)
do genDynamicDim rv i
tell ["*"]
_ -> return ()
@ -956,13 +951,6 @@ cgenExpression (A.SubscriptedExpr m (A.SubscriptFromFor _ _ start _) e@(A.AllSiz
tell ["]))"]
cgenExpression t = call genMissing $ "genExpression " ++ show t
cgenSizeSuffix :: Meta -> A.Type -> String -> CGen ()
cgenSizeSuffix m t dim
= case t of
A.Array {} -> tell ["_sizes[", dim, "]"]
A.Mobile (A.Array {}) -> tell ["->dimensions[", dim, "]"]
_ -> diePC emptyMeta $ formatCode "Cannot produce dimensions for type: %" t
cgenTypeSymbol :: String -> A.Type -> CGen ()
cgenTypeSymbol s t
= do f <- fget getScalarType

View File

@ -166,7 +166,6 @@ data GenOps = GenOps {
genSeq :: A.Structured A.Process -> CGen (),
genSimpleDyadic :: String -> A.Expression -> A.Expression -> CGen (),
genSimpleMonadic :: String -> A.Expression -> CGen (),
genSizeSuffix :: Meta -> A.Type -> String -> CGen (),
genSpec :: forall b. A.Specification -> CGen b -> CGen b,
genSpecMode :: A.SpecMode -> CGen (),
-- | Generates a STOP process that uses the given Meta tag and message as its printed message.

View File

@ -40,7 +40,7 @@ import System.IO
import qualified AST as A
import CompState
import GenerateC (cgenOps, cgenReplicatorLoop, cgetCType, cintroduceSpec,
generate, genLeftB, genMeta, genName, genRightB, justOnly, withIf)
genDynamicDim, generate, genLeftB, genMeta, genName, genRightB, justOnly, withIf)
import GenerateCBased
import Errors
import Metadata
@ -616,8 +616,7 @@ cppintroduceSpec (A.Specification _ n (A.Is _ am t@(A.Array ds c@(A.ChanEnd {}))
tell [","]
genName n
tell [","]
genName n
call genSizeSuffix m t' "0"
genDynamicDim (A.Variable m n) 0
tell [");"]
--For all other cases, use the C implementation:
cppintroduceSpec n = cintroduceSpec n