Got pragma-declared FUNCTIONS to be turned into PROCs and handled properly

This commit is contained in:
Neil Brown 2009-04-02 18:13:51 +00:00
parent 460c3e287f
commit 70789661f1
2 changed files with 15 additions and 3 deletions

View File

@ -1415,13 +1415,13 @@ pragma = do m <- getPosition >>* sourcePosToMeta
return (n, ProcName, n, fs, A.Proc m (A.PlainSpec, A.PlainRec) fs (A.Skip m))
else do sPROC
origN <- anyName ProcName
fs <- formalList >>* map fst
fs <- formalList'
sEq
n <- newProcName
return (n, ProcName, origN, fs, A.Proc m (A.PlainSpec, A.PlainRec) fs (A.Skip m))
<|> do ts <- tryVX (sepBy1 dataType sComma) sFUNCTION
origN <- anyName FunctionName
fs <- formalList >>* map fst
fs <- formalList'
sEq
n <- newFunctionName
return (n, FunctionName, origN, fs, A.Function m (A.PlainSpec, A.PlainRec) ts fs
@ -1451,6 +1451,10 @@ pragma = do m <- getPosition >>* sourcePosToMeta
isPragma (Token _ p@(Pragma {})) = Just p
isPragma _ = Nothing
formalList' = do fs <- formalList >>= scopeInFormals
scopeOutFormals fs
return fs
--}}}
--{{{ processes
process :: OccParser A.Process

View File

@ -51,7 +51,15 @@ functionsToProcs = pass "Convert FUNCTIONs to PROCs"
(Prop.agg_namesDone ++ [Prop.expressionTypesChecked, Prop.parUsageChecked,
Prop.functionTypesChecked])
[Prop.functionsRemoved]
(applyDepthM doSpecification)
(\t -> do exts <- getCompState >>* csExternals
exts' <- sequence [do st <- specTypeOfName $ A.Name emptyMeta n
A.Specification _ _ st'@(A.Proc _ _ fs' _) <-
doSpecification $ A.Specification
(findMeta st) (A.Name emptyMeta n) st
return $ (n, (extType, fs'))
| (n, (extType, fs)) <- exts]
modify $ \cs -> cs { csExternals = exts' }
applyDepthM doSpecification t)
where
doSpecification :: A.Specification -> PassM A.Specification
doSpecification (A.Specification m n (A.Function mf smrm rts fs evp))