Compare commits
724 Commits
coolant-mo
...
colobot2
Author | SHA1 | Date |
---|---|---|
|
b98edec8f8 | |
|
d22b32477e | |
|
884129a676 | |
|
0fa486b9f0 | |
|
4251873f49 | |
|
74ab7afb23 | |
|
ab3c22dce3 | |
|
72ca4f2d7c | |
|
3a8f75bd02 | |
|
32fed5af73 | |
![]() |
f07b7a1b60 | |
![]() |
0a95289f9f | |
![]() |
7d75b9cc14 | |
![]() |
909a2b2d2e | |
![]() |
7d22b607cc | |
![]() |
2f80292176 | |
![]() |
53b3062bee | |
![]() |
8e128ff08c | |
![]() |
3c4b9f6d01 | |
![]() |
9d5f88f07c | |
![]() |
b9c8d36d8b | |
![]() |
ff340fda92 | |
![]() |
c0d568241b | |
![]() |
d879fa5fc9 | |
![]() |
510fe6804a | |
![]() |
2b84da8a77 | |
![]() |
670cedd967 | |
![]() |
5a52c66b1f | |
![]() |
434bd0bd3a | |
![]() |
5f854da5fc | |
![]() |
86c2b2f0dc | |
![]() |
7fe75e20ad | |
![]() |
261eaa78e4 | |
![]() |
4d11040dba | |
![]() |
97ea5cc895 | |
![]() |
fe36b0fe29 | |
![]() |
8fab817118 | |
![]() |
8601066761 | |
![]() |
9586474fa8 | |
![]() |
5b79a4eb38 | |
![]() |
1034c2e45c | |
![]() |
fde2b901bd | |
![]() |
3e06584956 | |
![]() |
0ab9ae4b6e | |
![]() |
b296ee4d47 | |
![]() |
dccacd6352 | |
![]() |
b3c6e667f5 | |
![]() |
a48f13fb35 | |
![]() |
7db69f5d53 | |
![]() |
ae5e5b3874 | |
![]() |
b5b3f81840 | |
![]() |
fd81641cf7 | |
![]() |
840ded7e61 | |
![]() |
4c7e7280dd | |
![]() |
af1abfe41e | |
![]() |
8e950e5145 | |
![]() |
e807e7c984 | |
![]() |
d9d401e636 | |
![]() |
9a14d0c837 | |
![]() |
ee9f9d875d | |
![]() |
b12e5ad7cd | |
![]() |
ecb789d059 | |
![]() |
32fb105bca | |
![]() |
7d3e3c91e8 | |
![]() |
1b69589302 | |
![]() |
f7a33bbeb0 | |
![]() |
0ef77132a0 | |
![]() |
550193e570 | |
![]() |
beb29333d5 | |
![]() |
f9714c35f7 | |
![]() |
26598c4247 | |
![]() |
1ee0790785 | |
![]() |
6f05280ccb | |
![]() |
63b6bcf38d | |
![]() |
83b9ded0dc | |
![]() |
84ac0d3ba8 | |
![]() |
acc3c5ae5e | |
![]() |
ec0e735a3f | |
![]() |
a16771425a | |
![]() |
4fcd989e72 | |
![]() |
882672c0b5 | |
![]() |
b152bd5dea | |
![]() |
59600ae5c7 | |
![]() |
11f5073a3f | |
![]() |
cfa9a00024 | |
![]() |
9e1248e459 | |
![]() |
9ccc514a67 | |
![]() |
63ad09b615 | |
![]() |
1376d8b16d | |
![]() |
a04dcd8014 | |
![]() |
9c8a8f4cf4 | |
![]() |
dfac4209ef | |
![]() |
793ef3d0a4 | |
![]() |
0d57ac43bb | |
![]() |
3baf2bbb10 | |
![]() |
7c95855d4f | |
![]() |
dd2fbd2675 | |
![]() |
8eaebb8c84 | |
![]() |
172e1fbff0 | |
![]() |
461f1e2240 | |
![]() |
7c40c10b7a | |
![]() |
017a1571f7 | |
![]() |
f672e89201 | |
![]() |
9417b916da | |
![]() |
4f0854068c | |
![]() |
3171dc4a89 | |
![]() |
10b89e36f9 | |
![]() |
080c46daa1 | |
![]() |
b3d19a9e8d | |
![]() |
1bb918ce23 | |
![]() |
160a4a4f75 | |
![]() |
71e3e78644 | |
![]() |
6e7dee74cf | |
![]() |
8f11fc0126 | |
![]() |
5f9b14f43d | |
![]() |
b66ea8bcee | |
![]() |
37b403c46d | |
![]() |
2e7bf2a7a6 | |
![]() |
4b1b20ec5f | |
![]() |
d24a6b37a4 | |
![]() |
4531dc432e | |
![]() |
06bf44da38 | |
![]() |
9dd0159585 | |
![]() |
158901ff02 | |
![]() |
9a01408eda | |
![]() |
7c0dbd914f | |
![]() |
b990ee81ff | |
![]() |
bfd9dae533 | |
![]() |
cbfcbae7ab | |
![]() |
2e95aeac9b | |
![]() |
efbd296fc3 | |
![]() |
9c5d9d8f17 | |
![]() |
0b978f7dbc | |
![]() |
4634461c1d | |
![]() |
1c9c0929da | |
![]() |
24622e6a75 | |
![]() |
f60c62f05d | |
![]() |
ec9607784c | |
![]() |
5efd8342ec | |
![]() |
0618174b2b | |
![]() |
d47e265863 | |
![]() |
436c316a4a | |
![]() |
1d8e06c7ba | |
![]() |
21b6572b5b | |
![]() |
3b3cdb9961 | |
![]() |
bedd24801c | |
![]() |
983a9a6e03 | |
![]() |
2f50470591 | |
![]() |
5feffc70df | |
![]() |
e3ba33a508 | |
![]() |
b7cb26822b | |
![]() |
0e53336d61 | |
![]() |
0df78e7fa6 | |
![]() |
789c8b2292 | |
![]() |
c0669a591b | |
![]() |
708d3cfd46 | |
![]() |
6cc58b872f | |
![]() |
4c767953ea | |
![]() |
4ec0083cd8 | |
![]() |
87ad81f891 | |
![]() |
afbf687255 | |
![]() |
0693aa5e1e | |
![]() |
2a91d6bf35 | |
![]() |
b09977a503 | |
![]() |
438e4bba62 | |
![]() |
a74adb5f59 | |
![]() |
8632c7404d | |
![]() |
2ea94244e9 | |
![]() |
3c98af04b5 | |
![]() |
b5e27c9f19 | |
![]() |
ec425c768b | |
![]() |
3fd9815138 | |
![]() |
3805851255 | |
![]() |
a88d9cdd39 | |
![]() |
7d31b1e55d | |
![]() |
56e0c915b5 | |
![]() |
a25ce2d5df | |
![]() |
cac34e259b | |
![]() |
2a529ae07f | |
![]() |
a1e4e4b97c | |
![]() |
3b4c2f3049 | |
![]() |
f2cc131ff7 | |
![]() |
b6f2a9e544 | |
![]() |
daa9419557 | |
![]() |
0882b69ec8 | |
![]() |
013d3cccf4 | |
![]() |
8f710a24c8 | |
![]() |
7135a6660b | |
![]() |
7664594b8e | |
![]() |
07541d0bbb | |
![]() |
8fb0f76f6f | |
![]() |
640cde1653 | |
![]() |
4b1b1763df | |
![]() |
829c5fb42f | |
![]() |
fd3c2af358 | |
![]() |
5c2c52ad31 | |
![]() |
aa3efd5841 | |
![]() |
920a4c3fc8 | |
![]() |
d57370578f | |
![]() |
4a16ee76a1 | |
![]() |
7af32caec2 | |
![]() |
2d9db9c90a | |
![]() |
d7a22bf74c | |
![]() |
1a7346b845 | |
![]() |
8c40b7c753 | |
![]() |
fdc1792932 | |
![]() |
483a855848 | |
![]() |
4541db7f21 | |
![]() |
86d8ee4c38 | |
![]() |
73db861cc6 | |
![]() |
061ef44def | |
![]() |
dffb988798 | |
![]() |
d09c5da493 | |
![]() |
c011e49112 | |
![]() |
628567701a | |
![]() |
38990e283b | |
![]() |
fa5e229015 | |
![]() |
05163c09a1 | |
![]() |
8533be8d5c | |
![]() |
89551c83cf | |
![]() |
3001927576 | |
![]() |
baa616050a | |
![]() |
e839f0dec7 | |
![]() |
3168bf4350 | |
![]() |
6447304531 | |
![]() |
6aebf60300 | |
![]() |
0829cd84fe | |
![]() |
8af600692e | |
![]() |
3478ee322b | |
![]() |
550d0f915b | |
![]() |
d9e26c2516 | |
![]() |
4bce63e38d | |
![]() |
ec8a09e4a9 | |
![]() |
05b68a4b80 | |
![]() |
c378009128 | |
![]() |
2d794d1a32 | |
![]() |
e38835cfd4 | |
![]() |
e3ba1a1840 | |
![]() |
08f6c32551 | |
![]() |
2b8d580355 | |
![]() |
ee390bc270 | |
![]() |
14e7cd0e52 | |
![]() |
6d8a52eb15 | |
![]() |
951db17d53 | |
![]() |
0d612b9928 | |
![]() |
aacc2d0596 | |
![]() |
074706e7ec | |
![]() |
1631b9587f | |
![]() |
750a470b9a | |
![]() |
37bdc8665f | |
![]() |
cbf661f69f | |
![]() |
d16144eee4 | |
![]() |
1a190b7f6f | |
![]() |
a7b294025e | |
![]() |
e2d4dd6995 | |
![]() |
d9f3078396 | |
![]() |
0908e10ff6 | |
![]() |
7d9badb542 | |
![]() |
3bd4fee844 | |
![]() |
3405c038c9 | |
![]() |
3400a0fab0 | |
![]() |
85dc3f68e7 | |
![]() |
eff8e885d5 | |
![]() |
cbc07c04a5 | |
![]() |
0003494c9e | |
![]() |
741d5c75ba | |
![]() |
2ff722eee6 | |
![]() |
39b6621463 | |
![]() |
9a07c1d858 | |
![]() |
19ae57c9ad | |
![]() |
6e0207ca5e | |
![]() |
be8d37241a | |
![]() |
e76c00c7f4 | |
![]() |
cba70fc912 | |
![]() |
048393f448 | |
![]() |
710f448477 | |
![]() |
367dab9c5a | |
![]() |
c280924c0e | |
![]() |
5dacb82b22 | |
![]() |
a54a59146d | |
![]() |
a1ea633a3e | |
![]() |
68a222e03a | |
![]() |
67bd982969 | |
![]() |
d9073de251 | |
![]() |
754684bfe9 | |
![]() |
9c37f6cbd5 | |
![]() |
208f142cd2 | |
![]() |
e5d8e2b428 | |
![]() |
0bba168f94 | |
![]() |
db3b1d74d1 | |
![]() |
50fe905455 | |
![]() |
d5e8cfd4ba | |
![]() |
ffe1815ec9 | |
![]() |
2690d04f64 | |
![]() |
3707daf678 | |
![]() |
076dce6981 | |
![]() |
d6d74f200b | |
![]() |
1a7ffa693b | |
![]() |
dbe127569b | |
![]() |
da2471567d | |
![]() |
55f5d25c95 | |
![]() |
4634564f17 | |
![]() |
300a2d8569 | |
![]() |
b4bfb8b242 | |
![]() |
6277e10b3f | |
![]() |
47ad390f1d | |
![]() |
d25d6124a9 | |
![]() |
70151279f6 | |
![]() |
431416d75e | |
![]() |
77c6f8e54f | |
![]() |
dc99e19ed9 | |
![]() |
c659e060c1 | |
![]() |
f8f3a64612 | |
![]() |
7bf37a3999 | |
![]() |
3fabdad1fe | |
![]() |
a806bb2657 | |
![]() |
91c19bff55 | |
![]() |
9691974b1a | |
![]() |
07d3d79e8d | |
![]() |
498f15cc92 | |
![]() |
b36ec266f0 | |
![]() |
c0d067d24b | |
![]() |
12c0f41477 | |
![]() |
f7c66741c6 | |
![]() |
60deb0328a | |
![]() |
0ef4579da8 | |
![]() |
55c692e8bb | |
![]() |
835f84584e | |
![]() |
bd2ad39f6a | |
![]() |
48d2b4a618 | |
![]() |
cd6ea1a4c5 | |
![]() |
4ecfb47f07 | |
![]() |
d3dd99c384 | |
![]() |
69ea470a26 | |
![]() |
65da4c42c4 | |
![]() |
cd059bd511 | |
![]() |
53053b901f | |
![]() |
17f68efb81 | |
![]() |
98ad26da3d | |
![]() |
36ac6d9956 | |
![]() |
1eb17b2fa1 | |
![]() |
33744de372 | |
![]() |
d651b36eb2 | |
![]() |
7e0db31cc1 | |
![]() |
c389156499 | |
![]() |
0207669d61 | |
![]() |
b158318e83 | |
![]() |
11bfcc6d53 | |
![]() |
9269a55e8b | |
![]() |
2583f6fe36 | |
![]() |
193d105a3f | |
![]() |
ea7837b4c6 | |
![]() |
f9c275919e | |
![]() |
38b9b9be4c | |
![]() |
9fd935770a | |
![]() |
d1489a1fb1 | |
![]() |
0568fcdb81 | |
![]() |
39c837d323 | |
![]() |
3aa7c3c2e0 | |
![]() |
7a555e19c4 | |
![]() |
26c0d85c66 | |
![]() |
613efd7599 | |
![]() |
ae179d9005 | |
![]() |
96fece4e6d | |
![]() |
9139239f9f | |
![]() |
57502d2f54 | |
![]() |
ce71f25901 | |
![]() |
fea6b87139 | |
![]() |
4157604458 | |
![]() |
117c72ba72 | |
![]() |
79d4cd9060 | |
![]() |
1438438937 | |
![]() |
80f074e2ba | |
![]() |
171bba1bcd | |
![]() |
95579bbf1d | |
![]() |
c9dca4cebd | |
![]() |
6aa83c93ac | |
![]() |
a69b88e09a | |
![]() |
5daaba6e64 | |
![]() |
2b107736e2 | |
![]() |
30d688c1ec | |
![]() |
58c75ce61a | |
![]() |
100be95113 | |
![]() |
5c037837f5 | |
![]() |
12e696bf1c | |
![]() |
55513703b2 | |
![]() |
f2eafd563e | |
![]() |
16200bbeac | |
![]() |
465fe59dfb | |
![]() |
704e3f2f0d | |
![]() |
fe02cf3e4b | |
![]() |
5e7fb5010f | |
![]() |
b322ce064b | |
![]() |
ec21faf15c | |
![]() |
e0c5ca962f | |
![]() |
37f82acff0 | |
![]() |
c04d3ef50d | |
![]() |
62b14bcf62 | |
![]() |
005f5b5103 | |
![]() |
bb6c32c897 | |
![]() |
8299fe41bc | |
![]() |
d39f1999e7 | |
![]() |
d06b7e1456 | |
![]() |
41cf9974f9 | |
![]() |
bbf5c806d8 | |
![]() |
8f0b367f9c | |
![]() |
65e12621ff | |
![]() |
84d23e91ed | |
![]() |
5e37f84bc7 | |
![]() |
11047ecd53 | |
![]() |
91a290dade | |
![]() |
ea62a449d4 | |
![]() |
faa4eaae20 | |
![]() |
c039e7e859 | |
![]() |
d9c966a95b | |
![]() |
92f574d2ca | |
![]() |
decab29555 | |
![]() |
ecc23dfb3e | |
![]() |
a5d9bae052 | |
![]() |
c04291a55e | |
![]() |
efad9a4dae | |
![]() |
3ab153225a | |
|
76314f522f | |
![]() |
55d6c431f2 | |
![]() |
ce450d1c00 | |
![]() |
9f5ee21bbe | |
![]() |
27466a4223 | |
![]() |
a279541198 | |
![]() |
309f80b25f | |
![]() |
993a6adf6e | |
![]() |
fabbdda964 | |
![]() |
cdb63e2a8c | |
![]() |
8647deafc8 | |
![]() |
dbd9db86a6 | |
![]() |
b338b18f16 | |
![]() |
0b948b655e | |
![]() |
52446c1049 | |
![]() |
fbbe25b25e | |
![]() |
f5519f8936 | |
![]() |
9f2f7780a4 | |
![]() |
9c91fd1e52 | |
![]() |
7b237ce9ad | |
![]() |
404d2dbeb1 | |
![]() |
9a04685101 | |
![]() |
a7aaa07356 | |
![]() |
71ff89a803 | |
![]() |
c336a67afa | |
![]() |
10ec454f6b | |
![]() |
d71ee4ef68 | |
![]() |
05de2baef5 | |
![]() |
f64c610fa4 | |
![]() |
ad2e3db92f | |
![]() |
13098ee378 | |
![]() |
8fdf79958f | |
![]() |
8c6ac4cd16 | |
![]() |
2685a1eb60 | |
![]() |
a54a117ba4 | |
![]() |
a4cfe616a8 | |
![]() |
f08c67bef9 | |
![]() |
b17a4391b0 | |
![]() |
1c9f5f3f64 | |
![]() |
68c254c101 | |
![]() |
d7ec891ab8 | |
![]() |
dbc13bad20 | |
![]() |
d2c8888067 | |
![]() |
8d5cafecb3 | |
![]() |
d0961a517a | |
![]() |
4c1d3eecd1 | |
![]() |
56c99e741e | |
![]() |
4bb6f9f1b3 | |
![]() |
b9305dfd45 | |
![]() |
5749fff377 | |
![]() |
4c14050b27 | |
![]() |
33b7c893cb | |
![]() |
2023756023 | |
![]() |
a92fa950e2 | |
![]() |
e63afb3461 | |
![]() |
25a8d7b5b5 | |
![]() |
4780716c18 | |
![]() |
9cb80daedf | |
![]() |
aa8122f16f | |
|
9e743e86af | |
![]() |
fd36ff3840 | |
|
5eebe300fc | |
![]() |
93f3abee1a | |
![]() |
fbe2191800 | |
![]() |
b685d0060c | |
![]() |
253cca379b | |
![]() |
e6ce4112c6 | |
![]() |
51668c12d7 | |
![]() |
16795e0d49 | |
![]() |
62b770f7d3 | |
![]() |
df415880d0 | |
![]() |
1be69a0a51 | |
![]() |
2b96eda86d | |
![]() |
f57da76ae8 | |
![]() |
a5c7187017 | |
![]() |
5112bf86df | |
![]() |
2d32e3a798 | |
![]() |
fd2b72b296 | |
![]() |
eac74c23ec | |
![]() |
242477e3ee | |
![]() |
c4385961c4 | |
![]() |
f1d6787b08 | |
![]() |
b47ee4dd1e | |
![]() |
dc6cfbb691 | |
![]() |
754dfefefd | |
![]() |
7e6782a1be | |
![]() |
56a8c5eb48 | |
![]() |
63bf6bed08 | |
![]() |
d64d78acfc | |
![]() |
69d2d39c36 | |
![]() |
a0635ae400 | |
![]() |
dc64b95406 | |
![]() |
8390d85e46 | |
![]() |
95cab790c1 | |
![]() |
b72bedaf60 | |
![]() |
5f76722ecb | |
![]() |
4905abe30b | |
![]() |
ac32e40003 | |
![]() |
52ed8041f7 | |
![]() |
0a3cdd342b | |
![]() |
d29570c20a | |
![]() |
174669ec92 | |
![]() |
f87ae45745 | |
![]() |
2fa706a123 | |
![]() |
73429315a7 | |
![]() |
61126af370 | |
![]() |
419bd1cc21 | |
![]() |
167dd01bbe | |
![]() |
df7cdd4b8e | |
![]() |
2143f21828 | |
![]() |
17e38bf66c | |
![]() |
3ec39047e1 | |
![]() |
a9717206f3 | |
![]() |
634efbcabd | |
![]() |
c15efbad7b | |
![]() |
f0ba8ec325 | |
![]() |
fde66a9422 | |
![]() |
17ece36b3e | |
![]() |
83a32b36b3 | |
![]() |
c80a816808 | |
![]() |
a2c62a9da6 | |
![]() |
86f595b8ef | |
![]() |
cc4cfd2122 | |
![]() |
c4037a885f | |
|
a2aeef0155 | |
![]() |
fa5cf01af0 | |
![]() |
1b9d40d2fb | |
![]() |
9e8ebe4595 | |
![]() |
e8f9c0292b | |
![]() |
004c861ba9 | |
![]() |
81ddda4515 | |
![]() |
3da26a38ed | |
![]() |
6c3012b8a1 | |
![]() |
90af1d9c16 | |
![]() |
7d7a29117e | |
![]() |
9cf30fd9bc | |
![]() |
df65862c49 | |
![]() |
f2d91cde80 | |
![]() |
db031c7985 | |
![]() |
a3ceecb21e | |
![]() |
da6c0c66d7 | |
![]() |
767f7f0049 | |
![]() |
85f0f88c20 | |
![]() |
870d5237bb | |
![]() |
4ae0360640 | |
![]() |
b8523aa1db | |
![]() |
bf1982f4e4 | |
![]() |
963cd1b347 | |
![]() |
4c02fe9cda | |
![]() |
70b7a63b66 | |
![]() |
31781f214c | |
![]() |
1b74cc1144 | |
![]() |
535696de28 | |
![]() |
b9297cd9f4 | |
![]() |
a78cc159f8 | |
![]() |
fbb45807f1 | |
![]() |
1c8c01ad96 | |
![]() |
97b266182b | |
![]() |
4eaa8588d7 | |
![]() |
76bb08779a | |
![]() |
03c60202b8 | |
![]() |
dcd84523ab | |
![]() |
6a23e97533 | |
![]() |
4bd6e01b65 | |
![]() |
35b22f7a7f | |
![]() |
6efc977286 | |
![]() |
a6a7b0c96c | |
![]() |
0ef21bfdbb | |
![]() |
6d7aadf987 | |
![]() |
37e4ed8029 | |
![]() |
c50b36118e | |
![]() |
47687931d7 | |
![]() |
cb364a4f96 | |
![]() |
06921e711d | |
![]() |
124467c6e1 | |
![]() |
faa4a6eefa | |
![]() |
e96e8b46b2 | |
![]() |
6a22b709d6 | |
![]() |
7449111a00 | |
![]() |
6c715ffef9 | |
![]() |
a65776e0e7 | |
![]() |
c04b2738de | |
![]() |
86dff7396e | |
![]() |
1cffbb2bd3 | |
![]() |
55c0c3221d | |
![]() |
1b93963413 | |
![]() |
a46fee4d4e | |
![]() |
a5909ac4de | |
![]() |
4a62e9ed76 | |
![]() |
0102e45855 | |
![]() |
736c0894d1 | |
![]() |
04b1944939 | |
![]() |
e108715760 | |
![]() |
3566fb4826 | |
![]() |
a3dbeb9829 | |
![]() |
50b2afbda8 | |
![]() |
5cc565439c | |
![]() |
e2eb5b91e0 | |
![]() |
86ef158c00 | |
![]() |
ebcb124b0e | |
![]() |
dece19fbec | |
![]() |
a2df003b7e | |
![]() |
fb9fa49ce8 | |
![]() |
f449d9c800 | |
![]() |
a7d4eb00b6 | |
![]() |
55b46942cb | |
![]() |
5c0cfba8ae | |
![]() |
6a0234edd5 | |
![]() |
6d584ba481 | |
![]() |
373d8de7d0 | |
![]() |
7f9efea0a2 | |
![]() |
bbf9356628 | |
![]() |
0b9673029d | |
![]() |
9a14c8c7e9 | |
![]() |
354bbf9287 | |
![]() |
7bd18f9c8e | |
![]() |
0f33dbe154 | |
![]() |
f3ae4b4209 | |
![]() |
11e67cc61b | |
![]() |
00d72d8d7b | |
![]() |
d8e0465d6d | |
![]() |
92c9031749 | |
![]() |
17ba464d33 | |
![]() |
ad33e0e624 | |
![]() |
f09768fb2d | |
![]() |
9db6bb63e4 | |
![]() |
87fec23f4b | |
![]() |
5815db4062 | |
![]() |
b925838a91 | |
![]() |
e5d994b9e2 | |
![]() |
ddab760624 | |
![]() |
0c69dc8d30 | |
![]() |
c5e8df16e0 | |
![]() |
0597c0efda | |
![]() |
621453a01c | |
![]() |
3fbfadb0d4 | |
![]() |
8f122d6603 | |
![]() |
d4b2f23c4a | |
![]() |
ad02b55541 | |
![]() |
b5466261d4 | |
![]() |
0d6218bfa0 | |
![]() |
088c661839 | |
![]() |
fc2bd68876 | |
![]() |
853d8eee5d | |
![]() |
5bf6f12ae5 | |
![]() |
69aba7c352 | |
![]() |
0d30624119 | |
![]() |
61a7aa2592 | |
![]() |
2d3d03cc38 | |
![]() |
41379ded7e | |
![]() |
5cefa57dd5 | |
![]() |
50c3c45ef8 | |
![]() |
6f3b14202e | |
![]() |
7d30a82747 | |
![]() |
cd140f1384 | |
![]() |
190e04fdd7 | |
![]() |
9c2ea5f488 | |
![]() |
b8b2d32bc1 | |
![]() |
62620a93cd | |
![]() |
ed8dc04d94 | |
![]() |
e9a153df14 | |
![]() |
472aadf9ab | |
![]() |
266944c9d2 | |
![]() |
7268bcca11 | |
![]() |
edeae704f9 | |
![]() |
723c552783 | |
![]() |
e823c209fa | |
![]() |
1b47cf76d3 | |
![]() |
3f04654cd3 | |
![]() |
5b2b632de3 | |
![]() |
5b2f3111b6 | |
![]() |
146581e44c | |
![]() |
02eb4623b9 | |
![]() |
d0e29d4875 | |
![]() |
caf58c8ab8 | |
![]() |
4119e669d1 | |
![]() |
285350464f | |
![]() |
2a003a27b1 | |
![]() |
5e606336ca | |
![]() |
f51f457023 | |
![]() |
bd0c6d4344 | |
![]() |
a15b3e4dd4 | |
![]() |
0fddd79501 | |
![]() |
ca0ff013d4 | |
![]() |
94aa76e7a1 | |
![]() |
e01a6bd0ef | |
![]() |
7eb1df4119 | |
![]() |
db23c6eecf | |
![]() |
5f8b7a8149 | |
![]() |
e8b93f6cda | |
![]() |
614dc5e591 | |
![]() |
03c7d2e7ee | |
![]() |
d06116eb49 | |
![]() |
b72e802ff7 | |
![]() |
46bef8fd92 | |
![]() |
d470d9e63c | |
![]() |
d072680715 | |
![]() |
0b36bdf37f | |
![]() |
9a33551a03 | |
![]() |
37fab2fad2 | |
![]() |
b04d8ca99d | |
![]() |
a024866fd3 |
|
@ -0,0 +1,211 @@
|
||||||
|
name: Build
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-linux:
|
||||||
|
runs-on: ${{ matrix.host_os }}
|
||||||
|
container: ${{ matrix.container }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target_os: [linux]
|
||||||
|
host_os: [ubuntu-20.04]
|
||||||
|
container: ['']
|
||||||
|
fail-fast: false
|
||||||
|
steps:
|
||||||
|
- name: Install Colobot dependencies
|
||||||
|
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends build-essential cmake libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsndfile1-dev libvorbis-dev libogg-dev libpng-dev libglew-dev libopenal-dev libphysfs-dev gettext git po4a vorbis-tools librsvg2-bin xmlstarlet libglm-dev libmpg123-dev
|
||||||
|
if: matrix.container == ''
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Checkout the Google Test submodule
|
||||||
|
run: git submodule update --init -- lib/googletest
|
||||||
|
- name: Checkout the nlohmann json submodule
|
||||||
|
run: git submodule update --init -- lib/json
|
||||||
|
- name: Create build directory
|
||||||
|
run: cmake -E make_directory build
|
||||||
|
- name: Run CMake (for Linux)
|
||||||
|
run: cmake --preset Linux-CI
|
||||||
|
if: matrix.target_os == 'linux'
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build --preset Linux-CI
|
||||||
|
- name: Install
|
||||||
|
run: cmake --build --preset Linux-CI --target install
|
||||||
|
- name: Patch library path
|
||||||
|
run: patchelf --set-rpath '.' install/colobot
|
||||||
|
if: matrix.target_os == 'linux'
|
||||||
|
- name: Upload build
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{matrix.target_os}}-debug
|
||||||
|
path: install
|
||||||
|
if: matrix.host_os == 'ubuntu-20.04'
|
||||||
|
- name: Create AppImage
|
||||||
|
working-directory: build
|
||||||
|
run: |
|
||||||
|
# Download app image tool
|
||||||
|
wget -N https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
|
||||||
|
chmod +x linuxdeploy-x86_64.AppImage
|
||||||
|
./linuxdeploy-x86_64.AppImage --appimage-extract
|
||||||
|
|
||||||
|
# Create AppImage
|
||||||
|
NO_STRIP=1 ./squashfs-root/AppRun -e colobot --output appimage --appdir colobot.AppDir -d desktop/colobot.desktop -i ../desktop/colobot.svg
|
||||||
|
chmod +x Colobot-x86_64.AppImage
|
||||||
|
|
||||||
|
# Prepare folder for zip
|
||||||
|
mkdir -p appimage
|
||||||
|
cp -rp ../install/data appimage/data
|
||||||
|
cp -rp ../install/lang appimage/lang
|
||||||
|
cp -p Colobot-x86_64.AppImage appimage/colobot
|
||||||
|
if: matrix.target_os == 'linux'
|
||||||
|
- name: Upload AppImage
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{matrix.target_os}}-debug-AppImage
|
||||||
|
path: build/appimage
|
||||||
|
if: matrix.target_os == 'linux' && matrix.host_os == 'ubuntu-20.04'
|
||||||
|
- name: Run tests
|
||||||
|
# TODO: Maybe run Windows tests using wine as well?
|
||||||
|
working-directory: build
|
||||||
|
run: ./Colobot-UnitTests --gtest_output=xml:gtestresults.xml
|
||||||
|
if: matrix.target_os == 'linux'
|
||||||
|
- name: Upload test results
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: Test results (${{ matrix.target_os }}, ${{ matrix.host_os }})
|
||||||
|
path: build/gtestresults.xml
|
||||||
|
if: matrix.target_os == 'linux'
|
||||||
|
build-macos:
|
||||||
|
runs-on: ${{ matrix.host_os }}
|
||||||
|
container: ${{ matrix.container }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target_os: [macos]
|
||||||
|
host_os: [macos-11, macos-12]
|
||||||
|
container: ['']
|
||||||
|
fail-fast: false
|
||||||
|
steps:
|
||||||
|
- name: Install Colobot dependencies
|
||||||
|
run: brew install cmake sdl2 sdl2_image sdl2_ttf glew physfs flac libsndfile libvorbis vorbis-tools gettext libicns librsvg wget xmlstarlet glm
|
||||||
|
if: matrix.container == ''
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Checkout the Google Test submodule
|
||||||
|
run: git submodule update --init -- lib/googletest
|
||||||
|
- name: Checkout the nlohmann json submodule
|
||||||
|
run: git submodule update --init -- lib/json
|
||||||
|
- name: Create build directory
|
||||||
|
run: cmake -E make_directory build
|
||||||
|
- name: Run CMake (for Mac)
|
||||||
|
run: cmake --preset MacOS-CI
|
||||||
|
if: matrix.target_os == 'macos'
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build --preset MacOS-CI
|
||||||
|
- name: Run tests
|
||||||
|
# TODO: Maybe run Windows tests using wine as well?
|
||||||
|
working-directory: build
|
||||||
|
run: ./Colobot-UnitTests --gtest_output=xml:gtestresults.xml
|
||||||
|
if: matrix.target_os == 'macos'
|
||||||
|
- name: Upload test results
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: Test results (${{ matrix.target_os }}, ${{ matrix.host_os }})
|
||||||
|
path: build/gtestresults.xml
|
||||||
|
if: matrix.target_os == 'macos'
|
||||||
|
build-windows:
|
||||||
|
runs-on: windows-2019
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- arch: amd64
|
||||||
|
vcpkg_triplet: 'x64-windows-static'
|
||||||
|
- arch: x86
|
||||||
|
vcpkg_triplet: 'x86-windows-static'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Checkout the Google Test submodule
|
||||||
|
run: git submodule update --init -- lib/googletest
|
||||||
|
- name: Checkout the nlohmann json submodule
|
||||||
|
run: git submodule update --init -- lib/json
|
||||||
|
- name: Install Ninja
|
||||||
|
uses: seanmiddleditch/gha-setup-ninja@master
|
||||||
|
- name: Setup VS Environment
|
||||||
|
uses: seanmiddleditch/gha-setup-vsdevenv@master
|
||||||
|
with:
|
||||||
|
arch: ${{ matrix.arch }}
|
||||||
|
- name: Install Colobot dependencies
|
||||||
|
uses: lukka/run-vcpkg@v7
|
||||||
|
with:
|
||||||
|
setupOnly: true
|
||||||
|
vcpkgGitCommitId: 'f6a5d4e8eb7476b8d7fc12a56dff300c1c986131'
|
||||||
|
vcpkgTriplet: ${{ matrix.vcpkg_triplet }}
|
||||||
|
# SHA-256 hash of the vcpkg.json file, recalculated automatically when it changes
|
||||||
|
appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }}
|
||||||
|
additionalCachedPaths: ${{ github.workspace }}/build/vcpkg_installed
|
||||||
|
- name: Install external tools
|
||||||
|
working-directory: ${{ github.workspace }}
|
||||||
|
run: |
|
||||||
|
echo "Downloading gettext..."
|
||||||
|
(New-Object System.Net.WebClient).DownloadFile("https://github.com/mlocati/gettext-iconv-windows/releases/download/v0.20.2-v1.16/gettext0.20.2-iconv1.16-static-64.zip", "gettext.zip");
|
||||||
|
echo "Unpacking gettext..."
|
||||||
|
7z x -ogettext gettext.zip;
|
||||||
|
echo "Adding gettext to PATH..."
|
||||||
|
echo "${{ github.workspace }}\gettext\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
|
echo "Downloading xmlstarlet..."
|
||||||
|
(New-Object System.Net.WebClient).DownloadFile("https://downloads.sourceforge.net/project/xmlstar/xmlstarlet/1.6.1/xmlstarlet-1.6.1-win32.zip", "xmlstarlet.zip");
|
||||||
|
echo "Unpacking xmlstarlet..."
|
||||||
|
7z x -oxmlstarlet xmlstarlet.zip;
|
||||||
|
echo "Renaming xml.exe to xmlstarlet.exe"
|
||||||
|
Rename-Item -Path "${{ github.workspace }}\xmlstarlet\xmlstarlet-1.6.1\xml.exe" -NewName "xmlstarlet.exe"
|
||||||
|
echo "Adding xmlstarlet to PATH..."
|
||||||
|
echo "${{ github.workspace }}\xmlstarlet\xmlstarlet-1.6.1" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
|
echo "Downloading rsvg-convert..."
|
||||||
|
(New-Object System.Net.WebClient).DownloadFile("https://downloads.sourceforge.net/project/tumagcc/rsvg-convert-2.40.20.7z", "rsvg-convert.zip");
|
||||||
|
echo "Unpacking xmlstarlet..."
|
||||||
|
7z x -orsvg-convert rsvg-convert.zip;
|
||||||
|
echo "Adding rsvg-convert to PATH..."
|
||||||
|
echo "${{ github.workspace }}\rsvg-convert" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
|
shell: pwsh
|
||||||
|
- name: Create build directory
|
||||||
|
run: cmake -E make_directory build
|
||||||
|
- name: Run CMake (for Windows)
|
||||||
|
run: cmake --preset Windows-CI -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }} -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}\scripts\buildsystems\vcpkg.cmake
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
$nproc = (Get-CIMInstance -Class 'CIM_Processor').NumberOfLogicalProcessors
|
||||||
|
cmake --build --preset Windows-CI -j $nproc
|
||||||
|
shell: pwsh
|
||||||
|
- name: Install
|
||||||
|
run: cmake --build --preset Windows-CI --target install
|
||||||
|
- name: Upload build
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: windows-msvc-debug-${{ matrix.arch }}
|
||||||
|
path: install
|
||||||
|
- name: Run tests
|
||||||
|
working-directory: build
|
||||||
|
run: ./Colobot-UnitTests --gtest_output=xml:gtestresults.xml
|
||||||
|
- name: Upload test results
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: 'Test results (windows, MSVC, ${{ matrix.arch }})'
|
||||||
|
path: build/gtestresults.xml
|
||||||
|
doc:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Colobot dependencies
|
||||||
|
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends build-essential cmake libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsndfile1-dev libvorbis-dev libogg-dev libpng-dev libglew-dev libopenal-dev libphysfs-dev gettext git po4a vorbis-tools librsvg2-bin xmlstarlet doxygen graphviz libglm-dev libmpg123-dev
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Create build directory
|
||||||
|
run: cmake -E make_directory build
|
||||||
|
- name: Checkout the nlohmann json submodule
|
||||||
|
run: git submodule update --init -- lib/json
|
||||||
|
- name: Run CMake
|
||||||
|
working-directory: build
|
||||||
|
run: cmake ..
|
||||||
|
- name: Build docs
|
||||||
|
working-directory: build
|
||||||
|
run: make doc
|
||||||
|
- name: Upload docs
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: doc
|
||||||
|
path: build/doc
|
|
@ -0,0 +1,21 @@
|
||||||
|
name: Verify pull request target
|
||||||
|
|
||||||
|
on: [pull_request_target]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check_pr_target:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Send comment if wrong pull request target
|
||||||
|
if: github.base_ref == 'master'
|
||||||
|
uses: peter-evans/create-or-update-comment@v1
|
||||||
|
with:
|
||||||
|
issue-number: ${{ github.event.number }}
|
||||||
|
body: |
|
||||||
|
Hey! This pull request targets the `master` branch. You should probably target `dev` instead. Make sure to read the [contributing guidelines](https://github.com/colobot/colobot/blob/master/CONTRIBUTING.md#submitting-pull-requests) and [edit the target branch if necessary](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/changing-the-base-branch-of-a-pull-request).
|
||||||
|
- name: Wrong pull request target
|
||||||
|
if: github.base_ref == 'master'
|
||||||
|
run: echo "This pull request targets the master branch. Please edit the pull request to target dev." && exit 1
|
||||||
|
- name: Correct pull request target
|
||||||
|
if: github.base_ref != 'master'
|
||||||
|
run: echo "This pull request targets the correct branch." && exit 0
|
|
@ -11,11 +11,12 @@ Makefile
|
||||||
/src/libcolobotbase.a
|
/src/libcolobotbase.a
|
||||||
|
|
||||||
# Ignore the generated documentation
|
# Ignore the generated documentation
|
||||||
|
CMakeDoxyfile.in
|
||||||
|
CMakeDoxygenDefaults.cmake
|
||||||
/doc
|
/doc
|
||||||
/Doxyfile
|
/Doxyfile
|
||||||
|
|
||||||
# Ignore targets
|
# Ignore targets
|
||||||
/colobot
|
|
||||||
/src/CBot/libCBot.so
|
/src/CBot/libCBot.so
|
||||||
|
|
||||||
# Ignore local data
|
# Ignore local data
|
||||||
|
@ -23,7 +24,7 @@ Makefile
|
||||||
/saves
|
/saves
|
||||||
|
|
||||||
# Standard build directory
|
# Standard build directory
|
||||||
/build
|
/build*
|
||||||
|
|
||||||
# Ignore KDevelop files
|
# Ignore KDevelop files
|
||||||
.kdev4
|
.kdev4
|
||||||
|
@ -39,6 +40,13 @@ CMakeLists.txt.user.*
|
||||||
# Ignore Visual Studio Code files
|
# Ignore Visual Studio Code files
|
||||||
/.vscode
|
/.vscode
|
||||||
|
|
||||||
|
# Ignore CLion files
|
||||||
|
/.idea
|
||||||
|
|
||||||
# Ignore Visual Studio files
|
# Ignore Visual Studio files
|
||||||
/CMakeSettings.json
|
/CMakeSettings.json
|
||||||
/.vs
|
/.vs
|
||||||
|
/out
|
||||||
|
|
||||||
|
# Ignore CMakeUserPresets.json
|
||||||
|
CMakeUserPresets.json
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
[submodule "data"]
|
[submodule "data"]
|
||||||
path = data
|
path = data
|
||||||
url = git://github.com/colobot/colobot-data.git
|
url = https://github.com/colobot/colobot-data.git
|
||||||
|
branch = .
|
||||||
|
update = rebase
|
||||||
|
[submodule "lib/googletest"]
|
||||||
|
path = lib/googletest
|
||||||
|
url = https://github.com/google/googletest.git
|
||||||
|
ignore = all
|
||||||
|
[submodule "lib/json"]
|
||||||
|
path = lib/json
|
||||||
|
url = https://github.com/nlohmann/json
|
||||||
|
|
|
@ -0,0 +1,175 @@
|
||||||
|
if(CBOT_STATIC)
|
||||||
|
add_library(CBot STATIC)
|
||||||
|
else()
|
||||||
|
add_library(CBot SHARED)
|
||||||
|
install(TARGETS CBot
|
||||||
|
LIBRARY DESTINATION ${COLOBOT_INSTALL_LIB_DIR}
|
||||||
|
ARCHIVE DESTINATION ${COLOBOT_INSTALL_LIB_DIR}
|
||||||
|
RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_sources(CBot PRIVATE
|
||||||
|
src/CBot/CBot.h
|
||||||
|
src/CBot/CBotCStack.cpp
|
||||||
|
src/CBot/CBotCStack.h
|
||||||
|
src/CBot/CBotClass.cpp
|
||||||
|
src/CBot/CBotClass.h
|
||||||
|
src/CBot/CBotDebug.cpp
|
||||||
|
src/CBot/CBotDebug.h
|
||||||
|
src/CBot/CBotDefParam.cpp
|
||||||
|
src/CBot/CBotDefParam.h
|
||||||
|
src/CBot/CBotDefines.h
|
||||||
|
src/CBot/CBotEnums.h
|
||||||
|
src/CBot/CBotExternalCall.cpp
|
||||||
|
src/CBot/CBotExternalCall.h
|
||||||
|
src/CBot/CBotFileUtils.cpp
|
||||||
|
src/CBot/CBotFileUtils.h
|
||||||
|
src/CBot/CBotInstr/CBotBlock.cpp
|
||||||
|
src/CBot/CBotInstr/CBotBlock.h
|
||||||
|
src/CBot/CBotInstr/CBotBoolExpr.cpp
|
||||||
|
src/CBot/CBotInstr/CBotBoolExpr.h
|
||||||
|
src/CBot/CBotInstr/CBotBreak.cpp
|
||||||
|
src/CBot/CBotInstr/CBotBreak.h
|
||||||
|
src/CBot/CBotInstr/CBotCase.cpp
|
||||||
|
src/CBot/CBotInstr/CBotCase.h
|
||||||
|
src/CBot/CBotInstr/CBotCatch.cpp
|
||||||
|
src/CBot/CBotInstr/CBotCatch.h
|
||||||
|
src/CBot/CBotInstr/CBotCondition.cpp
|
||||||
|
src/CBot/CBotInstr/CBotCondition.h
|
||||||
|
src/CBot/CBotInstr/CBotDefArray.cpp
|
||||||
|
src/CBot/CBotInstr/CBotDefArray.h
|
||||||
|
src/CBot/CBotInstr/CBotDefBoolean.cpp
|
||||||
|
src/CBot/CBotInstr/CBotDefBoolean.h
|
||||||
|
src/CBot/CBotInstr/CBotDefClass.cpp
|
||||||
|
src/CBot/CBotInstr/CBotDefClass.h
|
||||||
|
src/CBot/CBotInstr/CBotDefFloat.cpp
|
||||||
|
src/CBot/CBotInstr/CBotDefFloat.h
|
||||||
|
src/CBot/CBotInstr/CBotDefInt.cpp
|
||||||
|
src/CBot/CBotInstr/CBotDefInt.h
|
||||||
|
src/CBot/CBotInstr/CBotDefString.cpp
|
||||||
|
src/CBot/CBotInstr/CBotDefString.h
|
||||||
|
src/CBot/CBotInstr/CBotDo.cpp
|
||||||
|
src/CBot/CBotInstr/CBotDo.h
|
||||||
|
src/CBot/CBotInstr/CBotEmpty.cpp
|
||||||
|
src/CBot/CBotInstr/CBotEmpty.h
|
||||||
|
src/CBot/CBotInstr/CBotExprLitBool.cpp
|
||||||
|
src/CBot/CBotInstr/CBotExprLitBool.h
|
||||||
|
src/CBot/CBotInstr/CBotExprLitChar.cpp
|
||||||
|
src/CBot/CBotInstr/CBotExprLitChar.h
|
||||||
|
src/CBot/CBotInstr/CBotExprLitNan.cpp
|
||||||
|
src/CBot/CBotInstr/CBotExprLitNan.h
|
||||||
|
src/CBot/CBotInstr/CBotExprLitNull.cpp
|
||||||
|
src/CBot/CBotInstr/CBotExprLitNull.h
|
||||||
|
src/CBot/CBotInstr/CBotExprLitNum.cpp
|
||||||
|
src/CBot/CBotInstr/CBotExprLitNum.h
|
||||||
|
src/CBot/CBotInstr/CBotExprLitString.cpp
|
||||||
|
src/CBot/CBotInstr/CBotExprLitString.h
|
||||||
|
src/CBot/CBotInstr/CBotExprRetVar.cpp
|
||||||
|
src/CBot/CBotInstr/CBotExprRetVar.h
|
||||||
|
src/CBot/CBotInstr/CBotExprUnaire.cpp
|
||||||
|
src/CBot/CBotInstr/CBotExprUnaire.h
|
||||||
|
src/CBot/CBotInstr/CBotExprVar.cpp
|
||||||
|
src/CBot/CBotInstr/CBotExprVar.h
|
||||||
|
src/CBot/CBotInstr/CBotExpression.cpp
|
||||||
|
src/CBot/CBotInstr/CBotExpression.h
|
||||||
|
src/CBot/CBotInstr/CBotFieldExpr.cpp
|
||||||
|
src/CBot/CBotInstr/CBotFieldExpr.h
|
||||||
|
src/CBot/CBotInstr/CBotFor.cpp
|
||||||
|
src/CBot/CBotInstr/CBotFor.h
|
||||||
|
src/CBot/CBotInstr/CBotFunction.cpp
|
||||||
|
src/CBot/CBotInstr/CBotFunction.h
|
||||||
|
src/CBot/CBotInstr/CBotIf.cpp
|
||||||
|
src/CBot/CBotInstr/CBotIf.h
|
||||||
|
src/CBot/CBotInstr/CBotIndexExpr.cpp
|
||||||
|
src/CBot/CBotInstr/CBotIndexExpr.h
|
||||||
|
src/CBot/CBotInstr/CBotInstr.cpp
|
||||||
|
src/CBot/CBotInstr/CBotInstr.h
|
||||||
|
src/CBot/CBotInstr/CBotInstrCall.cpp
|
||||||
|
src/CBot/CBotInstr/CBotInstrCall.h
|
||||||
|
src/CBot/CBotInstr/CBotInstrMethode.cpp
|
||||||
|
src/CBot/CBotInstr/CBotInstrMethode.h
|
||||||
|
src/CBot/CBotInstr/CBotInstrUtils.cpp
|
||||||
|
src/CBot/CBotInstr/CBotInstrUtils.h
|
||||||
|
src/CBot/CBotInstr/CBotLeftExpr.cpp
|
||||||
|
src/CBot/CBotInstr/CBotLeftExpr.h
|
||||||
|
src/CBot/CBotInstr/CBotLeftExprVar.cpp
|
||||||
|
src/CBot/CBotInstr/CBotLeftExprVar.h
|
||||||
|
src/CBot/CBotInstr/CBotListArray.cpp
|
||||||
|
src/CBot/CBotInstr/CBotListArray.h
|
||||||
|
src/CBot/CBotInstr/CBotListExpression.cpp
|
||||||
|
src/CBot/CBotInstr/CBotListExpression.h
|
||||||
|
src/CBot/CBotInstr/CBotListInstr.cpp
|
||||||
|
src/CBot/CBotInstr/CBotListInstr.h
|
||||||
|
src/CBot/CBotInstr/CBotLogicExpr.cpp
|
||||||
|
src/CBot/CBotInstr/CBotLogicExpr.h
|
||||||
|
src/CBot/CBotInstr/CBotNew.cpp
|
||||||
|
src/CBot/CBotInstr/CBotNew.h
|
||||||
|
src/CBot/CBotInstr/CBotParExpr.cpp
|
||||||
|
src/CBot/CBotInstr/CBotParExpr.h
|
||||||
|
src/CBot/CBotInstr/CBotPostIncExpr.cpp
|
||||||
|
src/CBot/CBotInstr/CBotPostIncExpr.h
|
||||||
|
src/CBot/CBotInstr/CBotPreIncExpr.cpp
|
||||||
|
src/CBot/CBotInstr/CBotPreIncExpr.h
|
||||||
|
src/CBot/CBotInstr/CBotRepeat.cpp
|
||||||
|
src/CBot/CBotInstr/CBotRepeat.h
|
||||||
|
src/CBot/CBotInstr/CBotReturn.cpp
|
||||||
|
src/CBot/CBotInstr/CBotReturn.h
|
||||||
|
src/CBot/CBotInstr/CBotSwitch.cpp
|
||||||
|
src/CBot/CBotInstr/CBotSwitch.h
|
||||||
|
src/CBot/CBotInstr/CBotThrow.cpp
|
||||||
|
src/CBot/CBotInstr/CBotThrow.h
|
||||||
|
src/CBot/CBotInstr/CBotTry.cpp
|
||||||
|
src/CBot/CBotInstr/CBotTry.h
|
||||||
|
src/CBot/CBotInstr/CBotTwoOpExpr.cpp
|
||||||
|
src/CBot/CBotInstr/CBotTwoOpExpr.h
|
||||||
|
src/CBot/CBotInstr/CBotWhile.cpp
|
||||||
|
src/CBot/CBotInstr/CBotWhile.h
|
||||||
|
src/CBot/CBotProgram.cpp
|
||||||
|
src/CBot/CBotProgram.h
|
||||||
|
src/CBot/CBotStack.cpp
|
||||||
|
src/CBot/CBotStack.h
|
||||||
|
src/CBot/CBotToken.cpp
|
||||||
|
src/CBot/CBotToken.h
|
||||||
|
src/CBot/CBotTypResult.cpp
|
||||||
|
src/CBot/CBotTypResult.h
|
||||||
|
src/CBot/CBotUtils.cpp
|
||||||
|
src/CBot/CBotUtils.h
|
||||||
|
src/CBot/CBotVar/CBotVar.cpp
|
||||||
|
src/CBot/CBotVar/CBotVar.h
|
||||||
|
src/CBot/CBotVar/CBotVarValue.h
|
||||||
|
src/CBot/CBotVar/CBotVarArray.cpp
|
||||||
|
src/CBot/CBotVar/CBotVarArray.h
|
||||||
|
src/CBot/CBotVar/CBotVarBoolean.cpp
|
||||||
|
src/CBot/CBotVar/CBotVarBoolean.h
|
||||||
|
src/CBot/CBotVar/CBotVarByte.h
|
||||||
|
src/CBot/CBotVar/CBotVarChar.h
|
||||||
|
src/CBot/CBotVar/CBotVarClass.cpp
|
||||||
|
src/CBot/CBotVar/CBotVarClass.h
|
||||||
|
src/CBot/CBotVar/CBotVarDouble.h
|
||||||
|
src/CBot/CBotVar/CBotVarFloat.cpp
|
||||||
|
src/CBot/CBotVar/CBotVarFloat.h
|
||||||
|
src/CBot/CBotVar/CBotVarInt.cpp
|
||||||
|
src/CBot/CBotVar/CBotVarInt.h
|
||||||
|
src/CBot/CBotVar/CBotVarLong.h
|
||||||
|
src/CBot/CBotVar/CBotVarPointer.cpp
|
||||||
|
src/CBot/CBotVar/CBotVarPointer.h
|
||||||
|
src/CBot/CBotVar/CBotVarShort.h
|
||||||
|
src/CBot/CBotVar/CBotVarString.cpp
|
||||||
|
src/CBot/CBotVar/CBotVarString.h
|
||||||
|
src/CBot/stdlib/Compilation.cpp
|
||||||
|
src/CBot/stdlib/Compilation.h
|
||||||
|
src/CBot/stdlib/FileFunctions.cpp
|
||||||
|
src/CBot/stdlib/MathFunctions.cpp
|
||||||
|
src/CBot/stdlib/StringFunctions.cpp
|
||||||
|
src/CBot/stdlib/stdlib.h
|
||||||
|
src/CBot/stdlib/stdlib_public.h
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(CBot PUBLIC src)
|
||||||
|
target_link_libraries(CBot PRIVATE
|
||||||
|
Colobot-Common
|
||||||
|
)
|
||||||
|
|
||||||
|
if(COLOBOT_LINT_BUILD)
|
||||||
|
add_fake_header_sources("src/CBot" CBot)
|
||||||
|
endif()
|
|
@ -1,9 +1,10 @@
|
||||||
/**
|
/**
|
||||||
* \dir src/CBot
|
* \dir CBot
|
||||||
* \brief CBot library
|
* \brief CBot library
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \namespace CBot
|
* \namespace CBot
|
||||||
* \brief CBot engine
|
* \brief CBot engine
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "CBot/CBotCStack.h"
|
#include "CBot/CBotCStack.h"
|
||||||
|
|
||||||
|
#include "CBot/CBotClass.h"
|
||||||
#include "CBot/CBotToken.h"
|
#include "CBot/CBotToken.h"
|
||||||
#include "CBot/CBotExternalCall.h"
|
#include "CBot/CBotExternalCall.h"
|
||||||
|
|
||||||
|
@ -30,107 +31,100 @@
|
||||||
namespace CBot
|
namespace CBot
|
||||||
{
|
{
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
struct CBotCStack::Data
|
||||||
CBotProgram* CBotCStack::m_prog = nullptr; // init the static variable
|
{
|
||||||
CBotError CBotCStack::m_error = CBotNoErr;
|
//! The program currently being compiled
|
||||||
int CBotCStack::m_end = 0;
|
CBotProgram* prog = nullptr;
|
||||||
CBotTypResult CBotCStack::m_retTyp = CBotTypResult(0);
|
//! The current error state of the compile stack
|
||||||
|
CBotError error = CBotNoErr;
|
||||||
|
int errEnd = 0;
|
||||||
|
//! The return type of the function currently being compiled
|
||||||
|
CBotTypResult retTyp = CBotTypResult(CBotTypVoid);
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
CBotCStack::CBotCStack(CBotCStack* ppapa)
|
CBotCStack::CBotCStack(CBotCStack* ppapa)
|
||||||
{
|
{
|
||||||
m_next = nullptr;
|
|
||||||
m_prev = ppapa;
|
m_prev = ppapa;
|
||||||
|
|
||||||
if (ppapa == nullptr)
|
if (ppapa == nullptr)
|
||||||
{
|
{
|
||||||
m_error = CBotNoErr;
|
m_data = new CBotCStack::Data;
|
||||||
m_start = 0;
|
m_errStart = 0;
|
||||||
m_end = 0;
|
|
||||||
m_bBlock = true;
|
m_bBlock = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_start = ppapa->m_start;
|
m_data = ppapa->m_data;
|
||||||
|
m_errStart = ppapa->m_errStart;
|
||||||
m_bBlock = false;
|
m_bBlock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_listVar = nullptr;
|
|
||||||
m_var = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CBotCStack::~CBotCStack()
|
CBotCStack::~CBotCStack()
|
||||||
{
|
{
|
||||||
if (m_next != nullptr) delete m_next;
|
if (m_prev == nullptr) delete m_data;
|
||||||
if (m_prev != nullptr) m_prev->m_next = nullptr; // removes chain
|
|
||||||
|
|
||||||
delete m_var;
|
|
||||||
delete m_listVar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CBotCStack* CBotCStack::TokenStack(CBotToken* pToken, bool bBlock)
|
CBotCStack* CBotCStack::TokenStack(CBotToken* pToken, bool bBlock)
|
||||||
{
|
{
|
||||||
if (m_next != nullptr) return m_next; // include on an existing stack
|
if (m_next) return m_next.get(); // include on an existing stack
|
||||||
|
|
||||||
CBotCStack* p = new CBotCStack(this);
|
m_next.reset(new CBotCStack(this));
|
||||||
m_next = p; // channel element
|
m_next->m_bBlock = bBlock;
|
||||||
p->m_bBlock = bBlock;
|
|
||||||
|
|
||||||
if (pToken != nullptr) p->SetStartError(pToken->GetStart());
|
if (pToken != nullptr) m_next->SetStartError(pToken->GetStart());
|
||||||
|
|
||||||
return p;
|
return m_next.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBotCStack::DeleteNext()
|
||||||
|
{
|
||||||
|
m_next.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
CBotInstr* CBotCStack::Return(CBotInstr* inst, CBotCStack* pfils)
|
CBotInstr* CBotCStack::Return(CBotInstr* inst, CBotCStack* pfils)
|
||||||
{
|
{
|
||||||
if ( pfils == this ) return inst;
|
if ( pfils == this ) return inst;
|
||||||
|
|
||||||
if (m_var != nullptr) delete m_var; // value replaced?
|
m_var = std::move(pfils->m_var); // result transmitted
|
||||||
m_var = pfils->m_var; // result transmitted
|
|
||||||
pfils->m_var = nullptr; // not to destroy the variable
|
|
||||||
|
|
||||||
if (m_error)
|
if (m_data->error != CBotNoErr)
|
||||||
{
|
{
|
||||||
m_start = pfils->m_start; // retrieves the position of the error
|
m_errStart = pfils->m_errStart; // retrieves the position of the error
|
||||||
m_end = pfils->m_end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete pfils;
|
m_next.reset();
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CBotFunction* CBotCStack::ReturnFunc(CBotFunction* inst, CBotCStack* pfils)
|
CBotFunction* CBotCStack::ReturnFunc(CBotFunction* inst, CBotCStack* pfils)
|
||||||
{
|
{
|
||||||
if (m_var != nullptr) delete m_var; // value replaced?
|
m_var = std::move(pfils->m_var); // result transmitted
|
||||||
m_var = pfils->m_var; // result transmitted
|
|
||||||
pfils->m_var = nullptr; // not to destroy the variable
|
|
||||||
|
|
||||||
if (m_error)
|
if (m_data->error != CBotNoErr)
|
||||||
{
|
{
|
||||||
m_start = pfils->m_start; // retrieves the position of the error
|
m_errStart = pfils->m_errStart; // retrieves the position of the error
|
||||||
m_end = pfils->m_end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete pfils;
|
m_next.reset();
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CBotError CBotCStack::GetError(int& start, int& end)
|
CBotError CBotCStack::GetError(int& start, int& end)
|
||||||
{
|
{
|
||||||
start = m_start;
|
start = m_errStart;
|
||||||
end = m_end;
|
end = m_data->errEnd;
|
||||||
return m_error;
|
return m_data->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CBotError CBotCStack::GetError()
|
CBotError CBotCStack::GetError()
|
||||||
{
|
{
|
||||||
return m_error;
|
return m_data->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -170,18 +164,13 @@ void CBotCStack::SetType(CBotTypResult& type)
|
||||||
CBotVar* CBotCStack::FindVar(CBotToken* &pToken)
|
CBotVar* CBotCStack::FindVar(CBotToken* &pToken)
|
||||||
{
|
{
|
||||||
CBotCStack* p = this;
|
CBotCStack* p = this;
|
||||||
std::string name = pToken->GetString();
|
const auto& name = pToken->GetString();
|
||||||
|
|
||||||
while (p != nullptr)
|
while (p != nullptr)
|
||||||
{
|
{
|
||||||
CBotVar* pp = p->m_listVar;
|
if (p->m_bBlock) for (auto& var : p->m_listVar)
|
||||||
while ( pp != nullptr)
|
|
||||||
{
|
{
|
||||||
if (name == pp->GetName())
|
if (name == var->GetName()) return var.get();
|
||||||
{
|
|
||||||
return pp;
|
|
||||||
}
|
|
||||||
pp = pp->m_next;
|
|
||||||
}
|
}
|
||||||
p = p->m_prev;
|
p = p->m_prev;
|
||||||
}
|
}
|
||||||
|
@ -210,39 +199,39 @@ CBotVar* CBotCStack::CopyVar(CBotToken& Token)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool CBotCStack::IsOk()
|
bool CBotCStack::IsOk()
|
||||||
{
|
{
|
||||||
return (m_error == 0);
|
return (m_data->error == CBotNoErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CBotCStack::SetStartError( int pos )
|
void CBotCStack::SetStartError( int pos )
|
||||||
{
|
{
|
||||||
if ( m_error != 0) return; // does not change existing error
|
if (m_data->error != CBotNoErr) return; // does not change existing error
|
||||||
m_start = pos;
|
m_errStart = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CBotCStack::SetError(CBotError n, int pos)
|
void CBotCStack::SetError(CBotError n, int pos)
|
||||||
{
|
{
|
||||||
if ( n!= 0 && m_error != 0) return; // does not change existing error
|
if (n != CBotNoErr && m_data->error != CBotNoErr) return; // does not change existing error
|
||||||
m_error = n;
|
m_data->error = n;
|
||||||
m_end = pos;
|
m_data->errEnd = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CBotCStack::SetError(CBotError n, CBotToken* p)
|
void CBotCStack::SetError(CBotError n, CBotToken* p)
|
||||||
{
|
{
|
||||||
if (m_error) return; // does not change existing error
|
if (m_data->error != CBotNoErr) return; // does not change existing error
|
||||||
m_error = n;
|
m_data->error = n;
|
||||||
m_start = p->GetStart();
|
m_errStart = p->GetStart();
|
||||||
m_end = p->GetEnd();
|
m_data->errEnd = p->GetEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CBotCStack::ResetError(CBotError n, int start, int end)
|
void CBotCStack::ResetError(CBotError n, int start, int end)
|
||||||
{
|
{
|
||||||
m_error = n;
|
m_data->error = n;
|
||||||
m_start = start;
|
m_errStart = start;
|
||||||
m_end = end;
|
m_data->errEnd = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -260,48 +249,47 @@ bool CBotCStack::NextToken(CBotToken* &p)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CBotCStack::SetProgram(CBotProgram* p)
|
void CBotCStack::SetProgram(CBotProgram* p)
|
||||||
{
|
{
|
||||||
m_prog = p;
|
m_data->prog = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CBotProgram* CBotCStack::GetProgram()
|
CBotProgram* CBotCStack::GetProgram()
|
||||||
{
|
{
|
||||||
return m_prog;
|
return m_data->prog;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CBotCStack::SetRetType(CBotTypResult& type)
|
void CBotCStack::SetRetType(CBotTypResult& type)
|
||||||
{
|
{
|
||||||
m_retTyp = type;
|
m_data->retTyp = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CBotTypResult CBotCStack::GetRetType()
|
CBotTypResult CBotCStack::GetRetType()
|
||||||
{
|
{
|
||||||
return m_retTyp;
|
return m_data->retTyp;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CBotCStack::SetVar( CBotVar* var )
|
void CBotCStack::SetVar( CBotVar* var )
|
||||||
{
|
{
|
||||||
if (m_var) delete m_var; // replacement of a variable
|
m_var.reset(var);
|
||||||
m_var = var;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CBotCStack::SetCopyVar( CBotVar* var )
|
void CBotCStack::SetCopyVar( CBotVar* var )
|
||||||
{
|
{
|
||||||
if (m_var) delete m_var; // replacement of a variable
|
m_var.reset();
|
||||||
|
|
||||||
if ( var == nullptr ) return;
|
if ( var == nullptr ) return;
|
||||||
m_var = CBotVar::Create("", var->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_INTRINSIC));
|
m_var.reset(CBotVar::Create("", var->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_INTRINSIC)));
|
||||||
m_var->Copy( var );
|
m_var->Copy( var );
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CBotVar* CBotCStack::GetVar()
|
CBotVar* CBotCStack::GetVar()
|
||||||
{
|
{
|
||||||
return m_var;
|
return m_var.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -309,34 +297,70 @@ void CBotCStack::AddVar(CBotVar* pVar)
|
||||||
{
|
{
|
||||||
CBotCStack* p = this;
|
CBotCStack* p = this;
|
||||||
|
|
||||||
// returns to the father element
|
// find the level of the current block
|
||||||
while (p != nullptr && p->m_bBlock == 0) p = p->m_prev;
|
while (p != nullptr && p->m_bBlock == 0) p = p->m_prev;
|
||||||
|
|
||||||
if ( p == nullptr ) return;
|
if (p == nullptr || pVar == nullptr) return;
|
||||||
|
|
||||||
CBotVar** pp = &p->m_listVar;
|
p->m_listVar.emplace_back(pVar);
|
||||||
while ( *pp != nullptr ) pp = &(*pp)->m_next;
|
}
|
||||||
|
|
||||||
*pp = pVar; // added after
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCStack::CreateVarThis(CBotClass* pClass)
|
||||||
|
{
|
||||||
|
if ( pClass == nullptr ) return;
|
||||||
|
|
||||||
|
CBotVar* pThis = CBotVar::Create("this", CBotTypResult(CBotTypClass, pClass));
|
||||||
|
|
||||||
|
pThis->SetUniqNum(-2); // special ID for "this"
|
||||||
|
AddVar(pThis);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCStack::CreateVarSuper(CBotClass* pClass)
|
||||||
|
{
|
||||||
|
if ( pClass == nullptr ) return;
|
||||||
|
|
||||||
|
CBotVar* pSuper = CBotVar::Create("super", CBotTypResult(CBotTypClass, pClass));
|
||||||
|
|
||||||
|
pSuper->SetUniqNum(-3); // special ID for "super"
|
||||||
|
AddVar(pSuper);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotCStack::CreateMemberVars(CBotClass* pClass, bool setDefined)
|
||||||
|
{
|
||||||
|
while (pClass != nullptr)
|
||||||
|
{
|
||||||
|
CBotVar* pv = pClass->GetVar();
|
||||||
|
while (pv != nullptr)
|
||||||
|
{
|
||||||
|
CBotVar* pcopy = CBotVar::Create(pv);
|
||||||
|
CBotVar::InitType initType = CBotVar::InitType::UNDEF;
|
||||||
|
if (setDefined || pv->IsStatic())
|
||||||
|
initType = CBotVar::InitType::DEF;
|
||||||
|
pcopy->SetInit(initType);
|
||||||
|
pcopy->SetUniqNum(pv->GetUniqNum());
|
||||||
|
pcopy->SetPrivate(pv->GetPrivate());
|
||||||
|
AddVar(pcopy);
|
||||||
|
pv = pv->GetNext();
|
||||||
|
}
|
||||||
|
pClass = pClass->GetParent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool CBotCStack::CheckVarLocal(CBotToken* &pToken)
|
bool CBotCStack::CheckVarLocal(CBotToken* &pToken)
|
||||||
{
|
{
|
||||||
CBotCStack* p = this;
|
CBotCStack* p = this;
|
||||||
std::string name = pToken->GetString();
|
const auto& name = pToken->GetString();
|
||||||
|
|
||||||
while (p != nullptr)
|
// find the level of the current block
|
||||||
|
while (p != nullptr && p->m_bBlock == 0) p = p->m_prev;
|
||||||
|
|
||||||
|
if (p != nullptr) for (auto& var : p->m_listVar)
|
||||||
{
|
{
|
||||||
CBotVar* pp = p->m_listVar;
|
if (name == var->GetName()) return true;
|
||||||
while ( pp != nullptr)
|
|
||||||
{
|
|
||||||
if (name == pp->GetName())
|
|
||||||
return true;
|
|
||||||
pp = pp->m_next;
|
|
||||||
}
|
|
||||||
if ( p->m_bBlock ) return false;
|
|
||||||
p = p->m_prev;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -347,10 +371,10 @@ CBotTypResult CBotCStack::CompileCall(CBotToken* &p, CBotVar** ppVars, long& nId
|
||||||
nIdent = 0;
|
nIdent = 0;
|
||||||
CBotTypResult val(-1);
|
CBotTypResult val(-1);
|
||||||
|
|
||||||
val = m_prog->GetExternalCalls()->CompileCall(p, nullptr, ppVars, this);
|
val = GetProgram()->GetExternalCalls()->CompileCall(p, nullptr, ppVars, this);
|
||||||
if (val.GetType() < 0)
|
if (val.GetType() < 0)
|
||||||
{
|
{
|
||||||
val = CBotFunction::CompileCall(m_prog->GetFunctions(), p->GetString(), ppVars, nIdent);
|
val = CBotFunction::CompileCall(p->GetString(), ppVars, nIdent, GetProgram());
|
||||||
if ( val.GetType() < 0 )
|
if ( val.GetType() < 0 )
|
||||||
{
|
{
|
||||||
// pVar = nullptr; // the error is not on a particular parameter
|
// pVar = nullptr; // the error is not on a particular parameter
|
||||||
|
@ -363,16 +387,19 @@ CBotTypResult CBotCStack::CompileCall(CBotToken* &p, CBotVar** ppVars, long& nId
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
|
bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam, const std::string& className)
|
||||||
{
|
{
|
||||||
std::string name = pToken->GetString();
|
const auto& name = pToken->GetString();
|
||||||
|
|
||||||
if ( m_prog->GetExternalCalls()->CheckCall(name) ) return true;
|
if ( GetProgram()->GetExternalCalls()->CheckCall(name) ) return true;
|
||||||
|
|
||||||
for (CBotFunction* pp : m_prog->GetFunctions())
|
for (CBotFunction* pp : GetProgram()->GetFunctions())
|
||||||
{
|
{
|
||||||
if ( pToken->GetString() == pp->GetName() )
|
if ( name == pp->GetName() )
|
||||||
{
|
{
|
||||||
|
// ignore methods for a different class
|
||||||
|
if ( className != pp->GetClassName() )
|
||||||
|
continue;
|
||||||
// are parameters exactly the same?
|
// are parameters exactly the same?
|
||||||
if ( pp->CheckParam( pParam ) )
|
if ( pp->CheckParam( pParam ) )
|
||||||
return true;
|
return true;
|
||||||
|
@ -381,8 +408,11 @@ bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
|
||||||
|
|
||||||
for (CBotFunction* pp : CBotFunction::m_publicFunctions)
|
for (CBotFunction* pp : CBotFunction::m_publicFunctions)
|
||||||
{
|
{
|
||||||
if ( pToken->GetString() == pp->GetName() )
|
if ( name == pp->GetName() )
|
||||||
{
|
{
|
||||||
|
// ignore methods for a different class
|
||||||
|
if ( className != pp->GetClassName() )
|
||||||
|
continue;
|
||||||
// are parameters exactly the same?
|
// are parameters exactly the same?
|
||||||
if ( pp->CheckParam( pParam ) )
|
if ( pp->CheckParam( pParam ) )
|
||||||
return true;
|
return true;
|
||||||
|
@ -392,4 +422,4 @@ bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace CBot
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -22,6 +22,9 @@
|
||||||
#include "CBot/CBotVar/CBotVar.h"
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
#include "CBot/CBotProgram.h"
|
#include "CBot/CBotProgram.h"
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace CBot
|
namespace CBot
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -100,6 +103,25 @@ public:
|
||||||
*/
|
*/
|
||||||
void AddVar(CBotVar* p);
|
void AddVar(CBotVar* p);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Create 'this' as a local variable.
|
||||||
|
* \param pClass The current class referred to by 'this'
|
||||||
|
*/
|
||||||
|
void CreateVarThis(CBotClass* pClass);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Create 'super' as a local variable.
|
||||||
|
* \param pClass The parent class referred to by 'super'
|
||||||
|
*/
|
||||||
|
void CreateVarSuper(CBotClass* pClass);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Create member variables of the current class as local variables.
|
||||||
|
* \param pClass The current class.
|
||||||
|
* \param setDefined Whether to mark the variables as initialized.
|
||||||
|
*/
|
||||||
|
void CreateMemberVars(CBotClass* pClass, bool setDefined);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief FindVar Finds a variable. Seeks a variable on the stack the token
|
* \brief FindVar Finds a variable. Seeks a variable on the stack the token
|
||||||
* may be a result of TokenTypVar (object of a class) or a pointer in the
|
* may be a result of TokenTypVar (object of a class) or a pointer in the
|
||||||
|
@ -138,6 +160,11 @@ public:
|
||||||
*/
|
*/
|
||||||
CBotCStack* TokenStack(CBotToken* pToken = nullptr, bool bBlock = false);
|
CBotCStack* TokenStack(CBotToken* pToken = nullptr, bool bBlock = false);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Deletes all subsequent stack frames created by TokenStack.
|
||||||
|
*/
|
||||||
|
void DeleteNext();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Return Transmits the result upper.
|
* \brief Return Transmits the result upper.
|
||||||
* \param p
|
* \param p
|
||||||
|
@ -235,11 +262,12 @@ public:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief CheckCall Test if a procedure name is already defined somewhere.
|
* \brief CheckCall Test if a procedure name is already defined somewhere.
|
||||||
* \param pToken
|
* \param pToken Token representing the name of a function.
|
||||||
* \param pParam
|
* \param pParam List of parameters.
|
||||||
|
* \param className Name of a class when checking for methods.
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
bool CheckCall(CBotToken* &pToken, CBotDefParam* pParam);
|
bool CheckCall(CBotToken* &pToken, CBotDefParam* pParam, const std::string& className);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief NextToken
|
* \brief NextToken
|
||||||
|
@ -249,21 +277,20 @@ public:
|
||||||
bool NextToken(CBotToken* &p);
|
bool NextToken(CBotToken* &p);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CBotCStack* m_next;
|
std::unique_ptr<CBotCStack> m_next;
|
||||||
CBotCStack* m_prev;
|
CBotCStack* m_prev;
|
||||||
|
|
||||||
static CBotError m_error;
|
int m_errStart = 0;
|
||||||
static int m_end;
|
|
||||||
int m_start;
|
struct Data;
|
||||||
|
|
||||||
|
CBotCStack::Data* m_data;
|
||||||
|
|
||||||
//! Result of the operations.
|
//! Result of the operations.
|
||||||
CBotVar* m_var;
|
std::unique_ptr<CBotVar> m_var;
|
||||||
//! Is part of a block (variables are local to this block).
|
//! Is part of a block (variables are local to this block).
|
||||||
bool m_bBlock;
|
bool m_bBlock;
|
||||||
CBotVar* m_listVar;
|
std::list<std::unique_ptr<CBotVar>> m_listVar;
|
||||||
//! List of compiled functions.
|
|
||||||
static CBotProgram* m_prog;
|
|
||||||
static CBotTypResult m_retTyp;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CBot
|
} // namespace CBot
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -315,7 +315,7 @@ CBotTypResult CBotClass::CompileMethode(CBotToken* name,
|
||||||
|
|
||||||
// find the methods declared by user
|
// find the methods declared by user
|
||||||
|
|
||||||
r = CBotFunction::CompileCall(m_pMethod, name->GetString(), ppParams, nIdent);
|
r = CBotFunction::CompileMethodCall(name->GetString(), ppParams, nIdent, pStack, this);
|
||||||
if ( r.Eq(CBotErrUndefCall) && m_parent != nullptr )
|
if ( r.Eq(CBotErrUndefCall) && m_parent != nullptr )
|
||||||
return m_parent->CompileMethode(name, pThis, ppParams, pStack, nIdent);
|
return m_parent->CompileMethode(name, pThis, ppParams, pStack, nIdent);
|
||||||
return r;
|
return r;
|
||||||
|
@ -332,7 +332,7 @@ bool CBotClass::ExecuteMethode(long& nIdent,
|
||||||
int ret = m_externalMethods->DoCall(pToken, pThis, ppParams, pStack, pResultType);
|
int ret = m_externalMethods->DoCall(pToken, pThis, ppParams, pStack, pResultType);
|
||||||
if (ret >= 0) return ret;
|
if (ret >= 0) return ret;
|
||||||
|
|
||||||
ret = CBotFunction::DoCall(m_pMethod, nIdent, pToken->GetString(), pThis, ppParams, pStack, pToken, this);
|
ret = CBotFunction::DoCall(nIdent, pToken->GetString(), pThis, ppParams, pStack, pToken, this);
|
||||||
if (ret >= 0) return ret;
|
if (ret >= 0) return ret;
|
||||||
|
|
||||||
if (m_parent != nullptr)
|
if (m_parent != nullptr)
|
||||||
|
@ -355,7 +355,7 @@ void CBotClass::RestoreMethode(long& nIdent,
|
||||||
CBotClass* pClass = this;
|
CBotClass* pClass = this;
|
||||||
while (pClass != nullptr)
|
while (pClass != nullptr)
|
||||||
{
|
{
|
||||||
bool ok = CBotFunction::RestoreCall(pClass->m_pMethod, nIdent, name->GetString(), pThis, ppParams, pStack, pClass);
|
bool ok = CBotFunction::RestoreCall(nIdent, name->GetString(), pThis, ppParams, pStack, pClass);
|
||||||
if (ok) return;
|
if (ok) return;
|
||||||
pClass = pClass->m_parent;
|
pClass = pClass->m_parent;
|
||||||
}
|
}
|
||||||
|
@ -542,6 +542,11 @@ void CBotClass::DefineClasses(std::list<CBotClass*> pClassList, CBotCStack* pSta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::list<CBotFunction*>& CBotClass::GetFunctions() const
|
||||||
|
{
|
||||||
|
return m_pMethod;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
||||||
{
|
{
|
||||||
|
@ -600,8 +605,8 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
||||||
// return a method precompiled in pass 1
|
// return a method precompiled in pass 1
|
||||||
CBotCStack* pStk = pStack->TokenStack(nullptr, true);
|
CBotCStack* pStk = pStack->TokenStack(nullptr, true);
|
||||||
CBotDefParam* params = CBotDefParam::Compile(p, pStk );
|
CBotDefParam* params = CBotDefParam::Compile(p, pStk );
|
||||||
delete pStk;
|
pStack->DeleteNext();
|
||||||
std::list<CBotFunction*>::iterator pfIter = std::find_if(m_pMethod.begin(), m_pMethod.end(), [&pp, ¶ms](CBotFunction* x)
|
auto pfIter = std::find_if(m_pMethod.begin(), m_pMethod.end(), [&pp, ¶ms](CBotFunction* x)
|
||||||
{
|
{
|
||||||
return x->GetName() == pp && x->CheckParam( params );
|
return x->GetName() == pp && x->CheckParam( params );
|
||||||
});
|
});
|
||||||
|
@ -609,45 +614,8 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
||||||
CBotFunction* pf = *pfIter;
|
CBotFunction* pf = *pfIter;
|
||||||
delete params;
|
delete params;
|
||||||
|
|
||||||
bool bConstructor = (pp == GetName());
|
|
||||||
CBotCStack* pile = pStack->TokenStack(nullptr, true);
|
CBotCStack* pile = pStack->TokenStack(nullptr, true);
|
||||||
|
|
||||||
// make "this" known
|
|
||||||
CBotToken TokenThis(std::string("this"), std::string());
|
|
||||||
CBotVar* pThis = CBotVar::Create(TokenThis, CBotTypResult( CBotTypClass, this ) );
|
|
||||||
pThis->SetUniqNum(-2);
|
|
||||||
pile->AddVar(pThis);
|
|
||||||
|
|
||||||
if (m_parent)
|
|
||||||
{
|
|
||||||
// makes "super" known
|
|
||||||
CBotToken TokenSuper(std::string("super"), std::string());
|
|
||||||
CBotVar* pThis = CBotVar::Create(TokenSuper, CBotTypResult(CBotTypClass, m_parent) );
|
|
||||||
pThis->SetUniqNum(-3);
|
|
||||||
pile->AddVar(pThis);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int num = 1;
|
|
||||||
CBotClass* my = this;
|
|
||||||
while (my != nullptr)
|
|
||||||
{
|
|
||||||
// places a copy of variables of a class (this) on a stack
|
|
||||||
CBotVar* pv = my->m_pVar;
|
|
||||||
while (pv != nullptr)
|
|
||||||
{
|
|
||||||
CBotVar* pcopy = CBotVar::Create(pv);
|
|
||||||
CBotVar::InitType initType = CBotVar::InitType::UNDEF;
|
|
||||||
if (!bConstructor || pv->IsStatic())
|
|
||||||
initType = CBotVar::InitType::DEF;
|
|
||||||
pcopy->SetInit(initType);
|
|
||||||
pcopy->SetUniqNum(pv->GetUniqNum());
|
|
||||||
pcopy->SetPrivate(pv->GetPrivate());
|
|
||||||
pile->AddVar(pcopy);
|
|
||||||
pv = pv->GetNext();
|
|
||||||
}
|
|
||||||
my = my->m_parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
// compiles a method
|
// compiles a method
|
||||||
p = pBase;
|
p = pBase;
|
||||||
CBotFunction* f =
|
CBotFunction* f =
|
||||||
|
@ -658,7 +626,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
||||||
f->m_pProg = pStack->GetProgram();
|
f->m_pProg = pStack->GetProgram();
|
||||||
f->m_bSynchro = bSynchro;
|
f->m_bSynchro = bSynchro;
|
||||||
}
|
}
|
||||||
pStack->Return(nullptr, pile);
|
pStack->DeleteNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
return pStack->IsOk();
|
return pStack->IsOk();
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -303,6 +303,12 @@ public:
|
||||||
*/
|
*/
|
||||||
static void DefineClasses(std::list<CBotClass*> pClassList, CBotCStack* pStack);
|
static void DefineClasses(std::list<CBotClass*> pClassList, CBotCStack* pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Get the list of user-defined methods in this class.
|
||||||
|
* \return List of methods, can be empty.
|
||||||
|
*/
|
||||||
|
const std::list<CBotFunction*>& GetFunctions() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief CompileDefItem
|
* \brief CompileDefItem
|
||||||
* \param p
|
* \param p
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -23,11 +23,11 @@
|
||||||
#include "CBot/CBotInstr/CBotFunction.h"
|
#include "CBot/CBotInstr/CBotFunction.h"
|
||||||
#include "CBot/CBotInstr/CBotInstrCall.h"
|
#include "CBot/CBotInstr/CBotInstrCall.h"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
|
||||||
|
|
||||||
namespace CBot
|
namespace CBot
|
||||||
{
|
{
|
||||||
|
@ -53,22 +53,34 @@ void CBotDebug::DumpCompiledProgram(CBotProgram* program)
|
||||||
instructions[ptr] = instructionsNextId++;
|
instructions[ptr] = instructionsNextId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
char buffer[20];
|
std::array<char, 20> buffer;
|
||||||
sprintf(buffer, "instr%d", instructions[ptr]);
|
snprintf(buffer.data(), buffer.size(), "instr%d", instructions[ptr]);
|
||||||
return std::string(buffer);
|
return std::string(buffer.data());
|
||||||
};
|
};
|
||||||
std::function<void(CBotInstr*)> DumpInstr = [&](CBotInstr* instr)
|
std::function<void(CBotInstr*)> DumpInstr = [&](CBotInstr* instr)
|
||||||
{
|
{
|
||||||
if (finished.find(instr) != finished.end()) return;
|
if (finished.find(instr) != finished.end()) return;
|
||||||
finished.insert(instr);
|
finished.insert(instr);
|
||||||
|
|
||||||
std::string label = "<b>"+instr->GetDebugName()+"</b>\n";
|
auto replaceAll = [](std::string& text, const std::string& from, const std::string& to)
|
||||||
|
{
|
||||||
|
std::size_t pos = 0;
|
||||||
|
|
||||||
|
while ((pos = text.find(from, pos)) != std::string::npos)
|
||||||
|
{
|
||||||
|
text.replace(pos, from.length(), to);
|
||||||
|
pos += to.length();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
std::string data = instr->GetDebugData();
|
std::string data = instr->GetDebugData();
|
||||||
boost::algorithm::replace_all(data, "&", "&");
|
replaceAll(data, "&", "&");
|
||||||
boost::algorithm::replace_all(data, "<", "<");
|
replaceAll(data, "<", "<");
|
||||||
boost::algorithm::replace_all(data, ">", ">");
|
replaceAll(data, ">", ">");
|
||||||
|
|
||||||
|
std::string label = "<b>"+instr->GetDebugName()+"</b>\n";
|
||||||
label += data;
|
label += data;
|
||||||
boost::algorithm::replace_all(label, "\n", "<br/>");
|
replaceAll(label, "\n", "<br/>");
|
||||||
|
|
||||||
std::string additional = "";
|
std::string additional = "";
|
||||||
if (instr->GetDebugName() == "CBotFunction")
|
if (instr->GetDebugName() == "CBotFunction")
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -64,10 +64,8 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
if (list == nullptr) list = param;
|
if (list == nullptr) list = param;
|
||||||
else list->AddNext(param); // added to the list
|
else list->AddNext(param); // added to the list
|
||||||
|
|
||||||
// CBotClass* pClass = nullptr;//= CBotClass::Find(p);
|
|
||||||
param->m_typename = p->GetString();
|
param->m_typename = p->GetString();
|
||||||
CBotTypResult type = param->m_type = TypeParam(p, pStack);
|
CBotTypResult type = param->m_type = TypeParam(p, pStack);
|
||||||
// if ( type == CBotTypPointer ) type = CBotTypClass; // we must create a new object
|
|
||||||
|
|
||||||
if (param->m_type.GetType() > 0)
|
if (param->m_type.GetType() > 0)
|
||||||
{
|
{
|
||||||
|
@ -96,7 +94,7 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
prevHasDefault = true;
|
prevHasDefault = true;
|
||||||
}
|
}
|
||||||
else pStack->SetError(CBotErrNoExpression, p);
|
else pStack->SetError(CBotErrNoExpression, p);
|
||||||
delete pStk;
|
pStack->DeleteNext();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (prevHasDefault) pStack->SetError(CBotErrDefaultValue, p->GetPrev());
|
if (prevHasDefault) pStack->SetError(CBotErrDefaultValue, p->GetPrev());
|
||||||
|
@ -105,7 +103,6 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
|
||||||
if ( type.Eq(CBotTypArrayPointer) ) type.SetType(CBotTypArrayBody);
|
if ( type.Eq(CBotTypArrayPointer) ) type.SetType(CBotTypArrayBody);
|
||||||
CBotVar* var = CBotVar::Create(pp->GetString(), type); // creates the variable
|
CBotVar* var = CBotVar::Create(pp->GetString(), type); // creates the variable
|
||||||
// if ( pClass ) var->SetClass(pClass);
|
|
||||||
var->SetInit(CBotVar::InitType::IS_POINTER); // mark initialized
|
var->SetInit(CBotVar::InitType::IS_POINTER); // mark initialized
|
||||||
param->m_nIdent = CBotVar::NextUniqNum();
|
param->m_nIdent = CBotVar::NextUniqNum();
|
||||||
var->SetUniqNum(param->m_nIdent);
|
var->SetUniqNum(param->m_nIdent);
|
||||||
|
@ -140,6 +137,7 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
|
||||||
while ( p != nullptr )
|
while ( p != nullptr )
|
||||||
{
|
{
|
||||||
pile = pile->AddStack();
|
pile = pile->AddStack();
|
||||||
|
if (pile->StackOver()) return pj->Return(pile);
|
||||||
if (pile->GetState() == 1) // already done?
|
if (pile->GetState() == 1) // already done?
|
||||||
{
|
{
|
||||||
if (ppVars != nullptr && ppVars[i] != nullptr) ++i;
|
if (ppVars != nullptr && ppVars[i] != nullptr) ++i;
|
||||||
|
@ -151,13 +149,12 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
|
||||||
|
|
||||||
if (useDefault || (ppVars == nullptr || ppVars[i] == nullptr))
|
if (useDefault || (ppVars == nullptr || ppVars[i] == nullptr))
|
||||||
{
|
{
|
||||||
assert(p->m_expr != nullptr);
|
useDefault = true; // end of arguments found
|
||||||
|
if (p->m_expr != nullptr) // has default expression ?
|
||||||
useDefault = true;
|
{
|
||||||
|
if (!p->m_expr->Execute(pile)) return false; // interupt here
|
||||||
if (!p->m_expr->Execute(pile)) return false; // interupt here
|
pVar = pile->GetVar();
|
||||||
|
}
|
||||||
pVar = pile->GetVar();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pVar = ppVars[i];
|
pVar = ppVars[i];
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -100,6 +100,7 @@ enum TokenId
|
||||||
ID_STATIC,
|
ID_STATIC,
|
||||||
ID_PROTECTED,
|
ID_PROTECTED,
|
||||||
ID_PRIVATE,
|
ID_PRIVATE,
|
||||||
|
ID_REPEAT,
|
||||||
ID_INT,
|
ID_INT,
|
||||||
ID_FLOAT,
|
ID_FLOAT,
|
||||||
ID_BOOLEAN,
|
ID_BOOLEAN,
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -82,19 +82,23 @@ int CBotExternalCallList::DoCall(CBotToken* token, CBotVar* thisVar, CBotVar** p
|
||||||
|
|
||||||
CBotExternalCall* pt = m_list[token->GetString()].get();
|
CBotExternalCall* pt = m_list[token->GetString()].get();
|
||||||
|
|
||||||
if (pStack->IsCallFinished()) return true;
|
if (thisVar == nullptr && pStack->IsCallFinished()) return true; // only for non-method external call
|
||||||
CBotStack* pile = pStack->AddStackExternalCall(pt);
|
|
||||||
|
|
||||||
// lists the parameters depending on the contents of the stack (pStackVar)
|
// if this is a method call we need to use AddStack()
|
||||||
CBotVar* pVar = MakeListVars(ppVar, true);
|
CBotStack* pile = (thisVar != nullptr) ? pStack->AddStack() : pStack->AddStackExternalCall(pt);
|
||||||
|
|
||||||
// creates a variable to the result
|
if (pile->GetState() == 0) // the first time?
|
||||||
CBotVar* pResult = rettype.Eq(CBotTypVoid) ? nullptr : CBotVar::Create("", rettype);
|
{
|
||||||
|
// lists the parameters depending on the contents of the stack
|
||||||
|
CBotVar* pVar = MakeListVars(ppVar, true);
|
||||||
|
pile->SetVar(pVar);
|
||||||
|
|
||||||
pile->SetVar(pVar);
|
CBotStack* pile2 = pile->AddStack();
|
||||||
|
// creates a variable to the result
|
||||||
CBotStack* pile2 = pile->AddStack();
|
CBotVar* pResult = rettype.Eq(CBotTypVoid) ? nullptr : CBotVar::Create("", rettype);
|
||||||
pile2->SetVar(pResult);
|
pile2->SetVar(pResult);
|
||||||
|
pile->IncState(); // increment state to mark this step done
|
||||||
|
}
|
||||||
|
|
||||||
pile->SetError(CBotNoErr, token); // save token for the position in case of error
|
pile->SetError(CBotNoErr, token); // save token for the position in case of error
|
||||||
return pt->Run(thisVar, pStack);
|
return pt->Run(thisVar, pStack);
|
||||||
|
@ -107,7 +111,8 @@ bool CBotExternalCallList::RestoreCall(CBotToken* token, CBotVar* thisVar, CBotV
|
||||||
|
|
||||||
CBotExternalCall* pt = m_list[token->GetString()].get();
|
CBotExternalCall* pt = m_list[token->GetString()].get();
|
||||||
|
|
||||||
CBotStack* pile = pStack->RestoreStackEOX(pt);
|
// if this is a method call we need to use RestoreStack()
|
||||||
|
CBotStack* pile = (thisVar != nullptr) ? pStack->RestoreStack() : pStack->RestoreStackEOX(pt);
|
||||||
if (pile == nullptr) return true;
|
if (pile == nullptr) return true;
|
||||||
|
|
||||||
pile->RestoreStack();
|
pile->RestoreStack();
|
||||||
|
@ -163,8 +168,7 @@ bool CBotExternalCallDefault::Run(CBotVar* thisVar, CBotStack* pStack)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != nullptr) pStack->SetCopyVar(result);
|
pStack->Return(pile2); // return 'result' and clear extra stack
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,8 +191,8 @@ CBotTypResult CBotExternalCallClass::Compile(CBotVar* thisVar, CBotVar* args, vo
|
||||||
|
|
||||||
bool CBotExternalCallClass::Run(CBotVar* thisVar, CBotStack* pStack)
|
bool CBotExternalCallClass::Run(CBotVar* thisVar, CBotStack* pStack)
|
||||||
{
|
{
|
||||||
if (pStack->IsCallFinished()) return true;
|
assert(thisVar != nullptr);
|
||||||
CBotStack* pile = pStack->AddStackExternalCall(this);
|
CBotStack* pile = pStack->AddStack();
|
||||||
CBotVar* args = pile->GetVar();
|
CBotVar* args = pile->GetVar();
|
||||||
|
|
||||||
CBotStack* pile2 = pile->AddStack();
|
CBotStack* pile2 = pile->AddStack();
|
||||||
|
@ -207,9 +211,8 @@ bool CBotExternalCallClass::Run(CBotVar* thisVar, CBotStack* pStack)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != nullptr) pStack->SetCopyVar(result);
|
pStack->Return(pile2); // return 'result' and clear extra stack
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace CBot
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -59,7 +59,7 @@ static bool ReadBinary(std::istream &istr, T &value)
|
||||||
while (true) // unsigned LEB128
|
while (true) // unsigned LEB128
|
||||||
{
|
{
|
||||||
if (!istr.read(reinterpret_cast<char*>(&chr), 1)) return false;
|
if (!istr.read(reinterpret_cast<char*>(&chr), 1)) return false;
|
||||||
if (shift < sizeof(T) * 8 - 1)
|
if (shift < sizeof(T) * 8)
|
||||||
value |= static_cast<T>(chr & 0x7F) << shift;
|
value |= static_cast<T>(chr & 0x7F) << shift;
|
||||||
shift += 7;
|
shift += 7;
|
||||||
if ((chr & 0x80) == 0) break;
|
if ((chr & 0x80) == 0) break;
|
||||||
|
@ -183,42 +183,66 @@ bool ReadLong(std::istream &istr, long &l)
|
||||||
|
|
||||||
bool WriteFloat(std::ostream &ostr, float f)
|
bool WriteFloat(std::ostream &ostr, float f)
|
||||||
{
|
{
|
||||||
union {float fValue; unsigned int iValue;} u;
|
union TypeConverter
|
||||||
|
{
|
||||||
|
float fValue;
|
||||||
|
uint32_t iValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
TypeConverter u;
|
||||||
u.fValue = 0.0f;
|
u.fValue = 0.0f;
|
||||||
u.iValue = 0;
|
u.iValue = 0;
|
||||||
|
|
||||||
u.fValue = f;
|
u.fValue = f;
|
||||||
return WriteBinary<unsigned int>(ostr, u.iValue);
|
return WriteBinary<uint32_t>(ostr, u.iValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadFloat(std::istream &istr, float &f)
|
bool ReadFloat(std::istream &istr, float &f)
|
||||||
{
|
{
|
||||||
union {float fValue; unsigned int iValue;} u;
|
union TypeConverter
|
||||||
|
{
|
||||||
|
float fValue;
|
||||||
|
uint32_t iValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
TypeConverter u;
|
||||||
u.fValue = 0.0f;
|
u.fValue = 0.0f;
|
||||||
u.iValue = 0;
|
u.iValue = 0;
|
||||||
|
|
||||||
if (!ReadBinary<unsigned int>(istr, u.iValue)) return false;
|
if (!ReadBinary<uint32_t>(istr, u.iValue)) return false;
|
||||||
f = u.fValue;
|
f = u.fValue;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WriteDouble(std::ostream &ostr, double d)
|
bool WriteDouble(std::ostream &ostr, double d)
|
||||||
{
|
{
|
||||||
union {double dValue; unsigned long iValue;} u;
|
union TypeConverter
|
||||||
|
{
|
||||||
|
double dValue;
|
||||||
|
uint64_t iValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
TypeConverter u;
|
||||||
u.dValue = 0.0;
|
u.dValue = 0.0;
|
||||||
u.iValue = 0;
|
u.iValue = 0;
|
||||||
|
|
||||||
u.dValue = d;
|
u.dValue = d;
|
||||||
return WriteBinary<unsigned long>(ostr, u.iValue);
|
return WriteBinary<uint64_t>(ostr, u.iValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadDouble(std::istream &istr, double &d)
|
bool ReadDouble(std::istream &istr, double &d)
|
||||||
{
|
{
|
||||||
union {double dValue; unsigned long iValue;} u;
|
union TypeConverter
|
||||||
|
{
|
||||||
|
double dValue;
|
||||||
|
uint64_t iValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
TypeConverter u;
|
||||||
u.dValue = 0.0;
|
u.dValue = 0.0;
|
||||||
u.iValue = 0;
|
u.iValue = 0;
|
||||||
|
|
||||||
if (!ReadBinary<unsigned long>(istr, u.iValue)) return false;
|
if (!ReadBinary<uint64_t>(istr, u.iValue)) return false;
|
||||||
d = u.dValue;
|
d = u.dValue;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -318,7 +342,11 @@ bool WriteStream(std::ostream &ostr, std::istream& istr)
|
||||||
if (!WriteLong(ostr, size)) return false;
|
if (!WriteLong(ostr, size)) return false;
|
||||||
|
|
||||||
if (!istr.seekg(0, istr.beg)) return false;
|
if (!istr.seekg(0, istr.beg)) return false;
|
||||||
if (!(ostr << istr.rdbuf())) return false;
|
while (size > 0)
|
||||||
|
{
|
||||||
|
size -= 1;
|
||||||
|
if (!ostr.put(istr.get())) return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -331,7 +359,7 @@ bool ReadStream(std::istream& istr, std::ostream &ostr)
|
||||||
|
|
||||||
while (length-- > 0)
|
while (length-- > 0)
|
||||||
{
|
{
|
||||||
if (!(ostr << istr.get())) return false;
|
if (!ostr.put(istr.get())) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -135,7 +135,7 @@ CBotInstr* CBotDefClass::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* p
|
||||||
// the constructor is there?
|
// the constructor is there?
|
||||||
// std::string noname;
|
// std::string noname;
|
||||||
CBotTypResult r = pClass->CompileMethode(&token, var, ppVars, pStk, inst->m_nMethodeIdent);
|
CBotTypResult r = pClass->CompileMethode(&token, var, ppVars, pStk, inst->m_nMethodeIdent);
|
||||||
delete pStk->TokenStack(); // releases the supplement stack
|
pStk->DeleteNext(); // releases the supplement stack
|
||||||
int typ = r.GetType();
|
int typ = r.GetType();
|
||||||
|
|
||||||
if (typ == CBotErrUndefCall)
|
if (typ == CBotErrUndefCall)
|
||||||
|
@ -160,7 +160,7 @@ CBotInstr* CBotDefClass::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* p
|
||||||
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStk, true)))
|
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStk, true)))
|
||||||
{
|
{
|
||||||
inst->m_exprRetVar->SetToken(vartoken);
|
inst->m_exprRetVar->SetToken(vartoken);
|
||||||
delete pStk->TokenStack();
|
pStk->DeleteNext();
|
||||||
}
|
}
|
||||||
pStk->SetVar(nullptr);
|
pStk->SetVar(nullptr);
|
||||||
|
|
||||||
|
@ -360,6 +360,7 @@ bool CBotDefClass::Execute(CBotStack* &pj)
|
||||||
if ( p != nullptr) while ( true )
|
if ( p != nullptr) while ( true )
|
||||||
{
|
{
|
||||||
pile2 = pile2->AddStack(); // place on the stack for the results
|
pile2 = pile2->AddStack(); // place on the stack for the results
|
||||||
|
if (pile2->StackOver()) return pj->Return(pile2);
|
||||||
if ( pile2->GetState() == 0 )
|
if ( pile2->GetState() == 0 )
|
||||||
{
|
{
|
||||||
if (!p->Execute(pile2)) return false; // interrupted here?
|
if (!p->Execute(pile2)) return false; // interrupted here?
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include "CBot/CBotInstr/CBotInstr.h"
|
#include "CBot/CBotInstr/CBotInstr.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace CBot
|
namespace CBot
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
#include "CBot/CBotVar/CBotVar.h"
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
namespace CBot
|
namespace CBot
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -41,9 +43,9 @@ bool CBotExprLitNan::Execute(CBotStack* &pj)
|
||||||
CBotStack* pile = pj->AddStack(this);
|
CBotStack* pile = pj->AddStack(this);
|
||||||
|
|
||||||
if (pile->IfStep()) return false;
|
if (pile->IfStep()) return false;
|
||||||
CBotVar* var = CBotVar::Create("", CBotTypInt);
|
CBotVar* var = CBotVar::Create("", CBotTypFloat);
|
||||||
|
|
||||||
var->SetInit(CBotVar::InitType::IS_NAN); // nan
|
var->SetValFloat(nanf(""));
|
||||||
pile->SetVar(var); // put on the stack
|
pile->SetVar(var); // put on the stack
|
||||||
return pj->Return(pile); // forward below
|
return pj->Return(pile); // forward below
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -38,7 +38,9 @@ class CBotExprLitNum : public CBotInstr
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CBotExprLitNum(T val);
|
// To keep linter happy, instead of = delete (see https://stackoverflow.com/a/37593094)
|
||||||
|
CBotExprLitNum(T val) { static_assert(sizeof(T) == 0, "Only specializations of CBotExprLitNum can be used"); };
|
||||||
|
|
||||||
~CBotExprLitNum();
|
~CBotExprLitNum();
|
||||||
|
|
||||||
/*!
|
/*!
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
#include "CBot/CBotVar/CBotVar.h"
|
#include "CBot/CBotVar/CBotVar.h"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace CBot
|
namespace CBot
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -206,12 +206,6 @@ bool CBotExpression::Execute(CBotStack* &pj)
|
||||||
if (m_token.GetType() != ID_ASS)
|
if (m_token.GetType() != ID_ASS)
|
||||||
{
|
{
|
||||||
pVar = pile1->GetVar(); // recovers if interrupted
|
pVar = pile1->GetVar(); // recovers if interrupted
|
||||||
initKind = pVar->GetInit();
|
|
||||||
if (initKind == CBotVar::InitType::IS_NAN)
|
|
||||||
{
|
|
||||||
pile2->SetError(CBotErrNan, m_leftop->GetToken());
|
|
||||||
return pj->Return(pile2);
|
|
||||||
}
|
|
||||||
result = CBotVar::Create("", pVar->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_INTRINSIC));
|
result = CBotVar::Create("", pVar->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_INTRINSIC));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -76,6 +76,18 @@ bool CBotFunction::IsPublic()
|
||||||
return m_bPublic;
|
return m_bPublic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotFunction::IsProtected() const
|
||||||
|
{
|
||||||
|
return m_bProtect;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool CBotFunction::IsPrivate() const
|
||||||
|
{
|
||||||
|
return m_bPrivate;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool CBotFunction::IsExtern()
|
bool CBotFunction::IsExtern()
|
||||||
{
|
{
|
||||||
|
@ -129,21 +141,17 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
|
||||||
{
|
{
|
||||||
CBotToken* pp;
|
CBotToken* pp;
|
||||||
CBotFunction* func = finput;
|
CBotFunction* func = finput;
|
||||||
if ( func == nullptr ) func = new CBotFunction();
|
assert(func != nullptr); // a pre-compiled function is required
|
||||||
|
|
||||||
CBotCStack* pStk = pStack->TokenStack(p, bLocal);
|
CBotCStack* pStk = pStack->TokenStack(p, bLocal);
|
||||||
|
|
||||||
// func->m_nFuncIdent = CBotVar::NextUniqNum();
|
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if ( IsOfType(p, ID_PUBLIC) )
|
if (IsOfType(p, ID_PRIVATE)) break;
|
||||||
{
|
if (IsOfType(p, ID_PROTECTED)) break;
|
||||||
func->m_bPublic = true;
|
if (IsOfType(p, ID_PUBLIC)) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
pp = p;
|
pp = p;
|
||||||
if ( IsOfType(p, ID_EXTERN) )
|
if (IsOfType(p, ID_EXTERN))
|
||||||
{
|
{
|
||||||
func->m_extern = *pp; // for the position of the word "extern"
|
func->m_extern = *pp; // for the position of the word "extern"
|
||||||
func->m_bExtern = true;
|
func->m_bExtern = true;
|
||||||
|
@ -183,10 +191,23 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pp = p;
|
pp = p;
|
||||||
func->m_token = *p;
|
func->m_token = *p;
|
||||||
if (!IsOfType(p, TokenTypVar)) goto bad;
|
if (!IsOfType(p, TokenTypVar)) goto bad;
|
||||||
|
// check if the class has a method like this
|
||||||
|
if (pClass->CheckCall(pStack->GetProgram(), func->m_param, pp))
|
||||||
|
{
|
||||||
|
pStk->SetStartError(func->m_classToken.GetStart());
|
||||||
|
pStk->SetError(CBotErrRedefFunc, pp->GetEnd());
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
// check if a constructor has return type void
|
||||||
|
if (func->GetName() == pClass->GetName() && !func->m_retTyp.Eq(CBotTypVoid))
|
||||||
|
{
|
||||||
|
pp = &(func->m_retToken);
|
||||||
|
pStk->SetError(CBotErrFuncNotVoid, pp);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
func->m_openpar = *p;
|
func->m_openpar = *p;
|
||||||
delete func->m_param;
|
delete func->m_param;
|
||||||
|
@ -198,28 +219,13 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
|
||||||
|
|
||||||
if (!func->m_MasterClass.empty())
|
if (!func->m_MasterClass.empty())
|
||||||
{
|
{
|
||||||
// return "this" known
|
CBotClass* pClass = CBotClass::Find(func->m_MasterClass);
|
||||||
CBotVar* pThis = CBotVar::Create("this", CBotTypResult( CBotTypClass, func->m_MasterClass ));
|
|
||||||
pThis->SetInit(CBotVar::InitType::IS_POINTER);
|
|
||||||
// pThis->SetUniqNum(func->m_nThisIdent = -2); //CBotVar::NextUniqNum() will not
|
|
||||||
pThis->SetUniqNum(-2);
|
|
||||||
pStk->AddVar(pThis);
|
|
||||||
|
|
||||||
// initialize variables acording to This
|
pStk->CreateVarThis(pClass);
|
||||||
// only saves the pointer to the first,
|
pStk->CreateVarSuper(pClass->GetParent());
|
||||||
// the rest is chained
|
|
||||||
CBotVar* pv = pThis->GetItemList();
|
bool bConstructor = (func->GetName() == func->m_MasterClass);
|
||||||
// int num = 1;
|
pStk->CreateMemberVars(pClass, !bConstructor);
|
||||||
while (pv != nullptr)
|
|
||||||
{
|
|
||||||
CBotVar* pcopy = CBotVar::Create(pv);
|
|
||||||
// pcopy->SetInit(2);
|
|
||||||
pcopy->Copy(pv);
|
|
||||||
pcopy->SetPrivate(pv->GetPrivate());
|
|
||||||
// pcopy->SetUniqNum(pv->GetUniqNum()); //num++);
|
|
||||||
pStk->AddVar(pcopy);
|
|
||||||
pv = pv->GetNext();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// and compiles the following instruction block
|
// and compiles the following instruction block
|
||||||
|
@ -242,7 +248,6 @@ bad:
|
||||||
pStk->SetError(CBotErrNoFunc, p);
|
pStk->SetError(CBotErrNoFunc, p);
|
||||||
}
|
}
|
||||||
pStk->SetError(CBotErrNoType, p);
|
pStk->SetError(CBotErrNoType, p);
|
||||||
if ( finput == nullptr ) delete func;
|
|
||||||
return pStack->ReturnFunc(nullptr, pStk);
|
return pStack->ReturnFunc(nullptr, pStk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,14 +259,30 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
|
||||||
|
|
||||||
CBotCStack* pStk = pStack->TokenStack(p, true);
|
CBotCStack* pStk = pStack->TokenStack(p, true);
|
||||||
|
|
||||||
|
CBotToken* pPriv = p;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if ( IsOfType(p, ID_PUBLIC) )
|
if (!func->m_bPublic) // don't repeat 'public'
|
||||||
{
|
{
|
||||||
// func->m_bPublic = true; // will be done in two passes
|
pPriv = p;
|
||||||
continue;
|
if (IsOfType(p, ID_PRIVATE))
|
||||||
|
{
|
||||||
|
func->m_bPrivate = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (IsOfType(p, ID_PROTECTED))
|
||||||
|
{
|
||||||
|
func->m_bProtect = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (IsOfType(p, ID_PUBLIC))
|
||||||
|
{
|
||||||
|
func->m_bPublic = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( IsOfType(p, ID_EXTERN) )
|
if (!func->m_bExtern && IsOfType(p, ID_EXTERN))
|
||||||
{
|
{
|
||||||
func->m_bExtern = true;
|
func->m_bExtern = true;
|
||||||
continue;
|
continue;
|
||||||
|
@ -297,12 +318,21 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
|
||||||
if (!IsOfType(p, TokenTypVar)) goto bad;
|
if (!IsOfType(p, TokenTypVar)) goto bad;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (pClass == nullptr) // not method in a class ?
|
||||||
|
{
|
||||||
|
if (func->m_bPrivate || func->m_bProtect) // not allowed for regular functions
|
||||||
|
{
|
||||||
|
pStk->SetError(CBotErrNoType, pPriv);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CBotToken* openPar = p;
|
CBotToken* openPar = p;
|
||||||
func->m_param = CBotDefParam::Compile(p, pStk); // compile parameters
|
func->m_param = CBotDefParam::Compile(p, pStk); // compile parameters
|
||||||
|
|
||||||
if (pStk->IsOk() && pClass != nullptr) // method in a class
|
if (pStk->IsOk() && pClass != nullptr) // method in a class
|
||||||
{
|
{
|
||||||
|
func->m_MasterClass = pClass->GetName();
|
||||||
// check if a constructor has return type void
|
// check if a constructor has return type void
|
||||||
if (func->GetName() == pClass->GetName() && !func->m_retTyp.Eq(CBotTypVoid))
|
if (func->GetName() == pClass->GetName() && !func->m_retTyp.Eq(CBotTypVoid))
|
||||||
{
|
{
|
||||||
|
@ -331,7 +361,7 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
|
||||||
{
|
{
|
||||||
// looks if the function exists elsewhere
|
// looks if the function exists elsewhere
|
||||||
pp = &(func->m_token);
|
pp = &(func->m_token);
|
||||||
if (( pClass != nullptr || !pStack->CheckCall(pp, func->m_param)) &&
|
if (( pClass != nullptr || !pStack->CheckCall(pp, func->m_param, func->m_MasterClass)) &&
|
||||||
( pClass == nullptr || !pClass->CheckCall(pStack->GetProgram(), func->m_param, pp)) )
|
( pClass == nullptr || !pClass->CheckCall(pStack->GetProgram(), func->m_param, pp)) )
|
||||||
{
|
{
|
||||||
if (IsOfType(p, ID_OPBLK))
|
if (IsOfType(p, ID_OPBLK))
|
||||||
|
@ -415,7 +445,7 @@ bool CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance)
|
||||||
pile->IncState();
|
pile->IncState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !m_block->Execute(pile) )
|
if (!pile->GetRetVar(m_block->Execute(pile)))
|
||||||
{
|
{
|
||||||
if ( pile->GetError() < 0 )
|
if ( pile->GetError() < 0 )
|
||||||
pile->SetError( CBotNoErr );
|
pile->SetError( CBotNoErr );
|
||||||
|
@ -472,10 +502,10 @@ void CBotFunction::RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInst
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CBotTypResult CBotFunction::CompileCall(const std::list<CBotFunction*>& localFunctionList, const std::string &name, CBotVar** ppVars, long &nIdent)
|
CBotTypResult CBotFunction::CompileCall(const std::string &name, CBotVar** ppVars, long &nIdent, CBotProgram* program)
|
||||||
{
|
{
|
||||||
CBotTypResult type;
|
CBotTypResult type;
|
||||||
if (!FindLocalOrPublic(localFunctionList, nIdent, name, ppVars, type))
|
if (!FindLocalOrPublic(program->GetFunctions(), nIdent, name, ppVars, type, program))
|
||||||
{
|
{
|
||||||
// Reset the identifier to "not found" value
|
// Reset the identifier to "not found" value
|
||||||
nIdent = 0;
|
nIdent = 0;
|
||||||
|
@ -485,7 +515,7 @@ CBotTypResult CBotFunction::CompileCall(const std::list<CBotFunction*>& localFun
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CBotFunction* CBotFunction::FindLocalOrPublic(const std::list<CBotFunction*>& localFunctionList, long &nIdent, const std::string &name,
|
CBotFunction* CBotFunction::FindLocalOrPublic(const std::list<CBotFunction*>& localFunctionList, long &nIdent, const std::string &name,
|
||||||
CBotVar** ppVars, CBotTypResult &TypeOrError, bool bPublic)
|
CBotVar** ppVars, CBotTypResult &TypeOrError, CBotProgram* baseProg)
|
||||||
{
|
{
|
||||||
TypeOrError.SetType(CBotErrUndefCall); // no routine of the name
|
TypeOrError.SetType(CBotErrUndefCall); // no routine of the name
|
||||||
|
|
||||||
|
@ -515,10 +545,39 @@ CBotFunction* CBotFunction::FindLocalOrPublic(const std::list<CBotFunction*>& lo
|
||||||
|
|
||||||
std::map<CBotFunction*, int> funcMap;
|
std::map<CBotFunction*, int> funcMap;
|
||||||
|
|
||||||
for (CBotFunction* pt : localFunctionList)
|
CBotFunction::SearchList(localFunctionList, name, ppVars, TypeOrError, funcMap);
|
||||||
|
|
||||||
|
CBotFunction::SearchPublic(name, ppVars, TypeOrError, funcMap);
|
||||||
|
|
||||||
|
if (baseProg != nullptr && baseProg->m_thisVar != nullptr)
|
||||||
|
{
|
||||||
|
// find object:: functions
|
||||||
|
CBotClass* pClass = baseProg->m_thisVar->GetClass();
|
||||||
|
CBotFunction::SearchList(localFunctionList, name, ppVars, TypeOrError, funcMap, pClass);
|
||||||
|
CBotFunction::SearchPublic(name, ppVars, TypeOrError, funcMap, pClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
return CBotFunction::BestFunction(funcMap, nIdent, TypeOrError);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotFunction::SearchList(const std::list<CBotFunction*>& functionList,
|
||||||
|
const std::string& name, CBotVar** ppVars, CBotTypResult& TypeOrError,
|
||||||
|
std::map<CBotFunction*, int>& funcMap, CBotClass* pClass)
|
||||||
|
{
|
||||||
|
for (CBotFunction* pt : functionList)
|
||||||
{
|
{
|
||||||
if ( pt->m_token.GetString() == name )
|
if ( pt->m_token.GetString() == name )
|
||||||
{
|
{
|
||||||
|
if (pClass != nullptr) // looking for a method ?
|
||||||
|
{
|
||||||
|
if (pt->m_MasterClass != pClass->GetName()) continue;
|
||||||
|
}
|
||||||
|
else // looking for a function
|
||||||
|
{
|
||||||
|
if (!pt->m_MasterClass.empty()) continue;
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int alpha = 0; // signature of parameters
|
int alpha = 0; // signature of parameters
|
||||||
// parameters are compatible?
|
// parameters are compatible?
|
||||||
|
@ -575,13 +634,26 @@ CBotFunction* CBotFunction::FindLocalOrPublic(const std::list<CBotFunction*>& lo
|
||||||
funcMap.insert( std::pair<CBotFunction*, int>(pt, alpha) );
|
funcMap.insert( std::pair<CBotFunction*, int>(pt, alpha) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( bPublic )
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CBotFunction::SearchPublic(const std::string& name, CBotVar** ppVars, CBotTypResult& TypeOrError,
|
||||||
|
std::map<CBotFunction*, int>& funcMap, CBotClass* pClass)
|
||||||
|
{
|
||||||
{
|
{
|
||||||
for (CBotFunction* pt : m_publicFunctions)
|
for (CBotFunction* pt : m_publicFunctions)
|
||||||
{
|
{
|
||||||
if ( pt->m_token.GetString() == name )
|
if ( pt->m_token.GetString() == name )
|
||||||
{
|
{
|
||||||
|
if (pClass != nullptr) // looking for a method ?
|
||||||
|
{
|
||||||
|
if (pt->m_MasterClass != pClass->GetName()) continue;
|
||||||
|
}
|
||||||
|
else // looking for a function
|
||||||
|
{
|
||||||
|
if (!pt->m_MasterClass.empty()) continue;
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int alpha = 0; // signature of parameters
|
int alpha = 0; // signature of parameters
|
||||||
// are parameters compatible ?
|
// are parameters compatible ?
|
||||||
|
@ -639,7 +711,12 @@ CBotFunction* CBotFunction::FindLocalOrPublic(const std::list<CBotFunction*>& lo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotFunction* CBotFunction::BestFunction(std::map<CBotFunction*, int>& funcMap,
|
||||||
|
long& nIdent, CBotTypResult& TypeOrError)
|
||||||
|
{
|
||||||
if ( !funcMap.empty() )
|
if ( !funcMap.empty() )
|
||||||
{
|
{
|
||||||
auto it = funcMap.begin();
|
auto it = funcMap.begin();
|
||||||
|
@ -675,7 +752,7 @@ int CBotFunction::DoCall(CBotProgram* program, const std::list<CBotFunction*>& l
|
||||||
CBotFunction* pt = nullptr;
|
CBotFunction* pt = nullptr;
|
||||||
CBotProgram* baseProg = pStack->GetProgram(true);
|
CBotProgram* baseProg = pStack->GetProgram(true);
|
||||||
|
|
||||||
pt = FindLocalOrPublic(localFunctionList, nIdent, name, ppVars, type);
|
pt = FindLocalOrPublic(localFunctionList, nIdent, name, ppVars, type, baseProg);
|
||||||
|
|
||||||
if ( pt != nullptr )
|
if ( pt != nullptr )
|
||||||
{
|
{
|
||||||
|
@ -766,7 +843,7 @@ void CBotFunction::RestoreCall(const std::list<CBotFunction*>& localFunctionList
|
||||||
CBotStack* pStk3;
|
CBotStack* pStk3;
|
||||||
CBotProgram* baseProg = pStack->GetProgram(true);
|
CBotProgram* baseProg = pStack->GetProgram(true);
|
||||||
|
|
||||||
pt = FindLocalOrPublic(localFunctionList, nIdent, name, ppVars, type);
|
pt = FindLocalOrPublic(localFunctionList, nIdent, name, ppVars, type, baseProg);
|
||||||
|
|
||||||
if ( pt != nullptr )
|
if ( pt != nullptr )
|
||||||
{
|
{
|
||||||
|
@ -824,13 +901,121 @@ void CBotFunction::RestoreCall(const std::list<CBotFunction*>& localFunctionList
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CBotFunction::DoCall(const std::list<CBotFunction*>& localFunctionList, long &nIdent, const std::string &name, CBotVar* pThis,
|
CBotTypResult CBotFunction::CompileMethodCall(const std::string& name, CBotVar** ppVars,
|
||||||
|
long& nIdent, CBotCStack* pStack, CBotClass* pClass)
|
||||||
|
{
|
||||||
|
nIdent = 0;
|
||||||
|
CBotTypResult type;
|
||||||
|
|
||||||
|
CBotFunction* pt = FindMethod(nIdent, name, ppVars, type, pClass, pStack->GetProgram());
|
||||||
|
|
||||||
|
if (pt != nullptr)
|
||||||
|
{
|
||||||
|
CBotToken token("this");
|
||||||
|
CBotVar* pThis = pStack->FindVar(token); // for 'this' context
|
||||||
|
|
||||||
|
if (pThis == nullptr || pThis->GetType() != CBotTypPointer) // called from inside a function
|
||||||
|
{
|
||||||
|
if (pt->IsPrivate() || pt->IsProtected())
|
||||||
|
type.SetType(CBotErrPrivate);
|
||||||
|
}
|
||||||
|
else // called from inside a method
|
||||||
|
{
|
||||||
|
CBotClass* thisClass = pThis->GetClass(); // current class
|
||||||
|
CBotClass* funcClass = CBotClass::Find(pt->m_MasterClass); // class of the method
|
||||||
|
|
||||||
|
if (pt->IsPrivate() && thisClass != funcClass)
|
||||||
|
type.SetType(CBotErrPrivate);
|
||||||
|
|
||||||
|
if (pt->IsProtected() && !thisClass->IsChildOf(funcClass))
|
||||||
|
type.SetType(CBotErrPrivate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
CBotFunction* CBotFunction::FindMethod(long& nIdent, const std::string& name,
|
||||||
|
CBotVar** ppVars, CBotTypResult& TypeOrError,
|
||||||
|
CBotClass* pClass, CBotProgram* program)
|
||||||
|
{
|
||||||
|
TypeOrError.SetType(CBotErrUndefCall); // no routine of the name
|
||||||
|
|
||||||
|
auto methods = pClass->GetFunctions();
|
||||||
|
|
||||||
|
if ( nIdent )
|
||||||
|
{
|
||||||
|
// search methods in the class
|
||||||
|
for (CBotFunction* pt : methods)
|
||||||
|
{
|
||||||
|
if ( pt->m_nFuncIdent == nIdent )
|
||||||
|
{
|
||||||
|
TypeOrError = pt->m_retTyp;
|
||||||
|
return pt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool skipPublic = false;
|
||||||
|
if (program != nullptr)
|
||||||
|
{
|
||||||
|
// search the current program
|
||||||
|
for (CBotFunction* pt : program->GetFunctions())
|
||||||
|
{
|
||||||
|
if ( pt->m_nFuncIdent == nIdent )
|
||||||
|
{
|
||||||
|
// check if the method is inherited
|
||||||
|
if ( pt->GetClassName() != pClass->GetName() )
|
||||||
|
{
|
||||||
|
skipPublic = true;
|
||||||
|
break; // break in case there is an override
|
||||||
|
}
|
||||||
|
TypeOrError = pt->m_retTyp;
|
||||||
|
return pt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// search the list of public functions
|
||||||
|
if (!skipPublic)
|
||||||
|
{
|
||||||
|
for (CBotFunction* pt : m_publicFunctions)
|
||||||
|
{
|
||||||
|
if (pt->m_nFuncIdent == nIdent)
|
||||||
|
{
|
||||||
|
// check if the method is inherited, break in case there is an override
|
||||||
|
if ( pt->GetClassName() != pClass->GetName() ) break;
|
||||||
|
TypeOrError = pt->m_retTyp;
|
||||||
|
return pt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( name.empty() ) return nullptr;
|
||||||
|
|
||||||
|
std::map<CBotFunction*, int> funcMap;
|
||||||
|
|
||||||
|
// search methods in the class
|
||||||
|
CBotFunction::SearchList(methods, name, ppVars, TypeOrError, funcMap, pClass);
|
||||||
|
|
||||||
|
// search the current program for methods
|
||||||
|
if (program != nullptr)
|
||||||
|
CBotFunction::SearchList(program->GetFunctions(), name, ppVars, TypeOrError, funcMap, pClass);
|
||||||
|
|
||||||
|
CBotFunction::SearchPublic(name, ppVars, TypeOrError, funcMap, pClass);
|
||||||
|
|
||||||
|
return CBotFunction::BestFunction(funcMap, nIdent, TypeOrError);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
int CBotFunction::DoCall(long &nIdent, const std::string &name, CBotVar* pThis,
|
||||||
CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken, CBotClass* pClass)
|
CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken, CBotClass* pClass)
|
||||||
{
|
{
|
||||||
CBotTypResult type;
|
CBotTypResult type;
|
||||||
CBotProgram* pProgCurrent = pStack->GetProgram();
|
CBotProgram* pProgCurrent = pStack->GetProgram();
|
||||||
|
|
||||||
CBotFunction* pt = FindLocalOrPublic(localFunctionList, nIdent, name, ppVars, type, false);
|
CBotFunction* pt = FindMethod(nIdent, name, ppVars, type, pClass, pProgCurrent);
|
||||||
|
|
||||||
if ( pt != nullptr )
|
if ( pt != nullptr )
|
||||||
{
|
{
|
||||||
|
@ -925,11 +1110,11 @@ int CBotFunction::DoCall(const std::list<CBotFunction*>& localFunctionList, long
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool CBotFunction::RestoreCall(const std::list<CBotFunction*>& localFunctionList, long &nIdent, const std::string &name, CBotVar* pThis,
|
bool CBotFunction::RestoreCall(long &nIdent, const std::string &name, CBotVar* pThis,
|
||||||
CBotVar** ppVars, CBotStack* pStack, CBotClass* pClass)
|
CBotVar** ppVars, CBotStack* pStack, CBotClass* pClass)
|
||||||
{
|
{
|
||||||
CBotTypResult type;
|
CBotTypResult type;
|
||||||
CBotFunction* pt = FindLocalOrPublic(localFunctionList, nIdent, name, ppVars, type);
|
CBotFunction* pt = FindMethod(nIdent, name, ppVars, type, pClass, pStack->GetProgram());
|
||||||
|
|
||||||
if ( pt != nullptr )
|
if ( pt != nullptr )
|
||||||
{
|
{
|
||||||
|
@ -1020,6 +1205,12 @@ std::string CBotFunction::GetParams()
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
const std::string& CBotFunction::GetClassName() const
|
||||||
|
{
|
||||||
|
return m_MasterClass;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CBotFunction::AddPublic(CBotFunction* func)
|
void CBotFunction::AddPublic(CBotFunction* func)
|
||||||
{
|
{
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -105,21 +105,19 @@ public:
|
||||||
*
|
*
|
||||||
* See FindLocalOrPublic for more detailed explanation
|
* See FindLocalOrPublic for more detailed explanation
|
||||||
*
|
*
|
||||||
* \param localFunctionList Linked list of local functions to search in, can be null
|
|
||||||
* \param name Name of the function
|
* \param name Name of the function
|
||||||
* \param ppVars List of function arguments
|
* \param ppVars List of function arguments
|
||||||
* \param nIdent[in, out] Unique identifier of the function
|
* \param nIdent[in, out] Unique identifier of the function
|
||||||
|
* \param program The current program, to search for functions.
|
||||||
* \return Type returned by the function or error code
|
* \return Type returned by the function or error code
|
||||||
* \see FindLocalOrPublic
|
* \see FindLocalOrPublic
|
||||||
*/
|
*/
|
||||||
static CBotTypResult CompileCall(const std::list<CBotFunction*>& localFunctionList,
|
static CBotTypResult CompileCall(const std::string &name, CBotVar** ppVars,
|
||||||
const std::string &name, CBotVar** ppVars, long &nIdent);
|
long &nIdent, CBotProgram* program);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Finds a local or public function
|
* \brief Finds a local or public function
|
||||||
*
|
*
|
||||||
* <p>Finds a local or (if bPublic is true) public function to call
|
|
||||||
*
|
|
||||||
* <p>First, it looks for a function according to its unique identifier.<br>
|
* <p>First, it looks for a function according to its unique identifier.<br>
|
||||||
* If the identifier is not found, looks by name and parameters.
|
* If the identifier is not found, looks by name and parameters.
|
||||||
*
|
*
|
||||||
|
@ -128,11 +126,46 @@ public:
|
||||||
* \param name Name of the function
|
* \param name Name of the function
|
||||||
* \param ppVars List of function arguments
|
* \param ppVars List of function arguments
|
||||||
* \param TypeOrError Type returned by the function or error code
|
* \param TypeOrError Type returned by the function or error code
|
||||||
* \param bPublic Whether to look in public functions or not
|
* \param baseProg Initial program, for context of the object/bot
|
||||||
* \return Pointer to found CBotFunction instance, or nullptr in case of no match or ambiguity (see TypeOrError for error code)
|
* \return Pointer to found CBotFunction instance, or nullptr in case of no match or ambiguity (see TypeOrError for error code)
|
||||||
*/
|
*/
|
||||||
static CBotFunction* FindLocalOrPublic(const std::list<CBotFunction*>& localFunctionList, long &nIdent, const std::string &name,
|
static CBotFunction* FindLocalOrPublic(const std::list<CBotFunction*>& localFunctionList, long &nIdent, const std::string &name,
|
||||||
CBotVar** ppVars, CBotTypResult &TypeOrError, bool bPublic = true);
|
CBotVar** ppVars, CBotTypResult &TypeOrError, CBotProgram* baseProg);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Find all functions that match the name and arguments.
|
||||||
|
* \param functionList List of functions to search, can be empty.
|
||||||
|
* \param name Name of the function to find.
|
||||||
|
* \param ppVars Arguments to compare with parameters.
|
||||||
|
* \param TypeOrError Contains a CBotError when no useable function has been found.
|
||||||
|
* \param funcMap Container for suitable functions and their signature values.
|
||||||
|
* \param pClass Pointer to class when searching for methods.
|
||||||
|
*/
|
||||||
|
static void SearchList(const std::list<CBotFunction*>& functionList,
|
||||||
|
const std::string& name, CBotVar** ppVars, CBotTypResult& TypeOrError,
|
||||||
|
std::map<CBotFunction*, int>& funcMap, CBotClass* pClass = nullptr);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Find all public functions that match the name and arguments.
|
||||||
|
* \param name Name of the function to find.
|
||||||
|
* \param ppVars Arguments to compare with parameters.
|
||||||
|
* \param TypeOrError Contains a CBotError when no useable function has been found.
|
||||||
|
* \param funcMap Container for suitable functions and their signature values.
|
||||||
|
* \param pClass Pointer to class when searching for methods.
|
||||||
|
*/
|
||||||
|
static void SearchPublic(const std::string& name, CBotVar** ppVars, CBotTypResult& TypeOrError,
|
||||||
|
std::map<CBotFunction*, int>& funcMap, CBotClass* pClass = nullptr);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Find the function with the lowest signature value. If there is more
|
||||||
|
* than one of the same signature value, TypeOrError is set to CBotErrAmbiguousCall.
|
||||||
|
* \param funcMap List of functions and their signature values, can be empty.
|
||||||
|
* \param[out] nIdent Unique identifier of the function.
|
||||||
|
* \param TypeOrError Type returned by the function or error code.
|
||||||
|
* \return Pointer to the function with the lowest signature or nullptr.
|
||||||
|
*/
|
||||||
|
static CBotFunction* BestFunction(std::map<CBotFunction*, int>& funcMap,
|
||||||
|
long& nIdent, CBotTypResult& TypeOrError);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief DoCall Fait un appel à une fonction.
|
* \brief DoCall Fait un appel à une fonction.
|
||||||
|
@ -160,10 +193,34 @@ public:
|
||||||
static void RestoreCall(const std::list<CBotFunction*>& localFunctionList,
|
static void RestoreCall(const std::list<CBotFunction*>& localFunctionList,
|
||||||
long &nIdent, const std::string &name, CBotVar** ppVars, CBotStack* pStack);
|
long &nIdent, const std::string &name, CBotVar** ppVars, CBotStack* pStack);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Find a method matching the name and arguments.
|
||||||
|
* \param name Name of the method to find.
|
||||||
|
* \param ppVars Arguments to compare with parameters.
|
||||||
|
* \param[out] nIdent Unique identifier of the method.
|
||||||
|
* \param pStack Current compilation stack frame.
|
||||||
|
* \param pClass Pointer to the class.
|
||||||
|
* \return The return type for the method or a CBotError.
|
||||||
|
*/
|
||||||
|
static CBotTypResult CompileMethodCall(const std::string& name, CBotVar** ppVars,
|
||||||
|
long& nIdent, CBotCStack* pStack, CBotClass* pClass);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Find a method by its unique identifier or by name and parameters.
|
||||||
|
* \param[in,out] nIdent Unique identifier of the method.
|
||||||
|
* \param name Name of the method to find.
|
||||||
|
* \param ppVars Arguments to compare with parameters.
|
||||||
|
* \param TypeOrError The return type for the method or a CBotError.
|
||||||
|
* \param pClass Pointer to the class.
|
||||||
|
* \param program The current program, to search for out-of-class methods.
|
||||||
|
* \return Pointer to the method that best matches the given arguments or nullptr.
|
||||||
|
*/
|
||||||
|
static CBotFunction* FindMethod(long& nIdent, const std::string& name,
|
||||||
|
CBotVar** ppVars, CBotTypResult& TypeOrError,
|
||||||
|
CBotClass* pClass, CBotProgram* program);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief DoCall Makes call of a method
|
* \brief DoCall Makes call of a method
|
||||||
* note: this is already on the stack, the pointer pThis is just to simplify.
|
|
||||||
* \param localFunctionList
|
|
||||||
* \param nIdent
|
* \param nIdent
|
||||||
* \param name
|
* \param name
|
||||||
* \param pThis
|
* \param pThis
|
||||||
|
@ -173,12 +230,11 @@ public:
|
||||||
* \param pClass
|
* \param pClass
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
static int DoCall(const std::list<CBotFunction*>& localFunctionList, long &nIdent, const std::string &name, CBotVar* pThis,
|
static int DoCall(long &nIdent, const std::string &name, CBotVar* pThis,
|
||||||
CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken, CBotClass* pClass);
|
CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken, CBotClass* pClass);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief RestoreCall
|
* \brief RestoreCall
|
||||||
* \param localFunctionList
|
|
||||||
* \param nIdent
|
* \param nIdent
|
||||||
* \param name
|
* \param name
|
||||||
* \param pThis
|
* \param pThis
|
||||||
|
@ -187,7 +243,7 @@ public:
|
||||||
* \param pClass
|
* \param pClass
|
||||||
* \return Returns true if the method call was restored.
|
* \return Returns true if the method call was restored.
|
||||||
*/
|
*/
|
||||||
static bool RestoreCall(const std::list<CBotFunction*>& localFunctionList, long &nIdent, const std::string &name, CBotVar* pThis,
|
static bool RestoreCall(long &nIdent, const std::string &name, CBotVar* pThis,
|
||||||
CBotVar** ppVars, CBotStack* pStack, CBotClass* pClass);
|
CBotVar** ppVars, CBotStack* pStack, CBotClass* pClass);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -215,12 +271,30 @@ public:
|
||||||
*/
|
*/
|
||||||
std::string GetParams();
|
std::string GetParams();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Get the name of the class for a method.
|
||||||
|
* \return The name of a class or empty string if it's not a method.
|
||||||
|
*/
|
||||||
|
const std::string& GetClassName() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief IsPublic
|
* \brief IsPublic
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
bool IsPublic();
|
bool IsPublic();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Check if a method is protected.
|
||||||
|
* \return true if a method was compiled with "protected" keyword.
|
||||||
|
*/
|
||||||
|
bool IsProtected() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Check if a method is private.
|
||||||
|
* \return true if a method was compiled with "private" keyword.
|
||||||
|
*/
|
||||||
|
bool IsPrivate() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief IsExtern
|
* \brief IsExtern
|
||||||
* \return
|
* \return
|
||||||
|
@ -266,6 +340,10 @@ private:
|
||||||
CBotTypResult m_retTyp;
|
CBotTypResult m_retTyp;
|
||||||
//! Public function.
|
//! Public function.
|
||||||
bool m_bPublic;
|
bool m_bPublic;
|
||||||
|
//! Protected method.
|
||||||
|
bool m_bProtect = false;
|
||||||
|
//! Private method.
|
||||||
|
bool m_bPrivate = false;
|
||||||
//! Extern function.
|
//! Extern function.
|
||||||
bool m_bExtern;
|
bool m_bExtern;
|
||||||
//! Name of the class we are part of
|
//! Name of the class we are part of
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -30,6 +30,7 @@
|
||||||
#include "CBot/CBotInstr/CBotExpression.h"
|
#include "CBot/CBotInstr/CBotExpression.h"
|
||||||
#include "CBot/CBotInstr/CBotFor.h"
|
#include "CBot/CBotInstr/CBotFor.h"
|
||||||
#include "CBot/CBotInstr/CBotIf.h"
|
#include "CBot/CBotInstr/CBotIf.h"
|
||||||
|
#include "CBot/CBotInstr/CBotRepeat.h"
|
||||||
#include "CBot/CBotInstr/CBotReturn.h"
|
#include "CBot/CBotInstr/CBotReturn.h"
|
||||||
#include "CBot/CBotInstr/CBotSwitch.h"
|
#include "CBot/CBotInstr/CBotSwitch.h"
|
||||||
#include "CBot/CBotInstr/CBotThrow.h"
|
#include "CBot/CBotInstr/CBotThrow.h"
|
||||||
|
@ -176,7 +177,7 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
{
|
{
|
||||||
type = pp->GetType();
|
type = pp->GetType();
|
||||||
// Allow only instructions that accept a label
|
// Allow only instructions that accept a label
|
||||||
if (!IsOfTypeList(pp, ID_WHILE, ID_FOR, ID_DO, 0))
|
if (!IsOfTypeList(pp, ID_WHILE, ID_FOR, ID_DO, ID_REPEAT, 0))
|
||||||
{
|
{
|
||||||
pStack->SetError(CBotErrLabel, pp->GetStart());
|
pStack->SetError(CBotErrLabel, pp->GetStart());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -195,6 +196,9 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
case ID_DO:
|
case ID_DO:
|
||||||
return CBotDo::Compile(p, pStack);
|
return CBotDo::Compile(p, pStack);
|
||||||
|
|
||||||
|
case ID_REPEAT:
|
||||||
|
return CBotRepeat::Compile(p, pStack);
|
||||||
|
|
||||||
case ID_BREAK:
|
case ID_BREAK:
|
||||||
case ID_CONTINUE:
|
case ID_CONTINUE:
|
||||||
return CBotBreak::Compile(p, pStack);
|
return CBotBreak::Compile(p, pStack);
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -38,7 +38,7 @@ class CBotDebug;
|
||||||
* \endcode
|
* \endcode
|
||||||
* the following structure is generated:
|
* the following structure is generated:
|
||||||
* \dot
|
* \dot
|
||||||
* # Generated using the CBot_compile_graph tool
|
* # Generated using the CBot-CompileGraph tool
|
||||||
* # and slightly modified
|
* # and slightly modified
|
||||||
* digraph {
|
* digraph {
|
||||||
* start [label=<START> shape=box3d color=cyan]
|
* start [label=<START> shape=box3d color=cyan]
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -78,12 +78,12 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
{
|
{
|
||||||
// if (pVar2!=nullptr) pp = pVar2->RetToken();
|
// if (pVar2!=nullptr) pp = pVar2->RetToken();
|
||||||
pStack->SetError( static_cast<CBotError>(inst->m_typRes.GetType()), pp );
|
pStack->SetError( static_cast<CBotError>(inst->m_typRes.GetType()), pp );
|
||||||
delete pStack->TokenStack();
|
pStack->DeleteNext();
|
||||||
delete inst;
|
delete inst;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete pStack->TokenStack();
|
pStack->DeleteNext();
|
||||||
if ( inst->m_typRes.GetType() > 0 )
|
if ( inst->m_typRes.GetType() > 0 )
|
||||||
{
|
{
|
||||||
CBotVar* pRes = CBotVar::Create("", inst->m_typRes);
|
CBotVar* pRes = CBotVar::Create("", inst->m_typRes);
|
||||||
|
@ -94,7 +94,7 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStack)))
|
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStack)))
|
||||||
{
|
{
|
||||||
inst->m_exprRetVar->SetToken(&inst->m_token);
|
inst->m_exprRetVar->SetToken(&inst->m_token);
|
||||||
delete pStack->TokenStack();
|
pStack->DeleteNext();
|
||||||
}
|
}
|
||||||
if ( !pStack->IsOk() )
|
if ( !pStack->IsOk() )
|
||||||
{
|
{
|
||||||
|
@ -105,7 +105,7 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
p = pp;
|
p = pp;
|
||||||
delete pStack->TokenStack();
|
pStack->DeleteNext();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +138,7 @@ bool CBotInstrCall::Execute(CBotStack* &pj)
|
||||||
if ( p != nullptr) while ( true )
|
if ( p != nullptr) while ( true )
|
||||||
{
|
{
|
||||||
pile = pile->AddStack(); // place on the stack for the results
|
pile = pile->AddStack(); // place on the stack for the results
|
||||||
|
if (pile->StackOver()) return pj->Return(pile);
|
||||||
if ( pile->GetState() == 0 )
|
if ( pile->GetState() == 0 )
|
||||||
{
|
{
|
||||||
if (!p->Execute(pile)) return false; // interrupted here?
|
if (!p->Execute(pile)) return false; // interrupted here?
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -70,7 +70,7 @@ CBotInstr* CBotInstrMethode::Compile(CBotToken* &p, CBotCStack* pStack, CBotVar*
|
||||||
CBotClass* pClass = var->GetClass(); // pointer to the class
|
CBotClass* pClass = var->GetClass(); // pointer to the class
|
||||||
inst->m_className = pClass->GetName(); // name of the class
|
inst->m_className = pClass->GetName(); // name of the class
|
||||||
CBotTypResult r = pClass->CompileMethode(pp, var, ppVars, pStack, inst->m_MethodeIdent);
|
CBotTypResult r = pClass->CompileMethode(pp, var, ppVars, pStack, inst->m_MethodeIdent);
|
||||||
delete pStack->TokenStack(); // release parameters on the stack
|
pStack->DeleteNext(); // release parameters on the stack
|
||||||
inst->m_typRes = r;
|
inst->m_typRes = r;
|
||||||
|
|
||||||
if (inst->m_typRes.GetType() > 20)
|
if (inst->m_typRes.GetType() > 20)
|
||||||
|
@ -95,7 +95,7 @@ CBotInstr* CBotInstrMethode::Compile(CBotToken* &p, CBotCStack* pStack, CBotVar*
|
||||||
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStack, bMethodChain)))
|
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStack, bMethodChain)))
|
||||||
{
|
{
|
||||||
inst->m_exprRetVar->SetToken(pp);
|
inst->m_exprRetVar->SetToken(pp);
|
||||||
delete pStack->TokenStack();
|
pStack->DeleteNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pStack->IsOk() )
|
if ( pStack->IsOk() )
|
||||||
|
@ -164,6 +164,7 @@ bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre
|
||||||
}
|
}
|
||||||
ppVars[i++] = pile2->GetVar(); // construct the list of pointers
|
ppVars[i++] = pile2->GetVar(); // construct the list of pointers
|
||||||
pile2 = pile2->AddStack(); // space on the stack for the result
|
pile2 = pile2->AddStack(); // space on the stack for the result
|
||||||
|
if (pile2->StackOver()) return pj->Return(pile2);
|
||||||
p = p->GetNext();
|
p = p->GetNext();
|
||||||
if ( p == nullptr) break;
|
if ( p == nullptr) break;
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -65,7 +65,7 @@ CBotInstr* CompileParams(CBotToken* &p, CBotCStack* pStack, CBotVar** ppVars)
|
||||||
{
|
{
|
||||||
if (pile->GetTypResult().Eq(99))
|
if (pile->GetTypResult().Eq(99))
|
||||||
{
|
{
|
||||||
delete pStack->TokenStack();
|
pStack->DeleteNext();
|
||||||
pStack->SetError(CBotErrVoid, p->GetStart());
|
pStack->SetError(CBotErrVoid, p->GetStart());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ CBotInstr* CompileParams(CBotToken* &p, CBotCStack* pStack, CBotVar** ppVars)
|
||||||
}
|
}
|
||||||
|
|
||||||
pStack->SetError(CBotErrClosePar, p->GetStart());
|
pStack->SetError(CBotErrClosePar, p->GetStart());
|
||||||
delete pStack->TokenStack();
|
pStack->DeleteNext();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of the Colobot: Gold Edition source code
|
* This file is part of the Colobot: Gold Edition source code
|
||||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
* Copyright (C) 2001-2023, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -87,7 +87,7 @@ CBotInstr* CBotNew::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
|
|
||||||
// constructor exist?
|
// constructor exist?
|
||||||
CBotTypResult r = pClass->CompileMethode(&inst->m_vartoken, pVar, ppVars, pStk, inst->m_nMethodeIdent);
|
CBotTypResult r = pClass->CompileMethode(&inst->m_vartoken, pVar, ppVars, pStk, inst->m_nMethodeIdent);
|
||||||
delete pStk->TokenStack(); // release extra stack
|
pStk->DeleteNext(); // release extra stack
|
||||||
int typ = r.GetType();
|
int typ = r.GetType();
|
||||||
|
|
||||||
// if there is no constructor, and no parameters either, it's ok
|
// if there is no constructor, and no parameters either, it's ok
|
||||||
|
@ -115,7 +115,7 @@ CBotInstr* CBotNew::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStk, true)))
|
if (nullptr != (inst->m_exprRetVar = CBotExprRetVar::Compile(p, pStk, true)))
|
||||||
{
|
{
|
||||||
inst->m_exprRetVar->SetToken(pp);
|
inst->m_exprRetVar->SetToken(pp);
|
||||||
delete pStk->TokenStack();
|
pStk->DeleteNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStack->IsOk())
|
if (pStack->IsOk())
|
||||||
|
@ -189,6 +189,7 @@ bool CBotNew::Execute(CBotStack* &pj)
|
||||||
if (p != nullptr) while ( true)
|
if (p != nullptr) while ( true)
|
||||||
{
|
{
|
||||||
pile2 = pile2->AddStack(); // space on the stack for the result
|
pile2 = pile2->AddStack(); // space on the stack for the result
|
||||||
|
if (pile2->StackOver()) return pj->Return(pile2);
|
||||||
if (pile2->GetState() == 0)
|
if (pile2->GetState() == 0)
|
||||||
{
|
{
|
||||||
if (!p->Execute(pile2)) return false; // interrupted here?
|
if (!p->Execute(pile2)) return false; // interrupted here?
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue