From 4e6b166696558ac85b33ba9df7cd5562b03a9f17 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Sun, 1 Jun 2008 19:46:32 +0000 Subject: [PATCH] Fixed implicit mobility to work in the (C++, at least) backend --- backends/GenerateC.hs | 1 + common/ShowCode.hs | 5 ++--- support/tock_support_cppcsp.h | 11 ++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/backends/GenerateC.hs b/backends/GenerateC.hs index f34f3e3..9c9223d 100644 --- a/backends/GenerateC.hs +++ b/backends/GenerateC.hs @@ -1506,6 +1506,7 @@ cgenAssign m [v] (A.ExpressionList _ [e]) A.Chan A.DirInput _ _ -> doAssign v e A.Chan A.DirOutput _ _ -> doAssign v e A.List _ -> call genListAssign v e + A.Mobile (A.List _) -> call genListAssign v e _ -> call genMissingC $ formatCode "assignment of type %" t where doAssign :: A.Variable -> A.Expression -> CGen () diff --git a/common/ShowCode.hs b/common/ShowCode.hs index eab30d8..e4d4eb6 100644 --- a/common/ShowCode.hs +++ b/common/ShowCode.hs @@ -278,8 +278,8 @@ instance ShowRain A.Type where ao :: Bool -> String ao b = if b then "any" else "one" showRainM A.Time = tell ["time"] - -- Mobility is not explicit in Rain: - showRainM (A.Mobile t) = showRainM t + -- Mobility is not explicit in Rain, but we should indicate it: + showRainM (A.Mobile t) = tell [""] >> showRainM t showRainM (A.List t) = tell ["["] >> showRainM t >> tell ["]"] showRainM (A.UnknownVarType en) = do tell ["(inferred type for: "] @@ -431,7 +431,6 @@ instance ShowRain A.Expression where showRainM (A.ExprConstr _ (A.RepConstr _ _ r e)) = tell ["["] >> showRainM e >> tell ["|"] >> showRainM r >> tell ["]"] - instance ShowOccam A.Formal where showOccamM (A.Formal am t n) = (maybeVal am) >> (showOccamM t) diff --git a/support/tock_support_cppcsp.h b/support/tock_support_cppcsp.h index f63363b..7bd1bd9 100644 --- a/support/tock_support_cppcsp.h +++ b/support/tock_support_cppcsp.h @@ -359,12 +359,21 @@ public: : ref(_ref) { } - + + /* //If you dereference both sides, you get a proper copy-assignment: inline void operator=(const derefTockList& _rhs) { ref->data = _rhs.ref->data; } + */ + + inline operator tockList() + { + tockList x; + x.data = ref->data; + return x; + } }; derefTockList operator*()