forked from Matway/mpl-c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
staticCall.mpl
executable file
·47 lines (42 loc) · 1.46 KB
/
staticCall.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
"staticCall" module
"control" useModule
staticCall: [
staticCallBody:;
copy staticCallLast:; # required to be static
copy staticCallFirst:; # required to be static
copy staticCallIndex:; # can be dynamic
[
staticCallIndex staticCallFirst < not staticCallIndex staticCallLast < and r:;
r not [
(
"index=" makeStringView staticCallIndex 0 cast
"; first=" makeStringView staticCallFirst 0 cast
"; last=" makeStringView staticCallLast 0 cast) addLog
] when
r
] "Index of static call is out of range" assert
staticCallFirst 2 staticCallFirst cast + staticCallLast > [ # static condition or die
staticCallFirst @staticCallBody call
] [
staticCallFirst 17 staticCallFirst cast + staticCallLast > [ # static condition or die
[
staticCallFirst staticCallLast < [
staticCallIndex staticCallFirst = [ # dynamic condition in loop
staticCallFirst @staticCallBody call # dont break, loop must be static
] when
staticCallFirst 1 + @staticCallFirst set
TRUE static
] [
FALSE static
] if
] loop
] [
staticCallMiddle: staticCallFirst staticCallLast + 2 staticCallFirst cast /;
staticCallIndex staticCallMiddle < [
staticCallIndex staticCallFirst staticCallMiddle @staticCallBody staticCall
] [
staticCallIndex staticCallMiddle staticCallLast @staticCallBody staticCall
] if
] if
] if
];