From 9e8dd73149658d8e97ea5f7ff5779cf4deaddd74 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 22 Aug 2007 16:10:47 +0000 Subject: [PATCH] Fixed the C++CSP backend by allowing it to override the tock_support.h header file with tock_support_cppcsp.h (the latter includes the former, but only after defining some preprocessor directives) --- GenerateC.hs | 8 ++++---- GenerateCPPCSP.hs | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/GenerateC.hs b/GenerateC.hs index dc66bf9..ee7b568 100644 --- a/GenerateC.hs +++ b/GenerateC.hs @@ -216,15 +216,15 @@ cgenOps = GenOps { --}}} --{{{ top-level -generate :: GenOps -> A.Process -> PassM String -generate ops ast +generate :: GenOps -> String -> A.Process -> PassM String +generate ops headerFileName ast = do (a, w) <- runWriterT (call genTopLevel ops ast) gds <- getGeneratedDefs - let out = ["#include \n"] ++ gds ++ w + let out = ["#include ",headerFileName,"\n"] ++ gds ++ w return $ concat out generateC :: A.Process -> PassM String -generateC = generate cgenOps +generateC = generate cgenOps "" cgenTLPChannel :: GenOps -> TLPChannel -> CGen () cgenTLPChannel _ TLPIn = tell ["in"] diff --git a/GenerateCPPCSP.hs b/GenerateCPPCSP.hs index 60d6066..8e6eb14 100644 --- a/GenerateCPPCSP.hs +++ b/GenerateCPPCSP.hs @@ -131,12 +131,11 @@ In occam-pi I could possibly use the channel-ends properly, but in occam 2.1 I h --{{{ top-level generateCPPCSP :: A.Process -> PassM String -generateCPPCSP = generate cppgenOps +generateCPPCSP = generate cppgenOps "" cppgenTopLevel :: GenOps -> A.Process -> CGen () cppgenTopLevel ops p - = do tell ["#include \n"] - call genProcess ops p + = do call genProcess ops p (name, chans) <- tlpInterface tell ["int main (int argc, char** argv) { csp::Start_CPPCSP();"] tell ["csp::One2OneChannel in,out,err;"] --TODO add streamreader