@@ -15,8 +15,10 @@ import qualified AST.Variable as Var
1515import qualified Reporting.Annotation as A
1616
1717
18+
1819---- GENERAL AST ----
1920
21+
2022{-| This is a fully general Abstract Syntax Tree (AST) for expressions. It has
2123"type holes" that allow us to enrich the AST with additional information as we
2224move through the compilation process. The type holes are used to represent:
@@ -56,8 +58,10 @@ data Expr' ann def var typ
5658 | GLShader String String Literal.GLShaderTipe
5759
5860
61+
5962-- PORTS
6063
64+
6165data PortImpl expr tipe
6266 = In String (Type.Port tipe)
6367 | Out String expr (Type.Port tipe)
@@ -73,8 +77,10 @@ portName impl =
7377 Task name _ _ -> name
7478
7579
80+
7681---- UTILITIES ----
7782
83+
7884rawVar :: String -> Expr' ann def Var.Raw typ
7985rawVar x =
8086 Var (Var.Raw x)
@@ -97,28 +103,31 @@ saveEnvName =
97103
98104dummyLet :: [def] -> Expr ann def Var.Canonical typ
99105dummyLet defs =
100− let body =
101− A.A undefined (Var (Var.builtin saveEnvName))
106+ let
107+ body =
108+ A.A undefined (Var (Var.builtin saveEnvName))
102109 in
103− A.A undefined (Let defs body)
110+ A.A undefined (Let defs body)
104111
105112
106113collectApps :: Expr ann def var typ -> [Expr ann def var typ]
107114collectApps annExpr@(A.A _ expr) =
108115 case expr of
109− App a b -> collectApps a ++ [b]
110− _ -> [annExpr]
116+ App a b ->
117+ collectApps a ++ [b]
118+
119+ _ ->
120+ [annExpr]
111121
112122
113−collectLambdas
114− :: Expr ann def var typ
115− -> ([Pattern.Pattern ann var], Expr ann def var typ)
123+collectLambdas :: Expr ann def var typ -> ([Pattern.Pattern ann var], Expr ann def var typ)
116124collectLambdas lexpr@(A.A _ expr) =
117125 case expr of
118126 Lambda pattern body ->
119− let
120− (ps, body') = collectLambdas body
121− in
122− (pattern : ps, body')
127+ let
128+ (ps, body') = collectLambdas body
129+ in
130+ (pattern : ps, body')
123131
124− _ -> ([], lexpr)
132+ _ ->
133+ ([], lexpr)