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