-
Notifications
You must be signed in to change notification settings - Fork 4
/
staticCall.mpl
56 lines (49 loc) · 1.87 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
48
49
50
51
52
53
54
55
56
# 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.
"String" use
"control" use
"logger" use
staticCall: [
staticCallBody:;
staticCallLast: new; # required to be static
staticCallFirst: new; # required to be static
staticCallIndex: new; # can be dynamic
[
staticCallIndex staticCallFirst < ~ staticCallIndex staticCallLast < and r:;
r ~ [
(
"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
];