From dbf886996a5de031d2e235c0eb22bea6a9c04a06 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 31 Mar 2009 10:50:04 +0000 Subject: [PATCH] Removed various bits of old code relating to the old sizes mechanism --- backends/GenerateC.hs | 31 ----------------------------- checks/UsageCheckUtils.hs | 1 - common/EvalConstants.hs | 5 ----- common/ShowCode.hs | 1 - common/Types.hs | 1 - data/AST.hs | 6 ------ frontends/OccamTypes.hs | 3 --- transformations/ImplicitMobility.hs | 13 ------------ 8 files changed, 61 deletions(-) diff --git a/backends/GenerateC.hs b/backends/GenerateC.hs index 2fc1ce0..f0f40eb 100644 --- a/backends/GenerateC.hs +++ b/backends/GenerateC.hs @@ -826,14 +826,6 @@ cgetCType m origT am where 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 _ _ var _ = var @@ -898,14 +890,6 @@ cgenArraySubscript check v es 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 cgenExpression :: A.Expression -> CGen () 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.FunctionCall m n 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 (A.ExprVariable _ 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)"] cgenExpression (A.IsDefined m e) = 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 cgenTypeSymbol :: String -> A.Type -> CGen () @@ -1209,8 +1180,6 @@ abbrevExpression am t@(A.Array _ _) e = case e of A.ExprVariable _ v -> call genVariable v am 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 abbrevExpression am t@(A.Record _) (A.ExprVariable _ v) = call genVariable v am diff --git a/checks/UsageCheckUtils.hs b/checks/UsageCheckUtils.hs index b185048..e78452c 100644 --- a/checks/UsageCheckUtils.hs +++ b/checks/UsageCheckUtils.hs @@ -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; --the generic recursion will take care of nested expressions, and even the expressions used as subscripts getVarExp' :: A.Expression -> Vars - getVarExp' (A.SizeVariable _ v) = processVarR v getVarExp' (A.ExprVariable _ v) = processVarR v getVarExp' _ = emptyVars diff --git a/common/EvalConstants.hs b/common/EvalConstants.hs index 40bab93..ddaf5a8 100644 --- a/common/EvalConstants.hs +++ b/common/EvalConstants.hs @@ -258,11 +258,6 @@ evalExpression (A.SizeExpr m e) case v of OccArray vs -> return $ OccInt (fromIntegral $ length vs) _ -> 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 (A.ExprVariable _ v) = evalVariable v evalExpression (A.True _) = return $ OccBool True diff --git a/common/ShowCode.hs b/common/ShowCode.hs index 7eaa2ae..59bf26f 100644 --- a/common/ShowCode.hs +++ b/common/ShowCode.hs @@ -441,7 +441,6 @@ instance ShowRain A.Expression where showRainM (A.MostNeg _ t) = bracket $ tell ["MOSTNEG "] >> showRainM t showRainM (A.SizeType _ t) = bracket $ tell ["SIZE "] >> showRainM t 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.ExprVariable _ v) = showRainM v showRainM (A.Literal _ _ lit) = showRainM lit diff --git a/common/Types.hs b/common/Types.hs index 22a0470..1adb4e1 100644 --- a/common/Types.hs +++ b/common/Types.hs @@ -316,7 +316,6 @@ typeOfExpression e A.MostNeg m t -> return t A.SizeType 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.ExprVariable m v -> typeOfVariable v A.Literal _ t _ -> return t diff --git a/data/AST.hs b/data/AST.hs index f614293..68d9ea8 100644 --- a/data/AST.hs +++ b/data/AST.hs @@ -269,12 +269,6 @@ data 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. | 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 | ExprVariable Meta Variable | Literal Meta Type LiteralRepr diff --git a/frontends/OccamTypes.hs b/frontends/OccamTypes.hs index 26f920f..b5744b8 100644 --- a/frontends/OccamTypes.hs +++ b/frontends/OccamTypes.hs @@ -1298,9 +1298,6 @@ checkExpressions = checkDepthM doExpression doExpression (A.SizeExpr m e) = do t <- astTypeOf e checkSequence True m t - doExpression (A.SizeVariable m v) - = do t <- astTypeOf v - checkSequence True m t doExpression (A.Conversion m _ t e) = do et <- astTypeOf e checkScalar m t >> checkScalar (findMeta e) et diff --git a/transformations/ImplicitMobility.hs b/transformations/ImplicitMobility.hs index ea709d4..0aaa35b 100644 --- a/transformations/ImplicitMobility.hs +++ b/transformations/ImplicitMobility.hs @@ -224,19 +224,6 @@ mobiliseArrays = pass "Make all arrays mobile" [] [] recurse let newSpec = A.Is m'' A.Original (A.Mobile t) $ A.ActualExpression $ A.AllocMobile m'' (A.Mobile t) Nothing 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' doStructured (A.Spec m (A.Specification m' n (A.Proc m'' sm fs body)) scope)