unproductive day i fear
This commit is contained in:
150
src/TIM.hs
150
src/TIM.hs
@@ -71,7 +71,7 @@ compile prog = Just $ TiState s d h g stats
|
||||
s = [mainAddr]
|
||||
d = []
|
||||
(h,g) = buildInitialHeap defs
|
||||
defs = prog <> corePrelude
|
||||
defs = insertModule corePrelude prog
|
||||
stats = Stats 0 0 0
|
||||
|
||||
mainAddr = fromJust $ lookup "main" g
|
||||
@@ -422,91 +422,91 @@ hdbgProg p hio = do
|
||||
TiState [resAddr] _ h _ sts = last p'
|
||||
res = hLookupUnsafe resAddr h
|
||||
|
||||
letrecExample :: Program
|
||||
letrecExample = Program
|
||||
[ ScDef "pair" ["x","y","f"] $ "f" :$ "x" :$ "y"
|
||||
, ScDef "fst" ["p"] $ "p" :$ "K"
|
||||
, ScDef "snd" ["p"] $ "p" :$ "K1"
|
||||
, ScDef "f" ["x","y"] $
|
||||
Let Rec
|
||||
[ "a" := "pair" :$ "x" :$ "b"
|
||||
, "b" := "pair" :$ "y" :$ "a"
|
||||
]
|
||||
("fst" :$ ("snd" :$ ("snd" :$ ("snd" :$ "a"))))
|
||||
, ScDef "main" [] $ "f" :$ IntE 3 :$ IntE 4
|
||||
]
|
||||
-- letrecExample :: Program
|
||||
-- letrecExample = Program
|
||||
-- [ ScDef "pair" ["x","y","f"] $ "f" :$ "x" :$ "y"
|
||||
-- , ScDef "fst" ["p"] $ "p" :$ "K"
|
||||
-- , ScDef "snd" ["p"] $ "p" :$ "K1"
|
||||
-- , ScDef "f" ["x","y"] $
|
||||
-- Let Rec
|
||||
-- [ "a" := "pair" :$ "x" :$ "b"
|
||||
-- , "b" := "pair" :$ "y" :$ "a"
|
||||
-- ]
|
||||
-- ("fst" :$ ("snd" :$ ("snd" :$ ("snd" :$ "a"))))
|
||||
-- , ScDef "main" [] $ "f" :$ IntE 3 :$ IntE 4
|
||||
-- ]
|
||||
|
||||
idExample :: Program
|
||||
idExample = Program
|
||||
[ ScDef "main" [] $ "id" :$ IntE 3
|
||||
]
|
||||
-- idExample :: Program
|
||||
-- idExample = Program
|
||||
-- [ ScDef "main" [] $ "id" :$ IntE 3
|
||||
-- ]
|
||||
|
||||
indExample1 :: Program
|
||||
indExample1 = Program
|
||||
[ ScDef "main" [] $ "twice" :$ "twice" :$ "id" :$ IntE 3
|
||||
]
|
||||
-- indExample1 :: Program
|
||||
-- indExample1 = Program
|
||||
-- [ ScDef "main" [] $ "twice" :$ "twice" :$ "id" :$ IntE 3
|
||||
-- ]
|
||||
|
||||
indExample2 :: Program
|
||||
indExample2 = Program
|
||||
[ ScDef "main" [] $ "twice" :$ "twice" :$ "twice" :$ "id" :$ IntE 3
|
||||
]
|
||||
-- indExample2 :: Program
|
||||
-- indExample2 = Program
|
||||
-- [ ScDef "main" [] $ "twice" :$ "twice" :$ "twice" :$ "id" :$ IntE 3
|
||||
-- ]
|
||||
|
||||
indExample3 :: Program
|
||||
indExample3 = Program
|
||||
[ ScDef "main" [] $
|
||||
Let Rec
|
||||
[ "x" := IntE 2
|
||||
, "y" := "f" :$ "x" :$ "x"
|
||||
]
|
||||
("g" :$ "y" :$ "y")
|
||||
, ScDef "f" ["a","b"] $ "b"
|
||||
, ScDef "g" ["a","b"] $ "a"
|
||||
]
|
||||
-- indExample3 :: Program
|
||||
-- indExample3 = Program
|
||||
-- [ ScDef "main" [] $
|
||||
-- Let Rec
|
||||
-- [ "x" := IntE 2
|
||||
-- , "y" := "f" :$ "x" :$ "x"
|
||||
-- ]
|
||||
-- ("g" :$ "y" :$ "y")
|
||||
-- , ScDef "f" ["a","b"] $ "b"
|
||||
-- , ScDef "g" ["a","b"] $ "a"
|
||||
-- ]
|
||||
|
||||
negExample1 :: Program
|
||||
negExample1 = Program
|
||||
[ ScDef "main" [] $
|
||||
"negate#" :$ ("id" :$ IntE 3)
|
||||
]
|
||||
-- negExample1 :: Program
|
||||
-- negExample1 = Program
|
||||
-- [ ScDef "main" [] $
|
||||
-- "negate#" :$ ("id" :$ IntE 3)
|
||||
-- ]
|
||||
|
||||
negExample2 :: Program
|
||||
negExample2 = Program
|
||||
[ ScDef "main" [] $
|
||||
"negate#" :$ IntE 3
|
||||
]
|
||||
-- negExample2 :: Program
|
||||
-- negExample2 = Program
|
||||
-- [ ScDef "main" [] $
|
||||
-- "negate#" :$ IntE 3
|
||||
-- ]
|
||||
|
||||
negExample3 :: Program
|
||||
negExample3 = Program
|
||||
[ ScDef "main" [] $
|
||||
"twice" :$ "negate#" :$ IntE 3
|
||||
]
|
||||
-- negExample3 :: Program
|
||||
-- negExample3 = Program
|
||||
-- [ ScDef "main" [] $
|
||||
-- "twice" :$ "negate#" :$ IntE 3
|
||||
-- ]
|
||||
|
||||
arithExample1 :: Program
|
||||
arithExample1 = Program
|
||||
[ ScDef "main" [] $
|
||||
"+#" :$ (IntE 3) :$ ("negate#" :$ (IntE 2))
|
||||
]
|
||||
-- arithExample1 :: Program
|
||||
-- arithExample1 = Program
|
||||
-- [ ScDef "main" [] $
|
||||
-- "+#" :$ (IntE 3) :$ ("negate#" :$ (IntE 2))
|
||||
-- ]
|
||||
|
||||
arithExample2 :: Program
|
||||
arithExample2 = Program
|
||||
[ ScDef "main" [] $
|
||||
"negate#" :$ ("+#" :$ (IntE 2) :$ ("*#" :$ IntE 5 :$ IntE 3))
|
||||
]
|
||||
-- arithExample2 :: Program
|
||||
-- arithExample2 = Program
|
||||
-- [ ScDef "main" [] $
|
||||
-- "negate#" :$ ("+#" :$ (IntE 2) :$ ("*#" :$ IntE 5 :$ IntE 3))
|
||||
-- ]
|
||||
|
||||
ifExample :: Program
|
||||
ifExample = Program
|
||||
[ ScDef "main" [] $
|
||||
"if#" :$ "True" :$ IntE 2 :$ IntE 3
|
||||
]
|
||||
-- ifExample :: Program
|
||||
-- ifExample = Program
|
||||
-- [ ScDef "main" [] $
|
||||
-- "if#" :$ "True" :$ IntE 2 :$ IntE 3
|
||||
-- ]
|
||||
|
||||
facExample :: Program
|
||||
facExample = Program
|
||||
[ ScDef "fac" ["n"] $
|
||||
"if#" :$ ("==#" :$ "n" :$ IntE 0)
|
||||
:$ (IntE 1)
|
||||
:$ ("*#" :$ "n" :$ ("fac" :$ ("-#" :$ "n" :$ IntE 1)))
|
||||
, ScDef "main" [] $ "fac" :$ IntE 3
|
||||
]
|
||||
-- facExample :: Program
|
||||
-- facExample = Program
|
||||
-- [ ScDef "fac" ["n"] $
|
||||
-- "if#" :$ ("==#" :$ "n" :$ IntE 0)
|
||||
-- :$ (IntE 1)
|
||||
-- :$ ("*#" :$ "n" :$ ("fac" :$ ("-#" :$ "n" :$ IntE 1)))
|
||||
-- , ScDef "main" [] $ "fac" :$ IntE 3
|
||||
-- ]
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user