forked from Matway/mpl-sl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Union.mpl
51 lines (43 loc) · 1.2 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
# Copyright (C) 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.
"algorithm.each" use
"control.Int32" use
"control.Nat16" use
"control.Nat32" use
"control.Nat64" use
"control.Nat8" use
"control.Ref" use
"control.max" use
Union: [{
SCHEMA_NAME: "Union" virtual;
Items: Ref virtual;
get: [
key:;
data storageAddress key @Items @ addressToReference
];
# Private
MAXIMUM_ALIGNMENT: [
1
Items [alignment Int32 cast max] each
];
MAXIMUM_SIZE: [
1
Items [storageSize Int32 cast max] each
];
data:
MAXIMUM_ALIGNMENT 1 = [Nat8] [
MAXIMUM_ALIGNMENT 2 = [Nat16] [
MAXIMUM_ALIGNMENT 4 = [Nat32] [
MAXIMUM_ALIGNMENT 8 = [Nat64] [
"Invalid alignment value" raiseStaticError
] if
] if
] if
] if
;
pad: Nat8 MAXIMUM_SIZE MAXIMUM_ALIGNMENT - array;
}];