From 8e5e73e3a2dde4fc7e73a6b25aea5f4146784856 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Thu, 19 Mar 2009 15:23:35 +0000 Subject: [PATCH] Fixed the support in the backends for mobile channel stuff --- backends/GenerateC.hs | 28 +++++++++++++++++++++++++--- common/EvalConstants.hs | 1 + 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/backends/GenerateC.hs b/backends/GenerateC.hs index 0b61cd7..6d73844 100644 --- a/backends/GenerateC.hs +++ b/backends/GenerateC.hs @@ -1073,6 +1073,12 @@ cgenInputItem c (A.InVariable m v) tell [","] rhs tell [");"] + A.Mobile {} -> + do tell ["MTChanIn(wptr,"] + call genVariable c + tell [",(void*)"] + rhs + tell [");"] _ -> do tell ["ChanIn(wptr,"] call genVariable c @@ -1099,21 +1105,37 @@ cgenOutputItem c (A.OutCounted m ce ae) call genBytesIn m subT (Right v) tell [");"] cgenOutputItem c (A.OutExpression m e) - = do t <- astTypeOf e - case (t, e) of + = do t <- astTypeOf c + let innerT = case t of + A.Chan _ t' -> t' + A.ChanEnd _ _ t' -> t' + case (innerT, e) of (A.Int, _) -> do tell ["ChanOutInt(wptr,"] call genVariable c tell [","] call genExpression e tell [");"] + (A.Mobile {}, A.ExprVariable _ (A.DerefVariable _ v)) -> + do tell ["{void* outtmp = MTClone(*"] + call genVariableAM v A.Abbrev + tell [");MTChanOut(wptr,"] + call genVariable c + tell [",&outtmp);}"] + (A.Mobile {}, A.ExprVariable _ v) -> + do tell ["MTChanOut(wptr,"] + call genVariable c + tell [",(void*)"] + call genVariableAM v A.Abbrev + tell [");"] (_, A.ExprVariable _ v) -> do tell ["ChanOut(wptr,"] call genVariable c tell [","] call genVariableAM v A.Abbrev tell [","] - call genBytesIn m t (Right v) + te <- astTypeOf e + call genBytesIn m te (Right v) tell [");"] --}}} diff --git a/common/EvalConstants.hs b/common/EvalConstants.hs index 1ff467c..608a61f 100644 --- a/common/EvalConstants.hs +++ b/common/EvalConstants.hs @@ -107,6 +107,7 @@ evalVariable (A.Variable m n) Nothing -> throwError (Just m, "non-constant variable " ++ show n ++ " used") evalVariable (A.SubscriptedVariable _ sub v) = evalVariable v >>= evalSubscript sub evalVariable (A.DirectedVariable _ _ v) = evalVariable v +evalVariable (A.DerefVariable _ v) = evalVariable v evalIndex :: A.Expression -> EvalM Int evalIndex e