summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-05-13 17:00:00 +1000
committerJed Barber <jjbarber@y7mail.com>2014-05-13 17:00:00 +1000
commit1cd61e1840794500166d3f8c18d9010ad5564f37 (patch)
tree52d0b6560ee2c51a8ac7ec636cd81099da61254e
parentb390293df9db7997fba3da03dea70377eebb8caa (diff)
Improved details of garbage collection function
-rw-r--r--src/Grasp/Interpreter.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Grasp/Interpreter.hs b/src/Grasp/Interpreter.hs
index fe8b42a..e556414 100644
--- a/src/Grasp/Interpreter.hs
+++ b/src/Grasp/Interpreter.hs
@@ -5,6 +5,7 @@ module Grasp.Interpreter (
import Data.Graph.Inductive.Graph( Node, LNode, LEdge, (&) )
import qualified Data.Graph.Inductive.Graph as Graph
+import qualified Data.Set as Set
import Grasp.Types
import Grasp.Parser
@@ -22,14 +23,14 @@ grasp g =
-reachable :: GraspProgram -> [Node]
-reachable g = []
+reachable :: GraspProgram -> [IP] -> [Node]
+reachable g ips = Graph.nodes g
-garbageCollect :: GraspProgram -> GraspProgram
-garbageCollect g =
- let unreachable = (Graph.nodes g) \\ (reachable g)
+garbageCollect :: GraspProgram -> [IP] -> GraspProgram
+garbageCollect g ips =
+ let unreachable = (Graph.nodes g) \\ (reachable g ips)
in Graph.delNodes unreachable g