tools/pas2c/Pas2C.hs
changeset 13887 5988e73080a3
parent 13878 0ce8aad17c24
child 14228 b01770d42517
equal deleted inserted replaced
13886:b6c35ac1c5ba 13887:5988e73080a3
   184 toCFiles :: String -> Map.Map String Records -> (String, PascalUnit) -> IO ()
   184 toCFiles :: String -> Map.Map String Records -> (String, PascalUnit) -> IO ()
   185 toCFiles _ _ (_, System _) = return ()
   185 toCFiles _ _ (_, System _) = return ()
   186 toCFiles _ _ (_, Redo _) = return ()
   186 toCFiles _ _ (_, Redo _) = return ()
   187 toCFiles outputPath ns pu@(fileName, _) = do
   187 toCFiles outputPath ns pu@(fileName, _) = do
   188     hPutStrLn stdout $ "Rendering '" ++ fileName ++ "'..."
   188     hPutStrLn stdout $ "Rendering '" ++ fileName ++ "'..."
       
   189     --let (fn, p) = pu in writeFile (outputPath ++ fn ++ ".dump") $ show p
   189     toCFiles' pu
   190     toCFiles' pu
   190     where
   191     where
   191     toCFiles' (fn, p@(Program {})) = writeFile (outputPath ++ fn ++ ".c") $ "#include \"fpcrtl.h\"\n" ++ (render2C initialState . pascal2C) p
   192     toCFiles' (fn, p@(Program {})) = writeFile (outputPath ++ fn ++ ".c") $ "#include \"fpcrtl.h\"\n" ++ (render2C initialState . pascal2C) p
   192     toCFiles' (fn, (Unit unitId@(Identifier i _) interface implementation _ _)) = do
   193     toCFiles' (fn, (Unit unitId@(Identifier i _) interface implementation _ _)) = do
   193         let (a, s) = runState (id2C IOInsert (setBaseType BTUnit unitId) >> interface2C interface True) initialState{currentUnit = map toLower i ++ "_"}
   194         let (a, s) = runState (id2C IOInsert (setBaseType BTUnit unitId) >> interface2C interface True) initialState{currentUnit = map toLower i ++ "_"}