From 879ec1b385d290a4375682ec613a9e7a1967fc7d Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 10 Oct 2018 13:56:25 -0400 Subject: Feature/source loc refactor (#668) * * Remove the need for IRHighLevelDecoration in Emit * Use the IRLayoutDecoration for GeometryShaderPrimitiveTypeModifier * Initial look at at variable byte encoding, and simple unit test. * Fixing problems with comparison due to naming differences with slang/fxc. * * More tests and perf improvements for byte encoding. * Mechanism to detect processor and processor features in main slang header. * Split out cpu based defines into slang-cpu-defines.h so do not polute slang.h * Support for variable byte encoding on serialization. * Removed unused flag. * Fix warning. * Fix calcMsByte32 for 0 values without using intrinsic. * Fix a mistake in calculating maximum instruction size. * Introduced the idea of SourceUnit. * Small improvements around naming. Add more functionality - including getting the HumaneLoc. * Add support for #line default * Compiling with new SourceLoc handling. * Fix off by one on #line directives. * Can use 32bits for SourceLoc. Fix serialize to use that. * Small fixes and comment on usage. * Premake run. * Fix signed warning. * Fix typo on StringSlicePool::has found in review. --- source/core/slang-string-slice-pool.h | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 source/core/slang-string-slice-pool.h (limited to 'source/core/slang-string-slice-pool.h') diff --git a/source/core/slang-string-slice-pool.h b/source/core/slang-string-slice-pool.h new file mode 100644 index 000000000..e6846b3dd --- /dev/null +++ b/source/core/slang-string-slice-pool.h @@ -0,0 +1,50 @@ +#ifndef SLANG_STRING_SLICE_POOL_H +#define SLANG_STRING_SLICE_POOL_H + +#include "slang-string.h" + +#include "list.h" +#include "slang-memory-arena.h" +#include "dictionary.h" + +namespace Slang { + +class StringSlicePool +{ +public: + /// Handle of 0 is null. If accessed will be returned as the empty string + enum class Handle : uint32_t; + typedef UnownedStringSlice Slice; + + /// Returns the index of a slice, if contained, or -1 if not found + int findIndex(const Slice& slice) const; + + /// True if has the slice + bool has(const Slice& slice) { return findIndex(slice) >= 0; } + /// Add a slice + Handle add(const Slice& slice); + + /// Empty contents + void clear(); + + /// Get the slice from the handle + const UnownedStringSlice& getSlice(Handle handle) const { return m_slices[UInt(handle)]; } + + /// Get all the slices + const List& getSlices() const { return m_slices; } + + /// Convert a handle to and index. (A handle is just an index!) + static int asIndex(Handle handle) { return int(handle); } + + /// Ctor + StringSlicePool(); + +protected: + List m_slices; + Dictionary m_map; + MemoryArena m_arena; +}; + +} // namespace Slang + +#endif // SLANG_STRING_SLICE_POOL_H -- cgit v1.2.3