89840b5087
When `-fdebug-dump-symbols` is supplied with `-funparse`, include symbol information in comments in the Fortran output. This will be used for testing to verify that correct symbols are defined and references in the right place. In `UnparseWithSymbols()`, walk the parse tree and collect symbol definitions and references, organized by statement. When a symbol is defined across several statement it is associated with the first. The definition of implicitly defined symbols is associated with the first reference. To write out the symbol information, a new optional argument is added to `Unparse()`: it is a function that is called immediately before each statement is unparsed. We pass in a function that prints out the symbol information collected for that statement. Add `Symbol::GetType()` to make it easier to write the symbol types and add `Symbol::SetType()` for uniformity. Original-commit: flang-compiler/f18@2e827de4ad Reviewed-on: https://github.com/flang-compiler/f18/pull/112 Tree-same-pre-rewrite: false
30 lines
1.1 KiB
C++
30 lines
1.1 KiB
C++
// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#ifndef FORTRAN_SEMANTICS_UNPARSE_WITH_SYMBOLS_H_
|
|
#define FORTRAN_SEMANTICS_UNPARSE_WITH_SYMBOLS_H_
|
|
|
|
#include "../parser/characters.h"
|
|
#include <iosfwd>
|
|
|
|
namespace Fortran::parser {
|
|
struct Program;
|
|
} // namespace Fortran::parser
|
|
|
|
namespace Fortran::semantics {
|
|
void UnparseWithSymbols(std::ostream &, const parser::Program &,
|
|
parser::Encoding encoding = parser::Encoding::UTF8);
|
|
} // namespace Fortran::semantics
|
|
|
|
#endif // FORTRAN_SEMANTICS_UNPARSE_WITH_SYMBOLS_H_
|