-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathComputeGeneratedFiles.scala
More file actions
134 lines (119 loc) · 3.76 KB
/
ComputeGeneratedFiles.scala
File metadata and controls
134 lines (119 loc) · 3.76 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package fpp.compiler.codegen
import fpp.compiler.analysis._
import fpp.compiler.ast._
import fpp.compiler.util._
/** Computes the names of generated files */
object ComputeGeneratedFiles {
/** Computes autocoded files (XML, C++ and JSON Dictionary) */
def getAutocodeFiles(tul: List[Ast.TransUnit]): Result.Result[List[String]] =
for {
// Perform analysis only up to the point we need
a <- enterSymbols(tul)
a <- CheckUses.visitList(a, tul, CheckUses.transUnit)
_ <- CheckUseDefCycles.visitList(a, tul, CheckUseDefCycles.transUnit)
a <- CheckTypeUses.visitList(a, tul, CheckTypeUses.transUnit)
xmlFiles <- getXmlFiles(a, tul)
cppFiles <- getAutocodeCppFiles(a, tul)
dictFiles <- getDictionaryJsonFiles(a, tul)
}
yield xmlFiles ++ cppFiles ++ dictFiles
/** Computes component implementation files */
def getImplFiles(tul: List[Ast.TransUnit]): Result.Result[List[String]] =
for {
a <- enterSymbols(tul)
cppFiles <- getImplCppFiles(a, tul)
}
yield cppFiles
/** Computes autocoded C++ files for testing */
def getTestFiles(
tul: List[Ast.TransUnit],
testHelperMode: CppWriter.TestHelperMode
): Result.Result[List[String]] =
for {
a <- enterSymbols(tul)
testFiles <- getTestCppFiles(a, tul, testHelperMode)
}
yield testFiles
/** Computes unit test implementation files */
def getTestImplFiles(
tul: List[Ast.TransUnit],
testHelperMode: CppWriter.TestHelperMode
): Result.Result[List[String]] =
for {
a <- enterSymbols(tul)
cppFiles <- getTestImplCppFiles(a, tul, testHelperMode)
}
yield cppFiles
private def enterSymbols(tul: List[Ast.TransUnit]): Result.Result[Analysis] =
EnterSymbols.visitList(Analysis(), tul, EnterSymbols.transUnit)
private def getAutocodeCppFiles(a: Analysis, tul: List[Ast.TransUnit]):
Result.Result[List[String]] =
for {
s <- ComputeAutocodeCppFiles.visitList(
CppWriterState(a),
tul,
ComputeAutocodeCppFiles.transUnit
)
}
yield s.locationMap.toList.map(_._1)
private def getImplCppFiles(a: Analysis, tul: List[Ast.TransUnit]):
Result.Result[List[String]] =
for {
s <- ComputeImplCppFiles.visitList(
CppWriterState(a),
tul,
ComputeImplCppFiles.transUnit
)
}
yield s.locationMap.toList.map(_._1)
private def getTestCppFiles(
a: Analysis,
tul: List[Ast.TransUnit],
testHelperMode: CppWriter.TestHelperMode
): Result.Result[List[String]] = {
val computeTestCppFiles = ComputeTestCppFiles(testHelperMode)
for {
s <- computeTestCppFiles.visitList(
CppWriterState(a),
tul,
computeTestCppFiles.transUnit
)
}
yield s.locationMap.toList.map(_._1)
}
private def getTestImplCppFiles(
a: Analysis,
tul: List[Ast.TransUnit],
testHelperMode: CppWriter.TestHelperMode
): Result.Result[List[String]] = {
val computeTestImplCppFiles = ComputeTestImplCppFiles(testHelperMode)
for {
s <- computeTestImplCppFiles.visitList(
CppWriterState(a),
tul,
computeTestImplCppFiles.transUnit
)
}
yield s.locationMap.toList.map(_._1)
}
private def getXmlFiles(a: Analysis, tul: List[Ast.TransUnit]):
Result.Result[List[String]] =
for {
s <- ComputeXmlFiles.visitList(
XmlWriterState(a),
tul,
ComputeXmlFiles.transUnit
)
}
yield s.locationMap.toList.map(_._1)
private def getDictionaryJsonFiles(a: Analysis, tul: List[Ast.TransUnit]):
Result.Result[List[String]] =
for {
s <- ComputeDictionaryFiles.visitList(
DictionaryJsonEncoderState(a),
tul,
ComputeDictionaryFiles.transUnit
)
}
yield s.locationMap.toList.map(_._1)
}