-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathids.m
192 lines (185 loc) · 4.6 KB
/
ids.m
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
const IDS <- immutable object IDS
const t <- 1
const sizes <- {
8, % ABSTRACTTYPEI
8, % ANYI
8, % ARRAYI
4, % BOOLEANI
1, % CHARACTERI
4, % CONDITIONI
4, % INTEGERI
8, % NILI
4, % NODEI
4, % SIGNATUREI
4, % REALI
4, % STRINGI
8, % VECTORI
4, % TIMEI
4, % NODELISTELEMENTI
4, % NODELISTI
4, % INSTREAMI
4, % OUTSTREAMI
8, % IMMUTABLEVECTORI
4, % BITCHUNKI
8, % SEQUENCEOFCHARACTERI
8, % HANDLERI
4, % VECTOROFCHARI
8, % RDIRECTORYI
4, % CONCRETETYPEI
4, % COPVECTORI
4, % COPVECTOREI
4, % AOPVECTORI
4, % AOPVECTOREI
4, % APARAMLISTI
4, % VECTOROFINTI
4, % INTERPRETERSTATEI
8, % DIRECTORYI
4, % IVECTOROFANYI
8, % SEQUENCEOFANYI
4, % IVECTOROFINTI
8, % SEQUENCEI
4, % STUBI
8, % DIRECTORYGAGGLEI
4, % LITERALLISTI
4, % VECTOROFANYI
4, % IVECTOROFSTRINGI
4 % VECTOROFSTRINGI
}
const brands : ImmutableVector.of[Character] <- {
'v', % ABSTRACTTYPEI
'v', % ANYI
'v', % ARRAYI
'd', % BOOLEANI
'c', % CHARACTERI
'x', % CONDITIONI
'd', % INTEGERI
'v', % NILI
'x', % NODEI
'x', % SIGNATUREI
'f', % REALI
'x', % STRINGI
'v', % VECTORI
'x', % TIMEI
'x', % NODELISTELEMENTI
'x', % NODELISTI
'x', % INSTREAMI
'x', % OUTSTREAMI
'v', % IMMUTABLEVECTORI
'x', % BITCHUNKI
'v', % SEQUENCEOFCHARACTERI
'v', % HANDLERI
'x', % VECTOROFCHARI
'v', % RDIRECTORYI
'x', % CONCRETETYPEI
'x', % COPVECTORI
'x', % COPVECTOREI
'x', % AOPVECTORI
'x', % AOPVECTOREI
'x', % APARAMLISTI
'x', % VECTOROFINTI
'x', % INTERPRETERSTATEI
'v', % DIRECTORYI
'x', % IVECTOROFANYI
'v', % SEQUENCEOFANYI
'x', % IVECTOROFINTI
'v', % SEQUENCEI
'x', % STUBI
'v', % DIRECTORYGAGGLEI
'x', % LITERALLISTI
'x', % VECTOROFANYI
'x', % IVECTOROFSTRINGI
'x' % VECTOROFSTRINGI
}
export operation IDToSize [id : Integer] -> [size : Integer]
var index : Integer <- ~1
size <- 8
if 0x1600 <= id and id <= 0x1640 then
index <- id - 0x1600
elseif 0x1800 <= id and id <= 0x1840 then
index <- id - 0x1800
end if
if index >= 0 then
size <- sizes[index]
end if
end IDToSize
export operation IDToBrand [id : Integer] -> [brand : Character]
var index : Integer <- ~1
brand <- 'v'
if 0x1600 <= id and id <= 0x1640 then
index <- id - 0x1600
elseif 0x1800 <= id and id <= 0x1840 then
index <- id - 0x1800
end if
if index >= 0 then
brand <- brands[index]
end if
end IDToBrand
export operation IDToInstCTID [id : Integer] -> [ctid : Integer]
var index : Integer
if 0x1600 <= id and id <= 0x1640 then
const size <- sizes[id - 0x1600]
if size = 4 or size = 1 then
ctid <- id + 0x200
end if
elseif 0x1000 <= id and id <= 0x1040 then
const size <- sizes[id - 0x1000]
if size = 4 or size = 1 then
ctid <- id + 0x800
end if
end if
end IDToInstCTID
export operation IDToATID [id : Integer] -> [atid : Integer]
if 0x1600 <= id and id <= 0x1640 then
atid <- id
elseif 0x1000 <= id and id <= 0x1040 then
atid <- id + 0x200
end if
end IDToATID
export operation IDToCTID [id : Integer] -> [ctid : Integer]
if 0x1400 <= id and id <= 0x1440 then
ctid <- id
elseif 0x1000 <= id and id <= 0x1040 then
ctid <- id
end if
end IDToCTID
export operation ConformsByID [ln : Integer, id1 : Integer, id2 : Integer] -> [r : Boolean]
var a : Any
const e : EnvironmentType <- Environment$env
r <- e$conformTable.Lookup[id1, id2]
if r == nil then
if id1 = id2 then
r <- true
elseif id1 = 0x1607 then
r <- true
elseif id2 = 0x1601 then
r <- true
elseif id1 = 0x1616 or id2 = 0x1616 or
id1 = 0x161e or id2 = 0x161e or
id1 = 0x1621 or id2 = 0x1621 or
id1 = 0x1623 or id2 = 0x1623 or
id1 = 0x1627 or id2 = 0x1627 then
if e$tracetypecheck then
e.Warning[ln, "Unknown types (%#x) and (%#x) one vector, conformity assumed", {id1, id2}]
end if
r <- true
elseif 0x1600 <= id2 and id2 <= 0x1640 then
const size <- sizes[id2 - 0x1600]
if size = 1 or size = 4 then
r <- false
end if
end if
if r !== nil then
e$conformTable.Insert[id1, id2, r]
end if
end if
if r == nil then
if e$tracetypecheck then
e.Warning[ln, "Unknown types (%#x and %#x), conformity assumed",
{ id1, id2} ]
end if
r <- true
e$conformTable.Insert[id1, id2, r]
end if
end ConformsByID
end IDS
export IDS