@@ -38,20 +38,15 @@ constrain env (L span expr) tipe =
3838 case expr of
3939 Literal lit -> liftIO $ Literal.constrain env span lit tipe
4040
41− GLShader _ src -> case declsRecord <$> PH.glSource src of
42− Nothing -> throwError [PP.text "Some sort of GLSL parse error"]
43− Just sourceTipe -> return . L span $ CEqual tipe (shaderTipe sourceTipe)
44− where
45− shaderTipe t = Env.get env Env.types "Graphics.WebGL.Shader" <| t
41+ GLShader uid src -> case PH.glSource src of
42+ Nothing -> throwError [PP.text $ "Some sort of GLSL parse error" ++ uid]
43+ Just sourceDecls -> return . L span $ CEqual tipe (shaderTipe attribute uniform varying)
44+ where
45+ shaderTipe a u v = Env.get env Env.types "Graphics.WebGL.Shader" <| a <| u <| v
4646 glTipe = Env.get env Env.types . PH.glTipeName
47− declsRecord :: PH.GLShaderDecls -> TermN Variable
48− declsRecord extractedTipes = record (fields' extractedTipes) (TermN EmptyRecord1)
49− fields' :: PH.GLShaderDecls -> Map.Map String [Type]
50− fields' extractedTipes = Map.fromList
51− [ ("attribute", [record (Map.map (\t -> [glTipe t]) $ PH.attribute extractedTipes) (TermN EmptyRecord1) ] )
52− , ("uniform", [record (Map.map (\t -> [glTipe t]) $ PH.uniform extractedTipes) (TermN EmptyRecord1) ] )
53− , ("varying", [record (Map.map (\t -> [glTipe t]) $ PH.varying extractedTipes) (TermN EmptyRecord1) ] )
54− ]
47+ attribute = record (Map.map (\t -> [glTipe t]) $ PH.attribute sourceDecls) (TermN EmptyRecord1)
48+ uniform = record (Map.map (\t -> [glTipe t]) $ PH.uniform sourceDecls) (TermN EmptyRecord1)
49+ varying = record (Map.map (\t -> [glTipe t]) $ PH.varying sourceDecls) (TermN EmptyRecord1)
5550
5651
5752 Var name | name == saveEnvName -> return (L span CSaveEnv)