Changed the AST to fix the different unknown/inferred types

The Infer type (used by the occam frontend) is now separated from the "Unknown" types used in type unification that I'm experimenting with in Rain.
This commit is contained in:
Neil Brown 2008-05-17 12:47:31 +00:00
parent e72e95625a
commit e6162877af
2 changed files with 17 additions and 6 deletions

View File

@ -225,8 +225,12 @@ instance ShowOccam A.Type where
showOccamM A.Any = tell ["ANY"]
showOccamM (A.Timer _) = tell ["TIMER"]
showOccamM A.Time = tell ["TIME"]
showOccamM A.Infer = tell ["(inferred type)"]
showOccamM (A.InferNum n) = tell ["(inferred numeric type: ",show n,")"]
showOccamM (A.UnknownVarType en)
= do tell ["(inferred type for: "]
either showName (const $ return ()) en
tell [")"]
showOccamM (A.UnknownNumLitType m _ n)
= tell ["(inferred numeric type: ",show m," ",show n,")"]
showOccamM (A.Mobile t) = tell ["MOBILE "] >> showOccamM t
showOccamM (A.Array ds t)
= (sequence dims) >> showOccamM t
@ -267,8 +271,12 @@ instance ShowRain A.Type where
-- Mobility is not explicit in Rain:
showRainM (A.Mobile t) = showRainM t
showRainM (A.List t) = tell ["["] >> showRainM t >> tell ["]"]
showRainM A.Infer = tell ["(inferred type)"]
showRainM (A.InferNum n) = tell ["(inferred numeric type: ",show n,")"]
showRainM (A.UnknownVarType en)
= do tell ["(inferred type for: "]
either showName (const $ return ()) en
tell [")"]
showRainM (A.UnknownNumLitType m _ n)
= tell ["(inferred numeric type: ",show m," ",show n,")"]
showRainM x = tell ["<invalid Rain type: ", show x, ">"]
instance ShowOccam A.DyadicOp where

View File

@ -144,9 +144,12 @@ data Type =
| Mobile Type
-- | A type that will be inferred automatically by a pass.
| Infer
-- | A type that will be inferred by type unification. Either for a named
-- variable, or for an anonymous, uniquely identified, expression
| UnknownVarType (Either Name (Meta, Int))
-- | A numeric type to be inferred later, that must be able to hold the given
-- value
| InferNum Integer
-- value. The Int is a unique identifier, the Integer is the number to hold
| UnknownNumLitType Meta Int Integer
deriving (Show, Eq, Typeable, Data)
-- | An array dimension.