Rain: changed from using the isSafeConversion function to a more appropriate new function isImplicitConversionRain
This commit is contained in:
parent
f9c21dc4c7
commit
7f9357d658
|
@ -20,7 +20,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
module Types
|
module Types
|
||||||
(
|
(
|
||||||
specTypeOfName, abbrevModeOfName, typeOfName, typeOfExpression, typeOfVariable, underlyingType, stripArrayType, abbrevModeOfVariable, abbrevModeOfSpec
|
specTypeOfName, abbrevModeOfName, typeOfName, typeOfExpression, typeOfVariable, underlyingType, stripArrayType, abbrevModeOfVariable, abbrevModeOfSpec
|
||||||
, isRealType, isIntegerType, isCaseableType, resolveUserType, isSafeConversion, isPreciseConversion
|
, isRealType, isIntegerType, isCaseableType, resolveUserType, isSafeConversion, isPreciseConversion, isImplicitConversionRain
|
||||||
, returnTypesOfFunction
|
, returnTypesOfFunction
|
||||||
, BytesInResult(..), bytesInType, sizeOfReplicator, sizeOfStructured
|
, BytesInResult(..), bytesInType, sizeOfReplicator, sizeOfStructured
|
||||||
|
|
||||||
|
@ -328,6 +328,16 @@ findMeta e = if null metaList then emptyMeta else head metaList
|
||||||
findMeta' :: Meta -> Meta
|
findMeta' :: Meta -> Meta
|
||||||
findMeta' m = m
|
findMeta' m = m
|
||||||
|
|
||||||
|
-- | Checks whether a given conversion can be done implicitly in Rain
|
||||||
|
-- Parameters are src dest
|
||||||
|
isImplicitConversionRain :: A.Type -> A.Type -> Bool
|
||||||
|
isImplicitConversionRain x y
|
||||||
|
= if (x == y)
|
||||||
|
then True
|
||||||
|
else if (x == A.Bool || y == A.Bool)
|
||||||
|
then False
|
||||||
|
else isSafeConversion x y
|
||||||
|
|
||||||
-- | Is a conversion between two types precise (i.e. do you need to specify
|
-- | Is a conversion between two types precise (i.e. do you need to specify
|
||||||
-- ROUND or TRUNC when doing it)?
|
-- ROUND or TRUNC when doing it)?
|
||||||
isPreciseConversion :: A.Type -> A.Type -> Bool
|
isPreciseConversion :: A.Type -> A.Type -> Bool
|
||||||
|
|
|
@ -198,7 +198,7 @@ matchParamPass = everywhereM ((mkM matchParamPassProc) `extM` matchParamPassFunc
|
||||||
--Adds a cast between two types if it is safe to do so, otherwise gives an error
|
--Adds a cast between two types if it is safe to do so, otherwise gives an error
|
||||||
doCast :: Int -> A.Type -> A.Type -> A.Expression -> PassM A.Expression
|
doCast :: Int -> A.Type -> A.Type -> A.Expression -> PassM A.Expression
|
||||||
doCast index to from item
|
doCast index to from item
|
||||||
= if isSafeConversion from to
|
= if isImplicitConversionRain from to
|
||||||
then return $ A.Conversion (findMeta item) A.DefaultConversion to item
|
then return $ A.Conversion (findMeta item) A.DefaultConversion to item
|
||||||
else dieP (findMeta item) $ "Could not perform implicit cast from supplied type: " ++ (show from) ++
|
else dieP (findMeta item) $ "Could not perform implicit cast from supplied type: " ++ (show from) ++
|
||||||
" to expected type: " ++ (show to) ++ " for parameter (zero-based): " ++ (show index)
|
" to expected type: " ++ (show to) ++ " for parameter (zero-based): " ++ (show index)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user