Changeset 11217

Show
Ignore:
Timestamp:
06.01.2009 17:15:36 (11 months ago)
Author:
csliam
Message:

Static analysis of CspCASL now returns some events as fully qualified events - but not all (yet)

Location:
trunk/CspCASL
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/CspCASL/CspProver_Consts.hs

    r10436 r11217  
    182182-- Conditional operator symbols 
    183183cspProver_conditionalS :: String 
    184 cspProver_conditionalS = "CONDITIONAL" 
     184cspProver_conditionalS = "IF" 
    185185cspProver_conditionalAltS :: String 
    186 cspProver_conditionalAltS = "(CONDITIONAL _ THEN _ ELSE _)" 
     186cspProver_conditionalAltS = "(IF _ THEN _ ELSE _)" 
    187187cspProver_conditionalAltArgPrios :: [Int] 
    188188cspProver_conditionalAltArgPrios = [900,88,88] 
  • trunk/CspCASL/SignCSP.hs

    r11215 r11217  
    179179-- Sentences 
    180180 
    181 -- A CspCASl senetence is either a CASL formula or a Procsses 
    182 -- equation. A process equation has on the LHS a process name, a list 
    183 -- of parameters which are qualified variables (which are terms), a 
    184 -- constituent communication alphabet and finally on the RHS a fully 
    185 -- qualified process. 
     181-- | A CspCASl senetence is either a CASL formula or a Procsses 
     182--   equation. A process equation has on the LHS a process name, a 
     183--   list of parameters which are qualified variables (which are 
     184--   terms), a constituent( or is it permitted ?) communication alphabet and 
     185--   finally on the RHS a fully qualified process. 
    186186data CspCASLSen = CASLSen (FORMULA ()) 
    187187                | ProcessEq PROCESS_NAME ProcVarList CommAlpha PROCESS 
  • trunk/CspCASL/StatAnaCSP.hs

    r11216 r11217  
    1919import qualified Control.Monad as Monad 
    2020import qualified Data.Map as Map 
    21 import qualified Data.Maybe as Maybe 
    2221import qualified Data.Set as S 
    2322-- liam added the following, they should be deleted from imports when 
     
    3736import Common.ConvertGlobalAnnos 
    3837import qualified Common.Lib.Rel as Rel 
    39 import Common.Id (getRange, Id, simpleIdToId, nullRange) 
     38import Common.Id (getRange, Id, simpleIdToId) 
    4039import Common.Lib.State 
    4140import Common.ExtSign 
     
    257256    PrefixProcess e p range -> 
    258257        do addDiags [mkDiag Debug "Prefix" proc] 
    259            (evComms, rcvMap) <- anaEvent e (lVars `Map.union` gVars) 
     258           (evComms, rcvMap, fqEvent) <- anaEvent e (lVars `Map.union` gVars) 
    260259           (comms, pFQTerm) <- anaProcTerm p gVars (rcvMap `Map.union` lVars) 
    261260           return (comms `S.union` evComms, 
    262                    FQProcess (PrefixProcess e pFQTerm range) (comms `S.union` evComms) range) 
     261                   FQProcess (PrefixProcess fqEvent pFQTerm range) (comms `S.union` evComms) range) 
    263262    InternalPrefixProcess v s p range -> 
    264263        do addDiags [mkDiag Debug "Internal prefix" proc] 
     
    340339           -- mfs is the fully qualified formula version of f 
    341340           mfs <- anaFormulaCspCASL (gVars `Map.union` lVars) f 
    342            addDiags [mkDiag Debug "Formula" f] 
    343            addDiags [mkDiag Debug "FQFormula" (Maybe.fromJust mfs)] 
     341           let fFQ = case mfs of 
     342                       Nothing -> f -- use olf formula as the fully qualified version 
     343                       Just fs -> fs -- use the real fully qualified formula 
    344344           let fComms = case mfs of 
    345345                          Nothing -> S.empty 
    346346                          Just fs -> formulaComms fs 
    347            return (S.unions [pComms, qComms, fComms], 
    348                    FQProcess (ConditionalProcess (Maybe.fromJust mfs) pFQTerm qFQTerm range) 
    349                                  (S.unions [pComms, qComms, fComms]) range) 
     347           let newAlpha = S.unions [pComms, qComms, fComms] 
     348           let fqProc = FQProcess (ConditionalProcess 
     349                                   (fFQ) pFQTerm qFQTerm range) 
     350                        newAlpha range 
     351           return (newAlpha, fqProc) 
    350352 
    351353-- | Statically analyse a CspCASL "named process" term. 
     
    409411-- Static analysis of events 
    410412 
    411 -- | Statically analyse a CspCASL event. 
    412 anaEvent :: EVENT -> ProcVarMap -> State CspCASLSign (CommAlpha, ProcVarMap) 
     413-- | Statically analyse a CspCASL event. Returns a constituent 
     414--   communication alphabet of the event, mapping for any new 
     415--   locally bound variables and a fully qualified version of the event. 
     416anaEvent :: EVENT -> ProcVarMap -> State CspCASLSign (CommAlpha, ProcVarMap, EVENT) 
    413417anaEvent e vars = case e of 
    414                     TermEvent t _ -> anaTermEvent t vars 
    415                     ChanSend c t _ -> anaChanSend c t vars 
    416                     ChanNonDetSend c v s _ -> anaChanBinding c v s 
    417                     ChanRecv c v s _ -> anaChanBinding c v s 
    418  
    419 -- | Statically analyse a CspCASL term event. 
     418                    TermEvent t r -> 
     419                        do (alpha, newVars, fqTerm) <- anaTermEvent t vars 
     420                           return (alpha, newVars, TermEvent fqTerm r) 
     421                    ChanSend c t r -> 
     422                        -- BUG - not returning a fully qualified event 
     423                        do (alpha, newVars, fqTerm) <- anaChanSend c t vars 
     424                           return (alpha, newVars, ChanSend c fqTerm r) 
     425                    ChanNonDetSend c v s r -> 
     426                        -- BUG - not returning a fully qualified event 
     427                        do (alpha, newVars) <- anaChanBinding c v s 
     428                           return (alpha, newVars, ChanNonDetSend c v s r) 
     429                    ChanRecv c v s r -> 
     430                        -- BUG - not returning a fully qualified event 
     431                        do (alpha, newVars) <- anaChanBinding c v s 
     432                           return (alpha, newVars, ChanRecv c v s r) 
     433 
     434-- | Statically analyse a CspCASL term event. Returns a constituent 
     435--   communication alphabet of the event and a mapping for any new 
     436--   locally bound variables and the fully qualified version of the 
     437--   term. 
    420438anaTermEvent :: (TERM ()) -> ProcVarMap -> 
    421                 State CspCASLSign (CommAlpha, ProcVarMap) 
     439                State CspCASLSign (CommAlpha, ProcVarMap, TERM ()) 
    422440anaTermEvent t vars = do 
    423441  mt <- anaTermCspCASL vars t 
    424   let alpha = case mt of 
    425                 Just at -> [(CommTypeSort (sortOfTerm at))] 
    426                 Nothing -> [] 
    427   return (S.fromList alpha, Map.empty) 
    428  
    429 -- | Statically analyse a CspCASL channel send event. 
     442  let (alpha, t') = case mt of 
     443                      -- return the alphabet and the fully qualified term 
     444                      Just at -> ([(CommTypeSort (sortOfTerm at))], at) 
     445                      -- return the empty alphabet and the original term 
     446                      Nothing -> ([], t) 
     447  return (S.fromList alpha, Map.empty, t') 
     448 
     449-- | Statically analyse a CspCASL channel send event. Returns a constituent 
     450--   communication alphabet of the event and a mapping for any new 
     451--   locally bound variables and the fully qualified version of the 
     452--   term. 
    430453anaChanSend :: CHANNEL_NAME -> (TERM ()) -> ProcVarMap -> 
    431                 State CspCASLSign (CommAlpha, ProcVarMap) 
     454                State CspCASLSign (CommAlpha, ProcVarMap, TERM ()) 
    432455anaChanSend c t vars = do 
    433456  sig <- get 
     
    436459    Nothing -> do 
    437460      addDiags [mkDiag Error "unknown channel" c] 
    438       return (S.empty, Map.empty) 
     461      return (S.empty, Map.empty, t) 
    439462    Just chanSort -> do 
    440463      mt <- anaTermCspCASL vars t 
    441464      case mt of 
    442465        Nothing -> -- CASL analysis failed 
    443                    return (S.empty, Map.empty) 
     466                   -- Use old term as the fully qualified term 
     467                   return (S.empty, Map.empty, t) 
    444468        (Just at) -> 
    445469            do mc <- ccTermCast at chanSort 
    446470               case mc of 
    447471                 Nothing -> -- cast failed 
    448                             return (S.empty, Map.empty) 
     472                            -- Use old term as the fully qualified term 
     473                            return (S.empty, Map.empty, t) 
    449474                 (Just ct) -> 
    450475                     do let castSort = sortOfTerm ct 
     
    452477                                    ,CommTypeChan $ TypedChanName c castSort 
    453478                                    ] 
    454                         return (S.fromList alpha, Map.empty) 
     479                        -- Use the real fully qualified term 
     480                        return (S.fromList alpha, Map.empty, ct) 
    455481 
    456482-- | Statically analyse a CspCASL "binding" channel event (which is 
     
    599625                     State CspCASLSign (Maybe (FORMULA ())) 
    600626anaFormulaCspCASL pm f = do 
    601     addDiags [mkDiag Debug "anaFormulaCspCASL" ()] 
     627    addDiags [mkDiag Debug "anaFormulaCspCASL" f] 
    602628    sig <- get 
    603629    let newVars = Map.union pm (varMap sig)