diff options
| author | Yong He <yonghe@outlook.com> | 2024-02-20 12:24:00 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-20 12:24:00 -0800 |
| commit | 4d20fd329956ac89408b1628a8291fea01bc9a6d (patch) | |
| tree | 8e62d9c1ec05142fd25d0b31073fdb56d44691b0 /source/compiler-core | |
| parent | 8e9b61e3bac69dbb37a1451b62302e688a017ced (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')
| -rw-r--r-- | source/compiler-core/slang-command-line-args.cpp | 42 | ||||
| -rw-r--r-- | source/compiler-core/slang-command-line-args.h | 13 |
2 files changed, 48 insertions, 7 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); diff --git a/source/compiler-core/slang-command-line-args.h b/source/compiler-core/slang-command-line-args.h index b2bd48c61..0c11a3c46 100644 --- a/source/compiler-core/slang-command-line-args.h +++ b/source/compiler-core/slang-command-line-args.h @@ -69,6 +69,9 @@ struct CommandLineArgs //String m_executablePath; ///< Can be optionally be set List<Arg> m_args; ///< The args RefPtr<CommandLineContext> m_context; ///< The context, which mainly has source manager + + String serialize(); + void deserialize(String content); }; struct CommandLineReader @@ -155,18 +158,16 @@ struct DownstreamArgs CommandLineContext* getContext() const { return m_context; } /// Ctor - DownstreamArgs(CommandLineContext* context): - m_context(context) - { - } + DownstreamArgs(CommandLineContext* context); + /// Default ctor - for convenience, should really use with context normally DownstreamArgs() {} + List<Entry> m_entries; ///< All of the entries + protected: Index _findOrAddName(SourceLoc loc, const UnownedStringSlice& name, Flags flags, DiagnosticSink* sink); - List<Entry> m_entries; ///< All of the entries - RefPtr<CommandLineContext> m_context; ///< The context that is being used (primarily for loc tracking) across all entries/args }; |
