can't do this! killing myself tonight ‼️ here's three lines of code i spent four hours on
This commit is contained in:
54
src/TI.hs
Normal file
54
src/TI.hs
Normal file
@@ -0,0 +1,54 @@
|
||||
module TI where
|
||||
----------------------------------------------------------------------------------
|
||||
import Data.Map (Map, (!?), (!))
|
||||
import qualified Data.Map as M
|
||||
import Data.Set (Set)
|
||||
import qualified Data.Set as S
|
||||
import Data.Maybe (fromJust)
|
||||
import Data.List (mapAccumL)
|
||||
import Core
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
data TiState = TiState [Addr] Dump Heap [(Name, Addr)] Stats
|
||||
|
||||
type Heap = Set Node
|
||||
|
||||
data Node = NAp Addr Addr
|
||||
| NSupercomb Name [Name] Expr
|
||||
| NNum Int
|
||||
|
||||
data Dump = DumpTempDummy
|
||||
|
||||
type Stats = Int
|
||||
|
||||
type Addr = Int
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
tiStatIncSteps :: Stats -> Stats
|
||||
tiStatIncSteps = (+1)
|
||||
|
||||
tiStatGetSteps :: Stats -> Int
|
||||
tiStatGetSteps = id
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
compile :: Program -> Maybe TiState
|
||||
compile prog = Just $ TiState s d h g stats
|
||||
where
|
||||
s = [mainAddr]
|
||||
d = DumpTempDummy
|
||||
(h,g) = buildInitialHeap defs
|
||||
defs = prog <> corePrelude
|
||||
stats = undefined
|
||||
|
||||
mainAddr = fromJust $ lookup "main" g
|
||||
|
||||
buildInitialHeap :: Program -> (Heap, [(Name, Addr)])
|
||||
buildInitialHeap = undefined
|
||||
|
||||
-- buildInitialHeap (Program scdefs) = mapAccumL allocateSc mempty scdefs
|
||||
-- where
|
||||
-- allocateSc :: Heap -> ScDef -> (Heap, (Name, Addr))
|
||||
-- allocateSc = undefined
|
||||
|
||||
Reference in New Issue
Block a user