{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PatternGuards #-}

module Language.Fortran.Transformation.Disambiguation.Intrinsic (disambiguateIntrinsic) where

import Prelude hiding (lookup)
import Data.Generics.Uniplate.Data
import Data.Data

import Language.Fortran.Analysis
import Language.Fortran.AST
import Language.Fortran.Transformation.TransformMonad


disambiguateIntrinsic :: Data a => Transform a ()
disambiguateIntrinsic :: Transform a ()
disambiguateIntrinsic = (ProgramFile (Analysis a) -> ProgramFile (Analysis a))
-> Transform a ()
forall a.
(ProgramFile (Analysis a) -> ProgramFile (Analysis a))
-> Transform a ()
modifyProgramFile (TransFunc Expression ProgramFile a
trans Expression (Analysis a) -> Expression (Analysis a)
forall a. Expression (Analysis a) -> Expression (Analysis a)
expression)
  where
    trans :: TransFunc Expression ProgramFile a
trans = forall a.
Data a =>
(Expression (Analysis a) -> Expression (Analysis a))
-> ProgramFile (Analysis a) -> ProgramFile (Analysis a)
forall from to. Biplate from to => (to -> to) -> from -> from
transformBi :: Data a => TransFunc Expression ProgramFile a
    expression :: Expression (Analysis a) -> Expression (Analysis a)
expression (ExpValue Analysis a
a SrcSpan
s (ValVariable Name
v))
      | Just (IDType Maybe BaseType
_ (Just ConstructType
CTIntrinsic)) <- Analysis a -> Maybe IDType
forall a. Analysis a -> Maybe IDType
idType Analysis a
a = Analysis a
-> SrcSpan -> Value (Analysis a) -> Expression (Analysis a)
forall a. a -> SrcSpan -> Value a -> Expression a
ExpValue Analysis a
a SrcSpan
s (Name -> Value (Analysis a)
forall a. Name -> Value a
ValIntrinsic Name
v)
    expression Expression (Analysis a)
e                                      = Expression (Analysis a)
e

--------------------------------------------------

-- Local variables:
-- mode: haskell
-- haskell-program-name: "cabal repl"
-- End: