module Vulkan.Utils.ShaderQQ.HLSL
( hlsl
, insertLineDirective
) where
import Language.Haskell.TH
import Language.Haskell.TH.Quote
import Vulkan.Utils.Internal ( badQQ )
import Vulkan.Utils.ShaderQQ.Interpolate
hlsl :: QuasiQuoter
hlsl :: QuasiQuoter
hlsl = (String -> QuasiQuoter
badQQ String
"hlsl")
{ quoteExp :: String -> Q Exp
quoteExp = \String
s -> do
Loc
loc <- Q Loc
location
let codeWithLineDirective :: String
codeWithLineDirective = String -> Loc -> String
insertLineDirective String
s Loc
loc
String -> Q Exp
interpExp String
codeWithLineDirective
}
insertLineDirective :: String -> Loc -> String
insertLineDirective :: String -> Loc -> String
insertLineDirective String
code Loc {String
CharPos
loc_end :: Loc -> CharPos
loc_filename :: Loc -> String
loc_module :: Loc -> String
loc_package :: Loc -> String
loc_start :: Loc -> CharPos
loc_end :: CharPos
loc_start :: CharPos
loc_module :: String
loc_package :: String
loc_filename :: String
..} =
let lineDirective :: String
lineDirective =
String
"#line " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show (forall a b. (a, b) -> a
fst CharPos
loc_start) forall a. Semigroup a => a -> a -> a
<> String
" \"" forall a. Semigroup a => a -> a -> a
<> String
loc_filename forall a. Semigroup a => a -> a -> a
<> String
"\""
in String
lineDirective forall a. Semigroup a => a -> a -> a
<> String
"\n" forall a. Semigroup a => a -> a -> a
<> String
code