From 778428fecc0548af565e92745cf1344bcf19367f Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 19 Apr 2021 15:39:42 -0400 Subject: Splitting up C++ extractor (#1800) * #include an absolute path didn't work - because paths were taken to always be relative. * Refactor out ClassLikeNode * WIP around ScopeNode. * Use push and popScope. * Small improvements around C++ extractor. * Adding dynamic casting support. * Made Field another Node type. * Disable command line dumping by default. * Removed comment. * Fix shadowed variable bug found on linux. * Split out node. * Renamed C++ extractor diagnostics to just diagnostics.cpp/.h * Remove C++ extractor Options into separate options.cpp/options.h files. * Split out parser and identifier lookup from C++ extractor. * Put in CppExtract namespace. Simplify some of the class names. * Some simple renaming. * Split out NodeTree from Parser. --- tools/slang-cpp-extractor/identifier-lookup.cpp | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tools/slang-cpp-extractor/identifier-lookup.cpp (limited to 'tools/slang-cpp-extractor/identifier-lookup.cpp') diff --git a/tools/slang-cpp-extractor/identifier-lookup.cpp b/tools/slang-cpp-extractor/identifier-lookup.cpp new file mode 100644 index 000000000..07f155248 --- /dev/null +++ b/tools/slang-cpp-extractor/identifier-lookup.cpp @@ -0,0 +1,48 @@ +#include "identifier-lookup.h" + +namespace CppExtract { +using namespace Slang; + +/* static */const IdentifierFlags IdentifierLookup::kIdentifierFlags[Index(IdentifierStyle::CountOf)] = +{ + 0, /// None + 0, /// Identifier + 0, /// Declare type + 0, /// Type set + IdentifierFlag::Keyword, /// TypeModifier + IdentifierFlag::Keyword, /// Keyword + IdentifierFlag::Keyword | IdentifierFlag::StartScope | IdentifierFlag::ClassLike, /// Class + IdentifierFlag::Keyword | IdentifierFlag::StartScope | IdentifierFlag::ClassLike, /// Struct + IdentifierFlag::Keyword | IdentifierFlag::StartScope, /// Namespace + IdentifierFlag::Keyword, /// Access + IdentifierFlag::Reflection, /// Reflected + IdentifierFlag::Reflection, /// Unreflected +}; + + +void IdentifierLookup::set(const UnownedStringSlice& name, IdentifierStyle style) +{ + StringSlicePool::Handle handle; + if (m_pool.findOrAdd(name, handle)) + { + // Add the extra flags + m_styles[Index(handle)] = style; + } + else + { + Index index = Index(handle); + SLANG_ASSERT(index == m_styles.getCount()); + m_styles.add(style); + } +} + +void IdentifierLookup::set(const char*const* names, size_t namesCount, IdentifierStyle style) +{ + for (size_t i = 0; i < namesCount; ++i) + { + set(UnownedStringSlice(names[i]), style); + } +} + + +} // namespace CppExtract -- cgit v1.2.3