diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2018-10-10 13:56:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-10 13:56:25 -0400 |
| commit | 879ec1b385d290a4375682ec613a9e7a1967fc7d (patch) | |
| tree | 0d5f32d83d45458db54cce281c0c6331a677cdff /source/core/slang-string-slice-pool.h | |
| parent | 60a91d63afab47a172690974c8b566af74072932 (diff) | |
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.
Diffstat (limited to 'source/core/slang-string-slice-pool.h')
| -rw-r--r-- | source/core/slang-string-slice-pool.h | 50 |
1 files changed, 50 insertions, 0 deletions
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<UnownedStringSlice>& 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<UnownedStringSlice> m_slices; + Dictionary<UnownedStringSlice, int> m_map; + MemoryArena m_arena; +}; + +} // namespace Slang + +#endif // SLANG_STRING_SLICE_POOL_H |
