diff options
| author | Kai-Hwa Yao <kyao@nvidia.com> | 2017-07-10 17:44:14 -0700 |
|---|---|---|
| committer | Kai-Hwa Yao <kyao@nvidia.com> | 2017-07-10 17:54:50 -0700 |
| commit | 22c7a4de0c3810fcfc1099843e42b315c366a7c5 (patch) | |
| tree | e53bfd90d2b9e4b04d22f58548999a33b7944d46 /source/slang/compiler.h | |
| parent | 61a816c1e898155aa93c5a740e2b7aad7d7b4fa1 (diff) | |
Removed spGetTranslationUnitCode; Unified EntryPointResult/TranslationUnitResult, added helper functionality; Ensure null termination when printing raw data
Diffstat (limited to 'source/slang/compiler.h')
| -rw-r--r-- | source/slang/compiler.h | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/source/slang/compiler.h b/source/slang/compiler.h index 3763faec7..2b440ad85 100644 --- a/source/slang/compiler.h +++ b/source/slang/compiler.h @@ -48,13 +48,30 @@ namespace Slang ReflectionJSON = SLANG_REFLECTION_JSON, }; + enum class ResultFormat + { + None, + Text, + Binary + }; + class CompileRequest; class TranslationUnitRequest; - // Result of compiling an entry point - struct EntryPointResult + // Result of compiling an entry point. + // Should only ever be string OR binary. + class CompileResult { - List<uint8_t> outputSource; + public: + CompileResult() = default; + CompileResult(String const& str) : format(ResultFormat::Text), outputString(str) {} + CompileResult(List<uint8_t> const& buffer) : format(ResultFormat::Binary), outputBinary(buffer) {} + + void append(CompileResult const& result); + + ResultFormat format = ResultFormat::None; + String outputString; + List<uint8_t> outputBinary; }; // Describes an entry point that we've been requested to compile @@ -80,7 +97,7 @@ namespace Slang // The resulting output for the enry point // // TODO: low-level code generation should be a distinct step - EntryPointResult result; + CompileResult result; // The translation unit that this entry point came from TranslationUnitRequest* getTranslationUnit(); @@ -105,12 +122,6 @@ namespace Slang String content; }; - // Result of compiling a translation unit - struct TranslationUnitResult - { - List<uint8_t> outputSource; - }; - // A single translation unit requested to be compiled. // class TranslationUnitRequest : public RefObject @@ -144,7 +155,7 @@ namespace Slang // The resulting output for the translation unit // // TODO: low-level code generation should be a distinct step - TranslationUnitResult result; + CompileResult result; }; // A directory to be searched when looking for files (e.g., `#include`) |
