Removed various bits of old code relating to the old sizes mechanism
This commit is contained in:
parent
4d2cdc0a9d
commit
dbf886996a
|
@ -826,14 +826,6 @@ cgetCType m origT am
|
||||||
where
|
where
|
||||||
const = if am == A.ValAbbrev then Const else id
|
const = if am == A.ValAbbrev then Const else id
|
||||||
|
|
||||||
-- | Return whether a type is one that is declared as a structure, but
|
|
||||||
-- abbreviated as a pointer.
|
|
||||||
indirectedType :: Meta -> A.Type -> CGen Bool
|
|
||||||
indirectedType m t@(A.Record _)
|
|
||||||
= recordAttr m t >>* (not . A.mobileRecord)
|
|
||||||
indirectedType _ (A.Chan _ _) = return True
|
|
||||||
indirectedType _ _ = return False
|
|
||||||
|
|
||||||
cgenDirectedVariable :: Meta -> A.Type -> CGen () -> A.Direction -> CGen ()
|
cgenDirectedVariable :: Meta -> A.Type -> CGen () -> A.Direction -> CGen ()
|
||||||
cgenDirectedVariable _ _ var _ = var
|
cgenDirectedVariable _ _ var _ = var
|
||||||
|
|
||||||
|
@ -898,14 +890,6 @@ cgenArraySubscript check v es
|
||||||
genChunks = map genDim subs
|
genChunks = map genDim subs
|
||||||
--}}}
|
--}}}
|
||||||
|
|
||||||
countSubscripts :: A.Variable -> (Int, A.Variable)
|
|
||||||
countSubscripts (A.SubscriptedVariable _ (A.Subscript {}) v)
|
|
||||||
= let (n, v') = countSubscripts v in (1+n, v')
|
|
||||||
countSubscripts (A.SubscriptedVariable _ _ v) = countSubscripts v
|
|
||||||
countSubscripts (A.DirectedVariable _ _ v) = countSubscripts v
|
|
||||||
countSubscripts (A.DerefVariable _ v) = countSubscripts v
|
|
||||||
countSubscripts v@(A.Variable _ _) = (0, v)
|
|
||||||
|
|
||||||
--{{{ expressions
|
--{{{ expressions
|
||||||
cgenExpression :: A.Expression -> CGen ()
|
cgenExpression :: A.Expression -> CGen ()
|
||||||
cgenExpression (A.Monadic m op e) = call genMonadic m op e
|
cgenExpression (A.Monadic m op e) = call genMonadic m op e
|
||||||
|
@ -922,11 +906,6 @@ cgenExpression (A.True m) = tell ["true"]
|
||||||
cgenExpression (A.False m) = tell ["false"]
|
cgenExpression (A.False m) = tell ["false"]
|
||||||
--cgenExpression (A.FunctionCall m n es)
|
--cgenExpression (A.FunctionCall m n es)
|
||||||
cgenExpression (A.IntrinsicFunctionCall m s es) = call genIntrinsicFunction m s es
|
cgenExpression (A.IntrinsicFunctionCall m s es) = call genIntrinsicFunction m s es
|
||||||
cgenExpression (A.SubscriptedExpr m (A.Subscript _ A.NoCheck sub) e)
|
|
||||||
= do call genExpression e
|
|
||||||
tell ["["]
|
|
||||||
call genExpression sub
|
|
||||||
tell ["]"]
|
|
||||||
--cgenExpression (A.BytesInExpr m e)
|
--cgenExpression (A.BytesInExpr m e)
|
||||||
cgenExpression (A.BytesInExpr m (A.ExprVariable _ v))
|
cgenExpression (A.BytesInExpr m (A.ExprVariable _ v))
|
||||||
= do t <- astTypeOf v
|
= do t <- astTypeOf v
|
||||||
|
@ -940,14 +919,6 @@ cgenExpression (A.IsDefined m (A.ExprVariable _ (A.DerefVariable _ v)))
|
||||||
= tell ["("] >> call genVariable v A.Original >> tell ["!=NULL)"]
|
= tell ["("] >> call genVariable v A.Original >> tell ["!=NULL)"]
|
||||||
cgenExpression (A.IsDefined m e)
|
cgenExpression (A.IsDefined m e)
|
||||||
= tell ["("] >> call genExpression e >> tell ["!=NULL)"]
|
= tell ["("] >> call genExpression e >> tell ["!=NULL)"]
|
||||||
cgenExpression (A.SubscriptedExpr m sub (A.ExprVariable _ v))
|
|
||||||
= call genVariable (A.SubscriptedVariable m sub v) A.Original
|
|
||||||
cgenExpression (A.SubscriptedExpr m (A.SubscriptFromFor _ _ start _) e@(A.AllSizesVariable {}))
|
|
||||||
= do tell ["(&("]
|
|
||||||
call genExpression e
|
|
||||||
tell ["["]
|
|
||||||
call genExpression start
|
|
||||||
tell ["]))"]
|
|
||||||
cgenExpression t = call genMissing $ "genExpression " ++ show t
|
cgenExpression t = call genMissing $ "genExpression " ++ show t
|
||||||
|
|
||||||
cgenTypeSymbol :: String -> A.Type -> CGen ()
|
cgenTypeSymbol :: String -> A.Type -> CGen ()
|
||||||
|
@ -1209,8 +1180,6 @@ abbrevExpression am t@(A.Array _ _) e
|
||||||
= case e of
|
= case e of
|
||||||
A.ExprVariable _ v -> call genVariable v am
|
A.ExprVariable _ v -> call genVariable v am
|
||||||
A.Literal _ t@(A.Array _ _) r -> call genExpression e
|
A.Literal _ t@(A.Array _ _) r -> call genExpression e
|
||||||
A.AllSizesVariable {} -> call genExpression e
|
|
||||||
A.SubscriptedExpr {} -> call genExpression e
|
|
||||||
_ -> call genMissingC $ formatCode "array expression abbreviation %" e
|
_ -> call genMissingC $ formatCode "array expression abbreviation %" e
|
||||||
abbrevExpression am t@(A.Record _) (A.ExprVariable _ v)
|
abbrevExpression am t@(A.Record _) (A.ExprVariable _ v)
|
||||||
= call genVariable v am
|
= call genVariable v am
|
||||||
|
|
|
@ -232,7 +232,6 @@ getVarExp = everything unionVars (emptyVars `mkQ` getVarExp')
|
||||||
--Only need to deal with the two cases where we can see an A.Variable directly;
|
--Only need to deal with the two cases where we can see an A.Variable directly;
|
||||||
--the generic recursion will take care of nested expressions, and even the expressions used as subscripts
|
--the generic recursion will take care of nested expressions, and even the expressions used as subscripts
|
||||||
getVarExp' :: A.Expression -> Vars
|
getVarExp' :: A.Expression -> Vars
|
||||||
getVarExp' (A.SizeVariable _ v) = processVarR v
|
|
||||||
getVarExp' (A.ExprVariable _ v) = processVarR v
|
getVarExp' (A.ExprVariable _ v) = processVarR v
|
||||||
getVarExp' _ = emptyVars
|
getVarExp' _ = emptyVars
|
||||||
|
|
||||||
|
|
|
@ -258,11 +258,6 @@ evalExpression (A.SizeExpr m e)
|
||||||
case v of
|
case v of
|
||||||
OccArray vs -> return $ OccInt (fromIntegral $ length vs)
|
OccArray vs -> return $ OccInt (fromIntegral $ length vs)
|
||||||
_ -> throwError (Just m, "size of non-constant expression " ++ show e ++ " used")
|
_ -> throwError (Just m, "size of non-constant expression " ++ show e ++ " used")
|
||||||
evalExpression (A.SizeVariable m v)
|
|
||||||
= do t <- astTypeOf v >>= underlyingType m
|
|
||||||
case t of
|
|
||||||
A.Array (A.Dimension n:_) _ -> evalExpression n
|
|
||||||
_ -> throwError (Just m, "size of non-fixed-size variable " ++ show v ++ " used")
|
|
||||||
evalExpression e@(A.Literal _ _ _) = evalLiteral e
|
evalExpression e@(A.Literal _ _ _) = evalLiteral e
|
||||||
evalExpression (A.ExprVariable _ v) = evalVariable v
|
evalExpression (A.ExprVariable _ v) = evalVariable v
|
||||||
evalExpression (A.True _) = return $ OccBool True
|
evalExpression (A.True _) = return $ OccBool True
|
||||||
|
|
|
@ -441,7 +441,6 @@ instance ShowRain A.Expression where
|
||||||
showRainM (A.MostNeg _ t) = bracket $ tell ["MOSTNEG "] >> showRainM t
|
showRainM (A.MostNeg _ t) = bracket $ tell ["MOSTNEG "] >> showRainM t
|
||||||
showRainM (A.SizeType _ t) = bracket $ tell ["SIZE "] >> showRainM t
|
showRainM (A.SizeType _ t) = bracket $ tell ["SIZE "] >> showRainM t
|
||||||
showRainM (A.SizeExpr _ e) = bracket $ tell ["SIZE "] >> showRainM e
|
showRainM (A.SizeExpr _ e) = bracket $ tell ["SIZE "] >> showRainM e
|
||||||
showRainM (A.SizeVariable _ v) = bracket $ tell ["SIZE "] >> showRainM v
|
|
||||||
showRainM (A.Conversion _ cm t e) = bracket $ showRainM t >> convOrSpace cm >> showRainM e
|
showRainM (A.Conversion _ cm t e) = bracket $ showRainM t >> convOrSpace cm >> showRainM e
|
||||||
showRainM (A.ExprVariable _ v) = showRainM v
|
showRainM (A.ExprVariable _ v) = showRainM v
|
||||||
showRainM (A.Literal _ _ lit) = showRainM lit
|
showRainM (A.Literal _ _ lit) = showRainM lit
|
||||||
|
|
|
@ -316,7 +316,6 @@ typeOfExpression e
|
||||||
A.MostNeg m t -> return t
|
A.MostNeg m t -> return t
|
||||||
A.SizeType m t -> return A.Int
|
A.SizeType m t -> return A.Int
|
||||||
A.SizeExpr m t -> return A.Int
|
A.SizeExpr m t -> return A.Int
|
||||||
A.SizeVariable m t -> return A.Int
|
|
||||||
A.Conversion m cm t e -> return t
|
A.Conversion m cm t e -> return t
|
||||||
A.ExprVariable m v -> typeOfVariable v
|
A.ExprVariable m v -> typeOfVariable v
|
||||||
A.Literal _ t _ -> return t
|
A.Literal _ t _ -> return t
|
||||||
|
|
|
@ -269,12 +269,6 @@ data Expression =
|
||||||
-- | The size of the outermost dimension of an array expression.
|
-- | The size of the outermost dimension of an array expression.
|
||||||
-- Given @[8][4]INT a:@, @SIZE a@ is 8 and @SIZE a[0]@ is 4.
|
-- Given @[8][4]INT a:@, @SIZE a@ is 8 and @SIZE a[0]@ is 4.
|
||||||
| SizeExpr Meta Expression
|
| SizeExpr Meta Expression
|
||||||
-- | The size of the outermost dimension of an array variable (see
|
|
||||||
-- 'SizeExpr').
|
|
||||||
| SizeVariable Meta Variable
|
|
||||||
-- | An array that contains all the dimensions of an array. Hence this is different
|
|
||||||
-- from SizeVariable which is only the outermost dimension.
|
|
||||||
| AllSizesVariable Meta Variable
|
|
||||||
| Conversion Meta ConversionMode Type Expression
|
| Conversion Meta ConversionMode Type Expression
|
||||||
| ExprVariable Meta Variable
|
| ExprVariable Meta Variable
|
||||||
| Literal Meta Type LiteralRepr
|
| Literal Meta Type LiteralRepr
|
||||||
|
|
|
@ -1298,9 +1298,6 @@ checkExpressions = checkDepthM doExpression
|
||||||
doExpression (A.SizeExpr m e)
|
doExpression (A.SizeExpr m e)
|
||||||
= do t <- astTypeOf e
|
= do t <- astTypeOf e
|
||||||
checkSequence True m t
|
checkSequence True m t
|
||||||
doExpression (A.SizeVariable m v)
|
|
||||||
= do t <- astTypeOf v
|
|
||||||
checkSequence True m t
|
|
||||||
doExpression (A.Conversion m _ t e)
|
doExpression (A.Conversion m _ t e)
|
||||||
= do et <- astTypeOf e
|
= do et <- astTypeOf e
|
||||||
checkScalar m t >> checkScalar (findMeta e) et
|
checkScalar m t >> checkScalar (findMeta e) et
|
||||||
|
|
|
@ -224,19 +224,6 @@ mobiliseArrays = pass "Make all arrays mobile" [] [] recurse
|
||||||
let newSpec = A.Is m'' A.Original (A.Mobile t) $
|
let newSpec = A.Is m'' A.Original (A.Mobile t) $
|
||||||
A.ActualExpression $ A.AllocMobile m'' (A.Mobile t) Nothing
|
A.ActualExpression $ A.AllocMobile m'' (A.Mobile t) Nothing
|
||||||
modifyName n (\nd -> nd {A.ndSpecType = newSpec})
|
modifyName n (\nd -> nd {A.ndSpecType = newSpec})
|
||||||
let name_sizes = n {A.nameName = A.nameName n ++ "_sizes"}
|
|
||||||
nd = A.NameDef {
|
|
||||||
A.ndMeta = m,
|
|
||||||
A.ndName = A.nameName name_sizes,
|
|
||||||
A.ndOrigName = A.nameName name_sizes,
|
|
||||||
A.ndSpecType = A.Declaration m $
|
|
||||||
A.Array [A.Dimension $ makeConstant m (length ds)]
|
|
||||||
A.Int,
|
|
||||||
A.ndAbbrevMode = A.Original,
|
|
||||||
A.ndNameSource = A.NamePredefined,
|
|
||||||
A.ndPlacement = A.Unplaced
|
|
||||||
}
|
|
||||||
defineName name_sizes nd
|
|
||||||
return $ A.Spec m (A.Specification m' n newSpec) scope'
|
return $ A.Spec m (A.Specification m' n newSpec) scope'
|
||||||
|
|
||||||
doStructured (A.Spec m (A.Specification m' n (A.Proc m'' sm fs body)) scope)
|
doStructured (A.Spec m (A.Specification m' n (A.Proc m'' sm fs body)) scope)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user