summaryrefslogtreecommitdiffstats
path: root/source/compiler-core/slang-command-line-args.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-02-20 12:24:00 -0800
committerGitHub <noreply@github.com>2024-02-20 12:24:00 -0800
commit4d20fd329956ac89408b1628a8291fea01bc9a6d (patch)
tree8e62d9c1ec05142fd25d0b31073fdb56d44691b0 /source/compiler-core/slang-command-line-args.cpp
parent8e9b61e3bac69dbb37a1451b62302e688a017ced (diff)
Refactor compiler option representations. (#3598)
* Refactor compiler option representation. * Fix binary compatibility. * Add a test for specifying compiler options at link time. * Fix binary compatibility. * Fix binary compatibility. * Fix backward compatibility on matrix layout. * Fix. * Fix. * Fix. * Fix gfx. * Fix gfx. * Fix dynamic dispatch. * Polish.
Diffstat (limited to 'source/compiler-core/slang-command-line-args.cpp')
-rw-r--r--source/compiler-core/slang-command-line-args.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/source/compiler-core/slang-command-line-args.cpp b/source/compiler-core/slang-command-line-args.cpp
index 813d2dd26..b69836030 100644
--- a/source/compiler-core/slang-command-line-args.cpp
+++ b/source/compiler-core/slang-command-line-args.cpp
@@ -2,7 +2,8 @@
#include "../core/slang-process-util.h"
#include "../core/slang-string-escape-util.h"
-
+#include "../core/slang-string-util.h"
+#include "../core/slang-type-text-util.h"
#include "slang-core-diagnostics.h"
namespace Slang {
@@ -63,6 +64,27 @@ bool CommandLineArgs::hasArgs(const char*const* args, Index count) const
return true;
}
+String CommandLineArgs::serialize()
+{
+ StringBuilder sb;
+ for (auto& arg : m_args)
+ sb << arg.value << "\n";
+ return sb.produceString();
+}
+
+void CommandLineArgs::deserialize(String content)
+{
+ List<UnownedStringSlice> slices;
+ StringUtil::split(content.getUnownedSlice(), '\n', slices);
+ for (auto arg : slices)
+ {
+ Arg v;
+ v.value = arg;
+ v.loc = SourceLoc();
+ m_args.add(v);
+ }
+}
+
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
CommandLineReader
@@ -118,6 +140,24 @@ SlangResult CommandLineReader::expectArg(CommandLineArg& outArg)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+DownstreamArgs::DownstreamArgs(CommandLineContext* context)
+ : m_context(context)
+{
+ // Add all of the possible names we allow for downstream tools
+ {
+ for (Index i = SLANG_PASS_THROUGH_NONE + 1; i < SLANG_PASS_THROUGH_COUNT_OF; ++i)
+ {
+ addName(TypeTextUtil::getPassThroughName(SlangPassThrough(i)));
+ }
+
+ // Generic downstream tool
+ addName("downstream");
+ // Generic downstream linker
+ addName("linker");
+ }
+}
+
+
Index DownstreamArgs::addName(const String& name)
{
Index index = findName(name);