on master help sign in
just some more work fleshing out the interface for gl type templating
commit88fce697b8d6020598d2b6caf2d4ab74eca560d3 authorJohn P Mayer Jr <john.p.mayer.jr@gmail.com> dateSun 1 Dec 2013, 23:43 (13 years ago) parentd690696
3 files changed+16−4
Elm.cabal+1 compiler/Parse/Helpers.hs+12−3 compiler/Type/Constrain/Expression.hs+3−1
Elm.cabal+1
@@ -202,6 +202,7 @@ Executable elm-doc
202202 directory,
203203 filepath,
204204 indents,
205+ language-glsl,
205206 mtl >= 2,
206207 pandoc >= 1.10,
207208 parsec >= 3.1.1,
compiler/Parse/Helpers.hs+12−3
@@ -6,6 +6,7 @@ import Control.Monad
66import Control.Monad.State
77import Data.Char (isUpper)
88import qualified Data.Set as Set
9+import Data.Map (Map)
910import qualified Data.Map as Map
1011import qualified Language.GLSL.Parser as GLP
1112import Language.GLSL.Syntax
@@ -328,14 +329,22 @@ glShader = try (string "[glShader|") >> closeShader "" where
328329 ]
329330
330331data GLTipe = V3 | M4
331−
332−glSource :: String -> Maybe [(StorageQualifier, GLTipe, String)]
332+data GLShaderDecls = GLShaderDecls
333+ { attribute :: Map String GLTipe
334+ , uniform :: Map String GLTipe
335+ , variying :: Map String GLTipe
336+ }
337+
338+--glSource :: String -> Maybe [(StorageQualifier, GLTipe, String)]
339+glSource :: String -> Maybe GLShaderDecls
333340glSource src =
334341 case GLP.parse src of
335342 Right (TranslationUnit decls) ->
336− Just . join . map extractGLinputs $ decls
343+ Just . foldl addGLinput emptyDecls . join . map extractGLinputs $ decls
337344 Left e -> Nothing
338345 where
346+ emptyDecls = GLShaderDecls Map.empty Map.empty Map.empty
347+ addGLinput = error "TODO"
339348 extractGLinputs decl = case decl of
340349 Declaration (InitDeclaration (TypeDeclarator (FullType (Just (TypeQualSto qual)) (TypeSpec _prec (TypeSpecNoPrecision tipe _mexpr1)))) [InitDecl name _mexpr2 _mexpr3]) ->
341350 if elem qual [Attribute, Varying, Uniform]
compiler/Type/Constrain/Expression.hs+3−1
@@ -42,7 +42,9 @@ constrain env (L span expr) tipe =
4242 GLShader _ src ->
4343 return . L span $ CEqual tipe (glTipe sourceTipe) where
4444 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"
4648
4749 Var name | name == saveEnvName -> return (L span CSaveEnv)
4850 | otherwise -> return (name <? tipe)