From dc4cfe331b5898d6aa4a3b9df3c670a4766f5bf3 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 8 Apr 2009 12:23:45 +0000 Subject: [PATCH] Made the operator search ignore the values of array dimensions, as it should do --- frontends/OccamTypes.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/frontends/OccamTypes.hs b/frontends/OccamTypes.hs index 5b78d58..c3a995f 100644 --- a/frontends/OccamTypes.hs +++ b/frontends/OccamTypes.hs @@ -730,13 +730,13 @@ inferTypes = occamOnlyPass "Infer types" -- list (which will be the most recent) possibles <- return [ ((opFuncName, es'), ts) - | (raw, opFuncName, ts) <- nubBy ((==) `on` (\(op,_,ts) -> (op,ts))) $ csOperators cs + | (raw, opFuncName, ts) <- nubBy opsMatch $ csOperators cs -- Must be right operator: , raw == A.nameName n -- Must be right arity: , length ts == length es -- Must have right types: - , ts == tes + , ts `typesEqForOp` tes ] case possibles of [] -> diePC m $ formatCode ("No matching " ++ opDescrip ++ " operator definition found for types: %") tes @@ -749,6 +749,16 @@ inferTypes = occamOnlyPass "Infer types" where direct = error "Cannot direct channels passed to FUNCTIONs" + opsMatch (opA, _, tsA) (opB, _, tsB) = (opA == opB) && (tsA `typesEqForOp` tsB) + + typesEqForOp :: [A.Type] -> [A.Type] -> Bool + typesEqForOp tsA tsB = (length tsA == length tsB) && (and $ zipWith typeEqForOp tsA tsB) + + typeEqForOp :: A.Type -> A.Type -> Bool + typeEqForOp (A.Array ds t) (A.Array ds' t') + = (length ds == length ds') && typeEqForOp t t' + typeEqForOp t t' = t == t' + doActuals :: Data a => Meta -> A.Name -> [A.Formal] -> (Meta -> A.Direction -> Transform a) -> Transform [a] doActuals m n fs applyDir as