-
Notifications
You must be signed in to change notification settings - Fork 4
/
Block.mpl
246 lines (213 loc) · 7.18 KB
/
Block.mpl
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
# Copyright (C) 2021 Matway Burkow
#
# This repository and all its contents belong to Matway Burkow (referred here and below as "the owner").
# The content is for demonstration purposes only.
# It is forbidden to use the content or any part of it for any purpose without explicit permission from the owner.
# By contributing to the repository, contributors acknowledge that ownership of their work transfers to the owner.
"Array" use
"HashTable" use
"String" use
"Variant" use
"control" use
"Mref" use
"Var" use
"astNodeType" use
ArgVirtual: [0n8 dynamic];
ArgGlobal: [1n8 dynamic];
ArgRef: [2n8 dynamic];
ArgCopy: [3n8 dynamic];
ArgDerefCopy: [4n8 dynamic];
ArgMeta: [5n8 dynamic];
ArgAlreadyUsed: [6n8 dynamic];
ArgReturn: [7n8 dynamic];
ArgRefDeref: [8n8 dynamic];
ArgReturnDeref: [9n8 dynamic];
NameCaseInvalid: [ 0n8 dynamic];
NameCaseBuiltin: [ 1n8 dynamic];
NameCaseLocal: [ 2n8 dynamic];
NameCaseFromModule: [ 3n8 dynamic];
NameCaseCapture: [ 4n8 dynamic];
NameCaseSelfMember: [ 5n8 dynamic];
NameCaseClosureMember: [ 6n8 dynamic];
NameCaseSelfObject: [ 7n8 dynamic];
NameCaseClosureObject: [ 8n8 dynamic];
NameCaseSelfObjectCapture: [ 9n8 dynamic];
NameCaseClosureObjectCapture: [10n8 dynamic];
MemberCaseToObjectCase: [2n8 +];
MemberCaseToObjectCaptureCase: [4n8 +];
NodeCaseEmpty: [0n8 dynamic];
NodeCaseCode: [1n8 dynamic];
NodeCaseDtor: [2n8 dynamic];
NodeCaseDeclaration: [3n8 dynamic];
NodeCaseCodeRefDeclaration: [4n8 dynamic];
NodeCaseExport: [5n8 dynamic];
NodeCaseLambda: [6n8 dynamic];
NodeCaseList: [7n8 dynamic];
NodeCaseObject: [8n8 dynamic];
NodeRecursionStateNo: [0n8 dynamic];
NodeRecursionStateFail: [1n8 dynamic];
NodeRecursionStateNew: [2n8 dynamic];
NodeRecursionStateOld: [3n8 dynamic];
NodeRecursionStateFailDone: [4n8 dynamic];
NodeStateNew: [0n8 dynamic];
NodeStateNoOutput: [1n8 dynamic]; #after calling NodeStateNew recursion with unknown output, node is uncompilable
NodeStateHasOutput: [2n8 dynamic]; #after merging "if" with output and without output, node can be compiled
NodeStateCompiled: [3n8 dynamic]; #node finished
NodeStateFailed: [4n8 dynamic]; #node finished
Argument: [{
refToVar: RefToVar;
argCase: ArgRef;
}];
Capture: [{
refToVar: RefToVar;
argCase: ArgRef;
stable: Cond;
mplFieldIndex: -1 dynamic;
nameInfo: -1 dynamic;
nameOverloadDepth: -1 dynamic;
file: ["MplFile.FileSchema" use FileSchema] Mref;
}];
CFunctionSignature: [{
inputs: RefToVar Array;
outputs: RefToVar Array;
variadic: FALSE dynamic;
convention: String;
}];
CompilerPositionInfo: [{
file: ["MplFile.FileSchema" use FileSchema] Mref;
line: -1 dynamic;
column: -1 dynamic;
token: StringView;
}];
makeInstruction: [{
enabled: TRUE dynamic;
alloca: FALSE dynamic;
fakePointer: FALSE dynamic;
fakeAlloca: FALSE dynamic;
irName1: -1 dynamic;
irName2: -1 dynamic;
irName3: -1 dynamic;
codeOffset: new;
codeSize: new;
}];
Instruction: [0 0 makeInstruction];
MatchingInfo: [{
inputs: Argument Array; #for generating signatures
captures: Capture Array; #for generating signatures, for finding 'self'
shadowEvents: ShadowEvent Array;
lastTopologyIndex: 0 dynamic;
currentInputCount: 0 dynamic;
maxInputCount: 0 dynamic;
}];
NameWithOverload: [{
nameInfo: -1 dynamic;
nameOverloadDepth: -1 dynamic;
}];
NameWithOverloadAndRefToVar: [{
virtual NAME_WITH_OVERLOAD_AND_REF_TO_VAR: ();
nameInfo: -1 dynamic;
nameOverloadDepth:-1 dynamic;
startPoint: -1 dynamic;
hasOverloadWord: FALSE dynamic;
refToVar: RefToVar;
}];
TokenRef: [{
astNode: AstNode Cref;
}];
UsedModuleInfo: [{
used: FALSE dynamic;
position: CompilerPositionInfo;
}];
ShadowEventInput: [Argument];
ShadowEventCapture: [Capture];
ShadowEventField: [{
object: RefToVar;
field: RefToVar;
mplFieldIndex: Int32;
}];
ShadowEventPointee: [{
pointer: RefToVar;
pointee: RefToVar;
}];
ShadowEvent: [(
Cond #ShadowReasonNo
ShadowEventCapture #ShadowReasonCapture
ShadowEventInput #ShadowReasonInput
ShadowEventField #ShadowReasonField
ShadowEventPointee #ShadowReasonPointee
Cond #ShadowReasonLambda
) Variant];
Block: [{
id: Int32;
root: FALSE dynamic;
file: ["MplFile.FileSchema" use FileSchema] Mref;
topNode: [@BlockSchema] Mref;
capturedFiles: Cond Array;
beginPosition: CompilerPositionInfo;
parent: 0 dynamic;
nodeCase: NodeCaseCode;
stack: RefToVar Array; # we must compile node without touching parent
minStackDepth: 0 dynamic;
programTemplate: String;
program: Instruction Array;
aliases: String Array;
lastLambdaName: Int32;
nextRecLambdaId: -1 dynamic;
globalPriority: Int32;
instructionCountBeforeRet: Int32;
hasCallImport: FALSE dynamic;
hasEmptyLambdas: FALSE dynamic;
nodeIsRecursive: FALSE dynamic;
nextLabelIsVirtual: FALSE dynamic;
nextLabelIsOverload: FALSE dynamic;
nextLabelIsPrivate: FALSE dynamic;
recursionState: NodeRecursionStateNo;
state: NodeStateNew;
struct: Struct;
irName: String;
header: String;
argTypes: String;
csignature: CFunctionSignature;
convention: String;
mplConvention: String;
signature: String;
nodeCompileOnce: FALSE dynamic;
empty: FALSE dynamic;
deleted: FALSE dynamic;
emptyDeclaration: FALSE dynamic;
uncompilable: FALSE dynamic;
variadic: FALSE dynamic;
hasNestedCall: FALSE dynamic;
hasCallTrace: FALSE dynamic;
changedStableName: FALSE dynamic;
countOfUCall: 0 dynamic;
declarationRefs: Cond Array;
buildingMatchingInfo: MatchingInfo;
matchingInfo: MatchingInfo;
outputs: Argument Array;
dependentPointers: (RefToVar RefToVar FALSE dynamic) Array;
captureErrors: Int32 CompilerPositionInfo HashTable;
fromModuleNames: NameWithOverloadAndRefToVar Array;
labelNames: NameWithOverloadAndRefToVar Array;
captureNames: NameWithOverload Array;
stableNames: Int32 Array;
candidatesToDie: RefToVar Array;
unprocessedAstNodes: TokenRef Array;
globalVariableNames: Int32 RefToVar Array HashTable;
refToVar: RefToVar; #refToVar of function with compiled node
varNameInfo: -1 dynamic; #variable name of imported function
astArrayIndex: -1 dynamic;
matchingChindIndex: -1 dynamic;
exportDepth: 0 dynamic;
namedFunctions: String Int32 HashTable; # name -> node ID
capturedVars: RefToVar Array;
fileLexicalBlocks: Int32 Int32 HashTable;
funcDbgIndex: -1 dynamic;
lastVarName: 0 dynamic;
lastBrLabelName: 0 dynamic;
variableCountDelta: 0 dynamic;
nextStringAttribute: String;
INIT: [];
DIE: [];
}];
virtual BlockSchema: Block Ref;