Commit e6389e0f authored by marton bognar's avatar marton bognar
Browse files

Fix filtering sorts by variable access

parent 211bac59
......@@ -49,9 +49,9 @@ data NamespaceDef
-- | Sort declaration
data SortDef
= MkDefSort {
sname :: SortName,
sctxs :: [Context],
sctors :: [ConstructorDef],
sname :: SortName,
sctxs :: [Context],
sctors :: [ConstructorDef],
srewrite :: Bool
}
deriving (Show, Eq)
......@@ -59,20 +59,20 @@ data SortDef
-- | Constructor declaration
data ConstructorDef
= MkDefConstructor {
cname :: ConstructorName,
clists :: [(IdenName, SortName)],
csorts :: [(IdenName, SortName)],
cfolds :: [(IdenName, SortName, FoldName)],
cattrs :: [AttributeDef],
cname :: ConstructorName,
clists :: [(IdenName, SortName)],
csorts :: [(IdenName, SortName)],
cfolds :: [(IdenName, SortName, FoldName)],
cattrs :: [AttributeDef],
cnatives :: [HaskellTypeName]
}
| MkBindConstructor {
cname :: ConstructorName,
clists :: [(IdenName, SortName)],
csorts :: [(IdenName, SortName)],
cfolds :: [(IdenName, SortName, FoldName)],
cname :: ConstructorName,
clists :: [(IdenName, SortName)],
csorts :: [(IdenName, SortName)],
cfolds :: [(IdenName, SortName, FoldName)],
_cbinder :: (IdenName, NamespaceName),
cattrs :: [AttributeDef],
cattrs :: [AttributeDef],
cnatives :: [HaskellTypeName]
}
| MkVarConstructor {
......
......@@ -25,7 +25,7 @@ freeVarFunctions :: Language -> ExternalFunctions -> [Function]
freeVarFunctions (_, sd, _, _) ef =
let ctxsBySname = map snameAndCtxs sd
varAccessBySname = varAccessBySortName sd
sortsWithVarAccess = filter (\(MkDefSort sname _ _ _) -> isJust (lookup sname varAccessBySname)) sd
sortsWithVarAccess = filter (\(MkDefSort sname _ _ _) -> fromJust (lookup sname varAccessBySname)) sd
in map (\sort ->
Fn ("freeVariables" ++ sname sort)
(map (\ctor ->
......@@ -76,7 +76,7 @@ mappingFunctions :: Language -> ExternalFunctions -> [Function]
mappingFunctions (_, sd, _, _) ef =
let ctxsBySname = map snameAndCtxs sd
varAccessBySname = varAccessBySortName sd
sortsWithVarAccess = filter (\(MkDefSort sname _ _ _) -> isJust (lookup sname varAccessBySname)) sd
sortsWithVarAccess = filter (\(MkDefSort sname _ _ _) -> fromJust (lookup sname varAccessBySname)) sd
in map (
\(MkDefSort sortName ctxs ctors _) ->
Fn (mapFnForSortName sortName)
......
......@@ -192,7 +192,7 @@ getEnvFunctions (nsd, sd, _, _)
substFunctions :: Language -> [Function]
substFunctions (nsd, sd, _, _) =
let varAccessBySname = varAccessBySortName sd
sortsWithVarAccess = filter (\sort -> isJust (lookup (sname sort) varAccessBySname)) sd
sortsWithVarAccess = filter (\sort -> fromJust (lookup (sname sort) varAccessBySname)) sd
in concatMap (\(MkDefSort sortName ctxs ctors rewrite) ->
let inhCtxs = [INH x y | INH x y <- ctxs]
in
......
......@@ -120,7 +120,7 @@ boundVarFunctions :: Language -> [Function]
boundVarFunctions (_, sd, _, _) =
let ctxsBySname = map snameAndCtxs sd
varAccessBySname = varAccessBySortName sd
sortsWithVarAccess = filter (\(MkDefSort sname _ _ _) -> isJust (lookup sname varAccessBySname)) sd
sortsWithVarAccess = filter (\(MkDefSort sname _ _ _) -> fromJust (lookup sname varAccessBySname)) sd
in map (\sort ->
Fn ("boundVariables" ++ sname sort)
(map (\ctor ->
......@@ -144,7 +144,7 @@ boundVarFunctions (_, sd, _, _) =
]
)
) (sctors sort))
) sortsWithVarAccess
) sd
where
-- | Generate a list of expressions, that when concatenated together give
-- the union of free variables for a given constructor (free variable
......@@ -185,7 +185,7 @@ substFunctionsC (nsd, sd, _, _) =
where
ctxsBySname = map snameAndCtxs sd
varAccessBySname = varAccessBySortName sd
sortsWithVarAccess = filter (\sort -> isJust (lookup (sname sort) varAccessBySname)) sd
sortsWithVarAccess = filter (\sort -> fromJust (lookup (sname sort) varAccessBySname)) sd
freeVariablesCall :: ConstructorDef -> (IdenName, SortName) -> Expression
freeVariablesCall ctor (iden, idenSort)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment