yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Theresa FoleyAdd support for on-demand AST deserialization (#7482)3ed776159

master
1.7 KiB82 linesraw
1// slang-fiddle-template.h
2#pragma once
3
4#include "compiler-core/slang-source-loc.h"
5#include "core/slang-list.h"
6#include "core/slang-string.h"
7#include "slang-fiddle-diagnostics.h"
8
9namespace fiddle
10{
11using namespace Slang;
12
13class TextTemplateStmt : public RefObject
14{
15public:
16};
17
18class TextTemplateScriptStmt : public TextTemplateStmt
19{
20public:
21    UnownedStringSlice scriptSource;
22};
23
24class TextTemplateRawStmt : public TextTemplateStmt
25{
26public:
27    // TODO(tfoley): Add a `SourceLoc` here, so
28    // that we can emit approriate `#line` directives
29    // to the output...
30
31    UnownedStringSlice text;
32};
33
34class TextTemplateSpliceStmt : public TextTemplateStmt
35{
36public:
37    UnownedStringSlice scriptExprSource;
38};
39
40class TextTemplateSeqStmt : public TextTemplateStmt
41{
42public:
43    List<RefPtr<TextTemplateStmt>> stmts;
44};
45
46class TextTemplate : public RefObject
47{
48public:
49    /// ID of this template within the enclosing file
50    Index id;
51
52    UnownedStringSlice templateStartLine;
53    UnownedStringSlice outputStartLine;
54    UnownedStringSlice endLine;
55
56    UnownedStringSlice templateSource;
57    UnownedStringSlice existingOutputContent;
58
59    RefPtr<TextTemplateStmt> body;
60};
61
62class TextTemplateFile : public RefObject
63{
64public:
65    SourceLoc loc;
66    UnownedStringSlice originalFileContent;
67    List<RefPtr<TextTemplate>> textTemplates;
68};
69
70RefPtr<TextTemplateFile> parseTextTemplateFile(SourceView* inputSourceView, DiagnosticSink* sink);
71
72void generateTextTemplateOutputs(
73    String originalFileName,
74    TextTemplateFile* file,
75    StringBuilder& builder,
76    DiagnosticSink* sink);
77
78String generateModifiedInputFileForTextTemplates(
79    String templateOutputFileName,
80    TextTemplateFile* file,
81    DiagnosticSink* sink);
82} // namespace fiddle