11 | ||| A data constructor. Use the tag to dispatch / construct.
12 | ||| Here the Name is only for documentation purposes and should not
13 | ||| be used.
15 | ||| A type constructor. We do not have a unique tag associated to types
16 | ||| and so we match on names instead.
19 | ||| A variable in a toplevel function definition
20 | |||
21 | ||| When generating the syntax tree of imperative
22 | ||| statements and expressions, we decide - based on
23 | ||| codegen directives - which Idris names to keep
24 | ||| and which names to convert to short, mangled
25 | ||| versions.
28 | ||| An unaltered name - usually a toplevel function
29 | ||| or a function argument with an explicitly given
30 | ||| name
33 | ||| Index of a local variables
36 | ||| Index of a mangled toplevel function
39 | ||| A minimal expression.
42 | ||| A variable
45 | ||| A projection targeting the field of a data type.
46 | ||| We include these here since it allows us to
47 | ||| conveniently carry around a `SortedMap Name Minimal`
48 | ||| for name resolution during the generation of the
49 | ||| imperative syntax tree.
52 | --------------------------------------------------------------------------------
53 | -- Expressions
54 | --------------------------------------------------------------------------------
56 | ||| The effect of a statement or a block of statements.
57 | ||| `Returns` means the
58 | ||| result of the final expression will be returned as
59 | ||| the current function's result, while `ErrorWithout v`
60 | ||| is a reminder, that the block of code will eventually
61 | ||| assign a value to `v` and will fail to do so if
62 | ||| `v` hasn't previously been declared.
63 | |||
64 | ||| This is used as a typelevel index to prevent us from
65 | ||| making some common stupid errors like declaring a variable
66 | ||| twice, or having several `return` statements in the same
67 | ||| block of code.
71 | mutual
72 | ||| An expression in a function definition.
75 | ||| A variable or projection. Minimal expressions
76 | ||| will always be inlined unless explicitly bound
77 | ||| in an Idris2 `let` expression.
80 | ||| Lambda expression
81 | |||
82 | ||| An empty argument list represents a delayed computation
85 | ||| Function application.
86 | |||
87 | ||| In case of a zero-argument list, we might also be
88 | ||| dealing with forcing a delayed computation.
91 | ||| Saturated construtor application.
92 | |||
93 | ||| The tag either represents the name of a type constructor
94 | ||| (when we are pattern matching on types) or the index
95 | ||| of a data constructor.
98 | ||| Primitive operation
101 | ||| Externally defined primitive operation.
104 | ||| A constant primitive.
107 | ||| An erased value.
110 | ||| An imperative statement in a function definition.
111 | |||
112 | ||| This is indexed over the `Effect` the statement,
113 | ||| will have.
114 | ||| An `effect` of `Nothing` means that the result of
115 | ||| the statement is `undefined`: The declaration of
116 | ||| a constant or assignment of a previously declared
117 | ||| variable. When we sequence statements in a block
118 | ||| of code, all but the last one of them must have
119 | ||| effect `Nothing`. This makes sure we properly declare variables
120 | ||| exactly once before eventually assigning them.
121 | ||| It makes also sure a block of code does not contain
122 | ||| several `return` statements (until they are the
123 | ||| results of the branches of a `switch` statement).
126 | ||| Returns the result of the given expression.
129 | ||| Introduces a new constant by assigning the result
130 | ||| of a single expression to the given variable.
133 | ||| Assigns the result of an expression to the given variable.
134 | ||| This will result in an error, if the variable has not
135 | ||| yet been declared.
138 | ||| Declares (but does not yet assign) a new mutable
139 | ||| variable. This is the only way to "saturate"
140 | ||| a `Stmt (Just $ ErrorWithout v)`.
143 | ||| Switch statement from a pattern match on
144 | ||| data or type constructors. The result of each branch
145 | ||| will have the given `Effect`.
146 | |||
147 | ||| The scrutinee has already been lifted to
148 | ||| the outer scope to make sure it is only
149 | ||| evaluated once.
156 | ||| Switch statement from a pattern on
157 | ||| a constant. The result of each branch
158 | ||| will have the given `Effect`.
165 | ||| A runtime exception.
168 | ||| A code block consisting of one or more
169 | ||| imperative statements.
172 | ||| Single branch in a pattern match on a data or
173 | ||| type constructor.
181 | ||| Single branch in a pattern match on a constant
188 | export
193 | export