@@ -15,8 +15,10 @@ import qualified AST.Variable as Var
15import qualified Reporting.Annotation as A
15import qualified Reporting.Annotation as A
18---- GENERAL AST ----
19---- GENERAL AST ----
20{-| This is a fully general Abstract Syntax Tree (AST) for expressions. It has
22{-| This is a fully general Abstract Syntax Tree (AST) for expressions. It has
21"type holes" that allow us to enrich the AST with additional information as we
23"type holes" that allow us to enrich the AST with additional information as we
22move through the compilation process. The type holes are used to represent:
24move through the compilation process. The type holes are used to represent:
@@ -56,8 +58,10 @@ data Expr' ann def var typ
56 | GLShader String String Literal.GLShaderTipe
58 | GLShader String String Literal.GLShaderTipe
61data PortImpl expr tipe
65data PortImpl expr tipe
62 = In String (Type.Port tipe)
66 = In String (Type.Port tipe)
63 | Out String expr (Type.Port tipe)
67 | Out String expr (Type.Port tipe)
@@ -73,8 +77,10 @@ portName impl =
73 Task name _ _ -> name
77 Task name _ _ -> name
76---- UTILITIES ----
81---- UTILITIES ----
78rawVar :: String -> Expr' ann def Var.Raw typ
84rawVar :: String -> Expr' ann def Var.Raw typ
80 Var (Var.Raw x)
86 Var (Var.Raw x)
@@ -97,28 +103,31 @@ saveEnvName =
98dummyLet :: [def] -> Expr ann def Var.Canonical typ
104dummyLet :: [def] -> Expr ann def Var.Canonical typ
99dummyLet defs =
105dummyLet defs =
100− let body =
107+ body =
101− A.A undefined (Var (Var.builtin saveEnvName))
108+ A.A undefined (Var (Var.builtin saveEnvName))
103− A.A undefined (Let defs body)
110+ A.A undefined (Let defs body)
106collectApps :: Expr ann def var typ -> [Expr ann def var typ]
113collectApps :: Expr ann def var typ -> [Expr ann def var typ]
107collectApps annExpr@(A.A _ expr) =
114collectApps annExpr@(A.A _ expr) =
108 case expr of
115 case expr of
109− App a b -> collectApps a ++ [b]
117+ collectApps a ++ [b]
110− _ -> [annExpr]
120+ [annExpr]
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)
116collectLambdas lexpr@(A.A _ expr) =
124collectLambdas lexpr@(A.A _ expr) =
117 case expr of
125 case expr of
118 Lambda pattern body ->
126 Lambda pattern body ->
120− (ps, body') = collectLambdas body
128+ (ps, body') = collectLambdas body
122− (pattern : ps, body')
130+ (pattern : ps, body')
124− _ -> ([], lexpr)
133+ ([], lexpr)