import SBP
import Types
import Util
+import Fleet
+import Compile
main = do t <- parseFile "src/edu/berkeley/fleet/f0/f0.g" "contrib/demo.f0"
putStrLn ""
writeFile "compiled.fleet" ("// compiled with f0\n\n"++compiled++"\n")
putStrLn ""
-compile :: Expr -> [Inst]
-compile (Decl _ _) = []
-compile (Seq s) = error "bleh"
-compile (Par e) = concatMap compile e
-compile (Move 1 s [d]) = [ (move s) { m_dest=(Just d) }, (accept d) ]
-compile (Move 1 s d) = [itake s]++sends++recvs
- where
- sends = map (\x -> ((send s) { m_dest=(Just x) })) d
- recvs = map (\x -> ((accept x) )) d
-compile (Literal 0 lit ds) = concatMap (\d -> [ ILiteral lit d, (accept d) {m_count=0} ]) ds
-compile (Literal 1 lit ds) = concatMap (\d -> [ ILiteral lit d, (accept d) ]) ds
-compile (Literal n lit ds) = concatMap (\d -> [ ILiteral lit d, (accept d) {m_count=n} ]) ds
-
-getdecls (Decl n t) = ["#ship " ++ n ++ " : " ++ t]
-getdecls (Seq es) = concatMap getdecls es
-getdecls (Par es) = concatMap getdecls es
-getdecls _ = []
-
-compileDef (Def s _ _ e) =
- "// " ++ s ++ "\n" ++
- (join "\n" $ getdecls e)++"\n"++
- (join "\n" $ map show (compile e))
-
-itake box = IMove { m_count=1, m_recycle=False, m_tokenIn=False, m_dataIn=True,
- m_latch=True, m_dataOut=False, m_tokenOut=False, m_dest=Nothing,
- m_benkobox=box }
-move box = (itake box){ m_dataOut=True }
-send box = (move box){ m_dataIn=False, m_latch=False }
-accept box = move box
-
-
-
\end{code}