summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-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
-rw-r--r--source/slang/core.meta.slang11
4 files changed, 35 insertions, 14 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);
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang
index 9fecc7661..a60da422c 100644
--- a/source/slang/core.meta.slang
+++ b/source/slang/core.meta.slang
@@ -1914,12 +1914,19 @@ ${{{{
}}}}
-
// Specialized function
__intrinsic_op
int getStringHash(String string);
+// Use will produce a syntax error in downstream compiler
+// Useful for testing diagnostics around compilation errors of downstream compiler
+__target_intrinsic(hlsl, " @ ")
+__target_intrinsic(glsl, " @ ")
+__target_intrinsic(cuda, " @ ")
+__target_intrinsic(cpp, " @ ")
+void __SyntaxError();
+
// Operators to apply to `enum` types
__generic<E : __EnumType>
@@ -2084,4 +2091,4 @@ __attributeTarget(DeclBase)
attribute_syntax [__requiresNVAPI] : RequiresNVAPIAttribute;
__attributeTarget(FunctionDeclBase)
-attribute_syntax [noinline] : NoInlineAttribute; \ No newline at end of file
+attribute_syntax [noinline] : NoInlineAttribute;