summaryrefslogtreecommitdiffstats
path: root/source/slang/slang.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang.cpp')
-rw-r--r--source/slang/slang.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index eb938f49c..25419fb33 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -31,6 +31,7 @@
#include "slang-parameter-binding.h"
#include "slang-parser.h"
#include "slang-preprocessor.h"
+#include "slang-reflection-json.h"
#include "slang-repro.h"
#include "slang-serialize-ast.h"
#include "slang-serialize-container.h"
@@ -6857,6 +6858,22 @@ SlangResult EndToEndCompileRequest::compile()
}
}
+ auto reflectionPath = getOptionSet().getStringOption(CompilerOptionName::EmitReflectionJSON);
+ if (reflectionPath.getLength() != 0)
+ {
+ auto bufferWriter = PrettyWriter();
+ emitReflectionJSON(this, this->getReflection(), bufferWriter);
+ if (reflectionPath == "-")
+ {
+ auto builder = bufferWriter.getBuilder();
+ StdWriters::getOut().write(builder.getBuffer(), builder.getLength());
+ }
+ else if (SLANG_FAILED(File::writeAllText(reflectionPath, bufferWriter.getBuilder())))
+ {
+ getSink()->diagnose(SourceLoc(), Diagnostics::unableToWriteFile, reflectionPath);
+ }
+ }
+
return res;
}