on master help sign in
just some more work fleshing out the interface for gl type templating
88fce69John P Mayer Jr
Elm.cabal+1
@@ -202,6 +202,7 @@ Executable elm-doc
202 directory,
202 directory,
203 filepath,
203 filepath,
204 indents,
204 indents,
205+ language-glsl,
205 mtl >= 2,
206 mtl >= 2,
206 pandoc >= 1.10,
207 pandoc >= 1.10,
207 parsec >= 3.1.1,
208 parsec >= 3.1.1,
compiler/Parse/Helpers.hs+12−3
@@ -6,6 +6,7 @@ import Control.Monad
6import Control.Monad.State
6import Control.Monad.State
7import Data.Char (isUpper)
7import Data.Char (isUpper)
8import qualified Data.Set as Set
8import qualified Data.Set as Set
9+import Data.Map (Map)
9import qualified Data.Map as Map
10import qualified Data.Map as Map
10import qualified Language.GLSL.Parser as GLP
11import qualified Language.GLSL.Parser as GLP
11import Language.GLSL.Syntax
12import Language.GLSL.Syntax
@@ -328,14 +329,22 @@ glShader = try (string "[glShader|") >> closeShader "" where
328 ]
329 ]
329
330
330data GLTipe = V3 | M4
331data GLTipe = V3 | M4
331−
332+data GLShaderDecls = GLShaderDecls
333+ { attribute :: Map String GLTipe
334+ , uniform :: Map String GLTipe
335+ , variying :: Map String GLTipe
336+ }
337+
332−glSource :: String -> Maybe [(StorageQualifier, GLTipe, String)]
338+--glSource :: String -> Maybe [(StorageQualifier, GLTipe, String)]
339+glSource :: String -> Maybe GLShaderDecls
333glSource src =
340glSource src =
334 case GLP.parse src of
341 case GLP.parse src of
335 Right (TranslationUnit decls) ->
342 Right (TranslationUnit decls) ->
336− Just . join . map extractGLinputs $ decls
343+ Just . foldl addGLinput emptyDecls . join . map extractGLinputs $ decls
337 Left e -> Nothing
344 Left e -> Nothing
338 where
345 where
346+ emptyDecls = GLShaderDecls Map.empty Map.empty Map.empty
347+ addGLinput = error "TODO"
339 extractGLinputs decl = case decl of
348 extractGLinputs decl = case decl of
340 Declaration (InitDeclaration (TypeDeclarator (FullType (Just (TypeQualSto qual)) (TypeSpec _prec (TypeSpecNoPrecision tipe _mexpr1)))) [InitDecl name _mexpr2 _mexpr3]) ->
349 Declaration (InitDeclaration (TypeDeclarator (FullType (Just (TypeQualSto qual)) (TypeSpec _prec (TypeSpecNoPrecision tipe _mexpr1)))) [InitDecl name _mexpr2 _mexpr3]) ->
341 if elem qual [Attribute, Varying, Uniform]
350 if elem qual [Attribute, Varying, Uniform]
compiler/Type/Constrain/Expression.hs+3−1
@@ -42,7 +42,9 @@ constrain env (L span expr) tipe =
42 GLShader _ src ->
42 GLShader _ src ->
43 return . L span $ CEqual tipe (glTipe sourceTipe) where
43 return . L span $ CEqual tipe (glTipe sourceTipe) where
44 glTipe t = Env.get env Env.types "GLShader" <| t
44 glTipe t = Env.get env Env.types "GLShader" <| t
45− sourceTipe = PH.glSource src
45+ sourceTipe = declsRecord $ PH.glSource src
46+ declsRecord :: Maybe PH.GLShaderDecls -> TermN Variable
47+ declsRecord = error "TODO"
46
48
47 Var name | name == saveEnvName -> return (L span CSaveEnv)
49 Var name | name == saveEnvName -> return (L span CSaveEnv)
48 | otherwise -> return (name <? tipe)
50 | otherwise -> return (name <? tipe)