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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
package org.shedlang.compiler.shid.instructions;
import org.shedlang.compiler.sources.Sources;
import org.shedlang.compiler.types.NamespaceName;
import org.shedlang.compiler.types.SimpleNativeType;
import org.shedlang.compiler.types.SimpleStructType;
import org.shedlang.compiler.types.UserDefinedEffect;
import java.math.BigInteger;
import java.util.List;
public class Shid {
private Shid() {
}
public static ShidBlock block(List<ShidVariable> boundVariables, List<ShidInstruction> instructions) {
return new ShidBlock(boundVariables, instructions, Sources.NULL);
}
public static ShidBlock block(List<ShidInstruction> instructions) {
return block(List.of(), instructions);
}
public static ShidInstruction call(int positionalArgCount, List<String> namedArgNames) {
return new ShidCall(positionalArgCount, namedArgNames, Sources.NULL);
}
public static ShidInstruction declareNativeType(
SimpleNativeType type
) {
return new ShidDeclareNativeType(
type,
Sources.NULL
);
}
public static ShidInstruction defineEffect(UserDefinedEffect effect) {
return new ShidDefineEffect(effect, Sources.NULL);
}
public static ShidInstruction defineStruct(
SimpleStructType type,
List<ShidDefineStruct.Field> fields
) {
return new ShidDefineStruct(
type,
fields,
Sources.NULL
);
}
public static ShidDefineStruct.Field defineStructField(String name) {
return new ShidDefineStruct.Field(name, Sources.NULL);
}
public static ShidInstruction discard() {
return new ShidDiscard(Sources.NULL);
}
public static ShidInstruction duplicate() {
return new ShidDuplicate(Sources.NULL);
}
public static ShidInstruction effectHandlerBreak(UserDefinedEffect effect) {
return new ShidEffectHandlerBreak(effect, Sources.NULL);
}
public static ShidInstruction fieldLoad(NamespaceName namespaceName, String fieldName) {
return new ShidFieldLoad(
new ShidFieldLoad.Receiver.Namespace(namespaceName),
fieldName,
Sources.NULL
);
}
public static ShidInstruction fieldLoad(SimpleStructType type, String fieldName) {
return new ShidFieldLoad(
new ShidFieldLoad.Receiver.Struct(type),
fieldName,
Sources.NULL
);
}
public static ShidInstruction fieldLoad(UserDefinedEffect effect, String fieldName) {
return new ShidFieldLoad(
new ShidFieldLoad.Receiver.Effect(effect),
fieldName,
Sources.NULL
);
}
public static ShidInstruction if_(
int resultCount,
ShidBlock trueBody,
ShidBlock falseBody
) {
return new ShidIf(resultCount, trueBody, falseBody, Sources.NULL);
}
public static ShidInstruction intAdd() {
return new ShidIntAdd(Sources.NULL);
}
public static ShidInstruction intEquals() {
return new ShidIntEquals(Sources.NULL);
}
public static ShidInstruction intGreaterThan() {
return new ShidIntGreaterThan(Sources.NULL);
}
public static ShidInstruction intGreaterThanOrEqual() {
return new ShidIntGreaterThanOrEqual(Sources.NULL);
}
public static ShidInstruction intLessThan() {
return new ShidIntLessThan(Sources.NULL);
}
public static ShidInstruction intLessThanOrEqual() {
return new ShidIntLessThanOrEqual(Sources.NULL);
}
public static ShidInstruction intMultiply() {
return new ShidIntMultiply(Sources.NULL);
}
public static ShidInstruction intNotEqual() {
return new ShidIntNotEqual(Sources.NULL);
}
public static ShidInstruction intSub() {
return new ShidIntSub(Sources.NULL);
}
public static ShidInstruction localDrop(String name) {
return new ShidLocalDrop(name, Sources.NULL);
}
public static ShidInstruction localLoad(String name) {
return new ShidLocalLoad(name, Sources.NULL);
}
public static ShidInstruction localStore(String name) {
return new ShidLocalStore(name, Sources.NULL);
}
public static ShidInstruction loop(ShidBlock body) {
return new ShidLoop(body, Sources.NULL);
}
public static ShidInstruction loopBreak() {
return new ShidLoopBreak(Sources.NULL);
}
public static ShidInstruction loopContinue() {
return new ShidLoopContinue(Sources.NULL);
}
public static ShidInstruction methodLoad(
SimpleStructType type,
String methodName
) {
return new ShidMethodLoad(type, methodName, Sources.NULL);
}
public static ShidInstruction methodStore(
SimpleStructType type,
String methodName
) {
return new ShidMethodStore(type, methodName, Sources.NULL);
}
public static ShidInstruction namespaceFieldStore(NamespaceName namespaceName, String fieldName) {
return new ShidNamespaceFieldStore(namespaceName, fieldName, Sources.NULL);
}
public static ShidInstruction namespaceImport(NamespaceName namespaceName) {
return new ShidNamespaceImport(namespaceName, Sources.NULL);
}
public static ShidParam param(String name) {
return new ShidParam(name, Sources.NULL);
}
public static ShidInstruction pushBool(boolean value) {
return new ShidPushBool(value, Sources.NULL);
}
public static ShidInstruction pushInt(int value) {
return new ShidPushInt(BigInteger.valueOf(value), Sources.NULL);
}
public static ShidInstruction pushString(String value) {
return new ShidPushString(value, Sources.NULL);
}
public static ShidInstruction pushUnit() {
return new ShidPushUnit(Sources.NULL);
}
public static ShidInstruction resume() {
return new ShidResume(Sources.NULL);
}
public static ShidInstruction return_() {
return new ShidReturn(Sources.NULL);
}
public static ShidInstruction stringAdd() {
return new ShidStringAdd(Sources.NULL);
}
public static ShidInstruction switch_(List<ShidSwitch.Case> cases) {
return new ShidSwitch(cases, Sources.NULL);
}
public static ShidSwitch.Case switchCase(
SimpleStructType type,
ShidBlock body
) {
return new ShidSwitch.Case(type, body, Sources.NULL);
}
public static ShidInstruction try_(
UserDefinedEffect handledEffect,
List<String> handlerMethodNames,
ShidBlock body
) {
return new ShidTry(
handledEffect,
handlerMethodNames,
body,
Sources.NULL
);
}
public static ShidInstruction tupleCreate(int elementCount) {
return new ShidTupleCreate(elementCount, Sources.NULL);
}
public static ShidInstruction tupleGet(int elementIndex, int elementCount) {
return new ShidTupleGet(elementIndex, elementCount, Sources.NULL);
}
public static ShidInstruction varLoad(String name) {
return new ShidVarLoad(name, Sources.NULL);
}
public static ShidInstruction varStore(String name) {
return new ShidVarStore(name, Sources.NULL);
}
}
|