From b496912c51d7f1a6efe5fca6308f0f7b26ade6b6 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 19 Mar 2008 17:49:32 +0000 Subject: [PATCH] Fixed conflicts with Adam's dimension changes --- backends/GenerateC.hs | 14 +++++++++----- common/Types.hs | 13 ++----------- frontends/ParseRain.hs | 4 ++-- transformations/PassTest.hs | 2 +- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/backends/GenerateC.hs b/backends/GenerateC.hs index 036a7f5..4a17b7c 100644 --- a/backends/GenerateC.hs +++ b/backends/GenerateC.hs @@ -844,11 +844,15 @@ cgenExpression (A.SizeExpr m e) = do call genExpression e call genSizeSuffix "0" cgenExpression (A.SizeVariable m v) - = do A.Array (d:_) _ <- typeOfVariable v - case d of - A.Dimension n -> tell [show n] - A.UnknownDimension -> do call genVariable v - call genSizeSuffix "0" + = do t <- typeOfVariable v + case t of + A.Array (d:_) _ -> + case d of + A.Dimension n -> call genExpression n + A.UnknownDimension -> do call genVariable v + call genSizeSuffix "0" + A.List _ -> + call genListSize v cgenExpression (A.Conversion m cm t e) = call genConversion m cm t e cgenExpression (A.ExprVariable m v) = call genVariable v cgenExpression (A.Literal _ t lr) = call genLiteral lr t diff --git a/common/Types.hs b/common/Types.hs index 6bffc00..d31162d 100644 --- a/common/Types.hs +++ b/common/Types.hs @@ -231,17 +231,8 @@ typeOfExpression e A.BytesInExpr m e -> return A.Int A.BytesInType m t -> return A.Int A.OffsetOf m t n -> return A.Int - A.ExprConstr m (A.RangeConstr _ b e) -> - do bt <- typeOfExpression b - et <- typeOfExpression e - st <- getCompState - if bt /= et - then dieP m "Types did not match for beginning and end of range" - else typeOfArrayList [A.UnknownDimension] bt - A.ExprConstr m (A.RepConstr _ rep e) -> - do t <- typeOfExpression e - count <- evalIntExpression $ countReplicator rep - typeOfArrayList [A.Dimension count] t + A.ExprConstr m (A.RangeConstr _ t _ _) -> return t + A.ExprConstr m (A.RepConstr _ t _ _) -> return t A.AllocMobile _ t _ -> return t --}}} diff --git a/frontends/ParseRain.hs b/frontends/ParseRain.hs index 5f67650..73c81e7 100644 --- a/frontends/ParseRain.hs +++ b/frontends/ParseRain.hs @@ -175,8 +175,8 @@ stringLiteral :: RainParser A.LiteralRepr stringLiteral = do (m,str) <- getToken testToken let processed = replaceEscapes str - let aes = [A.ArrayElemExpr $ A.Literal m A.Byte $ A.ByteLiteral m [c] | c <- processed] - return (A.ArrayLiteral m aes, A.Dimension $ length processed) + let aes = [A.Literal m A.Byte $ A.ByteLiteral m [c] | c <- processed] + return (A.ListLiteral m aes) "string literal" where testToken (L.TokStringLiteral str) = Just str diff --git a/transformations/PassTest.hs b/transformations/PassTest.hs index b453b98..c37e5f7 100644 --- a/transformations/PassTest.hs +++ b/transformations/PassTest.hs @@ -211,7 +211,7 @@ testTransformConstr0 = TestCase $ testPass "transformConstr0" exp (transformCons A.RepConstr m A.Byte (A.For m (simpleName "x") (intLiteral 0) (intLiteral 10)) (exprVariable "x") ) skipP exp = nameAndStopCaringPattern "indexVar" "i" $ mkPattern exp' - exp' = A.Spec m (A.Specification m (simpleName "arr") (A.Declaration m (A.Array [A.Dimension 10] A.Int))) $ + exp' = A.Spec m (A.Specification m (simpleName "arr") (A.Declaration m (A.Byte))) $ A.ProcThen m (A.Seq m $ A.Spec m (A.Specification m (simpleName "i") (A.Declaration m A.Int)) $ A.Several m [A.Only m $ A.Assign m [variable "i"] $ A.ExpressionList m [intLiteral 0],