diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-08-23 15:14:46 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-08-01 16:52:24 +0200 |
commit | d403dd2c9093703ee8910c16bb0ccb480d456704 (patch) | |
tree | 61ebb0741917955ad9b20c6d2c3f091476823102 /gcc/rust/rust-session-manager.cc | |
parent | 32e678b2ed752154b2f96719e33f11a7c6417f20 (diff) | |
download | gcc-d403dd2c9093703ee8910c16bb0ccb480d456704.zip gcc-d403dd2c9093703ee8910c16bb0ccb480d456704.tar.gz gcc-d403dd2c9093703ee8910c16bb0ccb480d456704.tar.bz2 |
gccrs: session-manager: Dump name resolution pass.
gcc/rust/ChangeLog:
* rust-session-manager.cc: Add files for dumping name resolution, call
name resolution dump function.
(Session::dump_name_resolution): New.
* rust-session-manager.h: New declaration.
Diffstat (limited to 'gcc/rust/rust-session-manager.cc')
-rw-r--r-- | gcc/rust/rust-session-manager.cc | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index 40adeb2..64e0190 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -69,6 +69,10 @@ const char *kASTDumpFile = "gccrs.ast.dump"; const char *kASTPrettyDumpFile = "gccrs.ast-pretty.dump"; const char *kASTPrettyDumpFileExpanded = "gccrs.ast-pretty-expanded.dump"; const char *kASTExpandedDumpFile = "gccrs.ast-expanded.dump"; +const char *kASTmacroResolutionDumpFile = "gccrs.ast-macro-resolution.dump"; +const char *kASTlabelResolutionDumpFile = "gccrs.ast-label-resolution.dump"; +const char *kASTtypeResolutionDumpFile = "gccrs.ast-type-resolution.dump"; +const char *kASTvalueResolutionDumpFile = "gccrs.ast-value-resolution.dump"; const char *kHIRDumpFile = "gccrs.hir.dump"; const char *kHIRPrettyDumpFile = "gccrs.hir-pretty.dump"; const char *kHIRTypeResolutionDumpFile = "gccrs.type-resolution.dump"; @@ -86,6 +90,7 @@ Session::get_instance () static std::string infer_crate_name (const std::string &filename) + { if (filename == "-") return kDefaultCrateName; @@ -626,9 +631,7 @@ Session::compile_crate (const char *filename) Resolver::NameResolution::Resolve (parsed_crate); if (options.dump_option_enabled (CompileOptions::RESOLUTION_DUMP)) - { - // TODO: what do I dump here? resolved names? AST with resolved names? - } + dump_name_resolution (name_resolution_ctx); if (saw_errors ()) return; @@ -983,6 +986,27 @@ Session::dump_ast_pretty (AST::Crate &crate, bool expanded) const } void +Session::dump_name_resolution (Resolver2_0::NameResolutionContext &ctx) const +{ + // YES this is ugly but NO GCC 4.8 does not allow us to make it fancier :( + std::string types_content = ctx.types.as_debug_string (); + std::ofstream types_stream{kASTtypeResolutionDumpFile}; + types_stream << types_content; + + std::string macros_content = ctx.macros.as_debug_string (); + std::ofstream macros_stream{kASTmacroResolutionDumpFile}; + macros_stream << macros_content; + + std::string labels_content = ctx.labels.as_debug_string (); + std::ofstream labels_stream{kASTlabelResolutionDumpFile}; + labels_stream << labels_content; + + std::string values_content = ctx.values.as_debug_string (); + std::ofstream values_stream{kASTvalueResolutionDumpFile}; + values_stream << values_content; +} + +void Session::dump_hir (HIR::Crate &crate) const { std::ofstream out; |