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

View File

@ -166,7 +166,6 @@ data GenOps = GenOps {
genSeq :: A.Structured A.Process -> CGen (), genSeq :: A.Structured A.Process -> CGen (),
genSimpleDyadic :: String -> A.Expression -> A.Expression -> CGen (), genSimpleDyadic :: String -> A.Expression -> A.Expression -> CGen (),
genSimpleMonadic :: String -> A.Expression -> CGen (), genSimpleMonadic :: String -> A.Expression -> CGen (),
genSizeSuffix :: Meta -> A.Type -> String -> CGen (),
genSpec :: forall b. A.Specification -> CGen b -> CGen b, genSpec :: forall b. A.Specification -> CGen b -> CGen b,
genSpecMode :: A.SpecMode -> CGen (), genSpecMode :: A.SpecMode -> CGen (),
-- | Generates a STOP process that uses the given Meta tag and message as its printed message. -- | 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 qualified AST as A
import CompState import CompState
import GenerateC (cgenOps, cgenReplicatorLoop, cgetCType, cintroduceSpec, import GenerateC (cgenOps, cgenReplicatorLoop, cgetCType, cintroduceSpec,
generate, genLeftB, genMeta, genName, genRightB, justOnly, withIf) genDynamicDim, generate, genLeftB, genMeta, genName, genRightB, justOnly, withIf)
import GenerateCBased import GenerateCBased
import Errors import Errors
import Metadata import Metadata
@ -616,8 +616,7 @@ cppintroduceSpec (A.Specification _ n (A.Is _ am t@(A.Array ds c@(A.ChanEnd {}))
tell [","] tell [","]
genName n genName n
tell [","] tell [","]
genName n genDynamicDim (A.Variable m n) 0
call genSizeSuffix m t' "0"
tell [");"] tell [");"]
--For all other cases, use the C implementation: --For all other cases, use the C implementation:
cppintroduceSpec n = cintroduceSpec n cppintroduceSpec n = cintroduceSpec n