{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# OPTIONS_HADDOCK hide #-}
module LLVM.AST.Type.Operand (
Operand(..),
) where
import LLVM.AST.Type.Constant
import LLVM.AST.Type.Downcast
import LLVM.AST.Type.Name
import LLVM.AST.Type.Representation
import qualified LLVM.AST.Operand as LLVM
data Operand a where
LocalReference :: Type a -> Name a -> Operand a
ConstantOperand :: Constant a -> Operand a
instance Downcast (Operand a) LLVM.Operand where
downcast :: Operand a -> Operand
downcast (LocalReference Type a
t Name a
n) = Type -> Name -> Operand
LLVM.LocalReference (Type a -> Type
forall typed untyped.
(Downcast typed untyped, HasCallStack) =>
typed -> untyped
downcast Type a
t) (Name a -> Name
forall typed untyped.
(Downcast typed untyped, HasCallStack) =>
typed -> untyped
downcast Name a
n)
downcast (ConstantOperand Constant a
c) = Constant -> Operand
LLVM.ConstantOperand (Constant a -> Constant
forall typed untyped.
(Downcast typed untyped, HasCallStack) =>
typed -> untyped
downcast Constant a
c)
instance TypeOf Operand where
typeOf :: Operand a -> Type a
typeOf (LocalReference Type a
t Name a
_) = Type a
t
typeOf (ConstantOperand Constant a
c) = Constant a -> Type a
forall (f :: * -> *) a. TypeOf f => f a -> Type a
typeOf Constant a
c