summaryrefslogtreecommitdiffstats
path: root/source/core
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-02-02 17:45:56 -0500
committerGitHub <noreply@github.com>2021-02-02 14:45:56 -0800
commit17d2b2492d42e54ea4e0d907b4d84aa17f4a6f33 (patch)
treebdcc4b0aba860139a011ca052e505b9202c6152c /source/core
parent5d755e584ff6c241f42204430e005b26314ed594 (diff)
Downstream compiler line number test (#1682)
* #include an absolute path didn't work - because paths were taken to always be relative. * WIP diagnostics for line number output. * Small param naming change * Use x macro for pass through compile human name lookup/getting. * WIP on parsing downstream compiler output. * Split out parsing into ParseDiagnosticUtil. Added test result of single line. * Dump out the std output on fail to parse diagnostics. * Change test type for syntax-error-intrinsic.slang be TEST not TEST_DIAGNOSTIC
Diffstat (limited to 'source/core')
-rw-r--r--source/core/slang-string-util.cpp6
-rw-r--r--source/core/slang-type-text-util.cpp30
-rw-r--r--source/core/slang-type-text-util.h2
3 files changed, 26 insertions, 12 deletions
diff --git a/source/core/slang-string-util.cpp b/source/core/slang-string-util.cpp
index 326bc3191..a859c6945 100644
--- a/source/core/slang-string-util.cpp
+++ b/source/core/slang-string-util.cpp
@@ -32,9 +32,9 @@ namespace Slang {
return areAllEqual(slicesA, slicesB, equalFn);
}
-/* static */void StringUtil::split(const UnownedStringSlice& in, char splitChar, List<UnownedStringSlice>& slicesOut)
+/* static */void StringUtil::split(const UnownedStringSlice& in, char splitChar, List<UnownedStringSlice>& outSlices)
{
- slicesOut.clear();
+ outSlices.clear();
const char* start = in.begin();
const char* end = in.end();
@@ -49,7 +49,7 @@ namespace Slang {
}
// Add to output
- slicesOut.add(UnownedStringSlice(start, cur));
+ outSlices.add(UnownedStringSlice(start, cur));
// Skip the split character, if at end we are okay anyway
start = cur + 1;
diff --git a/source/core/slang-type-text-util.cpp b/source/core/slang-type-text-util.cpp
index 80ef0027f..89cd4504b 100644
--- a/source/core/slang-type-text-util.cpp
+++ b/source/core/slang-type-text-util.cpp
@@ -128,22 +128,34 @@ static const ArchiveTypeInfo s_archiveTypeInfos[] =
return slang::TypeReflection::ScalarType::None;
}
+#define SLANG_PASS_THROUGH_HUMAN_TEXT(x) \
+ x(NONE, "Unknown") \
+ x(VISUAL_STUDIO, "Visual Studio") \
+ x(GCC, "GCC") \
+ x(CLANG, "Clang") \
+ x(NVRTC, "NVRTC") \
+ x(FXC, "fxc") \
+ x(DXC, "dxc") \
+ x(GLSLANG, "glslang")
+
/* static */UnownedStringSlice TypeTextUtil::getPassThroughAsHumanText(SlangPassThrough type)
{
+#define SLANG_PASS_THROUGH_HUMAN_CASE(value, text) case SLANG_PASS_THROUGH_##value: return UnownedStringSlice::fromLiteral(text);
+
switch (type)
{
- default:
- case SLANG_PASS_THROUGH_NONE: return UnownedStringSlice::fromLiteral("Unknown");
- case SLANG_PASS_THROUGH_VISUAL_STUDIO: return UnownedStringSlice::fromLiteral("Visual Studio");
- case SLANG_PASS_THROUGH_GCC: return UnownedStringSlice::fromLiteral("GCC");
- case SLANG_PASS_THROUGH_CLANG: return UnownedStringSlice::fromLiteral("Clang");
- case SLANG_PASS_THROUGH_NVRTC: return UnownedStringSlice::fromLiteral("NVRTC");
- case SLANG_PASS_THROUGH_FXC: return UnownedStringSlice::fromLiteral("fxc");
- case SLANG_PASS_THROUGH_DXC: return UnownedStringSlice::fromLiteral("dxc");
- case SLANG_PASS_THROUGH_GLSLANG: return UnownedStringSlice::fromLiteral("glslang");
+ default: /* fall-through to none */
+ SLANG_PASS_THROUGH_HUMAN_TEXT(SLANG_PASS_THROUGH_HUMAN_CASE)
}
}
+/* static */SlangResult TypeTextUtil::findPassThroughFromHumanText(const UnownedStringSlice& inText, SlangPassThrough& outPassThrough)
+{
+ #define SLANG_PASS_THROUGH_HUMAN_IF(value, text) if (inText == UnownedStringSlice::fromLiteral(text)) { outPassThrough = SLANG_PASS_THROUGH_##value; return SLANG_OK; } else
+ SLANG_PASS_THROUGH_HUMAN_TEXT(SLANG_PASS_THROUGH_HUMAN_IF)
+ return SLANG_FAIL;
+}
+
/* static */SlangSourceLanguage TypeTextUtil::findSourceLanguage(const UnownedStringSlice& text)
{
if (text == "c" || text == "C")
diff --git a/source/core/slang-type-text-util.h b/source/core/slang-type-text-util.h
index 07426246e..f5534ec72 100644
--- a/source/core/slang-type-text-util.h
+++ b/source/core/slang-type-text-util.h
@@ -20,6 +20,8 @@ struct TypeTextUtil
/// As human readable text
static UnownedStringSlice getPassThroughAsHumanText(SlangPassThrough type);
+ /// Gets pass through from human text (as from getPassThroughAsHumanText)
+ static SlangResult findPassThroughFromHumanText(const UnownedStringSlice& text, SlangPassThrough& outPassThrough);
/// Given a source language name returns a source language. Name here is distinct from extension
static SlangSourceLanguage findSourceLanguage(const UnownedStringSlice& text);