Skip to content

Commit 92884fa

Browse files
authored
Merge pull request flang-compiler#979 from flang-compiler/ps-dev-story
Updated the description of `evaluate::Expr` types
2 parents 204c67d + 75adddd commit 92884fa

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

documentation/ImplementingASemanticCheck.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,22 +214,21 @@ existing framework used in DO construct semantic checking that traversed an
214214
be able to use a similar framework to traverse an `evaluate::Expr` node to
215215
find all of the `evaluate::ActualArgument` nodes.
216216

217-
Note that there are two distinct data types in the compiler called `Expr`. One
218-
is in the `parser` namespace. `parser::Expr` is defined in the file
217+
Note that the compiler has multiple types called `Expr`. One is in the
218+
`parser` namespace. `parser::Expr` is defined in the file
219219
`include/flang/parser/parse-tree.h`. It represents a parsed expression that
220220
maps directly to the source code and has fields that specify any operators in
221221
the expression, the operands, and the source position of the expression.
222222

223-
The second `Expr` type is in the `evaluate` namespace. The `evaluate`
224-
namespace contains many types associated with semantic checking of expressions.
225-
`evaluate::Expr` is defined in the file `include/flang/evaluate/expression.h`.
226-
It represents an expression after it has undergone semantic checking and
227-
contains information that is only available after semantic analysis. This
228-
information includes the Fortran type of the expression, whether it's a
229-
reference to a function, whether it's an actual argument, etc. After an
230-
expression has undergone semantic analysis, the field `typedExpr` in the
231-
`parser::Expr` node is filled in with a pointer to the analyzed expression in
232-
`evaluate::Expr`.
223+
Additionally, in the namespace `evaluate`, there are `evaluate::Expr<T>`
224+
template classes defined in the file `include/flang/evaluate/expression.h`.
225+
These are parameterized over the various types of Fortran and constitute a
226+
suite of strongly-typed representations of valid Fortran expressions of type
227+
`T` that have been fully elaborated with conversion operations and subjected to
228+
constant folding. After an expression has undergone semantic analysis, the
229+
field `typedExpr` in the `parser::Expr` node is filled in with a pointer that
230+
owns an instance of `evaluate::Expr<SomeType>`, the most general representation
231+
of an analyzed expression.
233232

234233
All of the declarations associated with both FUNCTION and SUBROUTINE calls are
235234
in `include/flang/evaluate/call.h`. An `evaluate::FunctionRef` inherits from

0 commit comments

Comments
 (0)