-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathql_synth_types.mustache
More file actions
113 lines (104 loc) · 2.54 KB
/
ql_synth_types.mustache
File metadata and controls
113 lines (104 loc) · 2.54 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
/**
* INTERNAL: Do not use.
* This module defines the IPA layer on top of raw DB entities, and the conversions between the two
* layers.
*/
private import {{import_prefix}}.SynthConstructors
private import {{import_prefix}}.Raw
module Synth {
/**
* INTERNAL: Do not use.
* The synthesized type of all elements.
*/
cached newtype T{{root}} =
{{#final_classes}}
{{^first}}
or
{{/first}}
/**
* INTERNAL: Do not use.
*/
T{{name}}({{#params}}{{^first}}, {{/first}}{{type}} {{param}}{{/params}}){{#has_params}} { construct{{name}}({{#params}}{{^first}}, {{/first}}{{param}}{{/params}}) }{{/has_params}}
{{/final_classes}}
{{#non_final_classes}}
{{^root}}
/**
* INTERNAL: Do not use.
*/
class T{{name}} = {{#derived}}{{^first}} or {{/first}}T{{name}}{{/derived}};
{{/root}}
{{/non_final_classes}}
/**
* INTERNAL: Do not use.
*
* Gets the parent of synthetic element `e`.
*/
Raw::{{root}} getSynthParent(T{{root}} e) {
none()
{{#final_classes}}
{{#is_fresh_synth}}
{{#has_params}}
or
e = T{{name}}({{#params}}{{#first}}result{{/first}}{{^first}}, _{{/first}}{{/params}})
{{/has_params}}
{{/is_fresh_synth}}
{{/final_classes}}
}
{{#final_classes}}
/**
* INTERNAL: Do not use.
*
* Converts a raw element to a synthesized `T{{name}}`, if possible.
*/
T{{name}} convert{{name}}FromRaw(Raw::Element e) {
{{^is_fresh_synth}}
result = T{{name}}(e)
{{/is_fresh_synth}}
{{#is_fresh_synth}}
none()
{{/is_fresh_synth}}
}
{{/final_classes}}
{{#non_final_classes}}
/**
* INTERNAL: Do not use.
* Converts a raw DB element to a synthesized `T{{name}}`, if possible.
*/
T{{name}} convert{{name}}FromRaw(Raw::Element e) {
{{#derived}}
{{^first}}
or
{{/first}}
result = convert{{name}}FromRaw(e)
{{/derived}}
}
{{/non_final_classes}}
{{#final_classes}}
/**
* INTERNAL: Do not use.
* Converts a synthesized `T{{name}}` to a raw DB element, if possible.
*/
Raw::Element convert{{name}}ToRaw(T{{name}} e) {
{{^is_fresh_synth}}
e = T{{name}}(result)
{{/is_fresh_synth}}
{{#is_fresh_synth}}
none()
{{/is_fresh_synth}}
}
{{/final_classes}}
{{#non_final_classes}}
/**
* INTERNAL: Do not use.
* Converts a synthesized `T{{name}}` to a raw DB element, if possible.
*/
Raw::Element convert{{name}}ToRaw(T{{name}} e) {
{{#derived}}
{{^first}}
or
{{/first}}
result = convert{{name}}ToRaw(e)
{{/derived}}
}
{{/non_final_classes}}
}