forked from Matway/mpl-sl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnion.mpl
executable file
·65 lines (56 loc) · 1.21 KB
/
Union.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
"Union" module
"control" includeModule
Union: [{
virtual UNION: ();
schema typeList:;
virtual maxSize: [
result: 1 static;
i: 0 static;
[
i typeList fieldCount < [
curSize: i typeList @ storageSize 0ix cast 0 cast;
curSize result > [
curSize @result set
] when
i 1 + @i set
TRUE static
] [
FALSE static
] if
] loop
result
] call;
virtual maxAlignment: [
result: 1 static;
i: 0 static;
[
i typeList fieldCount < [
curSize: i typeList @ alignment 0ix cast 0 cast;
curSize result > [
curSize @result set
] when
i 1 + @i set
TRUE static
] [
FALSE static
] if
] loop
result
];
memory: [
maxAlignment 1 static = [0n8 dynamic] [
maxAlignment 2 static = [0n16 dynamic] [
maxAlignment 4 static = [0n32 dynamic] [
maxAlignment 8 static = [0n64 dynamic] [
().ALIGNMENT_HAS_INCORRECT_VALUE
] if
] if
] if
] if
] call;
filler: 0n8 maxSize maxAlignment - array dynamic;
get: [
index: copy;
@memory storageAddress index @typeList @ addressToReference
];
}];