From 78716a2727727f0eb045e106784e838f682f7f9f Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 26 Nov 2008 12:24:21 +0000 Subject: [PATCH] Added a CHP backend option to Tock --- Main.hs | 6 ++++-- Makefile.am | 1 + backends/GenerateCHP.hs | 30 ++++++++++++++++++++++++++++++ data/CompState.hs | 2 +- 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 backends/GenerateCHP.hs diff --git a/Main.hs b/Main.hs index e8bb446..f458a55 100644 --- a/Main.hs +++ b/Main.hs @@ -42,6 +42,7 @@ import CompState import Errors import FlowGraph import GenerateC +import GenerateCHP import GenerateCPPCSP import LexOccam import Metadata @@ -114,6 +115,7 @@ optBackend :: String -> OptFunc optBackend s ps = do backend <- case s of "c" -> return BackendC + "chp" -> return BackendCHP "cppcsp" -> return BackendCPPCSP "dumpast" -> return BackendDumpAST "src" -> return BackendSource @@ -481,8 +483,8 @@ compile mode fn (outHandles@(outHandle, _), headerName) let generator :: A.AST -> PassM () generator = case csBackend optsPS of - BackendC -> generateC outHandles headerName - BackendCPPCSP -> generateCPPCSP outHandles headerName + BackendC -> generateC outHandle + BackendCPPCSP -> generateCPPCSP outHandle BackendDumpAST -> liftIO . hPutStr outHandle . pshow BackendSource -> (liftIO . hPutStr outHandle) <.< showCode generator ast2 diff --git a/Makefile.am b/Makefile.am index 8a27ad1..f8498ca 100644 --- a/Makefile.am +++ b/Makefile.am @@ -143,6 +143,7 @@ tock_SOURCES_hs += backends/AnalyseAsm.hs tock_SOURCES_hs += backends/BackendPasses.hs tock_SOURCES_hs += backends/GenerateC.hs tock_SOURCES_hs += backends/GenerateCBased.hs +tock_SOURCES_hs += backends/GenerateCHP.hs tock_SOURCES_hs += backends/GenerateCPPCSP.hs tock_SOURCES_hs += backends/TLP.hs tock_SOURCES_hs += checks/ArrayUsageCheck.hs diff --git a/backends/GenerateCHP.hs b/backends/GenerateCHP.hs new file mode 100644 index 0000000..844b895 --- /dev/null +++ b/backends/GenerateCHP.hs @@ -0,0 +1,30 @@ +{- +Tock: a compiler for parallel languages +Copyright (C) 2008 University of Kent + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation, either version 2 of the License, or (at your +option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +-} + +-- | Generate CHP code from the AST +module GenerateCHP where + +import System.IO + +import qualified AST as A +import Pass + +generateCHP :: Handle -> A.AST -> PassM () +generateCHP h tr = genAST tr + +genAST _ = return () diff --git a/data/CompState.hs b/data/CompState.hs index ebddab0..beb4201 100644 --- a/data/CompState.hs +++ b/data/CompState.hs @@ -45,7 +45,7 @@ data CompMode = ModeFlowGraph | ModeLex | ModeHTML | ModeParse | ModeCompile | M deriving (Show, Data, Typeable, Eq) -- | Backends that Tock can use. -data CompBackend = BackendC | BackendCPPCSP | BackendDumpAST | BackendSource +data CompBackend = BackendC | BackendCPPCSP | BackendCHP | BackendDumpAST | BackendSource deriving (Show, Data, Typeable, Eq) -- | Frontends that Tock can use.