{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE MultiWayIf #-}
module What4.Serialize.Parser
( deserializeExpr
, deserializeExprWithConfig
, deserializeSymFn
, deserializeSymFnWithConfig
, deserializeBaseType
, readBaseTypes
, Atom(..)
, S.WellFormedSExpr(..)
, Config(..)
, defaultConfig
, SomeSymFn(..)
, type SExpr
, parseSExpr
, printSExpr
) where
import Control.Monad ( when )
import qualified Control.Monad.Except as E
import Control.Monad.IO.Class ( liftIO )
import qualified Control.Monad.Reader as R
import qualified Data.BitVector.Sized as BV
import qualified Data.Foldable as F
import qualified Data.HashMap.Lazy as HM
import Data.Kind
import qualified Data.SCargot.Repr.WellFormed as S
import Data.Text ( Text )
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import Text.Printf ( printf )
import qualified Data.Parameterized.NatRepr as PN
import qualified Data.Parameterized.Ctx as Ctx
import qualified Data.Parameterized.Context as Ctx
import Data.Parameterized.Classes
import Data.Parameterized.Some ( Some(..) )
import qualified Data.Parameterized.TraversableFC as FC
import What4.BaseTypes
import qualified What4.Expr.ArrayUpdateMap as WAU
import qualified What4.Expr.Builder as W4
import qualified What4.IndexLit as WIL
import qualified What4.Interface as W4
import What4.Serialize.SETokens ( Atom(..), printSExpr, parseSExpr )
import qualified What4.Utils.Serialize as U
import What4.Serialize.Printer ( SExpr )
import Prelude
data SomeSymFn t = forall dom ret. SomeSymFn (W4.SymFn t dom ret)
data Config sym =
Config
{ forall sym. Config sym -> Text -> IO (Maybe (SomeSymFn sym))
cSymFnLookup :: Text -> IO (Maybe (SomeSymFn sym))
, forall sym. Config sym -> Text -> IO (Maybe (Some (SymExpr sym)))
cExprLookup :: Text -> IO (Maybe (Some (W4.SymExpr sym)))
}
defaultConfig :: (W4.IsSymExprBuilder sym, ShowF (W4.SymExpr sym)) => sym -> Config sym
defaultConfig :: forall sym.
(IsSymExprBuilder sym, ShowF (SymExpr sym)) =>
sym -> Config sym
defaultConfig sym
_sym = Config { cSymFnLookup :: Text -> IO (Maybe (SomeSymFn sym))
cSymFnLookup = IO (Maybe (SomeSymFn sym)) -> Text -> IO (Maybe (SomeSymFn sym))
forall a b. a -> b -> a
const (Maybe (SomeSymFn sym) -> IO (Maybe (SomeSymFn sym))
forall a. a -> IO a
forall (m :: Type -> Type) a. Monad m => a -> m a
return Maybe (SomeSymFn sym)
forall a. Maybe a
Nothing)
, cExprLookup :: Text -> IO (Maybe (Some (SymExpr sym)))
cExprLookup = IO (Maybe (Some (SymExpr sym)))
-> Text -> IO (Maybe (Some (SymExpr sym)))
forall a b. a -> b -> a
const (Maybe (Some (SymExpr sym)) -> IO (Maybe (Some (SymExpr sym)))
forall a. a -> IO a
forall (m :: Type -> Type) a. Monad m => a -> m a
return Maybe (Some (SymExpr sym))
forall a. Maybe a
Nothing)
}
data ProcessorEnv sym =
ProcessorEnv
{ forall sym. ProcessorEnv sym -> sym
procSym :: sym
, forall sym. ProcessorEnv sym -> Text -> IO (Maybe (SomeSymFn sym))
procSymFnLookup :: Text -> IO (Maybe (SomeSymFn sym))
, forall sym.
ProcessorEnv sym -> Text -> IO (Maybe (Some (SymExpr sym)))
procExprLookup :: Text -> IO (Maybe (Some (W4.SymExpr sym)))
, forall sym. ProcessorEnv sym -> HashMap Text (Some (SymExpr sym))
procLetEnv :: HM.HashMap Text (Some (W4.SymExpr sym))
, forall sym. ProcessorEnv sym -> HashMap Text (SomeSymFn sym)
procLetFnEnv :: HM.HashMap Text (SomeSymFn sym)
}
type Processor sym a = E.ExceptT String (R.ReaderT (ProcessorEnv sym) IO) a
runProcessor :: ProcessorEnv sym -> Processor sym a -> IO (Either String a)
runProcessor :: forall sym a.
ProcessorEnv sym -> Processor sym a -> IO (Either String a)
runProcessor ProcessorEnv sym
env Processor sym a
action = ReaderT (ProcessorEnv sym) IO (Either String a)
-> ProcessorEnv sym -> IO (Either String a)
forall r (m :: Type -> Type) a. ReaderT r m a -> r -> m a
R.runReaderT (Processor sym a -> ReaderT (ProcessorEnv sym) IO (Either String a)
forall e (m :: Type -> Type) a. ExceptT e m a -> m (Either e a)
E.runExceptT Processor sym a
action) ProcessorEnv sym
env
lookupExpr :: Text -> Processor sym (Maybe (Some (W4.SymExpr sym)))
lookupExpr :: forall sym. Text -> Processor sym (Maybe (Some (SymExpr sym)))
lookupExpr Text
nm = do
Text -> IO (Maybe (Some (SymExpr sym)))
userLookupFn <- (ProcessorEnv sym -> Text -> IO (Maybe (Some (SymExpr sym))))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Text -> IO (Maybe (Some (SymExpr sym))))
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.asks ProcessorEnv sym -> Text -> IO (Maybe (Some (SymExpr sym)))
forall sym.
ProcessorEnv sym -> Text -> IO (Maybe (Some (SymExpr sym)))
procExprLookup
HashMap Text (Some (SymExpr sym))
letEnv <- (ProcessorEnv sym -> HashMap Text (Some (SymExpr sym)))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(HashMap Text (Some (SymExpr sym)))
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.asks ProcessorEnv sym -> HashMap Text (Some (SymExpr sym))
forall sym. ProcessorEnv sym -> HashMap Text (Some (SymExpr sym))
procLetEnv
case Text
-> HashMap Text (Some (SymExpr sym)) -> Maybe (Some (SymExpr sym))
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
HM.lookup Text
nm HashMap Text (Some (SymExpr sym))
letEnv of
Maybe (Some (SymExpr sym))
Nothing -> IO (Maybe (Some (SymExpr sym)))
-> Processor sym (Maybe (Some (SymExpr sym)))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe (Some (SymExpr sym)))
-> Processor sym (Maybe (Some (SymExpr sym))))
-> IO (Maybe (Some (SymExpr sym)))
-> Processor sym (Maybe (Some (SymExpr sym)))
forall a b. (a -> b) -> a -> b
$ Text -> IO (Maybe (Some (SymExpr sym)))
userLookupFn Text
nm
Maybe (Some (SymExpr sym))
res -> Maybe (Some (SymExpr sym))
-> Processor sym (Maybe (Some (SymExpr sym)))
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return Maybe (Some (SymExpr sym))
res
lookupFn :: Text -> Processor sym (Maybe (SomeSymFn sym))
lookupFn :: forall sym. Text -> Processor sym (Maybe (SomeSymFn sym))
lookupFn Text
nm = do
Text -> IO (Maybe (SomeSymFn sym))
userLookupFn <- (ProcessorEnv sym -> Text -> IO (Maybe (SomeSymFn sym)))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Text -> IO (Maybe (SomeSymFn sym)))
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.asks ProcessorEnv sym -> Text -> IO (Maybe (SomeSymFn sym))
forall sym. ProcessorEnv sym -> Text -> IO (Maybe (SomeSymFn sym))
procSymFnLookup
HashMap Text (SomeSymFn sym)
letEnv <- (ProcessorEnv sym -> HashMap Text (SomeSymFn sym))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(HashMap Text (SomeSymFn sym))
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.asks ProcessorEnv sym -> HashMap Text (SomeSymFn sym)
forall sym. ProcessorEnv sym -> HashMap Text (SomeSymFn sym)
procLetFnEnv
case Text -> HashMap Text (SomeSymFn sym) -> Maybe (SomeSymFn sym)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
HM.lookup Text
nm HashMap Text (SomeSymFn sym)
letEnv of
Maybe (SomeSymFn sym)
Nothing -> IO (Maybe (SomeSymFn sym)) -> Processor sym (Maybe (SomeSymFn sym))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe (SomeSymFn sym))
-> Processor sym (Maybe (SomeSymFn sym)))
-> IO (Maybe (SomeSymFn sym))
-> Processor sym (Maybe (SomeSymFn sym))
forall a b. (a -> b) -> a -> b
$ Text -> IO (Maybe (SomeSymFn sym))
userLookupFn Text
nm
Maybe (SomeSymFn sym)
res -> Maybe (SomeSymFn sym) -> Processor sym (Maybe (SomeSymFn sym))
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return Maybe (SomeSymFn sym)
res
deserializeExpr ::
forall sym t st fs . (sym ~ W4.ExprBuilder t st fs)
=> sym
-> SExpr
-> IO (Either String (Some (W4.SymExpr sym)))
deserializeExpr :: forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
sym -> SExpr -> IO (Either String (Some (SymExpr sym)))
deserializeExpr sym
sym = sym
-> Config sym -> SExpr -> IO (Either String (Some (SymExpr sym)))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
sym
-> Config sym -> SExpr -> IO (Either String (Some (SymExpr sym)))
deserializeExprWithConfig sym
sym Config sym
cfg
where cfg :: Config sym
cfg = sym -> Config sym
forall sym.
(IsSymExprBuilder sym, ShowF (SymExpr sym)) =>
sym -> Config sym
defaultConfig sym
sym
deserializeExprWithConfig ::
forall sym t st fs . (sym ~ W4.ExprBuilder t st fs)
=> sym
-> Config sym
-> SExpr
-> IO (Either String (Some (W4.SymExpr sym)))
deserializeExprWithConfig :: forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
sym
-> Config sym -> SExpr -> IO (Either String (Some (SymExpr sym)))
deserializeExprWithConfig sym
sym Config sym
cfg SExpr
sexpr = ProcessorEnv sym
-> Processor sym (Some (Expr t))
-> IO (Either String (Some (Expr t)))
forall sym a.
ProcessorEnv sym -> Processor sym a -> IO (Either String a)
runProcessor ProcessorEnv sym
env (SExpr -> Processor sym (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> Processor sym (Some (SymExpr sym))
readExpr SExpr
sexpr)
where env :: ProcessorEnv sym
env = ProcessorEnv { procSym :: sym
procSym = sym
sym
, procSymFnLookup :: Text -> IO (Maybe (SomeSymFn sym))
procSymFnLookup = Config sym -> Text -> IO (Maybe (SomeSymFn sym))
forall sym. Config sym -> Text -> IO (Maybe (SomeSymFn sym))
cSymFnLookup Config sym
cfg
, procExprLookup :: Text -> IO (Maybe (Some (SymExpr sym)))
procExprLookup = Config sym -> Text -> IO (Maybe (Some (SymExpr sym)))
forall sym. Config sym -> Text -> IO (Maybe (Some (SymExpr sym)))
cExprLookup Config sym
cfg
, procLetEnv :: HashMap Text (Some (SymExpr sym))
procLetEnv = HashMap Text (Some (SymExpr sym))
HashMap Text (Some (Expr t))
forall k v. HashMap k v
HM.empty
, procLetFnEnv :: HashMap Text (SomeSymFn sym)
procLetFnEnv = HashMap Text (SomeSymFn sym)
forall k v. HashMap k v
HM.empty
}
deserializeSymFn ::
forall sym t st fs . (sym ~ W4.ExprBuilder t st fs)
=> sym
-> SExpr
-> IO (Either String (SomeSymFn sym))
deserializeSymFn :: forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
sym -> SExpr -> IO (Either String (SomeSymFn sym))
deserializeSymFn sym
sym = sym -> Config sym -> SExpr -> IO (Either String (SomeSymFn sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
sym -> Config sym -> SExpr -> IO (Either String (SomeSymFn sym))
deserializeSymFnWithConfig sym
sym Config sym
cfg
where cfg :: Config sym
cfg = sym -> Config sym
forall sym.
(IsSymExprBuilder sym, ShowF (SymExpr sym)) =>
sym -> Config sym
defaultConfig sym
sym
deserializeSymFnWithConfig ::
forall sym t st fs . (sym ~ W4.ExprBuilder t st fs)
=> sym
-> Config sym
-> SExpr
-> IO (Either String (SomeSymFn sym))
deserializeSymFnWithConfig :: forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
sym -> Config sym -> SExpr -> IO (Either String (SomeSymFn sym))
deserializeSymFnWithConfig sym
sym Config sym
cfg SExpr
sexpr = ProcessorEnv sym
-> Processor sym (SomeSymFn sym)
-> IO (Either String (SomeSymFn sym))
forall sym a.
ProcessorEnv sym -> Processor sym a -> IO (Either String a)
runProcessor ProcessorEnv sym
env (SExpr -> Processor sym (SomeSymFn sym)
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> Processor sym (SomeSymFn sym)
readSymFn SExpr
sexpr)
where env :: ProcessorEnv sym
env = ProcessorEnv { procSym :: sym
procSym = sym
sym
, procSymFnLookup :: Text -> IO (Maybe (SomeSymFn sym))
procSymFnLookup = Config sym -> Text -> IO (Maybe (SomeSymFn sym))
forall sym. Config sym -> Text -> IO (Maybe (SomeSymFn sym))
cSymFnLookup Config sym
cfg
, procExprLookup :: Text -> IO (Maybe (Some (SymExpr sym)))
procExprLookup = Config sym -> Text -> IO (Maybe (Some (SymExpr sym)))
forall sym. Config sym -> Text -> IO (Maybe (Some (SymExpr sym)))
cExprLookup Config sym
cfg
, procLetEnv :: HashMap Text (Some (SymExpr sym))
procLetEnv = HashMap Text (Some (SymExpr sym))
HashMap Text (Some (Expr t))
forall k v. HashMap k v
HM.empty
, procLetFnEnv :: HashMap Text (SomeSymFn sym)
procLetFnEnv = HashMap Text (SomeSymFn sym)
forall k v. HashMap k v
HM.empty
}
deserializeBaseType ::
SExpr
-> Either String (Some BaseTypeRepr)
deserializeBaseType :: SExpr -> Either String (Some BaseTypeRepr)
deserializeBaseType SExpr
sexpr = SExpr -> Either String (Some BaseTypeRepr)
forall (m :: Type -> Type).
MonadError String m =>
SExpr -> m (Some BaseTypeRepr)
readBaseType SExpr
sexpr
prefixError :: (Monoid e, E.MonadError e m) => e -> m a -> m a
prefixError :: forall e (m :: Type -> Type) a.
(Monoid e, MonadError e m) =>
e -> m a -> m a
prefixError e
prefix m a
act = m a -> (e -> m a) -> m a
forall a. m a -> (e -> m a) -> m a
forall e (m :: Type -> Type) a.
MonadError e m =>
m a -> (e -> m a) -> m a
E.catchError m a
act (e -> m a
forall a. e -> m a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (e -> m a) -> (e -> e) -> e -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> e -> e
forall a. Monoid a => a -> a -> a
mappend e
prefix)
fromMaybeError :: (E.MonadError e m) => e -> Maybe a -> m a
fromMaybeError :: forall e (m :: Type -> Type) a.
MonadError e m =>
e -> Maybe a -> m a
fromMaybeError e
err = m a -> (a -> m a) -> Maybe a -> m a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (e -> m a
forall a. e -> m a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError e
err) a -> m a
forall a. a -> m a
forall (m :: Type -> Type) a. Monad m => a -> m a
return
readBaseType ::
forall m . (E.MonadError String m)
=> SExpr
-> m (Some BaseTypeRepr)
readBaseType :: forall (m :: Type -> Type).
MonadError String m =>
SExpr -> m (Some BaseTypeRepr)
readBaseType SExpr
sexpr =
case SExpr
sexpr of
S.WFSAtom (AId Text
atom) ->
case (Text -> String
T.unpack Text
atom) of
String
"Bool" -> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a. a -> m a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some BaseTypeRepr -> m (Some BaseTypeRepr))
-> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a b. (a -> b) -> a -> b
$ BaseTypeRepr 'BaseBoolType -> Some BaseTypeRepr
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some BaseTypeRepr 'BaseBoolType
BaseBoolRepr
String
"Int" -> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a. a -> m a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some BaseTypeRepr -> m (Some BaseTypeRepr))
-> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a b. (a -> b) -> a -> b
$ BaseTypeRepr 'BaseIntegerType -> Some BaseTypeRepr
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some BaseTypeRepr 'BaseIntegerType
BaseIntegerRepr
String
"Real" -> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a. a -> m a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some BaseTypeRepr -> m (Some BaseTypeRepr))
-> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a b. (a -> b) -> a -> b
$ BaseTypeRepr 'BaseRealType -> Some BaseTypeRepr
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some BaseTypeRepr 'BaseRealType
BaseRealRepr
String
"String" -> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a. a -> m a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some BaseTypeRepr -> m (Some BaseTypeRepr))
-> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a b. (a -> b) -> a -> b
$ BaseTypeRepr ('BaseStringType 'Unicode) -> Some BaseTypeRepr
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (StringInfoRepr 'Unicode -> BaseTypeRepr ('BaseStringType 'Unicode)
forall (si :: StringInfo).
StringInfoRepr si -> BaseTypeRepr ('BaseStringType si)
BaseStringRepr StringInfoRepr 'Unicode
UnicodeRepr)
String
"Complex" -> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a. a -> m a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some BaseTypeRepr -> m (Some BaseTypeRepr))
-> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a b. (a -> b) -> a -> b
$ BaseTypeRepr 'BaseComplexType -> Some BaseTypeRepr
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some BaseTypeRepr 'BaseComplexType
BaseComplexRepr
String
_ -> m (Some BaseTypeRepr)
panic
S.WFSList [(S.WFSAtom (AId Text
"BV")), (S.WFSAtom (AInt Integer
w))]
| Just (Some NatRepr x
wRepr) <- Integer -> Maybe (Some NatRepr)
forall a. Integral a => a -> Maybe (Some NatRepr)
someNat Integer
w
, Just LeqProof 1 x
LeqProof <- NatRepr 1 -> NatRepr x -> Maybe (LeqProof 1 x)
forall (m :: Nat) (n :: Nat).
NatRepr m -> NatRepr n -> Maybe (LeqProof m n)
testLeq (forall (n :: Nat). KnownNat n => NatRepr n
knownNat @1) NatRepr x
wRepr
-> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a. a -> m a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some BaseTypeRepr -> m (Some BaseTypeRepr))
-> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a b. (a -> b) -> a -> b
$ BaseTypeRepr ('BaseBVType x) -> Some BaseTypeRepr
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (NatRepr x -> BaseTypeRepr ('BaseBVType x)
forall (w :: Nat).
(1 <= w) =>
NatRepr w -> BaseTypeRepr ('BaseBVType w)
BaseBVRepr NatRepr x
wRepr)
| Bool
otherwise
-> m (Some BaseTypeRepr)
panic
S.WFSList [(S.WFSAtom (AId Text
"Float")), (S.WFSAtom (AInt Integer
e)), (S.WFSAtom (AInt Integer
s))]
| Just (Some NatRepr x
eRepr) <- Integer -> Maybe (Some NatRepr)
forall a. Integral a => a -> Maybe (Some NatRepr)
someNat Integer
e
, Just (Some NatRepr x
sRepr) <- Integer -> Maybe (Some NatRepr)
forall a. Integral a => a -> Maybe (Some NatRepr)
someNat Integer
s
, Just LeqProof 2 x
LeqProof <- NatRepr 2 -> NatRepr x -> Maybe (LeqProof 2 x)
forall (m :: Nat) (n :: Nat).
NatRepr m -> NatRepr n -> Maybe (LeqProof m n)
testLeq (forall (n :: Nat). KnownNat n => NatRepr n
knownNat @2) NatRepr x
eRepr
, Just LeqProof 2 x
LeqProof <- NatRepr 2 -> NatRepr x -> Maybe (LeqProof 2 x)
forall (m :: Nat) (n :: Nat).
NatRepr m -> NatRepr n -> Maybe (LeqProof m n)
testLeq (forall (n :: Nat). KnownNat n => NatRepr n
knownNat @2) NatRepr x
sRepr
-> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a. a -> m a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (BaseTypeRepr ('BaseFloatType ('FloatingPointPrecision x x))
-> Some BaseTypeRepr
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (FloatPrecisionRepr ('FloatingPointPrecision x x)
-> BaseTypeRepr ('BaseFloatType ('FloatingPointPrecision x x))
forall (fpp :: FloatPrecision).
FloatPrecisionRepr fpp -> BaseTypeRepr ('BaseFloatType fpp)
BaseFloatRepr (NatRepr x
-> NatRepr x -> FloatPrecisionRepr ('FloatingPointPrecision x x)
forall (eb :: Nat) (sb :: Nat).
(2 <= eb, 2 <= sb) =>
NatRepr eb
-> NatRepr sb -> FloatPrecisionRepr ('FloatingPointPrecision eb sb)
FloatingPointPrecisionRepr NatRepr x
eRepr NatRepr x
sRepr)))
| Bool
otherwise -> m (Some BaseTypeRepr)
panic
S.WFSList [(S.WFSAtom (AId Text
"Struct")), SExpr
args] -> do
Some Assignment BaseTypeRepr x
tps <- SExpr -> m (Some (Assignment BaseTypeRepr))
forall (m :: Type -> Type).
MonadError String m =>
SExpr -> m (Some (Assignment BaseTypeRepr))
readBaseTypes SExpr
args
Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a. a -> m a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some BaseTypeRepr -> m (Some BaseTypeRepr))
-> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a b. (a -> b) -> a -> b
$ BaseTypeRepr ('BaseStructType x) -> Some BaseTypeRepr
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Assignment BaseTypeRepr x -> BaseTypeRepr ('BaseStructType x)
forall (ctx :: Ctx BaseType).
Assignment BaseTypeRepr ctx -> BaseTypeRepr ('BaseStructType ctx)
BaseStructRepr Assignment BaseTypeRepr x
tps)
S.WFSList [S.WFSAtom (AId Text
"Array"), SExpr
ixArgs, SExpr
tpArg] -> do
Some Assignment BaseTypeRepr x
ixs <- SExpr -> m (Some (Assignment BaseTypeRepr))
forall (m :: Type -> Type).
MonadError String m =>
SExpr -> m (Some (Assignment BaseTypeRepr))
readBaseTypes SExpr
ixArgs
Some BaseTypeRepr x
tp <- SExpr -> m (Some BaseTypeRepr)
forall (m :: Type -> Type).
MonadError String m =>
SExpr -> m (Some BaseTypeRepr)
readBaseType SExpr
tpArg
case Assignment BaseTypeRepr x -> AssignView BaseTypeRepr x
forall {k} (f :: k -> Type) (ctx :: Ctx k).
Assignment f ctx -> AssignView f ctx
Ctx.viewAssign Assignment BaseTypeRepr x
ixs of
AssignView BaseTypeRepr x
Ctx.AssignEmpty -> String -> m (Some BaseTypeRepr)
forall a. String -> m a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String -> m (Some BaseTypeRepr))
-> String -> m (Some BaseTypeRepr)
forall a b. (a -> b) -> a -> b
$ String
"array type has no indices: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ SExpr -> String
forall a. Show a => a -> String
show SExpr
sexpr
Ctx.AssignExtend Assignment BaseTypeRepr ctx1
_ BaseTypeRepr tp
_ -> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a. a -> m a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some BaseTypeRepr -> m (Some BaseTypeRepr))
-> Some BaseTypeRepr -> m (Some BaseTypeRepr)
forall a b. (a -> b) -> a -> b
$ BaseTypeRepr ('BaseArrayType (ctx1 '::> tp) x) -> Some BaseTypeRepr
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Assignment BaseTypeRepr (ctx1 '::> tp)
-> BaseTypeRepr x -> BaseTypeRepr ('BaseArrayType (ctx1 '::> tp) x)
forall (idx :: Ctx BaseType) (tp :: BaseType) (xs :: BaseType).
Assignment BaseTypeRepr (idx ::> tp)
-> BaseTypeRepr xs -> BaseTypeRepr ('BaseArrayType (idx ::> tp) xs)
BaseArrayRepr Assignment BaseTypeRepr x
Assignment BaseTypeRepr (ctx1 '::> tp)
ixs BaseTypeRepr x
tp)
SExpr
_ -> m (Some BaseTypeRepr)
panic
where
panic :: m (Some BaseTypeRepr)
panic = String -> m (Some BaseTypeRepr)
forall a. String -> m a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String -> m (Some BaseTypeRepr))
-> String -> m (Some BaseTypeRepr)
forall a b. (a -> b) -> a -> b
$ String
"unknown base type: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ SExpr -> String
forall a. Show a => a -> String
show SExpr
sexpr
readBaseTypes ::
forall m . (E.MonadError String m)
=> SExpr
-> m (Some (Ctx.Assignment BaseTypeRepr))
readBaseTypes :: forall (m :: Type -> Type).
MonadError String m =>
SExpr -> m (Some (Assignment BaseTypeRepr))
readBaseTypes sexpr :: SExpr
sexpr@(S.WFSAtom Atom
_) = String -> m (Some (Assignment BaseTypeRepr))
forall a. String -> m a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String -> m (Some (Assignment BaseTypeRepr)))
-> String -> m (Some (Assignment BaseTypeRepr))
forall a b. (a -> b) -> a -> b
$ String
"expected list of base types: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ SExpr -> String
forall a. Show a => a -> String
show SExpr
sexpr
readBaseTypes (S.WFSList [SExpr]
sexprs) = [Some BaseTypeRepr] -> Some (Assignment BaseTypeRepr)
forall {k} (f :: k -> Type). [Some f] -> Some (Assignment f)
Ctx.fromList ([Some BaseTypeRepr] -> Some (Assignment BaseTypeRepr))
-> m [Some BaseTypeRepr] -> m (Some (Assignment BaseTypeRepr))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (SExpr -> m (Some BaseTypeRepr))
-> [SExpr] -> m [Some BaseTypeRepr]
forall (t :: Type -> Type) (m :: Type -> Type) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: Type -> Type) a b.
Monad m =>
(a -> m b) -> [a] -> m [b]
mapM SExpr -> m (Some BaseTypeRepr)
forall (m :: Type -> Type).
MonadError String m =>
SExpr -> m (Some BaseTypeRepr)
readBaseType [SExpr]
sexprs
data BVProof tp where
BVProof :: forall n. (1 <= n) => NatRepr n -> BVProof (BaseBVType n)
getBVProof :: (W4.IsExpr ex, E.MonadError String m) => ex tp -> m (BVProof tp)
getBVProof :: forall (ex :: BaseType -> Type) (m :: Type -> Type)
(tp :: BaseType).
(IsExpr ex, MonadError String m) =>
ex tp -> m (BVProof tp)
getBVProof ex tp
expr =
case ex tp -> BaseTypeRepr tp
forall (tp :: BaseType). ex tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType ex tp
expr of
BaseBVRepr NatRepr w
n -> BVProof tp -> m (BVProof tp)
forall a. a -> m a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (BVProof tp -> m (BVProof tp)) -> BVProof tp -> m (BVProof tp)
forall a b. (a -> b) -> a -> b
$ NatRepr w -> BVProof ('BaseBVType w)
forall (res :: Nat).
(1 <= res) =>
NatRepr res -> BVProof (BaseBVType res)
BVProof NatRepr w
n
BaseTypeRepr tp
t -> String -> m (BVProof tp)
forall a. String -> m a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String -> m (BVProof tp)) -> String -> m (BVProof tp)
forall a b. (a -> b) -> a -> b
$ String -> String -> String
forall r. PrintfType r => String -> r
printf String
"expected BV, found %s" (BaseTypeRepr tp -> String
forall a. Show a => a -> String
show BaseTypeRepr tp
t)
data Op sym where
FloatOp1 :: (forall fpp . sym ->
W4.SymFloat sym fpp ->
IO (W4.SymFloat sym fpp))
-> Op sym
Op1 :: Ctx.Assignment BaseTypeRepr (Ctx.EmptyCtx Ctx.::> arg1)
-> (sym ->
W4.SymExpr sym arg1 ->
IO (W4.SymExpr sym ret))
-> Op sym
Op2 :: Ctx.Assignment BaseTypeRepr (Ctx.EmptyCtx Ctx.::> arg1 Ctx.::> arg2)
-> (sym ->
W4.SymExpr sym arg1 ->
W4.SymExpr sym arg2 ->
IO (W4.SymExpr sym ret))
-> Op sym
Op3 :: Ctx.Assignment BaseTypeRepr (Ctx.EmptyCtx Ctx.::> arg1 Ctx.::> arg2 Ctx.::> arg3)
-> (sym ->
W4.SymExpr sym arg1 ->
W4.SymExpr sym arg2 ->
W4.SymExpr sym arg3 ->
IO (W4.SymExpr sym ret)
)
-> Op sym
Op4 :: Ctx.Assignment
BaseTypeRepr
(Ctx.EmptyCtx Ctx.::> arg1 Ctx.::> arg2 Ctx.::> arg3 Ctx.::> arg4)
-> ( sym ->
W4.SymExpr sym arg1 ->
W4.SymExpr sym arg2 ->
W4.SymExpr sym arg3 ->
W4.SymExpr sym arg4 ->
IO (W4.SymExpr sym ret)
)
-> Op sym
BVOp1 :: (forall w . (1 <= w) =>
sym ->
W4.SymBV sym w ->
IO (W4.SymBV sym w))
-> Op sym
BVOp2 :: (forall w . (1 <= w) =>
sym ->
W4.SymBV sym w ->
W4.SymBV sym w ->
IO (W4.SymBV sym w))
-> Op sym
BVComp2 :: (forall w . (1 <= w) =>
sym ->
W4.SymBV sym w ->
W4.SymBV sym w ->
IO (W4.Pred sym))
-> Op sym
lookupOp :: forall sym . W4.IsSymExprBuilder sym => Text -> Maybe (Op sym)
lookupOp :: forall sym. IsSymExprBuilder sym => Text -> Maybe (Op sym)
lookupOp Text
name = Text -> HashMap Text (Op sym) -> Maybe (Op sym)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
HM.lookup Text
name HashMap Text (Op sym)
forall sym. IsSymExprBuilder sym => HashMap Text (Op sym)
opTable
opTable :: (W4.IsSymExprBuilder sym) => HM.HashMap Text (Op sym)
opTable :: forall sym. IsSymExprBuilder sym => HashMap Text (Op sym)
opTable =
[(Text, Op sym)] -> HashMap Text (Op sym)
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HM.fromList [
(Text
"andp", Assignment
BaseTypeRepr (('EmptyCtx ::> 'BaseBoolType) ::> 'BaseBoolType)
-> (sym
-> SymExpr sym 'BaseBoolType
-> SymExpr sym 'BaseBoolType
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr (('EmptyCtx ::> 'BaseBoolType) ::> 'BaseBoolType)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym 'BaseBoolType
-> SymExpr sym 'BaseBoolType
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym)
-> (sym
-> SymExpr sym 'BaseBoolType
-> SymExpr sym 'BaseBoolType
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ sym
-> SymExpr sym 'BaseBoolType
-> SymExpr sym 'BaseBoolType
-> IO (SymExpr sym 'BaseBoolType)
forall sym.
IsExprBuilder sym =>
sym -> Pred sym -> Pred sym -> IO (Pred sym)
W4.andPred)
, (Text
"orp", Assignment
BaseTypeRepr (('EmptyCtx ::> 'BaseBoolType) ::> 'BaseBoolType)
-> (sym
-> SymExpr sym 'BaseBoolType
-> SymExpr sym 'BaseBoolType
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr (('EmptyCtx ::> 'BaseBoolType) ::> 'BaseBoolType)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym 'BaseBoolType
-> SymExpr sym 'BaseBoolType
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym)
-> (sym
-> SymExpr sym 'BaseBoolType
-> SymExpr sym 'BaseBoolType
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ sym
-> SymExpr sym 'BaseBoolType
-> SymExpr sym 'BaseBoolType
-> IO (SymExpr sym 'BaseBoolType)
forall sym.
IsExprBuilder sym =>
sym -> Pred sym -> Pred sym -> IO (Pred sym)
W4.orPred)
, (Text
"xorp", Assignment
BaseTypeRepr (('EmptyCtx ::> 'BaseBoolType) ::> 'BaseBoolType)
-> (sym
-> SymExpr sym 'BaseBoolType
-> SymExpr sym 'BaseBoolType
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr (('EmptyCtx ::> 'BaseBoolType) ::> 'BaseBoolType)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym 'BaseBoolType
-> SymExpr sym 'BaseBoolType
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym)
-> (sym
-> SymExpr sym 'BaseBoolType
-> SymExpr sym 'BaseBoolType
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ sym
-> SymExpr sym 'BaseBoolType
-> SymExpr sym 'BaseBoolType
-> IO (SymExpr sym 'BaseBoolType)
forall sym.
IsExprBuilder sym =>
sym -> Pred sym -> Pred sym -> IO (Pred sym)
W4.xorPred)
, (Text
"notp", Assignment BaseTypeRepr ('EmptyCtx ::> 'BaseBoolType)
-> (sym
-> SymExpr sym 'BaseBoolType -> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall (res :: BaseType) sym (arg2 :: BaseType).
Assignment BaseTypeRepr ('EmptyCtx ::> res)
-> (sym -> SymExpr sym res -> IO (SymExpr sym arg2)) -> Op sym
Op1 Assignment BaseTypeRepr ('EmptyCtx ::> 'BaseBoolType)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym 'BaseBoolType -> IO (SymExpr sym 'BaseBoolType))
-> Op sym)
-> (sym
-> SymExpr sym 'BaseBoolType -> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ sym -> SymExpr sym 'BaseBoolType -> IO (SymExpr sym 'BaseBoolType)
forall sym. IsExprBuilder sym => sym -> Pred sym -> IO (Pred sym)
W4.notPred)
, (Text
"floatneg", (forall (fpp :: FloatPrecision).
sym -> SymFloat sym fpp -> IO (SymFloat sym fpp))
-> Op sym
forall sym.
(forall (fpp :: FloatPrecision).
sym -> SymFloat sym fpp -> IO (SymFloat sym fpp))
-> Op sym
FloatOp1 sym -> SymFloat sym fpp -> IO (SymFloat sym fpp)
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> SymFloat sym fpp -> IO (SymFloat sym fpp)
forall (fpp :: FloatPrecision).
sym -> SymFloat sym fpp -> IO (SymFloat sym fpp)
W4.floatNeg)
, (Text
"floatabs", (forall (fpp :: FloatPrecision).
sym -> SymFloat sym fpp -> IO (SymFloat sym fpp))
-> Op sym
forall sym.
(forall (fpp :: FloatPrecision).
sym -> SymFloat sym fpp -> IO (SymFloat sym fpp))
-> Op sym
FloatOp1 sym -> SymFloat sym fpp -> IO (SymFloat sym fpp)
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> SymFloat sym fpp -> IO (SymFloat sym fpp)
forall (fpp :: FloatPrecision).
sym -> SymFloat sym fpp -> IO (SymFloat sym fpp)
W4.floatAbs)
, (Text
"intmul", Assignment
BaseTypeRepr
(('EmptyCtx ::> 'BaseIntegerType) ::> 'BaseIntegerType)
-> (sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> 'BaseIntegerType) ::> 'BaseIntegerType)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType))
-> Op sym)
-> (sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType)
forall sym.
IsExprBuilder sym =>
sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym)
W4.intMul)
, (Text
"intadd", Assignment
BaseTypeRepr
(('EmptyCtx ::> 'BaseIntegerType) ::> 'BaseIntegerType)
-> (sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> 'BaseIntegerType) ::> 'BaseIntegerType)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType))
-> Op sym)
-> (sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType)
forall sym.
IsExprBuilder sym =>
sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym)
W4.intAdd)
, (Text
"intmod", Assignment
BaseTypeRepr
(('EmptyCtx ::> 'BaseIntegerType) ::> 'BaseIntegerType)
-> (sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> 'BaseIntegerType) ::> 'BaseIntegerType)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType))
-> Op sym)
-> (sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType)
forall sym.
IsExprBuilder sym =>
sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym)
W4.intMod)
, (Text
"intdiv", Assignment
BaseTypeRepr
(('EmptyCtx ::> 'BaseIntegerType) ::> 'BaseIntegerType)
-> (sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> 'BaseIntegerType) ::> 'BaseIntegerType)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType))
-> Op sym)
-> (sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType)
forall sym.
IsExprBuilder sym =>
sym -> SymInteger sym -> SymInteger sym -> IO (SymInteger sym)
W4.intDiv)
, (Text
"intle", Assignment
BaseTypeRepr
(('EmptyCtx ::> 'BaseIntegerType) ::> 'BaseIntegerType)
-> (sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> 'BaseIntegerType) ::> 'BaseIntegerType)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym)
-> (sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ sym
-> SymExpr sym 'BaseIntegerType
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseBoolType)
forall sym.
IsExprBuilder sym =>
sym -> SymInteger sym -> SymInteger sym -> IO (Pred sym)
W4.intLe)
, (Text
"intabs", Assignment BaseTypeRepr ('EmptyCtx ::> 'BaseIntegerType)
-> (sym
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType))
-> Op sym
forall (res :: BaseType) sym (arg2 :: BaseType).
Assignment BaseTypeRepr ('EmptyCtx ::> res)
-> (sym -> SymExpr sym res -> IO (SymExpr sym arg2)) -> Op sym
Op1 Assignment BaseTypeRepr ('EmptyCtx ::> 'BaseIntegerType)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType))
-> Op sym)
-> (sym
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ sym
-> SymExpr sym 'BaseIntegerType
-> IO (SymExpr sym 'BaseIntegerType)
forall sym.
IsExprBuilder sym =>
sym -> SymInteger sym -> IO (SymInteger sym)
W4.intAbs)
, (Text
"bvand", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvAndBits)
, (Text
"bvor", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvOrBits)
, (Text
"bvadd", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvAdd)
, (Text
"bvmul", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvMul)
, (Text
"bvudiv", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvUdiv)
, (Text
"bvurem", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvUrem)
, (Text
"bvshl", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvShl)
, (Text
"bvlshr", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvLshr)
, (Text
"bvnand", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 ((forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym)
-> (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymBV sym w
arg1 SymBV sym w
arg2 -> sym -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w)
W4.bvNotBits sym
sym (SymBV sym w -> IO (SymBV sym w))
-> IO (SymBV sym w) -> IO (SymBV sym w)
forall (m :: Type -> Type) a b. Monad m => (a -> m b) -> m a -> m b
=<< sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvAndBits sym
sym SymBV sym w
arg1 SymBV sym w
arg2)
, (Text
"bvnor", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 ((forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym)
-> (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymBV sym w
arg1 SymBV sym w
arg2 -> sym -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w)
W4.bvNotBits sym
sym (SymBV sym w -> IO (SymBV sym w))
-> IO (SymBV sym w) -> IO (SymBV sym w)
forall (m :: Type -> Type) a b. Monad m => (a -> m b) -> m a -> m b
=<< sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvOrBits sym
sym SymBV sym w
arg1 SymBV sym w
arg2)
, (Text
"bvxor", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvXorBits)
, (Text
"bvxnor", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 ((forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym)
-> (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymBV sym w
arg1 SymBV sym w
arg2 -> sym -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w)
W4.bvNotBits sym
sym (SymBV sym w -> IO (SymBV sym w))
-> IO (SymBV sym w) -> IO (SymBV sym w)
forall (m :: Type -> Type) a b. Monad m => (a -> m b) -> m a -> m b
=<< sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvXorBits sym
sym SymBV sym w
arg1 SymBV sym w
arg2)
, (Text
"bvsub", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvSub)
, (Text
"bvsdiv", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvSdiv)
, (Text
"bvsrem", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvSrem)
, (Text
"bvsmod", String -> Op sym
forall a. HasCallStack => String -> a
error String
"bvsmod is not implemented")
, (Text
"bvashr", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
W4.bvAshr)
, (Text
"bvult", (forall (w :: Nat).
(1 <= w) =>
sym
-> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym))
-> Op sym
BVComp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
W4.bvUlt)
, (Text
"bvule", (forall (w :: Nat).
(1 <= w) =>
sym
-> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym))
-> Op sym
BVComp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
W4.bvUle)
, (Text
"bvugt", (forall (w :: Nat).
(1 <= w) =>
sym
-> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym))
-> Op sym
BVComp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
W4.bvUgt)
, (Text
"bvuge", (forall (w :: Nat).
(1 <= w) =>
sym
-> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym))
-> Op sym
BVComp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
W4.bvUge)
, (Text
"bvslt", (forall (w :: Nat).
(1 <= w) =>
sym
-> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym))
-> Op sym
BVComp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
W4.bvSlt)
, (Text
"bvsle", (forall (w :: Nat).
(1 <= w) =>
sym
-> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym))
-> Op sym
BVComp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
W4.bvSle)
, (Text
"bvsgt", (forall (w :: Nat).
(1 <= w) =>
sym
-> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym))
-> Op sym
BVComp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
W4.bvSgt)
, (Text
"bvsge", (forall (w :: Nat).
(1 <= w) =>
sym
-> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym))
-> Op sym
BVComp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
W4.bvSge)
, (Text
"bveq", (forall (w :: Nat).
(1 <= w) =>
sym
-> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym))
-> Op sym
BVComp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
W4.bvEq)
, (Text
"bvne", (forall (w :: Nat).
(1 <= w) =>
sym
-> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym))
-> Op sym
BVComp2 sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymExpr sym 'BaseBoolType)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
W4.bvNe)
, (Text
"bvneg", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp1 sym -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w)
W4.bvNeg)
, (Text
"bvnot", (forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
forall sym.
(forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w))
-> Op sym
BVOp1 sym -> SymBV sym w -> IO (SymBV sym w)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w)
W4.bvNotBits)
, (Text
"fnegd", Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall (res :: BaseType) sym (arg2 :: BaseType).
Assignment BaseTypeRepr ('EmptyCtx ::> res)
-> (sym -> SymExpr sym res -> IO (SymExpr sym arg2)) -> Op sym
Op1 Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> SymFloat sym fpp -> IO (SymFloat sym fpp)
W4.floatNeg @_ @Prec64)
, (Text
"fnegs", Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec32)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall (res :: BaseType) sym (arg2 :: BaseType).
Assignment BaseTypeRepr ('EmptyCtx ::> res)
-> (sym -> SymExpr sym res -> IO (SymExpr sym arg2)) -> Op sym
Op1 Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> SymFloat sym fpp -> IO (SymFloat sym fpp)
W4.floatNeg @_ @Prec32)
, (Text
"fabsd", Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall (res :: BaseType) sym (arg2 :: BaseType).
Assignment BaseTypeRepr ('EmptyCtx ::> res)
-> (sym -> SymExpr sym res -> IO (SymExpr sym arg2)) -> Op sym
Op1 Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> SymFloat sym fpp -> IO (SymFloat sym fpp)
W4.floatAbs @_ @Prec64)
, (Text
"fabss", Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec32)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall (res :: BaseType) sym (arg2 :: BaseType).
Assignment BaseTypeRepr ('EmptyCtx ::> res)
-> (sym -> SymExpr sym res -> IO (SymExpr sym arg2)) -> Op sym
Op1 Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> SymFloat sym fpp -> IO (SymFloat sym fpp)
W4.floatAbs @_ @Prec32)
, (Text
"fsqrt", Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec64)
x -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> RoundingMode -> SymFloat sym fpp -> IO (SymFloat sym fpp)
W4.floatSqrt @_ @Prec64 sym
sym RoundingMode
rm SymExpr sym (BaseFloatType Prec64)
x)
, (Text
"fsqrts", Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec32)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec32)
x -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> RoundingMode -> SymFloat sym fpp -> IO (SymFloat sym fpp)
W4.floatSqrt @_ @Prec32 sym
sym RoundingMode
rm SymExpr sym (BaseFloatType Prec32)
x)
, (Text
"fnand", Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall (res :: BaseType) sym (arg2 :: BaseType).
Assignment BaseTypeRepr ('EmptyCtx ::> res)
-> (sym -> SymExpr sym res -> IO (SymExpr sym arg2)) -> Op sym
Op1 Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym)
-> (sym
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> SymFloat sym fpp -> IO (Pred sym)
W4.floatIsNaN @_ @Prec64)
, (Text
"fnans", Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec32)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall (res :: BaseType) sym (arg2 :: BaseType).
Assignment BaseTypeRepr ('EmptyCtx ::> res)
-> (sym -> SymExpr sym res -> IO (SymExpr sym arg2)) -> Op sym
Op1 Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> SymFloat sym fpp -> IO (Pred sym)
W4.floatIsNaN @_ @Prec32)
, (Text
"frsp", Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec64)
x -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (fpp :: FloatPrecision) (fpp' :: FloatPrecision).
IsExprBuilder sym =>
sym
-> FloatPrecisionRepr fpp
-> RoundingMode
-> SymFloat sym fpp'
-> IO (SymFloat sym fpp)
W4.floatCast @_ @Prec32 @Prec64 sym
sym FloatPrecisionRepr Prec32
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr RoundingMode
rm SymExpr sym (BaseFloatType Prec64)
x)
, (Text
"fp_single_to_double", Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec32)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall (res :: BaseType) sym (arg2 :: BaseType).
Assignment BaseTypeRepr ('EmptyCtx ::> res)
-> (sym -> SymExpr sym res -> IO (SymExpr sym arg2)) -> Op sym
Op1 Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym ->
forall sym (fpp :: FloatPrecision) (fpp' :: FloatPrecision).
IsExprBuilder sym =>
sym
-> FloatPrecisionRepr fpp
-> RoundingMode
-> SymFloat sym fpp'
-> IO (SymFloat sym fpp)
W4.floatCast @_ @Prec64 @Prec32 sym
sym FloatPrecisionRepr Prec64
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr RoundingMode
W4.RNE)
, (Text
"fp_binary_to_double",
Assignment BaseTypeRepr ('EmptyCtx ::> BaseBVType 64)
-> (sym
-> SymExpr sym (BaseBVType 64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall (res :: BaseType) sym (arg2 :: BaseType).
Assignment BaseTypeRepr ('EmptyCtx ::> res)
-> (sym -> SymExpr sym res -> IO (SymExpr sym arg2)) -> Op sym
Op1 Assignment BaseTypeRepr ('EmptyCtx ::> BaseBVType 64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym -> forall sym (eb :: Nat) (sb :: Nat).
(IsExprBuilder sym, 2 <= eb, 2 <= sb) =>
sym
-> FloatPrecisionRepr (FloatingPointPrecision eb sb)
-> SymBV sym (eb + sb)
-> IO (SymFloat sym (FloatingPointPrecision eb sb))
W4.floatFromBinary @_ @11 @53 sym
sym FloatPrecisionRepr Prec64
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr)
, (Text
"fp_binary_to_single",
Assignment BaseTypeRepr ('EmptyCtx ::> BaseBVType 32)
-> (sym
-> SymExpr sym (BaseBVType 32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall (res :: BaseType) sym (arg2 :: BaseType).
Assignment BaseTypeRepr ('EmptyCtx ::> res)
-> (sym -> SymExpr sym res -> IO (SymExpr sym arg2)) -> Op sym
Op1 Assignment BaseTypeRepr ('EmptyCtx ::> BaseBVType 32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym -> forall sym (eb :: Nat) (sb :: Nat).
(IsExprBuilder sym, 2 <= eb, 2 <= sb) =>
sym
-> FloatPrecisionRepr (FloatingPointPrecision eb sb)
-> SymBV sym (eb + sb)
-> IO (SymFloat sym (FloatingPointPrecision eb sb))
W4.floatFromBinary @_ @8 @24 sym
sym FloatPrecisionRepr Prec32
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr)
, (Text
"fp_double_to_binary", Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseBVType 64)))
-> Op sym
forall (res :: BaseType) sym (arg2 :: BaseType).
Assignment BaseTypeRepr ('EmptyCtx ::> res)
-> (sym -> SymExpr sym res -> IO (SymExpr sym arg2)) -> Op sym
Op1 Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseBVType 64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseBVType 64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ forall sym (eb :: Nat) (sb :: Nat).
(IsExprBuilder sym, 2 <= eb, 2 <= sb) =>
sym
-> SymFloat sym (FloatingPointPrecision eb sb)
-> IO (SymBV sym (eb + sb))
W4.floatToBinary @_ @11 @53)
, (Text
"fp_single_to_binary", Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec32)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseBVType 32)))
-> Op sym
forall (res :: BaseType) sym (arg2 :: BaseType).
Assignment BaseTypeRepr ('EmptyCtx ::> res)
-> (sym -> SymExpr sym res -> IO (SymExpr sym arg2)) -> Op sym
Op1 Assignment BaseTypeRepr ('EmptyCtx ::> BaseFloatType Prec32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseBVType 32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseBVType 32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ forall sym (eb :: Nat) (sb :: Nat).
(IsExprBuilder sym, 2 <= eb, 2 <= sb) =>
sym
-> SymFloat sym (FloatingPointPrecision eb sb)
-> IO (SymBV sym (eb + sb))
W4.floatToBinary @_ @8 @24)
, (Text
"fctid", Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseBVType 64)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseBVType 64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseBVType 64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec64)
x -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseBVType 64)))
-> IO (SymExpr sym (BaseBVType 64))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseBVType 64)))
-> IO (SymExpr sym (BaseBVType 64)))
-> (RoundingMode -> IO (SymExpr sym (BaseBVType 64)))
-> IO (SymExpr sym (BaseBVType 64))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (w :: Nat) (fpp :: FloatPrecision).
(IsExprBuilder sym, 1 <= w) =>
sym
-> NatRepr w
-> RoundingMode
-> SymFloat sym fpp
-> IO (SymBV sym w)
W4.floatToSBV @_ @64 @Prec64 sym
sym NatRepr 64
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr RoundingMode
rm SymExpr sym (BaseFloatType Prec64)
x)
, (Text
"fctidu", Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseBVType 64)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseBVType 64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseBVType 64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec64)
x -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseBVType 64)))
-> IO (SymExpr sym (BaseBVType 64))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseBVType 64)))
-> IO (SymExpr sym (BaseBVType 64)))
-> (RoundingMode -> IO (SymExpr sym (BaseBVType 64)))
-> IO (SymExpr sym (BaseBVType 64))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (w :: Nat) (fpp :: FloatPrecision).
(IsExprBuilder sym, 1 <= w) =>
sym
-> NatRepr w
-> RoundingMode
-> SymFloat sym fpp
-> IO (SymBV sym w)
W4.floatToBV @_ @64 @Prec64 sym
sym NatRepr 64
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr RoundingMode
rm SymExpr sym (BaseFloatType Prec64)
x)
, (Text
"fctiw", Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseBVType 32)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseBVType 32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseBVType 32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec64)
x -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseBVType 32)))
-> IO (SymExpr sym (BaseBVType 32))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseBVType 32)))
-> IO (SymExpr sym (BaseBVType 32)))
-> (RoundingMode -> IO (SymExpr sym (BaseBVType 32)))
-> IO (SymExpr sym (BaseBVType 32))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (w :: Nat) (fpp :: FloatPrecision).
(IsExprBuilder sym, 1 <= w) =>
sym
-> NatRepr w
-> RoundingMode
-> SymFloat sym fpp
-> IO (SymBV sym w)
W4.floatToSBV @_ @32 @Prec64 sym
sym NatRepr 32
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr RoundingMode
rm SymExpr sym (BaseFloatType Prec64)
x)
, (Text
"fctiwu", Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseBVType 32)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseBVType 32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseBVType 32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec64)
x -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseBVType 32)))
-> IO (SymExpr sym (BaseBVType 32))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseBVType 32)))
-> IO (SymExpr sym (BaseBVType 32)))
-> (RoundingMode -> IO (SymExpr sym (BaseBVType 32)))
-> IO (SymExpr sym (BaseBVType 32))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (w :: Nat) (fpp :: FloatPrecision).
(IsExprBuilder sym, 1 <= w) =>
sym
-> NatRepr w
-> RoundingMode
-> SymFloat sym fpp
-> IO (SymBV sym w)
W4.floatToBV @_ @32 @Prec64 sym
sym NatRepr 32
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr RoundingMode
rm SymExpr sym (BaseFloatType Prec64)
x)
, (Text
"fcfid", Assignment
BaseTypeRepr (('EmptyCtx ::> BaseBVType 2) ::> BaseBVType 64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseBVType 64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr (('EmptyCtx ::> BaseBVType 2) ::> BaseBVType 64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseBVType 64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseBVType 64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseBVType 64)
x -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (w :: Nat) (fpp :: FloatPrecision).
(IsExprBuilder sym, 1 <= w) =>
sym
-> FloatPrecisionRepr fpp
-> RoundingMode
-> SymBV sym w
-> IO (SymFloat sym fpp)
W4.sbvToFloat @_ @64 @Prec64 sym
sym FloatPrecisionRepr Prec64
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr RoundingMode
rm SymExpr sym (BaseBVType 64)
x)
, (Text
"fcfids", Assignment
BaseTypeRepr (('EmptyCtx ::> BaseBVType 2) ::> BaseBVType 64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseBVType 64)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr (('EmptyCtx ::> BaseBVType 2) ::> BaseBVType 64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseBVType 64)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseBVType 64)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseBVType 64)
x -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (w :: Nat) (fpp :: FloatPrecision).
(IsExprBuilder sym, 1 <= w) =>
sym
-> FloatPrecisionRepr fpp
-> RoundingMode
-> SymBV sym w
-> IO (SymFloat sym fpp)
W4.sbvToFloat @_ @64 @Prec32 sym
sym FloatPrecisionRepr Prec32
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr RoundingMode
rm SymExpr sym (BaseBVType 64)
x)
, (Text
"fcfidu", Assignment
BaseTypeRepr (('EmptyCtx ::> BaseBVType 2) ::> BaseBVType 64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseBVType 64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr (('EmptyCtx ::> BaseBVType 2) ::> BaseBVType 64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseBVType 64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseBVType 64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseBVType 64)
x -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (w :: Nat) (fpp :: FloatPrecision).
(IsExprBuilder sym, 1 <= w) =>
sym
-> FloatPrecisionRepr fpp
-> RoundingMode
-> SymBV sym w
-> IO (SymFloat sym fpp)
W4.bvToFloat @_ @64 @Prec64 sym
sym FloatPrecisionRepr Prec64
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr RoundingMode
rm SymExpr sym (BaseBVType 64)
x)
, (Text
"fcfidus", Assignment
BaseTypeRepr (('EmptyCtx ::> BaseBVType 2) ::> BaseBVType 64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseBVType 64)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr (('EmptyCtx ::> BaseBVType 2) ::> BaseBVType 64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseBVType 64)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseBVType 64)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseBVType 64)
x -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (w :: Nat) (fpp :: FloatPrecision).
(IsExprBuilder sym, 1 <= w) =>
sym
-> FloatPrecisionRepr fpp
-> RoundingMode
-> SymBV sym w
-> IO (SymFloat sym fpp)
W4.bvToFloat @_ @64 @Prec32 sym
sym FloatPrecisionRepr Prec32
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr RoundingMode
rm SymExpr sym (BaseBVType 64)
x)
, (Text
"frti", Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec64)
x -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> RoundingMode -> SymFloat sym fpp -> IO (SymFloat sym fpp)
W4.floatRound @_ @Prec64 sym
sym RoundingMode
rm SymExpr sym (BaseFloatType Prec64)
x)
, (Text
"frtis", Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec32)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec32)
x -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> RoundingMode -> SymFloat sym fpp -> IO (SymFloat sym fpp)
W4.floatRound @_ @Prec32 sym
sym RoundingMode
rm SymExpr sym (BaseFloatType Prec32)
x)
, (Text
"fadd", Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) (arg3 :: BaseType) sym
(arg4 :: BaseType).
Assignment BaseTypeRepr ((('EmptyCtx ::> res) ::> arg2) ::> arg3)
-> (sym
-> SymExpr sym res
-> SymExpr sym arg2
-> SymExpr sym arg3
-> IO (SymExpr sym arg4))
-> Op sym
Op3 Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec64)
x SymExpr sym (BaseFloatType Prec64)
y -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym
-> RoundingMode
-> SymFloat sym fpp
-> SymFloat sym fpp
-> IO (SymFloat sym fpp)
W4.floatAdd @_ @Prec64 sym
sym RoundingMode
rm SymExpr sym (BaseFloatType Prec64)
x SymExpr sym (BaseFloatType Prec64)
y)
, (Text
"fadds", Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec32)
::> BaseFloatType Prec32)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) (arg3 :: BaseType) sym
(arg4 :: BaseType).
Assignment BaseTypeRepr ((('EmptyCtx ::> res) ::> arg2) ::> arg3)
-> (sym
-> SymExpr sym res
-> SymExpr sym arg2
-> SymExpr sym arg3
-> IO (SymExpr sym arg4))
-> Op sym
Op3 Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec32)
::> BaseFloatType Prec32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec32)
x SymExpr sym (BaseFloatType Prec32)
y -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym
-> RoundingMode
-> SymFloat sym fpp
-> SymFloat sym fpp
-> IO (SymFloat sym fpp)
W4.floatAdd @_ @Prec32 sym
sym RoundingMode
rm SymExpr sym (BaseFloatType Prec32)
x SymExpr sym (BaseFloatType Prec32)
y)
, (Text
"fsub", Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) (arg3 :: BaseType) sym
(arg4 :: BaseType).
Assignment BaseTypeRepr ((('EmptyCtx ::> res) ::> arg2) ::> arg3)
-> (sym
-> SymExpr sym res
-> SymExpr sym arg2
-> SymExpr sym arg3
-> IO (SymExpr sym arg4))
-> Op sym
Op3 Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec64)
x SymExpr sym (BaseFloatType Prec64)
y -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym
-> RoundingMode
-> SymFloat sym fpp
-> SymFloat sym fpp
-> IO (SymFloat sym fpp)
W4.floatSub @_ @Prec64 sym
sym RoundingMode
rm SymExpr sym (BaseFloatType Prec64)
x SymExpr sym (BaseFloatType Prec64)
y)
, (Text
"fsubs", Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec32)
::> BaseFloatType Prec32)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) (arg3 :: BaseType) sym
(arg4 :: BaseType).
Assignment BaseTypeRepr ((('EmptyCtx ::> res) ::> arg2) ::> arg3)
-> (sym
-> SymExpr sym res
-> SymExpr sym arg2
-> SymExpr sym arg3
-> IO (SymExpr sym arg4))
-> Op sym
Op3 Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec32)
::> BaseFloatType Prec32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec32)
x SymExpr sym (BaseFloatType Prec32)
y -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym
-> RoundingMode
-> SymFloat sym fpp
-> SymFloat sym fpp
-> IO (SymFloat sym fpp)
W4.floatSub @_ @Prec32 sym
sym RoundingMode
rm SymExpr sym (BaseFloatType Prec32)
x SymExpr sym (BaseFloatType Prec32)
y)
, (Text
"fmul", Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) (arg3 :: BaseType) sym
(arg4 :: BaseType).
Assignment BaseTypeRepr ((('EmptyCtx ::> res) ::> arg2) ::> arg3)
-> (sym
-> SymExpr sym res
-> SymExpr sym arg2
-> SymExpr sym arg3
-> IO (SymExpr sym arg4))
-> Op sym
Op3 Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec64)
x SymExpr sym (BaseFloatType Prec64)
y -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym
-> RoundingMode
-> SymFloat sym fpp
-> SymFloat sym fpp
-> IO (SymFloat sym fpp)
W4.floatMul @_ @Prec64 sym
sym RoundingMode
rm SymExpr sym (BaseFloatType Prec64)
x SymExpr sym (BaseFloatType Prec64)
y)
, (Text
"fmuls", Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec32)
::> BaseFloatType Prec32)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) (arg3 :: BaseType) sym
(arg4 :: BaseType).
Assignment BaseTypeRepr ((('EmptyCtx ::> res) ::> arg2) ::> arg3)
-> (sym
-> SymExpr sym res
-> SymExpr sym arg2
-> SymExpr sym arg3
-> IO (SymExpr sym arg4))
-> Op sym
Op3 Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec32)
::> BaseFloatType Prec32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec32)
x SymExpr sym (BaseFloatType Prec32)
y -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym
-> RoundingMode
-> SymFloat sym fpp
-> SymFloat sym fpp
-> IO (SymFloat sym fpp)
W4.floatMul @_ @Prec32 sym
sym RoundingMode
rm SymExpr sym (BaseFloatType Prec32)
x SymExpr sym (BaseFloatType Prec32)
y)
, (Text
"fdiv", Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) (arg3 :: BaseType) sym
(arg4 :: BaseType).
Assignment BaseTypeRepr ((('EmptyCtx ::> res) ::> arg2) ::> arg3)
-> (sym
-> SymExpr sym res
-> SymExpr sym arg2
-> SymExpr sym arg3
-> IO (SymExpr sym arg4))
-> Op sym
Op3 Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec64)
x SymExpr sym (BaseFloatType Prec64)
y -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym
-> RoundingMode
-> SymFloat sym fpp
-> SymFloat sym fpp
-> IO (SymFloat sym fpp)
W4.floatDiv @_ @Prec64 sym
sym RoundingMode
rm SymExpr sym (BaseFloatType Prec64)
x SymExpr sym (BaseFloatType Prec64)
y)
, (Text
"fdivs", Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec32)
::> BaseFloatType Prec32)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) (arg3 :: BaseType) sym
(arg4 :: BaseType).
Assignment BaseTypeRepr ((('EmptyCtx ::> res) ::> arg2) ::> arg3)
-> (sym
-> SymExpr sym res
-> SymExpr sym arg2
-> SymExpr sym arg3
-> IO (SymExpr sym arg4))
-> Op sym
Op3 Assignment
BaseTypeRepr
((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec32)
::> BaseFloatType Prec32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec32)
x SymExpr sym (BaseFloatType Prec32)
y -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym
-> RoundingMode
-> SymFloat sym fpp
-> SymFloat sym fpp
-> IO (SymFloat sym fpp)
W4.floatDiv @_ @Prec32 sym
sym RoundingMode
rm SymExpr sym (BaseFloatType Prec32)
x SymExpr sym (BaseFloatType Prec32)
y)
, (Text
"fltd", Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseFloatType Prec64) ::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseFloatType Prec64) ::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym)
-> (sym
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym)
W4.floatLt @_ @Prec64)
, (Text
"flts", Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseFloatType Prec32) ::> BaseFloatType Prec32)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseFloatType Prec32) ::> BaseFloatType Prec32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym)
W4.floatLt @_ @Prec32)
, (Text
"feqd", Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseFloatType Prec64) ::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseFloatType Prec64) ::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym)
-> (sym
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym)
W4.floatFpEq @_ @Prec64)
, (Text
"feqs", Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseFloatType Prec32) ::> BaseFloatType Prec32)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseFloatType Prec32) ::> BaseFloatType Prec32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym)
W4.floatFpEq @_ @Prec32)
, (Text
"fled", Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseFloatType Prec64) ::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseFloatType Prec64) ::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym)
-> (sym
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym)
W4.floatLe @_ @Prec64)
, (Text
"fles", Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseFloatType Prec32) ::> BaseFloatType Prec32)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) sym (arg3 :: BaseType).
Assignment BaseTypeRepr (('EmptyCtx ::> res) ::> arg2)
-> (sym
-> SymExpr sym res -> SymExpr sym arg2 -> IO (SymExpr sym arg3))
-> Op sym
Op2 Assignment
BaseTypeRepr
(('EmptyCtx ::> BaseFloatType Prec32) ::> BaseFloatType Prec32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym)
-> (sym
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym 'BaseBoolType))
-> Op sym
forall a b. (a -> b) -> a -> b
$ forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> SymFloat sym fpp -> SymFloat sym fpp -> IO (Pred sym)
W4.floatLe @_ @Prec32)
, (Text
"ffma", Assignment
BaseTypeRepr
(((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
::> BaseFloatType Prec64)
::> BaseFloatType Prec64)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) (arg3 :: BaseType)
(arg4 :: BaseType) sym (ret :: BaseType).
Assignment
BaseTypeRepr (((('EmptyCtx ::> res) ::> arg2) ::> arg3) ::> arg4)
-> (sym
-> SymExpr sym res
-> SymExpr sym arg2
-> SymExpr sym arg3
-> SymExpr sym arg4
-> IO (SymExpr sym ret))
-> Op sym
Op4 Assignment
BaseTypeRepr
(((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec64)
::> BaseFloatType Prec64)
::> BaseFloatType Prec64)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> SymExpr sym (BaseFloatType Prec64)
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec64)
x SymExpr sym (BaseFloatType Prec64)
y SymExpr sym (BaseFloatType Prec64)
z -> sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec64)))
-> IO (SymExpr sym (BaseFloatType Prec64))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm ->
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym
-> RoundingMode
-> SymFloat sym fpp
-> SymFloat sym fpp
-> SymFloat sym fpp
-> IO (SymFloat sym fpp)
W4.floatFMA @_ @Prec64 sym
sym RoundingMode
rm SymExpr sym (BaseFloatType Prec64)
x SymExpr sym (BaseFloatType Prec64)
y SymExpr sym (BaseFloatType Prec64)
z)
, (Text
"ffmas", Assignment
BaseTypeRepr
(((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec32)
::> BaseFloatType Prec32)
::> BaseFloatType Prec32)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall (res :: BaseType) (arg2 :: BaseType) (arg3 :: BaseType)
(arg4 :: BaseType) sym (ret :: BaseType).
Assignment
BaseTypeRepr (((('EmptyCtx ::> res) ::> arg2) ::> arg3) ::> arg4)
-> (sym
-> SymExpr sym res
-> SymExpr sym arg2
-> SymExpr sym arg3
-> SymExpr sym arg4
-> IO (SymExpr sym ret))
-> Op sym
Op4 Assignment
BaseTypeRepr
(((('EmptyCtx ::> BaseBVType 2) ::> BaseFloatType Prec32)
::> BaseFloatType Prec32)
::> BaseFloatType Prec32)
forall k (f :: k -> Type) (ctx :: k). KnownRepr f ctx => f ctx
knownRepr ((sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym)
-> (sym
-> SymExpr sym (BaseBVType 2)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> SymExpr sym (BaseFloatType Prec32)
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> Op sym
forall a b. (a -> b) -> a -> b
$ \sym
sym SymExpr sym (BaseBVType 2)
r SymExpr sym (BaseFloatType Prec32)
x SymExpr sym (BaseFloatType Prec32)
y SymExpr sym (BaseFloatType Prec32)
z ->
sym
-> SymExpr sym (BaseBVType 2)
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> SymBV sym 2
-> (RoundingMode -> IO (SymExpr sym tp))
-> IO (SymExpr sym tp)
U.withRounding sym
sym SymExpr sym (BaseBVType 2)
r ((RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32)))
-> (RoundingMode -> IO (SymExpr sym (BaseFloatType Prec32)))
-> IO (SymExpr sym (BaseFloatType Prec32))
forall a b. (a -> b) -> a -> b
$ \RoundingMode
rm -> forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym
-> RoundingMode
-> SymFloat sym fpp
-> SymFloat sym fpp
-> SymFloat sym fpp
-> IO (SymFloat sym fpp)
W4.floatFMA @_ @Prec32 sym
sym RoundingMode
rm SymExpr sym (BaseFloatType Prec32)
x SymExpr sym (BaseFloatType Prec32)
y SymExpr sym (BaseFloatType Prec32)
z)
]
readOneArg ::
forall sym t st fs . (sym ~ W4.ExprBuilder t st fs)
=> [SExpr]
-> Processor sym (Some (W4.SymExpr sym))
readOneArg :: forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym (Some (SymExpr sym))
readOneArg [SExpr]
operands = do
[Some (Expr t)]
args <- [SExpr] -> Processor sym [Some (SymExpr sym)]
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym [Some (SymExpr sym)]
readExprs [SExpr]
operands
case [Some (Expr t)]
args of
[Some (Expr t)
arg] -> Some (Expr t)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return Some (Expr t)
arg
[Some (Expr t)]
_ -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ String -> Int -> String
forall r. PrintfType r => String -> r
printf String
"expecting 1 argument, got %d" ([Some (Expr t)] -> Int
forall a. [a] -> Int
forall (t :: Type -> Type) a. Foldable t => t a -> Int
length [Some (Expr t)]
args)
readTwoArgs ::
forall sym t st fs . (sym ~ W4.ExprBuilder t st fs)
=> [SExpr]
-> Processor sym (Some (W4.SymExpr sym), Some (W4.SymExpr sym))
readTwoArgs :: forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym (Some (SymExpr sym), Some (SymExpr sym))
readTwoArgs [SExpr]
operands = do
[Some (Expr t)]
args <- [SExpr] -> Processor sym [Some (SymExpr sym)]
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym [Some (SymExpr sym)]
readExprs [SExpr]
operands
case [Some (Expr t)]
args of
[Some (Expr t)
arg1, Some (Expr t)
arg2] -> (Some (Expr t), Some (Expr t))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (Expr t), Some (Expr t))
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some (Expr t)
arg1, Some (Expr t)
arg2)
[Some (Expr t)]
_ -> String
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (Expr t), Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (Expr t), Some (Expr t)))
-> String
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (Expr t), Some (Expr t))
forall a b. (a -> b) -> a -> b
$ String -> Int -> String
forall r. PrintfType r => String -> r
printf String
"expecting 2 arguments, got %d" ([Some (Expr t)] -> Int
forall a. [a] -> Int
forall (t :: Type -> Type) a. Foldable t => t a -> Int
length [Some (Expr t)]
args)
readThreeArgs ::
forall sym t st fs . (sym ~ W4.ExprBuilder t st fs)
=> [SExpr]
-> Processor sym (Some (W4.SymExpr sym), Some (W4.SymExpr sym), Some (W4.SymExpr sym))
readThreeArgs :: forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr]
-> Processor
sym (Some (SymExpr sym), Some (SymExpr sym), Some (SymExpr sym))
readThreeArgs [SExpr]
operands = do
[Some (Expr t)]
args <- [SExpr] -> Processor sym [Some (SymExpr sym)]
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym [Some (SymExpr sym)]
readExprs [SExpr]
operands
case [Some (Expr t)]
args of
[Some (Expr t)
arg1, Some (Expr t)
arg2, Some (Expr t)
arg3] -> (Some (Expr t), Some (Expr t), Some (Expr t))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (Expr t), Some (Expr t), Some (Expr t))
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some (Expr t)
arg1, Some (Expr t)
arg2, Some (Expr t)
arg3)
[Some (Expr t)]
_ -> String
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (Expr t), Some (Expr t), Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (Expr t), Some (Expr t), Some (Expr t)))
-> String
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (Expr t), Some (Expr t), Some (Expr t))
forall a b. (a -> b) -> a -> b
$ String -> Int -> String
forall r. PrintfType r => String -> r
printf String
"expecting 3 arguments, got %d" ([Some (Expr t)] -> Int
forall a. [a] -> Int
forall (t :: Type -> Type) a. Foldable t => t a -> Int
length [Some (Expr t)]
args)
readApp ::
forall sym t st fs . (sym ~ W4.ExprBuilder t st fs)
=> SExpr
-> [SExpr]
-> Processor sym (Some (W4.SymExpr sym))
readApp :: forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> [SExpr] -> Processor sym (Some (SymExpr sym))
readApp (S.WFSAtom (AId Text
"call")) (S.WFSAtom (AId Text
fnName):[SExpr]
operands) = do
ExprBuilder t st fs
sym <- (ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ExprBuilder t st fs)
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.asks ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs
forall sym. ProcessorEnv sym -> sym
procSym
Maybe (SomeSymFn sym)
maybeFn <- Text -> Processor sym (Maybe (SomeSymFn sym))
forall sym. Text -> Processor sym (Maybe (SomeSymFn sym))
lookupFn Text
fnName
case Maybe (SomeSymFn sym)
maybeFn of
Just (SomeSymFn SymFn sym dom ret
fn) -> do
[Some (Expr t)]
args <- (SExpr
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> [SExpr]
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) [Some (Expr t)]
forall (t :: Type -> Type) (m :: Type -> Type) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: Type -> Type) a b.
Monad m =>
(a -> m b) -> [a] -> m [b]
mapM SExpr -> Processor sym (Some (SymExpr sym))
SExpr
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> Processor sym (Some (SymExpr sym))
readExpr [SExpr]
operands
Assignment (Expr t) dom
assn <- Assignment BaseTypeRepr dom
-> [Some (Expr t)] -> Processor sym (Assignment (Expr t) dom)
forall sym (ctx :: Ctx BaseType) (ex :: BaseType -> Type).
(IsSymExprBuilder sym, ShowF (SymExpr sym), ShowF ex, IsExpr ex) =>
Assignment BaseTypeRepr ctx
-> [Some ex] -> Processor sym (Assignment ex ctx)
exprAssignment (ExprSymFn t dom ret -> Assignment BaseTypeRepr dom
forall (args :: Ctx BaseType) (ret :: BaseType).
ExprSymFn t args ret -> Assignment BaseTypeRepr args
forall (fn :: Ctx BaseType -> BaseType -> Type)
(args :: Ctx BaseType) (ret :: BaseType).
IsSymFn fn =>
fn args ret -> Assignment BaseTypeRepr args
W4.fnArgTypes SymFn sym dom ret
ExprSymFn t dom ret
fn) [Some (Expr t)]
args
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t ret -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t ret -> Some (Expr t))
-> IO (Expr t ret) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> SymFn (ExprBuilder t st fs) dom ret
-> Assignment (SymExpr (ExprBuilder t st fs)) dom
-> IO (SymExpr (ExprBuilder t st fs) ret)
forall sym (args :: Ctx BaseType) (ret :: BaseType).
IsSymExprBuilder sym =>
sym
-> SymFn sym args ret
-> Assignment (SymExpr sym) args
-> IO (SymExpr sym ret)
forall (args :: Ctx BaseType) (ret :: BaseType).
ExprBuilder t st fs
-> SymFn (ExprBuilder t st fs) args ret
-> Assignment (SymExpr (ExprBuilder t st fs)) args
-> IO (SymExpr (ExprBuilder t st fs) ret)
W4.applySymFn ExprBuilder t st fs
sym SymFn sym dom ret
SymFn (ExprBuilder t st fs) dom ret
fn Assignment (SymExpr (ExprBuilder t st fs)) dom
Assignment (Expr t) dom
assn)
Maybe (SomeSymFn sym)
Nothing -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ String
"The function name `"
String -> String -> String
forall a. [a] -> [a] -> [a]
++(Text -> String
T.unpack Text
fnName)
String -> String -> String
forall a. [a] -> [a] -> [a]
++String
"` is not bound to a SymFn in the current Config."
readApp opRaw :: SExpr
opRaw@(S.WFSAtom (AId Text
"call")) [SExpr]
operands = String -> Processor sym (Some (SymExpr sym))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError
(String -> Processor sym (Some (SymExpr sym)))
-> String -> Processor sym (Some (SymExpr sym))
forall a b. (a -> b) -> a -> b
$ String
"Unrecognized use of `call`: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Text -> String
T.unpack (Seq String -> SExpr -> Text
printSExpr Seq String
forall a. Monoid a => a
mempty ([SExpr] -> SExpr
forall t. [WellFormedSExpr t] -> WellFormedSExpr t
S.L (SExpr
opRawSExpr -> [SExpr] -> [SExpr]
forall a. a -> [a] -> [a]
:[SExpr]
operands))))
readApp opRaw :: SExpr
opRaw@(S.WFSAtom (AId Text
operator)) [SExpr]
operands = do
ExprBuilder t st fs
sym <- (ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ExprBuilder t st fs)
forall a.
(ProcessorEnv (ExprBuilder t st fs) -> a)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.reader ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs
forall sym. ProcessorEnv sym -> sym
procSym
String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall e (m :: Type -> Type) a.
(Monoid e, MonadError e m) =>
e -> m a -> m a
prefixError (String
"in reading expression:\n"
String -> String -> String
forall a. [a] -> [a] -> [a]
++(Text -> String
T.unpack (Text -> String) -> Text -> String
forall a b. (a -> b) -> a -> b
$ Seq String -> SExpr -> Text
printSExpr Seq String
forall a. Monoid a => a
mempty (SExpr -> Text) -> SExpr -> Text
forall a b. (a -> b) -> a -> b
$ [SExpr] -> SExpr
forall t. [WellFormedSExpr t] -> WellFormedSExpr t
S.WFSList (SExpr
opRawSExpr -> [SExpr] -> [SExpr]
forall a. a -> [a] -> [a]
:[SExpr]
operands))String -> String -> String
forall a. [a] -> [a] -> [a]
++String
"\n") (ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$
case forall sym. IsSymExprBuilder sym => Text -> Maybe (Op sym)
lookupOp @sym Text
operator of
Just (FloatOp1 forall (fpp :: FloatPrecision).
sym -> SymFloat sym fpp -> IO (SymFloat sym fpp)
fn) -> do
[Some (Expr t)]
args <- [SExpr] -> Processor sym [Some (SymExpr sym)]
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym [Some (SymExpr sym)]
readExprs [SExpr]
operands
case [Some (Expr t)]
args of
[Some Expr t x
a1]
| BaseFloatRepr FloatPrecisionRepr fpp
_ <- Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
a1 -> IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t ('BaseFloatType fpp) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t ('BaseFloatType fpp) -> Some (Expr t))
-> IO (Expr t ('BaseFloatType fpp)) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> sym -> SymFloat sym fpp -> IO (SymFloat sym fpp)
forall (fpp :: FloatPrecision).
sym -> SymFloat sym fpp -> IO (SymFloat sym fpp)
fn sym
ExprBuilder t st fs
sym SymFloat sym fpp
Expr t x
a1)
[Some (Expr t)]
_ -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError String
"Unable to unpack FloatOp1 arg in Formula.Parser readApp"
Just (Op1 Assignment BaseTypeRepr ('EmptyCtx ::> arg1)
arg_types sym -> SymExpr sym arg1 -> IO (SymExpr sym ret)
fn) -> do
[Some (Expr t)]
args <- [SExpr] -> Processor sym [Some (SymExpr sym)]
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym [Some (SymExpr sym)]
readExprs [SExpr]
operands
Assignment BaseTypeRepr ('EmptyCtx ::> arg1)
-> [Some (Expr t)]
-> Processor sym (Assignment (Expr t) ('EmptyCtx ::> arg1))
forall sym (ctx :: Ctx BaseType) (ex :: BaseType -> Type).
(IsSymExprBuilder sym, ShowF (SymExpr sym), ShowF ex, IsExpr ex) =>
Assignment BaseTypeRepr ctx
-> [Some ex] -> Processor sym (Assignment ex ctx)
exprAssignment Assignment BaseTypeRepr ('EmptyCtx ::> arg1)
arg_types [Some (Expr t)]
args Processor sym (Assignment (Expr t) ('EmptyCtx ::> arg1))
-> (Assignment (Expr t) ('EmptyCtx ::> arg1)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b.
ExceptT String (ReaderT (ProcessorEnv sym) IO) a
-> (a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) b)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) b
forall (m :: Type -> Type) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Assignment (Expr t) ctx
Ctx.Empty Ctx.:> Expr t tp
arg1 ->
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t ret -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t ret -> Some (Expr t))
-> IO (Expr t ret) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> sym -> SymExpr sym arg1 -> IO (SymExpr sym ret)
fn sym
ExprBuilder t st fs
sym SymExpr sym arg1
Expr t tp
arg1)
Just (Op2 Assignment BaseTypeRepr (('EmptyCtx ::> arg1) ::> arg2)
arg_types sym -> SymExpr sym arg1 -> SymExpr sym arg2 -> IO (SymExpr sym ret)
fn) -> do
[Some (Expr t)]
args <- [SExpr] -> Processor sym [Some (SymExpr sym)]
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym [Some (SymExpr sym)]
readExprs [SExpr]
operands
Assignment BaseTypeRepr (('EmptyCtx ::> arg1) ::> arg2)
-> [Some (Expr t)]
-> Processor
sym (Assignment (Expr t) (('EmptyCtx ::> arg1) ::> arg2))
forall sym (ctx :: Ctx BaseType) (ex :: BaseType -> Type).
(IsSymExprBuilder sym, ShowF (SymExpr sym), ShowF ex, IsExpr ex) =>
Assignment BaseTypeRepr ctx
-> [Some ex] -> Processor sym (Assignment ex ctx)
exprAssignment Assignment BaseTypeRepr (('EmptyCtx ::> arg1) ::> arg2)
arg_types [Some (Expr t)]
args Processor sym (Assignment (Expr t) (('EmptyCtx ::> arg1) ::> arg2))
-> (Assignment (Expr t) (('EmptyCtx ::> arg1) ::> arg2)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b.
ExceptT String (ReaderT (ProcessorEnv sym) IO) a
-> (a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) b)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) b
forall (m :: Type -> Type) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Assignment (Expr t) ctx
Ctx.Empty Ctx.:> Expr t tp
arg1 Ctx.:> Expr t tp
arg2 ->
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t ret -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t ret -> Some (Expr t))
-> IO (Expr t ret) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> sym -> SymExpr sym arg1 -> SymExpr sym arg2 -> IO (SymExpr sym ret)
fn sym
ExprBuilder t st fs
sym SymExpr sym arg1
Expr t tp
arg1 SymExpr sym arg2
Expr t tp
arg2)
Just (Op3 Assignment BaseTypeRepr ((('EmptyCtx ::> arg1) ::> arg2) ::> arg3)
arg_types sym
-> SymExpr sym arg1
-> SymExpr sym arg2
-> SymExpr sym arg3
-> IO (SymExpr sym ret)
fn) -> do
[Some (Expr t)]
args <- [SExpr] -> Processor sym [Some (SymExpr sym)]
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym [Some (SymExpr sym)]
readExprs [SExpr]
operands
Assignment BaseTypeRepr ((('EmptyCtx ::> arg1) ::> arg2) ::> arg3)
-> [Some (Expr t)]
-> Processor
sym
(Assignment (Expr t) ((('EmptyCtx ::> arg1) ::> arg2) ::> arg3))
forall sym (ctx :: Ctx BaseType) (ex :: BaseType -> Type).
(IsSymExprBuilder sym, ShowF (SymExpr sym), ShowF ex, IsExpr ex) =>
Assignment BaseTypeRepr ctx
-> [Some ex] -> Processor sym (Assignment ex ctx)
exprAssignment Assignment BaseTypeRepr ((('EmptyCtx ::> arg1) ::> arg2) ::> arg3)
arg_types [Some (Expr t)]
args Processor
sym
(Assignment (Expr t) ((('EmptyCtx ::> arg1) ::> arg2) ::> arg3))
-> (Assignment (Expr t) ((('EmptyCtx ::> arg1) ::> arg2) ::> arg3)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b.
ExceptT String (ReaderT (ProcessorEnv sym) IO) a
-> (a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) b)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) b
forall (m :: Type -> Type) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Assignment (Expr t) ctx
Ctx.Empty Ctx.:> Expr t tp
arg1 Ctx.:> Expr t tp
arg2 Ctx.:> Expr t tp
arg3 ->
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t ret -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t ret -> Some (Expr t))
-> IO (Expr t ret) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> sym
-> SymExpr sym arg1
-> SymExpr sym arg2
-> SymExpr sym arg3
-> IO (SymExpr sym ret)
fn sym
ExprBuilder t st fs
sym SymExpr sym arg1
Expr t tp
arg1 SymExpr sym arg2
Expr t tp
arg2 SymExpr sym arg3
Expr t tp
arg3)
Just (Op4 Assignment
BaseTypeRepr (((('EmptyCtx ::> arg1) ::> arg2) ::> arg3) ::> arg4)
arg_types sym
-> SymExpr sym arg1
-> SymExpr sym arg2
-> SymExpr sym arg3
-> SymExpr sym arg4
-> IO (SymExpr sym ret)
fn) -> do
[Some (Expr t)]
args <- [SExpr] -> Processor sym [Some (SymExpr sym)]
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym [Some (SymExpr sym)]
readExprs [SExpr]
operands
Assignment
BaseTypeRepr (((('EmptyCtx ::> arg1) ::> arg2) ::> arg3) ::> arg4)
-> [Some (Expr t)]
-> Processor
sym
(Assignment
(Expr t) (((('EmptyCtx ::> arg1) ::> arg2) ::> arg3) ::> arg4))
forall sym (ctx :: Ctx BaseType) (ex :: BaseType -> Type).
(IsSymExprBuilder sym, ShowF (SymExpr sym), ShowF ex, IsExpr ex) =>
Assignment BaseTypeRepr ctx
-> [Some ex] -> Processor sym (Assignment ex ctx)
exprAssignment Assignment
BaseTypeRepr (((('EmptyCtx ::> arg1) ::> arg2) ::> arg3) ::> arg4)
arg_types [Some (Expr t)]
args Processor
sym
(Assignment
(Expr t) (((('EmptyCtx ::> arg1) ::> arg2) ::> arg3) ::> arg4))
-> (Assignment
(Expr t) (((('EmptyCtx ::> arg1) ::> arg2) ::> arg3) ::> arg4)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b.
ExceptT String (ReaderT (ProcessorEnv sym) IO) a
-> (a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) b)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) b
forall (m :: Type -> Type) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Assignment (Expr t) ctx
Ctx.Empty Ctx.:> Expr t tp
arg1 Ctx.:> Expr t tp
arg2 Ctx.:> Expr t tp
arg3 Ctx.:> Expr t tp
arg4 ->
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t ret -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t ret -> Some (Expr t))
-> IO (Expr t ret) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> sym
-> SymExpr sym arg1
-> SymExpr sym arg2
-> SymExpr sym arg3
-> SymExpr sym arg4
-> IO (SymExpr sym ret)
fn sym
ExprBuilder t st fs
sym SymExpr sym arg1
Expr t tp
arg1 SymExpr sym arg2
Expr t tp
arg2 SymExpr sym arg3
Expr t tp
arg3 SymExpr sym arg4
Expr t tp
arg4)
Just (BVOp1 forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w)
op) -> do
Some Expr t x
expr <- [SExpr] -> Processor sym (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym (Some (SymExpr sym))
readOneArg [SExpr]
operands
BVProof NatRepr n
_ <- Expr t x
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall (ex :: BaseType -> Type) (m :: Type -> Type)
(tp :: BaseType).
(IsExpr ex, MonadError String m) =>
ex tp -> m (BVProof tp)
getBVProof Expr t x
expr
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ Expr t ('BaseBVType n) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t ('BaseBVType n) -> Some (Expr t))
-> IO (Expr t ('BaseBVType n)) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> sym -> SymBV sym n -> IO (SymBV sym n)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> IO (SymBV sym w)
op sym
ExprBuilder t st fs
sym SymBV sym n
Expr t x
expr
Just (BVOp2 forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
op) -> do
(Some Expr t x
arg1, Some Expr t x
arg2) <- [SExpr] -> Processor sym (Some (SymExpr sym), Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym (Some (SymExpr sym), Some (SymExpr sym))
readTwoArgs [SExpr]
operands
BVProof NatRepr n
m <- String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall e (m :: Type -> Type) a.
(Monoid e, MonadError e m) =>
e -> m a -> m a
prefixError String
"in arg 1: " (ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall a b. (a -> b) -> a -> b
$ Expr t x
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall (ex :: BaseType -> Type) (m :: Type -> Type)
(tp :: BaseType).
(IsExpr ex, MonadError String m) =>
ex tp -> m (BVProof tp)
getBVProof Expr t x
arg1
BVProof NatRepr n
n <- String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall e (m :: Type -> Type) a.
(Monoid e, MonadError e m) =>
e -> m a -> m a
prefixError String
"in arg 2: " (ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall a b. (a -> b) -> a -> b
$ Expr t x
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall (ex :: BaseType -> Type) (m :: Type -> Type)
(tp :: BaseType).
(IsExpr ex, MonadError String m) =>
ex tp -> m (BVProof tp)
getBVProof Expr t x
arg2
case NatRepr n -> NatRepr n -> Maybe (n :~: n)
forall (a :: Nat) (b :: Nat).
NatRepr a -> NatRepr b -> Maybe (a :~: b)
forall {k} (f :: k -> Type) (a :: k) (b :: k).
TestEquality f =>
f a -> f b -> Maybe (a :~: b)
testEquality NatRepr n
m NatRepr n
n of
Just n :~: n
Refl -> IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t ('BaseBVType n) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t ('BaseBVType n) -> Some (Expr t))
-> IO (Expr t ('BaseBVType n)) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> sym -> SymBV sym n -> SymBV sym n -> IO (SymBV sym n)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (SymBV sym w)
op sym
ExprBuilder t st fs
sym SymBV sym n
Expr t x
arg1 SymBV sym n
Expr t x
arg2)
Maybe (n :~: n)
Nothing -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ String -> Text -> String -> String -> String
forall r. PrintfType r => String -> r
printf String
"arguments to %s must be the same length, \
\but arg 1 has length %s \
\and arg 2 has length %s"
Text
operator
(NatRepr n -> String
forall a. Show a => a -> String
show NatRepr n
m)
(NatRepr n -> String
forall a. Show a => a -> String
show NatRepr n
n)
Just (BVComp2 forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
op) -> do
(Some Expr t x
arg1, Some Expr t x
arg2) <- [SExpr] -> Processor sym (Some (SymExpr sym), Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym (Some (SymExpr sym), Some (SymExpr sym))
readTwoArgs [SExpr]
operands
BVProof NatRepr n
m <- String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall e (m :: Type -> Type) a.
(Monoid e, MonadError e m) =>
e -> m a -> m a
prefixError String
"in arg 1: " (ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall a b. (a -> b) -> a -> b
$ Expr t x
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall (ex :: BaseType -> Type) (m :: Type -> Type)
(tp :: BaseType).
(IsExpr ex, MonadError String m) =>
ex tp -> m (BVProof tp)
getBVProof Expr t x
arg1
BVProof NatRepr n
n <- String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall e (m :: Type -> Type) a.
(Monoid e, MonadError e m) =>
e -> m a -> m a
prefixError String
"in arg 2: " (ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall a b. (a -> b) -> a -> b
$ Expr t x
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall (ex :: BaseType -> Type) (m :: Type -> Type)
(tp :: BaseType).
(IsExpr ex, MonadError String m) =>
ex tp -> m (BVProof tp)
getBVProof Expr t x
arg2
case NatRepr n -> NatRepr n -> Maybe (n :~: n)
forall (a :: Nat) (b :: Nat).
NatRepr a -> NatRepr b -> Maybe (a :~: b)
forall {k} (f :: k -> Type) (a :: k) (b :: k).
TestEquality f =>
f a -> f b -> Maybe (a :~: b)
testEquality NatRepr n
m NatRepr n
n of
Just n :~: n
Refl -> IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t 'BaseBoolType -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t 'BaseBoolType -> Some (Expr t))
-> IO (Expr t 'BaseBoolType) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> sym -> SymBV sym n -> SymBV sym n -> IO (Pred sym)
forall (w :: Nat).
(1 <= w) =>
sym -> SymBV sym w -> SymBV sym w -> IO (Pred sym)
op sym
ExprBuilder t st fs
sym SymBV sym n
Expr t x
arg1 SymBV sym n
Expr t x
arg2)
Maybe (n :~: n)
Nothing -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ String -> Text -> String -> String -> String
forall r. PrintfType r => String -> r
printf String
"arguments to %s must be the same length, \
\but arg 1 has length %s \
\and arg 2 has length %s"
Text
operator
(NatRepr n -> String
forall a. Show a => a -> String
show NatRepr n
m)
(NatRepr n -> String
forall a. Show a => a -> String
show NatRepr n
n)
Maybe (Op sym)
Nothing ->
case Text
operator of
Text
"concat" -> do
(Some Expr t x
arg1, Some Expr t x
arg2) <- [SExpr] -> Processor sym (Some (SymExpr sym), Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym (Some (SymExpr sym), Some (SymExpr sym))
readTwoArgs [SExpr]
operands
BVProof NatRepr n
_ <- String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall e (m :: Type -> Type) a.
(Monoid e, MonadError e m) =>
e -> m a -> m a
prefixError String
"in arg 1: " (ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall a b. (a -> b) -> a -> b
$ Expr t x
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall (ex :: BaseType -> Type) (m :: Type -> Type)
(tp :: BaseType).
(IsExpr ex, MonadError String m) =>
ex tp -> m (BVProof tp)
getBVProof Expr t x
arg1
BVProof NatRepr n
_ <- String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall e (m :: Type -> Type) a.
(Monoid e, MonadError e m) =>
e -> m a -> m a
prefixError String
"in arg 2: " (ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall a b. (a -> b) -> a -> b
$ Expr t x
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall (ex :: BaseType -> Type) (m :: Type -> Type)
(tp :: BaseType).
(IsExpr ex, MonadError String m) =>
ex tp -> m (BVProof tp)
getBVProof Expr t x
arg2
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t (BaseBVType (n + n)) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t (BaseBVType (n + n)) -> Some (Expr t))
-> IO (Expr t (BaseBVType (n + n))) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> SymBV (ExprBuilder t st fs) n
-> SymBV (ExprBuilder t st fs) n
-> IO (SymBV (ExprBuilder t st fs) (n + n))
forall (u :: Nat) (v :: Nat).
(1 <= u, 1 <= v) =>
ExprBuilder t st fs
-> SymBV (ExprBuilder t st fs) u
-> SymBV (ExprBuilder t st fs) v
-> IO (SymBV (ExprBuilder t st fs) (u + v))
forall sym (u :: Nat) (v :: Nat).
(IsExprBuilder sym, 1 <= u, 1 <= v) =>
sym -> SymBV sym u -> SymBV sym v -> IO (SymBV sym (u + v))
W4.bvConcat ExprBuilder t st fs
sym SymBV (ExprBuilder t st fs) n
Expr t x
arg1 SymBV (ExprBuilder t st fs) n
Expr t x
arg2)
Text
"=" -> do
(Some Expr t x
arg1, Some Expr t x
arg2) <- [SExpr] -> Processor sym (Some (SymExpr sym), Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym (Some (SymExpr sym), Some (SymExpr sym))
readTwoArgs [SExpr]
operands
case BaseTypeRepr x -> BaseTypeRepr x -> Maybe (x :~: x)
forall {k} (f :: k -> Type) (a :: k) (b :: k).
TestEquality f =>
f a -> f b -> Maybe (a :~: b)
forall (a :: BaseType) (b :: BaseType).
BaseTypeRepr a -> BaseTypeRepr b -> Maybe (a :~: b)
testEquality (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
arg1) (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
arg2) of
Just x :~: x
Refl -> IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t 'BaseBoolType -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t 'BaseBoolType -> Some (Expr t))
-> IO (Expr t 'BaseBoolType) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> SymExpr (ExprBuilder t st fs) x
-> SymExpr (ExprBuilder t st fs) x
-> IO (Pred (ExprBuilder t st fs))
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym -> SymExpr sym tp -> SymExpr sym tp -> IO (Pred sym)
forall (tp :: BaseType).
ExprBuilder t st fs
-> SymExpr (ExprBuilder t st fs) tp
-> SymExpr (ExprBuilder t st fs) tp
-> IO (Pred (ExprBuilder t st fs))
W4.isEq ExprBuilder t st fs
sym SymExpr (ExprBuilder t st fs) x
Expr t x
arg1 SymExpr (ExprBuilder t st fs) x
Expr t x
arg2)
Maybe (x :~: x)
Nothing -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$
String -> String -> String -> String
forall r. PrintfType r => String -> r
printf String
"arguments must have same types, \
\but arg 1 has type %s \
\and arg 2 has type %s"
(BaseTypeRepr x -> String
forall a. Show a => a -> String
show (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
arg1))
(BaseTypeRepr x -> String
forall a. Show a => a -> String
show (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
arg2))
Text
"ite" -> do
(Some Expr t x
test, Some Expr t x
then_, Some Expr t x
else_) <- [SExpr]
-> Processor
sym (Some (SymExpr sym), Some (SymExpr sym), Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr]
-> Processor
sym (Some (SymExpr sym), Some (SymExpr sym), Some (SymExpr sym))
readThreeArgs [SExpr]
operands
case Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
test of
BaseTypeRepr x
BaseBoolRepr ->
case BaseTypeRepr x -> BaseTypeRepr x -> Maybe (x :~: x)
forall {k} (f :: k -> Type) (a :: k) (b :: k).
TestEquality f =>
f a -> f b -> Maybe (a :~: b)
forall (a :: BaseType) (b :: BaseType).
BaseTypeRepr a -> BaseTypeRepr b -> Maybe (a :~: b)
testEquality (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
then_) (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
else_) of
Just x :~: x
Refl -> IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t x -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t x -> Some (Expr t)) -> IO (Expr t x) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> Pred (ExprBuilder t st fs)
-> SymExpr (ExprBuilder t st fs) x
-> SymExpr (ExprBuilder t st fs) x
-> IO (SymExpr (ExprBuilder t st fs) x)
forall sym (tp :: BaseType).
IsExprBuilder sym =>
sym
-> Pred sym
-> SymExpr sym tp
-> SymExpr sym tp
-> IO (SymExpr sym tp)
forall (tp :: BaseType).
ExprBuilder t st fs
-> Pred (ExprBuilder t st fs)
-> SymExpr (ExprBuilder t st fs) tp
-> SymExpr (ExprBuilder t st fs) tp
-> IO (SymExpr (ExprBuilder t st fs) tp)
W4.baseTypeIte ExprBuilder t st fs
sym Pred (ExprBuilder t st fs)
Expr t x
test SymExpr (ExprBuilder t st fs) x
Expr t x
then_ SymExpr (ExprBuilder t st fs) x
Expr t x
else_)
Maybe (x :~: x)
Nothing -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$
String -> String -> String -> String
forall r. PrintfType r => String -> r
printf String
"then and else branches must have same type, \
\but then has type %s \
\and else has type %s"
(BaseTypeRepr x -> String
forall a. Show a => a -> String
show (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
then_))
(BaseTypeRepr x -> String
forall a. Show a => a -> String
show (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
else_))
BaseTypeRepr x
tp -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ String -> String -> String
forall r. PrintfType r => String -> r
printf String
"test expression must be a boolean; got %s" (BaseTypeRepr x -> String
forall a. Show a => a -> String
show BaseTypeRepr x
tp)
Text
"select" -> do
(Some Expr t x
arr, Some Expr t x
idx) <- [SExpr] -> Processor sym (Some (SymExpr sym), Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym (Some (SymExpr sym), Some (SymExpr sym))
readTwoArgs [SExpr]
operands
ArraySingleDim BaseTypeRepr res
_ <- BaseTypeRepr x
-> BaseTypeRepr x
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ArrayJudgment x x)
forall (m :: Type -> Type) (tp1 :: BaseType) (tp2 :: BaseType).
MonadError String m =>
BaseTypeRepr tp1 -> BaseTypeRepr tp2 -> m (ArrayJudgment tp1 tp2)
expectArrayWithIndex (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
idx) (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
arr)
let idx' :: Assignment (Expr t) (SingleCtx x)
idx' = Assignment (Expr t) 'EmptyCtx
forall {k} (f :: k -> Type). Assignment f EmptyCtx
Ctx.empty Assignment (Expr t) 'EmptyCtx
-> Expr t x -> Assignment (Expr t) (SingleCtx x)
forall {k} (ctx' :: Ctx k) (f :: k -> Type) (ctx :: Ctx k)
(tp :: k).
(ctx' ~ (ctx ::> tp)) =>
Assignment f ctx -> f tp -> Assignment f ctx'
Ctx.:> Expr t x
idx
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t res -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t res -> Some (Expr t))
-> IO (Expr t res) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> SymArray (ExprBuilder t st fs) (SingleCtx x) res
-> Assignment (SymExpr (ExprBuilder t st fs)) (SingleCtx x)
-> IO (SymExpr (ExprBuilder t st fs) res)
forall sym (idx :: Ctx BaseType) (tp :: BaseType) (b :: BaseType).
IsExprBuilder sym =>
sym
-> SymArray sym (idx ::> tp) b
-> Assignment (SymExpr sym) (idx ::> tp)
-> IO (SymExpr sym b)
forall (idx :: Ctx BaseType) (tp :: BaseType) (b :: BaseType).
ExprBuilder t st fs
-> SymArray (ExprBuilder t st fs) (idx ::> tp) b
-> Assignment (SymExpr (ExprBuilder t st fs)) (idx ::> tp)
-> IO (SymExpr (ExprBuilder t st fs) b)
W4.arrayLookup ExprBuilder t st fs
sym SymArray (ExprBuilder t st fs) (SingleCtx x) res
Expr t x
arr Assignment (SymExpr (ExprBuilder t st fs)) (SingleCtx x)
Assignment (Expr t) (SingleCtx x)
idx')
Text
"store" -> do
(Some Expr t x
arr, Some Expr t x
idx, Some Expr t x
expr) <- [SExpr]
-> Processor
sym (Some (SymExpr sym), Some (SymExpr sym), Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr]
-> Processor
sym (Some (SymExpr sym), Some (SymExpr sym), Some (SymExpr sym))
readThreeArgs [SExpr]
operands
ArraySingleDim BaseTypeRepr res
resRepr <- BaseTypeRepr x
-> BaseTypeRepr x
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ArrayJudgment x x)
forall (m :: Type -> Type) (tp1 :: BaseType) (tp2 :: BaseType).
MonadError String m =>
BaseTypeRepr tp1 -> BaseTypeRepr tp2 -> m (ArrayJudgment tp1 tp2)
expectArrayWithIndex (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
idx) (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
arr)
case BaseTypeRepr res -> BaseTypeRepr x -> Maybe (res :~: x)
forall {k} (f :: k -> Type) (a :: k) (b :: k).
TestEquality f =>
f a -> f b -> Maybe (a :~: b)
forall (a :: BaseType) (b :: BaseType).
BaseTypeRepr a -> BaseTypeRepr b -> Maybe (a :~: b)
testEquality BaseTypeRepr res
resRepr (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
expr) of
Just res :~: x
Refl ->
let idx' :: Assignment (Expr t) (SingleCtx x)
idx' = Assignment (Expr t) 'EmptyCtx
forall {k} (f :: k -> Type). Assignment f EmptyCtx
Ctx.empty Assignment (Expr t) 'EmptyCtx
-> Expr t x -> Assignment (Expr t) (SingleCtx x)
forall {k} (ctx' :: Ctx k) (f :: k -> Type) (ctx :: Ctx k)
(tp :: k).
(ctx' ~ (ctx ::> tp)) =>
Assignment f ctx -> f tp -> Assignment f ctx'
Ctx.:> Expr t x
idx
in IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t (BaseArrayType (SingleCtx x) x) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t (BaseArrayType (SingleCtx x) x) -> Some (Expr t))
-> IO (Expr t (BaseArrayType (SingleCtx x) x))
-> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> SymArray (ExprBuilder t st fs) (SingleCtx x) x
-> Assignment (SymExpr (ExprBuilder t st fs)) (SingleCtx x)
-> SymExpr (ExprBuilder t st fs) x
-> IO (SymArray (ExprBuilder t st fs) (SingleCtx x) x)
forall sym (idx :: Ctx BaseType) (tp :: BaseType) (b :: BaseType).
IsExprBuilder sym =>
sym
-> SymArray sym (idx ::> tp) b
-> Assignment (SymExpr sym) (idx ::> tp)
-> SymExpr sym b
-> IO (SymArray sym (idx ::> tp) b)
forall (idx :: Ctx BaseType) (tp :: BaseType) (b :: BaseType).
ExprBuilder t st fs
-> SymArray (ExprBuilder t st fs) (idx ::> tp) b
-> Assignment (SymExpr (ExprBuilder t st fs)) (idx ::> tp)
-> SymExpr (ExprBuilder t st fs) b
-> IO (SymArray (ExprBuilder t st fs) (idx ::> tp) b)
W4.arrayUpdate ExprBuilder t st fs
sym SymArray (ExprBuilder t st fs) (SingleCtx x) x
Expr t x
arr Assignment (SymExpr (ExprBuilder t st fs)) (SingleCtx x)
Assignment (Expr t) (SingleCtx x)
idx' SymExpr (ExprBuilder t st fs) x
Expr t x
expr)
Maybe (res :~: x)
Nothing -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ String -> String -> String -> String
forall r. PrintfType r => String -> r
printf String
"Array result type %s does not match %s"
(BaseTypeRepr res -> String
forall a. Show a => a -> String
show BaseTypeRepr res
resRepr)
(BaseTypeRepr x -> String
forall a. Show a => a -> String
show (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
expr))
Text
"updateArray" -> do
(Some Expr t x
arr, Some Expr t x
idx, Some Expr t x
expr) <- [SExpr]
-> Processor
sym (Some (SymExpr sym), Some (SymExpr sym), Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr]
-> Processor
sym (Some (SymExpr sym), Some (SymExpr sym), Some (SymExpr sym))
readThreeArgs [SExpr]
operands
ArraySingleDim BaseTypeRepr res
resRepr <- BaseTypeRepr x
-> BaseTypeRepr x
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ArrayJudgment x x)
forall (m :: Type -> Type) (tp1 :: BaseType) (tp2 :: BaseType).
MonadError String m =>
BaseTypeRepr tp1 -> BaseTypeRepr tp2 -> m (ArrayJudgment tp1 tp2)
expectArrayWithIndex (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
idx) (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
arr)
case BaseTypeRepr res -> BaseTypeRepr x -> Maybe (res :~: x)
forall {k} (f :: k -> Type) (a :: k) (b :: k).
TestEquality f =>
f a -> f b -> Maybe (a :~: b)
forall (a :: BaseType) (b :: BaseType).
BaseTypeRepr a -> BaseTypeRepr b -> Maybe (a :~: b)
testEquality BaseTypeRepr res
resRepr (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
expr) of
Just res :~: x
Refl ->
let idx' :: Assignment (Expr t) (SingleCtx x)
idx' = Assignment (Expr t) 'EmptyCtx
forall {k} (f :: k -> Type). Assignment f EmptyCtx
Ctx.empty Assignment (Expr t) 'EmptyCtx
-> Expr t x -> Assignment (Expr t) (SingleCtx x)
forall {k} (ctx' :: Ctx k) (f :: k -> Type) (ctx :: Ctx k)
(tp :: k).
(ctx' ~ (ctx ::> tp)) =>
Assignment f ctx -> f tp -> Assignment f ctx'
Ctx.:> Expr t x
idx
in IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t (BaseArrayType (SingleCtx x) x) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t (BaseArrayType (SingleCtx x) x) -> Some (Expr t))
-> IO (Expr t (BaseArrayType (SingleCtx x) x))
-> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> SymArray (ExprBuilder t st fs) (SingleCtx x) x
-> Assignment (SymExpr (ExprBuilder t st fs)) (SingleCtx x)
-> SymExpr (ExprBuilder t st fs) x
-> IO (SymArray (ExprBuilder t st fs) (SingleCtx x) x)
forall sym (idx :: Ctx BaseType) (tp :: BaseType) (b :: BaseType).
IsExprBuilder sym =>
sym
-> SymArray sym (idx ::> tp) b
-> Assignment (SymExpr sym) (idx ::> tp)
-> SymExpr sym b
-> IO (SymArray sym (idx ::> tp) b)
forall (idx :: Ctx BaseType) (tp :: BaseType) (b :: BaseType).
ExprBuilder t st fs
-> SymArray (ExprBuilder t st fs) (idx ::> tp) b
-> Assignment (SymExpr (ExprBuilder t st fs)) (idx ::> tp)
-> SymExpr (ExprBuilder t st fs) b
-> IO (SymArray (ExprBuilder t st fs) (idx ::> tp) b)
W4.arrayUpdate ExprBuilder t st fs
sym SymArray (ExprBuilder t st fs) (SingleCtx x) x
Expr t x
arr Assignment (SymExpr (ExprBuilder t st fs)) (SingleCtx x)
Assignment (Expr t) (SingleCtx x)
idx' SymExpr (ExprBuilder t st fs) x
Expr t x
expr)
Maybe (res :~: x)
Nothing -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ String -> String -> String -> String
forall r. PrintfType r => String -> r
printf String
"Array result type %s does not match %s"
(BaseTypeRepr res -> String
forall a. Show a => a -> String
show BaseTypeRepr res
resRepr)
(BaseTypeRepr x -> String
forall a. Show a => a -> String
show (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
expr))
Text
"arrayMap" ->
case [SExpr]
operands of
[SExpr
updateSExprList, SExpr
arrSExpr] -> do
Some Expr t x
arrExpr <- SExpr -> Processor sym (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> Processor sym (Some (SymExpr sym))
readExpr SExpr
arrSExpr
case Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
arrExpr of
BaseArrayRepr Assignment BaseTypeRepr (idx ::> tp)
idxReprs BaseTypeRepr xs
arrTyRepr -> do
ArrayUpdateMap (Expr t) (idx ::> tp) xs
updateMap <- Assignment BaseTypeRepr (idx ::> tp)
-> BaseTypeRepr xs
-> SExpr
-> Processor sym (ArrayUpdateMap (SymExpr sym) (idx ::> tp) xs)
forall sym t (st :: Type -> Type) fs (tp :: BaseType)
(i :: Ctx BaseType) (itp :: BaseType).
(sym ~ ExprBuilder t st fs) =>
Assignment BaseTypeRepr (i ::> itp)
-> BaseTypeRepr tp
-> SExpr
-> Processor sym (ArrayUpdateMap (SymExpr sym) (i ::> itp) tp)
expectArrayUpdateMap Assignment BaseTypeRepr (idx ::> tp)
idxReprs BaseTypeRepr xs
arrTyRepr SExpr
updateSExprList
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t ('BaseArrayType (idx ::> tp) xs) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t ('BaseArrayType (idx ::> tp) xs) -> Some (Expr t))
-> IO (Expr t ('BaseArrayType (idx ::> tp) xs))
-> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> App (Expr t) ('BaseArrayType (idx ::> tp) xs)
-> IO (Expr t ('BaseArrayType (idx ::> tp) xs))
forall t (st :: Type -> Type) fs (tp :: BaseType).
ExprBuilder t st fs -> App (Expr t) tp -> IO (Expr t tp)
W4.sbMakeExpr ExprBuilder t st fs
sym (Assignment BaseTypeRepr (idx ::> tp)
-> BaseTypeRepr xs
-> ArrayUpdateMap (Expr t) (idx ::> tp) xs
-> Expr t ('BaseArrayType (idx ::> tp) xs)
-> App (Expr t) ('BaseArrayType (idx ::> tp) xs)
forall (i :: Ctx BaseType) (itp :: BaseType) (tp1 :: BaseType)
(e :: BaseType -> Type).
Assignment BaseTypeRepr (i ::> itp)
-> BaseTypeRepr tp1
-> ArrayUpdateMap e (i ::> itp) tp1
-> e (BaseArrayType (i ::> itp) tp1)
-> App e (BaseArrayType (i ::> itp) tp1)
W4.ArrayMap Assignment BaseTypeRepr (idx ::> tp)
idxReprs BaseTypeRepr xs
arrTyRepr ArrayUpdateMap (Expr t) (idx ::> tp) xs
updateMap Expr t x
Expr t ('BaseArrayType (idx ::> tp) xs)
arrExpr))
BaseTypeRepr x
repr -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String
"expected an array type for the value in 'arrayMap', but got", BaseTypeRepr x -> String
forall a. Show a => a -> String
show BaseTypeRepr x
repr]
[SExpr]
_ -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String
"expected a list of indices and an array expression, but got", [SExpr] -> String
forall a. Show a => a -> String
show [SExpr]
operands]
Text
"field" -> do
case [SExpr]
operands of
[SExpr
rawStruct, S.WFSAtom (AInt Integer
rawIdx)] -> do
Some Expr t x
struct <- SExpr -> Processor sym (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> Processor sym (Some (SymExpr sym))
readExpr SExpr
rawStruct
case Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
struct of
(BaseStructRepr Assignment BaseTypeRepr ctx
fldTpReprs) ->
case Int -> Size ctx -> Maybe (Some (Index ctx))
forall {k} (ctx :: Ctx k).
Int -> Size ctx -> Maybe (Some (Index ctx))
Ctx.intIndex (Integer -> Int
forall a. Num a => Integer -> a
fromInteger Integer
rawIdx) (Assignment BaseTypeRepr ctx -> Size ctx
forall {k} (f :: k -> Type) (ctx :: Ctx k).
Assignment f ctx -> Size ctx
Ctx.size Assignment BaseTypeRepr ctx
fldTpReprs) of
Just (Some Index ctx x
i) -> IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t x -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t x -> Some (Expr t)) -> IO (Expr t x) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> SymStruct (ExprBuilder t st fs) ctx
-> Index ctx x
-> IO (SymExpr (ExprBuilder t st fs) x)
forall sym (flds :: Ctx BaseType) (tp :: BaseType).
IsExprBuilder sym =>
sym -> SymStruct sym flds -> Index flds tp -> IO (SymExpr sym tp)
forall (flds :: Ctx BaseType) (tp :: BaseType).
ExprBuilder t st fs
-> SymStruct (ExprBuilder t st fs) flds
-> Index flds tp
-> IO (SymExpr (ExprBuilder t st fs) tp)
W4.structField ExprBuilder t st fs
sym SymStruct (ExprBuilder t st fs) ctx
Expr t x
struct Index ctx x
i)
Maybe (Some (Index ctx))
Nothing -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$
[String] -> String
unwords [String
"invalid struct index, got", Assignment BaseTypeRepr ctx -> String
forall a. Show a => a -> String
show Assignment BaseTypeRepr ctx
fldTpReprs, String
"and", Integer -> String
forall a. Show a => a -> String
show Integer
rawIdx]
BaseTypeRepr x
srepr -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String
"expected a struct, got", BaseTypeRepr x -> String
forall a. Show a => a -> String
show BaseTypeRepr x
srepr]
[SExpr]
_ -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String
"expected an arg and an Int, got", [SExpr] -> String
forall a. Show a => a -> String
show [SExpr]
operands]
Text
"struct" -> do
case [SExpr]
operands of
[S.WFSList [SExpr]
rawFldExprs] -> do
Some Assignment (Expr t) x
flds <- [SExpr] -> Processor sym (Some (Assignment (SymExpr sym)))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym (Some (Assignment (SymExpr sym)))
readExprsAsAssignment [SExpr]
rawFldExprs
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t (BaseStructType x) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t (BaseStructType x) -> Some (Expr t))
-> IO (Expr t (BaseStructType x)) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> Assignment (SymExpr (ExprBuilder t st fs)) x
-> IO (SymStruct (ExprBuilder t st fs) x)
forall sym (flds :: Ctx BaseType).
IsExprBuilder sym =>
sym -> Assignment (SymExpr sym) flds -> IO (SymStruct sym flds)
forall (flds :: Ctx BaseType).
ExprBuilder t st fs
-> Assignment (SymExpr (ExprBuilder t st fs)) flds
-> IO (SymStruct (ExprBuilder t st fs) flds)
W4.mkStruct ExprBuilder t st fs
sym Assignment (SymExpr (ExprBuilder t st fs)) x
Assignment (Expr t) x
flds)
[SExpr]
_ -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String
"struct expects a single operand, got", [SExpr] -> String
forall a. Show a => a -> String
show [SExpr]
operands]
Text
"sbvToInteger" -> do
(Some Expr t x
arg) <- [SExpr] -> Processor sym (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym (Some (SymExpr sym))
readOneArg [SExpr]
operands
BVProof NatRepr n
_ <- Expr t x
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall (ex :: BaseType -> Type) (m :: Type -> Type)
(tp :: BaseType).
(IsExpr ex, MonadError String m) =>
ex tp -> m (BVProof tp)
getBVProof Expr t x
arg
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ Expr t 'BaseIntegerType -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t 'BaseIntegerType -> Some (Expr t))
-> IO (Expr t 'BaseIntegerType) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> SymBV (ExprBuilder t st fs) n
-> IO (SymInteger (ExprBuilder t st fs))
forall (w :: Nat).
(1 <= w) =>
ExprBuilder t st fs
-> SymBV (ExprBuilder t st fs) w
-> IO (SymInteger (ExprBuilder t st fs))
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> IO (SymInteger sym)
W4.sbvToInteger ExprBuilder t st fs
sym SymBV (ExprBuilder t st fs) n
Expr t x
arg
Text
"bvToInteger" -> do
(Some Expr t x
arg) <- [SExpr] -> Processor sym (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym (Some (SymExpr sym))
readOneArg [SExpr]
operands
BVProof NatRepr n
_ <- Expr t x
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall (ex :: BaseType -> Type) (m :: Type -> Type)
(tp :: BaseType).
(IsExpr ex, MonadError String m) =>
ex tp -> m (BVProof tp)
getBVProof Expr t x
arg
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ Expr t 'BaseIntegerType -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t 'BaseIntegerType -> Some (Expr t))
-> IO (Expr t 'BaseIntegerType) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> SymBV (ExprBuilder t st fs) n
-> IO (SymInteger (ExprBuilder t st fs))
forall (w :: Nat).
(1 <= w) =>
ExprBuilder t st fs
-> SymBV (ExprBuilder t st fs) w
-> IO (SymInteger (ExprBuilder t st fs))
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymBV sym w -> IO (SymInteger sym)
W4.bvToInteger ExprBuilder t st fs
sym SymBV (ExprBuilder t st fs) n
Expr t x
arg
Text
"integerToBV" -> do
case [SExpr]
operands of
[S.WFSAtom (ANat Nat
width), SExpr
rawValExpr] -> do
Some Expr t x
x <- SExpr -> Processor sym (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> Processor sym (Some (SymExpr sym))
readExpr SExpr
rawValExpr
case (Nat -> Some NatRepr
mkNatRepr Nat
width, Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
x) of
(Some NatRepr x
w, BaseTypeRepr x
BaseIntegerRepr)
| Just LeqProof 1 x
LeqProof <- NatRepr x -> Maybe (LeqProof 1 x)
forall (n :: Nat). NatRepr n -> Maybe (LeqProof 1 n)
isPosNat NatRepr x
w -> do
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t (BaseBVType x) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t (BaseBVType x) -> Some (Expr t))
-> IO (Expr t (BaseBVType x)) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> SymInteger (ExprBuilder t st fs)
-> NatRepr x
-> IO (SymBV (ExprBuilder t st fs) x)
forall (w :: Nat).
(1 <= w) =>
ExprBuilder t st fs
-> SymInteger (ExprBuilder t st fs)
-> NatRepr w
-> IO (SymBV (ExprBuilder t st fs) w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> SymInteger sym -> NatRepr w -> IO (SymBV sym w)
W4.integerToBV ExprBuilder t st fs
sym SymInteger (ExprBuilder t st fs)
Expr t x
x NatRepr x
w)
(Some NatRepr, BaseTypeRepr x)
srepr -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String
"expected a non-zero natural and an integer, got", (Some NatRepr, BaseTypeRepr x) -> String
forall a. Show a => a -> String
show (Some NatRepr, BaseTypeRepr x)
srepr]
[SExpr]
_ -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String
"integerToBV expects two operands, the first of which is a nat, got", [SExpr] -> String
forall a. Show a => a -> String
show [SExpr]
operands]
Text
_ -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ String -> Text -> String
forall r. PrintfType r => String -> r
printf String
"couldn't parse application of %s" (Seq String -> SExpr -> Text
printSExpr Seq String
forall a. Monoid a => a
mempty SExpr
opRaw)
readApp (S.WFSList [S.WFSAtom (AId Text
"_"), S.WFSAtom (AId Text
"extract"), S.WFSAtom (AInt Integer
iInt), S.WFSAtom (AInt Integer
jInt)])
[SExpr]
args = String
-> Processor sym (Some (SymExpr sym))
-> Processor sym (Some (SymExpr sym))
forall e (m :: Type -> Type) a.
(Monoid e, MonadError e m) =>
e -> m a -> m a
prefixError String
"in reading extract expression: " (Processor sym (Some (SymExpr sym))
-> Processor sym (Some (SymExpr sym)))
-> Processor sym (Some (SymExpr sym))
-> Processor sym (Some (SymExpr sym))
forall a b. (a -> b) -> a -> b
$ do
ExprBuilder t st fs
sym <- (ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ExprBuilder t st fs)
forall a.
(ProcessorEnv (ExprBuilder t st fs) -> a)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.reader ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs
forall sym. ProcessorEnv sym -> sym
procSym
(Some Expr t x
arg) <- [SExpr] -> Processor sym (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym (Some (SymExpr sym))
readOneArg [SExpr]
args
let nInt :: Integer
nInt = Integer
iInt Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
- Integer
jInt Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
1
idxInt :: Integer
idxInt = Integer
jInt
Some NatRepr x
nNat <- String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr)
forall e (m :: Type -> Type) a.
(Monoid e, MonadError e m) =>
e -> m a -> m a
prefixError String
"in calculating extract length: " (ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr)
forall a b. (a -> b) -> a -> b
$ Integer
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr)
forall (m :: Type -> Type).
MonadError String m =>
Integer -> m (Some NatRepr)
intToNatM Integer
nInt
Some NatRepr x
idxNat <- String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr)
forall e (m :: Type -> Type) a.
(Monoid e, MonadError e m) =>
e -> m a -> m a
prefixError String
"in extract lower bound: " (ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr)
forall a b. (a -> b) -> a -> b
$ Integer
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr)
forall (m :: Type -> Type).
MonadError String m =>
Integer -> m (Some NatRepr)
intToNatM Integer
idxInt
LeqProof 1 x
LeqProof <- String
-> Maybe (LeqProof 1 x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (LeqProof 1 x)
forall e (m :: Type -> Type) a.
MonadError e m =>
e -> Maybe a -> m a
fromMaybeError String
"extract length must be positive" (Maybe (LeqProof 1 x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (LeqProof 1 x))
-> Maybe (LeqProof 1 x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (LeqProof 1 x)
forall a b. (a -> b) -> a -> b
$ NatRepr x -> Maybe (LeqProof 1 x)
forall (n :: Nat). NatRepr n -> Maybe (LeqProof 1 n)
isPosNat NatRepr x
nNat
BVProof NatRepr n
lenNat <- Expr t x
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall (ex :: BaseType -> Type) (m :: Type -> Type)
(tp :: BaseType).
(IsExpr ex, MonadError String m) =>
ex tp -> m (BVProof tp)
getBVProof Expr t x
arg
LeqProof (x + x) n
LeqProof <- String
-> Maybe (LeqProof (x + x) n)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (LeqProof (x + x) n)
forall e (m :: Type -> Type) a.
MonadError e m =>
e -> Maybe a -> m a
fromMaybeError String
"invalid extract for given bitvector" (Maybe (LeqProof (x + x) n)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (LeqProof (x + x) n))
-> Maybe (LeqProof (x + x) n)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (LeqProof (x + x) n)
forall a b. (a -> b) -> a -> b
$
NatRepr (x + x) -> NatRepr n -> Maybe (LeqProof (x + x) n)
forall (m :: Nat) (n :: Nat).
NatRepr m -> NatRepr n -> Maybe (LeqProof m n)
testLeq (NatRepr x -> NatRepr x -> NatRepr (x + x)
forall (m :: Nat) (n :: Nat).
NatRepr m -> NatRepr n -> NatRepr (m + n)
addNat NatRepr x
idxNat NatRepr x
nNat) NatRepr n
lenNat
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t (BaseBVType x) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t (BaseBVType x) -> Some (Expr t))
-> IO (Expr t (BaseBVType x)) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> NatRepr x
-> NatRepr x
-> SymBV (ExprBuilder t st fs) n
-> IO (SymBV (ExprBuilder t st fs) x)
forall (idx :: Nat) (n :: Nat) (w :: Nat).
(1 <= n, (idx + n) <= w) =>
ExprBuilder t st fs
-> NatRepr idx
-> NatRepr n
-> SymBV (ExprBuilder t st fs) w
-> IO (SymBV (ExprBuilder t st fs) n)
forall sym (idx :: Nat) (n :: Nat) (w :: Nat).
(IsExprBuilder sym, 1 <= n, (idx + n) <= w) =>
sym -> NatRepr idx -> NatRepr n -> SymBV sym w -> IO (SymBV sym n)
W4.bvSelect ExprBuilder t st fs
sym NatRepr x
idxNat NatRepr x
nNat SymBV (ExprBuilder t st fs) n
Expr t x
arg)
readApp (S.WFSList [S.WFSAtom (AId Text
"_"), S.WFSAtom (AId Text
extend), S.WFSAtom (AInt Integer
iInt)])
[SExpr]
args
| Text
extend Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"zero_extend" Bool -> Bool -> Bool
||
Text
extend Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"sign_extend" = String
-> Processor sym (Some (SymExpr sym))
-> Processor sym (Some (SymExpr sym))
forall e (m :: Type -> Type) a.
(Monoid e, MonadError e m) =>
e -> m a -> m a
prefixError (String -> Text -> String
forall r. PrintfType r => String -> r
printf String
"in reading %s expression: " Text
extend) (Processor sym (Some (SymExpr sym))
-> Processor sym (Some (SymExpr sym)))
-> Processor sym (Some (SymExpr sym))
-> Processor sym (Some (SymExpr sym))
forall a b. (a -> b) -> a -> b
$ do
ExprBuilder t st fs
sym <- (ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ExprBuilder t st fs)
forall a.
(ProcessorEnv (ExprBuilder t st fs) -> a)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.reader ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs
forall sym. ProcessorEnv sym -> sym
procSym
Some Expr t x
arg <- [SExpr] -> Processor sym (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym (Some (SymExpr sym))
readOneArg [SExpr]
args
Some NatRepr x
iNat <- Integer
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr)
forall (m :: Type -> Type).
MonadError String m =>
Integer -> m (Some NatRepr)
intToNatM Integer
iInt
LeqProof 1 x
iPositive <- String
-> Maybe (LeqProof 1 x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (LeqProof 1 x)
forall e (m :: Type -> Type) a.
MonadError e m =>
e -> Maybe a -> m a
fromMaybeError String
"must extend by a positive length" (Maybe (LeqProof 1 x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (LeqProof 1 x))
-> Maybe (LeqProof 1 x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (LeqProof 1 x)
forall a b. (a -> b) -> a -> b
$ NatRepr x -> Maybe (LeqProof 1 x)
forall (n :: Nat). NatRepr n -> Maybe (LeqProof 1 n)
isPosNat NatRepr x
iNat
BVProof NatRepr n
lenNat <- Expr t x
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (BVProof x)
forall (ex :: BaseType -> Type) (m :: Type -> Type)
(tp :: BaseType).
(IsExpr ex, MonadError String m) =>
ex tp -> m (BVProof tp)
getBVProof Expr t x
arg
let newLen :: NatRepr (n + x)
newLen = NatRepr n -> NatRepr x -> NatRepr (n + x)
forall (m :: Nat) (n :: Nat).
NatRepr m -> NatRepr n -> NatRepr (m + n)
addNat NatRepr n
lenNat NatRepr x
iNat
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ LeqProof (n + 1) (n + x)
-> (((n + 1) <= (n + x)) => IO (Some (Expr t)))
-> IO (Some (Expr t))
forall (m :: Nat) (n :: Nat) a.
LeqProof m n -> ((m <= n) => a) -> a
withLeqProof (LeqProof n n -> LeqProof 1 x -> LeqProof (n + 1) (n + x)
forall (x_l :: Nat) (x_h :: Nat) (y_l :: Nat) (y_h :: Nat).
LeqProof x_l x_h
-> LeqProof y_l y_h -> LeqProof (x_l + y_l) (x_h + y_h)
leqAdd2 (NatRepr n -> LeqProof n n
forall (f :: Nat -> Type) (n :: Nat). f n -> LeqProof n n
leqRefl NatRepr n
lenNat) LeqProof 1 x
iPositive) ((((n + 1) <= (n + x)) => IO (Some (Expr t)))
-> IO (Some (Expr t)))
-> (((n + 1) <= (n + x)) => IO (Some (Expr t)))
-> IO (Some (Expr t))
forall a b. (a -> b) -> a -> b
$
let op :: ExprBuilder t st fs
-> NatRepr (n + x)
-> SymBV (ExprBuilder t st fs) n
-> IO (SymBV (ExprBuilder t st fs) (n + x))
op = if Text
extend Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"zero_extend" then ExprBuilder t st fs
-> NatRepr (n + x)
-> SymBV (ExprBuilder t st fs) n
-> IO (SymBV (ExprBuilder t st fs) (n + x))
forall (u :: Nat) (r :: Nat).
(1 <= u, (u + 1) <= r) =>
ExprBuilder t st fs
-> NatRepr r
-> SymBV (ExprBuilder t st fs) u
-> IO (SymBV (ExprBuilder t st fs) r)
forall sym (u :: Nat) (r :: Nat).
(IsExprBuilder sym, 1 <= u, (u + 1) <= r) =>
sym -> NatRepr r -> SymBV sym u -> IO (SymBV sym r)
W4.bvZext else ExprBuilder t st fs
-> NatRepr (n + x)
-> SymBV (ExprBuilder t st fs) n
-> IO (SymBV (ExprBuilder t st fs) (n + x))
forall (u :: Nat) (r :: Nat).
(1 <= u, (u + 1) <= r) =>
ExprBuilder t st fs
-> NatRepr r
-> SymBV (ExprBuilder t st fs) u
-> IO (SymBV (ExprBuilder t st fs) r)
forall sym (u :: Nat) (r :: Nat).
(IsExprBuilder sym, 1 <= u, (u + 1) <= r) =>
sym -> NatRepr r -> SymBV sym u -> IO (SymBV sym r)
W4.bvSext
in Expr t (BaseBVType (n + x)) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t (BaseBVType (n + x)) -> Some (Expr t))
-> IO (Expr t (BaseBVType (n + x))) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> NatRepr (n + x)
-> SymBV (ExprBuilder t st fs) n
-> IO (SymBV (ExprBuilder t st fs) (n + x))
op ExprBuilder t st fs
sym NatRepr (n + x)
newLen SymBV (ExprBuilder t st fs) n
Expr t x
arg
readApp (S.WFSList [S.WFSAtom (AId Text
"_"), S.WFSAtom (AId Text
"bvfill"), S.WFSAtom (AInt Integer
width)]) [SExpr]
args =
String
-> Processor sym (Some (SymExpr sym))
-> Processor sym (Some (SymExpr sym))
forall e (m :: Type -> Type) a.
(Monoid e, MonadError e m) =>
e -> m a -> m a
prefixError String
"in reading bvfill expression" (Processor sym (Some (SymExpr sym))
-> Processor sym (Some (SymExpr sym)))
-> Processor sym (Some (SymExpr sym))
-> Processor sym (Some (SymExpr sym))
forall a b. (a -> b) -> a -> b
$ do
ExprBuilder t st fs
sym <- (ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ExprBuilder t st fs)
forall a.
(ProcessorEnv (ExprBuilder t st fs) -> a)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.reader ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs
forall sym. ProcessorEnv sym -> sym
procSym
Some Expr t x
arg <- [SExpr] -> Processor sym (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym (Some (SymExpr sym))
readOneArg [SExpr]
args
case Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
arg of
BaseTypeRepr x
BaseBoolRepr -> do
Some NatRepr x
widthRep <- Integer
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some NatRepr)
forall (m :: Type -> Type).
MonadError String m =>
Integer -> m (Some NatRepr)
intToNatM Integer
width
LeqProof 1 x
LeqProof <- String
-> Maybe (LeqProof 1 x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (LeqProof 1 x)
forall e (m :: Type -> Type) a.
MonadError e m =>
e -> Maybe a -> m a
fromMaybeError String
"must extend by a positive length" (Maybe (LeqProof 1 x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (LeqProof 1 x))
-> Maybe (LeqProof 1 x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (LeqProof 1 x)
forall a b. (a -> b) -> a -> b
$ NatRepr x -> Maybe (LeqProof 1 x)
forall (n :: Nat). NatRepr n -> Maybe (LeqProof 1 n)
isPosNat NatRepr x
widthRep
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (Expr t (BaseBVType x) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t (BaseBVType x) -> Some (Expr t))
-> IO (Expr t (BaseBVType x)) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> NatRepr x
-> Pred (ExprBuilder t st fs)
-> IO (SymBV (ExprBuilder t st fs) x)
forall (w :: Nat).
(1 <= w) =>
ExprBuilder t st fs
-> NatRepr w
-> Pred (ExprBuilder t st fs)
-> IO (SymBV (ExprBuilder t st fs) w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> NatRepr w -> Pred sym -> IO (SymBV sym w)
W4.bvFill ExprBuilder t st fs
sym NatRepr x
widthRep Pred (ExprBuilder t st fs)
Expr t x
arg)
BaseTypeRepr x
tyrep -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
"Invalid argument type to bvFill: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ BaseTypeRepr x -> String
forall a. Show a => a -> String
show BaseTypeRepr x
tyrep)
readApp SExpr
rator [SExpr]
rands = String -> Processor sym (Some (SymExpr sym))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String -> Processor sym (Some (SymExpr sym)))
-> String -> Processor sym (Some (SymExpr sym))
forall a b. (a -> b) -> a -> b
$ (String
"readApp could not parse the following: "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Text -> String
T.unpack (Seq String -> SExpr -> Text
printSExpr Seq String
forall a. Monoid a => a
mempty (SExpr -> Text) -> SExpr -> Text
forall a b. (a -> b) -> a -> b
$ [SExpr] -> SExpr
forall t. [WellFormedSExpr t] -> WellFormedSExpr t
S.WFSList (SExpr
ratorSExpr -> [SExpr] -> [SExpr]
forall a. a -> [a] -> [a]
:[SExpr]
rands))))
intToNatM :: (E.MonadError String m) => Integer -> m (Some NatRepr)
intToNatM :: forall (m :: Type -> Type).
MonadError String m =>
Integer -> m (Some NatRepr)
intToNatM = String -> Maybe (Some NatRepr) -> m (Some NatRepr)
forall e (m :: Type -> Type) a.
MonadError e m =>
e -> Maybe a -> m a
fromMaybeError String
"integer must be non-negative to be a nat" (Maybe (Some NatRepr) -> m (Some NatRepr))
-> (Integer -> Maybe (Some NatRepr)) -> Integer -> m (Some NatRepr)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Maybe (Some NatRepr)
forall a. Integral a => a -> Maybe (Some NatRepr)
someNat
expectArrayUpdateMap
:: forall sym t st fs tp i itp
. (sym ~ W4.ExprBuilder t st fs)
=> Ctx.Assignment BaseTypeRepr (i Ctx.::> itp)
-> BaseTypeRepr tp
-> SExpr
-> Processor sym (WAU.ArrayUpdateMap (W4.SymExpr sym) (i Ctx.::> itp) tp)
expectArrayUpdateMap :: forall sym t (st :: Type -> Type) fs (tp :: BaseType)
(i :: Ctx BaseType) (itp :: BaseType).
(sym ~ ExprBuilder t st fs) =>
Assignment BaseTypeRepr (i ::> itp)
-> BaseTypeRepr tp
-> SExpr
-> Processor sym (ArrayUpdateMap (SymExpr sym) (i ::> itp) tp)
expectArrayUpdateMap Assignment BaseTypeRepr (i ::> itp)
idxReprs BaseTypeRepr tp
arrTyRepr SExpr
updateSExprList =
case SExpr
updateSExprList of
S.L [SExpr]
items -> (SExpr
-> ArrayUpdateMap (Expr t) (i ::> itp) tp
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(ArrayUpdateMap (Expr t) (i ::> itp) tp))
-> ArrayUpdateMap (Expr t) (i ::> itp) tp
-> [SExpr]
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(ArrayUpdateMap (Expr t) (i ::> itp) tp)
forall (t :: Type -> Type) (m :: Type -> Type) a b.
(Foldable t, Monad m) =>
(a -> b -> m b) -> b -> t a -> m b
F.foldrM SExpr
-> ArrayUpdateMap (Expr t) (i ::> itp) tp
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(ArrayUpdateMap (Expr t) (i ::> itp) tp)
expectArrayUpdateEntry ArrayUpdateMap (Expr t) (i ::> itp) tp
forall (e :: BaseType -> Type) (ctx :: Ctx BaseType)
(tp :: BaseType).
ArrayUpdateMap e ctx tp
WAU.empty [SExpr]
items
SExpr
_ -> String
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(ArrayUpdateMap (Expr t) (i ::> itp) tp)
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError String
"Expected a list of array element updates in ArrayMap"
where
expectArrayUpdateEntry :: SExpr
-> ArrayUpdateMap (Expr t) (i ::> itp) tp
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(ArrayUpdateMap (Expr t) (i ::> itp) tp)
expectArrayUpdateEntry SExpr
pair ArrayUpdateMap (Expr t) (i ::> itp) tp
updateMap =
case SExpr
pair of
S.L [S.L [SExpr]
idxListExprs, SExpr
elt] -> do
Assignment IndexLit (i ::> itp)
idxs <- (forall (tp :: BaseType).
Index (i ::> itp) tp
-> BaseTypeRepr tp
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (IndexLit tp))
-> Assignment BaseTypeRepr (i ::> itp)
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Assignment IndexLit (i ::> itp))
forall {k} (m :: Type -> Type) (ctx :: Ctx k) (f :: k -> Type)
(g :: k -> Type).
Applicative m =>
(forall (tp :: k). Index ctx tp -> f tp -> m (g tp))
-> Assignment f ctx -> m (Assignment g ctx)
Ctx.traverseWithIndex ([SExpr]
-> Index (i ::> itp) tp
-> BaseTypeRepr tp
-> Processor (ExprBuilder t st fs) (IndexLit tp)
forall (ctx :: Ctx BaseType) (tp :: BaseType) sym.
[SExpr]
-> Index ctx tp -> BaseTypeRepr tp -> Processor sym (IndexLit tp)
parseIndexLit [SExpr]
idxListExprs) Assignment BaseTypeRepr (i ::> itp)
idxReprs
Some Expr t x
x <- SExpr -> Processor sym (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> Processor sym (Some (SymExpr sym))
readExpr SExpr
elt
case BaseTypeRepr tp -> BaseTypeRepr x -> Maybe (tp :~: x)
forall {k} (f :: k -> Type) (a :: k) (b :: k).
TestEquality f =>
f a -> f b -> Maybe (a :~: b)
forall (a :: BaseType) (b :: BaseType).
BaseTypeRepr a -> BaseTypeRepr b -> Maybe (a :~: b)
testEquality BaseTypeRepr tp
arrTyRepr (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
x) of
Just tp :~: x
Refl -> ArrayUpdateMap (Expr t) (i ::> itp) tp
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(ArrayUpdateMap (Expr t) (i ::> itp) tp)
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (BaseTypeRepr tp
-> Assignment IndexLit (i ::> itp)
-> Expr t tp
-> ArrayUpdateMap (Expr t) (i ::> itp) tp
-> ArrayUpdateMap (Expr t) (i ::> itp) tp
forall (e :: BaseType -> Type) (tp :: BaseType)
(ctx :: Ctx BaseType).
(HashableF e, HasAbsValue e) =>
BaseTypeRepr tp
-> Assignment IndexLit ctx
-> e tp
-> ArrayUpdateMap e ctx tp
-> ArrayUpdateMap e ctx tp
WAU.insert BaseTypeRepr tp
arrTyRepr Assignment IndexLit (i ::> itp)
idxs Expr t tp
Expr t x
x ArrayUpdateMap (Expr t) (i ::> itp) tp
updateMap)
Maybe (tp :~: x)
Nothing -> String
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(ArrayUpdateMap (Expr t) (i ::> itp) tp)
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError ([String] -> String
forall (t :: Type -> Type) a. Foldable t => t [a] -> [a]
concat [ String
"Invalid element type in ArrayMap update: expected "
, BaseTypeRepr tp -> String
forall a. Show a => a -> String
show BaseTypeRepr tp
arrTyRepr
, String
" but got "
, BaseTypeRepr x -> String
forall a. Show a => a -> String
show (Expr t x -> BaseTypeRepr x
forall (tp :: BaseType). Expr t tp -> BaseTypeRepr tp
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Expr t x
x)])
SExpr
_ -> String
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(ArrayUpdateMap (Expr t) (i ::> itp) tp)
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError String
"Unexpected ArrayMap update item structure"
(!?) :: [a] -> Int -> Maybe a
[a]
lst !? :: forall a. [a] -> Int -> Maybe a
!? Int
idx
| Int
idx Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0 = Maybe a
forall a. Maybe a
Nothing
| Bool
otherwise = Int -> [a] -> Maybe a
forall {t} {a}. (Eq t, Num t) => t -> [a] -> Maybe a
go Int
idx [a]
lst
where
go :: t -> [a] -> Maybe a
go t
0 (a
x:[a]
_xs) = a -> Maybe a
forall a. a -> Maybe a
Just a
x
go t
i (a
_:[a]
xs) = t -> [a] -> Maybe a
go (t
i t -> t -> t
forall a. Num a => a -> a -> a
- t
1) [a]
xs
go t
_ [] = Maybe a
forall a. Maybe a
Nothing
parseIndexLit :: [SExpr]
-> Ctx.Index ctx tp
-> BaseTypeRepr tp
-> Processor sym (WIL.IndexLit tp)
parseIndexLit :: forall (ctx :: Ctx BaseType) (tp :: BaseType) sym.
[SExpr]
-> Index ctx tp -> BaseTypeRepr tp -> Processor sym (IndexLit tp)
parseIndexLit [SExpr]
exprs Index ctx tp
idx BaseTypeRepr tp
repr
| Just (S.A Atom
atom) <- [SExpr]
exprs [SExpr] -> Int -> Maybe SExpr
forall a. [a] -> Int -> Maybe a
!? Index ctx tp -> Int
forall k (ctx :: Ctx k) (tp :: k). Index ctx tp -> Int
Ctx.indexVal Index ctx tp
idx =
case (BaseTypeRepr tp
repr, Atom
atom) of
(BaseBVRepr NatRepr w
w, ABV Int
w' Integer
val)
| NatRepr w -> Integer
forall (n :: Nat). NatRepr n -> Integer
PN.intValue NatRepr w
w Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Int -> Integer
forall a. Integral a => a -> Integer
toInteger Int
w' ->
IndexLit tp -> Processor sym (IndexLit tp)
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (NatRepr w -> BV w -> IndexLit ('BaseBVType w)
forall (w :: Nat).
(1 <= w) =>
NatRepr w -> BV w -> IndexLit ('BaseBVType w)
WIL.BVIndexLit NatRepr w
w (NatRepr w -> Integer -> BV w
forall (w :: Nat). NatRepr w -> Integer -> BV w
BV.mkBV NatRepr w
w Integer
val))
| Bool
otherwise -> String -> Processor sym (IndexLit tp)
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
"Array update index bitvector size mismatch: expected " String -> String -> String
forall a. [a] -> [a] -> [a]
++ NatRepr w -> String
forall a. Show a => a -> String
show NatRepr w
w String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" but got " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
w')
(BaseTypeRepr tp
BaseIntegerRepr, AInt Integer
i) -> IndexLit tp -> Processor sym (IndexLit tp)
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Integer -> IndexLit 'BaseIntegerType
WIL.IntIndexLit Integer
i)
(BaseTypeRepr tp, Atom)
_ -> String -> Processor sym (IndexLit tp)
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
"Unexpected array update index type: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ BaseTypeRepr tp -> String
forall a. Show a => a -> String
show BaseTypeRepr tp
repr)
| Bool
otherwise = String -> Processor sym (IndexLit tp)
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
"Invalid or missing array update index at " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Index ctx tp -> String
forall a. Show a => a -> String
show Index ctx tp
idx)
data ArrayJudgment :: BaseType -> BaseType -> Type where
ArraySingleDim :: forall idx res.
BaseTypeRepr res
-> ArrayJudgment idx (BaseArrayType (Ctx.SingleCtx idx) res)
expectArrayWithIndex :: (E.MonadError String m) => BaseTypeRepr tp1 -> BaseTypeRepr tp2 -> m (ArrayJudgment tp1 tp2)
expectArrayWithIndex :: forall (m :: Type -> Type) (tp1 :: BaseType) (tp2 :: BaseType).
MonadError String m =>
BaseTypeRepr tp1 -> BaseTypeRepr tp2 -> m (ArrayJudgment tp1 tp2)
expectArrayWithIndex BaseTypeRepr tp1
dimRepr (BaseArrayRepr Assignment BaseTypeRepr (idx ::> tp)
idxTpReprs BaseTypeRepr xs
resRepr) =
case Assignment BaseTypeRepr (idx ::> tp)
-> AssignView BaseTypeRepr (idx ::> tp)
forall {k} (f :: k -> Type) (ctx :: Ctx k).
Assignment f ctx -> AssignView f ctx
Ctx.viewAssign Assignment BaseTypeRepr (idx ::> tp)
idxTpReprs of
Ctx.AssignExtend Assignment BaseTypeRepr ctx1
rest BaseTypeRepr tp
idxTpRepr ->
case Assignment BaseTypeRepr ctx1 -> AssignView BaseTypeRepr ctx1
forall {k} (f :: k -> Type) (ctx :: Ctx k).
Assignment f ctx -> AssignView f ctx
Ctx.viewAssign Assignment BaseTypeRepr ctx1
rest of
AssignView BaseTypeRepr ctx1
Ctx.AssignEmpty ->
case BaseTypeRepr tp -> BaseTypeRepr tp1 -> Maybe (tp :~: tp1)
forall {k} (f :: k -> Type) (a :: k) (b :: k).
TestEquality f =>
f a -> f b -> Maybe (a :~: b)
forall (a :: BaseType) (b :: BaseType).
BaseTypeRepr a -> BaseTypeRepr b -> Maybe (a :~: b)
testEquality BaseTypeRepr tp
idxTpRepr BaseTypeRepr tp1
dimRepr of
Just tp :~: tp1
Refl -> ArrayJudgment tp1 tp2 -> m (ArrayJudgment tp1 tp2)
forall a. a -> m a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (ArrayJudgment tp1 tp2 -> m (ArrayJudgment tp1 tp2))
-> ArrayJudgment tp1 tp2 -> m (ArrayJudgment tp1 tp2)
forall a b. (a -> b) -> a -> b
$ BaseTypeRepr xs
-> ArrayJudgment tp1 (BaseArrayType (SingleCtx tp1) xs)
forall (idx :: BaseType) (res :: BaseType).
BaseTypeRepr res
-> ArrayJudgment idx (BaseArrayType (SingleCtx idx) res)
ArraySingleDim BaseTypeRepr xs
resRepr
Maybe (tp :~: tp1)
Nothing -> String -> m (ArrayJudgment tp1 tp2)
forall a. String -> m a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String -> m (ArrayJudgment tp1 tp2))
-> String -> m (ArrayJudgment tp1 tp2)
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String
"Array index type", BaseTypeRepr tp -> String
forall a. Show a => a -> String
show BaseTypeRepr tp
idxTpRepr,
String
"does not match", BaseTypeRepr tp1 -> String
forall a. Show a => a -> String
show BaseTypeRepr tp1
dimRepr]
AssignView BaseTypeRepr ctx1
_ -> String -> m (ArrayJudgment tp1 tp2)
forall a. String -> m a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError String
"multidimensional arrays are not supported"
expectArrayWithIndex BaseTypeRepr tp1
_ BaseTypeRepr tp2
repr = String -> m (ArrayJudgment tp1 tp2)
forall a. String -> m a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String -> m (ArrayJudgment tp1 tp2))
-> String -> m (ArrayJudgment tp1 tp2)
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [String
"expected an array, got", BaseTypeRepr tp2 -> String
forall a. Show a => a -> String
show BaseTypeRepr tp2
repr]
exprAssignment ::
forall sym ctx ex . (W4.IsSymExprBuilder sym, ShowF (W4.SymExpr sym), ShowF ex, W4.IsExpr ex)
=> Ctx.Assignment BaseTypeRepr ctx
-> [Some ex]
-> Processor sym (Ctx.Assignment ex ctx)
exprAssignment :: forall sym (ctx :: Ctx BaseType) (ex :: BaseType -> Type).
(IsSymExprBuilder sym, ShowF (SymExpr sym), ShowF ex, IsExpr ex) =>
Assignment BaseTypeRepr ctx
-> [Some ex] -> Processor sym (Assignment ex ctx)
exprAssignment Assignment BaseTypeRepr ctx
tpAssns [Some ex]
exs = do
Some Assignment ex x
exsAsn <- Some (Assignment ex)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some (Assignment ex))
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some (Assignment ex)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some (Assignment ex)))
-> Some (Assignment ex)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some (Assignment ex))
forall a b. (a -> b) -> a -> b
$ [Some ex] -> Some (Assignment ex)
forall {k} (f :: k -> Type). [Some f] -> Some (Assignment f)
Ctx.fromList [Some ex]
exs
Assignment BaseTypeRepr x
exsRepr <- Assignment BaseTypeRepr x
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Assignment BaseTypeRepr x)
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Assignment BaseTypeRepr x
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Assignment BaseTypeRepr x))
-> Assignment BaseTypeRepr x
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Assignment BaseTypeRepr x)
forall a b. (a -> b) -> a -> b
$ (forall (x :: BaseType). ex x -> BaseTypeRepr x)
-> forall (x :: Ctx BaseType).
Assignment ex x -> Assignment BaseTypeRepr x
forall k l (t :: (k -> Type) -> l -> Type) (f :: k -> Type)
(g :: k -> Type).
FunctorFC t =>
(forall (x :: k). f x -> g x) -> forall (x :: l). t f x -> t g x
forall (f :: BaseType -> Type) (g :: BaseType -> Type).
(forall (x :: BaseType). f x -> g x)
-> forall (x :: Ctx BaseType). Assignment f x -> Assignment g x
FC.fmapFC ex x -> BaseTypeRepr x
forall (x :: BaseType). ex x -> BaseTypeRepr x
forall (e :: BaseType -> Type) (tp :: BaseType).
IsExpr e =>
e tp -> BaseTypeRepr tp
W4.exprType Assignment ex x
exsAsn
case Assignment BaseTypeRepr x
-> Assignment BaseTypeRepr ctx -> Maybe (x :~: ctx)
forall {k} (f :: k -> Type) (a :: k) (b :: k).
TestEquality f =>
f a -> f b -> Maybe (a :~: b)
forall (a :: Ctx BaseType) (b :: Ctx BaseType).
Assignment BaseTypeRepr a
-> Assignment BaseTypeRepr b -> Maybe (a :~: b)
testEquality Assignment BaseTypeRepr x
exsRepr Assignment BaseTypeRepr ctx
tpAssns of
Just x :~: ctx
Refl -> Assignment ex ctx -> Processor sym (Assignment ex ctx)
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return Assignment ex ctx
Assignment ex x
exsAsn
Maybe (x :~: ctx)
Nothing -> String -> Processor sym (Assignment ex ctx)
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String -> Processor sym (Assignment ex ctx))
-> String -> Processor sym (Assignment ex ctx)
forall a b. (a -> b) -> a -> b
$
String
"Unexpected expression types for " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Assignment ex x -> String
forall a. Show a => a -> String
show Assignment ex x
exsAsn
String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\nExpected: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Assignment BaseTypeRepr ctx -> String
forall a. Show a => a -> String
show Assignment BaseTypeRepr ctx
tpAssns
String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\nGot: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Assignment BaseTypeRepr x -> String
forall a. Show a => a -> String
show Assignment BaseTypeRepr x
exsRepr
readLetExpr ::
forall sym t st fs . (sym ~ W4.ExprBuilder t st fs)
=> [SExpr]
-> SExpr
-> Processor sym (Some (W4.SymExpr sym))
readLetExpr :: forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> SExpr -> Processor sym (Some (SymExpr sym))
readLetExpr [] SExpr
body = SExpr
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> Processor sym (Some (SymExpr sym))
readExpr SExpr
body
readLetExpr ((S.WFSList [S.WFSAtom (AId Text
x), SExpr
e]):[SExpr]
rst) SExpr
body = do
Some (Expr t)
v <- SExpr
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> Processor sym (Some (SymExpr sym))
readExpr SExpr
e
(ProcessorEnv (ExprBuilder t st fs)
-> ProcessorEnv (ExprBuilder t st fs))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
(ProcessorEnv (ExprBuilder t st fs)
-> ProcessorEnv (ExprBuilder t st fs))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall r (m :: Type -> Type) a.
MonadReader r m =>
(r -> r) -> m a -> m a
R.local (\ProcessorEnv (ExprBuilder t st fs)
c -> ProcessorEnv (ExprBuilder t st fs)
c {procLetEnv = (HM.insert x v) $ procLetEnv c}) (ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$
[SExpr]
-> SExpr
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> SExpr -> Processor sym (Some (SymExpr sym))
readLetExpr [SExpr]
rst SExpr
body
readLetExpr [SExpr]
bindings SExpr
_body = String
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some (SymExpr sym))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some (SymExpr sym)))
-> String
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some (SymExpr sym))
forall a b. (a -> b) -> a -> b
$
String
"invalid s-expression for let-bindings: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ ([SExpr] -> String
forall a. Show a => a -> String
show [SExpr]
bindings)
readLetFnExpr ::
forall sym t st fs . (sym ~ W4.ExprBuilder t st fs)
=> [SExpr]
-> SExpr
-> Processor sym (Some (W4.SymExpr sym))
readLetFnExpr :: forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> SExpr -> Processor sym (Some (SymExpr sym))
readLetFnExpr [] SExpr
body = SExpr
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> Processor sym (Some (SymExpr sym))
readExpr SExpr
body
readLetFnExpr ((S.WFSList [S.WFSAtom (AId Text
f), SExpr
e]):[SExpr]
rst) SExpr
body = do
SomeSymFn sym
v <- SExpr -> Processor sym (SomeSymFn sym)
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> Processor sym (SomeSymFn sym)
readSymFn SExpr
e
(ProcessorEnv sym -> ProcessorEnv sym)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
(ProcessorEnv sym -> ProcessorEnv sym)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall r (m :: Type -> Type) a.
MonadReader r m =>
(r -> r) -> m a -> m a
R.local (\ProcessorEnv sym
c -> ProcessorEnv sym
c {procLetFnEnv = (HM.insert f v) $ procLetFnEnv c}) (ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$
[SExpr]
-> SExpr
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> SExpr -> Processor sym (Some (SymExpr sym))
readLetExpr [SExpr]
rst SExpr
body
readLetFnExpr [SExpr]
bindings SExpr
_body = String
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some (SymExpr sym))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some (SymExpr sym)))
-> String
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some (SymExpr sym))
forall a b. (a -> b) -> a -> b
$
String
"invalid s-expression for let-bindings: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ ([SExpr] -> String
forall a. Show a => a -> String
show [SExpr]
bindings)
readExpr ::
forall sym t st fs . (sym ~ W4.ExprBuilder t st fs)
=> SExpr
-> Processor sym (Some (W4.SymExpr sym))
readExpr :: forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> Processor sym (Some (SymExpr sym))
readExpr (S.WFSAtom (AInt Integer
n)) = do
ExprBuilder t st fs
sym <- (ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ExprBuilder t st fs)
forall a.
(ProcessorEnv (ExprBuilder t st fs) -> a)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.reader ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs
forall sym. ProcessorEnv sym -> sym
procSym
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ (Expr t 'BaseIntegerType -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t 'BaseIntegerType -> Some (Expr t))
-> IO (Expr t 'BaseIntegerType) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> Integer -> IO (SymInteger (ExprBuilder t st fs))
forall sym.
IsExprBuilder sym =>
sym -> Integer -> IO (SymInteger sym)
W4.intLit ExprBuilder t st fs
sym Integer
n)
readExpr (S.WFSAtom (ANat Nat
_)) =
String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError String
"Bare Natural literals are no longer used"
readExpr (S.WFSAtom (ABool Bool
b)) = do
ExprBuilder t st fs
sym <- (ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ExprBuilder t st fs)
forall a.
(ProcessorEnv (ExprBuilder t st fs) -> a)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.reader ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs
forall sym. ProcessorEnv sym -> sym
procSym
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ Some (Expr t) -> IO (Some (Expr t))
forall a. a -> IO a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some (Expr t) -> IO (Some (Expr t)))
-> Some (Expr t) -> IO (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ Expr t 'BaseBoolType -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t 'BaseBoolType -> Some (Expr t))
-> Expr t 'BaseBoolType -> Some (Expr t)
forall a b. (a -> b) -> a -> b
$ ExprBuilder t st fs -> Bool -> Pred (ExprBuilder t st fs)
forall sym. IsExprBuilder sym => sym -> Bool -> Pred sym
W4.backendPred ExprBuilder t st fs
sym Bool
b
readExpr (S.WFSAtom (AFloat (Some FloatPrecisionRepr x
repr) BigFloat
bf)) = do
ExprBuilder t st fs
sym <- (ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ExprBuilder t st fs)
forall a.
(ProcessorEnv (ExprBuilder t st fs) -> a)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.reader ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs
forall sym. ProcessorEnv sym -> sym
procSym
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ (Expr t (BaseFloatType x) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t (BaseFloatType x) -> Some (Expr t))
-> IO (Expr t (BaseFloatType x)) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> FloatPrecisionRepr x
-> BigFloat
-> IO (SymFloat (ExprBuilder t st fs) x)
forall sym (fpp :: FloatPrecision).
IsExprBuilder sym =>
sym -> FloatPrecisionRepr fpp -> BigFloat -> IO (SymFloat sym fpp)
forall (fpp :: FloatPrecision).
ExprBuilder t st fs
-> FloatPrecisionRepr fpp
-> BigFloat
-> IO (SymFloat (ExprBuilder t st fs) fpp)
W4.floatLit ExprBuilder t st fs
sym FloatPrecisionRepr x
repr BigFloat
bf)
readExpr (S.WFSAtom (AStr Some StringInfoRepr
prefix Text
content)) = do
ExprBuilder t st fs
sym <- (ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ExprBuilder t st fs)
forall a.
(ProcessorEnv (ExprBuilder t st fs) -> a)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.reader ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs
forall sym. ProcessorEnv sym -> sym
procSym
case Some StringInfoRepr
prefix of
(Some StringInfoRepr x
W4.UnicodeRepr) -> do
Expr t ('BaseStringType 'Unicode)
s <- IO (Expr t ('BaseStringType 'Unicode))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Expr t ('BaseStringType 'Unicode))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Expr t ('BaseStringType 'Unicode))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Expr t ('BaseStringType 'Unicode)))
-> IO (Expr t ('BaseStringType 'Unicode))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Expr t ('BaseStringType 'Unicode))
forall a b. (a -> b) -> a -> b
$ ExprBuilder t st fs
-> StringLiteral 'Unicode
-> IO (SymExpr (ExprBuilder t st fs) ('BaseStringType 'Unicode))
forall sym (si :: StringInfo).
IsExprBuilder sym =>
sym -> StringLiteral si -> IO (SymString sym si)
forall (si :: StringInfo).
ExprBuilder t st fs
-> StringLiteral si -> IO (SymString (ExprBuilder t st fs) si)
W4.stringLit ExprBuilder t st fs
sym (StringLiteral 'Unicode
-> IO (SymExpr (ExprBuilder t st fs) ('BaseStringType 'Unicode)))
-> StringLiteral 'Unicode
-> IO (SymExpr (ExprBuilder t st fs) ('BaseStringType 'Unicode))
forall a b. (a -> b) -> a -> b
$ Text -> StringLiteral 'Unicode
W4.UnicodeLiteral Text
content
Some (Expr t)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some (Expr t)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> Some (Expr t)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ Expr t ('BaseStringType 'Unicode) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t ('BaseStringType 'Unicode) -> Some (Expr t))
-> Expr t ('BaseStringType 'Unicode) -> Some (Expr t)
forall a b. (a -> b) -> a -> b
$ Expr t ('BaseStringType 'Unicode)
s
(Some StringInfoRepr x
W4.Char8Repr) -> do
Expr t ('BaseStringType 'Char8)
s <- IO (Expr t ('BaseStringType 'Char8))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Expr t ('BaseStringType 'Char8))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Expr t ('BaseStringType 'Char8))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Expr t ('BaseStringType 'Char8)))
-> IO (Expr t ('BaseStringType 'Char8))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Expr t ('BaseStringType 'Char8))
forall a b. (a -> b) -> a -> b
$ ExprBuilder t st fs
-> StringLiteral 'Char8
-> IO (SymString (ExprBuilder t st fs) 'Char8)
forall sym (si :: StringInfo).
IsExprBuilder sym =>
sym -> StringLiteral si -> IO (SymString sym si)
forall (si :: StringInfo).
ExprBuilder t st fs
-> StringLiteral si -> IO (SymString (ExprBuilder t st fs) si)
W4.stringLit ExprBuilder t st fs
sym (StringLiteral 'Char8
-> IO (SymString (ExprBuilder t st fs) 'Char8))
-> StringLiteral 'Char8
-> IO (SymString (ExprBuilder t st fs) 'Char8)
forall a b. (a -> b) -> a -> b
$ ByteString -> StringLiteral 'Char8
W4.Char8Literal (ByteString -> StringLiteral 'Char8)
-> ByteString -> StringLiteral 'Char8
forall a b. (a -> b) -> a -> b
$ Text -> ByteString
T.encodeUtf8 Text
content
Some (Expr t)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some (Expr t)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> Some (Expr t)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ Expr t ('BaseStringType 'Char8) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t ('BaseStringType 'Char8) -> Some (Expr t))
-> Expr t ('BaseStringType 'Char8) -> Some (Expr t)
forall a b. (a -> b) -> a -> b
$ Expr t ('BaseStringType 'Char8)
s
(Some StringInfoRepr x
W4.Char16Repr) -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ String
"Char16 strings are not yet supported"
readExpr (S.WFSAtom (AReal Rational
_)) = String -> Processor sym (Some (SymExpr sym))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String -> Processor sym (Some (SymExpr sym)))
-> String -> Processor sym (Some (SymExpr sym))
forall a b. (a -> b) -> a -> b
$ String
"TODO: support readExpr for real literals"
readExpr (S.WFSAtom (ABV Int
len Integer
val)) = do
ExprBuilder t st fs
sym <- (ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ExprBuilder t st fs)
forall a.
(ProcessorEnv (ExprBuilder t st fs) -> a)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.reader ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs
forall sym. ProcessorEnv sym -> sym
procSym
case Integer -> Maybe (Some NatRepr)
forall a. Integral a => a -> Maybe (Some NatRepr)
someNat (Int -> Integer
forall a. Integral a => a -> Integer
toInteger Int
len) of
Just (Some NatRepr x
lenRepr) -> do
LeqProof 1 x
pf <- case NatRepr x -> Maybe (LeqProof 1 x)
forall (n :: Nat). NatRepr n -> Maybe (LeqProof 1 n)
isPosNat NatRepr x
lenRepr of
Just LeqProof 1 x
pf -> LeqProof 1 x
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (LeqProof 1 x)
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return LeqProof 1 x
pf
Maybe (LeqProof 1 x)
Nothing -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (LeqProof 1 x)
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError String
"What4.Serialize.Parser.readExpr isPosNat failure"
IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> IO (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ LeqProof 1 x
-> ((1 <= x) => IO (Some (Expr t))) -> IO (Some (Expr t))
forall (m :: Nat) (n :: Nat) a.
LeqProof m n -> ((m <= n) => a) -> a
withLeqProof LeqProof 1 x
pf (Expr t (BaseBVType x) -> Some (Expr t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (Expr t (BaseBVType x) -> Some (Expr t))
-> IO (Expr t (BaseBVType x)) -> IO (Some (Expr t))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> NatRepr x -> BV x -> IO (SymBV (ExprBuilder t st fs) x)
forall (w :: Nat).
(1 <= w) =>
ExprBuilder t st fs
-> NatRepr w -> BV w -> IO (SymBV (ExprBuilder t st fs) w)
forall sym (w :: Nat).
(IsExprBuilder sym, 1 <= w) =>
sym -> NatRepr w -> BV w -> IO (SymBV sym w)
W4.bvLit ExprBuilder t st fs
sym NatRepr x
lenRepr (NatRepr x -> Integer -> BV x
forall (w :: Nat). NatRepr w -> Integer -> BV w
BV.mkBV NatRepr x
lenRepr Integer
val))
Maybe (Some NatRepr)
Nothing -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError String
"SemMC.Formula.Parser.readExpr someNat failure"
readExpr (S.WFSAtom (AId Text
name)) = do
Maybe (Some (Expr t))
maybeBinding <- Text -> Processor sym (Maybe (Some (SymExpr sym)))
forall sym. Text -> Processor sym (Maybe (Some (SymExpr sym)))
lookupExpr Text
name
case Maybe (Some (Expr t))
maybeBinding of
Just Some (Expr t)
binding -> Some (Expr t)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return Some (Expr t)
binding
Maybe (Some (Expr t))
Nothing -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ (String
"Unbound variable encountered during deserialization: "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Text -> String
T.unpack Text
name))
readExpr (S.WFSList ((S.WFSAtom (AId Text
"let")):[SExpr]
rhs)) =
case [SExpr]
rhs of
[S.WFSList [SExpr]
bindings, SExpr
body] -> [SExpr] -> SExpr -> Processor sym (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> SExpr -> Processor sym (Some (SymExpr sym))
readLetExpr [SExpr]
bindings SExpr
body
[SExpr]
_ -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError String
"ill-formed let s-expression"
readExpr (S.WFSList ((S.WFSAtom (AId Text
"letfn")):[SExpr]
rhs)) =
case [SExpr]
rhs of
[S.WFSList [SExpr]
bindings, SExpr
body] -> [SExpr] -> SExpr -> Processor sym (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> SExpr -> Processor sym (Some (SymExpr sym))
readLetFnExpr [SExpr]
bindings SExpr
body
[SExpr]
_ -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError String
"ill-formed letfn s-expression"
readExpr (S.WFSList []) = String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError String
"ill-formed empty s-expression"
readExpr (S.WFSList (SExpr
operator:[SExpr]
operands)) = SExpr -> [SExpr] -> Processor sym (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> [SExpr] -> Processor sym (Some (SymExpr sym))
readApp SExpr
operator [SExpr]
operands
readExprs ::
forall sym t st fs . (sym ~ W4.ExprBuilder t st fs)
=> [SExpr]
-> Processor sym [Some (W4.SymExpr sym)]
readExprs :: forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym [Some (SymExpr sym)]
readExprs [SExpr]
exprs = (SExpr
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> [SExpr]
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) [Some (Expr t)]
forall (t :: Type -> Type) (m :: Type -> Type) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: Type -> Type) a b.
Monad m =>
(a -> m b) -> [a] -> m [b]
mapM SExpr -> Processor sym (Some (SymExpr sym))
SExpr
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> Processor sym (Some (SymExpr sym))
readExpr [SExpr]
exprs
readExprsAsAssignment ::
forall sym t st fs . (sym ~ W4.ExprBuilder t st fs)
=> [SExpr]
-> Processor sym (Some (Ctx.Assignment (W4.SymExpr sym)))
readExprsAsAssignment :: forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym (Some (Assignment (SymExpr sym)))
readExprsAsAssignment [SExpr]
exprs = [Some (Expr t)] -> Some (Assignment (Expr t))
forall {k} (f :: k -> Type). [Some f] -> Some (Assignment f)
Ctx.fromList ([Some (Expr t)] -> Some (Assignment (Expr t)))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) [Some (Expr t)]
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some (Assignment (Expr t)))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> [SExpr] -> Processor sym [Some (SymExpr sym)]
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
[SExpr] -> Processor sym [Some (SymExpr sym)]
readExprs [SExpr]
exprs
readFnType ::
forall sym . (W4.IsSymExprBuilder sym, ShowF (W4.SymExpr sym))
=> SExpr
-> Processor sym ([Some BaseTypeRepr], Some BaseTypeRepr)
readFnType :: forall sym.
(IsSymExprBuilder sym, ShowF (SymExpr sym)) =>
SExpr -> Processor sym ([Some BaseTypeRepr], Some BaseTypeRepr)
readFnType (S.WFSList ((S.WFSAtom (AId Text
"->")):[SExpr]
typeSExprs)) =
case [SExpr] -> Maybe ([SExpr], SExpr)
forall a. [a] -> Maybe ([a], a)
unsnoc [SExpr]
typeSExprs of
Maybe ([SExpr], SExpr)
Nothing ->
String -> Processor sym ([Some BaseTypeRepr], Some BaseTypeRepr)
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String -> Processor sym ([Some BaseTypeRepr], Some BaseTypeRepr))
-> String -> Processor sym ([Some BaseTypeRepr], Some BaseTypeRepr)
forall a b. (a -> b) -> a -> b
$ (String
"invalid type signature for function: "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Text -> String
T.unpack (Text -> String) -> Text -> String
forall a b. (a -> b) -> a -> b
$ Seq String -> SExpr -> Text
printSExpr Seq String
forall a. Monoid a => a
mempty ([SExpr] -> SExpr
forall t. [WellFormedSExpr t] -> WellFormedSExpr t
S.L [SExpr]
typeSExprs)))
Just ([SExpr]
domSExps, SExpr
retSExp) -> do
[Some BaseTypeRepr]
dom <- (SExpr
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some BaseTypeRepr))
-> [SExpr]
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) [Some BaseTypeRepr]
forall (t :: Type -> Type) (m :: Type -> Type) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: Type -> Type) a b.
Monad m =>
(a -> m b) -> [a] -> m [b]
mapM SExpr
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some BaseTypeRepr)
forall (m :: Type -> Type).
MonadError String m =>
SExpr -> m (Some BaseTypeRepr)
readBaseType [SExpr]
domSExps
Some BaseTypeRepr
ret <- SExpr
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (Some BaseTypeRepr)
forall (m :: Type -> Type).
MonadError String m =>
SExpr -> m (Some BaseTypeRepr)
readBaseType SExpr
retSExp
([Some BaseTypeRepr], Some BaseTypeRepr)
-> Processor sym ([Some BaseTypeRepr], Some BaseTypeRepr)
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return ([Some BaseTypeRepr]
dom, Some BaseTypeRepr
ret)
readFnType SExpr
sexpr =
String -> Processor sym ([Some BaseTypeRepr], Some BaseTypeRepr)
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String -> Processor sym ([Some BaseTypeRepr], Some BaseTypeRepr))
-> String -> Processor sym ([Some BaseTypeRepr], Some BaseTypeRepr)
forall a b. (a -> b) -> a -> b
$ (String
"invalid type signature for function: "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Text -> String
T.unpack (Text -> String) -> Text -> String
forall a b. (a -> b) -> a -> b
$ Seq String -> SExpr -> Text
printSExpr Seq String
forall a. Monoid a => a
mempty SExpr
sexpr))
unsnoc :: [a] -> Maybe ([a], a)
unsnoc :: forall a. [a] -> Maybe ([a], a)
unsnoc [] = Maybe ([a], a)
forall a. Maybe a
Nothing
unsnoc (a
x:[a]
xs) = case [a] -> Maybe ([a], a)
forall a. [a] -> Maybe ([a], a)
unsnoc [a]
xs of
Maybe ([a], a)
Nothing -> ([a], a) -> Maybe ([a], a)
forall a. a -> Maybe a
Just ([], a
x)
Just ([a]
a,a
b) -> ([a], a) -> Maybe ([a], a)
forall a. a -> Maybe a
Just (a
xa -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
a, a
b)
readFnArgs ::
forall sym . (W4.IsSymExprBuilder sym, ShowF (W4.SymExpr sym))
=> [SExpr]
-> Processor sym [Text]
readFnArgs :: forall sym.
(IsSymExprBuilder sym, ShowF (SymExpr sym)) =>
[SExpr] -> Processor sym [Text]
readFnArgs [] = [Text] -> ExceptT String (ReaderT (ProcessorEnv sym) IO) [Text]
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return []
readFnArgs ((S.WFSAtom (AId Text
name)):[SExpr]
rest) = do
[Text]
names <- ([SExpr] -> ExceptT String (ReaderT (ProcessorEnv sym) IO) [Text]
forall sym.
(IsSymExprBuilder sym, ShowF (SymExpr sym)) =>
[SExpr] -> Processor sym [Text]
readFnArgs [SExpr]
rest)
[Text] -> ExceptT String (ReaderT (ProcessorEnv sym) IO) [Text]
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return ([Text] -> ExceptT String (ReaderT (ProcessorEnv sym) IO) [Text])
-> [Text] -> ExceptT String (ReaderT (ProcessorEnv sym) IO) [Text]
forall a b. (a -> b) -> a -> b
$ Text
nameText -> [Text] -> [Text]
forall a. a -> [a] -> [a]
:[Text]
names
readFnArgs (SExpr
badArg:[SExpr]
_) =
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) [Text]
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) [Text])
-> String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) [Text]
forall a b. (a -> b) -> a -> b
$ (String
"invalid function argument encountered: "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Text -> String
T.unpack (Text -> String) -> Text -> String
forall a b. (a -> b) -> a -> b
$ Seq String -> SExpr -> Text
printSExpr Seq String
forall a. Monoid a => a
mempty SExpr
badArg))
someVarExpr ::
forall sym . (W4.IsSymExprBuilder sym, ShowF (W4.SymExpr sym))
=> sym
-> Some (W4.BoundVar sym)
-> Some (W4.SymExpr sym)
someVarExpr :: forall sym.
(IsSymExprBuilder sym, ShowF (SymExpr sym)) =>
sym -> Some (BoundVar sym) -> Some (SymExpr sym)
someVarExpr sym
sym (Some BoundVar sym x
bv) = SymExpr sym x -> Some (SymExpr sym)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (sym -> BoundVar sym x -> SymExpr sym x
forall sym (tp :: BaseType).
IsSymExprBuilder sym =>
sym -> BoundVar sym tp -> SymExpr sym tp
forall (tp :: BaseType). sym -> BoundVar sym tp -> SymExpr sym tp
W4.varExpr sym
sym BoundVar sym x
bv)
readSymFn ::
forall sym t st fs . (sym ~ W4.ExprBuilder t st fs)
=> SExpr
-> Processor sym (SomeSymFn sym)
readSymFn :: forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> Processor sym (SomeSymFn sym)
readSymFn (S.WFSList [ S.WFSAtom (AId Text
"definedfn")
, S.WFSAtom (AStr Some StringInfoRepr
_ Text
rawSymFnName)
, SExpr
rawFnType
, S.WFSList [SExpr]
argVarsRaw
, SExpr
bodyRaw
]) = do
ExprBuilder t st fs
sym <- (ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ExprBuilder t st fs)
forall a.
(ProcessorEnv (ExprBuilder t st fs) -> a)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.reader ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs
forall sym. ProcessorEnv sym -> sym
procSym
SolverSymbol
symFnName <- case String -> Either SolverSymbolError SolverSymbol
W4.userSymbol (Text -> String
T.unpack Text
rawSymFnName) of
Left SolverSymbolError
_ -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) SolverSymbol
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) SolverSymbol)
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) SolverSymbol
forall a b. (a -> b) -> a -> b
$ (String
"Bad symbolic function name : "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Text -> String
T.unpack Text
rawSymFnName))
Right SolverSymbol
solverSym -> SolverSymbol
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) SolverSymbol
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return SolverSymbol
solverSym
[Text]
argNames <- [SExpr] -> Processor sym [Text]
forall sym.
(IsSymExprBuilder sym, ShowF (SymExpr sym)) =>
[SExpr] -> Processor sym [Text]
readFnArgs [SExpr]
argVarsRaw
([Some BaseTypeRepr]
argTys, Some BaseTypeRepr
_retTy) <- SExpr -> Processor sym ([Some BaseTypeRepr], Some BaseTypeRepr)
forall sym.
(IsSymExprBuilder sym, ShowF (SymExpr sym)) =>
SExpr -> Processor sym ([Some BaseTypeRepr], Some BaseTypeRepr)
readFnType SExpr
rawFnType
Bool
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) ()
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) ()
forall (f :: Type -> Type). Applicative f => Bool -> f () -> f ()
when (Bool -> Bool
not ([Some BaseTypeRepr] -> Int
forall a. [a] -> Int
forall (t :: Type -> Type) a. Foldable t => t a -> Int
length [Some BaseTypeRepr]
argTys Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== [Text] -> Int
forall a. [a] -> Int
forall (t :: Type -> Type) a. Foldable t => t a -> Int
length [Text]
argNames)) (ExceptT String (ReaderT (ProcessorEnv sym) IO) ()
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) ())
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) ()
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) ()
forall a b. (a -> b) -> a -> b
$
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) ()
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) ())
-> String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) ()
forall a b. (a -> b) -> a -> b
$ String
"Function type expected "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Int -> String
forall a. Show a => a -> String
show (Int -> String) -> Int -> String
forall a b. (a -> b) -> a -> b
$ [Some BaseTypeRepr] -> Int
forall a. [a] -> Int
forall (t :: Type -> Type) a. Foldable t => t a -> Int
length [Some BaseTypeRepr]
argTys)
String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" args but found "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Int -> String
forall a. Show a => a -> String
show (Int -> String) -> Int -> String
forall a b. (a -> b) -> a -> b
$ [Text] -> Int
forall a. [a] -> Int
forall (t :: Type -> Type) a. Foldable t => t a -> Int
length [Text]
argNames)
[Some (BoundVar (ExprBuilder t st fs))]
argVars <- ((Text, Some BaseTypeRepr)
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (BoundVar (ExprBuilder t st fs))))
-> [(Text, Some BaseTypeRepr)]
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
[Some (BoundVar (ExprBuilder t st fs))]
forall (t :: Type -> Type) (m :: Type -> Type) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: Type -> Type) a b.
Monad m =>
(a -> m b) -> [a] -> m [b]
mapM (\(Text
name, (Some BaseTypeRepr x
ty)) ->
case String -> Either SolverSymbolError SolverSymbol
W4.userSymbol (Text -> String
T.unpack Text
name) of
Left SolverSymbolError
_ -> String
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (BoundVar (ExprBuilder t st fs)))
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (BoundVar (ExprBuilder t st fs))))
-> String
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (BoundVar (ExprBuilder t st fs)))
forall a b. (a -> b) -> a -> b
$ String
"Bad arg name : " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Text -> String
T.unpack Text
name)
Right SolverSymbol
solverSym -> IO (Some (BoundVar (ExprBuilder t st fs)))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (BoundVar (ExprBuilder t st fs)))
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (Some (BoundVar (ExprBuilder t st fs)))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (BoundVar (ExprBuilder t st fs))))
-> IO (Some (BoundVar (ExprBuilder t st fs)))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (BoundVar (ExprBuilder t st fs)))
forall a b. (a -> b) -> a -> b
$ ExprBoundVar t x -> Some (BoundVar (ExprBuilder t st fs))
ExprBoundVar t x -> Some (ExprBoundVar t)
forall k (f :: k -> Type) (x :: k). f x -> Some f
Some (ExprBoundVar t x -> Some (BoundVar (ExprBuilder t st fs)))
-> IO (ExprBoundVar t x)
-> IO (Some (BoundVar (ExprBuilder t st fs)))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ExprBuilder t st fs
-> SolverSymbol
-> BaseTypeRepr x
-> IO (BoundVar (ExprBuilder t st fs) x)
forall sym (tp :: BaseType).
IsSymExprBuilder sym =>
sym -> SolverSymbol -> BaseTypeRepr tp -> IO (BoundVar sym tp)
forall (tp :: BaseType).
ExprBuilder t st fs
-> SolverSymbol
-> BaseTypeRepr tp
-> IO (BoundVar (ExprBuilder t st fs) tp)
W4.freshBoundVar ExprBuilder t st fs
sym SolverSymbol
solverSym BaseTypeRepr x
ty)
([(Text, Some BaseTypeRepr)]
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
[Some (BoundVar (ExprBuilder t st fs))])
-> [(Text, Some BaseTypeRepr)]
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
[Some (BoundVar (ExprBuilder t st fs))]
forall a b. (a -> b) -> a -> b
$ [Text] -> [Some BaseTypeRepr] -> [(Text, Some BaseTypeRepr)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Text]
argNames [Some BaseTypeRepr]
argTys
(Some Expr t x
body) <- let newBindings :: HashMap Text (Some (SymExpr (ExprBuilder t st fs)))
newBindings = [(Text, Some (SymExpr (ExprBuilder t st fs)))]
-> HashMap Text (Some (SymExpr (ExprBuilder t st fs)))
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HM.fromList
([(Text, Some (SymExpr (ExprBuilder t st fs)))]
-> HashMap Text (Some (SymExpr (ExprBuilder t st fs))))
-> [(Text, Some (SymExpr (ExprBuilder t st fs)))]
-> HashMap Text (Some (SymExpr (ExprBuilder t st fs)))
forall a b. (a -> b) -> a -> b
$ [Text]
-> [Some (SymExpr (ExprBuilder t st fs))]
-> [(Text, Some (SymExpr (ExprBuilder t st fs)))]
forall a b. [a] -> [b] -> [(a, b)]
zip [Text]
argNames
([Some (SymExpr (ExprBuilder t st fs))]
-> [(Text, Some (SymExpr (ExprBuilder t st fs)))])
-> [Some (SymExpr (ExprBuilder t st fs))]
-> [(Text, Some (SymExpr (ExprBuilder t st fs)))]
forall a b. (a -> b) -> a -> b
$ (Some (BoundVar (ExprBuilder t st fs))
-> Some (SymExpr (ExprBuilder t st fs)))
-> [Some (BoundVar (ExprBuilder t st fs))]
-> [Some (SymExpr (ExprBuilder t st fs))]
forall a b. (a -> b) -> [a] -> [b]
map (ExprBuilder t st fs
-> Some (BoundVar (ExprBuilder t st fs))
-> Some (SymExpr (ExprBuilder t st fs))
forall sym.
(IsSymExprBuilder sym, ShowF (SymExpr sym)) =>
sym -> Some (BoundVar sym) -> Some (SymExpr sym)
someVarExpr ExprBuilder t st fs
sym) [Some (BoundVar (ExprBuilder t st fs))]
argVars
in (ProcessorEnv (ExprBuilder t st fs)
-> ProcessorEnv (ExprBuilder t st fs))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a.
(ProcessorEnv (ExprBuilder t st fs)
-> ProcessorEnv (ExprBuilder t st fs))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall r (m :: Type -> Type) a.
MonadReader r m =>
(r -> r) -> m a -> m a
R.local
(\ProcessorEnv (ExprBuilder t st fs)
env -> ProcessorEnv (ExprBuilder t st fs)
env {procLetEnv = HM.union (procLetEnv env) newBindings})
(ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t)))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (Some (Expr t))
forall a b. (a -> b) -> a -> b
$ SExpr -> Processor sym (Some (SymExpr sym))
forall sym t (st :: Type -> Type) fs.
(sym ~ ExprBuilder t st fs) =>
SExpr -> Processor sym (Some (SymExpr sym))
readExpr SExpr
bodyRaw
Some Assignment (ExprBoundVar t) x
argVarAssignment <- Some (Assignment (ExprBoundVar t))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (Assignment (ExprBoundVar t)))
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some (Assignment (ExprBoundVar t))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (Assignment (ExprBoundVar t))))
-> Some (Assignment (ExprBoundVar t))
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (Assignment (ExprBoundVar t)))
forall a b. (a -> b) -> a -> b
$ [Some (ExprBoundVar t)] -> Some (Assignment (ExprBoundVar t))
forall {k} (f :: k -> Type). [Some f] -> Some (Assignment f)
Ctx.fromList [Some (BoundVar (ExprBuilder t st fs))]
[Some (ExprBoundVar t)]
argVars
ExprSymFn t x x
symFn <- IO (ExprSymFn t x x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (ExprSymFn t x x)
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (ExprSymFn t x x)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ExprSymFn t x x))
-> IO (ExprSymFn t x x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (ExprSymFn t x x)
forall a b. (a -> b) -> a -> b
$ ExprBuilder t st fs
-> SolverSymbol
-> Assignment (BoundVar (ExprBuilder t st fs)) x
-> SymExpr (ExprBuilder t st fs) x
-> UnfoldPolicy
-> IO (SymFn (ExprBuilder t st fs) x x)
forall sym (args :: Ctx BaseType) (ret :: BaseType).
IsSymExprBuilder sym =>
sym
-> SolverSymbol
-> Assignment (BoundVar sym) args
-> SymExpr sym ret
-> UnfoldPolicy
-> IO (SymFn sym args ret)
forall (args :: Ctx BaseType) (ret :: BaseType).
ExprBuilder t st fs
-> SolverSymbol
-> Assignment (BoundVar (ExprBuilder t st fs)) args
-> SymExpr (ExprBuilder t st fs) ret
-> UnfoldPolicy
-> IO (SymFn (ExprBuilder t st fs) args ret)
W4.definedFn ExprBuilder t st fs
sym SolverSymbol
symFnName Assignment (BoundVar (ExprBuilder t st fs)) x
Assignment (ExprBoundVar t) x
argVarAssignment SymExpr (ExprBuilder t st fs) x
Expr t x
body UnfoldPolicy
W4.UnfoldConcrete
SomeSymFn sym -> Processor sym (SomeSymFn sym)
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (SomeSymFn sym -> Processor sym (SomeSymFn sym))
-> SomeSymFn sym -> Processor sym (SomeSymFn sym)
forall a b. (a -> b) -> a -> b
$ SymFn sym x x -> SomeSymFn sym
forall t (dom :: Ctx BaseType) (ret :: BaseType).
SymFn t dom ret -> SomeSymFn t
SomeSymFn SymFn sym x x
ExprSymFn t x x
symFn
readSymFn badSExp :: SExpr
badSExp@(S.WFSList ((S.WFSAtom (AId Text
"definedfn")):[SExpr]
_)) =
String -> Processor sym (SomeSymFn sym)
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String -> Processor sym (SomeSymFn sym))
-> String -> Processor sym (SomeSymFn sym)
forall a b. (a -> b) -> a -> b
$ (String
"invalid `definedfn`: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Text -> String
T.unpack (Text -> String) -> Text -> String
forall a b. (a -> b) -> a -> b
$ Seq String -> SExpr -> Text
printSExpr Seq String
forall a. Monoid a => a
mempty SExpr
badSExp))
readSymFn (S.WFSList [ S.WFSAtom (AId Text
"uninterpfn")
, S.WFSAtom (AStr Some StringInfoRepr
_ Text
rawSymFnName)
, SExpr
rawFnType
]) = do
ExprBuilder t st fs
sym <- (ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ExprBuilder t st fs)
forall a.
(ProcessorEnv (ExprBuilder t st fs) -> a)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall r (m :: Type -> Type) a. MonadReader r m => (r -> a) -> m a
R.reader ProcessorEnv (ExprBuilder t st fs) -> ExprBuilder t st fs
forall sym. ProcessorEnv sym -> sym
procSym
SolverSymbol
symFnName <- case String -> Either SolverSymbolError SolverSymbol
W4.userSymbol (Text -> String
T.unpack Text
rawSymFnName) of
Left SolverSymbolError
_ -> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) SolverSymbol
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) SolverSymbol)
-> String
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) SolverSymbol
forall a b. (a -> b) -> a -> b
$ (String
"Bad symbolic function name : "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Text -> String
T.unpack Text
rawSymFnName))
Right SolverSymbol
solverSym -> SolverSymbol
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) SolverSymbol
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return SolverSymbol
solverSym
([Some BaseTypeRepr]
argTys, (Some BaseTypeRepr x
retTy)) <- SExpr -> Processor sym ([Some BaseTypeRepr], Some BaseTypeRepr)
forall sym.
(IsSymExprBuilder sym, ShowF (SymExpr sym)) =>
SExpr -> Processor sym ([Some BaseTypeRepr], Some BaseTypeRepr)
readFnType SExpr
rawFnType
Some Assignment BaseTypeRepr x
domain <- Some (Assignment BaseTypeRepr)
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (Assignment BaseTypeRepr))
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (Some (Assignment BaseTypeRepr)
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (Assignment BaseTypeRepr)))
-> Some (Assignment BaseTypeRepr)
-> ExceptT
String
(ReaderT (ProcessorEnv sym) IO)
(Some (Assignment BaseTypeRepr))
forall a b. (a -> b) -> a -> b
$ [Some BaseTypeRepr] -> Some (Assignment BaseTypeRepr)
forall {k} (f :: k -> Type). [Some f] -> Some (Assignment f)
Ctx.fromList [Some BaseTypeRepr]
argTys
ExprSymFn t x x
symFn <- IO (ExprSymFn t x x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (ExprSymFn t x x)
forall a. IO a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO (IO (ExprSymFn t x x)
-> ExceptT
String (ReaderT (ProcessorEnv sym) IO) (ExprSymFn t x x))
-> IO (ExprSymFn t x x)
-> ExceptT String (ReaderT (ProcessorEnv sym) IO) (ExprSymFn t x x)
forall a b. (a -> b) -> a -> b
$ ExprBuilder t st fs
-> SolverSymbol
-> Assignment BaseTypeRepr x
-> BaseTypeRepr x
-> IO (SymFn (ExprBuilder t st fs) x x)
forall sym (args :: Ctx BaseType) (ret :: BaseType).
IsSymExprBuilder sym =>
sym
-> SolverSymbol
-> Assignment BaseTypeRepr args
-> BaseTypeRepr ret
-> IO (SymFn sym args ret)
forall (args :: Ctx BaseType) (ret :: BaseType).
ExprBuilder t st fs
-> SolverSymbol
-> Assignment BaseTypeRepr args
-> BaseTypeRepr ret
-> IO (SymFn (ExprBuilder t st fs) args ret)
W4.freshTotalUninterpFn ExprBuilder t st fs
sym SolverSymbol
symFnName Assignment BaseTypeRepr x
domain BaseTypeRepr x
retTy
SomeSymFn sym -> Processor sym (SomeSymFn sym)
forall a. a -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (SomeSymFn sym -> Processor sym (SomeSymFn sym))
-> SomeSymFn sym -> Processor sym (SomeSymFn sym)
forall a b. (a -> b) -> a -> b
$ SymFn sym x x -> SomeSymFn sym
forall t (dom :: Ctx BaseType) (ret :: BaseType).
SymFn t dom ret -> SomeSymFn t
SomeSymFn SymFn sym x x
ExprSymFn t x x
symFn
readSymFn badSExp :: SExpr
badSExp@(S.WFSList ((S.WFSAtom (AId Text
"uninterpfn")):[SExpr]
_)) =
String -> Processor sym (SomeSymFn sym)
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String -> Processor sym (SomeSymFn sym))
-> String -> Processor sym (SomeSymFn sym)
forall a b. (a -> b) -> a -> b
$ (String
"invalid `uninterpfn`: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Text -> String
T.unpack (Text -> String) -> Text -> String
forall a b. (a -> b) -> a -> b
$ Seq String -> SExpr -> Text
printSExpr Seq String
forall a. Monoid a => a
mempty SExpr
badSExp))
readSymFn SExpr
sexpr = String -> Processor sym (SomeSymFn sym)
forall a.
String -> ExceptT String (ReaderT (ProcessorEnv sym) IO) a
forall e (m :: Type -> Type) a. MonadError e m => e -> m a
E.throwError (String
"invalid function definition: "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Text -> String
T.unpack (Text -> String) -> Text -> String
forall a b. (a -> b) -> a -> b
$ Seq String -> SExpr -> Text
printSExpr Seq String
forall a. Monoid a => a
mempty SExpr
sexpr))