Commit b067baf1 authored by Katharina Brandl's avatar Katharina Brandl
Browse files

Conversion of graph to dot.

parent b1c0417a
Pipeline #123194 passed with stages
in 86 minutes and 18 seconds
......@@ -39,3 +39,4 @@ tests:
- hspec
- sturdy-wasm
- prettyprinter
- fgl
module GraphToDot where
import Control.Arrow.Transformer.Abstract.Fix.ControlFlow (CFG(..))
import Data.Graph.Inductive.Graph
import Data.Graph.Inductive.PatriciaTree
graphToDot :: (stmt -> String) -> CFG stmt -> String
graphToDot f (CFG graph) =
let nodes = labNodes graph in
let edges = labEdges graph in
"digraph { " ++ concatMap toNode nodes ++ concatMap toEdge edges ++ "}"
where
toNode (n,inst) = (show n) ++"[label=\"" ++ (f inst) ++ "\"]; "
toEdge (from,to,_) = (show from) ++ " -> " ++ (show to) ++ "; "
......@@ -9,6 +9,7 @@ import UnitAnalysis as U
import UnitAnalysisValue
import Soundness
import GenericInterpreter(Exc(..))
import GraphToDot
--import Control.Arrow.Transformer.Abstract.WasmFrame (Vector(..))
--import Control.Arrow.Transformer.Abstract.Stack (AbsList(..))
......@@ -112,6 +113,13 @@ spec = do
let cfg = fst result
--putStrLn $ show cfg
(succResult result) `shouldBe` [Value $ VI32 ()]
it "print cfg" $ do
result <- runFunc "fact" "fac-rec" [Value $ VI64 ()]
let cfg = fst result
putStrLn (show cfg)
putStrLn $ graphToDot show cfg
pending
-- it "run non-terminating" $ do
-- validMod <- readModule "test/samples/simple.wast"
-- Right (modInst, store) <- instantiate validMod
......
Markdown is supported
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