summaryrefslogtreecommitdiff
path: root/source/core
diff options
context:
space:
mode:
Diffstat (limited to 'source/core')
-rw-r--r--source/core/slang-type-text-util.cpp43
-rw-r--r--source/core/slang-type-text-util.h6
2 files changed, 49 insertions, 0 deletions
diff --git a/source/core/slang-type-text-util.cpp b/source/core/slang-type-text-util.cpp
index bfa193486..2ba3011d8 100644
--- a/source/core/slang-type-text-util.cpp
+++ b/source/core/slang-type-text-util.cpp
@@ -1,5 +1,6 @@
#include "slang-type-text-util.h"
+#include "slang-array-view.h"
#include "slang-string-util.h"
@@ -30,6 +31,14 @@ namespace Slang
x(nvrtc, NVRTC) \
x(llvm, LLVM)
+#define SLANG_DEBUG_INFO_FORMATS(x) \
+ x(default-format, DEFAULT) \
+ x(c7, C7) \
+ x(pdb, PDB) \
+ x(stabs, STABS) \
+ x(coff, COFF) \
+ x(dwarf, DWARF)
+
namespace { // anonymous
struct ScalarTypeInfo
@@ -109,6 +118,40 @@ static const ArchiveTypeInfo s_archiveTypeInfos[] =
return SLANG_ARCHIVE_TYPE_UNDEFINED;
}
+struct DebugInfoFormatTable
+{
+ UnownedStringSlice entries[SLANG_DEBUG_INFO_FORMAT_COUNT_OF];
+
+ static DebugInfoFormatTable _makeTable()
+ {
+ DebugInfoFormatTable dst;
+#define SLANG_DEBUG_INFO_FORMAT_ENTRY(name, value) \
+ dst.entries[SLANG_DEBUG_INFO_FORMAT_##value] = toSlice(#name);
+ SLANG_DEBUG_INFO_FORMATS(SLANG_DEBUG_INFO_FORMAT_ENTRY)
+ return dst;
+ }
+
+ static Index findIndex(const UnownedStringSlice slice) { return makeConstArrayView(table.entries).indexOf(slice); }
+ static UnownedStringSlice getSlice(SlangDebugInfoFormat format) { return table.entries[Index(format)]; }
+
+ static const DebugInfoFormatTable table;
+};
+
+/* static */const DebugInfoFormatTable DebugInfoFormatTable::table = DebugInfoFormatTable::_makeTable();
+
+/* static */SlangResult TypeTextUtil::findDebugInfoFormat(const Slang::UnownedStringSlice& text, SlangDebugInfoFormat& out)
+{
+ const auto index = DebugInfoFormatTable::findIndex(text);
+ if (index >= 0)
+ {
+ out = SlangDebugInfoFormat(index);
+ return SLANG_OK;
+ }
+ return SLANG_FAIL;
+}
+
+/* static */UnownedStringSlice TypeTextUtil::getDebugInfoFormatName(SlangDebugInfoFormat format) { return DebugInfoFormatTable::getSlice(format); }
+
/* static */UnownedStringSlice TypeTextUtil::getScalarTypeName(slang::TypeReflection::ScalarType scalarType)
{
typedef slang::TypeReflection::ScalarType ScalarType;
diff --git a/source/core/slang-type-text-util.h b/source/core/slang-type-text-util.h
index f5534ec72..df9b83013 100644
--- a/source/core/slang-type-text-util.h
+++ b/source/core/slang-type-text-util.h
@@ -18,6 +18,12 @@ struct TypeTextUtil
// Converts text to scalar type. Returns 'none' if not determined
static slang::TypeReflection::ScalarType findScalarType(const Slang::UnownedStringSlice& text);
+ /// Given a slice finds the associated debug info format
+ static SlangResult findDebugInfoFormat(const Slang::UnownedStringSlice& text, SlangDebugInfoFormat& out);
+
+ /// Get the text name for a format
+ static UnownedStringSlice getDebugInfoFormatName(SlangDebugInfoFormat format);
+
/// As human readable text
static UnownedStringSlice getPassThroughAsHumanText(SlangPassThrough type);
/// Gets pass through from human text (as from getPassThroughAsHumanText)