Commit graph

10 commits

Author SHA1 Message Date
Tim Keith
a3de9d789c [flang] Partial implementation of Symbols and Scopes.
A Symbol consists of a common part (in class Symbol) containing name,
owner, attributes. Information for a specific kind of symbol is in a
variant containing one of the *Details classes. So the kind of symbol is
determined by the type of details class stored in the details_ variant.

For scopes there is a single Scope class with an enum indicating the
kind. So far there isn't a need for extra kind-specific details as with
Symbols but that could change. Symbols defined in a Scope are stored
there in a simple map.

resolve-names.cc is a partial implementation of a parse-tree walker that
resolves names to Symbols. Currently is only handles functions (which
introduce a new Scope) and entity-decls. The test-type executable was
reused as a driver for this to avoid the need for a new one.

Sample output is below. When each "end function" is encountered the
scope is dumped, which shows the symbols defined in it.

$ cat a.f90
pure integer(8) function foo(arg1, arg2) result(res)
  integer :: arg1
  real :: arg2
contains
  function bar(arg1)
    real :: bar
    real :: arg1
  end function
end function

$ Debug/tools/f18/test-type a.f90
Subprogram scope: 0 children
  arg1:  Entity type: REAL
  bar:  Entity type: REAL
Subprogram scope: 1 children
  arg1:  Entity type: INTEGER
  arg2:  Entity type: REAL
  bar:  Subprogram (arg1)
  foo:  Subprogram (arg1, arg2) result(res)
  res:  Entity type: INTEGER(8)

Original-commit: flang-compiler/f18@1cd2fbc04d
Reviewed-on: https://github.com/flang-compiler/f18/pull/30
Tree-same-pre-rewrite: false
2018-03-22 17:25:34 -07:00
peter klausler
79d044e9b5 [flang] Take flang-compiler/f18#2 on unparsing, now using the new parse tree walker.
Clean out old data structure formatter.

Create stand-alone Parsing class to compose parts of the parser together.

Hello, world!

Better error recovery on command line errors.

Fix bugs from initial run at f77_correct.

Allow parentheses on PROGRAM statement.

Fix Hollerith scanning.

Remove REDIMENSION with good error recovery.

Fix new "spaces" parser, clean up calls to it.

Fix bugs exposed by in38.f90.

Escaped \a is not special to pgf90; get slashes around STRUCTURE name right.

Better multi-byte source encoding support in Hollerith.

Reformat C++.

More work on multi-byte source encoding.

Pass 219 tests in f77_correct, with good excuses for the rest.

Original-commit: flang-compiler/f18@8a1a0aa2dc
Reviewed-on: https://github.com/flang-compiler/f18/pull/25
Tree-same-pre-rewrite: false
2018-03-13 16:32:09 -07:00
Tim Keith
01580dd19a [flang] Replace raw pointers with std::unique_ptr.
This simplifies the "delete and set to null" pattern to just a call to
reset(), and "assign and set to null" to a call to std::move.

The ideal would be a custom deleter that throws an error when an
implicit delete happens but not when reset() is called, but I'm not sure
that's possible.

Original-commit: flang-compiler/f18@f618fc729a
Reviewed-on: https://github.com/flang-compiler/f18/pull/23
2018-03-01 18:04:05 -08:00
Tim Keith
600788e5f7 [flang] Add MakeTypes to build types using visitor.
This replaces the manual walking code in test-type.cc. It walks the
parse tree and constructs DeclTypeSpec and DerivedTypeDef objects for
each type encountered. It's in a new file, make-types.cc, so that
failing compilations complete faster.

Handle more parts of derived type definitions.

Also some minor cleanups in type.h and type.cc.

Original-commit: flang-compiler/f18@859e7e2665
Reviewed-on: https://github.com/flang-compiler/f18/pull/23
Tree-same-pre-rewrite: false
2018-03-01 15:24:35 -08:00
Stephane Chauveau
8f6f23fc54 [flang] Add simple recursive CMake directory structure
Original-commit: flang-compiler/f18@a021b2ca76
Reviewed-on: https://github.com/flang-compiler/f18/pull/13
Tree-same-pre-rewrite: false
2018-02-19 14:28:12 +01:00
Tim Keith
4a735b61c6 [flang] Rename methods with uppercase names.
Original-commit: flang-compiler/f18@00fec54e5a
Reviewed-on: https://github.com/flang-compiler/f18/pull/8
2018-02-15 08:27:19 -08:00
Tim Keith
cbd894be78 [flang] Continue adding to type.h
New classes: Bound, DeclTypeSpec, ShapeSpec, ComponentArraySpec,
DataComponentDef, ProcDecl, ProcComponentDef, DerivedTypedef

Original-commit: flang-compiler/f18@a09d1e8c81
Reviewed-on: https://github.com/flang-compiler/f18/pull/8
Tree-same-pre-rewrite: false
2018-02-14 15:24:02 -08:00
Tim Keith
6c168650b7 [flang] Add Attrs class to represent set of Attr
Original-commit: flang-compiler/f18@8bb1f0eb9b
Reviewed-on: https://github.com/flang-compiler/f18/pull/8
Tree-same-pre-rewrite: false
2018-02-14 15:07:59 -08:00
Tim Keith
c0d92ef566 [flang] Clean up Makefile, add reformat target.
Now the only targets in Makefile are Debug, Release, and reformat.
"make reformat" reformats all C++ source in place.

Also includes the result of "make reformat". Most of the changes were
just moving the "main" include up.

Original-commit: flang-compiler/f18@cf7d3a7afb
2018-02-07 16:27:36 -08:00
Tim Keith
e065e5b510 [flang] Move type.{h,cc} and attr.{h,cc}
The are now in new namespace and directory, "semantics", similar to
"parser".

Original-commit: flang-compiler/f18@115a1341e2
Reviewed-on: https://github.com/flang-compiler/f18/pull/5
2018-02-07 15:54:07 -08:00