From 7dbbdc1806cba94807fc7ec9f249e57ecc7721bb Mon Sep 17 00:00:00 2001 From: Mark Probst Date: Sat, 9 Sep 2017 15:19:55 -0700 Subject: [PATCH] Remove dead subtype code --- src/IRGraph.purs | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/src/IRGraph.purs b/src/IRGraph.purs index 3c2ba04d..da01f1cf 100644 --- a/src/IRGraph.purs +++ b/src/IRGraph.purs @@ -45,7 +45,6 @@ module IRGraph import Prelude import Control.Comonad (extract) -import Data.Foldable (all) import Data.Identity (Identity(..)) import Data.Int.Bits as Bits import Data.List (List, (:)) @@ -240,43 +239,6 @@ matchingProperties ma mb = M.fromFoldable $ L.concatMap getFromB (M.toUnfoldable | otherwise -> L.Nil Nothing -> L.Nil - -isMaybeSubtypeOfMaybe :: IRGraph -> Maybe IRType -> Maybe IRType -> Boolean -isMaybeSubtypeOfMaybe _ Nothing Nothing = true -isMaybeSubtypeOfMaybe graph (Just a) (Just b) = isSubtypeOf graph a b -isMaybeSubtypeOfMaybe _ _ _ = false - -isSubclassOf :: IRGraph -> Int -> Int -> Boolean -isSubclassOf graph ia ib = - let IRClassData { properties: pa } = getClassFromGraph graph ia - IRClassData { properties: pb } = getClassFromGraph graph ib - in propertiesAreSubset pa pb - where - propertiesAreSubset :: Map String IRType -> Map String IRType -> Boolean - propertiesAreSubset ma mb = all (isInB mb) (M.toUnfoldable ma :: List (Tuple String IRType)) - isInB mb (Tuple n ta) = maybe false (isSubtypeOf graph ta) (M.lookup n mb) - --- FIXME: generalize with isMaybeSubtypeOfMaybe -isMaybeSubclassOfMaybe :: IRGraph -> Maybe Int -> Maybe Int -> Boolean -isMaybeSubclassOfMaybe _ Nothing Nothing = true -isMaybeSubclassOfMaybe graph (Just a) (Just b) = isSubclassOf graph a b -isMaybeSubclassOfMaybe _ _ _ = false - -isSubtypeOf :: IRGraph -> IRType -> IRType -> Boolean -isSubtypeOf _ IRAnything _ = true -isSubtypeOf graph (IRUnion a) (IRUnion b) = - let IRUnionRep { primitives: pa, arrayType: aa, classRef: ca, mapType: ma } = a - IRUnionRep { primitives: pb, arrayType: ab, classRef: cb, mapType: mb } = a - in - (Bits.and pa pb) == pa && - isMaybeSubtypeOfMaybe graph aa ab && - isMaybeSubtypeOfMaybe graph ma mb && - isMaybeSubclassOfMaybe graph ca cb -isSubtypeOf graph (IRArray a) (IRArray b) = isSubtypeOf graph a b -isSubtypeOf graph (IRMap a) (IRMap b) = isSubtypeOf graph a b -isSubtypeOf graph (IRClass ia) (IRClass ib) = isSubclassOf graph ia ib -isSubtypeOf _ a b = a == b - regatherClassNames :: IRGraph -> IRGraph regatherClassNames graph@(IRGraph { classes, toplevels }) = -- FIXME: gather names from top levels map, too