{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE TemplateHaskellQuotes #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE UnboxedTuples #-}
module Language.Haskell.TH.Syntax (
Quote (..),
Exp (..),
Match (..),
Clause (..),
Q (..),
Pat (..),
Stmt (..),
Con (..),
Type (..),
Dec (..),
BangType,
VarBangType,
FieldExp,
FieldPat,
Name (..),
FunDep (..),
Pred,
RuleBndr (..),
TySynEqn (..),
InjectivityAnn (..),
Kind,
Overlap (..),
DerivClause (..),
DerivStrategy (..),
Code (..),
ModName (..),
addCorePlugin,
addDependentFile,
addForeignFile,
addForeignFilePath,
addForeignSource,
addModFinalizer,
addTempFile,
addTopDecls,
badIO,
bindCode,
bindCode_,
cmpEq,
compareBytes,
counter,
defaultFixity,
eqBytes,
extsEnabled,
getDoc,
getPackageRoot,
getQ,
get_cons_names,
hoistCode,
isExtEnabled,
isInstance,
joinCode,
liftCode,
location,
lookupName,
lookupTypeName,
lookupValueName,
manyName,
maxPrecedence,
memcmp,
mkNameG,
mkNameU,
mkOccName,
mkPkgName,
mk_tup_name,
mkName,
mkNameG_v,
mkNameG_d,
mkNameG_tc,
mkNameL,
mkNameS,
unTypeCode,
mkModName,
unsafeCodeCoerce,
mkNameQ,
mkNameG_fld,
modString,
nameBase,
nameModule,
namePackage,
nameSpace,
newDeclarationGroup,
newNameIO,
occString,
oneName,
pkgString,
putDoc,
putQ,
recover,
reify,
reifyAnnotations,
reifyConStrictness,
reifyFixity,
reifyInstances,
reifyModule,
reifyRoles,
reifyType,
report,
reportError,
reportWarning,
runIO,
sequenceQ,
runQ,
showName,
showName',
thenCmp,
tupleDataName,
tupleTypeName,
unTypeQ,
unboxedSumDataName,
unboxedSumTypeName,
unboxedTupleDataName,
unboxedTupleTypeName,
unsafeTExpCoerce,
ForeignSrcLang (..),
Extension (..),
AnnLookup (..),
AnnTarget (..),
Arity,
Bang (..),
BndrVis (..),
Body (..),
Bytes (..),
Callconv (..),
CharPos,
Cxt,
DecidedStrictness (..),
DocLoc (..),
FamilyResultSig (..),
Fixity (..),
FixityDirection (..),
Foreign (..),
Guard (..),
Info (..),
Inline (..),
InstanceDec,
Lit (..),
Loc (..),
Module (..),
ModuleInfo (..),
NameFlavour (..),
NameIs (..),
NameSpace (..),
NamespaceSpecifier (..),
OccName (..),
ParentName,
PatSynArgs (..),
PatSynDir (..),
PatSynType,
Phases (..),
PkgName (..),
Pragma (..),
Quasi (..),
Range (..),
Role (..),
RuleMatch (..),
Safety (..),
SourceStrictness (..),
SourceUnpackedness (..),
Specificity (..),
Strict,
StrictType,
SumAlt,
SumArity,
TExp (..),
TyLit (..),
TyVarBndr (..),
TypeFamilyHead (..),
Uniq,
Unlifted,
VarStrictType,
makeRelativeToProject,
liftString,
Lift (..),
dataToExpQ,
dataToPatQ,
dataToQa,
falseName,
justName,
leftName,
liftData,
nonemptyName,
nothingName,
rightName,
trueName,
addrToByteArrayName,
addrToByteArray,
)
where
import GHC.Internal.TH.Syntax
import GHC.Internal.TH.Lift
import System.FilePath
import Data.Array.Byte
import GHC.Exts
import GHC.ST
makeRelativeToProject :: FilePath -> Q FilePath
makeRelativeToProject :: FilePath -> Q FilePath
makeRelativeToProject FilePath
fp | FilePath -> Bool
isRelative FilePath
fp = do
root <- Q FilePath
getPackageRoot
return (root </> fp)
makeRelativeToProject FilePath
fp = FilePath -> Q FilePath
forall a. a -> Q a
forall (m :: * -> *) a. Monad m => a -> m a
return FilePath
fp
addrToByteArrayName :: Name
addrToByteArrayName :: Name
addrToByteArrayName = 'addrToByteArray
addrToByteArray :: Int -> Addr# -> ByteArray
addrToByteArray :: Int -> Addr# -> ByteArray
addrToByteArray (I# Int#
len) Addr#
addr = (forall s. ST s ByteArray) -> ByteArray
forall a. (forall s. ST s a) -> a
runST ((forall s. ST s ByteArray) -> ByteArray)
-> (forall s. ST s ByteArray) -> ByteArray
forall a b. (a -> b) -> a -> b
$ STRep s ByteArray -> ST s ByteArray
forall s a. STRep s a -> ST s a
ST (STRep s ByteArray -> ST s ByteArray)
-> STRep s ByteArray -> ST s ByteArray
forall a b. (a -> b) -> a -> b
$
\State# s
s -> case Int# -> State# s -> (# State# s, MutableByteArray# s #)
forall d. Int# -> State# d -> (# State# d, MutableByteArray# d #)
newByteArray# Int#
len State# s
s of
(# State# s
s', MutableByteArray# s
mb #) -> case Addr#
-> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
forall d.
Addr#
-> MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
copyAddrToByteArray# Addr#
addr MutableByteArray# s
mb Int#
0# Int#
len State# s
s' of
State# s
s'' -> case MutableByteArray# s -> State# s -> (# State# s, ByteArray# #)
forall d.
MutableByteArray# d -> State# d -> (# State# d, ByteArray# #)
unsafeFreezeByteArray# MutableByteArray# s
mb State# s
s'' of
(# State# s
s''', ByteArray#
ret #) -> (# State# s
s''', ByteArray# -> ByteArray
ByteArray ByteArray#
ret #)