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
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

View File

@ -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
--}}}

View File

@ -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

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")
) 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],