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:
parent
e72e95625a
commit
e6162877af
|
@ -225,8 +225,12 @@ instance ShowOccam A.Type where
|
||||||
showOccamM A.Any = tell ["ANY"]
|
showOccamM A.Any = tell ["ANY"]
|
||||||
showOccamM (A.Timer _) = tell ["TIMER"]
|
showOccamM (A.Timer _) = tell ["TIMER"]
|
||||||
showOccamM A.Time = tell ["TIME"]
|
showOccamM A.Time = tell ["TIME"]
|
||||||
showOccamM A.Infer = tell ["(inferred type)"]
|
showOccamM (A.UnknownVarType en)
|
||||||
showOccamM (A.InferNum n) = tell ["(inferred numeric type: ",show n,")"]
|
= 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.Mobile t) = tell ["MOBILE "] >> showOccamM t
|
||||||
showOccamM (A.Array ds t)
|
showOccamM (A.Array ds t)
|
||||||
= (sequence dims) >> showOccamM t
|
= (sequence dims) >> showOccamM t
|
||||||
|
@ -267,8 +271,12 @@ instance ShowRain A.Type where
|
||||||
-- Mobility is not explicit in Rain:
|
-- Mobility is not explicit in Rain:
|
||||||
showRainM (A.Mobile t) = showRainM t
|
showRainM (A.Mobile t) = showRainM t
|
||||||
showRainM (A.List t) = tell ["["] >> showRainM t >> tell ["]"]
|
showRainM (A.List t) = tell ["["] >> showRainM t >> tell ["]"]
|
||||||
showRainM A.Infer = tell ["(inferred type)"]
|
showRainM (A.UnknownVarType en)
|
||||||
showRainM (A.InferNum n) = tell ["(inferred numeric type: ",show n,")"]
|
= 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, ">"]
|
showRainM x = tell ["<invalid Rain type: ", show x, ">"]
|
||||||
|
|
||||||
instance ShowOccam A.DyadicOp where
|
instance ShowOccam A.DyadicOp where
|
||||||
|
|
|
@ -144,9 +144,12 @@ data Type =
|
||||||
| Mobile Type
|
| Mobile Type
|
||||||
-- | A type that will be inferred automatically by a pass.
|
-- | A type that will be inferred automatically by a pass.
|
||||||
| Infer
|
| 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
|
-- | A numeric type to be inferred later, that must be able to hold the given
|
||||||
-- value
|
-- value. The Int is a unique identifier, the Integer is the number to hold
|
||||||
| InferNum Integer
|
| UnknownNumLitType Meta Int Integer
|
||||||
deriving (Show, Eq, Typeable, Data)
|
deriving (Show, Eq, Typeable, Data)
|
||||||
|
|
||||||
-- | An array dimension.
|
-- | An array dimension.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user