From 3485710e93d833a1c7b691af707cfd8962af7d17 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 17 Jul 2025 07:57:42 +0000 Subject: Merge NamePool and RootNamePool into a single type (#7797) * Initial plan * Merge NamePool and RootNamePool into single NamePool class Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Remove unnecessary comment from slang-fiddle-scrape.cpp Co-authored-by: Theresa Foley * Address review feedback: initialize namePool to nullptr and remove unnecessary comments Co-authored-by: Theresa Foley --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Theresa Foley Co-authored-by: Yong He --- .../slang-capability-generator/capability-generator-main.cpp | 2 -- tools/slang-cpp-parser/unit-test.cpp | 3 --- tools/slang-fiddle/slang-fiddle-main.cpp | 12 ++++++------ tools/slang-fiddle/slang-fiddle-scrape.cpp | 6 ++---- tools/slang-fiddle/slang-fiddle-scrape.h | 2 +- 5 files changed, 9 insertions(+), 16 deletions(-) (limited to 'tools') diff --git a/tools/slang-capability-generator/capability-generator-main.cpp b/tools/slang-capability-generator/capability-generator-main.cpp index f6202607a..56b615330 100644 --- a/tools/slang-capability-generator/capability-generator-main.cpp +++ b/tools/slang-capability-generator/capability-generator-main.cpp @@ -1326,8 +1326,6 @@ SlangResult parseDefFile( SourceView* sourceView = sourceManager->createSourceView(sourceFile, nullptr, SourceLoc()); Lexer lexer; NamePool namePool; - RootNamePool rootPool; - namePool.setRootNamePool(&rootPool); lexer.initialize(sourceView, sink, &namePool, sourceManager->getMemoryArena()); CapabilityDefParser parser(&lexer, sink, capabilitySharedContext); diff --git a/tools/slang-cpp-parser/unit-test.cpp b/tools/slang-cpp-parser/unit-test.cpp index 70851fd7c..41420578e 100644 --- a/tools/slang-cpp-parser/unit-test.cpp +++ b/tools/slang-cpp-parser/unit-test.cpp @@ -25,13 +25,10 @@ struct TestState m_sink.init(&m_sourceManager, Lexer::sourceLocationLexer); - m_namePool.setRootNamePool(&m_rootNamePool); - // We don't require marker m_options.m_requireMark = false; } - RootNamePool m_rootNamePool; Options m_options; SourceManager m_sourceManager; DiagnosticSink m_sink; diff --git a/tools/slang-fiddle/slang-fiddle-main.cpp b/tools/slang-fiddle/slang-fiddle-main.cpp index b85412454..cf8407995 100644 --- a/tools/slang-fiddle/slang-fiddle-main.cpp +++ b/tools/slang-fiddle/slang-fiddle-main.cpp @@ -42,12 +42,12 @@ public: struct App { public: - App(SourceManager& sourceManager, DiagnosticSink& sink, RootNamePool& rootNamePool) - : sourceManager(sourceManager), sink(sink), rootNamePool(rootNamePool) + App(SourceManager& sourceManager, DiagnosticSink& sink, NamePool& namePool) + : sourceManager(sourceManager), sink(sink), namePool(namePool) { } - RootNamePool& rootNamePool; + NamePool& namePool; SourceManager& sourceManager; DiagnosticSink& sink; @@ -61,7 +61,7 @@ public: return fiddle::parseSourceUnit( inputSourceView, logicalModule, - &rootNamePool, + &namePool, &sink, &sourceManager, outputFileName); @@ -409,7 +409,7 @@ int main(int argc, char const* const* argv) ComPtr writer(new FileWriter(stderr, WriterFlag::AutoFlush)); - RootNamePool rootNamePool; + NamePool namePool; SourceManager sourceManager; sourceManager.initialize(nullptr, nullptr); @@ -433,7 +433,7 @@ int main(int argc, char const* const* argv) try { - App app(sourceManager, sink, rootNamePool); + App app(sourceManager, sink, namePool); app.execute(argc, argv); } catch (...) diff --git a/tools/slang-fiddle/slang-fiddle-scrape.cpp b/tools/slang-fiddle/slang-fiddle-scrape.cpp index a96183130..c3b83527c 100644 --- a/tools/slang-fiddle/slang-fiddle-scrape.cpp +++ b/tools/slang-fiddle/slang-fiddle-scrape.cpp @@ -1602,20 +1602,18 @@ bool findOutputFileIncludeDirective(List tokens, String outputF RefPtr parseSourceUnit( SourceView* inputSourceView, LogicalModule* logicalModule, - RootNamePool* rootNamePool, + NamePool* namePool, DiagnosticSink* sink, SourceManager* sourceManager, String outputFileName) { Lexer lexer; - NamePool namePool; - namePool.setRootNamePool(rootNamePool); // We suppress any diagnostics that might get emitted during lexing, // so that we can ignore any files we don't understand. // DiagnosticSink lexerSink; - lexer.initialize(inputSourceView, &lexerSink, &namePool, sourceManager->getMemoryArena()); + lexer.initialize(inputSourceView, &lexerSink, namePool, sourceManager->getMemoryArena()); auto inputTokens = lexer.lexAllTokens(); auto tokensWithTrivia = collectTokensWithTrivia(inputTokens); diff --git a/tools/slang-fiddle/slang-fiddle-scrape.h b/tools/slang-fiddle/slang-fiddle-scrape.h index 050576674..098c11aad 100644 --- a/tools/slang-fiddle/slang-fiddle-scrape.h +++ b/tools/slang-fiddle/slang-fiddle-scrape.h @@ -350,7 +350,7 @@ T* findDecl(ContainerDecl* outerDecl, UnownedStringSlice const& name) RefPtr parseSourceUnit( SourceView* inputSourceView, LogicalModule* logicalModule, - RootNamePool* rootNamePool, + NamePool* namePool, DiagnosticSink* sink, SourceManager* sourceManager, String outputFileName); -- cgit v1.2.3