summaryrefslogtreecommitdiff
path: root/source/slang/compiler.h
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-06-13 14:10:10 -0700
committerGitHub <noreply@github.com>2017-06-13 14:10:10 -0700
commit5a11b47b34845874e1d8bfa28181661863645920 (patch)
treeed48ba12c7db141d517b29343b9127692e72ad8c /source/slang/compiler.h
parent7fc4c40b17f340800d6616e0bae111606cef18cc (diff)
parentd81c347e0edcbbf181885baf2b13978c28dfc9a8 (diff)
Merge pull request #5 from tfoleyNV/cross-compile
Cross compilation
Diffstat (limited to 'source/slang/compiler.h')
-rw-r--r--source/slang/compiler.h56
1 files changed, 46 insertions, 10 deletions
diff --git a/source/slang/compiler.h b/source/slang/compiler.h
index f35d6603c..01db7874f 100644
--- a/source/slang/compiler.h
+++ b/source/slang/compiler.h
@@ -17,6 +17,7 @@ namespace Slang
{
class ILConstOperand;
struct IncludeHandler;
+ struct CompileRequest;
enum class CompilerMode
{
@@ -87,28 +88,31 @@ namespace Slang
// The source file(s) that will be compiled to form this translation unit
List<RefPtr<SourceFile> > sourceFiles;
+
+ // Preprocessor definitions to use for this translation unit only
+ // (whereas the ones on `CompileOptions` will be shared)
+ Dictionary<String, String> preprocessorDefinitions;
};
class CompileOptions
{
public:
- CompilerMode Mode = CompilerMode::ProduceShader;
+ // What target language are we compiling to?
CodeGenTarget Target = CodeGenTarget::Unknown;
- StageTarget stage = StageTarget::Unknown;
- EnumerableDictionary<String, String> BackendArguments;
- String SymbolToCompile;
- String outputName;
- List<String> TemplateShaderArguments;
+ // Directories to search for `#include` files or `import`ed modules
List<String> SearchDirectories;
- Dictionary<String, String> PreprocessorDefinitions;
+ // Definitions to provide during preprocessing
+ Dictionary<String, String> preprocessorDefinitions;
+
+ // Translation units we are being asked to compile
List<TranslationUnitOptions> translationUnits;
- // the code generation profile we've been asked to use
+ // The code generation profile we've been asked to use.
Profile profile;
- // should we just pass the input to another compiler?
+ // Should we just pass the input to another compiler?
PassThroughMode passThrough = PassThroughMode::None;
// Flags supplied through the API
@@ -133,13 +137,34 @@ namespace Slang
RefPtr<ProgramLayout> layout;
};
+ // Context information for code generation
+ struct ExtraContext
+ {
+ CompileOptions const* options = nullptr;
+ TranslationUnitOptions const* translationUnitOptions = nullptr;
+
+ CompileResult* compileResult = nullptr;
+
+ RefPtr<ProgramSyntaxNode> programSyntax;
+ ProgramLayout* programLayout;
+
+ String sourceText;
+ String sourcePath;
+
+ CompileOptions const& getOptions() { return *options; }
+ TranslationUnitOptions const& getTranslationUnitOptions() { return *translationUnitOptions; }
+ };
+
+#if 0
+
class ShaderCompiler : public CoreLib::Basic::Object
{
public:
virtual void Compile(
CompileResult& result,
CollectionOfTranslationUnits* collectionOfTranslationUnits,
- const CompileOptions& options) = 0;
+ const CompileOptions& options,
+ CompileRequest* request) = 0;
virtual TranslationUnitResult PassThrough(
String const& sourceText,
@@ -150,6 +175,17 @@ namespace Slang
};
ShaderCompiler * CreateShaderCompiler();
+#endif
+
+ TranslationUnitResult passThrough(
+ String const& sourceText,
+ String const& sourcePath,
+ const CompileOptions & options,
+ TranslationUnitOptions const& translationUnitOptions);
+
+ void generateOutput(
+ ExtraContext& context,
+ CollectionOfTranslationUnits* collectionOfTranslationUnits);
}
}