Fixed conflicts with Adam's dimension changes

This commit is contained in:
Neil Brown 2008-03-19 17:49:32 +00:00
parent 05866457e4
commit b496912c51
4 changed files with 14 additions and 19 deletions

View File

@ -844,11 +844,15 @@ cgenExpression (A.SizeExpr m e)
= do call genExpression e = do call genExpression e
call genSizeSuffix "0" call genSizeSuffix "0"
cgenExpression (A.SizeVariable m v) cgenExpression (A.SizeVariable m v)
= do A.Array (d:_) _ <- typeOfVariable v = do t <- typeOfVariable v
case d of case t of
A.Dimension n -> tell [show n] A.Array (d:_) _ ->
A.UnknownDimension -> do call genVariable v case d of
call genSizeSuffix "0" 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.Conversion m cm t e) = call genConversion m cm t e
cgenExpression (A.ExprVariable m v) = call genVariable v cgenExpression (A.ExprVariable m v) = call genVariable v
cgenExpression (A.Literal _ t lr) = call genLiteral lr t cgenExpression (A.Literal _ t lr) = call genLiteral lr t

View File

@ -231,17 +231,8 @@ typeOfExpression e
A.BytesInExpr m e -> return A.Int A.BytesInExpr m e -> return A.Int
A.BytesInType m t -> return A.Int A.BytesInType m t -> return A.Int
A.OffsetOf m t n -> return A.Int A.OffsetOf m t n -> return A.Int
A.ExprConstr m (A.RangeConstr _ b e) -> A.ExprConstr m (A.RangeConstr _ t _ _) -> return t
do bt <- typeOfExpression b A.ExprConstr m (A.RepConstr _ t _ _) -> return t
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.AllocMobile _ t _ -> return t A.AllocMobile _ t _ -> return t
--}}} --}}}

View File

@ -175,8 +175,8 @@ stringLiteral :: RainParser A.LiteralRepr
stringLiteral stringLiteral
= do (m,str) <- getToken testToken = do (m,str) <- getToken testToken
let processed = replaceEscapes str let processed = replaceEscapes str
let aes = [A.ArrayElemExpr $ A.Literal m A.Byte $ A.ByteLiteral m [c] | c <- processed] let aes = [A.Literal m A.Byte $ A.ByteLiteral m [c] | c <- processed]
return (A.ArrayLiteral m aes, A.Dimension $ length processed) return (A.ListLiteral m aes)
<?> "string literal" <?> "string literal"
where where
testToken (L.TokStringLiteral str) = Just str testToken (L.TokStringLiteral str) = Just str

View File

@ -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") A.RepConstr m A.Byte (A.For m (simpleName "x") (intLiteral 0) (intLiteral 10)) (exprVariable "x")
) skipP ) skipP
exp = nameAndStopCaringPattern "indexVar" "i" $ mkPattern exp' 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.ProcThen m
(A.Seq m $ A.Spec m (A.Specification m (simpleName "i") (A.Declaration m A.Int)) $ (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], A.Several m [A.Only m $ A.Assign m [variable "i"] $ A.ExpressionList m [intLiteral 0],