Skip to content

Commit

Permalink
New: prettier printing of faulty ArgumentValues fact map
Browse files Browse the repository at this point in the history
  • Loading branch information
nponeccop committed Aug 4, 2013
1 parent 77370be commit 248b67e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
25 changes: 22 additions & 3 deletions HN/Optimizer/Visualise.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{-# LANGUAGE GADTs #-}
module HN.Optimizer.Visualise where

import Compiler.Hoopl
import Data.Functor.Foldable
import HN.Optimizer.Node
import Data.Functor.Fixedpoint
import Utils

instance Show (Node e x) where
show (Entry l) = show l
Expand All @@ -20,4 +21,22 @@ instance Show a => Show (ExpressionFunctor a) where
show e = case e of
Constant c -> show c
Atom aa -> show aa
Application a b -> show a ++ concatMap (\b -> ' ' : show b) b
Application a b -> show a ++ concatMap (\b -> ' ' : show b) b

foo x = concatMap ff $ mapToList x where
ff (l, x) = show l ++ " => " ++ case x of

Top -> "T\n"
Bot -> "\n"
PElem x -> concatMap bar x ++ "\n"

bar x = case x of
Top -> "T\n"
Bot -> "\n"
PElem x -> cata phi x ++ " "

phi x = case x of
Atom x -> show x
Constant x -> show x
Application a b -> "(" ++ a ++ " " ++ joinStr " " b ++ ")"

4 changes: 2 additions & 2 deletions Test/Optimizer/ArgumentValues.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import CPP.CompileTools
import HN.Optimizer.ArgumentValues
import HN.Optimizer.GraphCompiler
import HN.Optimizer.Visualise ()
import HN.Optimizer.Visualise
import FFI.TypeParser
import Compiler.Hoopl

main = do
ast <- parseHN "hn_tests/print15.hn"
ffi <- importHni "lib/lib.hni"
print $ run avPass $ fst $ compileGraph ffi $ head ast
putStrLn $ foo $ run avPass $ fst $ compileGraph ffi $ head ast

run pass graph = case runSimpleUniqueMonad . runWithFuel infiniteFuel $
analyzeAndRewriteFwd pass entry graph $
Expand Down

0 comments on commit 248b67e

Please sign in to comment.