Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db39bf4937 | ||
|
|
e69505ce7e | ||
|
|
dbcd6bfaab | ||
|
|
f5c7674018 | ||
|
|
8d5b97e1c8 | ||
|
|
88eaa3b38d | ||
|
|
6e15e7cc94 | ||
|
|
851b6d558e | ||
|
|
d65ffcd876 | ||
|
|
db8f861d24 | ||
|
|
1d23cf4603 | ||
|
|
9fe8127292 | ||
|
|
fb276e9c81 | ||
|
|
2829e1c9c3 | ||
|
|
bd6b57c749 | ||
|
|
a0839a37b6 | ||
|
|
c93c6dcb39 | ||
|
|
b01cdd4f72 | ||
|
|
b937cc95bb | ||
|
|
324255795e | ||
|
|
36963777d7 | ||
|
|
372fcb7b55 | ||
|
|
4213167b49 | ||
|
|
33d387f065 | ||
|
|
bd2a5787a7 | ||
|
|
8ef2943e88 | ||
|
|
dc8de752d2 | ||
|
|
5d8cd8a1e8 | ||
|
|
20941b9e22 | ||
|
|
549e9e15d2 | ||
|
|
f850c091e9 | ||
|
|
265e667831 | ||
|
|
cf8e05c0a0 | ||
|
|
fe5e127c24 | ||
|
|
069f0ce2c5 | ||
|
|
a38a9a8d66 | ||
|
|
e3c5aabf6c | ||
|
|
c2e8cce063 | ||
|
|
fff996aae3 | ||
|
|
3df8dbd498 | ||
|
|
7794268a51 | ||
|
|
e32f635d7f | ||
|
|
e8fbd6100c | ||
|
|
b5996d4d56 | ||
|
|
ab05d88d85 | ||
|
|
64f8723ff7 | ||
|
|
1b47579f1f | ||
|
|
c667560e5e | ||
|
|
dda1fa727c | ||
|
|
25c754f99d | ||
|
|
c6be527773 | ||
|
|
2971a77ea3 | ||
|
|
a18944c912 | ||
|
|
d5db38f930 | ||
|
|
47ee6f6b0d | ||
|
|
d446baf6df | ||
|
|
147e8a0e8f | ||
|
|
f0be15f518 | ||
|
|
590f425785 | ||
|
|
53767b2294 | ||
|
|
cbfd23cf41 | ||
|
|
a402181ea7 | ||
|
|
68e9866d6c | ||
|
|
31f07bcf5f | ||
|
|
551e4073dd | ||
|
|
c8ea79a789 | ||
|
|
c29ddc5aea | ||
|
|
83e83befee | ||
|
|
d80a88ab66 | ||
|
|
952d650bd9 | ||
|
|
a4f96fc6d0 | ||
|
|
28279efc6c | ||
|
|
d046baba56 | ||
|
|
60eb63cb61 | ||
|
|
f4493b5cb9 | ||
|
|
b98f9a9770 | ||
|
|
bb86d1ae82 | ||
|
|
228b794298 | ||
|
|
993e2006bf | ||
|
|
cab239fbc1 | ||
|
|
d3a68ca7da | ||
|
|
6424a77dec | ||
|
|
078b428610 | ||
|
|
f39cfca18c | ||
|
|
c84225f927 | ||
|
|
c466b866be | ||
|
|
10157d6d4f | ||
|
|
908338ed49 | ||
|
|
8810665a8e | ||
|
|
f6c598d72a | ||
|
|
876ad302da | ||
|
|
5d5eb8da74 | ||
|
|
481d770f90 | ||
|
|
f516f33648 | ||
|
|
f648837255 | ||
|
|
319b1c1f25 | ||
|
|
1cc761e82d | ||
|
|
791a25ab22 | ||
|
|
8756e99a2b | ||
|
|
e29d2b0cb8 | ||
|
|
8f81bc5524 | ||
|
|
df2f145eb7 | ||
|
|
deb6a69d00 | ||
|
|
2198893997 | ||
|
|
327e3d216f | ||
|
|
4bda4ad9ac | ||
|
|
a67ffdfcf3 | ||
|
|
8ea4979701 | ||
|
|
e4466d9011 | ||
|
|
c392ee6831 | ||
|
|
9093e4963c | ||
|
|
f8fa2262b8 | ||
|
|
6bab05b864 | ||
|
|
56850a7131 | ||
|
|
236fd96e77 | ||
|
|
ebe33a4f92 | ||
|
|
aaba542d2d | ||
|
|
c5f77e70fa | ||
|
|
d8968fd609 | ||
|
|
046ec6ac45 | ||
|
|
729e6679af | ||
|
|
c86794f081 | ||
|
|
8dad606832 | ||
|
|
bb2d55478f | ||
|
|
52c1e83d9b | ||
|
|
3d64c600c8 | ||
|
|
9bf91b4feb | ||
|
|
9207376076 | ||
|
|
f9dbaee0fe | ||
|
|
76a62bb09b | ||
|
|
bfce304e49 | ||
|
|
d9fe12e558 | ||
|
|
10eefa8410 | ||
|
|
68aa9c4146 | ||
|
|
ff5bdc0608 | ||
|
|
05f47b9cef | ||
|
|
00a3294c55 | ||
|
|
21c4c05ded | ||
|
|
1bfc685eac | ||
|
|
d00c87d510 | ||
|
|
d44b3b9cc5 | ||
|
|
02f3f27e5f | ||
|
|
8d0d9f49c7 | ||
|
|
04f50be0c5 | ||
|
|
c1a48dc4b4 | ||
|
|
d765ba339d | ||
|
|
a44448070c | ||
|
|
58b959e8ea | ||
|
|
606b6694e7 | ||
|
|
0c60df0482 | ||
|
|
517bb1122b | ||
|
|
f66359c448 | ||
|
|
e04bca4458 | ||
|
|
40fca8ff0c | ||
|
|
85be7629a3 | ||
|
|
887f84c05b | ||
|
|
24918e87d3 | ||
|
|
103368eca8 | ||
|
|
187ec8f8cc | ||
|
|
6c1c2cf55c | ||
|
|
4261092d46 | ||
|
|
7555b4156c | ||
|
|
fd8196551d | ||
|
|
a5d0cc42be | ||
|
|
d52c8e9f1f | ||
|
|
c7acca34e3 | ||
|
|
ffd2295671 | ||
|
|
01a610385f | ||
|
|
89da65fa10 | ||
|
|
d2d097a4f4 | ||
|
|
6808cf4f0a | ||
|
|
565a2cd8a5 | ||
|
|
b40839ac01 | ||
|
|
d39f7be3a6 | ||
|
|
c3ad8125e8 | ||
|
|
984d68baf7 | ||
|
|
eb61b825f6 | ||
|
|
05a2d66932 | ||
|
|
9b8d3cc5fd | ||
|
|
df455992b7 | ||
|
|
a14418ee56 | ||
|
|
ac8f008e4f | ||
|
|
04c7025aa6 | ||
|
|
713ea6f2b9 | ||
|
|
8f2279a65a | ||
|
|
c0327f0f50 | ||
|
|
ef733eeed7 | ||
|
|
29c77cd0ff | ||
|
|
ea6af8b79a | ||
|
|
5c1f284b62 | ||
|
|
ddfa475f63 | ||
|
|
970c942354 | ||
|
|
cf28984e4f | ||
|
|
484e2bec5c | ||
|
|
0e60bd47c0 | ||
|
|
045c3aea88 | ||
|
|
831ae6261e | ||
|
|
2bbb6155a6 | ||
|
|
0af8b3422d | ||
|
|
c0759cfa4a | ||
|
|
1d6f8750e5 | ||
|
|
c2609195b3 | ||
|
|
c8092bd0c2 | ||
|
|
e49ff0c74e | ||
|
|
d93412a781 | ||
|
|
3e97f03f46 | ||
|
|
fe760be8a3 | ||
|
|
180674b76a | ||
|
|
c1ea6216d6 | ||
|
|
1a12c25791 | ||
|
|
b41410c253 | ||
|
|
20eb9b1dfa | ||
|
|
7f29417833 | ||
|
|
f7d71dbc54 | ||
|
|
781e368c6e | ||
|
|
03199d3013 | ||
|
|
4aff0a311b | ||
|
|
e49e22eb09 | ||
|
|
1ba578b77a | ||
|
|
0304e67009 | ||
|
|
0c63d2b3c0 | ||
|
|
e5917b9b58 | ||
|
|
1de430b251 | ||
|
|
52891ff9ed | ||
|
|
70a9bee68d | ||
|
|
14ca5efab7 | ||
|
|
f31fc60903 | ||
|
|
fb86580a94 | ||
|
|
cac7518cc3 | ||
|
|
62c9f4d928 | ||
|
|
06cdbbfecf | ||
|
|
fa52a4fa4a | ||
|
|
00935c4a4f | ||
|
|
4a514c05b4 | ||
|
|
be57f6b5e6 | ||
|
|
4cb279d5bd | ||
|
|
b999b3dcf6 | ||
|
|
a4bf552b52 | ||
|
|
e3b5e53232 | ||
|
|
bc00904dac | ||
|
|
c5222f9d8b | ||
|
|
25cff7231d | ||
|
|
b773326d0b | ||
|
|
0806c840a0 | ||
|
|
61074d1708 | ||
|
|
1c0da4329d | ||
|
|
ae63739d49 | ||
|
|
16a46697ed | ||
|
|
c8c3d089ff | ||
|
|
29e77c4e06 | ||
|
|
05efe1b3bc | ||
|
|
b58f9ed7c3 | ||
|
|
b1802a2da5 | ||
|
|
9b92bf15c2 | ||
|
|
55d23bf13b | ||
|
|
18fe3ba482 | ||
|
|
6b04851f8e | ||
|
|
adad70b7d0 | ||
|
|
cd824e97da | ||
|
|
a930c3118b | ||
|
|
9b2e33f61d | ||
|
|
e69749f927 | ||
|
|
e35102e995 | ||
|
|
8962ce85b9 | ||
|
|
7c530f8d05 | ||
|
|
60afe7defb | ||
|
|
8669079ca7 | ||
|
|
bc1a06afb3 | ||
|
|
b127149ecd | ||
|
|
cc11906b28 | ||
|
|
a85aae1f0c | ||
|
|
eec8890307 | ||
|
|
4b0d3705db | ||
|
|
bdd27a61b1 | ||
|
|
cbfcbd9fb0 | ||
|
|
1c780b4d1a | ||
|
|
8721e312a1 | ||
|
|
48ca4f5393 | ||
|
|
3b1f1ce903 | ||
|
|
0d2d623982 | ||
|
|
c1f22693fe | ||
|
|
fb996bb222 | ||
|
|
54cac13960 | ||
|
|
b09cf46ef1 | ||
|
|
ae25d9d76d | ||
|
|
8bb5267bc1 | ||
|
|
2c1856150b | ||
|
|
1e1b63b161 | ||
|
|
19afb00c1a | ||
|
|
68a6211030 | ||
|
|
dc440f6392 | ||
|
|
a5542cb6af | ||
|
|
4ebd599daf | ||
|
|
e777f5a6cb | ||
|
|
555b42294b | ||
|
|
88181bc767 | ||
|
|
8d4f0d1a9a | ||
|
|
416e7d3dab | ||
|
|
b94f833d2c | ||
|
|
01030d3c43 | ||
|
|
b442ebdc98 | ||
|
|
b7738e7af9 | ||
|
|
67ead555a0 | ||
|
|
12777dc0ab | ||
|
|
01ca8a9870 | ||
|
|
8e285f653b | ||
|
|
d7d8b22c24 | ||
|
|
16aac1dcdf | ||
|
|
1f2264e345 | ||
|
|
4df381a138 | ||
|
|
ddf9d1e10e | ||
|
|
ea9865e9f7 | ||
|
|
aab000379e | ||
|
|
b9a93c9402 | ||
|
|
db2154869c | ||
|
|
63039e7682 | ||
|
|
846a69ca81 | ||
|
|
a38f1cb11b | ||
|
|
3a0e532091 | ||
|
|
6516d02466 | ||
|
|
0e314c33e3 | ||
|
|
630fa7a498 | ||
|
|
f36459fbfa | ||
|
|
6ff559c27a | ||
|
|
5a655dfc01 | ||
|
|
99ca92c254 | ||
|
|
281a76e668 | ||
|
|
252a0ee332 | ||
|
|
7b0cb8935a | ||
|
|
e614a0c943 | ||
|
|
957beea092 | ||
|
|
04961c5299 | ||
|
|
995572c1b9 | ||
|
|
cf9807e75d | ||
|
|
4ed7b6c20e | ||
|
|
9ea44fb478 | ||
|
|
0fa8cdce35 | ||
|
|
b89f112003 | ||
|
|
43858207cb | ||
|
|
3f7d977e2d | ||
|
|
8dbf4265d3 | ||
|
|
ab98403bbc | ||
|
|
495e4c57a6 | ||
|
|
efd55b0142 | ||
|
|
d0a4d16d31 | ||
|
|
b0725e5ec1 | ||
|
|
dfae6cb8b2 | ||
|
|
fbc585311e | ||
|
|
209ff21711 | ||
|
|
3acdad7208 | ||
|
|
4ce608df96 | ||
|
|
95117c9823 | ||
|
|
6ecb3a6dfe | ||
|
|
0ec234e1c5 | ||
|
|
2149a25280 | ||
|
|
9816c6e097 | ||
|
|
791a6e2044 | ||
|
|
583a938c94 | ||
|
|
c7b80c5d97 | ||
|
|
0eaa6ca2da | ||
|
|
dd49e96b89 | ||
|
|
462e61d3a3 | ||
|
|
ba02c83d6a | ||
|
|
eb004ccc21 | ||
|
|
ba49ee774c | ||
|
|
ed163ea7f9 | ||
|
|
65dad6f715 | ||
|
|
f3f86debeb | ||
|
|
d83f24a4f3 | ||
|
|
6e8b92ba33 | ||
|
|
27a4bde81a | ||
|
|
6d6de8f13c | ||
|
|
3bf547de0b | ||
|
|
e444c648aa | ||
|
|
cf75e7833c | ||
|
|
8a6946b4f5 | ||
|
|
944fbc010d | ||
|
|
e60388aac2 | ||
|
|
4976c58126 | ||
|
|
53fd5306f9 | ||
|
|
6885553439 | ||
|
|
6052ef7187 | ||
|
|
a4bf9168a3 | ||
|
|
30c510fa48 | ||
|
|
e3bac4d0b2 | ||
|
|
bf9b06af8c | ||
|
|
07653b02de | ||
|
|
a5e0c55f99 | ||
|
|
8419e52906 | ||
|
|
ed591d9434 | ||
|
|
5801dc6493 | ||
|
|
a40b1ad699 | ||
|
|
227b7078d5 | ||
|
|
a9d3290aba | ||
|
|
001c19d6ad | ||
|
|
ff13dfd58f | ||
|
|
6ba13ff395 | ||
|
|
e618fc272c | ||
|
|
7c98a03bd1 | ||
|
|
b24f42f144 | ||
|
|
61a04dda5f | ||
|
|
db5bdd0dd6 | ||
|
|
0b07e9c6c6 | ||
|
|
f3b5cfcdb9 | ||
|
|
c1080fdc53 | ||
|
|
85d8c2db9a | ||
|
|
31dc821a50 | ||
|
|
f5edc77d43 | ||
|
|
2b2975c755 | ||
|
|
45a37da259 | ||
|
|
97eff27fc4 | ||
|
|
707b46648c | ||
|
|
4fb392ae7b | ||
|
|
4034421a5f | ||
|
|
2abc877b89 | ||
|
|
1f72b4d82a | ||
|
|
4214aa6705 | ||
|
|
51feb3940f | ||
|
|
3ef00627a7 | ||
|
|
ef653fb04c | ||
|
|
915eb474e7 | ||
|
|
373821b1ec | ||
|
|
53f61023bd | ||
|
|
27b1f76522 | ||
|
|
2e24a939ed | ||
|
|
258edeed0e | ||
|
|
12ea0ba6e0 | ||
|
|
9eaed98931 | ||
|
|
3259b60ab6 | ||
|
|
e1d305621a | ||
|
|
6d6453173b | ||
|
|
162b1c133a | ||
|
|
3a6961242d | ||
|
|
7f998d0fa0 | ||
|
|
92cdf5a2e2 | ||
|
|
d0eed5a776 | ||
|
|
e055e6022a | ||
|
|
9d794fd553 | ||
|
|
f370fee9cd | ||
|
|
e392ac4a1a | ||
|
|
99a407b03b | ||
|
|
e7d434fd2e | ||
|
|
17c8ec4c44 | ||
|
|
ec0d52819b | ||
|
|
882577dc26 | ||
|
|
13c1cce325 | ||
|
|
a550d3af3a | ||
|
|
17cf4b8d7a | ||
|
|
a517aa1ff2 | ||
|
|
e812606938 | ||
|
|
1e21bb2dba | ||
|
|
9d32028420 | ||
|
|
950176f7c4 | ||
|
|
f8b3efbcfe | ||
|
|
20711c0bf8 | ||
|
|
433e6b437e | ||
|
|
a010e9b91c | ||
|
|
c92f81de9e | ||
|
|
e42bef2476 | ||
|
|
d24c3db73f | ||
|
|
fa951d47a5 | ||
|
|
7affefe26e | ||
|
|
ff24fa07b2 | ||
|
|
12b962ecc5 | ||
|
|
0350a9428a | ||
|
|
855e02e38a | ||
|
|
37dbbd9774 | ||
|
|
092531e45a | ||
|
|
a9be514615 | ||
|
|
e8cbf83e7b | ||
|
|
7d9c6eb659 | ||
|
|
f637e5cacb | ||
|
|
904b878c73 | ||
|
|
cdc2720f40 | ||
|
|
1b58cc0d09 | ||
|
|
6303fc4e92 | ||
|
|
439c1f4dc8 | ||
|
|
6c4d4ac83c | ||
|
|
62509cf04e | ||
|
|
68340b5735 | ||
|
|
0b11fbd50d | ||
|
|
5ce4233c8e | ||
|
|
dd853d17a1 | ||
|
|
2df32d8d41 | ||
|
|
bb1911d488 | ||
|
|
d1624d62f9 | ||
|
|
ae02604918 | ||
|
|
695a6bd995 | ||
|
|
19fe2573df | ||
|
|
5b4bfc60a2 | ||
|
|
5644fa9955 | ||
|
|
899fa2669c | ||
|
|
9737c80b42 | ||
|
|
85fe62e973 | ||
|
|
44f0ed5a50 | ||
|
|
1bef46492e | ||
|
|
56101869f0 | ||
|
|
e226c1a8c3 | ||
|
|
5fdeca75f7 | ||
|
|
3743980735 | ||
|
|
c1f7232151 | ||
|
|
988f9ad089 | ||
|
|
7e23372a06 | ||
|
|
3d6b93833c | ||
|
|
7e5809aba1 | ||
|
|
f7cbb88ddc | ||
|
|
f3f0dc371e | ||
|
|
115baa2b1d | ||
|
|
d42553c15b | ||
|
|
94b9a85de1 | ||
|
|
631e7539e0 | ||
|
|
f67c64bb11 | ||
|
|
3f7c39c54a | ||
|
|
26fac782bf | ||
|
|
c712855c41 | ||
|
|
3bb25fca02 | ||
|
|
41bd9eb16c | ||
|
|
96c31ae231 | ||
|
|
ad6fea93e0 | ||
|
|
5481fe1ee1 | ||
|
|
024b8c2cbb | ||
|
|
d8c0b4b97d | ||
|
|
60f418fff3 | ||
|
|
c90b0902ad | ||
|
|
7f2d795efc | ||
|
|
23b3b56992 | ||
|
|
00f762f331 | ||
|
|
62f095256c | ||
|
|
a362db55a5 | ||
|
|
b212ee1f99 | ||
|
|
358bdb0888 | ||
|
|
5fc4cabfe2 | ||
|
|
efb9d4fc30 | ||
|
|
303cffc993 | ||
|
|
5a4d2928af | ||
|
|
a7fd6b118c | ||
|
|
237d2effae | ||
|
|
79fbd4c77b | ||
|
|
75f26d45ff | ||
|
|
d9adc60235 | ||
|
|
035586f107 | ||
|
|
8307f7acf8 | ||
|
|
4b95721a6b | ||
|
|
c33a123ad3 | ||
|
|
0d86be7c88 | ||
|
|
064b186e7c | ||
|
|
1ddd37b999 | ||
|
|
11e45e33c1 | ||
|
|
6a3727bb9d | ||
|
|
d49a37b18e | ||
|
|
a2ceb306e8 | ||
|
|
af0aba2d25 | ||
|
|
308745461f | ||
|
|
cb40d42334 | ||
|
|
6d778c41d7 | ||
|
|
a680c04509 | ||
|
|
0626309f27 | ||
|
|
caa8eb7d0a | ||
|
|
a824b417ec | ||
|
|
4db90a3595 | ||
|
|
550da36b9b | ||
|
|
25a0ba4d73 | ||
|
|
6338bebce6 | ||
|
|
33040218af | ||
|
|
0a80220cb1 | ||
|
|
8705f0bd29 | ||
|
|
0bcca4d1b0 | ||
|
|
a314febfc7 | ||
|
|
d331a12820 | ||
|
|
705d7806d7 | ||
|
|
ed602a754b | ||
|
|
1499b1a04c | ||
|
|
3f315b1480 | ||
|
|
206efef4bd | ||
|
|
ba6633eb73 | ||
|
|
ad33d3f04b | ||
|
|
1130600b0e | ||
|
|
f84b903428 | ||
|
|
62d2ba6b0b | ||
|
|
2b6e7aa111 | ||
|
|
14b825cc91 | ||
|
|
f87fee9d53 | ||
|
|
4e411aaf74 | ||
|
|
7902069c2b | ||
|
|
1547bf0247 | ||
|
|
727a9f12e2 | ||
|
|
7ba47cce99 | ||
|
|
bfb14aa07b | ||
|
|
c0fee57975 | ||
|
|
c54945dd66 | ||
|
|
39d0bf75dd |
No files matched your search
@@ -1,182 +0,0 @@
|
||||
-*- outline -*-
|
||||
|
||||
Generic code sharing
|
||||
====================
|
||||
|
||||
* Porting
|
||||
|
||||
** Generic class init trampoline
|
||||
|
||||
The generic class init trampoline is very similar to the class init
|
||||
trampoline, with the exception that the VTable of the class to be
|
||||
inited is passed in a register, MONO_ARCH_VTABLE_REG. That can be the
|
||||
same as the IMT register.
|
||||
|
||||
The call to the generic class init trampoline is never patched because
|
||||
the VTable is not constant - it depends on the type arguments of the
|
||||
class/method doing the call to the trampoline. For that reason, the
|
||||
trampoline needs a fast path for the case that the class is already
|
||||
inited. See tramp-x86.c for how to portably figure out the number of
|
||||
the bit in the bit-field that needs to be checked.
|
||||
|
||||
** RGCTX register
|
||||
|
||||
Generic shared code needs access to type information. This
|
||||
information is contained in a RGCTX for non-generic methods and in an
|
||||
MRGCTX for generic methods. It is passed in one of several ways,
|
||||
depending on the type of the called method:
|
||||
|
||||
1. Non-generic non-static methods of reference types have access to
|
||||
the RGCTX via the "this" argument (this->vtable->rgctx).
|
||||
|
||||
2. Non-generic static methods of reference types and non-generic
|
||||
methods of value types need to be passed a pointer to the
|
||||
caller's class's VTable in the MONO_ARCH_RGCTX_REG register.
|
||||
|
||||
3. Generic methods need to be passed a pointer to the MRGCTX in the
|
||||
MONO_ARCH_RGCTX_REG register.
|
||||
|
||||
The MONO_ARCH_RGCTX_REG must not be clobbered by trampolines.
|
||||
|
||||
MONO_ARCH_RGCTX_REG can be the same as the IMT register for now, but
|
||||
this might change in the future when we implement virtual generic
|
||||
method calls (more) efficiently.
|
||||
|
||||
** Dealing with types
|
||||
|
||||
Types passed to arch functions might be type parameters
|
||||
(MONO_TYPE_(M)VAR) if the MonoGenericSharingContext* argument is
|
||||
non-NULL. For example, an argument or return type in a method passed
|
||||
to mono_arch_find_this_argument() could be a MONO_TYPE_VAR. To guard
|
||||
for that case use mini_get_basic_type_from_generic() on the type. See
|
||||
get_call_info() in mini-x86.c, for example.
|
||||
|
||||
** (M)RGCTX lazy fetch trampoline
|
||||
|
||||
The purpose of the lazy fetch trampoline is to fetch a slot from an
|
||||
(M)RGCTX which might not be inited, yet. In the latter case, it needs
|
||||
to go make a transition to unmanaged code to fill the slot. This is
|
||||
the layout of a RGCTX:
|
||||
|
||||
+---------------------------------+
|
||||
| next | slot 0 | slot 1 | slot 2 |
|
||||
+--|------------------------------+
|
||||
|
|
||||
+-----+
|
||||
| +---------------------------------
|
||||
+->| next | slot 3 | slot 4 | slot 5 ....
|
||||
+--|------------------------------
|
||||
|
|
||||
+-----+
|
||||
| +------------------------------------
|
||||
+->| next | slot 10 | slot 11 | slot 12 ....
|
||||
+--|---------------------------------
|
||||
.
|
||||
.
|
||||
.
|
||||
|
||||
For fetching a slot from a RGCTX the trampoline is passed a pointer to
|
||||
the VTable. From there it has to fetch the pointer to the RGCTX,
|
||||
which might be null. Then it has to traverse the correct number of
|
||||
"next" links, each of which might be NULL. Arriving at the right
|
||||
array it needs to fetch the slot, which might also be NULL. If any of
|
||||
the NULL cases, the trampoline must transition to unmanaged code to
|
||||
potentially setup the RGCTX and fill the slot. Here is pseudo-code
|
||||
for fetching slot 11:
|
||||
|
||||
; vtable ptr in r1
|
||||
; fetch RGCTX array 0
|
||||
r2 = *(r1 + offsetof(MonoVTable, runtime_generic_context))
|
||||
if r2 == NULL goto unmanaged
|
||||
; fetch RGCTX array 1
|
||||
r2 = *r2
|
||||
if r2 == NULL goto unmanaged
|
||||
; fetch RGCTX array 2
|
||||
r2 = *r2
|
||||
if r2 == NULL goto unmanaged
|
||||
; fetch slot 11
|
||||
r2 = *(r2 + 2 * sizeof (gpointer))
|
||||
if r2 == NULL goto unmanaged
|
||||
return r2
|
||||
unmanaged:
|
||||
jump unmanaged_fetch_code
|
||||
|
||||
The number of slots in the arrays must be obtained from the function
|
||||
mono_class_rgctx_get_array_size().
|
||||
|
||||
The MRGCTX case is different in two aspects. First, the trampoline is
|
||||
not passed a pointer to a VTable, but a pointer directly to the
|
||||
MRGCTX, which is guaranteed not to be NULL (any of the next pointers
|
||||
and any of the slots can be NULL, though). Second, the layout of the
|
||||
first array is slightly different, in that the first two slots are
|
||||
occupied by a pointers to the class's VTable and to the method's
|
||||
method_inst. The next pointer is in the third slot and the first
|
||||
actual slot, "slot 0", in the fourth:
|
||||
|
||||
+--------------------------------------------------------+
|
||||
| vtable | method_inst | next | slot 0 | slot 1 | slot 2 |
|
||||
+-------------------------|------------------------------+
|
||||
.
|
||||
.
|
||||
|
||||
All other arrays have the same layout as the RGCTX ones, except
|
||||
possibly for their length.
|
||||
|
||||
The function to create the trampoline,
|
||||
mono_arch_create_rgctx_lazy_fetch_trampoline(), gets passed an encoded
|
||||
slot number. Use the macro MONO_RGCTX_SLOT_IS_MRGCTX to query whether
|
||||
a trampoline for an MRGCTX is needed, as opposed to one for a RGCTX.
|
||||
Use MONO_RGCTX_SLOT_INDEX to get the index of the slot (like 2 for
|
||||
"slot 2" as above).
|
||||
|
||||
|
||||
* Getting generics information about a stack frame
|
||||
|
||||
If a method is compiled with generic sharing, its MonoJitInfo has
|
||||
has_generic_jit_info set. In that case, the MonoJitInfo is followed
|
||||
(after the MonoJitExceptionInfo array) by a MonoGenericJitInfo.
|
||||
|
||||
The MonoGenericJitInfo contains information about the location of the
|
||||
this/vtable/MRGCTX variable, if the has_this flag is set. If that is
|
||||
the case, there are two possibilities:
|
||||
|
||||
1. this_in_reg is set. this_reg is the number of the register where
|
||||
the variable is stored.
|
||||
|
||||
2. this_in_reg is not set. The variable is stored at offset
|
||||
this_offset from the address in the register with number
|
||||
this_reg.
|
||||
|
||||
The variable can either point to the "this" object, to a vtable or to
|
||||
an MRGCTX:
|
||||
|
||||
1. If the method is a non-generic non-static method of a reference
|
||||
type, the variable points to the "this" object.
|
||||
|
||||
2. If the method is a non-generic static method or a non-generic
|
||||
method of a value type, the variable points to the vtable of the
|
||||
class.
|
||||
|
||||
3. If the method is a generic method, the variable points to the
|
||||
MRGCTX of the method.
|
||||
|
||||
|
||||
* Layout of the MRGCTX
|
||||
|
||||
The MRGCTX is a structure that starts with
|
||||
MonoMethodRuntimeGenericContext, which contains a pointer to the
|
||||
vtable of the class and a pointer to the MonoGenericInst with the type
|
||||
arguments for the method.
|
||||
|
||||
|
||||
* Blog posts about generic code sharing
|
||||
|
||||
http://schani.wordpress.com/2007/09/22/generics-sharing-in-mono/
|
||||
http://schani.wordpress.com/2007/10/12/the-trouble-with-shared-generics/
|
||||
http://schani.wordpress.com/2007/10/15/a-quick-generics-sharing-update/
|
||||
http://schani.wordpress.com/2008/01/29/other-types/
|
||||
http://schani.wordpress.com/2008/02/25/generic-types-are-lazy/
|
||||
http://schani.wordpress.com/2008/03/10/sharing-static-methods/
|
||||
http://schani.wordpress.com/2008/04/22/sharing-everything-and-saving-memory/
|
||||
http://schani.wordpress.com/2008/06/02/sharing-generic-methods/
|
||||
http://schani.wordpress.com/2008/06/27/another-generic-sharing-update/
|
||||
@@ -1,64 +0,0 @@
|
||||
#include <config.h>
|
||||
#include <glib.h>
|
||||
#include <gmodule.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include "test.h"
|
||||
|
||||
#if defined (G_OS_WIN32)
|
||||
#define EXTERNAL_SYMBOL "GetProcAddress"
|
||||
#else
|
||||
#define EXTERNAL_SYMBOL "system"
|
||||
#endif
|
||||
|
||||
void G_MODULE_EXPORT
|
||||
dummy_test_export ()
|
||||
{
|
||||
}
|
||||
|
||||
/* test for g_module_open (NULL, ...) */
|
||||
RESULT
|
||||
test_module_symbol_null ()
|
||||
{
|
||||
gpointer proc = GINT_TO_POINTER (42);
|
||||
|
||||
GModule *m = g_module_open (NULL, G_MODULE_BIND_LAZY);
|
||||
|
||||
if (m == NULL)
|
||||
return FAILED ("bind to main module failed. #0");
|
||||
|
||||
if (g_module_symbol (m, "__unlikely_\nexistent__", &proc))
|
||||
return FAILED ("non-existent symbol lookup failed. #1");
|
||||
|
||||
if (proc)
|
||||
return FAILED ("non-existent symbol lookup failed. #2");
|
||||
|
||||
if (!g_module_symbol (m, EXTERNAL_SYMBOL, &proc))
|
||||
return FAILED ("external lookup failed. #3");
|
||||
|
||||
if (!proc)
|
||||
return FAILED ("external lookup failed. #4");
|
||||
|
||||
if (!g_module_symbol (m, "dummy_test_export", &proc))
|
||||
return FAILED ("in-proc lookup failed. #5");
|
||||
|
||||
if (!proc)
|
||||
return FAILED ("in-proc lookup failed. #6");
|
||||
|
||||
if (!g_module_close (m))
|
||||
return FAILED ("close failed. #7");
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
static Test module_tests [] = {
|
||||
{"g_module_symbol_null", test_module_symbol_null},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
DEFINE_TEST_GROUP_INIT(module_tests_init, module_tests)
|
||||
|
||||
|
||||
@@ -1,87 +1,3 @@
|
||||
2008-05-14 Marek Safar <[email protected]>
|
||||
|
||||
* Makefile: Enabled more tests.
|
||||
|
||||
2008-02-18 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile (net_2_0_centum_tests): Add System.Xml.Linq here.
|
||||
|
||||
2008-02-17 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile (_boot_): Orchestrate the net_2_1 bootstrap.
|
||||
(net_2_1_bootstrap_SUBDIRS, net_2_1_raw_SUBDIRS): New.
|
||||
|
||||
2008-02-06 Zoltan Varga <[email protected]>
|
||||
|
||||
* Makefile (dir-check): Hopefully fix make dist.
|
||||
|
||||
2008-02-05 Zoltan Varga <[email protected]>
|
||||
|
||||
* Makefile: Abort with an error message if make is typed directly in this
|
||||
directory, instead from the 'mono' directory.
|
||||
|
||||
2007-12-06 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* Makefile: currently Sys.Web.Extensions is not ready for
|
||||
centum_tests.
|
||||
|
||||
2007-12-04 Marek Safar <[email protected]>
|
||||
|
||||
* Makefile: Added more tests.
|
||||
|
||||
2007-12-03 Marek Safar <[email protected]>
|
||||
|
||||
* Makefile: Added 3.5 profile, it probably not used here.
|
||||
|
||||
2007-11-28 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile (_boot_): Incorporate 'net_2_1' into the bootstrap
|
||||
process -- it depends on 'net_2_0' profile being built.
|
||||
|
||||
2007-07-27 Marek Safar <[email protected]>
|
||||
|
||||
* Makefile: Removed gmcs and smcs, removed DIST_ONLY_SUBDIRS.
|
||||
|
||||
2007-07-27 Jb Evain <[email protected]>
|
||||
|
||||
* Makefile: integrate the tuner in the build.
|
||||
|
||||
2007-07-26 Jb Evain <[email protected]>
|
||||
|
||||
* smcs: add a project of its own for the 2.1 compiler.
|
||||
|
||||
2007-07-11 Jb Evain <[email protected]>
|
||||
|
||||
* Makefile: work on the 2.1 profile.
|
||||
|
||||
2007-05-11 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile (net_2_0_bootstrap_SUBDIRS): Add 'mcs'.
|
||||
|
||||
2007-04-18 Marek Habersack <[email protected]>
|
||||
|
||||
* Makefile (SUBDIRS): removed tools/culevel, it is now built in
|
||||
the 1.1 bootstrap phase.
|
||||
|
||||
2007-04-17 Marek Habersack <[email protected]>
|
||||
|
||||
* Makefile (thisdir): added tools/culevel to the list of
|
||||
subdirectories - it must be compiled before compiling the classes
|
||||
since System.Web depends on it.
|
||||
|
||||
2007-04-06 Wade Berrier <[email protected]>
|
||||
|
||||
* Makefile: use bzip2 instead of gzip for 'make dist'
|
||||
(even though it's not used here anymore)
|
||||
|
||||
2006-08-18 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile (net_2_0_bootstrap_SUBDIRS): Add 'tools'.
|
||||
|
||||
2006-04-11 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile (SUBDIRS): Remove tools/resgen.
|
||||
|
||||
2005-11-21 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile (net_2_0_bootstrap_SUBDIRS): Add ilasm.
|
||||
|
||||
@@ -25,16 +25,12 @@
|
||||
please use the attribute [MonoTODO]. This attribute can be used
|
||||
to programatically generate our status web pages:
|
||||
|
||||
[MonoTODO("My Function is not available on Mono")]
|
||||
[MonoTODO]
|
||||
int MyFunction ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
Ideally, write a human description of the reason why there is
|
||||
a MonoTODO, this will be useful in the future for our
|
||||
automated tools that can assist in developers porting their code.
|
||||
|
||||
* Supporting .NET 1.2, .NET 1.1 and .NET 1.0 builds
|
||||
|
||||
The defines NET_1_1 and NET_2_0 are used to include
|
||||
@@ -408,11 +404,6 @@
|
||||
|
||||
From that point on a list of changes in a file-by-file basis,
|
||||
describing what changes were done.
|
||||
|
||||
This information must be cut and pasted into your commit
|
||||
message, so the information ends up in two places: in the
|
||||
subversion repository metadata and also on the source code
|
||||
distirbution (which does not have the Subversion metadata).
|
||||
|
||||
* Warnings
|
||||
|
||||
@@ -473,44 +464,4 @@ class X : Y {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
* Conditional compilation
|
||||
|
||||
Ideally we would not need conditional compilation, and the use
|
||||
of #ifdef is strongly discouraged. But due to our support for
|
||||
old C# 1.0 compilers we have to use it in a few places.
|
||||
|
||||
Try to avoid negative tests that have an else clause, for
|
||||
example:
|
||||
|
||||
#if !NET_2_0
|
||||
CODE_FOR_1_0
|
||||
#else
|
||||
CODE_FOR_2_0
|
||||
#endif
|
||||
|
||||
Instead use:
|
||||
|
||||
#if NET_2_0
|
||||
CODE_FOR_2_0
|
||||
#else
|
||||
CODE_FOR_1_0
|
||||
#endif
|
||||
|
||||
When a major feature differs across compilation targets, try
|
||||
to factor out the code into a separate class, a helper class
|
||||
or a separate file, and include that in your profile while
|
||||
surrounding that helper file/class with the ifdefs to reduce
|
||||
the amount of ifdefs in the code.
|
||||
|
||||
For instance, this is used for some parts of Grasshopper where
|
||||
the code is ifdefed out, when large parts of a file would have
|
||||
been ifdefed out, we moved the code into a MyOtherFile.jvm.cs
|
||||
|
||||
For 2.0 classes, this is even simpler as code can be trivially
|
||||
factored out into
|
||||
|
||||
MyHelperClass.cli.cs
|
||||
MyHelperClass.jvm.cs
|
||||
|
||||
By using partial classes.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
The Mono code under the mcs/ directory is licensed under various
|
||||
different licenses:
|
||||
The Mono code is licensed under various different licenses.
|
||||
|
||||
GNU GPL: details avaliable in the file LICENSE.GPL
|
||||
GNU LGPL: details available in the file LICENSE.LGPL
|
||||
@@ -21,14 +20,14 @@ different licenses:
|
||||
applications with them).
|
||||
|
||||
Third party libraries include: ByteFX.Data,
|
||||
ICSharpCode.SharpZipLib, Npgsql, MicrosoftAjaxLibrary.
|
||||
ICSharpCode.SharpZipLib, Npgsql.
|
||||
|
||||
The Microsoft.JScript assembly is covered by the
|
||||
MIT X11 and the Mozilla MPL license as it contains
|
||||
ported pieces of code from Rhino, the Mozilla JavaScript
|
||||
implementations
|
||||
|
||||
* Mono C# compiler: Dual licensed MIT X11 and GNU GPL.
|
||||
* Mono C# compiler: GNU GPL
|
||||
|
||||
* Mono Basic compiler: GNU GPL.
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
// Copyright 2006 James Newton-King
|
||||
// http://www.newtonsoft.com
|
||||
//
|
||||
// This work is licensed under the Creative Commons Attribution 2.5 License
|
||||
// http://creativecommons.org/licenses/by/2.5/
|
||||
//
|
||||
// You are free:
|
||||
// * to copy, distribute, display, and perform the work
|
||||
// * to make derivative works
|
||||
// * to make commercial use of the work
|
||||
//
|
||||
// Under the following conditions:
|
||||
// * For any reuse or distribution, you must make clear to others the license terms of this work.
|
||||
// * Any of these conditions can be waived if you get permission from the copyright holder.
|
||||
|
||||
From: james.newtonking@gmail.com [mailto:james.newtonking@gmail.com] On Behalf Of James Newton-King
|
||||
Sent: Tuesday, June 05, 2007 6:36 AM
|
||||
To: Konstantin Triger
|
||||
Subject: Re: Support request by Konstantin Triger for Json.NET
|
||||
|
||||
Hey Kosta
|
||||
|
||||
I think it would be awesome to use Json.NET in Mono for System.Web.Extensions.
|
||||
|
||||
The CC license has the following clause: Any of the above conditions can be waived if you get permission from the copyright holder.
|
||||
|
||||
I can waive that statement for you and Mono. Would that be acceptable?
|
||||
|
||||
|
||||
Regards,
|
||||
James
|
||||
@@ -1,27 +0,0 @@
|
||||
Microsoft Permissive License (Ms-PL)
|
||||
|
||||
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
|
||||
|
||||
1. Definitions
|
||||
|
||||
The terms “reproduce,” “reproduction,” “derivative works,” and “distribution” have the same meaning here as under U.S. copyright law.
|
||||
A “contribution” is the original software, or any additions or changes to the software.
|
||||
A “contributor” is any person that distributes its contribution under this license.
|
||||
“Licensed patents” are a contributor’s patent claims that read directly on its contribution.
|
||||
|
||||
2. Grant of Rights
|
||||
|
||||
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
||||
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
||||
|
||||
3. Conditions and Limitations
|
||||
|
||||
(A) No Trademark License- This license does not grant you rights to use any contributors’ name, logo, or trademarks.
|
||||
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
|
||||
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
|
||||
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
|
||||
(E) The software is licensed “as-is.” You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
|
||||
(F) If you distribute the software or derivative works with programs you develop, you agree to indemnify, defend, and hold harmless all contributors from any claims, including attorneys’ fees, related to the distribution or use of your programs. For clarity, you have no such obligations to a contributor for any claims based solely on the unmodified contributions of that contributor.
|
||||
(G) If you make any additions or changes to the original software, you may only distribute them under a new namespace. In addition, you will clearly identify your changes or additions as your own.
|
||||
|
||||
|
||||
@@ -1,61 +1,37 @@
|
||||
thisdir := .
|
||||
|
||||
SUBDIRS := build jay mcs class nunit20 ilasm tools tests errors docs
|
||||
SUBDIRS := build jay mcs tools/resgen class mbas nunit20 ilasm tools tests errors docs
|
||||
DIST_ONLY_SUBDIRS := gmcs
|
||||
|
||||
basic_SUBDIRS := build jay mcs class
|
||||
net_1_1_bootstrap_SUBDIRS := build jay mcs class ilasm tools
|
||||
net_2_0_bootstrap_SUBDIRS := build jay mcs class ilasm tools
|
||||
net_2_0_SUBDIRS := build jay mcs class nunit20 ilasm tools tests errors
|
||||
net_2_1_bootstrap_SUBDIRS := build mcs class
|
||||
net_2_1_raw_SUBDIRS := build mcs class tools
|
||||
net_2_1_SUBDIRS := tools tests errors
|
||||
net_3_5_SUBDIRS := build class
|
||||
net_2_0_bootstrap_SUBDIRS := build class ilasm
|
||||
net_2_0_SUBDIRS := build jay gmcs class nunit20 ilasm tests errors tools
|
||||
|
||||
# List of test subdirs that should pass 100%
|
||||
centum_tests := \
|
||||
class/corlib \
|
||||
class/System \
|
||||
class/System.XML \
|
||||
class/Commons.Xml.Relaxng \
|
||||
class/Cscompmgd \
|
||||
class/Microsoft.JScript \
|
||||
class/Mono.Posix \
|
||||
class/Mono.Security \
|
||||
class/System.Design \
|
||||
class/System.DirectoryServices \
|
||||
class/System.Drawing \
|
||||
class/System.Messaging \
|
||||
class/System.Runtime.Remoting \
|
||||
class/System.Runtime.Serialization.Formatters.Soap \
|
||||
class/System.Security \
|
||||
class/System.ServiceProcess \
|
||||
class/System.Web \
|
||||
class/System.Web.Services \
|
||||
tests \
|
||||
class/corlib \
|
||||
class/System \
|
||||
class/Commons.Xml.Relaxng \
|
||||
class/Cscompmgd \
|
||||
class/Microsoft.JScript \
|
||||
class/Mono.Posix \
|
||||
class/Mono.Security \
|
||||
class/System.Messaging \
|
||||
class/System.Runtime.Remoting \
|
||||
class/System.Runtime.Serialization.Formatters.Soap \
|
||||
class/System.Security \
|
||||
class/System.ServiceProcess \
|
||||
class/System.Web.Services \
|
||||
tests \
|
||||
errors
|
||||
|
||||
default_centum_tests := \
|
||||
default_centum_tests := \
|
||||
$(centum_tests) \
|
||||
class/System.XML \
|
||||
class/System.Data
|
||||
|
||||
net_2_0_centum_tests := \
|
||||
$(centum_tests) \
|
||||
class/System.Core \
|
||||
class/System.Configuration \
|
||||
class/System.Data.DataSetExtensions \
|
||||
class/System.Xml.Linq \
|
||||
class/System.Transactions \
|
||||
class/Microsoft.Build.Framework \
|
||||
class/Microsoft.Build.Utilities \
|
||||
class/Microsoft.Build.Engine \
|
||||
class/Mono.C5
|
||||
|
||||
# class/System.Web.Extensions
|
||||
# class/Microsoft.Build.Tasks
|
||||
|
||||
# note that System.Xml.Linq is here to prevent this from being empty
|
||||
net_3_5_centum_tests := \
|
||||
class/System.Xml.Linq
|
||||
net_2_0_centum_tests := $(centum_tests) class/Mono.C5
|
||||
|
||||
ifdef ONLY_CENTUM_TESTS
|
||||
TEST_SUBDIRS := $($(PROFILE)_centum_tests)
|
||||
@@ -67,18 +43,15 @@ endif
|
||||
|
||||
include build/rules.make
|
||||
|
||||
all-recursive $(STD_TARGETS:=-recursive): dir-check platform-check profile-check
|
||||
all-recursive $(STD_TARGETS:=-recursive): platform-check profile-check
|
||||
|
||||
.PHONY: all-local $(STD_TARGETS:=-local)
|
||||
all-local $(STD_TARGETS:=-local):
|
||||
@:
|
||||
|
||||
dir-check:
|
||||
@if [ "$(NO_DIR_CHECK)" = "" -a "$(PROFILE)" != "basic" ]; then echo "Running make from the mcs directory is not supported. Run make from the parent directory (if using a tarball), or from the directory where the runtime is checked out (if using an SVN checkout)."; exit 1; fi
|
||||
|
||||
# fun specialty targets
|
||||
|
||||
PROFILES = default net_2_0 net_3_5
|
||||
PROFILES = default net_2_0
|
||||
|
||||
.PHONY: all-profiles $(STD_TARGETS:=-profiles)
|
||||
all-profiles $(STD_TARGETS:=-profiles): %-profiles: profiles-do--%
|
||||
@@ -97,10 +70,6 @@ profiles-do--run-test:
|
||||
|
||||
# Orchestrate the bootstrap here.
|
||||
_boot_ = all clean install
|
||||
$(_boot_:%=profile-do--net_3_5--%): profile-do--net_3_5--%: profile-do--net_2_0--%
|
||||
$(_boot_:%=profile-do--net_2_1--%): profile-do--net_2_1--%: profile-do--net_2_1_raw--%
|
||||
$(_boot_:%=profile-do--net_2_1_raw--%): profile-do--net_2_1_raw--%: profile-do--net_2_1_bootstrap--%
|
||||
$(_boot_:%=profile-do--net_2_1_bootstrap--%): profile-do--net_2_1_bootstrap--%: profile-do--net_2_0--%
|
||||
$(_boot_:%=profile-do--net_2_0--%): profile-do--net_2_0--%: profile-do--net_2_0_bootstrap--%
|
||||
$(_boot_:%=profile-do--net_2_0_bootstrap--%): profile-do--net_2_0_bootstrap--%: profile-do--default--%
|
||||
$(_boot_:%=profile-do--default--%): profile-do--default--%: profile-do--net_1_1_bootstrap--%
|
||||
@@ -127,7 +96,6 @@ DISTFILES = \
|
||||
LICENSE \
|
||||
LICENSE.GPL \
|
||||
LICENSE.LGPL \
|
||||
LICENSE.MPL \
|
||||
Makefile \
|
||||
mkinstalldirs \
|
||||
MIT.X11 \
|
||||
@@ -145,7 +113,7 @@ dist-pre:
|
||||
|
||||
dist-tarball: dist-pre
|
||||
$(MAKE) distdir='$(package)' dist-recursive
|
||||
tar cvjf $(package).tar.bz2 $(package)
|
||||
tar cvzf $(package).tar.gz $(package)
|
||||
|
||||
dist: dist-tarball
|
||||
rm -rf $(package)
|
||||
@@ -166,9 +134,9 @@ distcheck: dist-tarball
|
||||
$(MAKE) prefix=$(prefix) && $(MAKE) test && $(MAKE) install DESTDIR="$$destdir" && \
|
||||
$(MAKE) clean && $(MAKE) dist || exit 1) || exit 1 ; \
|
||||
mv Distcheck-MCS $(package) ; \
|
||||
tar tjf $(package)/$(package).tar.bz2 |sed -e 's,/$$,,' |sort >distdist.list ; \
|
||||
rm $(package)/$(package).tar.bz2 ; \
|
||||
tar tjf $(package).tar.bz2 |sed -e 's,/$$,,' |sort >before.list ; \
|
||||
tar tzf $(package)/$(package).tar.gz |sed -e 's,/$$,,' |sort >distdist.list ; \
|
||||
rm $(package)/$(package).tar.gz ; \
|
||||
tar tzf $(package).tar.gz |sed -e 's,/$$,,' |sort >before.list ; \
|
||||
find $(package) |egrep -v '(makefrag|response)' |sed -e 's,/$$,,' |sort >after.list ; \
|
||||
cmp before.list after.list || exit 1 ; \
|
||||
cmp before.list distdist.list || exit 1 ; \
|
||||
@@ -180,7 +148,7 @@ monocharge:
|
||||
mkdir "$$chargedir" ; \
|
||||
DESTDIR=`cd "$$chargedir" && pwd` ; \
|
||||
$(MAKE) install DESTDIR="$$DESTDIR" || exit 1 ; \
|
||||
tar cvjf "$$chargedir".tar.bz2 "$$chargedir" ; \
|
||||
tar cvzf "$$chargedir".tgz "$$chargedir" ; \
|
||||
rm -rf "$$chargedir"
|
||||
|
||||
# A bare-bones monocharge.
|
||||
@@ -194,5 +162,5 @@ monocharge-lite:
|
||||
$(MAKE) -C class/System install DESTDIR="$$DESTDIR" || exit 1; \
|
||||
$(MAKE) -C class/System.XML install DESTDIR="$$DESTDIR" || exit 1; \
|
||||
$(MAKE) -C class/Mono.CSharp.Debugger install DESTDIR="$$DESTDIR" || exit 1; \
|
||||
tar cvjf "$$chargedir".tar.bz2 "$$chargedir" ; \
|
||||
tar cvzf "$$chargedir".tgz "$$chargedir" ; \
|
||||
rm -rf "$$chargedir"
|
||||
@@ -12,6 +12,9 @@ package module which drives the compilation of this directory.
|
||||
* Layout
|
||||
========
|
||||
|
||||
bmcs/
|
||||
New experimental Basic compiler.
|
||||
|
||||
build/
|
||||
Rules, configuration and makefile components to build
|
||||
this module.
|
||||
@@ -65,19 +68,6 @@ And to install:
|
||||
|
||||
make PROFILE=net_2_0 install
|
||||
|
||||
* Running Unit tests
|
||||
====================
|
||||
|
||||
You can run unit tests in individual components by running the command
|
||||
"make run-test". If you want to run tests for a different profile (say
|
||||
'net_2_0')
|
||||
|
||||
make run-test PROFILE=net_2_0
|
||||
|
||||
If you want to only run the tests in a single fixture (say
|
||||
'MonoTests.System.TypeTest'), you can use
|
||||
|
||||
make run-test TEST_HARNESS_FLAGS=/fixture:MonoTests.System.TypeTest
|
||||
|
||||
* Acknowledgements
|
||||
==================
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyVersion(Consts.MonoVersion)]
|
||||
[assembly: AssemblyTitle ("Mono VB.NET Compiler")]
|
||||
[assembly: AssemblyDescription ("Mono VB.NET Compiler with Generics")]
|
||||
[assembly: AssemblyCopyright ("2001, 2002, 2003 Ximian, Inc.")]
|
||||
[assembly: AssemblyCompany ("Ximian, Inc.")]
|
||||
@@ -0,0 +1,406 @@
|
||||
//
|
||||
// CryptoConvert.cs - Crypto Convertion Routines
|
||||
//
|
||||
// Author:
|
||||
// Sebastien Pouliot <[email protected]>
|
||||
//
|
||||
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
|
||||
// (C) 2004 Novell (http://www.novell.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.Cryptography {
|
||||
|
||||
#if INSIDE_CORLIB
|
||||
internal
|
||||
#else
|
||||
public
|
||||
#endif
|
||||
sealed class CryptoConvert {
|
||||
|
||||
private CryptoConvert ()
|
||||
{
|
||||
}
|
||||
|
||||
static private int ToInt32LE (byte [] bytes, int offset)
|
||||
{
|
||||
return (bytes [offset+3] << 24) | (bytes [offset+2] << 16) | (bytes [offset+1] << 8) | bytes [offset];
|
||||
}
|
||||
|
||||
static private uint ToUInt32LE (byte [] bytes, int offset)
|
||||
{
|
||||
return (uint)((bytes [offset+3] << 24) | (bytes [offset+2] << 16) | (bytes [offset+1] << 8) | bytes [offset]);
|
||||
}
|
||||
|
||||
static private byte [] GetBytesLE (int val)
|
||||
{
|
||||
return new byte [] {
|
||||
(byte) (val & 0xff),
|
||||
(byte) ((val >> 8) & 0xff),
|
||||
(byte) ((val >> 16) & 0xff),
|
||||
(byte) ((val >> 24) & 0xff)
|
||||
};
|
||||
}
|
||||
|
||||
static private byte[] Trim (byte[] array)
|
||||
{
|
||||
for (int i=0; i < array.Length; i++) {
|
||||
if (array [i] != 0x00) {
|
||||
byte[] result = new byte [array.Length - i];
|
||||
Buffer.BlockCopy (array, i, result, 0, result.Length);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// convert the key from PRIVATEKEYBLOB to RSA
|
||||
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/security/Security/private_key_blobs.asp
|
||||
// e.g. SNK files, PVK files
|
||||
static public RSA FromCapiPrivateKeyBlob (byte[] blob)
|
||||
{
|
||||
return FromCapiPrivateKeyBlob (blob, 0);
|
||||
}
|
||||
|
||||
static public RSA FromCapiPrivateKeyBlob (byte[] blob, int offset)
|
||||
{
|
||||
if (blob == null)
|
||||
throw new ArgumentNullException ("blob");
|
||||
if (offset >= blob.Length)
|
||||
throw new ArgumentException ("blob is too small.");
|
||||
|
||||
try {
|
||||
if ((blob [offset] != 0x07) || // PRIVATEKEYBLOB (0x07)
|
||||
(blob [offset+1] != 0x02) || // Version (0x02)
|
||||
(blob [offset+2] != 0x00) || // Reserved (word)
|
||||
(blob [offset+3] != 0x00) ||
|
||||
(ToUInt32LE (blob, offset+8) != 0x32415352)) // DWORD magic = RSA2
|
||||
throw new CryptographicException ("Invalid blob header");
|
||||
|
||||
// ALGID (CALG_RSA_SIGN, CALG_RSA_KEYX, ...)
|
||||
// int algId = ToInt32LE (blob, offset+4);
|
||||
|
||||
// DWORD bitlen
|
||||
int bitLen = ToInt32LE (blob, offset+12);
|
||||
|
||||
// DWORD public exponent
|
||||
RSAParameters rsap = new RSAParameters ();
|
||||
byte[] exp = new byte [4];
|
||||
Buffer.BlockCopy (blob, offset+16, exp, 0, 4);
|
||||
Array.Reverse (exp);
|
||||
rsap.Exponent = Trim (exp);
|
||||
|
||||
int pos = offset+20;
|
||||
// BYTE modulus[rsapubkey.bitlen/8];
|
||||
int byteLen = (bitLen >> 3);
|
||||
rsap.Modulus = new byte [byteLen];
|
||||
Buffer.BlockCopy (blob, pos, rsap.Modulus, 0, byteLen);
|
||||
Array.Reverse (rsap.Modulus);
|
||||
pos += byteLen;
|
||||
|
||||
// BYTE prime1[rsapubkey.bitlen/16];
|
||||
int byteHalfLen = (byteLen >> 1);
|
||||
rsap.P = new byte [byteHalfLen];
|
||||
Buffer.BlockCopy (blob, pos, rsap.P, 0, byteHalfLen);
|
||||
Array.Reverse (rsap.P);
|
||||
pos += byteHalfLen;
|
||||
|
||||
// BYTE prime2[rsapubkey.bitlen/16];
|
||||
rsap.Q = new byte [byteHalfLen];
|
||||
Buffer.BlockCopy (blob, pos, rsap.Q, 0, byteHalfLen);
|
||||
Array.Reverse (rsap.Q);
|
||||
pos += byteHalfLen;
|
||||
|
||||
// BYTE exponent1[rsapubkey.bitlen/16];
|
||||
rsap.DP = new byte [byteHalfLen];
|
||||
Buffer.BlockCopy (blob, pos, rsap.DP, 0, byteHalfLen);
|
||||
Array.Reverse (rsap.DP);
|
||||
pos += byteHalfLen;
|
||||
|
||||
// BYTE exponent2[rsapubkey.bitlen/16];
|
||||
rsap.DQ = new byte [byteHalfLen];
|
||||
Buffer.BlockCopy (blob, pos, rsap.DQ, 0, byteHalfLen);
|
||||
Array.Reverse (rsap.DQ);
|
||||
pos += byteHalfLen;
|
||||
|
||||
// BYTE coefficient[rsapubkey.bitlen/16];
|
||||
rsap.InverseQ = new byte [byteHalfLen];
|
||||
Buffer.BlockCopy (blob, pos, rsap.InverseQ, 0, byteHalfLen);
|
||||
Array.Reverse (rsap.InverseQ);
|
||||
pos += byteHalfLen;
|
||||
|
||||
// ok, this is hackish but CryptoAPI support it so...
|
||||
// note: only works because CRT is used by default
|
||||
// http://bugzilla.ximian.com/show_bug.cgi?id=57941
|
||||
rsap.D = new byte [byteLen]; // must be allocated
|
||||
if (pos + byteLen + offset <= blob.Length) {
|
||||
// BYTE privateExponent[rsapubkey.bitlen/8];
|
||||
Buffer.BlockCopy (blob, pos, rsap.D, 0, byteLen);
|
||||
Array.Reverse (rsap.D);
|
||||
}
|
||||
|
||||
RSA rsa = (RSA)RSA.Create ();
|
||||
rsa.ImportParameters (rsap);
|
||||
return rsa;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new CryptographicException ("Invalid blob.", e);
|
||||
}
|
||||
}
|
||||
|
||||
static public byte[] ToCapiPrivateKeyBlob (RSA rsa)
|
||||
{
|
||||
RSAParameters p = rsa.ExportParameters (true);
|
||||
int keyLength = p.Modulus.Length; // in bytes
|
||||
byte[] blob = new byte [20 + (keyLength << 2) + (keyLength >> 1)];
|
||||
|
||||
blob [0] = 0x07; // Type - PRIVATEKEYBLOB (0x07)
|
||||
blob [1] = 0x02; // Version - Always CUR_BLOB_VERSION (0x02)
|
||||
// [2], [3] // RESERVED - Always 0
|
||||
blob [5] = 0x24; // ALGID - Always 00 24 00 00 (for CALG_RSA_SIGN)
|
||||
blob [8] = 0x52; // Magic - RSA2 (ASCII in hex)
|
||||
blob [9] = 0x53;
|
||||
blob [10] = 0x41;
|
||||
blob [11] = 0x32;
|
||||
|
||||
byte[] bitlen = GetBytesLE (keyLength << 3);
|
||||
blob [12] = bitlen [0]; // bitlen
|
||||
blob [13] = bitlen [1];
|
||||
blob [14] = bitlen [2];
|
||||
blob [15] = bitlen [3];
|
||||
|
||||
// public exponent (DWORD)
|
||||
int pos = 16;
|
||||
int n = p.Exponent.Length;
|
||||
while (n > 0)
|
||||
blob [pos++] = p.Exponent [--n];
|
||||
// modulus
|
||||
pos = 20;
|
||||
byte[] part = p.Modulus;
|
||||
int len = part.Length;
|
||||
Array.Reverse (part, 0, len);
|
||||
Buffer.BlockCopy (part, 0, blob, pos, len);
|
||||
pos += len;
|
||||
// private key
|
||||
part = p.P;
|
||||
len = part.Length;
|
||||
Array.Reverse (part, 0, len);
|
||||
Buffer.BlockCopy (part, 0, blob, pos, len);
|
||||
pos += len;
|
||||
|
||||
part = p.Q;
|
||||
len = part.Length;
|
||||
Array.Reverse (part, 0, len);
|
||||
Buffer.BlockCopy (part, 0, blob, pos, len);
|
||||
pos += len;
|
||||
|
||||
part = p.DP;
|
||||
len = part.Length;
|
||||
Array.Reverse (part, 0, len);
|
||||
Buffer.BlockCopy (part, 0, blob, pos, len);
|
||||
pos += len;
|
||||
|
||||
part = p.DQ;
|
||||
len = part.Length;
|
||||
Array.Reverse (part, 0, len);
|
||||
Buffer.BlockCopy (part, 0, blob, pos, len);
|
||||
pos += len;
|
||||
|
||||
part = p.InverseQ;
|
||||
len = part.Length;
|
||||
Array.Reverse (part, 0, len);
|
||||
Buffer.BlockCopy (part, 0, blob, pos, len);
|
||||
pos += len;
|
||||
|
||||
part = p.D;
|
||||
len = part.Length;
|
||||
Array.Reverse (part, 0, len);
|
||||
Buffer.BlockCopy (part, 0, blob, pos, len);
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
static public RSA FromCapiPublicKeyBlob (byte[] blob)
|
||||
{
|
||||
return FromCapiPublicKeyBlob (blob, 0);
|
||||
}
|
||||
|
||||
static public RSA FromCapiPublicKeyBlob (byte[] blob, int offset)
|
||||
{
|
||||
if (blob == null)
|
||||
throw new ArgumentNullException ("blob");
|
||||
if (offset >= blob.Length)
|
||||
throw new ArgumentException ("blob is too small.");
|
||||
|
||||
try {
|
||||
if ((blob [offset] != 0x06) || // PUBLICKEYBLOB (0x06)
|
||||
(blob [offset+1] != 0x02) || // Version (0x02)
|
||||
(blob [offset+2] != 0x00) || // Reserved (word)
|
||||
(blob [offset+3] != 0x00) ||
|
||||
(ToUInt32LE (blob, offset+8) != 0x31415352)) // DWORD magic = RSA1
|
||||
throw new CryptographicException ("Invalid blob header");
|
||||
|
||||
// ALGID (CALG_RSA_SIGN, CALG_RSA_KEYX, ...)
|
||||
// int algId = ToInt32LE (blob, offset+4);
|
||||
|
||||
// DWORD bitlen
|
||||
int bitLen = ToInt32LE (blob, offset+12);
|
||||
|
||||
// DWORD public exponent
|
||||
RSAParameters rsap = new RSAParameters ();
|
||||
rsap.Exponent = new byte [3];
|
||||
rsap.Exponent [0] = blob [offset+18];
|
||||
rsap.Exponent [1] = blob [offset+17];
|
||||
rsap.Exponent [2] = blob [offset+16];
|
||||
|
||||
int pos = offset+20;
|
||||
// BYTE modulus[rsapubkey.bitlen/8];
|
||||
int byteLen = (bitLen >> 3);
|
||||
rsap.Modulus = new byte [byteLen];
|
||||
Buffer.BlockCopy (blob, pos, rsap.Modulus, 0, byteLen);
|
||||
Array.Reverse (rsap.Modulus);
|
||||
|
||||
RSA rsa = (RSA)RSA.Create ();
|
||||
rsa.ImportParameters (rsap);
|
||||
return rsa;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new CryptographicException ("Invalid blob.", e);
|
||||
}
|
||||
}
|
||||
|
||||
static public byte[] ToCapiPublicKeyBlob (RSA rsa)
|
||||
{
|
||||
RSAParameters p = rsa.ExportParameters (false);
|
||||
int keyLength = p.Modulus.Length; // in bytes
|
||||
byte[] blob = new byte [20 + keyLength];
|
||||
|
||||
blob [0] = 0x06; // Type - PUBLICKEYBLOB (0x06)
|
||||
blob [1] = 0x02; // Version - Always CUR_BLOB_VERSION (0x02)
|
||||
// [2], [3] // RESERVED - Always 0
|
||||
blob [5] = 0x24; // ALGID - Always 00 24 00 00 (for CALG_RSA_SIGN)
|
||||
blob [8] = 0x52; // Magic - RSA1 (ASCII in hex)
|
||||
blob [9] = 0x53;
|
||||
blob [10] = 0x41;
|
||||
blob [11] = 0x31;
|
||||
|
||||
byte[] bitlen = GetBytesLE (keyLength << 3);
|
||||
blob [12] = bitlen [0]; // bitlen
|
||||
blob [13] = bitlen [1];
|
||||
blob [14] = bitlen [2];
|
||||
blob [15] = bitlen [3];
|
||||
|
||||
// public exponent (DWORD)
|
||||
int pos = 16;
|
||||
int n = p.Exponent.Length;
|
||||
while (n > 0)
|
||||
blob [pos++] = p.Exponent [--n];
|
||||
// modulus
|
||||
pos = 20;
|
||||
byte[] part = p.Modulus;
|
||||
int len = part.Length;
|
||||
Array.Reverse (part, 0, len);
|
||||
Buffer.BlockCopy (part, 0, blob, pos, len);
|
||||
pos += len;
|
||||
return blob;
|
||||
}
|
||||
|
||||
// PRIVATEKEYBLOB
|
||||
// PUBLICKEYBLOB
|
||||
static public RSA FromCapiKeyBlob (byte[] blob)
|
||||
{
|
||||
return FromCapiKeyBlob (blob, 0);
|
||||
}
|
||||
|
||||
static public RSA FromCapiKeyBlob (byte[] blob, int offset)
|
||||
{
|
||||
if (blob == null)
|
||||
throw new ArgumentNullException ("blob");
|
||||
if (offset >= blob.Length)
|
||||
throw new ArgumentException ("blob is too small.");
|
||||
|
||||
switch (blob [offset]) {
|
||||
case 0x00:
|
||||
// this could be a public key inside an header
|
||||
// like "sn -e" would produce
|
||||
if (blob [offset + 12] == 0x06) {
|
||||
return FromCapiPublicKeyBlob (blob, offset + 12);
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
return FromCapiPublicKeyBlob (blob, offset);
|
||||
case 0x07:
|
||||
return FromCapiPrivateKeyBlob (blob, offset);
|
||||
}
|
||||
throw new CryptographicException ("Unknown blob format.");
|
||||
}
|
||||
|
||||
static public byte[] ToCapiKeyBlob (AsymmetricAlgorithm keypair, bool includePrivateKey)
|
||||
{
|
||||
if (keypair == null)
|
||||
throw new ArgumentNullException ("keypair");
|
||||
|
||||
// check between RSA and DSA (and potentially others like DH)
|
||||
if (keypair is RSA)
|
||||
return ToCapiKeyBlob ((RSA)keypair, includePrivateKey);
|
||||
else
|
||||
return null; // TODO
|
||||
}
|
||||
|
||||
static public byte[] ToCapiKeyBlob (RSA rsa, bool includePrivateKey)
|
||||
{
|
||||
if (rsa == null)
|
||||
throw new ArgumentNullException ("rsa");
|
||||
|
||||
rsa.ExportParameters (includePrivateKey);
|
||||
if (includePrivateKey)
|
||||
return ToCapiPrivateKeyBlob (rsa);
|
||||
else
|
||||
return ToCapiPublicKeyBlob (rsa);
|
||||
}
|
||||
|
||||
static public string ToHex (byte[] input)
|
||||
{
|
||||
if (input == null)
|
||||
return null;
|
||||
|
||||
StringBuilder sb = new StringBuilder (input.Length * 2);
|
||||
foreach (byte b in input) {
|
||||
sb.Append (b.ToString ("X2", CultureInfo.InvariantCulture));
|
||||
}
|
||||
return sb.ToString ();
|
||||
}
|
||||
|
||||
static private byte FromHexChar (char c)
|
||||
{
|
||||
if ((c >= 'a') && (c <= 'f'))
|
||||
return (byte) (c - 'a' + 10);
|
||||
if ((c >= 'A') && (c <= 'F'))
|
||||
return (byte) (c - 'A' + 10);
|
||||
if ((c >= '0') && (c <= '9'))
|
||||
return (byte) (c - '0');
|
||||
throw new ArgumentException ("invalid hex char");
|
||||
}
|
||||
|
||||
static public byte[] FromHex (string hex)
|
||||
{
|
||||
if (hex == null)
|
||||
return null;
|
||||
if ((hex.Length & 0x1) == 0x1)
|
||||
throw new ArgumentException ("Length must be a multiple of 2");
|
||||
|
||||
byte[] result = new byte [hex.Length >> 1];
|
||||
int n = 0;
|
||||
int i = 0;
|
||||
while (n < result.Length) {
|
||||
result [n] = (byte) (FromHexChar (hex [i++]) << 4);
|
||||
result [n++] += FromHexChar (hex [i++]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#
|
||||
# This makefile needs work, currently we overwrite the value of `bmcs.exe',
|
||||
# the reason is that we need this to be compiled with gmcs, so it uses the
|
||||
# .NET 2.0 profile.
|
||||
#
|
||||
thisdir := bmcs
|
||||
SUBDIRS :=
|
||||
include ../build/rules.make
|
||||
|
||||
#uncomment to enable some debug stuff
|
||||
#DEBUG_FLAGS=/define:MCS_DEBUG
|
||||
|
||||
BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/net_2_0_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/net_2_0_bootstrap/mcs.exe $(DEBUG_FLAGS)
|
||||
|
||||
BUILT_SOURCES = mb-parser.cs
|
||||
|
||||
EXTRA_DISTFILES = mb-parser.jay
|
||||
|
||||
PROGRAM_COMPILE = $(BOOT_COMPILE)
|
||||
|
||||
CLEAN_FILES = y.output
|
||||
|
||||
PROGRAM = bmcs.exe
|
||||
|
||||
mb-parser.cs: mb-parser.jay $(topdir)/jay/skeleton.cs
|
||||
$(topdir)/jay/jay -ctv < $(topdir)/jay/skeleton.cs $< > jay-tmp.out && mv jay-tmp.out $@
|
||||
|
||||
include ../build/executable.make
|
||||
|
||||
bmcs.exe: mb-parser.cs
|
||||
gmcs -d:NET_1_1 -d:ONLY_1_1 -debug /target:exe /out:bmcs.exe /r:Microsoft.VisualBasic.dll mb-parser.cs @bmcs.exe.sources -nowarn:219 -nowarn:162
|
||||
|
||||
winstall: all
|
||||
cp bmcs.exe $(prefix)/lib/mono/2.0/
|
||||
|
||||
diffus:
|
||||
diff --exclude='.svn' --exclude='*-parser.*' --exclude='*-tokenizer.cs' -ruN ../gmcs ../bmcs
|
||||
@@ -0,0 +1,22 @@
|
||||
* This is BMCS
|
||||
|
||||
Last merge to GMCS: 42056
|
||||
|
||||
BMCS is a new fork of the generics compiler from revision
|
||||
38733 (11th of January 2005).
|
||||
|
||||
This new compiler is based on the changes that Jambunathan did
|
||||
to mcs from November 30th, 2004 to integrate the existing mbas
|
||||
compiler with a more recent mcs.
|
||||
|
||||
We have ported those changes to use `gmcs' so that we get
|
||||
support for generics into our VB compiler eventually.
|
||||
|
||||
Work toward integrating the improvements from mbas will go here.
|
||||
|
||||
* LICENSING
|
||||
|
||||
Notice that the compiler might eventually need to go into the
|
||||
class libraries. We request that contributors grant us permission
|
||||
to relicense the code under the MIT X11 license if we have to.
|
||||
|
||||
@@ -0,0 +1,632 @@
|
||||
//
|
||||
// assign.cs: Assignments.
|
||||
//
|
||||
// Author:
|
||||
// Miguel de Icaza ([email protected])
|
||||
// Martin Baulig ([email protected])
|
||||
//
|
||||
// (C) 2001, 2002, 2003 Ximian, Inc.
|
||||
// (C) 2004 Novell, Inc
|
||||
//
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
|
||||
namespace Mono.CSharp {
|
||||
|
||||
/// <summary>
|
||||
/// This interface is implemented by expressions that can be assigned to.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This interface is implemented by Expressions whose values can not
|
||||
/// store the result on the top of the stack.
|
||||
///
|
||||
/// Expressions implementing this (Properties, Indexers and Arrays) would
|
||||
/// perform an assignment of the Expression "source" into its final
|
||||
/// location.
|
||||
///
|
||||
/// No values on the top of the stack are expected to be left by
|
||||
/// invoking this method.
|
||||
/// </remarks>
|
||||
public interface IAssignMethod {
|
||||
//
|
||||
// This is an extra version of Emit. If leave_copy is `true'
|
||||
// A copy of the expression will be left on the stack at the
|
||||
// end of the code generated for EmitAssign
|
||||
//
|
||||
void Emit (EmitContext ec, bool leave_copy);
|
||||
|
||||
//
|
||||
// This method does the assignment
|
||||
// `source' will be stored into the location specified by `this'
|
||||
// if `leave_copy' is true, a copy of `source' will be left on the stack
|
||||
// if `prepare_for_load' is true, when `source' is emitted, there will
|
||||
// be data on the stack that it can use to compuatate its value. This is
|
||||
// for expressions like a [f ()] ++, where you can't call `f ()' twice.
|
||||
//
|
||||
void EmitAssign (EmitContext ec, Expression source, bool leave_copy, bool prepare_for_load);
|
||||
|
||||
/*
|
||||
For simple assignments, this interface is very simple, EmitAssign is called with source
|
||||
as the source expression and leave_copy and prepare_for_load false.
|
||||
|
||||
For compound assignments it gets complicated.
|
||||
|
||||
EmitAssign will be called as before, however, prepare_for_load will be
|
||||
true. The @source expression will contain an expression
|
||||
which calls Emit. So, the calls look like:
|
||||
|
||||
this.EmitAssign (ec, source, false, true) ->
|
||||
source.Emit (ec); ->
|
||||
[...] ->
|
||||
this.Emit (ec, false); ->
|
||||
end this.Emit (ec, false); ->
|
||||
end [...]
|
||||
end source.Emit (ec);
|
||||
end this.EmitAssign (ec, source, false, true)
|
||||
|
||||
|
||||
When prepare_for_load is true, EmitAssign emits a `token' on the stack that
|
||||
Emit will use for its state.
|
||||
|
||||
Let's take FieldExpr as an example. assume we are emitting f ().y += 1;
|
||||
|
||||
Here is the call tree again. This time, each call is annotated with the IL
|
||||
it produces:
|
||||
|
||||
this.EmitAssign (ec, source, false, true)
|
||||
call f
|
||||
dup
|
||||
|
||||
Binary.Emit ()
|
||||
this.Emit (ec, false);
|
||||
ldfld y
|
||||
end this.Emit (ec, false);
|
||||
|
||||
IntConstant.Emit ()
|
||||
ldc.i4.1
|
||||
end IntConstant.Emit
|
||||
|
||||
add
|
||||
end Binary.Emit ()
|
||||
|
||||
stfld
|
||||
end this.EmitAssign (ec, source, false, true)
|
||||
|
||||
Observe two things:
|
||||
1) EmitAssign left a token on the stack. It was the result of f ().
|
||||
2) This token was used by Emit
|
||||
|
||||
leave_copy (in both EmitAssign and Emit) tells the compiler to leave a copy
|
||||
of the expression at that point in evaluation. This is used for pre/post inc/dec
|
||||
and for a = x += y. Let's do the above example with leave_copy true in EmitAssign
|
||||
|
||||
this.EmitAssign (ec, source, true, true)
|
||||
call f
|
||||
dup
|
||||
|
||||
Binary.Emit ()
|
||||
this.Emit (ec, false);
|
||||
ldfld y
|
||||
end this.Emit (ec, false);
|
||||
|
||||
IntConstant.Emit ()
|
||||
ldc.i4.1
|
||||
end IntConstant.Emit
|
||||
|
||||
add
|
||||
end Binary.Emit ()
|
||||
|
||||
dup
|
||||
stloc temp
|
||||
stfld
|
||||
ldloc temp
|
||||
end this.EmitAssign (ec, source, true, true)
|
||||
|
||||
And with it true in Emit
|
||||
|
||||
this.EmitAssign (ec, source, false, true)
|
||||
call f
|
||||
dup
|
||||
|
||||
Binary.Emit ()
|
||||
this.Emit (ec, true);
|
||||
ldfld y
|
||||
dup
|
||||
stloc temp
|
||||
end this.Emit (ec, true);
|
||||
|
||||
IntConstant.Emit ()
|
||||
ldc.i4.1
|
||||
end IntConstant.Emit
|
||||
|
||||
add
|
||||
end Binary.Emit ()
|
||||
|
||||
stfld
|
||||
ldloc temp
|
||||
end this.EmitAssign (ec, source, false, true)
|
||||
|
||||
Note that these two examples are what happens for ++x and x++, respectively.
|
||||
*/
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An Expression to hold a temporary value.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The LocalTemporary class is used to hold temporary values of a given
|
||||
/// type to "simulate" the expression semantics on property and indexer
|
||||
/// access whose return values are void.
|
||||
///
|
||||
/// The local temporary is used to alter the normal flow of code generation
|
||||
/// basically it creates a local variable, and its emit instruction generates
|
||||
/// code to access this value, return its address or save its value.
|
||||
///
|
||||
/// If `is_address' is true, then the value that we store is the address to the
|
||||
/// real value, and not the value itself.
|
||||
///
|
||||
/// This is needed for a value type, because otherwise you just end up making a
|
||||
/// copy of the value on the stack and modifying it. You really need a pointer
|
||||
/// to the origional value so that you can modify it in that location. This
|
||||
/// Does not happen with a class because a class is a pointer -- so you always
|
||||
/// get the indirection.
|
||||
///
|
||||
/// The `is_address' stuff is really just a hack. We need to come up with a better
|
||||
/// way to handle it.
|
||||
/// </remarks>
|
||||
public class LocalTemporary : Expression, IMemoryLocation {
|
||||
LocalBuilder builder;
|
||||
bool is_address;
|
||||
|
||||
public LocalTemporary (EmitContext ec, Type t) : this (ec, t, false) {}
|
||||
|
||||
public LocalTemporary (EmitContext ec, Type t, bool is_address)
|
||||
{
|
||||
type = t;
|
||||
eclass = ExprClass.Value;
|
||||
loc = Location.Null;
|
||||
builder = ec.GetTemporaryLocal (is_address ? TypeManager.GetReferenceType (t): t);
|
||||
this.is_address = is_address;
|
||||
}
|
||||
|
||||
public LocalTemporary (LocalBuilder b, Type t)
|
||||
{
|
||||
type = t;
|
||||
eclass = ExprClass.Value;
|
||||
loc = Location.Null;
|
||||
builder = b;
|
||||
}
|
||||
|
||||
public void Release (EmitContext ec)
|
||||
{
|
||||
ec.FreeTemporaryLocal (builder, type);
|
||||
builder = null;
|
||||
}
|
||||
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public override void Emit (EmitContext ec)
|
||||
{
|
||||
ILGenerator ig = ec.ig;
|
||||
|
||||
ig.Emit (OpCodes.Ldloc, builder);
|
||||
// we need to copy from the pointer
|
||||
if (is_address)
|
||||
LoadFromPtr (ig, type);
|
||||
}
|
||||
|
||||
// NB: if you have `is_address' on the stack there must
|
||||
// be a managed pointer. Otherwise, it is the type from
|
||||
// the ctor.
|
||||
public void Store (EmitContext ec)
|
||||
{
|
||||
ILGenerator ig = ec.ig;
|
||||
ig.Emit (OpCodes.Stloc, builder);
|
||||
}
|
||||
|
||||
public void AddressOf (EmitContext ec, AddressOp mode)
|
||||
{
|
||||
// if is_address, than this is just the address anyways,
|
||||
// so we just return this.
|
||||
ILGenerator ig = ec.ig;
|
||||
|
||||
if (is_address)
|
||||
ig.Emit (OpCodes.Ldloc, builder);
|
||||
else
|
||||
ig.Emit (OpCodes.Ldloca, builder);
|
||||
}
|
||||
|
||||
public bool PointsToAddress {
|
||||
get {
|
||||
return is_address;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Assign node takes care of assigning the value of source into
|
||||
/// the expression represented by target.
|
||||
/// </summary>
|
||||
public class Assign : ExpressionStatement {
|
||||
protected Expression target, source, real_source;
|
||||
protected LocalTemporary temp = null, real_temp = null;
|
||||
protected Assign embedded = null;
|
||||
protected bool is_embedded = false;
|
||||
protected bool must_free_temp = false;
|
||||
|
||||
public Assign (Expression target, Expression source, Location l)
|
||||
{
|
||||
this.target = target;
|
||||
this.source = this.real_source = source;
|
||||
this.loc = l;
|
||||
}
|
||||
|
||||
protected Assign (Assign embedded, Location l)
|
||||
: this (embedded.target, embedded.source, l)
|
||||
{
|
||||
this.is_embedded = true;
|
||||
}
|
||||
|
||||
protected virtual Assign GetEmbeddedAssign (Location loc)
|
||||
{
|
||||
return new Assign (this, loc);
|
||||
}
|
||||
|
||||
public Expression Target {
|
||||
get {
|
||||
return target;
|
||||
}
|
||||
|
||||
set {
|
||||
target = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Expression Source {
|
||||
get {
|
||||
return source;
|
||||
}
|
||||
|
||||
set {
|
||||
source = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void error70 (EventInfo ei, Location l)
|
||||
{
|
||||
Report.Error (70, l, "The event '" + ei.Name +
|
||||
"' can only appear on the left-side of a += or -= (except when" +
|
||||
" used from within the type '" + ei.DeclaringType + "')");
|
||||
}
|
||||
|
||||
//
|
||||
// Will return either `this' or an instance of `New'.
|
||||
//
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
// Create an embedded assignment if our source is an assignment.
|
||||
if (source is Assign)
|
||||
source = embedded = ((Assign) source).GetEmbeddedAssign (loc);
|
||||
|
||||
real_source = source = source.Resolve (ec);
|
||||
if (source == null)
|
||||
return null;
|
||||
|
||||
//
|
||||
// This is used in an embedded assignment.
|
||||
// As an example, consider the statement "A = X = Y = Z".
|
||||
//
|
||||
if (is_embedded && !(source is Constant)) {
|
||||
// If this is the innermost assignment (the "Y = Z" in our example),
|
||||
// create a new temporary local, otherwise inherit that variable
|
||||
// from our child (the "X = (Y = Z)" inherits the local from the
|
||||
// "Y = Z" assignment).
|
||||
|
||||
if (embedded == null) {
|
||||
if (this is CompoundAssign)
|
||||
real_temp = temp = new LocalTemporary (ec, target.Type);
|
||||
else
|
||||
real_temp = temp = new LocalTemporary (ec, source.Type);
|
||||
} else
|
||||
temp = embedded.temp;
|
||||
|
||||
// Set the source to the new temporary variable.
|
||||
// This means that the following target.ResolveLValue () will tell
|
||||
// the target to read it's source value from that variable.
|
||||
source = temp;
|
||||
}
|
||||
|
||||
// If we have an embedded assignment, use the embedded assignment's temporary
|
||||
// local variable as source.
|
||||
if (embedded != null)
|
||||
source = (embedded.temp != null) ? embedded.temp : embedded.source;
|
||||
|
||||
target = target.ResolveLValue (ec, source);
|
||||
|
||||
if (target == null)
|
||||
return null;
|
||||
|
||||
Type target_type = target.Type;
|
||||
Type source_type = real_source.Type;
|
||||
|
||||
// If we're an embedded assignment, our parent will reuse our source as its
|
||||
// source, it won't read from our target.
|
||||
if (is_embedded)
|
||||
type = source_type;
|
||||
else
|
||||
type = target_type;
|
||||
eclass = ExprClass.Value;
|
||||
|
||||
if (target is EventExpr) {
|
||||
EventInfo ei = ((EventExpr) target).EventInfo;
|
||||
|
||||
Expression ml = MemberLookup (
|
||||
ec, ec.ContainerType, ei.Name,
|
||||
MemberTypes.Event, AllBindingFlags | BindingFlags.DeclaredOnly, loc);
|
||||
|
||||
if (ml == null) {
|
||||
//
|
||||
// If this is the case, then the Event does not belong
|
||||
// to this Type and so, according to the spec
|
||||
// is allowed to only appear on the left hand of
|
||||
// the += and -= operators
|
||||
//
|
||||
// Note that target will not appear as an EventExpr
|
||||
// in the case it is being referenced within the same type container;
|
||||
// it will appear as a FieldExpr in that case.
|
||||
//
|
||||
|
||||
if (!(source is BinaryDelegate)) {
|
||||
error70 (ei, loc);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FieldExpr field_exp = target as FieldExpr;
|
||||
if (field_exp != null && field_exp.DeclaringType.IsValueType && !ec.IsConstructor && !ec.IsFieldInitializer) {
|
||||
field_exp = field_exp.InstanceExpression as FieldExpr;
|
||||
if (field_exp != null && field_exp.FieldInfo.IsInitOnly) {
|
||||
if (field_exp.IsStatic) {
|
||||
Report.Error (1650, loc, "Members of static readonly field '{0}' cannot be assigned to " +
|
||||
"(except in a static constructor or a variable initializer)", TypeManager.GetFullNameSignature (field_exp.FieldInfo));
|
||||
} else {
|
||||
Report.Error (1648, loc, "Members of readonly field '{0}' cannot be assigned to " +
|
||||
"(except in a constructor or a variable initializer)", TypeManager.GetFullNameSignature (field_exp.FieldInfo));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(target is IAssignMethod) && (target.eclass != ExprClass.EventAccess)) {
|
||||
Report.Error (131, loc,
|
||||
"Left hand of an assignment must be a variable, " +
|
||||
"a property or an indexer");
|
||||
return null;
|
||||
}
|
||||
|
||||
if ((source.eclass == ExprClass.Type) && (source is TypeExpr)) {
|
||||
source.Error_UnexpectedKind ("variable or value", loc);
|
||||
return null;
|
||||
} else if ((RootContext.Version == LanguageVersion.ISO_1) &&
|
||||
(source is MethodGroupExpr)){
|
||||
((MethodGroupExpr) source).ReportUsageError ();
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
if (target_type == source_type){
|
||||
if (source is New && target_type.IsValueType &&
|
||||
(target.eclass != ExprClass.IndexerAccess) && (target.eclass != ExprClass.PropertyAccess)){
|
||||
New n = (New) source;
|
||||
|
||||
if (n.SetValueTypeVariable (target))
|
||||
return n;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
//
|
||||
// If this assignemnt/operator was part of a compound binary
|
||||
// operator, then we allow an explicit conversion, as detailed
|
||||
// in the spec.
|
||||
//
|
||||
|
||||
if (this is CompoundAssign){
|
||||
CompoundAssign a = (CompoundAssign) this;
|
||||
|
||||
Binary b = source as Binary;
|
||||
if (b != null){
|
||||
//
|
||||
// 1. if the source is explicitly convertible to the
|
||||
// target_type
|
||||
//
|
||||
|
||||
source = Convert.WideningAndNarrowingConversion (ec, source, target_type, loc);
|
||||
if (source == null){
|
||||
Convert.Error_CannotWideningConversion (loc, source_type, target_type);
|
||||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
// 2. and the original right side is implicitly convertible to
|
||||
// the type of target
|
||||
//
|
||||
if (Convert.WideningStandardConversionExists (ec, a.original_source, target_type))
|
||||
return this;
|
||||
|
||||
//
|
||||
// In the spec 2.4 they added: or if type of the target is int
|
||||
// and the operator is a shift operator...
|
||||
//
|
||||
if (source_type == TypeManager.int32_type &&
|
||||
(b.Oper == Binary.Operator.LeftShift || b.Oper == Binary.Operator.RightShift))
|
||||
return this;
|
||||
|
||||
Convert.Error_CannotWideningConversion (loc, a.original_source.Type, target_type);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
source = Convert.ImplicitVBConversionRequired (ec, source, target_type, loc);
|
||||
if (source == null)
|
||||
return null;
|
||||
|
||||
// If we're an embedded assignment, we need to create a new temporary variable
|
||||
// for the converted value. Our parent will use this new variable as its source.
|
||||
// The same applies when we have an embedded assignment - in this case, we need
|
||||
// to convert our embedded assignment's temporary local variable to the correct
|
||||
// type and store it in a new temporary local.
|
||||
if (is_embedded || embedded != null) {
|
||||
type = target_type;
|
||||
temp = new LocalTemporary (ec, type);
|
||||
must_free_temp = true;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
Expression EmitEmbedded (EmitContext ec)
|
||||
{
|
||||
// Emit an embedded assignment.
|
||||
|
||||
if (real_temp != null) {
|
||||
// If we're the innermost assignment, `real_source' is the right-hand
|
||||
// expression which gets assigned to all the variables left of it.
|
||||
// Emit this expression and store its result in real_temp.
|
||||
real_source.Emit (ec);
|
||||
real_temp.Store (ec);
|
||||
}
|
||||
|
||||
if (embedded != null)
|
||||
embedded.EmitEmbedded (ec);
|
||||
|
||||
// This happens when we've done a type conversion, in this case source will be
|
||||
// the expression which does the type conversion from real_temp.
|
||||
// So emit it and store the result in temp; this is the var which will be read
|
||||
// by our parent.
|
||||
if (temp != real_temp) {
|
||||
source.Emit (ec);
|
||||
temp.Store (ec);
|
||||
}
|
||||
|
||||
Expression temp_source = (temp != null) ? temp : source;
|
||||
((IAssignMethod) target).EmitAssign (ec, temp_source, false, false);
|
||||
return temp_source;
|
||||
}
|
||||
|
||||
void ReleaseEmbedded (EmitContext ec)
|
||||
{
|
||||
if (embedded != null)
|
||||
embedded.ReleaseEmbedded (ec);
|
||||
|
||||
if (real_temp != null)
|
||||
real_temp.Release (ec);
|
||||
|
||||
if (must_free_temp)
|
||||
temp.Release (ec);
|
||||
}
|
||||
|
||||
void Emit (EmitContext ec, bool is_statement)
|
||||
{
|
||||
if (target is EventExpr) {
|
||||
((EventExpr) target).EmitAddOrRemove (ec, source);
|
||||
return;
|
||||
}
|
||||
|
||||
IAssignMethod am = (IAssignMethod) target;
|
||||
|
||||
Expression temp_source;
|
||||
if (embedded != null) {
|
||||
temp_source = embedded.EmitEmbedded (ec);
|
||||
|
||||
if (temp != null) {
|
||||
source.Emit (ec);
|
||||
temp.Store (ec);
|
||||
temp_source = temp;
|
||||
}
|
||||
} else
|
||||
temp_source = source;
|
||||
|
||||
am.EmitAssign (ec, temp_source, !is_statement, this is CompoundAssign);
|
||||
|
||||
if (embedded != null) {
|
||||
if (temp != null)
|
||||
temp.Release (ec);
|
||||
embedded.ReleaseEmbedded (ec);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Emit (EmitContext ec)
|
||||
{
|
||||
Emit (ec, false);
|
||||
}
|
||||
|
||||
public override void EmitStatement (EmitContext ec)
|
||||
{
|
||||
Emit (ec, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// This class is used for compound assignments.
|
||||
//
|
||||
class CompoundAssign : Assign {
|
||||
Binary.Operator op;
|
||||
public Expression original_source;
|
||||
|
||||
public CompoundAssign (Binary.Operator op, Expression target, Expression source, Location l)
|
||||
: base (target, source, l)
|
||||
{
|
||||
original_source = source;
|
||||
this.op = op;
|
||||
}
|
||||
|
||||
protected CompoundAssign (CompoundAssign embedded, Location l)
|
||||
: this (embedded.op, embedded.target, embedded.source, l)
|
||||
{
|
||||
this.is_embedded = true;
|
||||
}
|
||||
|
||||
protected override Assign GetEmbeddedAssign (Location loc)
|
||||
{
|
||||
return new CompoundAssign (this, loc);
|
||||
}
|
||||
|
||||
public Expression ResolveSource (EmitContext ec)
|
||||
{
|
||||
return original_source.Resolve (ec);
|
||||
}
|
||||
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
original_source = original_source.Resolve (ec);
|
||||
if (original_source == null)
|
||||
return null;
|
||||
|
||||
target = target.Resolve (ec);
|
||||
if (target == null)
|
||||
return null;
|
||||
|
||||
//
|
||||
// Only now we can decouple the original source/target
|
||||
// into a tree, to guarantee that we do not have side
|
||||
// effects.
|
||||
//
|
||||
source = new Binary (op, target, original_source, loc);
|
||||
return base.DoResolve (ec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
AssemblyInfo.cs
|
||||
anonymous.cs
|
||||
assign.cs
|
||||
attribute.cs
|
||||
driver.cs
|
||||
mb-tokenizer.cs
|
||||
cfold.cs
|
||||
class.cs
|
||||
codegen.cs
|
||||
const.cs
|
||||
constant.cs
|
||||
convert.cs
|
||||
decl.cs
|
||||
delegate.cs
|
||||
doc.cs
|
||||
enum.cs
|
||||
ecore.cs
|
||||
expression.cs
|
||||
flowanalysis.cs
|
||||
generic.cs
|
||||
iterators.cs
|
||||
literal.cs
|
||||
location.cs
|
||||
modifiers.cs
|
||||
namespace.cs
|
||||
parameter.cs
|
||||
pending.cs
|
||||
report.cs
|
||||
rootcontext.cs
|
||||
statement.cs
|
||||
support.cs
|
||||
typemanager.cs
|
||||
symbolwriter.cs
|
||||
tree.cs
|
||||
module.cs
|
||||
../class/corlib/Mono.Security.Cryptography/CryptoConvert.cs
|
||||
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
|
||||
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
|
||||
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
|
||||
../build/common/Consts.cs
|
||||
@@ -0,0 +1,321 @@
|
||||
//
|
||||
// const.cs: Constant declarations.
|
||||
//
|
||||
// Author:
|
||||
// Miguel de Icaza ([email protected])
|
||||
// Marek Safar ([email protected])
|
||||
//
|
||||
// (C) 2001 Ximian, Inc.
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
// This is needed because the following situation arises:
|
||||
//
|
||||
// The FieldBuilder is declared with the real type for an enumeration
|
||||
//
|
||||
// When we attempt to set the value for the constant, the FieldBuilder.SetConstant
|
||||
// function aborts because it requires its argument to be of the same type
|
||||
//
|
||||
|
||||
namespace Mono.CSharp {
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Collections;
|
||||
|
||||
public class Const : FieldMember {
|
||||
public Expression Expr;
|
||||
EmitContext const_ec;
|
||||
|
||||
bool resolved = false;
|
||||
object ConstantValue = null;
|
||||
|
||||
bool in_transit = false;
|
||||
|
||||
public const int AllowedModifiers =
|
||||
Modifiers.NEW |
|
||||
Modifiers.PUBLIC |
|
||||
Modifiers.PROTECTED |
|
||||
Modifiers.INTERNAL |
|
||||
Modifiers.PRIVATE;
|
||||
|
||||
public Const (TypeContainer parent, Expression constant_type, string name,
|
||||
Expression expr, int mod_flags, Attributes attrs, Location loc)
|
||||
: base (parent, constant_type, mod_flags, AllowedModifiers,
|
||||
new MemberName (name), null, attrs, loc)
|
||||
{
|
||||
Expr = expr;
|
||||
ModFlags |= Modifiers.STATIC;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
void dump_tree (Type t)
|
||||
{
|
||||
Console.WriteLine ("Dumping hierarchy");
|
||||
while (t != null){
|
||||
Console.WriteLine (" " + t.FullName + " " +
|
||||
(t.GetType ().IsEnum ? "yes" : "no"));
|
||||
t = t.BaseType;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
protected override bool CheckBase ()
|
||||
{
|
||||
// Constant.Define can be called when the parent type hasn't yet been populated
|
||||
// and it's base types need not have been populated. So, we defer this check
|
||||
// to the second time Define () is called on this member.
|
||||
if (Parent.BaseCache == null)
|
||||
return true;
|
||||
return base.CheckBase ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the constant in the @parent
|
||||
/// </summary>
|
||||
public override bool Define ()
|
||||
{
|
||||
// Make Define () idempotent, but ensure that the error check happens.
|
||||
if (FieldBuilder != null)
|
||||
return base.CheckBase ();
|
||||
|
||||
if (!base.Define ())
|
||||
return false;
|
||||
|
||||
const_ec = new EmitContext (Parent, Location, null, MemberType, ModFlags);
|
||||
|
||||
Type ttype = MemberType;
|
||||
while (ttype.IsArray)
|
||||
ttype = TypeManager.GetElementType (ttype);
|
||||
|
||||
if (!TypeManager.IsBuiltinType(ttype) && (!ttype.IsSubclassOf(TypeManager.enum_type)) && !(Expr is NullLiteral)){
|
||||
Report.Error (
|
||||
-3, Location,
|
||||
"Constant type is not valid (only system types are allowed)");
|
||||
return false;
|
||||
}
|
||||
|
||||
FieldAttributes field_attr = FieldAttributes.Static | Modifiers.FieldAttr (ModFlags);
|
||||
// I don't know why but they emit decimal constant as InitOnly
|
||||
if (ttype == TypeManager.decimal_type) {
|
||||
field_attr |= FieldAttributes.InitOnly;
|
||||
}
|
||||
else {
|
||||
field_attr |= FieldAttributes.Literal;
|
||||
}
|
||||
|
||||
FieldBuilder = Parent.TypeBuilder.DefineField (Name, MemberType, field_attr);
|
||||
|
||||
TypeManager.RegisterConstant (FieldBuilder, this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// Changes the type of the constant expression `expr' to the Type `type'
|
||||
// Returns null on failure.
|
||||
//
|
||||
public static Constant ChangeType (Location loc, Constant expr, Type type)
|
||||
{
|
||||
if (type == TypeManager.object_type)
|
||||
return expr;
|
||||
|
||||
bool fail;
|
||||
|
||||
// from the null type to any reference-type.
|
||||
if (expr.Type == TypeManager.null_type && !type.IsValueType && !TypeManager.IsEnumType (type))
|
||||
return NullLiteral.Null;
|
||||
|
||||
if (!Convert.WideningStandardConversionExists (Convert.ConstantEC, expr, type)){
|
||||
Convert.Error_CannotWideningConversion (loc, expr.Type, type);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Special-case: The 0 literal can be converted to an enum value,
|
||||
// and WideningStandardConversionExists will return true in that case.
|
||||
if (expr.Type == TypeManager.int32_type && TypeManager.IsEnumType (type)){
|
||||
if (expr is IntLiteral && ((IntLiteral) expr).Value == 0)
|
||||
return new EnumConstant (expr, type);
|
||||
}
|
||||
|
||||
object constant_value = TypeManager.ChangeType (expr.GetValue (), type, out fail);
|
||||
if (fail){
|
||||
Convert.Error_CannotWideningConversion (loc, expr.Type, type);
|
||||
|
||||
//
|
||||
// We should always catch the error before this is ever
|
||||
// reached, by calling Convert.WideningStandardConversionExists
|
||||
//
|
||||
throw new Exception (
|
||||
String.Format ("LookupConstantValue: This should never be reached {0} {1}", expr.Type, type));
|
||||
}
|
||||
|
||||
Constant retval;
|
||||
if (type == TypeManager.int32_type)
|
||||
retval = new IntConstant ((int) constant_value);
|
||||
else if (type == TypeManager.uint32_type)
|
||||
retval = new UIntConstant ((uint) constant_value);
|
||||
else if (type == TypeManager.int64_type)
|
||||
retval = new LongConstant ((long) constant_value);
|
||||
else if (type == TypeManager.uint64_type)
|
||||
retval = new ULongConstant ((ulong) constant_value);
|
||||
else if (type == TypeManager.float_type)
|
||||
retval = new FloatConstant ((float) constant_value);
|
||||
else if (type == TypeManager.double_type)
|
||||
retval = new DoubleConstant ((double) constant_value);
|
||||
else if (type == TypeManager.string_type)
|
||||
retval = new StringConstant ((string) constant_value);
|
||||
else if (type == TypeManager.short_type)
|
||||
retval = new ShortConstant ((short) constant_value);
|
||||
else if (type == TypeManager.ushort_type)
|
||||
retval = new UShortConstant ((ushort) constant_value);
|
||||
else if (type == TypeManager.sbyte_type)
|
||||
retval = new SByteConstant ((sbyte) constant_value);
|
||||
else if (type == TypeManager.byte_type)
|
||||
retval = new ByteConstant ((byte) constant_value);
|
||||
else if (type == TypeManager.char_type)
|
||||
retval = new CharConstant ((char) constant_value);
|
||||
else if (type == TypeManager.bool_type)
|
||||
retval = new BoolConstant ((bool) constant_value);
|
||||
else if (type == TypeManager.decimal_type)
|
||||
retval = new DecimalConstant ((decimal) constant_value);
|
||||
else
|
||||
throw new Exception ("LookupConstantValue: Unhandled constant type: " + type);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up the value of a constant field. Defines it if it hasn't
|
||||
/// already been. Similar to LookupEnumValue in spirit.
|
||||
/// </summary>
|
||||
public bool LookupConstantValue (out object value)
|
||||
{
|
||||
if (resolved) {
|
||||
value = ConstantValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (in_transit) {
|
||||
Report.Error (110, Location,
|
||||
"The evaluation of the constant value for `" +
|
||||
Name + "' involves a circular definition.");
|
||||
value = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
in_transit = true;
|
||||
int errors = Report.Errors;
|
||||
|
||||
//
|
||||
// We might have cleared Expr ourselves in a recursive definition
|
||||
//
|
||||
if (Expr == null){
|
||||
value = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
Expr = Expr.Resolve (const_ec);
|
||||
|
||||
in_transit = false;
|
||||
|
||||
if (Expr == null) {
|
||||
if (errors == Report.Errors)
|
||||
Report.Error (150, Location, "A constant value is expected");
|
||||
value = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
Expression real_expr = Expr;
|
||||
|
||||
Constant ce = Expr as Constant;
|
||||
if (ce == null){
|
||||
UnCheckedExpr un_expr = Expr as UnCheckedExpr;
|
||||
CheckedExpr ch_expr = Expr as CheckedExpr;
|
||||
EmptyCast ec_expr = Expr as EmptyCast;
|
||||
|
||||
if ((un_expr != null) && (un_expr.Expr is Constant))
|
||||
Expr = un_expr.Expr;
|
||||
else if ((ch_expr != null) && (ch_expr.Expr is Constant))
|
||||
Expr = ch_expr.Expr;
|
||||
else if ((ec_expr != null) && (ec_expr.Child is Constant))
|
||||
Expr = ec_expr.Child;
|
||||
else if (Expr is ArrayCreation){
|
||||
Report.Error (133, Location, "Arrays can not be constant");
|
||||
} else {
|
||||
if (errors == Report.Errors)
|
||||
Report.Error (150, Location, "A constant value is expected");
|
||||
value = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
ce = Expr as Constant;
|
||||
}
|
||||
|
||||
if (MemberType != real_expr.Type) {
|
||||
ce = ChangeType (Location, ce, MemberType);
|
||||
if (ce == null){
|
||||
value = null;
|
||||
return false;
|
||||
}
|
||||
Expr = ce;
|
||||
}
|
||||
|
||||
if (ce != null)
|
||||
ConstantValue = ce.GetValue ();
|
||||
|
||||
if (MemberType.IsEnum){
|
||||
//
|
||||
// This sadly does not work for our user-defined enumerations types ;-(
|
||||
//
|
||||
try {
|
||||
ConstantValue = System.Enum.ToObject (
|
||||
MemberType, ConstantValue);
|
||||
} catch (ArgumentException){
|
||||
Report.Error (
|
||||
-16, Location,
|
||||
".NET SDK 1.0 does not permit to create the constant "+
|
||||
" field from a user-defined enumeration");
|
||||
}
|
||||
}
|
||||
|
||||
if (ce is DecimalConstant) {
|
||||
Decimal d = ((DecimalConstant)ce).Value;
|
||||
int[] bits = Decimal.GetBits (d);
|
||||
object[] args = new object[] { (byte)(bits [3] >> 16), (byte)(bits [3] >> 31), (uint)bits [2], (uint)bits [1], (uint)bits [0] };
|
||||
CustomAttributeBuilder cab = new CustomAttributeBuilder (TypeManager.decimal_constant_attribute_ctor, args);
|
||||
FieldBuilder.SetCustomAttribute (cab);
|
||||
}
|
||||
else{
|
||||
FieldBuilder.SetConstant (ConstantValue);
|
||||
}
|
||||
|
||||
if (!TypeManager.RegisterFieldValue (FieldBuilder, ConstantValue))
|
||||
throw new Exception ("Cannot register const value");
|
||||
|
||||
value = ConstantValue;
|
||||
resolved = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Emits the field value by evaluating the expression
|
||||
/// </summary>
|
||||
public override void Emit ()
|
||||
{
|
||||
object value;
|
||||
LookupConstantValue (out value);
|
||||
|
||||
if (OptAttributes != null) {
|
||||
OptAttributes.Emit (const_ec, this);
|
||||
}
|
||||
|
||||
base.Emit ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,819 @@
|
||||
//
|
||||
// doc.cs: Support for XML documentation comment.
|
||||
//
|
||||
// Author:
|
||||
// Atsushi Enomoto <[email protected]>
|
||||
//
|
||||
// Licensed under the terms of the GNU GPL
|
||||
//
|
||||
// (C) 2004 Novell, Inc.
|
||||
//
|
||||
//
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
|
||||
namespace Mono.CSharp {
|
||||
|
||||
//
|
||||
// Support class for XML documentation.
|
||||
//
|
||||
public static class DocUtil
|
||||
{
|
||||
// TypeContainer
|
||||
|
||||
//
|
||||
// Generates xml doc comments (if any), and if required,
|
||||
// handle warning report.
|
||||
//
|
||||
internal static void GenerateTypeDocComment (TypeContainer t,
|
||||
DeclSpace ds)
|
||||
{
|
||||
GenerateDocComment (t, ds);
|
||||
|
||||
if (t.DefaultStaticConstructor != null)
|
||||
t.DefaultStaticConstructor.GenerateDocComment (t);
|
||||
|
||||
if (t.InstanceConstructors != null)
|
||||
foreach (Constructor c in t.InstanceConstructors)
|
||||
c.GenerateDocComment (t);
|
||||
|
||||
if (t.Types != null)
|
||||
foreach (TypeContainer tc in t.Types)
|
||||
tc.GenerateDocComment (t);
|
||||
|
||||
if (t.Parts != null) {
|
||||
IDictionary comments = RootContext.Documentation.PartialComments;
|
||||
foreach (ClassPart cp in t.Parts) {
|
||||
if (cp.DocComment == null)
|
||||
continue;
|
||||
comments [cp] = cp;
|
||||
}
|
||||
}
|
||||
|
||||
if (t.Enums != null)
|
||||
foreach (Enum en in t.Enums)
|
||||
en.GenerateDocComment (t);
|
||||
|
||||
if (t.Constants != null)
|
||||
foreach (Const c in t.Constants)
|
||||
c.GenerateDocComment (t);
|
||||
|
||||
if (t.Fields != null)
|
||||
foreach (Field f in t.Fields)
|
||||
f.GenerateDocComment (t);
|
||||
|
||||
if (t.Events != null)
|
||||
foreach (Event e in t.Events)
|
||||
e.GenerateDocComment (t);
|
||||
|
||||
if (t.Indexers != null)
|
||||
foreach (Indexer ix in t.Indexers)
|
||||
ix.GenerateDocComment (t);
|
||||
|
||||
if (t.Properties != null)
|
||||
foreach (Property p in t.Properties)
|
||||
p.GenerateDocComment (t);
|
||||
|
||||
if (t.Methods != null)
|
||||
foreach (Method m in t.Methods)
|
||||
m.GenerateDocComment (t);
|
||||
|
||||
if (t.Operators != null)
|
||||
foreach (Operator o in t.Operators)
|
||||
o.GenerateDocComment (t);
|
||||
}
|
||||
|
||||
// MemberCore
|
||||
private static readonly string lineHead =
|
||||
Environment.NewLine + " ";
|
||||
|
||||
private static XmlNode GetDocCommentNode (MemberCore mc,
|
||||
string name)
|
||||
{
|
||||
// FIXME: It could be even optimizable as not
|
||||
// to use XmlDocument. But anyways the nodes
|
||||
// are not kept in memory.
|
||||
XmlDocument doc = RootContext.Documentation.XmlDocumentation;
|
||||
try {
|
||||
XmlElement el = doc.CreateElement ("member");
|
||||
el.SetAttribute ("name", name);
|
||||
string normalized = mc.DocComment;
|
||||
el.InnerXml = normalized;
|
||||
// csc keeps lines as written in the sources
|
||||
// and inserts formatting indentation (which
|
||||
// is different from XmlTextWriter.Formatting
|
||||
// one), but when a start tag contains an
|
||||
// endline, it joins the next line. We don't
|
||||
// have to follow such a hacky behavior.
|
||||
string [] split =
|
||||
normalized.Split ('\n');
|
||||
int j = 0;
|
||||
for (int i = 0; i < split.Length; i++) {
|
||||
string s = split [i].TrimEnd ();
|
||||
if (s.Length > 0)
|
||||
split [j++] = s;
|
||||
}
|
||||
el.InnerXml = lineHead + String.Join (
|
||||
lineHead, split, 0, j);
|
||||
return el;
|
||||
} catch (XmlException ex) {
|
||||
Report.Warning (1570, 1, mc.Location, "XML comment on '{0}' has non-well-formed XML ({1}).", name, ex.Message);
|
||||
XmlComment com = doc.CreateComment (String.Format ("FIXME: Invalid documentation markup was found for member {0}", name));
|
||||
return com;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Generates xml doc comments (if any), and if required,
|
||||
// handle warning report.
|
||||
//
|
||||
internal static void GenerateDocComment (MemberCore mc,
|
||||
DeclSpace ds)
|
||||
{
|
||||
if (mc.DocComment != null) {
|
||||
string name = mc.GetDocCommentName (ds);
|
||||
|
||||
XmlNode n = GetDocCommentNode (mc, name);
|
||||
|
||||
XmlElement el = n as XmlElement;
|
||||
if (el != null) {
|
||||
mc.OnGenerateDocComment (ds, el);
|
||||
|
||||
// FIXME: it could be done with XmlReader
|
||||
foreach (XmlElement inc in n.SelectNodes (".//include"))
|
||||
HandleInclude (mc, inc);
|
||||
|
||||
// FIXME: it could be done with XmlReader
|
||||
DeclSpace dsTarget = mc as DeclSpace;
|
||||
if (dsTarget == null)
|
||||
dsTarget = ds;
|
||||
|
||||
foreach (XmlElement see in n.SelectNodes (".//see"))
|
||||
HandleSee (mc, dsTarget, see);
|
||||
foreach (XmlElement seealso in n.SelectNodes (".//seealso"))
|
||||
HandleSeeAlso (mc, dsTarget, seealso);
|
||||
foreach (XmlElement see in n.SelectNodes (".//exception"))
|
||||
HandleException (mc, dsTarget, see);
|
||||
}
|
||||
|
||||
n.WriteTo (RootContext.Documentation.XmlCommentOutput);
|
||||
}
|
||||
else if (mc.IsExposedFromAssembly (ds)) {
|
||||
Constructor c = mc as Constructor;
|
||||
if (c == null || !c.IsDefault ())
|
||||
Report.Warning (1591, 4, mc.Location,
|
||||
"Missing XML comment for publicly visible type or member '{0}'", mc.GetSignatureForError ());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Processes "include" element. Check included file and
|
||||
// embed the document content inside this documentation node.
|
||||
//
|
||||
private static void HandleInclude (MemberCore mc, XmlElement el)
|
||||
{
|
||||
string file = el.GetAttribute ("file");
|
||||
string path = el.GetAttribute ("path");
|
||||
if (file == "") {
|
||||
Report.Warning (1590, 1, mc.Location, "Invalid XML 'include' element; Missing 'file' attribute.");
|
||||
el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (" Include tag is invalid "), el);
|
||||
}
|
||||
else if (path == "") {
|
||||
Report.Warning (1590, 1, mc.Location, "Invalid XML 'include' element; Missing 'path' attribute.");
|
||||
el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (" Include tag is invalid "), el);
|
||||
}
|
||||
else {
|
||||
XmlDocument doc = RootContext.Documentation.StoredDocuments [file] as XmlDocument;
|
||||
if (doc == null) {
|
||||
try {
|
||||
doc = new XmlDocument ();
|
||||
doc.Load (file);
|
||||
RootContext.Documentation.StoredDocuments.Add (file, doc);
|
||||
} catch (Exception) {
|
||||
el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (String.Format (" Badly formed XML in at comment file '{0}': cannot be included ", file)), el);
|
||||
Report.Warning (1592, 1, mc.Location, "Badly formed XML in included comments file -- '{0}'", file);
|
||||
}
|
||||
}
|
||||
bool keepIncludeNode = false;
|
||||
if (doc != null) {
|
||||
try {
|
||||
XmlNodeList nl = doc.SelectNodes (path);
|
||||
if (nl.Count == 0) {
|
||||
el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (" No matching elements were found for the include tag embedded here. "), el);
|
||||
|
||||
keepIncludeNode = true;
|
||||
}
|
||||
foreach (XmlNode n in nl)
|
||||
el.ParentNode.InsertBefore (el.OwnerDocument.ImportNode (n, true), el);
|
||||
} catch (Exception ex) {
|
||||
el.ParentNode.InsertBefore (el.OwnerDocument.CreateComment (" Failed to insert some or all of included XML "), el);
|
||||
Report.Warning (1589, 1, mc.Location, "Unable to include XML fragment '{0}' of file {1} -- {2}.", path, file, ex.Message);
|
||||
}
|
||||
}
|
||||
if (!keepIncludeNode)
|
||||
el.ParentNode.RemoveChild (el);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Handles <see> elements.
|
||||
//
|
||||
private static void HandleSee (MemberCore mc,
|
||||
DeclSpace ds, XmlElement see)
|
||||
{
|
||||
HandleXrefCommon (mc, ds, see);
|
||||
}
|
||||
|
||||
//
|
||||
// Handles <seealso> elements.
|
||||
//
|
||||
private static void HandleSeeAlso (MemberCore mc,
|
||||
DeclSpace ds, XmlElement seealso)
|
||||
{
|
||||
HandleXrefCommon (mc, ds, seealso);
|
||||
}
|
||||
|
||||
//
|
||||
// Handles <exception> elements.
|
||||
//
|
||||
private static void HandleException (MemberCore mc,
|
||||
DeclSpace ds, XmlElement seealso)
|
||||
{
|
||||
HandleXrefCommon (mc, ds, seealso);
|
||||
}
|
||||
|
||||
static readonly char [] wsChars =
|
||||
new char [] {' ', '\t', '\n', '\r'};
|
||||
|
||||
//
|
||||
// returns a full runtime type name from a name which might
|
||||
// be C# specific type name.
|
||||
//
|
||||
private static Type FindDocumentedType (MemberCore mc, string name, DeclSpace ds, string cref)
|
||||
{
|
||||
bool isArray = false;
|
||||
string identifier = name;
|
||||
if (name [name.Length - 1] == ']') {
|
||||
string tmp = name.Substring (0, name.Length - 1).Trim (wsChars);
|
||||
if (tmp [tmp.Length - 1] == '[') {
|
||||
identifier = tmp.Substring (0, tmp.Length - 1).Trim (wsChars);
|
||||
isArray = true;
|
||||
}
|
||||
}
|
||||
Type t = FindDocumentedTypeNonArray (mc, identifier, ds, cref);
|
||||
if (t != null && isArray)
|
||||
t = Array.CreateInstance (t, 0).GetType ();
|
||||
return t;
|
||||
}
|
||||
|
||||
private static Type FindDocumentedTypeNonArray (MemberCore mc,
|
||||
string identifier, DeclSpace ds, string cref)
|
||||
{
|
||||
switch (identifier) {
|
||||
case "int":
|
||||
return typeof (int);
|
||||
case "uint":
|
||||
return typeof (uint);
|
||||
case "short":
|
||||
return typeof (short);
|
||||
case "ushort":
|
||||
return typeof (ushort);
|
||||
case "long":
|
||||
return typeof (long);
|
||||
case "ulong":
|
||||
return typeof (ulong);
|
||||
case "float":
|
||||
return typeof (float);
|
||||
case "double":
|
||||
return typeof (double);
|
||||
case "char":
|
||||
return typeof (char);
|
||||
case "decimal":
|
||||
return typeof (decimal);
|
||||
case "byte":
|
||||
return typeof (byte);
|
||||
case "sbyte":
|
||||
return typeof (sbyte);
|
||||
case "object":
|
||||
return typeof (object);
|
||||
case "bool":
|
||||
return typeof (bool);
|
||||
case "string":
|
||||
return typeof (string);
|
||||
case "void":
|
||||
return typeof (void);
|
||||
}
|
||||
FullNamedExpression e = ds.FindType (mc.Location, identifier);
|
||||
if (e != null) {
|
||||
if (!(e is TypeExpr))
|
||||
return null;
|
||||
return ((TypeExpr) e).ResolveType (ds.EmitContext);
|
||||
}
|
||||
int index = identifier.LastIndexOf ('.');
|
||||
if (index < 0)
|
||||
return null;
|
||||
int warn;
|
||||
Type parent = FindDocumentedType (mc, identifier.Substring (0, index), ds, cref);
|
||||
if (parent == null)
|
||||
return null;
|
||||
return FindDocumentedMember (mc, parent,
|
||||
identifier.Substring (index + 1),
|
||||
Type.EmptyTypes,
|
||||
ds, out warn, cref) as Type;
|
||||
}
|
||||
|
||||
//
|
||||
// Returns a MemberInfo that is referenced in XML documentation
|
||||
// (by "see" or "seealso" elements).
|
||||
//
|
||||
private static MemberInfo FindDocumentedMember (MemberCore mc,
|
||||
Type type, string memberName, Type [] paramList,
|
||||
DeclSpace ds, out int warningType, string cref)
|
||||
{
|
||||
warningType = 0;
|
||||
MethodSignature msig = new MethodSignature (memberName, null, paramList);
|
||||
MemberInfo [] mis = type.FindMembers (
|
||||
MemberTypes.All,
|
||||
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance,
|
||||
MethodSignature.method_signature_filter,
|
||||
msig);
|
||||
if (mis.Length > 0)
|
||||
return mis [0];
|
||||
|
||||
if (paramList.Length == 0) {
|
||||
// search for fields/events etc.
|
||||
mis = type.FindMembers (
|
||||
MemberTypes.All,
|
||||
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance,
|
||||
Type.FilterName,
|
||||
memberName);
|
||||
return (mis.Length > 0) ? mis [0] : null;
|
||||
}
|
||||
|
||||
// search for operators (whose parameters exactly
|
||||
// matches with the list) and possibly report CS1581.
|
||||
string oper = null;
|
||||
string returnTypeName = null;
|
||||
if (memberName.StartsWith ("implicit operator ")) {
|
||||
oper = "op_Implicit";
|
||||
returnTypeName = memberName.Substring (18).Trim (wsChars);
|
||||
}
|
||||
else if (memberName.StartsWith ("explicit operator ")) {
|
||||
oper = "op_Explicit";
|
||||
returnTypeName = memberName.Substring (18).Trim (wsChars);
|
||||
}
|
||||
else if (memberName.StartsWith ("operator ")) {
|
||||
oper = memberName.Substring (9).Trim (wsChars);
|
||||
switch (oper) {
|
||||
// either unary or binary
|
||||
case "+":
|
||||
oper = paramList.Length == 2 ?
|
||||
Binary.oper_names [(int) Binary.Operator.Addition] :
|
||||
Unary.oper_names [(int) Unary.Operator.UnaryPlus];
|
||||
break;
|
||||
case "-":
|
||||
oper = paramList.Length == 2 ?
|
||||
Binary.oper_names [(int) Binary.Operator.Subtraction] :
|
||||
Unary.oper_names [(int) Unary.Operator.UnaryNegation];
|
||||
break;
|
||||
// unary
|
||||
case "!":
|
||||
oper = Unary.oper_names [(int) Unary.Operator.LogicalNot]; break;
|
||||
case "~":
|
||||
oper = Unary.oper_names [(int) Unary.Operator.OnesComplement]; break;
|
||||
|
||||
case "++":
|
||||
oper = "op_Increment"; break;
|
||||
case "--":
|
||||
oper = "op_Decrement"; break;
|
||||
case "true":
|
||||
oper = "op_True"; break;
|
||||
case "false":
|
||||
oper = "op_False"; break;
|
||||
// binary
|
||||
case "*":
|
||||
oper = Binary.oper_names [(int) Binary.Operator.Multiply]; break;
|
||||
case "/":
|
||||
oper = Binary.oper_names [(int) Binary.Operator.Division]; break;
|
||||
case "%":
|
||||
oper = Binary.oper_names [(int) Binary.Operator.Modulus]; break;
|
||||
case "&":
|
||||
oper = Binary.oper_names [(int) Binary.Operator.BitwiseAnd]; break;
|
||||
case "|":
|
||||
oper = Binary.oper_names [(int) Binary.Operator.BitwiseOr]; break;
|
||||
case "^":
|
||||
oper = Binary.oper_names [(int) Binary.Operator.ExclusiveOr]; break;
|
||||
case "<<":
|
||||
oper = Binary.oper_names [(int) Binary.Operator.LeftShift]; break;
|
||||
case ">>":
|
||||
oper = Binary.oper_names [(int) Binary.Operator.RightShift]; break;
|
||||
case "==":
|
||||
oper = Binary.oper_names [(int) Binary.Operator.Equality]; break;
|
||||
case "!=":
|
||||
oper = Binary.oper_names [(int) Binary.Operator.Inequality]; break;
|
||||
case "<":
|
||||
oper = Binary.oper_names [(int) Binary.Operator.LessThan]; break;
|
||||
case ">":
|
||||
oper = Binary.oper_names [(int) Binary.Operator.GreaterThan]; break;
|
||||
case "<=":
|
||||
oper = Binary.oper_names [(int) Binary.Operator.LessThanOrEqual]; break;
|
||||
case ">=":
|
||||
oper = Binary.oper_names [(int) Binary.Operator.GreaterThanOrEqual]; break;
|
||||
default:
|
||||
warningType = 1584;
|
||||
Report.Warning (1020, 1, mc.Location, "Overloadable {0} operator is expected", paramList.Length == 2 ? "binary" : "unary");
|
||||
Report.Warning (1584, 1, mc.Location, "XML comment on '{0}' has syntactically incorrect attribute '{1}'", mc.GetSignatureForError (), cref);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// here we still does not consider return type (to
|
||||
// detect CS1581 or CS1002+CS1584).
|
||||
msig = new MethodSignature (oper, null, paramList);
|
||||
mis = type.FindMembers (
|
||||
MemberTypes.Method,
|
||||
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static,
|
||||
MethodSignature.method_signature_filter,
|
||||
msig);
|
||||
if (mis.Length == 0)
|
||||
return null; // CS1574
|
||||
MemberInfo mi = mis [0];
|
||||
Type expected = mi is MethodInfo ?
|
||||
((MethodInfo) mi).ReturnType :
|
||||
mi is PropertyInfo ?
|
||||
((PropertyInfo) mi).PropertyType :
|
||||
null;
|
||||
if (returnTypeName != null) {
|
||||
Type returnType = FindDocumentedType (mc, returnTypeName, ds, cref);
|
||||
if (returnType == null || returnType != expected) {
|
||||
warningType = 1581;
|
||||
Report.Warning (1581, 1, mc.Location, "Invalid return type in XML comment cref attribute '{0}'", cref);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return mis [0];
|
||||
}
|
||||
|
||||
//
|
||||
// Processes "see" or "seealso" elements.
|
||||
// Checks cref attribute.
|
||||
//
|
||||
private static void HandleXrefCommon (MemberCore mc,
|
||||
DeclSpace ds, XmlElement xref)
|
||||
{
|
||||
string cref = xref.GetAttribute ("cref").Trim (wsChars);
|
||||
// when, XmlReader, "if (cref == null)"
|
||||
if (!xref.HasAttribute ("cref"))
|
||||
return;
|
||||
if (cref.Length == 0)
|
||||
Report.Warning (1001, 1, mc.Location, "Identifier expected");
|
||||
// ... and continue until CS1584.
|
||||
|
||||
string signature; // "x:" are stripped
|
||||
string name; // method invokation "(...)" are removed
|
||||
string parameters; // method parameter list
|
||||
|
||||
// strip 'T:' 'M:' 'F:' 'P:' 'E:' etc.
|
||||
// Here, MS ignores its member kind. No idea why.
|
||||
if (cref.Length > 2 && cref [1] == ':')
|
||||
signature = cref.Substring (2).Trim (wsChars);
|
||||
else
|
||||
signature = cref;
|
||||
|
||||
int parensPos = signature.IndexOf ('(');
|
||||
if (parensPos > 0 && signature [signature.Length - 1] == ')') {
|
||||
name = signature.Substring (0, parensPos).Trim (wsChars);
|
||||
parameters = signature.Substring (parensPos + 1, signature.Length - parensPos - 2);
|
||||
}
|
||||
else {
|
||||
name = signature;
|
||||
parameters = String.Empty;
|
||||
}
|
||||
|
||||
string identifier = name;
|
||||
|
||||
if (name.Length > 0 && name [name.Length - 1] == ']') {
|
||||
string tmp = name.Substring (0, name.Length - 1).Trim (wsChars);
|
||||
if (tmp [tmp.Length - 1] == '[')
|
||||
identifier = tmp.Substring (0, tmp.Length - 1).Trim (wsChars);
|
||||
}
|
||||
|
||||
// Check if identifier is valid.
|
||||
// This check is not necessary to mark as error, but
|
||||
// csc specially reports CS1584 for wrong identifiers.
|
||||
foreach (string nameElem in identifier.Split ('.')) {
|
||||
if (!Tokenizer.IsValidIdentifier (nameElem)
|
||||
&& nameElem.IndexOf ("operator") < 0) {
|
||||
if (nameElem.EndsWith ("[]") &&
|
||||
Tokenizer.IsValidIdentifier (
|
||||
nameElem.Substring (
|
||||
0, nameElem.Length - 2)))
|
||||
continue;
|
||||
|
||||
Report.Warning (1584, 1, mc.Location, "XML comment on '{0}' has syntactically incorrect attribute '{1}'", mc.GetSignatureForError (), cref);
|
||||
xref.SetAttribute ("cref", "!:" + signature);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// check if parameters are valid
|
||||
Type [] parameterTypes = Type.EmptyTypes;
|
||||
if (parameters.Length > 0) {
|
||||
string [] paramList = parameters.Split (',');
|
||||
ArrayList plist = new ArrayList ();
|
||||
for (int i = 0; i < paramList.Length; i++) {
|
||||
string paramTypeName = paramList [i].Trim (wsChars);
|
||||
Type paramType = FindDocumentedType (mc, paramTypeName, ds, cref);
|
||||
if (paramType == null) {
|
||||
Report.Warning (1580, 1, mc.Location, "Invalid type for parameter '{0}' in XML comment cref attribute '{1}'", i + 1, cref);
|
||||
return;
|
||||
}
|
||||
plist.Add (paramType);
|
||||
}
|
||||
parameterTypes = plist.ToArray (typeof (Type)) as Type [];
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
sb.Append ('(');
|
||||
for (int i = 0; i < parameterTypes.Length; i++) {
|
||||
Type t = parameterTypes [i];
|
||||
if (sb.Length > 1)
|
||||
sb.Append (',');
|
||||
sb.Append (t.FullName.Replace ('+', '.'));
|
||||
}
|
||||
sb.Append (')');
|
||||
parameters = sb.ToString ();
|
||||
}
|
||||
|
||||
Type type = FindDocumentedType (mc, name, ds, cref);
|
||||
if (type != null) {
|
||||
xref.SetAttribute ("cref", "T:" + type.FullName.Replace ("+", "."));
|
||||
return; // a type
|
||||
}
|
||||
|
||||
// don't use identifier here. System[] is not alloed.
|
||||
if (Namespace.IsNamespace (name)) {
|
||||
xref.SetAttribute ("cref", "N:" + name);
|
||||
return; // a namespace
|
||||
}
|
||||
|
||||
int period = name.LastIndexOf ('.');
|
||||
if (period > 0) {
|
||||
string typeName = name.Substring (0, period);
|
||||
string memberName = name.Substring (period + 1);
|
||||
type = FindDocumentedType (mc, typeName, ds, cref);
|
||||
int warnResult;
|
||||
if (type != null) {
|
||||
MemberInfo mi = FindDocumentedMember (mc, type, memberName, parameterTypes, ds, out warnResult, cref);
|
||||
if (warnResult > 0)
|
||||
return;
|
||||
if (mi != null) {
|
||||
xref.SetAttribute ("cref", GetMemberDocHead (mi.MemberType) + type.FullName.Replace ("+", ".") + "." + memberName + parameters);
|
||||
return; // a member of a type
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
int warnResult;
|
||||
MemberInfo mi = FindDocumentedMember (mc, ds.TypeBuilder, name, parameterTypes, ds, out warnResult, cref);
|
||||
if (warnResult > 0)
|
||||
return;
|
||||
if (mi != null) {
|
||||
xref.SetAttribute ("cref", GetMemberDocHead (mi.MemberType) + ds.TypeBuilder.FullName.Replace ("+", ".") + "." + name);
|
||||
return; // local member name
|
||||
}
|
||||
}
|
||||
|
||||
Report.Warning (1574, 1, mc.Location, "XML comment on '{0}' has cref attribute '{1}' that could not be resolved in '{2}'.", mc.GetSignatureForError (), cref, ds.GetSignatureForError ());
|
||||
|
||||
xref.SetAttribute ("cref", "!:" + name);
|
||||
}
|
||||
|
||||
//
|
||||
// Get a prefix from member type for XML documentation (used
|
||||
// to formalize cref target name).
|
||||
//
|
||||
static string GetMemberDocHead (MemberTypes type)
|
||||
{
|
||||
switch (type) {
|
||||
case MemberTypes.Constructor:
|
||||
case MemberTypes.Method:
|
||||
return "M:";
|
||||
case MemberTypes.Event:
|
||||
return "E:";
|
||||
case MemberTypes.Field:
|
||||
return "F:";
|
||||
case MemberTypes.NestedType:
|
||||
case MemberTypes.TypeInfo:
|
||||
return "T:";
|
||||
case MemberTypes.Property:
|
||||
return "P:";
|
||||
}
|
||||
return "!:";
|
||||
}
|
||||
|
||||
// MethodCore
|
||||
|
||||
//
|
||||
// Returns a string that represents the signature for this
|
||||
// member which should be used in XML documentation.
|
||||
//
|
||||
public static string GetMethodDocCommentName (MethodCore mc, DeclSpace ds)
|
||||
{
|
||||
Parameter [] plist = mc.Parameters.FixedParameters;
|
||||
Parameter parr = mc.Parameters.ArrayParameter;
|
||||
string paramSpec = String.Empty;
|
||||
if (plist != null) {
|
||||
StringBuilder psb = new StringBuilder ();
|
||||
foreach (Parameter p in plist) {
|
||||
psb.Append (psb.Length != 0 ? "," : "(");
|
||||
psb.Append (p.ParameterType.FullName.Replace ("+", "."));
|
||||
}
|
||||
paramSpec = psb.ToString ();
|
||||
}
|
||||
if (parr != null)
|
||||
paramSpec += String.Concat (
|
||||
paramSpec == String.Empty ? "(" : ",",
|
||||
parr.ParameterType.FullName.Replace ("+", "."));
|
||||
|
||||
if (paramSpec.Length > 0)
|
||||
paramSpec += ")";
|
||||
|
||||
string name = mc is Constructor ? "#ctor" : mc.Name;
|
||||
string suffix = String.Empty;
|
||||
Operator op = mc as Operator;
|
||||
if (op != null) {
|
||||
switch (op.OperatorType) {
|
||||
case Operator.OpType.Implicit:
|
||||
case Operator.OpType.Explicit:
|
||||
suffix = "~" + op.OperatorMethodBuilder.ReturnType.FullName.Replace ('+', '.');
|
||||
break;
|
||||
}
|
||||
}
|
||||
return String.Concat (mc.DocCommentHeader, ds.Name, ".", name, paramSpec, suffix);
|
||||
}
|
||||
|
||||
//
|
||||
// Raised (and passed an XmlElement that contains the comment)
|
||||
// when GenerateDocComment is writing documentation expectedly.
|
||||
//
|
||||
// FIXME: with a few effort, it could be done with XmlReader,
|
||||
// that means removal of DOM use.
|
||||
//
|
||||
internal static void OnMethodGenerateDocComment (
|
||||
MethodCore mc, DeclSpace ds, XmlElement el)
|
||||
{
|
||||
Hashtable paramTags = new Hashtable ();
|
||||
foreach (XmlElement pelem in el.SelectNodes ("param")) {
|
||||
int i;
|
||||
string xname = pelem.GetAttribute ("name");
|
||||
if (xname == "")
|
||||
continue; // really? but MS looks doing so
|
||||
if (xname != "" && mc.Parameters.GetParameterByName (xname, out i) == null)
|
||||
Report.Warning (1572, 2, mc.Location, "XML comment on '{0}' has a 'param' tag for '{1}', but there is no such parameter.", mc.Name, xname);
|
||||
else if (paramTags [xname] != null)
|
||||
Report.Warning (1571, 2, mc.Location, "XML comment on '{0}' has a duplicate param tag for '{1}'", mc.Name, xname);
|
||||
paramTags [xname] = xname;
|
||||
}
|
||||
Parameter [] plist = mc.Parameters.FixedParameters;
|
||||
if (plist != null) {
|
||||
foreach (Parameter p in plist) {
|
||||
if (paramTags.Count > 0 && paramTags [p.Name] == null)
|
||||
Report.Warning (1573, 4, mc.Location, "Parameter '{0}' has no matching param tag in the XML comment for '{1}' (but other parameters do)", mc.Name, p.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enum
|
||||
public static void GenerateEnumDocComment (Enum e, DeclSpace ds)
|
||||
{
|
||||
GenerateDocComment (e, ds);
|
||||
foreach (string name in e.ordered_enums) {
|
||||
MemberCore mc = e.GetDefinition (name);
|
||||
GenerateDocComment (mc, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Implements XML documentation generation.
|
||||
//
|
||||
public class Documentation
|
||||
{
|
||||
public Documentation (string xml_output_filename)
|
||||
{
|
||||
docfilename = xml_output_filename;
|
||||
XmlDocumentation = new XmlDocument ();
|
||||
XmlDocumentation.PreserveWhitespace = false;
|
||||
}
|
||||
|
||||
private string docfilename;
|
||||
|
||||
//
|
||||
// Used to create element which helps well-formedness checking.
|
||||
//
|
||||
public XmlDocument XmlDocumentation;
|
||||
|
||||
//
|
||||
// The output for XML documentation.
|
||||
//
|
||||
public XmlWriter XmlCommentOutput;
|
||||
|
||||
//
|
||||
// Stores XmlDocuments that are included in XML documentation.
|
||||
// Keys are included filenames, values are XmlDocuments.
|
||||
//
|
||||
public Hashtable StoredDocuments = new Hashtable ();
|
||||
|
||||
//
|
||||
// Stores comments on partial types (should handle uniquely).
|
||||
// Keys are PartialContainers, values are comment strings
|
||||
// (didn't use StringBuilder; usually we have just 2 or more).
|
||||
//
|
||||
public IDictionary PartialComments = new ListDictionary ();
|
||||
|
||||
//
|
||||
// Outputs XML documentation comment from tokenized comments.
|
||||
//
|
||||
public bool OutputDocComment (string asmfilename)
|
||||
{
|
||||
XmlTextWriter w = null;
|
||||
try {
|
||||
w = new XmlTextWriter (docfilename, null);
|
||||
w.Indentation = 4;
|
||||
w.Formatting = Formatting.Indented;
|
||||
w.WriteStartDocument ();
|
||||
w.WriteStartElement ("doc");
|
||||
w.WriteStartElement ("assembly");
|
||||
w.WriteStartElement ("name");
|
||||
w.WriteString (Path.ChangeExtension (asmfilename, null));
|
||||
w.WriteEndElement (); // name
|
||||
w.WriteEndElement (); // assembly
|
||||
w.WriteStartElement ("members");
|
||||
XmlCommentOutput = w;
|
||||
GenerateDocComment ();
|
||||
w.WriteFullEndElement (); // members
|
||||
w.WriteEndElement ();
|
||||
w.WriteWhitespace (Environment.NewLine);
|
||||
w.WriteEndDocument ();
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
Report.Error (1569, "Error generating XML documentation file '{0}' ('{1}')", docfilename, ex.Message);
|
||||
return false;
|
||||
} finally {
|
||||
if (w != null)
|
||||
w.Close ();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Fixes full type name of each documented types/members up.
|
||||
//
|
||||
public void GenerateDocComment ()
|
||||
{
|
||||
TypeContainer root = RootContext.Tree.Types;
|
||||
if (root.Interfaces != null)
|
||||
foreach (Interface i in root.Interfaces)
|
||||
DocUtil.GenerateTypeDocComment (i, null);
|
||||
|
||||
if (root.Types != null)
|
||||
foreach (TypeContainer tc in root.Types)
|
||||
DocUtil.GenerateTypeDocComment (tc, null);
|
||||
|
||||
if (root.Parts != null) {
|
||||
IDictionary comments = PartialComments;
|
||||
foreach (ClassPart cp in root.Parts) {
|
||||
if (cp.DocComment == null)
|
||||
continue;
|
||||
comments [cp] = cp;
|
||||
}
|
||||
}
|
||||
|
||||
if (root.Delegates != null)
|
||||
foreach (Delegate d in root.Delegates)
|
||||
DocUtil.GenerateDocComment (d, null);
|
||||
|
||||
if (root.Enums != null)
|
||||
foreach (Enum e in root.Enums)
|
||||
DocUtil.GenerateEnumDocComment (e, null);
|
||||
|
||||
IDictionary table = new ListDictionary ();
|
||||
foreach (ClassPart cp in PartialComments.Keys) {
|
||||
table [cp.PartialContainer] += cp.DocComment;
|
||||
}
|
||||
foreach (PartialContainer pc in table.Keys) {
|
||||
pc.DocComment = table [pc] as string;
|
||||
DocUtil.GenerateDocComment (pc, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,811 @@
|
||||
//
|
||||
// enum.cs: Enum handling.
|
||||
//
|
||||
// Author: Miguel de Icaza ([email protected])
|
||||
// Ravi Pratap ([email protected])
|
||||
//
|
||||
// Licensed under the terms of the GNU GPL
|
||||
//
|
||||
// (C) 2001 Ximian, Inc (http://www.ximian.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Globalization;
|
||||
using System.Xml;
|
||||
|
||||
namespace Mono.CSharp {
|
||||
|
||||
class EnumMember: MemberCore {
|
||||
static string[] attribute_targets = new string [] { "field" };
|
||||
|
||||
Enum parent_enum;
|
||||
public FieldBuilder builder;
|
||||
internal readonly Expression Type;
|
||||
|
||||
public EnumMember (Enum parent_enum, Expression expr, string name,
|
||||
Location loc, Attributes attrs):
|
||||
base (null, new MemberName (name), attrs, loc)
|
||||
{
|
||||
this.parent_enum = parent_enum;
|
||||
this.ModFlags = parent_enum.ModFlags;
|
||||
this.Type = expr;
|
||||
}
|
||||
|
||||
public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
|
||||
{
|
||||
if (a.Type == TypeManager.marshal_as_attr_type) {
|
||||
UnmanagedMarshal marshal = a.GetMarshal (this);
|
||||
if (marshal != null) {
|
||||
builder.SetMarshal (marshal);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (a.Type.IsSubclassOf (TypeManager.security_attr_type)) {
|
||||
a.Error_InvalidSecurityParent ();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.SetCustomAttribute (cb);
|
||||
}
|
||||
|
||||
public override AttributeTargets AttributeTargets {
|
||||
get {
|
||||
return AttributeTargets.Field;
|
||||
}
|
||||
}
|
||||
|
||||
public void DefineMember (TypeBuilder tb)
|
||||
{
|
||||
FieldAttributes attr = FieldAttributes.Public | FieldAttributes.Static
|
||||
| FieldAttributes.Literal;
|
||||
|
||||
builder = tb.DefineField (Name, tb, attr);
|
||||
}
|
||||
|
||||
public override bool Define ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public void Emit (EmitContext ec)
|
||||
{
|
||||
if (OptAttributes != null)
|
||||
OptAttributes.Emit (ec, this);
|
||||
|
||||
Emit ();
|
||||
}
|
||||
|
||||
public override string GetSignatureForError()
|
||||
{
|
||||
return String.Concat (parent_enum.GetSignatureForError (), '.', base.GetSignatureForError ());
|
||||
}
|
||||
|
||||
public override string[] ValidAttributeTargets {
|
||||
get {
|
||||
return attribute_targets;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool VerifyClsCompliance(DeclSpace ds)
|
||||
{
|
||||
// Because parent is TypeContainer and we have only DeclSpace parent.
|
||||
// Parameter replacing is required
|
||||
return base.VerifyClsCompliance (parent_enum);
|
||||
}
|
||||
|
||||
// There is no base type
|
||||
protected override void VerifyObsoleteAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
public override string DocCommentHeader {
|
||||
get { return "F:"; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration container
|
||||
/// </summary>
|
||||
public class Enum : DeclSpace {
|
||||
public ArrayList ordered_enums;
|
||||
|
||||
public Expression BaseType;
|
||||
|
||||
public Type UnderlyingType;
|
||||
|
||||
Hashtable member_to_location;
|
||||
|
||||
//
|
||||
// This is for members that have been defined
|
||||
//
|
||||
Hashtable member_to_value;
|
||||
|
||||
//
|
||||
// This is used to mark members we're currently defining
|
||||
//
|
||||
Hashtable in_transit;
|
||||
|
||||
ArrayList field_builders;
|
||||
|
||||
public const int AllowedModifiers =
|
||||
Modifiers.NEW |
|
||||
Modifiers.PUBLIC |
|
||||
Modifiers.PROTECTED |
|
||||
Modifiers.INTERNAL |
|
||||
Modifiers.PRIVATE;
|
||||
|
||||
public Enum (NamespaceEntry ns, TypeContainer parent, Expression type,
|
||||
int mod_flags, MemberName name, Attributes attrs, Location l)
|
||||
: base (ns, parent, name, attrs, l)
|
||||
{
|
||||
this.BaseType = type;
|
||||
ModFlags = Modifiers.Check (AllowedModifiers, mod_flags,
|
||||
IsTopLevel ? Modifiers.INTERNAL : Modifiers.PRIVATE, l);
|
||||
|
||||
ordered_enums = new ArrayList ();
|
||||
member_to_location = new Hashtable ();
|
||||
member_to_value = new Hashtable ();
|
||||
in_transit = new Hashtable ();
|
||||
field_builders = new ArrayList ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds @name to the enumeration space, with @expr
|
||||
/// being its definition.
|
||||
/// </summary>
|
||||
public void AddEnumMember (string name, Expression expr, Location loc, Attributes opt_attrs, string documentation)
|
||||
{
|
||||
if (name == "value__") {
|
||||
Report.Error (76, loc, "An item in an enumeration can't have an identifier `value__'");
|
||||
return;
|
||||
}
|
||||
|
||||
EnumMember em = new EnumMember (this, expr, name, loc, opt_attrs);
|
||||
em.DocComment = documentation;
|
||||
if (!AddToContainer (em, name, ""))
|
||||
return;
|
||||
|
||||
|
||||
// TODO: can be almost deleted
|
||||
ordered_enums.Add (name);
|
||||
member_to_location.Add (name, loc);
|
||||
}
|
||||
|
||||
//
|
||||
// This is used by corlib compilation: we map from our
|
||||
// type to a type that is consumable by the DefineField
|
||||
//
|
||||
Type MapToInternalType (Type t)
|
||||
{
|
||||
if (t == TypeManager.int32_type)
|
||||
return typeof (int);
|
||||
if (t == TypeManager.int64_type)
|
||||
return typeof (long);
|
||||
if (t == TypeManager.uint32_type)
|
||||
return typeof (uint);
|
||||
if (t == TypeManager.uint64_type)
|
||||
return typeof (ulong);
|
||||
if (t == TypeManager.float_type)
|
||||
return typeof (float);
|
||||
if (t == TypeManager.double_type)
|
||||
return typeof (double);
|
||||
if (t == TypeManager.byte_type)
|
||||
return typeof (byte);
|
||||
if (t == TypeManager.sbyte_type)
|
||||
return typeof (sbyte);
|
||||
if (t == TypeManager.char_type)
|
||||
return typeof (char);
|
||||
if (t == TypeManager.short_type)
|
||||
return typeof (short);
|
||||
if (t == TypeManager.ushort_type)
|
||||
return typeof (ushort);
|
||||
|
||||
throw new Exception ();
|
||||
}
|
||||
|
||||
public override TypeBuilder DefineType ()
|
||||
{
|
||||
if (TypeBuilder != null)
|
||||
return TypeBuilder;
|
||||
|
||||
TypeAttributes attr = Modifiers.TypeAttr (ModFlags, IsTopLevel);
|
||||
|
||||
ec = new EmitContext (this, this, Location, null, null, ModFlags, false);
|
||||
|
||||
attr |= TypeAttributes.Class | TypeAttributes.Sealed;
|
||||
|
||||
if (!(BaseType is TypeLookupExpression)) {
|
||||
Report.Error (1008, Location,
|
||||
"Type byte, sbyte, short, ushort, int, uint, " +
|
||||
"long, or ulong expected (got: `{0}')", BaseType);
|
||||
return null;
|
||||
}
|
||||
|
||||
TypeExpr ute = ResolveBaseTypeExpr (BaseType, false, Location);
|
||||
if (ute == null)
|
||||
return null;
|
||||
|
||||
UnderlyingType = ute.Type;
|
||||
|
||||
if (UnderlyingType != TypeManager.int32_type &&
|
||||
UnderlyingType != TypeManager.uint32_type &&
|
||||
UnderlyingType != TypeManager.int64_type &&
|
||||
UnderlyingType != TypeManager.uint64_type &&
|
||||
UnderlyingType != TypeManager.short_type &&
|
||||
UnderlyingType != TypeManager.ushort_type &&
|
||||
UnderlyingType != TypeManager.byte_type &&
|
||||
UnderlyingType != TypeManager.sbyte_type) {
|
||||
Report.Error (1008, Location,
|
||||
"Type byte, sbyte, short, ushort, int, uint, " +
|
||||
"long, or ulong expected (got: " +
|
||||
TypeManager.CSharpName (UnderlyingType) + ")");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (IsTopLevel) {
|
||||
if (TypeManager.NamespaceClash (Name, Location))
|
||||
return null;
|
||||
|
||||
ModuleBuilder builder = CodeGen.Module.Builder;
|
||||
|
||||
TypeBuilder = builder.DefineType (Name, attr, TypeManager.enum_type);
|
||||
} else {
|
||||
TypeBuilder builder = Parent.TypeBuilder;
|
||||
|
||||
TypeBuilder = builder.DefineNestedType (
|
||||
Basename, attr, TypeManager.enum_type);
|
||||
}
|
||||
|
||||
//
|
||||
// Call MapToInternalType for corlib
|
||||
//
|
||||
TypeBuilder.DefineField ("value__", UnderlyingType,
|
||||
FieldAttributes.Public | FieldAttributes.SpecialName
|
||||
| FieldAttributes.RTSpecialName);
|
||||
|
||||
TypeManager.AddEnumType (Name, TypeBuilder, this);
|
||||
|
||||
return TypeBuilder;
|
||||
}
|
||||
|
||||
bool IsValidEnumConstant (Expression e)
|
||||
{
|
||||
if (!(e is Constant))
|
||||
return false;
|
||||
|
||||
if (e is IntConstant || e is UIntConstant || e is LongConstant ||
|
||||
e is ByteConstant || e is SByteConstant || e is ShortConstant ||
|
||||
e is UShortConstant || e is ULongConstant || e is EnumConstant ||
|
||||
e is CharConstant)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
object GetNextDefaultValue (object default_value)
|
||||
{
|
||||
if (UnderlyingType == TypeManager.int32_type) {
|
||||
int i = (int) default_value;
|
||||
|
||||
if (i < System.Int32.MaxValue)
|
||||
return ++i;
|
||||
else
|
||||
return null;
|
||||
} else if (UnderlyingType == TypeManager.uint32_type) {
|
||||
uint i = (uint) default_value;
|
||||
|
||||
if (i < System.UInt32.MaxValue)
|
||||
return ++i;
|
||||
else
|
||||
return null;
|
||||
} else if (UnderlyingType == TypeManager.int64_type) {
|
||||
long i = (long) default_value;
|
||||
|
||||
if (i < System.Int64.MaxValue)
|
||||
return ++i;
|
||||
else
|
||||
return null;
|
||||
} else if (UnderlyingType == TypeManager.uint64_type) {
|
||||
ulong i = (ulong) default_value;
|
||||
|
||||
if (i < System.UInt64.MaxValue)
|
||||
return ++i;
|
||||
else
|
||||
return null;
|
||||
} else if (UnderlyingType == TypeManager.short_type) {
|
||||
short i = (short) default_value;
|
||||
|
||||
if (i < System.Int16.MaxValue)
|
||||
return ++i;
|
||||
else
|
||||
return null;
|
||||
} else if (UnderlyingType == TypeManager.ushort_type) {
|
||||
ushort i = (ushort) default_value;
|
||||
|
||||
if (i < System.UInt16.MaxValue)
|
||||
return ++i;
|
||||
else
|
||||
return null;
|
||||
} else if (UnderlyingType == TypeManager.byte_type) {
|
||||
byte i = (byte) default_value;
|
||||
|
||||
if (i < System.Byte.MaxValue)
|
||||
return ++i;
|
||||
else
|
||||
return null;
|
||||
} else if (UnderlyingType == TypeManager.sbyte_type) {
|
||||
sbyte i = (sbyte) default_value;
|
||||
|
||||
if (i < System.SByte.MaxValue)
|
||||
return ++i;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
void Error_ConstantValueCannotBeConverted (object val, Location loc)
|
||||
{
|
||||
if (val is Constant)
|
||||
Report.Error (31, loc, "Constant value '" + ((Constant) val).AsString () +
|
||||
"' cannot be converted" +
|
||||
" to a " + TypeManager.CSharpName (UnderlyingType));
|
||||
else
|
||||
Report.Error (31, loc, "Constant value '" + val +
|
||||
"' cannot be converted" +
|
||||
" to a " + TypeManager.CSharpName (UnderlyingType));
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if a standard implicit conversion exists from
|
||||
/// expr_type to target_type
|
||||
/// </summary>
|
||||
public static bool WideningConversionExists (Type expr_type, Type target_type)
|
||||
{
|
||||
expr_type = TypeManager.TypeToCoreType (expr_type);
|
||||
|
||||
if (expr_type == TypeManager.void_type)
|
||||
return false;
|
||||
|
||||
if (expr_type == target_type)
|
||||
return true;
|
||||
|
||||
// First numeric conversions
|
||||
|
||||
if (expr_type == TypeManager.sbyte_type){
|
||||
//
|
||||
// From sbyte to short, int, long, float, double.
|
||||
//
|
||||
if ((target_type == TypeManager.int32_type) ||
|
||||
(target_type == TypeManager.int64_type) ||
|
||||
(target_type == TypeManager.double_type) ||
|
||||
(target_type == TypeManager.float_type) ||
|
||||
(target_type == TypeManager.short_type) ||
|
||||
(target_type == TypeManager.decimal_type))
|
||||
return true;
|
||||
|
||||
} else if (expr_type == TypeManager.byte_type){
|
||||
//
|
||||
// From byte to short, ushort, int, uint, long, ulong, float, double
|
||||
//
|
||||
if ((target_type == TypeManager.short_type) ||
|
||||
(target_type == TypeManager.ushort_type) ||
|
||||
(target_type == TypeManager.int32_type) ||
|
||||
(target_type == TypeManager.uint32_type) ||
|
||||
(target_type == TypeManager.uint64_type) ||
|
||||
(target_type == TypeManager.int64_type) ||
|
||||
(target_type == TypeManager.float_type) ||
|
||||
(target_type == TypeManager.double_type) ||
|
||||
(target_type == TypeManager.decimal_type))
|
||||
return true;
|
||||
|
||||
} else if (expr_type == TypeManager.short_type){
|
||||
//
|
||||
// From short to int, long, float, double
|
||||
//
|
||||
if ((target_type == TypeManager.int32_type) ||
|
||||
(target_type == TypeManager.int64_type) ||
|
||||
(target_type == TypeManager.double_type) ||
|
||||
(target_type == TypeManager.float_type) ||
|
||||
(target_type == TypeManager.decimal_type))
|
||||
return true;
|
||||
|
||||
} else if (expr_type == TypeManager.ushort_type){
|
||||
//
|
||||
// From ushort to int, uint, long, ulong, float, double
|
||||
//
|
||||
if ((target_type == TypeManager.uint32_type) ||
|
||||
(target_type == TypeManager.uint64_type) ||
|
||||
(target_type == TypeManager.int32_type) ||
|
||||
(target_type == TypeManager.int64_type) ||
|
||||
(target_type == TypeManager.double_type) ||
|
||||
(target_type == TypeManager.float_type) ||
|
||||
(target_type == TypeManager.decimal_type))
|
||||
return true;
|
||||
|
||||
} else if (expr_type == TypeManager.int32_type){
|
||||
//
|
||||
// From int to long, float, double
|
||||
//
|
||||
if ((target_type == TypeManager.int64_type) ||
|
||||
(target_type == TypeManager.double_type) ||
|
||||
(target_type == TypeManager.float_type) ||
|
||||
(target_type == TypeManager.decimal_type))
|
||||
return true;
|
||||
|
||||
} else if (expr_type == TypeManager.uint32_type){
|
||||
//
|
||||
// From uint to long, ulong, float, double
|
||||
//
|
||||
if ((target_type == TypeManager.int64_type) ||
|
||||
(target_type == TypeManager.uint64_type) ||
|
||||
(target_type == TypeManager.double_type) ||
|
||||
(target_type == TypeManager.float_type) ||
|
||||
(target_type == TypeManager.decimal_type))
|
||||
return true;
|
||||
|
||||
} else if ((expr_type == TypeManager.uint64_type) ||
|
||||
(expr_type == TypeManager.int64_type)) {
|
||||
//
|
||||
// From long/ulong to float, double
|
||||
//
|
||||
if ((target_type == TypeManager.double_type) ||
|
||||
(target_type == TypeManager.float_type) ||
|
||||
(target_type == TypeManager.decimal_type))
|
||||
return true;
|
||||
|
||||
} else if (expr_type == TypeManager.char_type){
|
||||
//
|
||||
// From char to ushort, int, uint, long, ulong, float, double
|
||||
//
|
||||
if ((target_type == TypeManager.ushort_type) ||
|
||||
(target_type == TypeManager.int32_type) ||
|
||||
(target_type == TypeManager.uint32_type) ||
|
||||
(target_type == TypeManager.uint64_type) ||
|
||||
(target_type == TypeManager.int64_type) ||
|
||||
(target_type == TypeManager.float_type) ||
|
||||
(target_type == TypeManager.double_type) ||
|
||||
(target_type == TypeManager.decimal_type))
|
||||
return true;
|
||||
|
||||
} else if (expr_type == TypeManager.float_type){
|
||||
//
|
||||
// float to double
|
||||
//
|
||||
if (target_type == TypeManager.double_type)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Horrible, horrible. But there is no other way we can pass the EmitContext
|
||||
// to the recursive definition triggered by the evaluation of a forward
|
||||
// expression
|
||||
//
|
||||
static EmitContext current_ec = null;
|
||||
|
||||
/// <summary>
|
||||
/// This is used to lookup the value of an enum member. If the member is undefined,
|
||||
/// it attempts to define it and return its value
|
||||
/// </summary>
|
||||
public object LookupEnumValue (EmitContext ec, string name, Location loc)
|
||||
{
|
||||
|
||||
object default_value = null;
|
||||
Constant c = null;
|
||||
|
||||
default_value = member_to_value [name];
|
||||
|
||||
if (default_value != null)
|
||||
return default_value;
|
||||
|
||||
//
|
||||
// This may happen if we're calling a method in System.Enum, for instance
|
||||
// Enum.IsDefined().
|
||||
//
|
||||
if (!defined_names.Contains (name))
|
||||
return null;
|
||||
|
||||
if (in_transit.Contains (name)) {
|
||||
Report.Error (110, loc, "The evaluation of the constant value for `" +
|
||||
Name + "." + name + "' involves a circular definition.");
|
||||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
// So if the above doesn't happen, we have a member that is undefined
|
||||
// We now proceed to define it
|
||||
//
|
||||
Expression val = this [name];
|
||||
|
||||
if (val == null) {
|
||||
|
||||
int idx = ordered_enums.IndexOf (name);
|
||||
|
||||
if (idx == 0)
|
||||
default_value = 0;
|
||||
else {
|
||||
for (int i = 0; i < idx; ++i) {
|
||||
string n = (string) ordered_enums [i];
|
||||
Location m_loc = (Mono.CSharp.Location)
|
||||
member_to_location [n];
|
||||
in_transit.Add (name, true);
|
||||
|
||||
EmitContext old_ec = current_ec;
|
||||
current_ec = ec;
|
||||
|
||||
default_value = LookupEnumValue (ec, n, m_loc);
|
||||
|
||||
current_ec = old_ec;
|
||||
|
||||
in_transit.Remove (name);
|
||||
if (default_value == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
default_value = GetNextDefaultValue (default_value);
|
||||
}
|
||||
|
||||
} else {
|
||||
bool old = ec.InEnumContext;
|
||||
ec.InEnumContext = true;
|
||||
in_transit.Add (name, true);
|
||||
|
||||
EmitContext old_ec = current_ec;
|
||||
current_ec = ec;
|
||||
val = val.Resolve (ec);
|
||||
current_ec = old_ec;
|
||||
|
||||
in_transit.Remove (name);
|
||||
ec.InEnumContext = old;
|
||||
|
||||
if (val == null)
|
||||
return null;
|
||||
|
||||
if (!IsValidEnumConstant (val)) {
|
||||
Report.Error (
|
||||
1008, loc,
|
||||
"Type byte, sbyte, short, ushort, int, uint, long, or " +
|
||||
"ulong expected (have: " + val + ")");
|
||||
return null;
|
||||
}
|
||||
|
||||
c = (Constant) val;
|
||||
default_value = c.GetValue ();
|
||||
|
||||
if (default_value == null) {
|
||||
Error_ConstantValueCannotBeConverted (c, loc);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (val is EnumConstant){
|
||||
Type etype = TypeManager.EnumToUnderlying (c.Type);
|
||||
|
||||
if (!WideningConversionExists (etype, UnderlyingType)){
|
||||
Convert.Error_CannotWideningConversion (
|
||||
loc, c.Type, UnderlyingType);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EnumMember em = (EnumMember) defined_names [name];
|
||||
em.DefineMember (TypeBuilder);
|
||||
|
||||
bool fail;
|
||||
default_value = TypeManager.ChangeType (default_value, UnderlyingType, out fail);
|
||||
if (fail){
|
||||
Error_ConstantValueCannotBeConverted (c, loc);
|
||||
return null;
|
||||
}
|
||||
|
||||
em.builder.SetConstant (default_value);
|
||||
field_builders.Add (em.builder);
|
||||
member_to_value [name] = default_value;
|
||||
|
||||
if (!TypeManager.RegisterFieldValue (em.builder, default_value))
|
||||
return null;
|
||||
|
||||
return default_value;
|
||||
}
|
||||
|
||||
public override bool DefineMembers (TypeContainer parent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Define ()
|
||||
{
|
||||
//
|
||||
// If there was an error during DefineEnum, return
|
||||
//
|
||||
if (TypeBuilder == null)
|
||||
return false;
|
||||
|
||||
ec = new EmitContext (this, this, Location, null, UnderlyingType, ModFlags, false);
|
||||
|
||||
object default_value = 0;
|
||||
|
||||
|
||||
foreach (string name in ordered_enums) {
|
||||
//
|
||||
// Have we already been defined, thanks to some cross-referencing ?
|
||||
//
|
||||
if (member_to_value.Contains (name))
|
||||
continue;
|
||||
|
||||
Location loc = (Mono.CSharp.Location) member_to_location [name];
|
||||
|
||||
if (this [name] != null) {
|
||||
default_value = LookupEnumValue (ec, name, loc);
|
||||
|
||||
if (default_value == null)
|
||||
return true;
|
||||
} else {
|
||||
if (name == "value__"){
|
||||
Report.Error (76, loc, "The name `value__' is reserved for enumerations");
|
||||
return false;
|
||||
}
|
||||
|
||||
EnumMember em = (EnumMember) defined_names [name];
|
||||
|
||||
em.DefineMember (TypeBuilder);
|
||||
FieldBuilder fb = em.builder;
|
||||
|
||||
if (default_value == null) {
|
||||
Report.Error (543, loc, "Enumerator value for '" + name + "' is too large to " +
|
||||
"fit in its type");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool fail;
|
||||
default_value = TypeManager.ChangeType (default_value, UnderlyingType, out fail);
|
||||
if (fail){
|
||||
Error_ConstantValueCannotBeConverted (default_value, loc);
|
||||
return false;
|
||||
}
|
||||
|
||||
fb.SetConstant (default_value);
|
||||
field_builders.Add (fb);
|
||||
member_to_value [name] = default_value;
|
||||
|
||||
if (!TypeManager.RegisterFieldValue (fb, default_value))
|
||||
return false;
|
||||
}
|
||||
|
||||
default_value = GetNextDefaultValue (default_value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Emit ()
|
||||
{
|
||||
if (OptAttributes != null) {
|
||||
OptAttributes.Emit (ec, this);
|
||||
}
|
||||
|
||||
foreach (EnumMember em in defined_names.Values) {
|
||||
em.Emit (ec);
|
||||
}
|
||||
|
||||
base.Emit ();
|
||||
}
|
||||
|
||||
void VerifyClsName ()
|
||||
{
|
||||
Hashtable ht = new Hashtable ();
|
||||
foreach (string name in ordered_enums) {
|
||||
string locase = name.ToLower (System.Globalization.CultureInfo.InvariantCulture);
|
||||
if (!ht.Contains (locase)) {
|
||||
ht.Add (locase, defined_names [name]);
|
||||
continue;
|
||||
}
|
||||
|
||||
MemberCore conflict = (MemberCore)ht [locase];
|
||||
Report.SymbolRelatedToPreviousError (conflict);
|
||||
conflict = GetDefinition (name);
|
||||
Report.Error (3005, conflict.Location, "Identifier '{0}' differing only in case is not CLS-compliant", conflict.GetSignatureForError ());
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool VerifyClsCompliance (DeclSpace ds)
|
||||
{
|
||||
if (!base.VerifyClsCompliance (ds))
|
||||
return false;
|
||||
|
||||
VerifyClsName ();
|
||||
|
||||
if (!AttributeTester.IsClsCompliant (UnderlyingType)) {
|
||||
Report.Error (3009, Location, "'{0}': base type '{1}' is not CLS-compliant", GetSignatureForError (), TypeManager.CSharpName (UnderlyingType));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns full enum name.
|
||||
/// </summary>
|
||||
string GetEnumeratorName (string valueName)
|
||||
{
|
||||
return String.Concat (Name, ".", valueName);
|
||||
}
|
||||
|
||||
//
|
||||
// IMemberFinder
|
||||
//
|
||||
public override MemberList FindMembers (MemberTypes mt, BindingFlags bf,
|
||||
MemberFilter filter, object criteria)
|
||||
{
|
||||
ArrayList members = new ArrayList ();
|
||||
|
||||
if ((mt & MemberTypes.Field) != 0) {
|
||||
if (criteria is string){
|
||||
if (member_to_value [criteria] == null && current_ec != null){
|
||||
LookupEnumValue (current_ec, (string) criteria, Location.Null);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (FieldBuilder fb in field_builders)
|
||||
if (filter (fb, criteria) == true)
|
||||
members.Add (fb);
|
||||
}
|
||||
|
||||
return new MemberList (members);
|
||||
}
|
||||
|
||||
public override MemberCache MemberCache {
|
||||
get {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList ValueNames {
|
||||
get {
|
||||
return ordered_enums;
|
||||
}
|
||||
}
|
||||
|
||||
// indexer
|
||||
public Expression this [string name] {
|
||||
get {
|
||||
return ((EnumMember) defined_names [name]).Type;
|
||||
}
|
||||
}
|
||||
|
||||
public override AttributeTargets AttributeTargets {
|
||||
get {
|
||||
return AttributeTargets.Enum;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void VerifyObsoleteAttribute()
|
||||
{
|
||||
// UnderlyingType is never obsolete
|
||||
}
|
||||
|
||||
//
|
||||
// Generates xml doc comments (if any), and if required,
|
||||
// handle warning report.
|
||||
//
|
||||
internal override void GenerateDocComment (DeclSpace ds)
|
||||
{
|
||||
DocUtil.GenerateEnumDocComment (this, ds);
|
||||
}
|
||||
|
||||
//
|
||||
// Represents header string for documentation comment.
|
||||
//
|
||||
public override string DocCommentHeader {
|
||||
get { return "T:"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
// gen-il.cs: Generates MSIL code from the CIR.Tree
|
||||
//
|
||||
// Author: Miguel de Icaza ([email protected])
|
||||
//
|
||||
// Licensed under the terms of the GNU GPL
|
||||
//
|
||||
// (C) 2001 Ximian, Inc. (http://www.ximian.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using CIR;
|
||||
|
||||
namespace MSIL {
|
||||
|
||||
public class Generator : CIR.ITreeDump {
|
||||
StreamWriter o;
|
||||
int indent = 0;
|
||||
|
||||
void output (string s)
|
||||
{
|
||||
Console.Write (s);
|
||||
o.Write (s);
|
||||
}
|
||||
|
||||
void space ()
|
||||
{
|
||||
output (new String (' ', indent * 2));
|
||||
}
|
||||
|
||||
void ioutput (string s)
|
||||
{
|
||||
space ();
|
||||
output (s);
|
||||
}
|
||||
|
||||
void ioutputl (string s)
|
||||
{
|
||||
ioutput (s + "\n");
|
||||
}
|
||||
|
||||
string ClassAttributes (Class c)
|
||||
{
|
||||
// FIXME
|
||||
return "";
|
||||
}
|
||||
|
||||
string ILName (string name)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
string ClassExtends (Class c)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void GenerateFromClass (Class c)
|
||||
{
|
||||
ioutputl (".class " + ClassAttributes (c) + " " + ILName (c.Name));
|
||||
ioutputl (ClassExtends (c));
|
||||
ioutputl ("{");
|
||||
indent++;
|
||||
|
||||
|
||||
|
||||
indent--;
|
||||
ioutputl ("}");
|
||||
}
|
||||
|
||||
void GenerateFromTypes (TypeContainer types)
|
||||
{
|
||||
if (types.Types == null)
|
||||
return;
|
||||
|
||||
foreach (DictionaryEntry de in types.Types){
|
||||
TypeContainer type = (TypeContainer) de.Value;
|
||||
|
||||
if (type is Class)
|
||||
GenerateFromClass ((Class) type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int GenerateFromTree (Tree tree, StreamWriter os)
|
||||
{
|
||||
this.o = os;
|
||||
|
||||
ioutputl (".assembly test.exe { }");
|
||||
GenerateFromTypes (tree.Types);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void ParseOptions (string options)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,988 @@
|
||||
// cs-treedump.cs: Dumps the parsed tree to standard output
|
||||
//
|
||||
// Author: Miguel de Icaza ([email protected])
|
||||
//
|
||||
// Licensed under the terms of the GNU GPL
|
||||
//
|
||||
// (C) 2001 Ximian, Inc. (http://www.ximian.com)
|
||||
//
|
||||
// TODO:
|
||||
// Variable declarations
|
||||
// Fix precedence rules to lower the number of parenthesis.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using CIR;
|
||||
|
||||
namespace Generator {
|
||||
|
||||
public class TreeDump : CIR.ITreeDump {
|
||||
StreamWriter o;
|
||||
int indent;
|
||||
bool indented;
|
||||
bool tag_values;
|
||||
|
||||
void space ()
|
||||
{
|
||||
if (!indented)
|
||||
output (new String (' ', indent * 8));
|
||||
indented = true;
|
||||
}
|
||||
|
||||
void output (string s)
|
||||
{
|
||||
Console.Write (s);
|
||||
//o.Write (s);
|
||||
}
|
||||
|
||||
void newline ()
|
||||
{
|
||||
output ("\n");
|
||||
indented = false;
|
||||
}
|
||||
|
||||
void output_newline (string s)
|
||||
{
|
||||
output (s);
|
||||
newline ();
|
||||
}
|
||||
|
||||
void ioutput (string s)
|
||||
{
|
||||
space ();
|
||||
output (s);
|
||||
}
|
||||
|
||||
string GetParameter (Parameter par)
|
||||
{
|
||||
Parameter.Modifier f = par.ModFlags;
|
||||
string mod = "";
|
||||
|
||||
switch (f){
|
||||
case Parameter.Modifier.REF:
|
||||
mod = "ref "; break;
|
||||
case Parameter.Modifier.OUT:
|
||||
mod = "out "; break;
|
||||
case Parameter.Modifier.PARAMS:
|
||||
mod = "params "; break;
|
||||
case Parameter.Modifier.NONE:
|
||||
mod = ""; break;
|
||||
}
|
||||
return mod + par.Type + " " + par.Name;
|
||||
}
|
||||
|
||||
string GetUnary (Unary u, int paren_level)
|
||||
{
|
||||
string e;
|
||||
bool left = true;
|
||||
string s = "0_ERROR>";
|
||||
int prec = 0;
|
||||
|
||||
switch (u.Oper){
|
||||
case Unary.Operator.UnaryPlus:
|
||||
prec = 10;
|
||||
s = "+";
|
||||
break;
|
||||
|
||||
case Unary.Operator.UnaryNegation:
|
||||
prec = 10;
|
||||
s = "-";
|
||||
break;
|
||||
|
||||
case Unary.Operator.LogicalNot:
|
||||
s = "!";
|
||||
prec = 10;
|
||||
break;
|
||||
|
||||
case Unary.Operator.OnesComplement:
|
||||
prec = 10;
|
||||
s = "~";
|
||||
break;
|
||||
|
||||
case Unary.Operator.Indirection:
|
||||
prec = 10;
|
||||
s = "*";
|
||||
break;
|
||||
|
||||
case Unary.Operator.AddressOf:
|
||||
prec = 10;
|
||||
s = "&";
|
||||
break;
|
||||
|
||||
case Unary.Operator.PreIncrement:
|
||||
prec = 11;
|
||||
s = "++";
|
||||
break;
|
||||
|
||||
case Unary.Operator.PreDecrement:
|
||||
prec = 11;
|
||||
s = "--";
|
||||
break;
|
||||
|
||||
case Unary.Operator.PostDecrement:
|
||||
left = false;
|
||||
prec = 12;
|
||||
s = "--";
|
||||
break;
|
||||
|
||||
case Unary.Operator.PostIncrement:
|
||||
s = "++";
|
||||
prec = 12;
|
||||
left = false;
|
||||
break;
|
||||
}
|
||||
|
||||
e = GetExpression (u.Expr, prec);
|
||||
if (left)
|
||||
e = s + e;
|
||||
else
|
||||
e = e + s;
|
||||
|
||||
if (prec < paren_level)
|
||||
return "(" + e + ")";
|
||||
else
|
||||
return e;
|
||||
}
|
||||
|
||||
string GetBinary (Binary b, int paren_level)
|
||||
{
|
||||
string l, r;
|
||||
string op = null;
|
||||
bool assoc_left = true;
|
||||
int prec = 0;
|
||||
|
||||
switch (b.Oper){
|
||||
case Binary.Operator.Multiply:
|
||||
prec = 9;
|
||||
op = "*"; break;
|
||||
|
||||
case Binary.Operator.Division:
|
||||
prec = 9;
|
||||
op = "/"; break;
|
||||
|
||||
case Binary.Operator.Modulus:
|
||||
prec = 9;
|
||||
op = "%"; break;
|
||||
|
||||
case Binary.Operator.Addition:
|
||||
prec = 8;
|
||||
op = "+"; break;
|
||||
|
||||
case Binary.Operator.Subtraction:
|
||||
prec = 8;
|
||||
op = "-"; break;
|
||||
|
||||
case Binary.Operator.LeftShift:
|
||||
prec = 7;
|
||||
op = "<<"; break;
|
||||
|
||||
case Binary.Operator.RightShift:
|
||||
prec = 7;
|
||||
op = ">>"; break;
|
||||
|
||||
case Binary.Operator.LessThan:
|
||||
prec = 6;
|
||||
op = "<"; break;
|
||||
|
||||
case Binary.Operator.GreaterThan:
|
||||
prec = 6;
|
||||
op = ">"; break;
|
||||
|
||||
case Binary.Operator.LessThanOrEqual:
|
||||
prec = 6;
|
||||
op = "<="; break;
|
||||
|
||||
case Binary.Operator.GreaterThanOrEqual:
|
||||
prec = 6;
|
||||
op = ">="; break;
|
||||
|
||||
case Binary.Operator.Equality:
|
||||
prec = 5;
|
||||
op = "=="; break;
|
||||
|
||||
case Binary.Operator.Inequality:
|
||||
prec = 5;
|
||||
op = "!="; break;
|
||||
|
||||
case Binary.Operator.BitwiseAnd:
|
||||
prec = 4;
|
||||
op = "&"; break;
|
||||
|
||||
case Binary.Operator.BitwiseOr:
|
||||
prec = 2;
|
||||
op = "|"; break;
|
||||
|
||||
case Binary.Operator.LogicalAndAlso:
|
||||
prec = 1;
|
||||
op = "AndAlso"; break;
|
||||
|
||||
case Binary.Operator.LogicalOrElse:
|
||||
prec = 0;
|
||||
op = "OrElse"; break;
|
||||
|
||||
case Binary.Operator.ExclusiveOr:
|
||||
prec = 3;
|
||||
op = "^"; break;
|
||||
}
|
||||
|
||||
l = GetExpression (b.Left, prec - (assoc_left ? 0 : 1));
|
||||
r = GetExpression (b.Right, prec - (assoc_left ? 0 : 1));
|
||||
|
||||
if (prec <= paren_level)
|
||||
return "(" + l + " " + op + " " + r + ")";
|
||||
else
|
||||
return l + " " + op + " " + r;
|
||||
}
|
||||
|
||||
string GetCast (Cast c)
|
||||
{
|
||||
return "(" + c.TargetType + ") (" + GetExpression (c.Expr, 0) + ")";
|
||||
}
|
||||
|
||||
string GetConditional (Conditional c)
|
||||
{
|
||||
return "(" + GetExpression (c.Expr, 0) + ") ? (" +
|
||||
GetExpression (c.TrueExpr, 0) + ") : (" +
|
||||
GetExpression (c.FalseExpr, 0) + ")";
|
||||
}
|
||||
|
||||
string GetAssign (Assign a)
|
||||
{
|
||||
return GetExpression (a.Target, 0) + " = " + GetExpression (a.Source, 0);
|
||||
}
|
||||
|
||||
string GetArguments (ArrayList args)
|
||||
{
|
||||
string r = "";
|
||||
|
||||
if (args != null){
|
||||
int top = args.Count;
|
||||
|
||||
for (int i = 0; i < top; i++){
|
||||
Argument arg = (Argument) args [i];
|
||||
|
||||
switch (arg.ArgType){
|
||||
case Argument.AType.Ref:
|
||||
r += "ref "; break;
|
||||
case Argument.AType.Out:
|
||||
r += "out "; break;
|
||||
}
|
||||
r += GetExpression (arg.Expr, 0);
|
||||
|
||||
if (i+1 != top)
|
||||
r += ", ";
|
||||
}
|
||||
}
|
||||
|
||||
return "(" + r + ")";
|
||||
}
|
||||
|
||||
string GetInvocation (Invocation i)
|
||||
{
|
||||
return GetExpression (i.Expr, 0) + " " + GetArguments (i.Arguments);
|
||||
}
|
||||
|
||||
string GetNew (New n)
|
||||
{
|
||||
return "new " + n.RequestedType + GetArguments (n.Arguments);
|
||||
}
|
||||
|
||||
string GetTypeOf (TypeOf t)
|
||||
{
|
||||
return "typeof (" + t.QueriedType + ")";
|
||||
}
|
||||
|
||||
string GetSizeOf (SizeOf t)
|
||||
{
|
||||
return "sizeof (" + t.QueriedType + ")";
|
||||
}
|
||||
|
||||
string GetMemberAccess (MemberAccess m)
|
||||
{
|
||||
return GetExpression (m.Expr, 0) +
|
||||
(tag_values ? "/* member access */ . " : ".") +
|
||||
m.Identifier;
|
||||
}
|
||||
|
||||
string GetSimpleName (SimpleName n)
|
||||
{
|
||||
string s = n.Name;
|
||||
|
||||
if (s.StartsWith ("0_"))
|
||||
return "id_" + s;
|
||||
else
|
||||
return s;
|
||||
}
|
||||
|
||||
string GetProbe (Probe p)
|
||||
{
|
||||
string s = GetExpression (p.Expr, 6);
|
||||
|
||||
if (p.Oper == CIR.Probe.Operator.Is)
|
||||
s += " is ";
|
||||
else if (p.Oper == CIR.Probe.Operator.As)
|
||||
s += " as ";
|
||||
else
|
||||
s += "UNHANDLED";
|
||||
|
||||
s += p.ProbeType;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
string GetLocalVariableReference (LocalVariableReference l)
|
||||
{
|
||||
if (tag_values)
|
||||
return "/* local var: */" + l.Name;
|
||||
else
|
||||
return l.Name;
|
||||
}
|
||||
|
||||
string GetParameterReference (ParameterReference r)
|
||||
{
|
||||
if (tag_values)
|
||||
return "/* par: */ " + r.Name;
|
||||
else
|
||||
return r.Name;
|
||||
}
|
||||
|
||||
string GetExpression (Expression e, int paren_level)
|
||||
{
|
||||
if (e == null){
|
||||
return "<NULL EXPRESSION>";
|
||||
}
|
||||
|
||||
if (e is Unary)
|
||||
return GetUnary ((Unary) e, paren_level);
|
||||
else if (e is Binary)
|
||||
return GetBinary ((Binary) e, paren_level);
|
||||
else if (e is Cast)
|
||||
return GetCast ((Cast) e);
|
||||
else if (e is Conditional)
|
||||
return GetConditional ((Conditional) e);
|
||||
else if (e is SimpleName)
|
||||
return GetSimpleName ((SimpleName)e);
|
||||
else if (e is LocalVariableReference)
|
||||
return GetLocalVariableReference ((LocalVariableReference) e);
|
||||
else if (e is ParameterReference)
|
||||
return GetParameterReference ((ParameterReference) e);
|
||||
else if (e is Assign)
|
||||
return GetAssign ((Assign) e);
|
||||
else if (e is Literal)
|
||||
return e.ToString ();
|
||||
else if (e is Invocation)
|
||||
return GetInvocation ((Invocation) e);
|
||||
else if (e is New)
|
||||
return GetNew ((New) e);
|
||||
else if (e is This)
|
||||
return "this";
|
||||
else if (e is TypeOf)
|
||||
return GetTypeOf ((TypeOf) e);
|
||||
else if (e is SizeOf)
|
||||
return GetSizeOf ((SizeOf) e);
|
||||
else if (e is MemberAccess)
|
||||
return GetMemberAccess ((MemberAccess) e);
|
||||
else if (e is Probe)
|
||||
return GetProbe ((Probe) e);
|
||||
else
|
||||
return "WARNING {" + e.ToString () + "} WARNING";
|
||||
}
|
||||
|
||||
void GenerateParameters (Parameters pars)
|
||||
{
|
||||
Parameter [] pfixed;
|
||||
Parameter parray;
|
||||
|
||||
pfixed = pars.FixedParameters;
|
||||
|
||||
if (pfixed != null){
|
||||
for (int i = 0; i < pfixed.Length; i++){
|
||||
output (GetParameter (pfixed [i]));
|
||||
if (i+1 != pfixed.Length)
|
||||
output (", ");
|
||||
}
|
||||
}
|
||||
|
||||
parray = pars.ArrayParameter;
|
||||
if (parray != null){
|
||||
output (GetParameter (parray));
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateIf (If s)
|
||||
{
|
||||
bool do_indent;
|
||||
|
||||
output ("if (" + GetExpression (s.Expr, 0) + ") ");
|
||||
do_indent = !(s.TrueStatement is Block);
|
||||
if (do_indent)
|
||||
indent++;
|
||||
GenerateStatement (s.TrueStatement, true, false, false);
|
||||
if (do_indent)
|
||||
indent--;
|
||||
if (s.FalseStatement != null){
|
||||
ioutput ("else");
|
||||
newline ();
|
||||
GenerateStatement (s.FalseStatement, false, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateDo (Do s)
|
||||
{
|
||||
output ("do"); newline ();
|
||||
indent++;
|
||||
GenerateStatement (s.EmbeddedStatement, false, false, false);
|
||||
indent--;
|
||||
output (" while (" + GetExpression (s.Expr, 0) + ");");
|
||||
newline ();
|
||||
}
|
||||
|
||||
void GenerateWhile (While s)
|
||||
{
|
||||
output ("while (" + GetExpression (s.Expr, 0) + ")");
|
||||
GenerateStatement (s.Statement, true, true, false);
|
||||
}
|
||||
|
||||
void GenerateFor (For s)
|
||||
{
|
||||
output ("for (");
|
||||
if (! (s.InitStatement == EmptyStatement.Value))
|
||||
GenerateStatement (s.InitStatement, true, true, true);
|
||||
output ("; ");
|
||||
output (GetExpression (s.Test, 0));
|
||||
output ("; ");
|
||||
if (! (s.Increment == EmptyStatement.Value))
|
||||
GenerateStatement (s.Increment, true, true, true);
|
||||
output (") ");
|
||||
GenerateStatement (s.Statement, true, true, false);
|
||||
}
|
||||
|
||||
void GenerateReturn (Return s)
|
||||
{
|
||||
output ("return " +
|
||||
(s.Expr != null ?
|
||||
GetExpression (s.Expr, 0) : "" + ";") +
|
||||
";");
|
||||
newline ();
|
||||
}
|
||||
|
||||
void GenerateGoto (Goto s)
|
||||
{
|
||||
output ("goto " + s.Target + ";");
|
||||
newline ();
|
||||
}
|
||||
|
||||
void GenerateThrow (Throw s)
|
||||
{
|
||||
}
|
||||
|
||||
void GenerateStatementExpression (StatementExpression s)
|
||||
{
|
||||
output (GetExpression (s.Expr, 0) + ";");
|
||||
newline ();
|
||||
}
|
||||
|
||||
void GenerateSwitchLabels (ArrayList labels)
|
||||
{
|
||||
foreach (SwitchLabel sl in labels){
|
||||
Expression lab = sl.Label;
|
||||
|
||||
if (lab == null){
|
||||
ioutput ("default:");
|
||||
newline ();
|
||||
} else {
|
||||
ioutput ("case " + GetExpression (lab, 0) + ":");
|
||||
newline ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateSwitch (Switch s)
|
||||
{
|
||||
output_newline ("switch (" + GetExpression (s.Expr, 0) + ")");
|
||||
foreach (SwitchSection ss in s.Sections){
|
||||
GenerateSwitchLabels (ss.Labels);
|
||||
GenerateBlock (ss.Block, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateChecked (Checked c)
|
||||
{
|
||||
output ("checked ");
|
||||
GenerateBlock (c.Block, false, false);
|
||||
}
|
||||
|
||||
void GenerateUnchecked (Unchecked c)
|
||||
{
|
||||
output ("unchecked ");
|
||||
GenerateBlock (c.Block, false, false);
|
||||
}
|
||||
|
||||
void GenerateCatchClauses (ArrayList list)
|
||||
{
|
||||
foreach (Catch c in list){
|
||||
space ();
|
||||
output ("catch ");
|
||||
|
||||
if (c.Type != null){
|
||||
output ("(" + c.Type +
|
||||
(c.Name != null ? " " + c.Name : "") + ")");
|
||||
}
|
||||
GenerateBlock (c.Block, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateTry (Try t)
|
||||
{
|
||||
output ("try");
|
||||
GenerateBlock (t.Block, false, false);
|
||||
|
||||
if (t.Specific != null){
|
||||
GenerateCatchClauses (t.Specific);
|
||||
}
|
||||
|
||||
if (t.General != null){
|
||||
space ();
|
||||
output ("catch");
|
||||
GenerateBlock (t.Block, false, false);
|
||||
}
|
||||
|
||||
if (t.Fini != null){
|
||||
GenerateBlock (t.Fini, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateStatement (Statement s, bool doPlacement, bool blockFlushesLine, bool embedded)
|
||||
{
|
||||
if (s == null){
|
||||
output ("WARNING: got a null Statement");
|
||||
newline ();
|
||||
return;
|
||||
}
|
||||
|
||||
if (doPlacement){
|
||||
if (s is Block){
|
||||
GenerateBlock ((Block) s, doPlacement, embedded);
|
||||
return;
|
||||
} else
|
||||
newline ();
|
||||
}
|
||||
|
||||
space ();
|
||||
if (s is If)
|
||||
GenerateIf ((If) s);
|
||||
else if (s is Do)
|
||||
GenerateDo ((Do) s);
|
||||
else if (s is While)
|
||||
GenerateWhile ((While) s);
|
||||
else if (s is For)
|
||||
GenerateFor ((For) s);
|
||||
else if (s is Return)
|
||||
GenerateReturn ((Return) s);
|
||||
else if (s is Goto)
|
||||
GenerateGoto ((Goto) s);
|
||||
else if (s is Throw)
|
||||
GenerateThrow ((Throw) s);
|
||||
else if (s is Break)
|
||||
output_newline ("break;");
|
||||
else if (s is Continue)
|
||||
output_newline ("continue;");
|
||||
else if (s == EmptyStatement.Value)
|
||||
output_newline ("/* empty statement */;");
|
||||
else if (s is Block)
|
||||
GenerateBlock ((Block) s, doPlacement, embedded);
|
||||
else if (s is StatementExpression)
|
||||
GenerateStatementExpression ((StatementExpression) s);
|
||||
else if (s is Switch)
|
||||
GenerateSwitch ((Switch) s);
|
||||
else if (s is Checked)
|
||||
GenerateChecked ((Checked) s);
|
||||
else if (s is Unchecked)
|
||||
GenerateUnchecked ((Unchecked) s);
|
||||
else if (s is Try)
|
||||
GenerateTry ((Try) s);
|
||||
else {
|
||||
System.Type t = s.GetType ();
|
||||
|
||||
output ("\n*****UNKNOWN Statement:" + t.ToString ());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// embedded is used only for things like the For thing
|
||||
// that has blocks but for display purposes we want to keep
|
||||
// without newlines.
|
||||
void GenerateBlock (Block b, bool doPlacement, bool embedded)
|
||||
{
|
||||
if (b.Label != null)
|
||||
output (b.Label + ":");
|
||||
|
||||
if (!b.Implicit){
|
||||
if (!doPlacement)
|
||||
space ();
|
||||
|
||||
output ("{");
|
||||
if (!embedded)
|
||||
newline ();
|
||||
indent++;
|
||||
}
|
||||
|
||||
if (b.Variables != null){
|
||||
foreach (DictionaryEntry entry in b.Variables){
|
||||
VariableInfo vi = (VariableInfo) entry.Value;
|
||||
|
||||
space ();
|
||||
output_newline (
|
||||
vi.Type + " " +
|
||||
(string) entry.Key + ";");
|
||||
}
|
||||
newline ();
|
||||
}
|
||||
|
||||
foreach (Statement s in b.Statements){
|
||||
GenerateStatement (s, false, true, false);
|
||||
}
|
||||
|
||||
if (!b.Implicit){
|
||||
indent--;
|
||||
ioutput ("}");
|
||||
if (!embedded)
|
||||
newline ();
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateMethod (Method m)
|
||||
{
|
||||
ioutput (GetModifiers (m.ModFlags) +
|
||||
m.ReturnType + " " +
|
||||
m.Name + " (");
|
||||
GenerateParameters (m.Parameters);
|
||||
output_newline (")");
|
||||
|
||||
|
||||
GenerateBlock (m.Block, false, false);
|
||||
newline ();
|
||||
}
|
||||
|
||||
void GenerateInterfaceMethod (InterfaceMethod imethod)
|
||||
{
|
||||
space ();
|
||||
output (imethod.IsNew ? "new " : "");
|
||||
output (imethod.ReturnType + " " + imethod.Name + " (");
|
||||
GenerateParameters (imethod.Parameters);
|
||||
output (");");
|
||||
newline ();
|
||||
}
|
||||
|
||||
void GenerateInterfaceProperty (InterfaceProperty iprop)
|
||||
{
|
||||
space ();
|
||||
output (iprop.IsNew ? "new " : "");
|
||||
output (iprop.Type + " " + iprop.Name + " { ");
|
||||
if (iprop.HasGet) output ("get; ");
|
||||
if (iprop.HasSet) output ("set; ");
|
||||
output ("}");
|
||||
newline ();
|
||||
}
|
||||
|
||||
void GenerateInterfaceEvent (InterfaceEvent ievent)
|
||||
{
|
||||
space ();
|
||||
output ((ievent.IsNew ? "new " : "") + "event ");
|
||||
output (ievent.Type + " " + ievent.Name + ";");
|
||||
newline ();
|
||||
}
|
||||
|
||||
void GenerateInterfaceIndexer (InterfaceIndexer iindexer)
|
||||
{
|
||||
space ();
|
||||
output (iindexer.IsNew ? "new " : "");
|
||||
output (iindexer.Type + " this [");
|
||||
output (iindexer.Parameters + "] {");
|
||||
if (iindexer.HasGet) output ("get; ");
|
||||
if (iindexer.HasSet) output ("set; ");
|
||||
output ("}");
|
||||
newline ();
|
||||
}
|
||||
|
||||
string GenIfaceBases (Interface iface)
|
||||
{
|
||||
return GenBases (iface.Bases);
|
||||
}
|
||||
|
||||
void GenerateInterface (Interface iface)
|
||||
{
|
||||
ioutput (GetModifiers (iface.ModFlags) + "interface " +
|
||||
ClassName (iface.Name) + GenIfaceBases (iface) + " {");
|
||||
newline ();
|
||||
indent++;
|
||||
|
||||
if (iface.InterfaceMethods != null){
|
||||
foreach (DictionaryEntry de in iface.InterfaceMethods){
|
||||
InterfaceMethod method = (InterfaceMethod) de.Value;
|
||||
GenerateInterfaceMethod (method);
|
||||
}
|
||||
}
|
||||
|
||||
if (iface.InterfaceProperties != null){
|
||||
foreach (DictionaryEntry de in iface.InterfaceProperties){
|
||||
InterfaceProperty iprop = (InterfaceProperty) de.Value;
|
||||
GenerateInterfaceProperty (iprop);
|
||||
}
|
||||
}
|
||||
|
||||
if (iface.InterfaceEvents != null){
|
||||
foreach (DictionaryEntry de in iface.InterfaceEvents){
|
||||
InterfaceEvent ievent = (InterfaceEvent) de.Value;
|
||||
GenerateInterfaceEvent (ievent);
|
||||
}
|
||||
}
|
||||
|
||||
if (iface.InterfaceIndexers != null){
|
||||
foreach (DictionaryEntry de in iface.InterfaceIndexers){
|
||||
InterfaceIndexer iindexer = (InterfaceIndexer) de.Value;
|
||||
GenerateInterfaceIndexer (iindexer);
|
||||
}
|
||||
}
|
||||
indent--;
|
||||
ioutput ("}");
|
||||
newline ();
|
||||
newline ();
|
||||
}
|
||||
|
||||
void GenerateField (Field f)
|
||||
{
|
||||
space ();
|
||||
output (GetModifiers (f.ModFlags) +
|
||||
f.Type + " " + f.Name);
|
||||
if (f.Initializer != null){
|
||||
if (f.Initializer is Expression)
|
||||
output (" = " + GetExpression ((Expression) f.Initializer, 0));
|
||||
else
|
||||
output ("ADD SUPPORT FOR ARRAYS");
|
||||
}
|
||||
output (";");
|
||||
newline ();
|
||||
}
|
||||
|
||||
void GenerateConstructor (Constructor c)
|
||||
{
|
||||
ConstructorInitializer init = c.Initializer;
|
||||
|
||||
space ();
|
||||
output (GetModifiers (c.ModFlags) + c.Name + " (");
|
||||
GenerateParameters (c.Parameters);
|
||||
output (")");
|
||||
|
||||
if (init != null){
|
||||
if (init is ConstructorThisInitializer)
|
||||
output (": this (");
|
||||
else
|
||||
output (": base (");
|
||||
output (GetArguments (init.Arguments));
|
||||
output (")");
|
||||
}
|
||||
newline ();
|
||||
GenerateBlock (c.Block, false, false);
|
||||
}
|
||||
|
||||
void GenerateProperty (Property prop)
|
||||
{
|
||||
space ();
|
||||
output (GetModifiers (prop.ModFlags) + prop.Type +
|
||||
" " + prop.Name + " {");
|
||||
newline ();
|
||||
indent++;
|
||||
if (prop.Get != null){
|
||||
space ();
|
||||
output ("get ");
|
||||
GenerateBlock (prop.Get, false, false);
|
||||
newline ();
|
||||
}
|
||||
|
||||
if (prop.Set != null){
|
||||
space ();
|
||||
output ("set ");
|
||||
GenerateBlock (prop.Set, false, false);
|
||||
}
|
||||
indent--;
|
||||
space ();
|
||||
output ("}");
|
||||
newline ();
|
||||
}
|
||||
|
||||
void GenerateEnum (CIR.Enum e)
|
||||
{
|
||||
space ();
|
||||
output ("enum " + e.Name + " {");
|
||||
newline ();
|
||||
|
||||
indent++;
|
||||
foreach (string name in e.ValueNames){
|
||||
Expression expr = e [name];
|
||||
|
||||
space ();
|
||||
|
||||
output (name);
|
||||
if (expr != null)
|
||||
output (" = " + GetExpression (expr, 0));
|
||||
|
||||
output (",");
|
||||
newline ();
|
||||
}
|
||||
indent--;
|
||||
space ();
|
||||
output_newline ("}");
|
||||
}
|
||||
|
||||
void GenerateTypeContainerData (TypeContainer tc)
|
||||
{
|
||||
if (tc.Constants != null){
|
||||
foreach (Constant c in tc.Constants){
|
||||
space ();
|
||||
|
||||
output ("const " + c.ConstantType + " " + c.Name + " = " +
|
||||
GetExpression (c.Expr, 0) + ";");
|
||||
newline ();
|
||||
}
|
||||
newline ();
|
||||
}
|
||||
|
||||
if (tc.Enums != null){
|
||||
foreach (CIR.Enum e in tc.Enums)
|
||||
GenerateEnum (e);
|
||||
}
|
||||
|
||||
if (tc.Fields != null){
|
||||
foreach (Field f in tc.Fields)
|
||||
GenerateField (f);
|
||||
newline ();
|
||||
}
|
||||
|
||||
if (tc.Constructors != null){
|
||||
foreach (Constructor c in tc.Constructors)
|
||||
GenerateConstructor (c);
|
||||
|
||||
newline ();
|
||||
|
||||
}
|
||||
|
||||
if (tc.Properties != null){
|
||||
foreach (Property prop in tc.Properties)
|
||||
GenerateProperty (prop);
|
||||
}
|
||||
|
||||
GenerateFromTypes (tc);
|
||||
|
||||
if (tc.Methods != null){
|
||||
foreach (Method m in tc.Methods){
|
||||
GenerateMethod (m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string GetModifiers (int mod_flags)
|
||||
{
|
||||
string s = "";
|
||||
|
||||
for (int i = 1; i <= (int) CIR.Modifiers.TOP; i <<= 1){
|
||||
if ((mod_flags & i) != 0)
|
||||
s += Modifiers.Name (i) + " ";
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
string ClassName (string name)
|
||||
{
|
||||
return name;
|
||||
//return name.Substring (1 + name.LastIndexOf ('.'));
|
||||
}
|
||||
|
||||
string GenBases (ArrayList bases)
|
||||
{
|
||||
if (bases == null)
|
||||
return "";
|
||||
|
||||
string res = ": ";
|
||||
int top = bases.Count;
|
||||
for (int i = 0; i < bases.Count; i++){
|
||||
Type t = (Type) bases [i];
|
||||
|
||||
res += t.Name;
|
||||
if (i + 1 != top)
|
||||
res += ", ";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
string GenClassBases (Class c)
|
||||
{
|
||||
return GenBases (c.Bases);
|
||||
}
|
||||
|
||||
void GenerateFromClass (Class c)
|
||||
{
|
||||
ioutput (GetModifiers (c.ModFlags) + "class " + ClassName (c.Name) +
|
||||
" " + GenClassBases (c) + " {");
|
||||
newline ();
|
||||
indent++;
|
||||
|
||||
GenerateTypeContainerData (c);
|
||||
|
||||
indent--;
|
||||
ioutput ("}");
|
||||
newline ();
|
||||
newline ();
|
||||
}
|
||||
|
||||
void GenerateFromStruct (Struct s)
|
||||
{
|
||||
GenerateTypeContainerData (s);
|
||||
}
|
||||
|
||||
void GenerateFromTypes (TypeContainer types)
|
||||
{
|
||||
if (types.Types == null)
|
||||
return;
|
||||
|
||||
foreach (DictionaryEntry de in types.Types){
|
||||
TypeContainer type = (TypeContainer) de.Value;
|
||||
|
||||
if (type is Class)
|
||||
GenerateFromClass ((Class) type);
|
||||
if (type is Struct)
|
||||
GenerateFromStruct ((Struct) type);
|
||||
|
||||
}
|
||||
|
||||
if (types.Interfaces != null){
|
||||
foreach (DictionaryEntry de in types.Interfaces){
|
||||
Interface iface = (Interface) de.Value;
|
||||
|
||||
GenerateInterface (iface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Dump (Tree tree, StreamWriter output)
|
||||
{
|
||||
this.o = output;
|
||||
|
||||
indent = 0;
|
||||
GenerateFromTypes (tree.Types);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void ParseOptions (string options)
|
||||
{
|
||||
if (options == "tag")
|
||||
tag_values = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
AssemblyInfo.cs
|
||||
anonymous.cs
|
||||
assign.cs
|
||||
attribute.cs
|
||||
driver.cs
|
||||
cs-tokenizer.cs
|
||||
cfold.cs
|
||||
class.cs
|
||||
codegen.cs
|
||||
const.cs
|
||||
constant.cs
|
||||
convert.cs
|
||||
decl.cs
|
||||
delegate.cs
|
||||
doc.cs
|
||||
enum.cs
|
||||
ecore.cs
|
||||
expression.cs
|
||||
flowanalysis.cs
|
||||
generic.cs
|
||||
iterators.cs
|
||||
literal.cs
|
||||
location.cs
|
||||
modifiers.cs
|
||||
namespace.cs
|
||||
parameter.cs
|
||||
pending.cs
|
||||
report.cs
|
||||
rootcontext.cs
|
||||
statement.cs
|
||||
support.cs
|
||||
typemanager.cs
|
||||
symbolwriter.cs
|
||||
tree.cs
|
||||
CryptoConvert.cs
|
||||
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs
|
||||
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
|
||||
../class/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
|
||||
@@ -0,0 +1,320 @@
|
||||
//
|
||||
// literal.cs: Literal representation for the IL tree.
|
||||
//
|
||||
// Author:
|
||||
// Miguel de Icaza ([email protected])
|
||||
//
|
||||
// (C) 2001 Ximian, Inc.
|
||||
//
|
||||
//
|
||||
// Notice that during parsing we create objects of type Literal, but the
|
||||
// types are not loaded (thats why the Resolve method has to assign the
|
||||
// type at that point).
|
||||
//
|
||||
// Literals differ from the constants in that we know we encountered them
|
||||
// as a literal in the source code (and some extra rules apply there) and
|
||||
// they have to be resolved (since during parsing we have not loaded the
|
||||
// types yet) while constants are created only after types have been loaded
|
||||
// and are fully resolved when born.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
|
||||
//
|
||||
// I put System.Null just so we do not have to special case it on
|
||||
// TypeManager.CSharpName
|
||||
//
|
||||
namespace System {
|
||||
//
|
||||
// Represents the Null Type, just used as a placeholder for the type in NullLiteral
|
||||
//
|
||||
public class Null {
|
||||
}
|
||||
}
|
||||
|
||||
namespace Mono.CSharp {
|
||||
|
||||
//
|
||||
// Unlike C#, VB.NET doesn't understand "signed byte",
|
||||
// "unsigned short", "unsigned int" and "unsigned long" as
|
||||
// primitive types. The NotDefinedAsPrimitiveType just exists
|
||||
// to accomodate this fact.
|
||||
//
|
||||
public class NotDefinedAsPrimitiveType {
|
||||
}
|
||||
|
||||
//
|
||||
// The NullType just exists to compare type equality, and for
|
||||
// expressions that might have the `null type'
|
||||
//
|
||||
public class NullType {
|
||||
}
|
||||
|
||||
//
|
||||
// The null Literal constant
|
||||
//
|
||||
public class NullLiteral : Constant {
|
||||
public static readonly NullLiteral Null;
|
||||
|
||||
static NullLiteral ()
|
||||
{
|
||||
Null = new NullLiteral ();
|
||||
}
|
||||
|
||||
public NullLiteral ()
|
||||
{
|
||||
eclass = ExprClass.Value;
|
||||
}
|
||||
|
||||
override public string AsString ()
|
||||
{
|
||||
return "null";
|
||||
}
|
||||
|
||||
public override object GetValue ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
type = TypeManager.null_type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override void Emit (EmitContext ec)
|
||||
{
|
||||
ec.ig.Emit (OpCodes.Ldnull);
|
||||
}
|
||||
|
||||
public override CharConstant ConvertToChar ()
|
||||
{
|
||||
return new CharConstant ((char) 0);
|
||||
}
|
||||
|
||||
public override BoolConstant ConvertToBoolean ()
|
||||
{
|
||||
return new BoolConstant (false);
|
||||
}
|
||||
|
||||
public override ByteConstant ConvertToByte ()
|
||||
{
|
||||
return new ByteConstant ((byte) 0);
|
||||
}
|
||||
|
||||
public override ShortConstant ConvertToShort ()
|
||||
{
|
||||
return new ShortConstant ((short) 0);
|
||||
}
|
||||
|
||||
public override DecimalConstant ConvertToDecimal ()
|
||||
{
|
||||
return new DecimalConstant ((decimal) 0);
|
||||
}
|
||||
|
||||
public override DoubleConstant ConvertToDouble ()
|
||||
{
|
||||
return new DoubleConstant ((double) 0);
|
||||
}
|
||||
|
||||
public override FloatConstant ConvertToFloat ()
|
||||
{
|
||||
return new FloatConstant ((float) 0);
|
||||
}
|
||||
|
||||
public override LongConstant ConvertToLong ()
|
||||
{
|
||||
return new LongConstant ((long) 0);
|
||||
}
|
||||
|
||||
public override IntConstant ConvertToInt ()
|
||||
{
|
||||
return new IntConstant (0);
|
||||
}
|
||||
|
||||
public override bool IsNegative {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsZeroInteger {
|
||||
get { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// A null literal in a pointer context
|
||||
//
|
||||
public class NullPointer : NullLiteral {
|
||||
public new static readonly NullLiteral Null;
|
||||
|
||||
static NullPointer ()
|
||||
{
|
||||
Null = new NullPointer ();
|
||||
}
|
||||
|
||||
private NullPointer ()
|
||||
{
|
||||
type = TypeManager.object_type;
|
||||
}
|
||||
|
||||
public override void Emit (EmitContext ec)
|
||||
{
|
||||
ILGenerator ig = ec.ig;
|
||||
|
||||
ig.Emit (OpCodes.Ldc_I4_0);
|
||||
ig.Emit (OpCodes.Conv_U);
|
||||
}
|
||||
}
|
||||
|
||||
public class BoolLiteral : BoolConstant {
|
||||
public BoolLiteral (bool val) : base (val)
|
||||
{
|
||||
}
|
||||
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
type = TypeManager.bool_type;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class CharLiteral : CharConstant {
|
||||
public CharLiteral (char c) : base (c)
|
||||
{
|
||||
}
|
||||
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
type = TypeManager.char_type;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class IntLiteral : IntConstant {
|
||||
public static IntLiteral One, Zero;
|
||||
|
||||
static IntLiteral ()
|
||||
{
|
||||
Zero = new IntLiteral (0);
|
||||
One = new IntLiteral (1);
|
||||
}
|
||||
|
||||
public IntLiteral (int l) : base (l)
|
||||
{
|
||||
}
|
||||
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
type = TypeManager.int32_type;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class UIntLiteral : UIntConstant {
|
||||
public UIntLiteral (uint l) : base (l)
|
||||
{
|
||||
}
|
||||
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
type = TypeManager.uint32_type;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class LongLiteral : LongConstant {
|
||||
public LongLiteral (long l) : base (l)
|
||||
{
|
||||
}
|
||||
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
type = TypeManager.int64_type;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class ULongLiteral : ULongConstant {
|
||||
public ULongLiteral (ulong l) : base (l)
|
||||
{
|
||||
}
|
||||
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
type = TypeManager.uint64_type;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class FloatLiteral : FloatConstant {
|
||||
|
||||
public FloatLiteral (float f) : base (f)
|
||||
{
|
||||
}
|
||||
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
type = TypeManager.float_type;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class DoubleLiteral : DoubleConstant {
|
||||
public DoubleLiteral (double d) : base (d)
|
||||
{
|
||||
}
|
||||
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
type = TypeManager.double_type;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class DecimalLiteral : DecimalConstant {
|
||||
public DecimalLiteral (decimal d) : base (d)
|
||||
{
|
||||
}
|
||||
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
type = TypeManager.decimal_type;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class StringLiteral : StringConstant {
|
||||
public StringLiteral (string s) : base (s)
|
||||
{
|
||||
}
|
||||
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
type = TypeManager.string_type;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// VB.NET specific
|
||||
//
|
||||
public class DateLiteral : DateConstant {
|
||||
public DateLiteral (DateTime s) : base (s)
|
||||
{
|
||||
}
|
||||
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
type = TypeManager.date_type;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
//
|
||||
// location.cs: Keeps track of the location of source code entity
|
||||
//
|
||||
// Author:
|
||||
// Miguel de Icaza
|
||||
//
|
||||
// (C) 2001 Ximian, Inc.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
|
||||
namespace Mono.CSharp {
|
||||
/// <summary>
|
||||
/// This is one single source file.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is intentionally a class and not a struct since we need
|
||||
/// to pass this by reference.
|
||||
/// </remarks>
|
||||
public sealed class SourceFile : ISourceFile {
|
||||
public readonly string Name;
|
||||
public readonly string Path;
|
||||
public readonly int Index;
|
||||
public SourceFileEntry SourceFileEntry;
|
||||
public bool HasLineDirective;
|
||||
|
||||
public SourceFile (string name, string path, int index)
|
||||
{
|
||||
this.Index = index;
|
||||
this.Name = name;
|
||||
this.Path = path;
|
||||
}
|
||||
|
||||
SourceFileEntry ISourceFile.Entry {
|
||||
get { return SourceFileEntry; }
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return String.Format ("SourceFile ({0}:{1}:{2}:{3})",
|
||||
Name, Path, Index, SourceFileEntry);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Keeps track of the location in the program
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// This uses a compact representation and a couple of auxiliary
|
||||
/// structures to keep track of tokens to (file,line) mappings.
|
||||
///
|
||||
/// We could probably also keep track of columns by storing those
|
||||
/// in 8 bits (and say, map anything after char 255 to be `255+').
|
||||
/// </remarks>
|
||||
public struct Location {
|
||||
public int token;
|
||||
|
||||
static ArrayList source_list;
|
||||
static Hashtable source_files;
|
||||
static int source_bits;
|
||||
static int source_mask;
|
||||
static int source_count;
|
||||
static int current_source;
|
||||
|
||||
public readonly static Location Null;
|
||||
|
||||
static Location ()
|
||||
{
|
||||
source_files = new Hashtable ();
|
||||
source_list = new ArrayList ();
|
||||
current_source = 0;
|
||||
Null.token = 0;
|
||||
}
|
||||
|
||||
// <summary>
|
||||
// This must be called before parsing/tokenizing any files.
|
||||
// </summary>
|
||||
static public void AddFile (string name)
|
||||
{
|
||||
string path = Path.GetFullPath (name);
|
||||
|
||||
if (source_files.Contains (path)){
|
||||
int id = (int) source_files [path];
|
||||
string other_name = ((SourceFile) source_list [id - 1]).Name;
|
||||
if (name.Equals (other_name))
|
||||
Report.Warning (2002, "Source file '{0}' specified multiple times", name);
|
||||
else
|
||||
Report.Warning (2002, "Source filenames '{0}' and '{1}' both refer to the same file: {2}", name, other_name, path);
|
||||
return;
|
||||
}
|
||||
|
||||
source_files.Add (path, ++source_count);
|
||||
source_list.Add (new SourceFile (name, path, source_count));
|
||||
}
|
||||
|
||||
static public SourceFile[] SourceFiles {
|
||||
get {
|
||||
SourceFile[] retval = new SourceFile [source_list.Count];
|
||||
source_list.CopyTo (retval, 0);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
static int log2 (int number)
|
||||
{
|
||||
int bits = 0;
|
||||
while (number > 0) {
|
||||
bits++;
|
||||
number /= 2;
|
||||
}
|
||||
|
||||
return bits;
|
||||
}
|
||||
|
||||
// <summary>
|
||||
// After adding all source files we want to compile with AddFile(), this method
|
||||
// must be called to `reserve' an appropriate number of bits in the token for the
|
||||
// source file. We reserve some extra space for files we encounter via #line
|
||||
// directives while parsing.
|
||||
// </summary>
|
||||
static public void Initialize ()
|
||||
{
|
||||
source_bits = log2 (source_list.Count) + 2;
|
||||
source_mask = (1 << source_bits) - 1;
|
||||
}
|
||||
|
||||
// <remarks>
|
||||
// This is used when we encounter a #line preprocessing directive.
|
||||
// </remarks>
|
||||
static public SourceFile LookupFile (string name)
|
||||
{
|
||||
string path = name == "" ? "" : Path.GetFullPath (name);
|
||||
|
||||
if (!source_files.Contains (path)) {
|
||||
if (source_count >= (1 << source_bits))
|
||||
return new SourceFile (name, path, 0);
|
||||
|
||||
source_files.Add (path, ++source_count);
|
||||
SourceFile retval = new SourceFile (name, path, source_count);
|
||||
source_list.Add (retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int index = (int) source_files [path];
|
||||
return (SourceFile) source_list [index - 1];
|
||||
}
|
||||
|
||||
/*
|
||||
static public void Push (SourceFile file)
|
||||
{
|
||||
current_source = file.Index;
|
||||
}
|
||||
*/
|
||||
|
||||
// <remarks>
|
||||
// If we're compiling with debugging support, this is called between parsing
|
||||
// and code generation to register all the source files with the
|
||||
// symbol writer.
|
||||
// </remarks>
|
||||
static public void DefineSymbolDocuments (SymbolWriter symwriter)
|
||||
{
|
||||
foreach (SourceFile file in source_list) {
|
||||
file.SourceFileEntry = symwriter.DefineDocument (file.Path);
|
||||
}
|
||||
}
|
||||
|
||||
public Location (int row)
|
||||
{
|
||||
if (row < 0)
|
||||
token = 0;
|
||||
else
|
||||
token = current_source + (row << source_bits);
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return Name + ": (" + Row + ")";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the Location is Null
|
||||
/// </summary>
|
||||
static public bool IsNull (Location l)
|
||||
{
|
||||
return l.token == 0;
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
int index = token & source_mask;
|
||||
if ((token == 0) || (index == 0))
|
||||
return "Internal";
|
||||
|
||||
SourceFile file = (SourceFile) source_list [index - 1];
|
||||
return file.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public int Row {
|
||||
get {
|
||||
if (token == 0)
|
||||
return 1;
|
||||
|
||||
return token >> source_bits;
|
||||
}
|
||||
}
|
||||
|
||||
public int File {
|
||||
get {
|
||||
return token & source_mask;
|
||||
}
|
||||
}
|
||||
|
||||
// The ISymbolDocumentWriter interface is used by the symbol writer to
|
||||
// describe a single source file - for each source file there's exactly
|
||||
// one corresponding ISymbolDocumentWriter instance.
|
||||
//
|
||||
// This class has an internal hash table mapping source document names
|
||||
// to such ISymbolDocumentWriter instances - so there's exactly one
|
||||
// instance per document.
|
||||
//
|
||||
// This property returns the ISymbolDocumentWriter instance which belongs
|
||||
// to the location's source file.
|
||||
//
|
||||
// If we don't have a symbol writer, this property is always null.
|
||||
public SourceFile SourceFile {
|
||||
get {
|
||||
int index = token & source_mask;
|
||||
if (index == 0)
|
||||
return null;
|
||||
return (SourceFile) source_list [index - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
//
|
||||
// modifiers.cs: Modifier handling.
|
||||
//
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Mono.CSharp {
|
||||
public class Modifiers {
|
||||
|
||||
//
|
||||
// The ordering of the following 4 constants
|
||||
// has been carefully done.
|
||||
//
|
||||
public const int PROTECTED = 0x0001;
|
||||
public const int PUBLIC = 0x0002;
|
||||
public const int PRIVATE = 0x0004;
|
||||
public const int INTERNAL = 0x0008;
|
||||
public const int NEW = 0x0010;
|
||||
public const int ABSTRACT = 0x0020;
|
||||
public const int SEALED = 0x0040;
|
||||
public const int STATIC = 0x0080;
|
||||
public const int READONLY = 0x0100;
|
||||
public const int VIRTUAL = 0x0200;
|
||||
public const int OVERRIDE = 0x0400;
|
||||
public const int EXTERN = 0x0800;
|
||||
public const int VOLATILE = 0x1000;
|
||||
public const int UNSAFE = 0x2000;
|
||||
public const int WRITEONLY = 0x04000;
|
||||
public const int SHADOWS = 0x08000;
|
||||
public const int DEFAULT = 0x10000;
|
||||
public const int NONVIRTUAL= 0x20000;
|
||||
private const int TOP = 0x20000;
|
||||
|
||||
//
|
||||
// We use this internally to flag that the method contains an iterator
|
||||
//
|
||||
public const int METHOD_YIELDS = 0x8000;
|
||||
public const int METHOD_GENERIC = 0x10000;
|
||||
|
||||
public const int Accessibility =
|
||||
PUBLIC | PROTECTED | INTERNAL | PRIVATE;
|
||||
public const int AllowedExplicitImplFlags =
|
||||
UNSAFE | EXTERN;
|
||||
|
||||
static public string Name (int i)
|
||||
{
|
||||
string s = "";
|
||||
|
||||
switch (i) {
|
||||
case Modifiers.NEW:
|
||||
s = "new"; break;
|
||||
case Modifiers.PUBLIC:
|
||||
s = "public"; break;
|
||||
case Modifiers.PROTECTED:
|
||||
s = "protected"; break;
|
||||
case Modifiers.INTERNAL:
|
||||
s = "internal"; break;
|
||||
case Modifiers.PRIVATE:
|
||||
s = "private"; break;
|
||||
case Modifiers.ABSTRACT:
|
||||
s = "abstract"; break;
|
||||
case Modifiers.SEALED:
|
||||
s = "sealed"; break;
|
||||
case Modifiers.STATIC:
|
||||
s = "static"; break;
|
||||
case Modifiers.READONLY:
|
||||
s = "readonly"; break;
|
||||
case Modifiers.VIRTUAL:
|
||||
s = "virtual"; break;
|
||||
case Modifiers.OVERRIDE:
|
||||
s = "override"; break;
|
||||
case Modifiers.EXTERN:
|
||||
s = "extern"; break;
|
||||
case Modifiers.VOLATILE:
|
||||
s = "volatile"; break;
|
||||
case Modifiers.UNSAFE:
|
||||
s = "unsafe"; break;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
public static TypeAttributes TypeAttr (int mod_flags, bool is_toplevel)
|
||||
{
|
||||
TypeAttributes t = 0;
|
||||
|
||||
if (is_toplevel){
|
||||
if ((mod_flags & PUBLIC) != 0)
|
||||
t |= TypeAttributes.Public;
|
||||
if ((mod_flags & PRIVATE) != 0)
|
||||
t |= TypeAttributes.NotPublic;
|
||||
} else {
|
||||
if ((mod_flags & PUBLIC) != 0)
|
||||
t |= TypeAttributes.NestedPublic;
|
||||
if ((mod_flags & PRIVATE) != 0)
|
||||
t |= TypeAttributes.NestedPrivate;
|
||||
if ((mod_flags & PROTECTED) != 0 && (mod_flags & INTERNAL) != 0)
|
||||
t |= TypeAttributes.NestedFamORAssem;
|
||||
if ((mod_flags & PROTECTED) != 0)
|
||||
t |= TypeAttributes.NestedFamily;
|
||||
if ((mod_flags & INTERNAL) != 0)
|
||||
t |= TypeAttributes.NestedAssembly;
|
||||
}
|
||||
|
||||
if ((mod_flags & SEALED) != 0)
|
||||
t |= TypeAttributes.Sealed;
|
||||
if ((mod_flags & ABSTRACT) != 0)
|
||||
t |= TypeAttributes.Abstract;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
public static TypeAttributes TypeAttr (int mod_flags, TypeContainer caller)
|
||||
{
|
||||
TypeAttributes t = TypeAttr (mod_flags, caller.IsTopLevel);
|
||||
|
||||
// If we do not have static constructors, static methods
|
||||
// can be invoked without initializing the type.
|
||||
if (!caller.UserDefinedStaticConstructor &&
|
||||
(caller.Kind != Kind.Interface))
|
||||
t |= TypeAttributes.BeforeFieldInit;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
public static FieldAttributes FieldAttr (int mod_flags)
|
||||
{
|
||||
FieldAttributes fa = 0;
|
||||
|
||||
if ((mod_flags & PUBLIC) != 0)
|
||||
fa |= FieldAttributes.Public;
|
||||
if ((mod_flags & PRIVATE) != 0)
|
||||
fa |= FieldAttributes.Private;
|
||||
if ((mod_flags & PROTECTED) != 0){
|
||||
if ((mod_flags & INTERNAL) != 0)
|
||||
fa |= FieldAttributes.FamORAssem;
|
||||
else
|
||||
fa |= FieldAttributes.Family;
|
||||
} else {
|
||||
if ((mod_flags & INTERNAL) != 0)
|
||||
fa |= FieldAttributes.Assembly;
|
||||
}
|
||||
|
||||
if ((mod_flags & STATIC) != 0)
|
||||
fa |= FieldAttributes.Static;
|
||||
if ((mod_flags & READONLY) != 0)
|
||||
fa |= FieldAttributes.InitOnly;
|
||||
|
||||
return fa;
|
||||
}
|
||||
|
||||
public static MethodAttributes MethodAttr (int mod_flags)
|
||||
{
|
||||
MethodAttributes ma = MethodAttributes.HideBySig;
|
||||
|
||||
if ((mod_flags & PUBLIC) != 0)
|
||||
ma |= MethodAttributes.Public;
|
||||
if ((mod_flags & PRIVATE) != 0)
|
||||
ma |= MethodAttributes.Private;
|
||||
if ((mod_flags & PROTECTED) != 0){
|
||||
if ((mod_flags & INTERNAL) != 0)
|
||||
ma |= MethodAttributes.FamORAssem;
|
||||
else
|
||||
ma |= MethodAttributes.Family;
|
||||
} else {
|
||||
if ((mod_flags & INTERNAL) != 0)
|
||||
ma |= MethodAttributes.Assembly;
|
||||
}
|
||||
|
||||
if ((mod_flags & STATIC) != 0)
|
||||
ma |= MethodAttributes.Static;
|
||||
if ((mod_flags & ABSTRACT) != 0){
|
||||
ma |= MethodAttributes.Abstract | MethodAttributes.Virtual;
|
||||
}
|
||||
if ((mod_flags & SEALED) != 0)
|
||||
ma |= MethodAttributes.Final;
|
||||
|
||||
if ((mod_flags & VIRTUAL) != 0)
|
||||
ma |= MethodAttributes.Virtual;
|
||||
|
||||
if ((mod_flags & OVERRIDE) != 0)
|
||||
ma |= MethodAttributes.Virtual;
|
||||
else {
|
||||
if ((ma & MethodAttributes.Virtual) != 0)
|
||||
ma |= MethodAttributes.NewSlot;
|
||||
}
|
||||
|
||||
return ma;
|
||||
}
|
||||
|
||||
// <summary>
|
||||
// Checks the object @mod modifiers to be in @allowed.
|
||||
// Returns the new mask. Side effect: reports any
|
||||
// incorrect attributes.
|
||||
// </summary>
|
||||
public static int Check (int allowed, int mod, int def_access, Location l)
|
||||
{
|
||||
int invalid_flags = (~allowed) & mod;
|
||||
int i;
|
||||
|
||||
if (invalid_flags == 0){
|
||||
int a = mod;
|
||||
|
||||
if ((mod & Modifiers.UNSAFE) != 0){
|
||||
if (!RootContext.Unsafe){
|
||||
Report.Error (227, l,
|
||||
"Unsafe code requires the -unsafe command " +
|
||||
"line option to be specified");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If no accessibility bits provided
|
||||
// then provide the defaults.
|
||||
//
|
||||
if ((mod & Accessibility) == 0){
|
||||
mod |= def_access;
|
||||
return mod;
|
||||
}
|
||||
|
||||
//
|
||||
// Make sure that no conflicting accessibility
|
||||
// bits have been set. Protected+Internal is
|
||||
// allowed, that is why they are placed on bits
|
||||
// 1 and 4 (so the shift 3 basically merges them)
|
||||
//
|
||||
a &= 15;
|
||||
a |= (a >> 3);
|
||||
a = ((a & 2) >> 1) + (a & 5);
|
||||
a = ((a & 4) >> 2) + (a & 3);
|
||||
if (a > 1)
|
||||
Report.Error (107, l, "More than one protection modifier specified");
|
||||
|
||||
return mod;
|
||||
}
|
||||
|
||||
for (i = 1; i <= TOP; i <<= 1){
|
||||
if ((i & invalid_flags) == 0)
|
||||
continue;
|
||||
|
||||
Error_InvalidModifier (l, Name (i));
|
||||
}
|
||||
|
||||
return allowed & mod;
|
||||
}
|
||||
|
||||
public static void Error_InvalidModifier (Location l, string name)
|
||||
{
|
||||
Report.Error (106, l, "the modifier " + name + " is not valid for this item");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// module.cs: Module handler
|
||||
//
|
||||
// Author: Rafael Teixeira ([email protected])
|
||||
//
|
||||
// Licensed under the terms of the GNU GPL
|
||||
//
|
||||
// (C) 2002 Rafael Teixeira
|
||||
//
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Diagnostics.SymbolStore;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Mono.CSharp ;
|
||||
|
||||
namespace Mono.CSharp
|
||||
{
|
||||
public class VBModule : Class
|
||||
{
|
||||
public new const int AllowedModifiers = Modifiers.PUBLIC |Modifiers.INTERNAL;
|
||||
|
||||
public VBModule (NamespaceEntry ns, TypeContainer parent, MemberName name, int mod,
|
||||
Attributes attrs, Location l)
|
||||
: base (ns, parent, name, 0, attrs, l)
|
||||
|
||||
{
|
||||
if (parent.Parent != null)
|
||||
Report.Error (30617, l,
|
||||
"'Module' statements can occur only at file or namespace level");
|
||||
|
||||
// overwrite ModFlags
|
||||
this.ModFlags = Modifiers.Check (AllowedModifiers, mod, Modifiers.INTERNAL, l);
|
||||
|
||||
// add specialized attribute
|
||||
|
||||
Mono.CSharp.Attribute standardModuleAttribute = new Mono.CSharp.Attribute(null, Expression.StringToExpression ("Microsoft.VisualBasic.CompilerServices", l), "StandardModuleAttribute", null, l);
|
||||
|
||||
ArrayList al = new ArrayList();
|
||||
al.Add(standardModuleAttribute);
|
||||
if (attributes == null) {
|
||||
attributes = new Attributes(al);
|
||||
} else {
|
||||
attributes.AddAttributes(al);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override TypeAttributes TypeAttr
|
||||
{
|
||||
get {
|
||||
return base.TypeAttr | TypeAttributes.AutoLayout | TypeAttributes.Class | TypeAttributes.Sealed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,635 @@
|
||||
//
|
||||
// namespace.cs: Tracks namespaces
|
||||
//
|
||||
// Author:
|
||||
// Miguel de Icaza ([email protected])
|
||||
//
|
||||
// (C) 2001 Ximian, Inc.
|
||||
//
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Mono.CSharp {
|
||||
|
||||
/// <summary>
|
||||
/// Keeps track of the namespaces defined in the C# code.
|
||||
///
|
||||
/// This is an Expression to allow it to be referenced in the
|
||||
/// compiler parse/intermediate tree during name resolution.
|
||||
/// </summary>
|
||||
public class Namespace : FullNamedExpression, IAlias {
|
||||
static ArrayList all_namespaces = new ArrayList ();
|
||||
static Hashtable namespaces_map = new Hashtable ();
|
||||
|
||||
Namespace parent;
|
||||
string fullname;
|
||||
ArrayList entries;
|
||||
Hashtable namespaces;
|
||||
Hashtable defined_names;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor Takes the current namespace and the
|
||||
/// name. This is bootstrapped with parent == null
|
||||
/// and name = ""
|
||||
/// </summary>
|
||||
public Namespace (Namespace parent, string name)
|
||||
{
|
||||
// Expression members.
|
||||
this.eclass = ExprClass.Namespace;
|
||||
this.Type = null;
|
||||
this.loc = Location.Null;
|
||||
|
||||
this.parent = parent;
|
||||
|
||||
string pname = parent != null ? parent.Name : "";
|
||||
|
||||
if (pname == "")
|
||||
fullname = name;
|
||||
else
|
||||
fullname = parent.Name + "." + name;
|
||||
|
||||
entries = new ArrayList ();
|
||||
namespaces = new Hashtable ();
|
||||
defined_names = new Hashtable ();
|
||||
|
||||
all_namespaces.Add (this);
|
||||
if (namespaces_map.Contains (fullname))
|
||||
return;
|
||||
namespaces_map [fullname] = true;
|
||||
}
|
||||
|
||||
public override Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public override void Emit (EmitContext ec)
|
||||
{
|
||||
throw new InternalErrorException ("Expression tree referenced namespace " + fullname + " during Emit ()");
|
||||
}
|
||||
|
||||
public static bool IsNamespace (string name)
|
||||
{
|
||||
return namespaces_map [name] != null;
|
||||
}
|
||||
|
||||
public static Namespace Root = new Namespace (null, "");
|
||||
|
||||
public Namespace GetNamespace (string name, bool create)
|
||||
{
|
||||
int pos = name.IndexOf ('.');
|
||||
|
||||
Namespace ns;
|
||||
string first;
|
||||
if (pos >= 0)
|
||||
first = name.Substring (0, pos);
|
||||
else
|
||||
first = name;
|
||||
|
||||
ns = (Namespace) namespaces [first];
|
||||
if (ns == null) {
|
||||
if (!create)
|
||||
return null;
|
||||
|
||||
ns = new Namespace (this, first);
|
||||
namespaces.Add (first, ns);
|
||||
}
|
||||
|
||||
if (pos >= 0)
|
||||
ns = ns.GetNamespace (name.Substring (pos + 1), create);
|
||||
|
||||
return ns;
|
||||
}
|
||||
|
||||
public static Namespace LookupNamespace (string name, bool create)
|
||||
{
|
||||
return Root.GetNamespace (name, create);
|
||||
}
|
||||
|
||||
public FullNamedExpression Lookup (DeclSpace ds, string name, Location loc)
|
||||
{
|
||||
IAlias o = (IAlias) defined_names [name];
|
||||
|
||||
Type t;
|
||||
DeclSpace tdecl = o as DeclSpace;
|
||||
if (tdecl != null) {
|
||||
t = tdecl.DefineType ();
|
||||
if (t == null)
|
||||
return null;
|
||||
|
||||
if ((ds == null) || ds.CheckAccessLevel (t))
|
||||
return new TypeExpression (t, Location.Null);
|
||||
}
|
||||
|
||||
Namespace ns = GetNamespace (name, false);
|
||||
if (ns != null)
|
||||
return ns;
|
||||
|
||||
t = TypeManager.LookupType (DeclSpace.MakeFQN (fullname, name));
|
||||
if ((t == null) || ((ds != null) && !ds.CheckAccessLevel (t)))
|
||||
return null;
|
||||
|
||||
return new TypeExpression (t, Location.Null);
|
||||
}
|
||||
|
||||
public void AddNamespaceEntry (NamespaceEntry entry)
|
||||
{
|
||||
entries.Add (entry);
|
||||
}
|
||||
|
||||
public void DefineName (string name, IAlias o)
|
||||
{
|
||||
defined_names.Add (name, o);
|
||||
}
|
||||
|
||||
static public ArrayList UserDefinedNamespaces {
|
||||
get {
|
||||
return all_namespaces;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The qualified name of the current namespace
|
||||
/// </summary>
|
||||
public string Name {
|
||||
get {
|
||||
return fullname;
|
||||
}
|
||||
}
|
||||
|
||||
public override string FullName {
|
||||
get {
|
||||
return fullname;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The parent of this namespace, used by the parser to "Pop"
|
||||
/// the current namespace declaration
|
||||
/// </summary>
|
||||
public Namespace Parent {
|
||||
get {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DefineNamespaces (SymbolWriter symwriter)
|
||||
{
|
||||
foreach (Namespace ns in all_namespaces) {
|
||||
foreach (NamespaceEntry entry in ns.entries)
|
||||
entry.DefineNamespace (symwriter);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to validate that all the using clauses are correct
|
||||
/// after we are finished parsing all the files.
|
||||
/// </summary>
|
||||
public static void VerifyUsing ()
|
||||
{
|
||||
foreach (Namespace ns in all_namespaces) {
|
||||
foreach (NamespaceEntry entry in ns.entries)
|
||||
entry.VerifyUsing ();
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
if (this == Root)
|
||||
return "Namespace (<root>)";
|
||||
else
|
||||
return String.Format ("Namespace ({0})", Name);
|
||||
}
|
||||
|
||||
bool IAlias.IsType {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
TypeExpr IAlias.ResolveAsType (EmitContext ec)
|
||||
{
|
||||
throw new InvalidOperationException ();
|
||||
}
|
||||
}
|
||||
|
||||
public class NamespaceEntry
|
||||
{
|
||||
Namespace ns;
|
||||
NamespaceEntry parent, implicit_parent;
|
||||
SourceFile file;
|
||||
int symfile_id;
|
||||
Hashtable aliases;
|
||||
ArrayList using_clauses;
|
||||
public bool DeclarationFound = false;
|
||||
|
||||
//
|
||||
// This class holds the location where a using definition is
|
||||
// done, and whether it has been used by the program or not.
|
||||
//
|
||||
// We use this to flag using clauses for namespaces that do not
|
||||
// exist.
|
||||
//
|
||||
public class UsingEntry {
|
||||
public Expression Name;
|
||||
public readonly NamespaceEntry NamespaceEntry;
|
||||
public readonly Location Location;
|
||||
|
||||
public UsingEntry (NamespaceEntry entry, Expression name, Location loc)
|
||||
{
|
||||
Name = name;
|
||||
NamespaceEntry = entry;
|
||||
Location = loc;
|
||||
}
|
||||
|
||||
internal FullNamedExpression resolved;
|
||||
|
||||
public Namespace Resolve ()
|
||||
{
|
||||
if (resolved != null)
|
||||
return resolved as Namespace;
|
||||
|
||||
DeclSpace root = RootContext.Tree.Types;
|
||||
root.NamespaceEntry = NamespaceEntry;
|
||||
resolved = Name.ResolveAsTypeStep (root.EmitContext);
|
||||
root.NamespaceEntry = null;
|
||||
|
||||
return resolved as Namespace;
|
||||
}
|
||||
}
|
||||
|
||||
public class AliasEntry {
|
||||
public readonly string Name;
|
||||
public readonly Expression Alias;
|
||||
public readonly NamespaceEntry NamespaceEntry;
|
||||
public readonly Location Location;
|
||||
|
||||
public AliasEntry (NamespaceEntry entry, string name, Expression alias, Location loc)
|
||||
{
|
||||
Name = name;
|
||||
Alias = alias;
|
||||
NamespaceEntry = entry;
|
||||
Location = loc;
|
||||
}
|
||||
|
||||
FullNamedExpression resolved;
|
||||
|
||||
public FullNamedExpression Resolve ()
|
||||
{
|
||||
if (resolved != null)
|
||||
return resolved;
|
||||
|
||||
DeclSpace root = RootContext.Tree.Types;
|
||||
root.NamespaceEntry = NamespaceEntry;
|
||||
resolved = Alias.ResolveAsTypeStep (root.EmitContext);
|
||||
root.NamespaceEntry = null;
|
||||
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
|
||||
public NamespaceEntry (NamespaceEntry parent, SourceFile file, string name, Location loc)
|
||||
{
|
||||
this.parent = parent;
|
||||
this.file = file;
|
||||
this.IsImplicit = false;
|
||||
this.ID = ++next_id;
|
||||
|
||||
if (parent != null)
|
||||
ns = parent.NS.GetNamespace (name, true);
|
||||
else if (name != null)
|
||||
ns = Namespace.LookupNamespace (name, true);
|
||||
else
|
||||
ns = Namespace.Root;
|
||||
ns.AddNamespaceEntry (this);
|
||||
this.FullName = ns.Name;
|
||||
}
|
||||
|
||||
|
||||
private NamespaceEntry (NamespaceEntry parent, SourceFile file, Namespace ns)
|
||||
{
|
||||
this.parent = parent;
|
||||
this.file = file;
|
||||
this.IsImplicit = true;
|
||||
this.ID = ++next_id;
|
||||
this.ns = ns;
|
||||
this.FullName = ns.Name;
|
||||
}
|
||||
|
||||
//
|
||||
// According to section 16.3.1 (using-alias-directive), the namespace-or-type-name is
|
||||
// resolved as if the immediately containing namespace body has no using-directives.
|
||||
//
|
||||
// Section 16.3.2 says that the same rule is applied when resolving the namespace-name
|
||||
// in the using-namespace-directive.
|
||||
//
|
||||
// To implement these rules, the expressions in the using directives are resolved using
|
||||
// the "doppelganger" (ghostly bodiless duplicate).
|
||||
//
|
||||
NamespaceEntry doppelganger;
|
||||
NamespaceEntry Doppelganger {
|
||||
get {
|
||||
if (!IsImplicit && doppelganger == null)
|
||||
doppelganger = new NamespaceEntry (ImplicitParent, file, ns);
|
||||
return doppelganger;
|
||||
}
|
||||
}
|
||||
|
||||
static int next_id = 0;
|
||||
public readonly string FullName;
|
||||
public readonly int ID;
|
||||
public readonly bool IsImplicit;
|
||||
|
||||
public Namespace NS {
|
||||
get {
|
||||
return ns;
|
||||
}
|
||||
}
|
||||
|
||||
public NamespaceEntry Parent {
|
||||
get {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
||||
public NamespaceEntry ImplicitParent {
|
||||
get {
|
||||
if (parent == null)
|
||||
return null;
|
||||
if (implicit_parent == null) {
|
||||
implicit_parent = (parent.NS == ns.Parent)
|
||||
? parent
|
||||
: new NamespaceEntry (parent, file, ns.Parent);
|
||||
}
|
||||
return implicit_parent;
|
||||
}
|
||||
}
|
||||
|
||||
public void DefineName (string name, IAlias o)
|
||||
{
|
||||
ns.DefineName (name, o);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Records a new namespace for resolving name references
|
||||
/// </summary>
|
||||
public void Using (Expression ns, Location loc)
|
||||
{
|
||||
string name = ns.ToString ();
|
||||
if (DeclarationFound){
|
||||
Report.Error (1529, loc, "A using clause must precede all other namespace elements");
|
||||
return;
|
||||
}
|
||||
|
||||
if (name == FullName)
|
||||
return;
|
||||
|
||||
if (using_clauses == null)
|
||||
using_clauses = new ArrayList ();
|
||||
|
||||
foreach (UsingEntry old_entry in using_clauses) {
|
||||
if (old_entry.Name.ToString () == name) {
|
||||
if (RootContext.WarningLevel >= 3)
|
||||
Report.Warning (105, loc, "The using directive for '{0}' appeared previously in this namespace", name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UsingEntry ue = new UsingEntry (Doppelganger, ns, loc);
|
||||
using_clauses.Add (ue);
|
||||
}
|
||||
|
||||
public void UsingAlias (string name, Expression alias, Location loc)
|
||||
{
|
||||
if (DeclarationFound){
|
||||
Report.Error (1529, loc, "A using clause must precede all other namespace elements");
|
||||
return;
|
||||
}
|
||||
|
||||
if (aliases == null)
|
||||
aliases = new Hashtable ();
|
||||
|
||||
if (aliases.Contains (name)){
|
||||
Report.Error (1537, loc, "The using alias `" + name +
|
||||
"' appeared previously in this namespace");
|
||||
return;
|
||||
}
|
||||
|
||||
aliases [name] = new AliasEntry (Doppelganger, name, alias, loc);
|
||||
}
|
||||
|
||||
public FullNamedExpression LookupAlias (string alias)
|
||||
{
|
||||
AliasEntry entry = null;
|
||||
if (aliases != null)
|
||||
entry = (AliasEntry) aliases [alias];
|
||||
|
||||
return entry == null ? null : entry.Resolve ();
|
||||
}
|
||||
|
||||
public FullNamedExpression LookupNamespaceOrType (DeclSpace ds, string name, Location loc)
|
||||
{
|
||||
FullNamedExpression resolved = null;
|
||||
string rest = null;
|
||||
|
||||
// If name is of the form `N.I', first lookup `N', then search a member `I' in it.
|
||||
int pos = name.IndexOf ('.');
|
||||
if (pos >= 0) {
|
||||
rest = name.Substring (pos + 1);
|
||||
name = name.Substring (0, pos);
|
||||
}
|
||||
|
||||
for (NamespaceEntry curr_ns = this; curr_ns != null; curr_ns = curr_ns.ImplicitParent) {
|
||||
if ((resolved = curr_ns.Lookup (ds, name, loc)) != null)
|
||||
break;
|
||||
}
|
||||
|
||||
if (resolved == null || rest == null)
|
||||
return resolved;
|
||||
|
||||
Namespace ns = resolved as Namespace;
|
||||
if (ns != null)
|
||||
return ns.Lookup (ds, rest, loc);
|
||||
|
||||
Type nested = TypeManager.LookupType (resolved.FullName + "." + rest);
|
||||
if ((nested == null) || ((ds != null) && !ds.CheckAccessLevel (nested)))
|
||||
return null;
|
||||
|
||||
return new TypeExpression (nested, Location.Null);
|
||||
}
|
||||
|
||||
private FullNamedExpression Lookup (DeclSpace ds, string name, Location loc)
|
||||
{
|
||||
// Precondition: Only simple names (no dots) will be looked up with this function.
|
||||
|
||||
//
|
||||
// Check whether it's in the namespace.
|
||||
//
|
||||
FullNamedExpression o = NS.Lookup (ds, name, loc);
|
||||
if (o != null)
|
||||
return o;
|
||||
|
||||
if (IsImplicit)
|
||||
return null;
|
||||
|
||||
//
|
||||
// Check aliases.
|
||||
//
|
||||
o = LookupAlias (name);
|
||||
if (o != null)
|
||||
return o;
|
||||
|
||||
//
|
||||
// Check using entries.
|
||||
//
|
||||
FullNamedExpression t = null, match = null;
|
||||
foreach (Namespace using_ns in GetUsingTable ()) {
|
||||
match = using_ns.Lookup (ds, name, loc);
|
||||
if ((match != null) && (match is TypeExpr)) {
|
||||
if (t != null) {
|
||||
DeclSpace.Error_AmbiguousTypeReference (loc, name, t.FullName, match.FullName);
|
||||
return null;
|
||||
} else {
|
||||
t = match;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
// Our cached computation.
|
||||
Namespace [] namespace_using_table;
|
||||
public Namespace[] GetUsingTable ()
|
||||
{
|
||||
if (namespace_using_table != null)
|
||||
return namespace_using_table;
|
||||
|
||||
if (using_clauses == null) {
|
||||
namespace_using_table = new Namespace [0];
|
||||
return namespace_using_table;
|
||||
}
|
||||
|
||||
ArrayList list = new ArrayList (using_clauses.Count);
|
||||
|
||||
foreach (UsingEntry ue in using_clauses) {
|
||||
Namespace using_ns = ue.Resolve ();
|
||||
if (using_ns == null)
|
||||
continue;
|
||||
|
||||
list.Add (using_ns);
|
||||
}
|
||||
|
||||
namespace_using_table = new Namespace [list.Count];
|
||||
list.CopyTo (namespace_using_table, 0);
|
||||
return namespace_using_table;
|
||||
}
|
||||
|
||||
public void DefineNamespace (SymbolWriter symwriter)
|
||||
{
|
||||
if (symfile_id != 0)
|
||||
return;
|
||||
if (parent != null)
|
||||
parent.DefineNamespace (symwriter);
|
||||
|
||||
string[] using_list;
|
||||
if (using_clauses != null) {
|
||||
using_list = new string [using_clauses.Count];
|
||||
for (int i = 0; i < using_clauses.Count; i++)
|
||||
using_list [i] = ((UsingEntry) using_clauses [i]).Name.ToString ();
|
||||
} else {
|
||||
using_list = new string [0];
|
||||
}
|
||||
|
||||
int parent_id = parent != null ? parent.symfile_id : 0;
|
||||
if (file.SourceFileEntry == null)
|
||||
return;
|
||||
|
||||
symfile_id = symwriter.DefineNamespace (
|
||||
ns.Name, file.SourceFileEntry, using_list, parent_id);
|
||||
}
|
||||
|
||||
public int SymbolFileID {
|
||||
get {
|
||||
return symfile_id;
|
||||
}
|
||||
}
|
||||
|
||||
static void MsgtryRef (string s)
|
||||
{
|
||||
Console.WriteLine (" Try using -r:" + s);
|
||||
}
|
||||
|
||||
static void MsgtryPkg (string s)
|
||||
{
|
||||
Console.WriteLine (" Try using -pkg:" + s);
|
||||
}
|
||||
|
||||
protected void error246 (Location loc, string name)
|
||||
{
|
||||
Report.Error (246, loc, "The namespace `" + name +
|
||||
"' can not be found (missing assembly reference?)");
|
||||
|
||||
switch (name) {
|
||||
case "Gtk": case "GtkSharp":
|
||||
MsgtryPkg ("gtk-sharp");
|
||||
break;
|
||||
|
||||
case "Gdk": case "GdkSharp":
|
||||
MsgtryPkg ("gdk-sharp");
|
||||
break;
|
||||
|
||||
case "Glade": case "GladeSharp":
|
||||
MsgtryPkg ("glade-sharp");
|
||||
break;
|
||||
|
||||
case "System.Drawing":
|
||||
case "System.Web.Services":
|
||||
case "System.Web":
|
||||
case "System.Data":
|
||||
case "System.Windows.Forms":
|
||||
MsgtryRef (name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to validate that all the using clauses are correct
|
||||
/// after we are finished parsing all the files.
|
||||
/// </summary>
|
||||
public void VerifyUsing ()
|
||||
{
|
||||
if (using_clauses != null){
|
||||
foreach (UsingEntry ue in using_clauses){
|
||||
if (ue.Resolve () != null)
|
||||
continue;
|
||||
|
||||
if (ue.resolved == null)
|
||||
error246 (ue.Location, ue.Name.ToString ());
|
||||
else
|
||||
Report.Error (138, ue.Location, "The using keyword only lets you specify a namespace, " +
|
||||
"`" + ue.Name + "' is a class not a namespace.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (aliases != null){
|
||||
foreach (DictionaryEntry de in aliases){
|
||||
AliasEntry alias = (AliasEntry) de.Value;
|
||||
|
||||
if (alias.Resolve () != null)
|
||||
continue;
|
||||
|
||||
error246 (alias.Location, alias.Alias.ToString ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
if (NS == Namespace.Root)
|
||||
return "NamespaceEntry (<root>)";
|
||||
else
|
||||
return String.Format ("NamespaceEntry ({0},{1},{2})", FullName, IsImplicit, ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,720 @@
|
||||
//
|
||||
// parameter.cs: Parameter definition.
|
||||
//
|
||||
// Author: Miguel de Icaza ([email protected])
|
||||
//
|
||||
// Licensed under the terms of the GNU GPL
|
||||
//
|
||||
// (C) 2001 Ximian, Inc (http://www.ximian.com)
|
||||
//
|
||||
//
|
||||
//
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Collections;
|
||||
|
||||
namespace Mono.CSharp {
|
||||
|
||||
/// <summary>
|
||||
/// Abstract Base class for parameters of a method.
|
||||
/// </summary>
|
||||
public abstract class ParameterBase : Attributable {
|
||||
|
||||
protected ParameterBuilder builder;
|
||||
|
||||
public ParameterBase (Attributes attrs)
|
||||
: base (attrs)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
|
||||
{
|
||||
if (a.Type == TypeManager.marshal_as_attr_type) {
|
||||
UnmanagedMarshal marshal = a.GetMarshal (this);
|
||||
if (marshal != null) {
|
||||
builder.SetMarshal (marshal);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (a.Type.IsSubclassOf (TypeManager.security_attr_type)) {
|
||||
a.Error_InvalidSecurityParent ();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.SetCustomAttribute (cb);
|
||||
}
|
||||
|
||||
public override bool IsClsCompliaceRequired(DeclSpace ds)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class for applying custom attributes on the return type
|
||||
/// </summary>
|
||||
public class ReturnParameter: ParameterBase {
|
||||
public ReturnParameter (MethodBuilder mb, Location location):
|
||||
base (null)
|
||||
{
|
||||
try {
|
||||
builder = mb.DefineParameter (0, ParameterAttributes.None, "");
|
||||
}
|
||||
catch (ArgumentOutOfRangeException) {
|
||||
Report.Warning (-28, location, "The Microsoft .NET Runtime 1.x does not permit setting custom attributes on the return type");
|
||||
}
|
||||
}
|
||||
|
||||
public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
|
||||
{
|
||||
if (a.Type == TypeManager.cls_compliant_attribute_type) {
|
||||
Report.Warning (3023, 1, a.Location, "CLSCompliant attribute has no meaning when applied to return types. Try putting it on the method instead");
|
||||
}
|
||||
|
||||
// This occurs after Warning -28
|
||||
if (builder == null)
|
||||
return;
|
||||
|
||||
base.ApplyAttributeBuilder (a, cb);
|
||||
}
|
||||
|
||||
public override AttributeTargets AttributeTargets {
|
||||
get {
|
||||
return AttributeTargets.ReturnValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is never called
|
||||
/// </summary>
|
||||
public override string[] ValidAttributeTargets {
|
||||
get {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class for applying custom attributes on the implicit parameter type
|
||||
/// of the 'set' method in properties, and the 'add' and 'remove' methods in events.
|
||||
/// </summary>
|
||||
public class ImplicitParameter: ParameterBase {
|
||||
public ImplicitParameter (MethodBuilder mb):
|
||||
base (null)
|
||||
{
|
||||
builder = mb.DefineParameter (1, ParameterAttributes.None, "");
|
||||
}
|
||||
|
||||
public override AttributeTargets AttributeTargets {
|
||||
get {
|
||||
return AttributeTargets.Parameter;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is never called
|
||||
/// </summary>
|
||||
public override string[] ValidAttributeTargets {
|
||||
get {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Represents a single method parameter
|
||||
/// </summary>
|
||||
|
||||
//TODO: Add location member to this or base class for better error location and all methods simplification.
|
||||
public class Parameter : ParameterBase {
|
||||
[Flags]
|
||||
public enum Modifier : byte {
|
||||
NONE = 0,
|
||||
VAL = 0,
|
||||
REF = 1,
|
||||
OUT = 2,
|
||||
PARAMS = 4,
|
||||
// This is a flag which says that it's either REF or OUT.
|
||||
ISBYREF = 8,
|
||||
ARGLIST = 16,
|
||||
// This value is changed from the one in mbas source code
|
||||
OPTIONAL = 32
|
||||
}
|
||||
|
||||
static string[] attribute_targets = new string [] { "param" };
|
||||
|
||||
public Expression TypeName;
|
||||
public readonly Modifier ModFlags;
|
||||
public readonly string Name;
|
||||
GenericConstraints constraints;
|
||||
Type parameter_type;
|
||||
|
||||
EmitContext ec; // because ApplyAtrribute doesn't have ec
|
||||
|
||||
/* These two fields are mbas specific. The corresponding
|
||||
changes need to be merged from mbas */
|
||||
|
||||
public readonly Expression ParameterInitializer;
|
||||
public readonly bool IsOptional;
|
||||
|
||||
public Parameter (Expression type, string name, Modifier mod, Attributes attrs)
|
||||
: base (attrs)
|
||||
{
|
||||
Name = name;
|
||||
ModFlags = mod;
|
||||
TypeName = type;
|
||||
ParameterInitializer = null;
|
||||
IsOptional = false;
|
||||
}
|
||||
|
||||
public Parameter (Expression type, string name, Modifier mod, Attributes attrs, Expression pi)
|
||||
: base (attrs)
|
||||
{
|
||||
Name = name;
|
||||
ModFlags = mod;
|
||||
TypeName = type;
|
||||
ParameterInitializer = pi;
|
||||
IsOptional = false;
|
||||
}
|
||||
|
||||
public Parameter (Expression type, string name, Modifier mod, Attributes attrs, Expression pi, bool opt)
|
||||
: base (attrs)
|
||||
{
|
||||
Name = name;
|
||||
ModFlags = mod;
|
||||
TypeName = type;
|
||||
ParameterInitializer = pi;
|
||||
IsOptional = opt;
|
||||
}
|
||||
|
||||
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
|
||||
{
|
||||
if (a.Type == TypeManager.in_attribute_type && Attributes == ParameterAttributes.Out) {
|
||||
Report.Error (36, a.Location, "Can not use [In] attribute on out parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
if (a.Type == TypeManager.param_array_type) {
|
||||
Report.Error (674, a.Location, "Do not use 'System.ParamArrayAttribute'. Use the 'params' keyword instead");
|
||||
return;
|
||||
}
|
||||
|
||||
if (a.Type == TypeManager.out_attribute_type && (ModFlags & Modifier.REF) != 0 &&
|
||||
!OptAttributes.Contains (TypeManager.in_attribute_type, ec)) {
|
||||
Report.Error (662, a.Location,
|
||||
"'{0}' cannot specify only Out attribute on a ref parameter. Use both In and Out attributes, or neither", GetSignatureForError ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (a.Type == TypeManager.cls_compliant_attribute_type) {
|
||||
Report.Warning (3022, 1, a.Location, "CLSCompliant attribute has no meaning when applied to parameters. Try putting it on the method instead");
|
||||
}
|
||||
|
||||
base.ApplyAttributeBuilder (a, cb);
|
||||
}
|
||||
|
||||
// <summary>
|
||||
// Resolve is used in method definitions
|
||||
// </summary>
|
||||
public bool Resolve (EmitContext ec, Location l)
|
||||
{
|
||||
TypeExpr texpr = TypeName.ResolveAsTypeTerminal (ec);
|
||||
this.ec = ec;
|
||||
|
||||
if (texpr == null)
|
||||
return false;
|
||||
|
||||
TypeParameterExpr tparam = texpr as TypeParameterExpr;
|
||||
if (tparam != null)
|
||||
constraints = tparam.TypeParameter.Constraints;
|
||||
|
||||
parameter_type = texpr.Type;
|
||||
|
||||
if (parameter_type.IsAbstract && parameter_type.IsSealed) {
|
||||
Report.Error (721, l, "'{0}': static types cannot be used as parameters", GetSignatureForError ());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (parameter_type == TypeManager.void_type){
|
||||
Report.Error (1536, l, "Invalid parameter type 'void'");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((ModFlags & Parameter.Modifier.ISBYREF) != 0){
|
||||
if (parameter_type == TypeManager.typed_reference_type ||
|
||||
parameter_type == TypeManager.arg_iterator_type){
|
||||
Report.Error (1601, l,
|
||||
"out or ref parameter can not be of type TypedReference or ArgIterator");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return parameter_type != null;
|
||||
}
|
||||
|
||||
public Type ExternalType ()
|
||||
{
|
||||
if ((ModFlags & Parameter.Modifier.ISBYREF) != 0)
|
||||
return TypeManager.GetReferenceType (parameter_type);
|
||||
|
||||
return parameter_type;
|
||||
}
|
||||
|
||||
public Type ParameterType {
|
||||
get {
|
||||
return parameter_type;
|
||||
}
|
||||
}
|
||||
|
||||
public GenericConstraints GenericConstraints {
|
||||
get {
|
||||
return constraints;
|
||||
}
|
||||
}
|
||||
|
||||
public ParameterAttributes Attributes {
|
||||
get {
|
||||
int flags = ((int) ModFlags) & ~((int) Parameter.Modifier.ISBYREF);
|
||||
switch ((Modifier) flags) {
|
||||
case Modifier.NONE:
|
||||
return ParameterAttributes.None;
|
||||
case Modifier.REF:
|
||||
return ParameterAttributes.None;
|
||||
case Modifier.OUT:
|
||||
return ParameterAttributes.Out;
|
||||
case Modifier.PARAMS:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ParameterAttributes.None;
|
||||
}
|
||||
}
|
||||
|
||||
public static ParameterAttributes GetParameterAttributes (Modifier mod)
|
||||
{
|
||||
int flags = ((int) mod) & ~((int) Parameter.Modifier.ISBYREF);
|
||||
switch ((Modifier) flags) {
|
||||
case Modifier.NONE:
|
||||
return ParameterAttributes.None;
|
||||
case Modifier.REF:
|
||||
return ParameterAttributes.None;
|
||||
case Modifier.OUT:
|
||||
return ParameterAttributes.Out;
|
||||
case Modifier.PARAMS:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ParameterAttributes.None;
|
||||
}
|
||||
|
||||
public override AttributeTargets AttributeTargets {
|
||||
get {
|
||||
return AttributeTargets.Parameter;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the signature for this parameter evaluating it on the
|
||||
/// @tc context
|
||||
/// </summary>
|
||||
public string GetSignature (EmitContext ec, Location loc)
|
||||
{
|
||||
if (parameter_type == null){
|
||||
if (!Resolve (ec, loc))
|
||||
return null;
|
||||
}
|
||||
|
||||
return ExternalType ().FullName;
|
||||
}
|
||||
|
||||
public string GetSignatureForError ()
|
||||
{
|
||||
string typeName;
|
||||
if (parameter_type != null)
|
||||
typeName = TypeManager.CSharpName (parameter_type);
|
||||
else if (TypeName.Type != null)
|
||||
typeName = TypeManager.CSharpName (TypeName.Type);
|
||||
else
|
||||
typeName = TypeName.ToString ();
|
||||
|
||||
switch (ModFlags & unchecked (~Modifier.ISBYREF)) {
|
||||
case Modifier.OUT:
|
||||
return "out " + typeName;
|
||||
case Modifier.PARAMS:
|
||||
return "params " + typeName;
|
||||
case Modifier.REF:
|
||||
return "ref " + typeName;
|
||||
}
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public void DefineParameter (EmitContext ec, MethodBuilder mb, ConstructorBuilder cb, int index, Location loc)
|
||||
{
|
||||
ParameterAttributes par_attr = Attributes;
|
||||
|
||||
if (mb == null)
|
||||
builder = cb.DefineParameter (index, par_attr, Name);
|
||||
else
|
||||
builder = mb.DefineParameter (index, par_attr, Name);
|
||||
|
||||
if (OptAttributes != null) {
|
||||
OptAttributes.Emit (ec, this);
|
||||
}
|
||||
}
|
||||
|
||||
public override string[] ValidAttributeTargets {
|
||||
get {
|
||||
return attribute_targets;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the methods parameters
|
||||
/// </summary>
|
||||
public class Parameters {
|
||||
public Parameter [] FixedParameters;
|
||||
public readonly Parameter ArrayParameter;
|
||||
public readonly bool HasArglist;
|
||||
string signature;
|
||||
Type [] types;
|
||||
Location loc;
|
||||
|
||||
static Parameters empty_parameters;
|
||||
|
||||
public Parameters (Parameter [] fixed_parameters, Parameter array_parameter, Location l)
|
||||
{
|
||||
FixedParameters = fixed_parameters;
|
||||
ArrayParameter = array_parameter;
|
||||
loc = l;
|
||||
}
|
||||
|
||||
public Parameters (Parameter [] fixed_parameters, bool has_arglist, Location l)
|
||||
{
|
||||
FixedParameters = fixed_parameters;
|
||||
HasArglist = has_arglist;
|
||||
loc = l;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used to reuse a set of empty parameters, because they
|
||||
/// are common
|
||||
/// </summary>
|
||||
public static Parameters EmptyReadOnlyParameters {
|
||||
get {
|
||||
if (empty_parameters == null)
|
||||
empty_parameters = new Parameters (null, null, Location.Null);
|
||||
|
||||
return empty_parameters;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Empty {
|
||||
get {
|
||||
return (FixedParameters == null) && (ArrayParameter == null);
|
||||
}
|
||||
}
|
||||
|
||||
public void ComputeSignature (EmitContext ec)
|
||||
{
|
||||
signature = "";
|
||||
if (FixedParameters != null){
|
||||
for (int i = 0; i < FixedParameters.Length; i++){
|
||||
Parameter par = FixedParameters [i];
|
||||
|
||||
signature += par.GetSignature (ec, loc);
|
||||
}
|
||||
}
|
||||
//
|
||||
// Note: as per the spec, the `params' arguments (ArrayParameter)
|
||||
// are not used in the signature computation for a method
|
||||
//
|
||||
}
|
||||
|
||||
void Error_DuplicateParameterName (string name)
|
||||
{
|
||||
Report.Error (
|
||||
100, loc, "The parameter name `" + name + "' is a duplicate");
|
||||
}
|
||||
|
||||
public bool VerifyArgs ()
|
||||
{
|
||||
int count;
|
||||
int i, j;
|
||||
|
||||
if (FixedParameters == null)
|
||||
return true;
|
||||
|
||||
count = FixedParameters.Length;
|
||||
string array_par_name = ArrayParameter != null ? ArrayParameter.Name : null;
|
||||
|
||||
for (i = 0; i < count; i++){
|
||||
string base_name = FixedParameters [i].Name;
|
||||
for (j = i + 1; j < count; j++){
|
||||
if (base_name != FixedParameters [j].Name)
|
||||
continue;
|
||||
Error_DuplicateParameterName (base_name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (base_name == array_par_name){
|
||||
Error_DuplicateParameterName (base_name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the signature of the Parameters evaluated in
|
||||
/// the @ec EmitContext
|
||||
/// </summary>
|
||||
public string GetSignature (EmitContext ec)
|
||||
{
|
||||
if (signature == null){
|
||||
VerifyArgs ();
|
||||
ComputeSignature (ec);
|
||||
}
|
||||
|
||||
return signature;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the paramenter information based on the name
|
||||
/// </summary>
|
||||
public Parameter GetParameterByName (string name, out int idx)
|
||||
{
|
||||
idx = 0;
|
||||
int i = 0;
|
||||
|
||||
if (FixedParameters != null){
|
||||
foreach (Parameter par in FixedParameters){
|
||||
if (par.Name == name){
|
||||
idx = i;
|
||||
return par;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (ArrayParameter != null){
|
||||
if (name == ArrayParameter.Name){
|
||||
idx = i;
|
||||
return ArrayParameter;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Parameter GetParameterByName (string name)
|
||||
{
|
||||
int idx;
|
||||
|
||||
return GetParameterByName (name, out idx);
|
||||
}
|
||||
|
||||
bool ComputeParameterTypes (EmitContext ec)
|
||||
{
|
||||
int extra = (ArrayParameter != null) ? 1 : 0;
|
||||
int i = 0;
|
||||
int pc;
|
||||
|
||||
if (FixedParameters == null)
|
||||
pc = extra;
|
||||
else
|
||||
pc = extra + FixedParameters.Length;
|
||||
|
||||
types = new Type [pc];
|
||||
|
||||
if (!VerifyArgs ()){
|
||||
FixedParameters = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool failed = false;
|
||||
if (FixedParameters != null){
|
||||
foreach (Parameter p in FixedParameters){
|
||||
Type t = null;
|
||||
|
||||
if (p.Resolve (ec, loc))
|
||||
t = p.ExternalType ();
|
||||
else
|
||||
failed = true;
|
||||
|
||||
types [i] = t;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (extra > 0){
|
||||
if (ArrayParameter.Resolve (ec, loc))
|
||||
types [i] = ArrayParameter.ExternalType ();
|
||||
else
|
||||
failed = true;
|
||||
}
|
||||
|
||||
if (failed){
|
||||
types = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// This variant is used by Delegates, because they need to
|
||||
// resolve/define names, instead of the plain LookupType
|
||||
//
|
||||
public bool ComputeAndDefineParameterTypes (EmitContext ec)
|
||||
{
|
||||
bool old_type_resolving = ec.ResolvingTypeTree;
|
||||
ec.ResolvingTypeTree = true;
|
||||
bool retval = ComputeParameterTypes (ec);
|
||||
ec.ResolvingTypeTree = old_type_resolving;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the argument types as an array
|
||||
/// </summary>
|
||||
static Type [] no_types = new Type [0];
|
||||
|
||||
public Type [] GetParameterInfo (EmitContext ec)
|
||||
{
|
||||
if (types != null)
|
||||
return types;
|
||||
|
||||
if (FixedParameters == null && ArrayParameter == null)
|
||||
return no_types;
|
||||
|
||||
if (ComputeParameterTypes (ec) == false){
|
||||
types = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the type of a given parameter, and stores in the `is_out'
|
||||
/// boolean whether this is an out or ref parameter.
|
||||
///
|
||||
/// Note that the returned type will not contain any dereference in this
|
||||
/// case (ie, you get "int" for a ref int instead of "int&"
|
||||
/// </summary>
|
||||
public Type GetParameterInfo (EmitContext ec, int idx, out Parameter.Modifier mod)
|
||||
{
|
||||
mod = Parameter.Modifier.NONE;
|
||||
|
||||
if (!VerifyArgs ()){
|
||||
FixedParameters = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (FixedParameters == null && ArrayParameter == null)
|
||||
return null;
|
||||
|
||||
if (types == null)
|
||||
if (ComputeParameterTypes (ec) == false)
|
||||
return null;
|
||||
|
||||
//
|
||||
// If this is a request for the variable lenght arg.
|
||||
//
|
||||
int array_idx = (FixedParameters != null ? FixedParameters.Length : 0);
|
||||
if (idx == array_idx)
|
||||
return types [idx];
|
||||
|
||||
//
|
||||
// Otherwise, it is a fixed parameter
|
||||
//
|
||||
Parameter p = FixedParameters [idx];
|
||||
mod = p.ModFlags;
|
||||
|
||||
if ((mod & (Parameter.Modifier.REF | Parameter.Modifier.OUT)) != 0)
|
||||
mod |= Parameter.Modifier.ISBYREF;
|
||||
|
||||
return p.ParameterType;
|
||||
}
|
||||
|
||||
public CallingConventions GetCallingConvention ()
|
||||
{
|
||||
if (HasArglist)
|
||||
return CallingConventions.VarArgs;
|
||||
else
|
||||
return CallingConventions.Standard;
|
||||
}
|
||||
|
||||
//
|
||||
// The method's attributes are passed in because we need to extract
|
||||
// the "return:" attribute from there to apply on the return type
|
||||
//
|
||||
public void LabelParameters (EmitContext ec,
|
||||
MethodBase builder,
|
||||
Location loc) {
|
||||
//
|
||||
// Define each type attribute (in/out/ref) and
|
||||
// the argument names.
|
||||
//
|
||||
int i = 0;
|
||||
|
||||
MethodBuilder mb = builder as MethodBuilder;
|
||||
ConstructorBuilder cb = builder as ConstructorBuilder;
|
||||
|
||||
if (FixedParameters != null) {
|
||||
for (i = 0; i < FixedParameters.Length; i++) {
|
||||
FixedParameters [i].DefineParameter (ec, mb, cb, i + 1, loc);
|
||||
}
|
||||
}
|
||||
|
||||
if (ArrayParameter != null){
|
||||
ParameterBuilder pb;
|
||||
Parameter array_param = ArrayParameter;
|
||||
|
||||
if (mb == null)
|
||||
pb = cb.DefineParameter (
|
||||
i + 1, array_param.Attributes,
|
||||
array_param.Name);
|
||||
else
|
||||
pb = mb.DefineParameter (
|
||||
i + 1, array_param.Attributes,
|
||||
array_param.Name);
|
||||
|
||||
CustomAttributeBuilder a = new CustomAttributeBuilder (
|
||||
TypeManager.cons_param_array_attribute, new object [0]);
|
||||
|
||||
pb.SetCustomAttribute (a);
|
||||
}
|
||||
}
|
||||
|
||||
public Parameters Copy (Location l)
|
||||
{
|
||||
Parameters p = new Parameters (null, null, l);
|
||||
p.FixedParameters = new Parameter[this.FixedParameters.Length];
|
||||
this.FixedParameters.CopyTo (p.FixedParameters, 0);
|
||||
|
||||
return (p);
|
||||
}
|
||||
|
||||
public void AppendParameter (Parameter p)
|
||||
{
|
||||
if (FixedParameters != null)
|
||||
{
|
||||
Parameter [] pa = new Parameter [FixedParameters.Length+1];
|
||||
FixedParameters.CopyTo (pa, 0);
|
||||
pa[FixedParameters.Length] = p;
|
||||
FixedParameters = pa;
|
||||
}
|
||||
else
|
||||
{
|
||||
FixedParameters = new Parameter [1];
|
||||
FixedParameters[0] = p;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
namespace Compiler {
|
||||
|
||||
using System;
|
||||
|
||||
abstract public class Parser {
|
||||
public string name;
|
||||
public System.IO.Stream input;
|
||||
|
||||
public Parser (Mono.CSharp.Tree tree, string name, System.IO.Stream stream)
|
||||
{
|
||||
this.tree = tree;
|
||||
this.name = name;
|
||||
this.input = stream;
|
||||
}
|
||||
|
||||
public string getName (){
|
||||
return name;
|
||||
}
|
||||
|
||||
abstract public int parse ();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,572 @@
|
||||
//
|
||||
// pending.cs: Pending method implementation
|
||||
//
|
||||
// Author:
|
||||
// Miguel de Icaza ([email protected])
|
||||
//
|
||||
// Licensed under the terms of the GNU GPL
|
||||
//
|
||||
// (C) 2001, 2002 Ximian, Inc (http://www.ximian.com)
|
||||
//
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
|
||||
namespace Mono.CSharp {
|
||||
|
||||
struct TypeAndMethods {
|
||||
public Type type;
|
||||
public MethodInfo [] methods;
|
||||
|
||||
//
|
||||
// Whether it is optional, this is used to allow the explicit/implicit
|
||||
// implementation when a base class already implements an interface.
|
||||
//
|
||||
// For example:
|
||||
//
|
||||
// class X : IA { } class Y : X, IA { IA.Explicit (); }
|
||||
//
|
||||
public bool optional;
|
||||
|
||||
// Far from ideal, but we want to avoid creating a copy
|
||||
// of methods above.
|
||||
public Type [][] args;
|
||||
|
||||
//
|
||||
// This flag on the method says `We found a match, but
|
||||
// because it was private, we could not use the match
|
||||
//
|
||||
public bool [] found;
|
||||
|
||||
// If a method is defined here, then we always need to
|
||||
// create a proxy for it. This is used when implementing
|
||||
// an interface's indexer with a different IndexerName.
|
||||
public MethodInfo [] need_proxy;
|
||||
|
||||
//
|
||||
// The name of the indexer (if it exists), precompute set/get, because
|
||||
// they would be recomputed many times inside a loop later on.
|
||||
//
|
||||
public string set_indexer_name;
|
||||
public string get_indexer_name;
|
||||
}
|
||||
|
||||
public class PendingImplementation {
|
||||
/// <summary>
|
||||
/// The container for this PendingImplementation
|
||||
/// </summary>
|
||||
TypeContainer container;
|
||||
|
||||
/// <summary>
|
||||
/// This filter is used by FindMembers, and it is used to
|
||||
/// extract only virtual/abstract fields
|
||||
/// </summary>
|
||||
static MemberFilter virtual_method_filter;
|
||||
|
||||
/// <summary>
|
||||
/// This is the array of TypeAndMethods that describes the pending implementations
|
||||
/// (both interfaces and abstract methods in base class)
|
||||
/// </summary>
|
||||
TypeAndMethods [] pending_implementations;
|
||||
|
||||
static bool IsVirtualFilter (MemberInfo m, object filterCriteria)
|
||||
{
|
||||
MethodInfo mi = m as MethodInfo;
|
||||
return (mi == null) ? false : mi.IsVirtual;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inits the virtual_method_filter
|
||||
/// </summary>
|
||||
static PendingImplementation ()
|
||||
{
|
||||
virtual_method_filter = new MemberFilter (IsVirtualFilter);
|
||||
}
|
||||
|
||||
// <remarks>
|
||||
// Returns a list of the abstract methods that are exposed by all of our
|
||||
// bases that we must implement. Notice that this `flattens' the
|
||||
// method search space, and takes into account overrides.
|
||||
// </remarks>
|
||||
static ArrayList GetAbstractMethods (Type t)
|
||||
{
|
||||
ArrayList list = null;
|
||||
bool searching = true;
|
||||
Type current_type = t;
|
||||
|
||||
do {
|
||||
MemberList mi;
|
||||
|
||||
mi = TypeContainer.FindMembers (
|
||||
current_type, MemberTypes.Method,
|
||||
BindingFlags.Public | BindingFlags.Instance |
|
||||
BindingFlags.DeclaredOnly,
|
||||
virtual_method_filter, null);
|
||||
|
||||
if (current_type == TypeManager.object_type)
|
||||
searching = false;
|
||||
else {
|
||||
current_type = current_type.BaseType;
|
||||
if (!current_type.IsAbstract)
|
||||
searching = false;
|
||||
}
|
||||
|
||||
if (mi.Count == 0)
|
||||
continue;
|
||||
|
||||
if (mi.Count == 1 && !(mi [0] is MethodBase))
|
||||
searching = false;
|
||||
else
|
||||
list = TypeManager.CopyNewMethods (list, mi);
|
||||
} while (searching);
|
||||
|
||||
if (list == null)
|
||||
return null;
|
||||
|
||||
for (int i = 0; i < list.Count; i++){
|
||||
while (list.Count > i && !((MethodInfo) list [i]).IsAbstract)
|
||||
list.RemoveAt (i);
|
||||
}
|
||||
|
||||
if (list.Count == 0)
|
||||
return null;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
PendingImplementation (TypeContainer container, MissingInterfacesInfo [] missing_ifaces, ArrayList abstract_methods, int total)
|
||||
{
|
||||
TypeBuilder type_builder = container.TypeBuilder;
|
||||
|
||||
this.container = container;
|
||||
pending_implementations = new TypeAndMethods [total];
|
||||
|
||||
int i = 0;
|
||||
foreach (MissingInterfacesInfo missing in missing_ifaces){
|
||||
MethodInfo [] mi;
|
||||
Type t = missing.Type;
|
||||
|
||||
if (!t.IsInterface)
|
||||
continue;
|
||||
|
||||
if (t is TypeBuilder){
|
||||
TypeContainer iface;
|
||||
|
||||
iface = TypeManager.LookupInterface (t);
|
||||
|
||||
mi = iface.GetMethods ();
|
||||
} else
|
||||
mi = t.GetMethods ();
|
||||
|
||||
int count = mi.Length;
|
||||
pending_implementations [i].type = t;
|
||||
pending_implementations [i].optional = missing.Optional;
|
||||
pending_implementations [i].methods = mi;
|
||||
pending_implementations [i].args = new Type [count][];
|
||||
pending_implementations [i].found = new bool [count];
|
||||
pending_implementations [i].need_proxy = new MethodInfo [count];
|
||||
string indexer_name = TypeManager.IndexerPropertyName (t);
|
||||
|
||||
pending_implementations [i].set_indexer_name = "set_" + indexer_name;
|
||||
pending_implementations [i].get_indexer_name = "get_" + indexer_name;
|
||||
|
||||
int j = 0;
|
||||
foreach (MethodInfo m in mi){
|
||||
Type [] types = TypeManager.GetArgumentTypes (m);
|
||||
|
||||
pending_implementations [i].args [j] = types;
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (abstract_methods != null){
|
||||
int count = abstract_methods.Count;
|
||||
pending_implementations [i].methods = new MethodInfo [count];
|
||||
pending_implementations [i].need_proxy = new MethodInfo [count];
|
||||
|
||||
abstract_methods.CopyTo (pending_implementations [i].methods, 0);
|
||||
pending_implementations [i].found = new bool [count];
|
||||
pending_implementations [i].args = new Type [count][];
|
||||
pending_implementations [i].type = type_builder;
|
||||
|
||||
string indexer_name = TypeManager.IndexerPropertyName (type_builder);
|
||||
pending_implementations [i].set_indexer_name = "set_" + indexer_name;
|
||||
pending_implementations [i].get_indexer_name = "get_" + indexer_name;
|
||||
|
||||
int j = 0;
|
||||
foreach (MemberInfo m in abstract_methods){
|
||||
MethodInfo mi = (MethodInfo) m;
|
||||
|
||||
Type [] types = TypeManager.GetArgumentTypes (mi);
|
||||
|
||||
pending_implementations [i].args [j] = types;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct MissingInterfacesInfo {
|
||||
public Type Type;
|
||||
public bool Optional;
|
||||
|
||||
public MissingInterfacesInfo (Type t)
|
||||
{
|
||||
Type = t;
|
||||
Optional = false;
|
||||
}
|
||||
}
|
||||
|
||||
static MissingInterfacesInfo [] EmptyMissingInterfacesInfo = new MissingInterfacesInfo [0];
|
||||
|
||||
static MissingInterfacesInfo [] GetMissingInterfaces (TypeBuilder type_builder)
|
||||
{
|
||||
//
|
||||
// Notice that TypeBuilders will only return the interfaces that the Type
|
||||
// is supposed to implement, not all the interfaces that the type implements.
|
||||
//
|
||||
// Even better -- on MS it returns an empty array, no matter what.
|
||||
//
|
||||
// Completely broken. So we do it ourselves!
|
||||
//
|
||||
Type [] impl = TypeManager.GetExplicitInterfaces (type_builder);
|
||||
|
||||
if (impl == null || impl.Length == 0)
|
||||
return EmptyMissingInterfacesInfo;
|
||||
|
||||
MissingInterfacesInfo [] ret = new MissingInterfacesInfo [impl.Length];
|
||||
|
||||
for (int i = 0; i < impl.Length; i++)
|
||||
ret [i] = new MissingInterfacesInfo (impl [i]);
|
||||
|
||||
// we really should not get here because Object doesnt implement any
|
||||
// interfaces. But it could implement something internal, so we have
|
||||
// to handle that case.
|
||||
if (type_builder.BaseType == null)
|
||||
return ret;
|
||||
|
||||
Type [] base_impls = TypeManager.GetInterfaces (type_builder.BaseType);
|
||||
|
||||
foreach (Type t in base_impls) {
|
||||
for (int i = 0; i < ret.Length; i ++) {
|
||||
if (t == ret [i].Type) {
|
||||
ret [i].Optional = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//
|
||||
// Factory method: if there are pending implementation methods, we return a PendingImplementation
|
||||
// object, otherwise we return null.
|
||||
//
|
||||
// Register method implementations are either abstract methods
|
||||
// flagged as such on the base class or interface methods
|
||||
//
|
||||
static public PendingImplementation GetPendingImplementations (TypeContainer container)
|
||||
{
|
||||
TypeBuilder type_builder = container.TypeBuilder;
|
||||
MissingInterfacesInfo [] missing_interfaces;
|
||||
Type b = type_builder.BaseType;
|
||||
|
||||
missing_interfaces = GetMissingInterfaces (type_builder);
|
||||
|
||||
//
|
||||
// If we are implementing an abstract class, and we are not
|
||||
// ourselves abstract, and there are abstract methods (C# allows
|
||||
// abstract classes that have no abstract methods), then allocate
|
||||
// one slot.
|
||||
//
|
||||
// We also pre-compute the methods.
|
||||
//
|
||||
bool implementing_abstract = ((b != null) && b.IsAbstract && !type_builder.IsAbstract);
|
||||
ArrayList abstract_methods = null;
|
||||
|
||||
if (implementing_abstract){
|
||||
abstract_methods = GetAbstractMethods (b);
|
||||
|
||||
if (abstract_methods == null)
|
||||
implementing_abstract = false;
|
||||
}
|
||||
|
||||
int total = missing_interfaces.Length + (implementing_abstract ? 1 : 0);
|
||||
if (total == 0)
|
||||
return null;
|
||||
|
||||
return new PendingImplementation (container, missing_interfaces, abstract_methods, total);
|
||||
}
|
||||
|
||||
public enum Operation {
|
||||
//
|
||||
// If you change this, review the whole InterfaceMethod routine as there
|
||||
// are a couple of assumptions on these three states
|
||||
//
|
||||
Lookup, ClearOne, ClearAll
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the specified method is an interface method implementation
|
||||
/// </summary>
|
||||
public MethodInfo IsInterfaceMethod (Type t, string name, Type ret_type, Type [] args)
|
||||
{
|
||||
return InterfaceMethod (t, name, ret_type, args, Operation.Lookup, null);
|
||||
}
|
||||
|
||||
public MethodInfo IsInterfaceIndexer (Type t, Type ret_type, Type [] args)
|
||||
{
|
||||
return InterfaceMethod (t, null, ret_type, args, Operation.Lookup, null);
|
||||
}
|
||||
|
||||
public void ImplementMethod (Type t, string name, Type ret_type, Type [] args, bool clear_one)
|
||||
{
|
||||
InterfaceMethod (t, name, ret_type, args,
|
||||
clear_one ? Operation.ClearOne : Operation.ClearAll, null);
|
||||
}
|
||||
|
||||
public void ImplementIndexer (Type t, MethodInfo mi, Type ret_type, Type [] args, bool clear_one)
|
||||
{
|
||||
InterfaceMethod (t, null, ret_type, args,
|
||||
clear_one ? Operation.ClearOne : Operation.ClearAll, mi);
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// If a method in Type `t' (or null to look in all interfaces
|
||||
/// and the base abstract class) with name `Name', return type `ret_type' and
|
||||
/// arguments `args' implements an interface, this method will
|
||||
/// return the MethodInfo that this method implements.
|
||||
///
|
||||
/// If `name' is null, we operate solely on the method's signature. This is for
|
||||
/// instance used when implementing indexers.
|
||||
///
|
||||
/// The `Operation op' controls whether to lookup, clear the pending bit, or clear
|
||||
/// all the methods with the given signature.
|
||||
///
|
||||
/// The `MethodInfo need_proxy' is used when we're implementing an interface's
|
||||
/// indexer in a class. If the new indexer's IndexerName does not match the one
|
||||
/// that was used in the interface, then we always need to create a proxy for it.
|
||||
///
|
||||
/// </remarks>
|
||||
public MethodInfo InterfaceMethod (Type t, string name, Type ret_type, Type [] args,
|
||||
Operation op, MethodInfo need_proxy)
|
||||
{
|
||||
int arg_len = args.Length;
|
||||
|
||||
if (pending_implementations == null)
|
||||
return null;
|
||||
|
||||
foreach (TypeAndMethods tm in pending_implementations){
|
||||
if (!(t == null || tm.type == t))
|
||||
continue;
|
||||
|
||||
int method_count = tm.methods.Length;
|
||||
MethodInfo m;
|
||||
for (int i = 0; i < method_count; i++){
|
||||
m = tm.methods [i];
|
||||
|
||||
if (m == null)
|
||||
continue;
|
||||
|
||||
string mname = TypeManager.GetMethodName (m);
|
||||
|
||||
//
|
||||
// `need_proxy' is not null when we're implementing an
|
||||
// interface indexer and this is Clear(One/All) operation.
|
||||
//
|
||||
// If `name' is null, then we do a match solely based on the
|
||||
// signature and not on the name (this is done in the Lookup
|
||||
// for an interface indexer).
|
||||
//
|
||||
if (name == null){
|
||||
if (mname != tm.get_indexer_name && mname != tm.set_indexer_name)
|
||||
continue;
|
||||
} else if ((need_proxy == null) && (name != mname))
|
||||
continue;
|
||||
|
||||
if (!TypeManager.IsEqual (ret_type, m.ReturnType)){
|
||||
if (!((ret_type == null && m.ReturnType == TypeManager.void_type) ||
|
||||
(m.ReturnType == null && ret_type == TypeManager.void_type)))
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if we have the same parameters
|
||||
//
|
||||
if (tm.args [i].Length != arg_len)
|
||||
continue;
|
||||
|
||||
int j, top = args.Length;
|
||||
bool fail = false;
|
||||
|
||||
for (j = 0; j < top; j++){
|
||||
if (!TypeManager.IsEqual (tm.args [i][j], args[j])){
|
||||
fail = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fail)
|
||||
continue;
|
||||
|
||||
if (op != Operation.Lookup){
|
||||
// If `t != null', then this is an explicitly interface
|
||||
// implementation and we can always clear the method.
|
||||
// `need_proxy' is not null if we're implementing an
|
||||
// interface indexer. In this case, we need to create
|
||||
// a proxy if the implementation's IndexerName doesn't
|
||||
// match the IndexerName in the interface.
|
||||
bool name_matches = false;
|
||||
if (name == mname || mname == tm.get_indexer_name || mname == tm.set_indexer_name)
|
||||
name_matches = true;
|
||||
|
||||
if ((t == null) && (need_proxy != null) && !name_matches)
|
||||
tm.need_proxy [i] = need_proxy;
|
||||
else
|
||||
tm.methods [i] = null;
|
||||
}
|
||||
tm.found [i] = true;
|
||||
|
||||
//
|
||||
// Lookups and ClearOne return
|
||||
//
|
||||
if (op != Operation.ClearAll)
|
||||
return m;
|
||||
}
|
||||
|
||||
// If a specific type was requested, we can stop now.
|
||||
if (tm.type == t)
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C# allows this kind of scenarios:
|
||||
/// interface I { void M (); }
|
||||
/// class X { public void M (); }
|
||||
/// class Y : X, I { }
|
||||
///
|
||||
/// For that case, we create an explicit implementation function
|
||||
/// I.M in Y.
|
||||
/// </summary>
|
||||
void DefineProxy (Type iface, MethodInfo base_method, MethodInfo iface_method,
|
||||
Type [] args)
|
||||
{
|
||||
MethodBuilder proxy;
|
||||
|
||||
string proxy_name = iface.Name + "." + iface_method.Name;
|
||||
|
||||
proxy = container.TypeBuilder.DefineMethod (
|
||||
proxy_name,
|
||||
MethodAttributes.HideBySig |
|
||||
MethodAttributes.NewSlot |
|
||||
MethodAttributes.Virtual,
|
||||
CallingConventions.Standard | CallingConventions.HasThis,
|
||||
base_method.ReturnType, args);
|
||||
|
||||
ParameterData pd = Invocation.GetParameterData (iface_method);
|
||||
proxy.DefineParameter (0, ParameterAttributes.None, "");
|
||||
for (int i = 0; i < pd.Count; i++) {
|
||||
string name = pd.ParameterName (i);
|
||||
ParameterAttributes attr = Parameter.GetParameterAttributes (pd.ParameterModifier (i));
|
||||
proxy.DefineParameter (i + 1, attr, name);
|
||||
}
|
||||
|
||||
int top = args.Length;
|
||||
ILGenerator ig = proxy.GetILGenerator ();
|
||||
|
||||
for (int i = 0; i <= top; i++)
|
||||
ParameterReference.EmitLdArg (ig, i);
|
||||
|
||||
ig.Emit (OpCodes.Call, base_method);
|
||||
ig.Emit (OpCodes.Ret);
|
||||
|
||||
container.TypeBuilder.DefineMethodOverride (proxy, iface_method);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function tells whether one of our base classes implements
|
||||
/// the given method (which turns out, it is valid to have an interface
|
||||
/// implementation in a base
|
||||
/// </summary>
|
||||
bool BaseImplements (Type iface_type, MethodInfo mi)
|
||||
{
|
||||
MethodSignature ms;
|
||||
|
||||
Type [] args = TypeManager.GetArgumentTypes (mi);
|
||||
ms = new MethodSignature (mi.Name, mi.ReturnType, args);
|
||||
MemberList list = TypeContainer.FindMembers (
|
||||
container.TypeBuilder.BaseType, MemberTypes.Method | MemberTypes.Property,
|
||||
BindingFlags.Public | BindingFlags.Instance,
|
||||
MethodSignature.method_signature_filter, ms);
|
||||
|
||||
if (list.Count == 0)
|
||||
return false;
|
||||
|
||||
MethodInfo base_method = (MethodInfo) list [0];
|
||||
if (!base_method.IsAbstract)
|
||||
DefineProxy (iface_type, base_method, mi, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that any pending abstract methods or interface methods
|
||||
/// were implemented.
|
||||
/// </summary>
|
||||
public bool VerifyPendingMethods ()
|
||||
{
|
||||
int top = pending_implementations.Length;
|
||||
bool errors = false;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < top; i++){
|
||||
Type type = pending_implementations [i].type;
|
||||
int j = 0;
|
||||
|
||||
foreach (MethodInfo mi in pending_implementations [i].methods){
|
||||
if (mi == null)
|
||||
continue;
|
||||
|
||||
if (type.IsInterface){
|
||||
MethodInfo need_proxy =
|
||||
pending_implementations [i].need_proxy [j];
|
||||
|
||||
if (need_proxy != null) {
|
||||
Type [] args = TypeManager.GetArgumentTypes (mi);
|
||||
DefineProxy (type, need_proxy, mi, args);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (BaseImplements (type, mi))
|
||||
continue;
|
||||
|
||||
if (pending_implementations [i].optional)
|
||||
continue;
|
||||
|
||||
if (pending_implementations [i].found [j]) {
|
||||
string[] methodLabel = TypeManager.CSharpSignature (mi).Split ('.');
|
||||
Report.Error (536, container.Location,
|
||||
"'{0}' does not implement interface member '{1}'. '{2}.{3}' " +
|
||||
"is either static, not public, or has the wrong return type",
|
||||
container.Name, TypeManager.CSharpSignature (mi),
|
||||
container.Name, methodLabel[methodLabel.Length - 1]);
|
||||
}
|
||||
else {
|
||||
Report.Error (535, container.Location, "'{0}' does not implement interface member '{1}'",
|
||||
container.Name, TypeManager.CSharpSignature (mi));
|
||||
}
|
||||
} else {
|
||||
Report.Error (534, container.Location, "'{0}' does not implement inherited abstract member '{1}'",
|
||||
container.Name, TypeManager.CSharpSignature (mi));
|
||||
}
|
||||
errors = true;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
} /* end of class */
|
||||
}
|
||||
@@ -0,0 +1,669 @@
|
||||
//
|
||||
// report.cs: report errors and warnings.
|
||||
//
|
||||
// Author: Miguel de Icaza ([email protected])
|
||||
//
|
||||
// (C) 2001 Ximian, Inc. (http://www.ximian.com)
|
||||
//
|
||||
|
||||
//
|
||||
// FIXME: currently our class library does not support custom number format strings
|
||||
//
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Mono.CSharp {
|
||||
|
||||
/// <summary>
|
||||
/// This class is used to report errors and warnings t te user.
|
||||
/// </summary>
|
||||
public class Report {
|
||||
/// <summary>
|
||||
/// Errors encountered so far
|
||||
/// </summary>
|
||||
static public int Errors;
|
||||
|
||||
/// <summary>
|
||||
/// Warnings encountered so far
|
||||
/// </summary>
|
||||
static public int Warnings;
|
||||
|
||||
/// <summary>
|
||||
/// Whether errors should be throw an exception
|
||||
/// </summary>
|
||||
static public bool Fatal;
|
||||
|
||||
/// <summary>
|
||||
/// Whether warnings should be considered errors
|
||||
/// </summary>
|
||||
static public bool WarningsAreErrors;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to dump a stack trace on errors.
|
||||
/// </summary>
|
||||
static public bool Stacktrace;
|
||||
|
||||
//
|
||||
// If the 'expected' error code is reported then the
|
||||
// compilation succeeds.
|
||||
//
|
||||
// Used for the test suite to excercise the error codes
|
||||
//
|
||||
static int expected_error = 0;
|
||||
|
||||
//
|
||||
// Keeps track of the warnings that we are ignoring
|
||||
//
|
||||
static Hashtable warning_ignore_table;
|
||||
|
||||
static Hashtable warning_regions_table;
|
||||
|
||||
/// <summary>
|
||||
/// List of symbols related to reported error/warning. You have to fill it before error/warning is reported.
|
||||
/// </summary>
|
||||
static StringCollection extra_information = new StringCollection ();
|
||||
|
||||
abstract class AbstractMessage {
|
||||
|
||||
static void Check (int code)
|
||||
{
|
||||
if (code == expected_error) {
|
||||
Environment.Exit (0);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract bool IsWarning { get; }
|
||||
|
||||
public abstract string MessageType { get; }
|
||||
|
||||
public virtual void Print (int code, string location, string text)
|
||||
{
|
||||
if (code < 0)
|
||||
code = 8000-code;
|
||||
|
||||
StringBuilder msg = new StringBuilder ();
|
||||
if (location.Length != 0) {
|
||||
msg.Append (location);
|
||||
msg.Append (' ');
|
||||
}
|
||||
msg.AppendFormat ("{0} CS{1:0000}: {2}", MessageType, code, text);
|
||||
Console.Error.WriteLine (msg.ToString ());
|
||||
|
||||
foreach (string s in extra_information)
|
||||
Console.Error.WriteLine (s + MessageType);
|
||||
|
||||
extra_information.Clear ();
|
||||
|
||||
if (Stacktrace)
|
||||
Console.WriteLine (FriendlyStackTrace (new StackTrace (true)));
|
||||
|
||||
if (Fatal) {
|
||||
if (!IsWarning || WarningsAreErrors)
|
||||
throw new Exception (text);
|
||||
}
|
||||
|
||||
Check (code);
|
||||
}
|
||||
|
||||
public virtual void Print (int code, Location location, string text)
|
||||
{
|
||||
if (location.Equals (Location.Null)) {
|
||||
Print (code, "", text);
|
||||
return;
|
||||
}
|
||||
Print (code, String.Format ("{0}({1})", location.Name, location.Row), text);
|
||||
}
|
||||
}
|
||||
|
||||
sealed class WarningMessage: AbstractMessage {
|
||||
Location loc = Location.Null;
|
||||
readonly int Level;
|
||||
|
||||
public WarningMessage ():
|
||||
this (-1) {}
|
||||
|
||||
public WarningMessage (int level)
|
||||
{
|
||||
Level = level;
|
||||
}
|
||||
|
||||
public override bool IsWarning {
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
bool IsEnabled (int code)
|
||||
{
|
||||
if (RootContext.WarningLevel < Level)
|
||||
return false;
|
||||
|
||||
if (warning_ignore_table != null) {
|
||||
if (warning_ignore_table.Contains (code)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (warning_regions_table == null || loc.Equals (Location.Null))
|
||||
return true;
|
||||
|
||||
WarningRegions regions = (WarningRegions)warning_regions_table [loc.Name];
|
||||
return regions.IsWarningEnabled (code, loc.Row);
|
||||
}
|
||||
|
||||
public override void Print(int code, string location, string text)
|
||||
{
|
||||
if (!IsEnabled (code)) {
|
||||
extra_information.Clear ();
|
||||
return;
|
||||
}
|
||||
|
||||
if (WarningsAreErrors) {
|
||||
new ErrorMessage ().Print (code, location, text);
|
||||
return;
|
||||
}
|
||||
|
||||
Warnings++;
|
||||
base.Print (code, location, text);
|
||||
}
|
||||
|
||||
public override void Print(int code, Location location, string text)
|
||||
{
|
||||
loc = location;
|
||||
base.Print (code, location, text);
|
||||
}
|
||||
|
||||
public override string MessageType {
|
||||
get {
|
||||
return "warning";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sealed class ErrorMessage: AbstractMessage {
|
||||
|
||||
public override void Print(int code, string location, string text)
|
||||
{
|
||||
Errors++;
|
||||
base.Print (code, location, text);
|
||||
}
|
||||
|
||||
public override bool IsWarning {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override string MessageType {
|
||||
get {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void FeatureIsNotStandardized (Location loc, string feature)
|
||||
{
|
||||
Report.Error (1644, loc, "Feature '{0}' cannot be used because it is not part of the standardized ISO C# language specification", feature);
|
||||
}
|
||||
|
||||
public static string FriendlyStackTrace (Exception e)
|
||||
{
|
||||
return FriendlyStackTrace (new StackTrace (e, true));
|
||||
}
|
||||
|
||||
static string FriendlyStackTrace (StackTrace t)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
|
||||
bool foundUserCode = false;
|
||||
|
||||
for (int i = 0; i < t.FrameCount; i++) {
|
||||
StackFrame f = t.GetFrame (i);
|
||||
MethodBase mb = f.GetMethod ();
|
||||
|
||||
if (!foundUserCode && mb.ReflectedType == typeof (Report))
|
||||
continue;
|
||||
|
||||
foundUserCode = true;
|
||||
|
||||
sb.Append ("\tin ");
|
||||
|
||||
if (f.GetFileLineNumber () > 0)
|
||||
sb.AppendFormat ("(at {0}:{1}) ", f.GetFileName (), f.GetFileLineNumber ());
|
||||
|
||||
sb.AppendFormat ("{0}.{1} (", mb.ReflectedType.Name, mb.Name);
|
||||
|
||||
bool first = true;
|
||||
foreach (ParameterInfo pi in mb.GetParameters ()) {
|
||||
if (!first)
|
||||
sb.Append (", ");
|
||||
first = false;
|
||||
|
||||
sb.Append (TypeManager.CSharpName (pi.ParameterType));
|
||||
}
|
||||
sb.Append (")\n");
|
||||
}
|
||||
|
||||
return sb.ToString ();
|
||||
}
|
||||
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
// IF YOU ADD A NEW WARNING YOU HAVE TO DUPLICATE ITS ID HERE
|
||||
//
|
||||
public static bool IsValidWarning (int code)
|
||||
{
|
||||
int[] all_warnings = new int[] {
|
||||
28, 67, 78, 105, 108, 109, 114, 192, 168, 169, 183, 184, 219, 251, 612, 618, 626, 628, 642, 649,
|
||||
659, 660, 661, 672, 1030, 1522, 1616, 1691, 1692, 1901, 2002, 2023, 3012, 3019, 8024, 8028
|
||||
};
|
||||
|
||||
foreach (int i in all_warnings) {
|
||||
if (i == code)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static public void LocationOfPreviousError (Location loc)
|
||||
{
|
||||
Console.Error.WriteLine (String.Format ("{0}({1}) (Location of symbol related to previous error)", loc.Name, loc.Row));
|
||||
}
|
||||
|
||||
static public void RuntimeMissingSupport (Location loc, string feature)
|
||||
{
|
||||
Report.Error (-88, loc, "Your .NET Runtime does not support '{0}'. Please use the latest Mono runtime instead.", feature);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// In most error cases is very useful to have information about symbol that caused the error.
|
||||
/// Call this method before you call Report.Error when it makes sense.
|
||||
/// </summary>
|
||||
static public void SymbolRelatedToPreviousError (Location loc, string symbol)
|
||||
{
|
||||
SymbolRelatedToPreviousError (String.Format ("{0}({1})", loc.Name, loc.Row), symbol);
|
||||
}
|
||||
|
||||
static public void SymbolRelatedToPreviousError (MemberInfo mi)
|
||||
{
|
||||
TypeContainer temp_ds = TypeManager.LookupGenericTypeContainer (mi.DeclaringType);
|
||||
if (temp_ds == null) {
|
||||
SymbolRelatedToPreviousError (mi.DeclaringType.Assembly.Location, TypeManager.GetFullNameSignature (mi));
|
||||
} else {
|
||||
MethodBase mb = mi as MethodBase;
|
||||
if (mb != null) {
|
||||
while (mb.Mono_IsInflatedMethod)
|
||||
mb = mb.GetGenericMethodDefinition ();
|
||||
IMethodData md = TypeManager.GetMethod (mb);
|
||||
SymbolRelatedToPreviousError (md.Location, md.GetSignatureForError (temp_ds));
|
||||
return;
|
||||
}
|
||||
|
||||
string name = String.Concat (temp_ds.Name, ".", mi.Name);
|
||||
MemberCore mc = temp_ds.GetDefinition (name);
|
||||
SymbolRelatedToPreviousError (mc);
|
||||
}
|
||||
}
|
||||
|
||||
static public void SymbolRelatedToPreviousError (MemberCore mc)
|
||||
{
|
||||
SymbolRelatedToPreviousError (mc.Location, mc.GetSignatureForError ());
|
||||
}
|
||||
|
||||
static public void SymbolRelatedToPreviousError (Type type)
|
||||
{
|
||||
DeclSpace temp_ds = TypeManager.LookupDeclSpace (type);
|
||||
if (temp_ds == null)
|
||||
SymbolRelatedToPreviousError (type.Assembly.Location, TypeManager.CSharpName (type));
|
||||
else
|
||||
SymbolRelatedToPreviousError (temp_ds.Location, TypeManager.CSharpName (type));
|
||||
}
|
||||
|
||||
static void SymbolRelatedToPreviousError (string loc, string symbol)
|
||||
{
|
||||
extra_information.Add (String.Format ("{0}: '{1}' (name of symbol related to previous ", loc, symbol));
|
||||
}
|
||||
|
||||
public static void ExtraInformation (Location loc, string msg)
|
||||
{
|
||||
extra_information.Add (String.Format ("{0}({1}) {2}", loc.Name, loc.Row, msg));
|
||||
}
|
||||
|
||||
public static WarningRegions RegisterWarningRegion (Location location)
|
||||
{
|
||||
if (warning_regions_table == null)
|
||||
warning_regions_table = new Hashtable ();
|
||||
|
||||
WarningRegions regions = (WarningRegions)warning_regions_table [location.Name];
|
||||
if (regions == null) {
|
||||
regions = new WarningRegions ();
|
||||
warning_regions_table.Add (location.Name, regions);
|
||||
}
|
||||
return regions;
|
||||
}
|
||||
|
||||
static public void Warning (int code, int level, Location loc, string format, params object[] args)
|
||||
{
|
||||
WarningMessage w = new WarningMessage (level);
|
||||
w.Print (code, loc, String.Format (format, args));
|
||||
}
|
||||
|
||||
static public void Warning (int code, Location loc, string format, params object[] args)
|
||||
{
|
||||
WarningMessage w = new WarningMessage ();
|
||||
w.Print (code, loc, String.Format (format, args));
|
||||
}
|
||||
|
||||
static public void Warning (int code, string format, params object[] args)
|
||||
{
|
||||
Warning (code, Location.Null, String.Format (format, args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Did you test your WarningLevel, that you use this method
|
||||
/// </summary>
|
||||
static public void Warning (int code, string text)
|
||||
{
|
||||
Warning (code, Location.Null, text);
|
||||
}
|
||||
|
||||
static public void Error (int code, string format, params object[] args)
|
||||
{
|
||||
Error (code, Location.Null, String.Format (format, args));
|
||||
}
|
||||
|
||||
static public void Error (int code, Location loc, string format, params object[] args)
|
||||
{
|
||||
ErrorMessage e = new ErrorMessage ();
|
||||
e.Print (code, loc, String.Format (format, args));
|
||||
}
|
||||
|
||||
static public void SetIgnoreWarning (int code)
|
||||
{
|
||||
if (warning_ignore_table == null)
|
||||
warning_ignore_table = new Hashtable ();
|
||||
|
||||
warning_ignore_table [code] = true;
|
||||
}
|
||||
|
||||
static public int ExpectedError {
|
||||
set {
|
||||
expected_error = value;
|
||||
}
|
||||
get {
|
||||
return expected_error;
|
||||
}
|
||||
}
|
||||
|
||||
public static int DebugFlags = 0;
|
||||
|
||||
[Conditional ("MCS_DEBUG")]
|
||||
static public void Debug (string message, params object[] args)
|
||||
{
|
||||
Debug (4, message, args);
|
||||
}
|
||||
|
||||
[Conditional ("MCS_DEBUG")]
|
||||
static public void Debug (int category, string message, params object[] args)
|
||||
{
|
||||
if ((category & DebugFlags) == 0)
|
||||
return;
|
||||
|
||||
StringBuilder sb = new StringBuilder (message);
|
||||
|
||||
if ((args != null) && (args.Length > 0)) {
|
||||
sb.Append (": ");
|
||||
|
||||
bool first = true;
|
||||
foreach (object arg in args) {
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
sb.Append (", ");
|
||||
if (arg == null)
|
||||
sb.Append ("null");
|
||||
else if (arg is ICollection)
|
||||
sb.Append (PrintCollection ((ICollection) arg));
|
||||
else
|
||||
sb.Append (arg);
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine (sb.ToString ());
|
||||
}
|
||||
|
||||
static public string PrintCollection (ICollection collection)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
|
||||
sb.Append (collection.GetType ());
|
||||
sb.Append ("(");
|
||||
|
||||
bool first = true;
|
||||
foreach (object o in collection) {
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
sb.Append (", ");
|
||||
sb.Append (o);
|
||||
}
|
||||
|
||||
sb.Append (")");
|
||||
return sb.ToString ();
|
||||
}
|
||||
}
|
||||
|
||||
public enum TimerType {
|
||||
FindMembers = 0,
|
||||
TcFindMembers = 1,
|
||||
MemberLookup = 2,
|
||||
CachedLookup = 3,
|
||||
CacheInit = 4,
|
||||
MiscTimer = 5,
|
||||
CountTimers = 6
|
||||
}
|
||||
|
||||
public enum CounterType {
|
||||
FindMembers = 0,
|
||||
MemberCache = 1,
|
||||
MiscCounter = 2,
|
||||
CountCounters = 3
|
||||
}
|
||||
|
||||
public class Timer
|
||||
{
|
||||
static DateTime[] timer_start;
|
||||
static TimeSpan[] timers;
|
||||
static long[] timer_counters;
|
||||
static long[] counters;
|
||||
|
||||
static Timer ()
|
||||
{
|
||||
timer_start = new DateTime [(int) TimerType.CountTimers];
|
||||
timers = new TimeSpan [(int) TimerType.CountTimers];
|
||||
timer_counters = new long [(int) TimerType.CountTimers];
|
||||
counters = new long [(int) CounterType.CountCounters];
|
||||
|
||||
for (int i = 0; i < (int) TimerType.CountTimers; i++) {
|
||||
timer_start [i] = DateTime.Now;
|
||||
timers [i] = TimeSpan.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
[Conditional("TIMER")]
|
||||
static public void IncrementCounter (CounterType which)
|
||||
{
|
||||
++counters [(int) which];
|
||||
}
|
||||
|
||||
[Conditional("TIMER")]
|
||||
static public void StartTimer (TimerType which)
|
||||
{
|
||||
timer_start [(int) which] = DateTime.Now;
|
||||
}
|
||||
|
||||
[Conditional("TIMER")]
|
||||
static public void StopTimer (TimerType which)
|
||||
{
|
||||
timers [(int) which] += DateTime.Now - timer_start [(int) which];
|
||||
++timer_counters [(int) which];
|
||||
}
|
||||
|
||||
[Conditional("TIMER")]
|
||||
static public void ShowTimers ()
|
||||
{
|
||||
ShowTimer (TimerType.FindMembers, "- FindMembers timer");
|
||||
ShowTimer (TimerType.TcFindMembers, "- TypeContainer.FindMembers timer");
|
||||
ShowTimer (TimerType.MemberLookup, "- MemberLookup timer");
|
||||
ShowTimer (TimerType.CachedLookup, "- CachedLookup timer");
|
||||
ShowTimer (TimerType.CacheInit, "- Cache init");
|
||||
ShowTimer (TimerType.MiscTimer, "- Misc timer");
|
||||
|
||||
ShowCounter (CounterType.FindMembers, "- Find members");
|
||||
ShowCounter (CounterType.MemberCache, "- Member cache");
|
||||
ShowCounter (CounterType.MiscCounter, "- Misc counter");
|
||||
}
|
||||
|
||||
static public void ShowCounter (CounterType which, string msg)
|
||||
{
|
||||
Console.WriteLine ("{0} {1}", counters [(int) which], msg);
|
||||
}
|
||||
|
||||
static public void ShowTimer (TimerType which, string msg)
|
||||
{
|
||||
Console.WriteLine (
|
||||
"[{0:00}:{1:000}] {2} (used {3} times)",
|
||||
(int) timers [(int) which].TotalSeconds,
|
||||
timers [(int) which].Milliseconds, msg,
|
||||
timer_counters [(int) which]);
|
||||
}
|
||||
}
|
||||
|
||||
public class InternalErrorException : Exception {
|
||||
public InternalErrorException ()
|
||||
: base ("Internal error")
|
||||
{
|
||||
}
|
||||
|
||||
public InternalErrorException (string message)
|
||||
: base (message)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles #pragma warning
|
||||
/// </summary>
|
||||
public class WarningRegions {
|
||||
|
||||
abstract class PragmaCmd
|
||||
{
|
||||
public int Line;
|
||||
|
||||
protected PragmaCmd (int line)
|
||||
{
|
||||
Line = line;
|
||||
}
|
||||
|
||||
public abstract bool IsEnabled (int code, bool previous);
|
||||
}
|
||||
|
||||
class Disable: PragmaCmd
|
||||
{
|
||||
int code;
|
||||
public Disable (int line, int code)
|
||||
: base (line)
|
||||
{
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public override bool IsEnabled (int code, bool previous)
|
||||
{
|
||||
return this.code == code ? false : previous;
|
||||
}
|
||||
}
|
||||
|
||||
class DisableAll: PragmaCmd
|
||||
{
|
||||
public DisableAll (int line)
|
||||
: base (line) {}
|
||||
|
||||
public override bool IsEnabled(int code, bool previous)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class Enable: PragmaCmd
|
||||
{
|
||||
int code;
|
||||
public Enable (int line, int code)
|
||||
: base (line)
|
||||
{
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public override bool IsEnabled(int code, bool previous)
|
||||
{
|
||||
return this.code == code ? true : previous;
|
||||
}
|
||||
}
|
||||
|
||||
class EnableAll: PragmaCmd
|
||||
{
|
||||
public EnableAll (int line)
|
||||
: base (line) {}
|
||||
|
||||
public override bool IsEnabled(int code, bool previous)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ArrayList regions = new ArrayList ();
|
||||
|
||||
public void WarningDisable (int line)
|
||||
{
|
||||
regions.Add (new DisableAll (line));
|
||||
}
|
||||
|
||||
public void WarningDisable (Location location, int code)
|
||||
{
|
||||
if (CheckWarningCode (code, location))
|
||||
regions.Add (new Disable (location.Row, code));
|
||||
}
|
||||
|
||||
public void WarningEnable (int line)
|
||||
{
|
||||
regions.Add (new EnableAll (line));
|
||||
}
|
||||
|
||||
public void WarningEnable (Location location, int code)
|
||||
{
|
||||
if (CheckWarningCode (code, location))
|
||||
regions.Add (new Enable (location.Row, code));
|
||||
}
|
||||
|
||||
public bool IsWarningEnabled (int code, int src_line)
|
||||
{
|
||||
bool result = true;
|
||||
foreach (PragmaCmd pragma in regions) {
|
||||
if (src_line < pragma.Line)
|
||||
break;
|
||||
|
||||
result = pragma.IsEnabled (code, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CheckWarningCode (int code, Location loc)
|
||||
{
|
||||
if (Report.IsValidWarning (code))
|
||||
return true;
|
||||
|
||||
Report.Warning (1691, 1, loc, "'{0}' is not a valid warning number", code);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,724 @@
|
||||
//
|
||||
// rootcontext.cs: keeps track of our tree representation, and assemblies loaded.
|
||||
//
|
||||
// Author: Miguel de Icaza ([email protected])
|
||||
// Ravi Pratap ([email protected])
|
||||
//
|
||||
// Licensed under the terms of the GNU GPL
|
||||
//
|
||||
// (C) 2001 Ximian, Inc (http://www.ximian.com)
|
||||
// (C) 2004 Novell, Inc
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Diagnostics;
|
||||
using System.Xml;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
namespace Mono.CSharp {
|
||||
|
||||
public enum LanguageVersion
|
||||
{
|
||||
Default = 0,
|
||||
ISO_1 = 1
|
||||
}
|
||||
|
||||
public class RootContext {
|
||||
|
||||
//
|
||||
// Contains the parsed tree
|
||||
//
|
||||
static Tree tree;
|
||||
|
||||
//
|
||||
// This hashtable contains all of the #definitions across the source code
|
||||
// it is used by the ConditionalAttribute handler.
|
||||
//
|
||||
public static Hashtable AllDefines = new Hashtable ();
|
||||
|
||||
//
|
||||
// Whether we are being linked against the standard libraries.
|
||||
// This is only used to tell whether `System.Object' should
|
||||
// have a base class or not.
|
||||
//
|
||||
public static bool StdLib = true;
|
||||
|
||||
//
|
||||
// This keeps track of the order in which classes were defined
|
||||
// so that we can poulate them in that order.
|
||||
//
|
||||
// Order is important, because we need to be able to tell, by
|
||||
// examining the list of methods of the base class, which ones are virtual
|
||||
// or abstract as well as the parent names (to implement new,
|
||||
// override).
|
||||
//
|
||||
static ArrayList type_container_resolve_order;
|
||||
static ArrayList attribute_types;
|
||||
|
||||
//
|
||||
// Holds a reference to the Private Implementation Details
|
||||
// class.
|
||||
//
|
||||
static ArrayList helper_classes;
|
||||
|
||||
static TypeBuilder impl_details_class;
|
||||
|
||||
public static int WarningLevel = 3;
|
||||
|
||||
public static Target Target = Target.Exe;
|
||||
public static string TargetExt = ".exe";
|
||||
|
||||
public static bool VerifyClsCompliance = true;
|
||||
|
||||
public static LanguageVersion Version = LanguageVersion.Default;
|
||||
|
||||
//
|
||||
// We keep strongname related info here because
|
||||
// it's also used as complier options from CSC 8.x
|
||||
//
|
||||
public static string StrongNameKeyFile;
|
||||
public static string StrongNameKeyContainer;
|
||||
public static bool StrongNameDelaySign = false;
|
||||
|
||||
//
|
||||
// If set, enable XML documentation generation
|
||||
//
|
||||
public static Documentation Documentation;
|
||||
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
static RootContext ()
|
||||
{
|
||||
tree = new Tree ();
|
||||
type_container_resolve_order = new ArrayList ();
|
||||
}
|
||||
|
||||
public static bool NeedsEntryPoint {
|
||||
get {
|
||||
return RootContext.Target == Target.Exe || RootContext.Target == Target.WinExe;
|
||||
}
|
||||
}
|
||||
|
||||
static public Tree Tree {
|
||||
get {
|
||||
return tree;
|
||||
}
|
||||
}
|
||||
|
||||
static public string MainClass;
|
||||
|
||||
public static void RegisterOrder (TypeContainer tc)
|
||||
{
|
||||
type_container_resolve_order.Add (tc);
|
||||
}
|
||||
|
||||
public static void RegisterAttribute (TypeContainer tc)
|
||||
{
|
||||
if (attribute_types == null)
|
||||
attribute_types = new ArrayList ();
|
||||
|
||||
attribute_types.Add (tc);
|
||||
}
|
||||
|
||||
//
|
||||
// The default compiler checked state. It's "On" in case of VB.NET compiler.
|
||||
//
|
||||
static public bool Checked = true;
|
||||
|
||||
|
||||
//
|
||||
// Whether to allow Unsafe code
|
||||
//
|
||||
static public bool Unsafe = false;
|
||||
|
||||
//
|
||||
// VB.NET specific compiler options
|
||||
//
|
||||
|
||||
//
|
||||
// The default type checking state
|
||||
//
|
||||
static public bool StricterTypeChecking = false;
|
||||
|
||||
//
|
||||
// The default character comparison mode
|
||||
//
|
||||
|
||||
static public CompareMethod StringComparisonMode = CompareMethod.Binary;
|
||||
|
||||
static string MakeFQN (string nsn, string name)
|
||||
{
|
||||
if (nsn == "")
|
||||
return name;
|
||||
return String.Concat (nsn, ".", name);
|
||||
}
|
||||
|
||||
// <remarks>
|
||||
// This function is used to resolve the hierarchy tree.
|
||||
// It processes interfaces, structs and classes in that order.
|
||||
//
|
||||
// It creates the TypeBuilder's as it processes the user defined
|
||||
// types.
|
||||
// </remarks>
|
||||
static public void ResolveTree ()
|
||||
{
|
||||
//
|
||||
// Process the attribute types separately and before anything else
|
||||
//
|
||||
if (attribute_types != null)
|
||||
foreach (TypeContainer tc in attribute_types)
|
||||
tc.DefineType ();
|
||||
|
||||
//
|
||||
// Interfaces are processed next, as classes and
|
||||
// structs might inherit from an object or implement
|
||||
// a set of interfaces, we need to be able to tell
|
||||
// them appart by just using the TypeManager.
|
||||
//
|
||||
TypeContainer root = Tree.Types;
|
||||
|
||||
ArrayList ifaces = root.Interfaces;
|
||||
if (ifaces != null){
|
||||
foreach (Interface i in ifaces)
|
||||
i.DefineType ();
|
||||
}
|
||||
|
||||
foreach (TypeContainer tc in root.Types)
|
||||
tc.DefineType ();
|
||||
|
||||
if (root.Delegates != null)
|
||||
foreach (Delegate d in root.Delegates)
|
||||
d.DefineType ();
|
||||
|
||||
if (root.Enums != null)
|
||||
foreach (Enum e in root.Enums)
|
||||
e.DefineType ();
|
||||
}
|
||||
|
||||
static void Error_TypeConflict (string name, Location loc)
|
||||
{
|
||||
Report.Error (
|
||||
520, loc, "`" + name + "' conflicts with a predefined type");
|
||||
}
|
||||
|
||||
static void Error_TypeConflict (string name)
|
||||
{
|
||||
Report.Error (
|
||||
520, "`" + name + "' conflicts with a predefined type");
|
||||
}
|
||||
|
||||
//
|
||||
// Resolves a single class during the corlib bootstrap process
|
||||
//
|
||||
static TypeBuilder BootstrapCorlib_ResolveClass (TypeContainer root, string name)
|
||||
{
|
||||
object o = root.GetDefinition (name);
|
||||
if (o == null){
|
||||
Report.Error (518, "The predefined type `" + name + "' is not defined");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(o is Class)){
|
||||
if (o is DeclSpace){
|
||||
DeclSpace d = (DeclSpace) o;
|
||||
|
||||
Error_TypeConflict (name, d.Location);
|
||||
} else
|
||||
Error_TypeConflict (name);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return ((DeclSpace) o).DefineType ();
|
||||
}
|
||||
|
||||
//
|
||||
// Resolves a struct during the corlib bootstrap process
|
||||
//
|
||||
static void BootstrapCorlib_ResolveStruct (TypeContainer root, string name)
|
||||
{
|
||||
object o = root.GetDefinition (name);
|
||||
if (o == null){
|
||||
Report.Error (518, "The predefined type `" + name + "' is not defined");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(o is Struct)){
|
||||
if (o is DeclSpace){
|
||||
DeclSpace d = (DeclSpace) o;
|
||||
|
||||
Error_TypeConflict (name, d.Location);
|
||||
} else
|
||||
Error_TypeConflict (name);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
((DeclSpace) o).DefineType ();
|
||||
}
|
||||
|
||||
//
|
||||
// Resolves a struct during the corlib bootstrap process
|
||||
//
|
||||
static void BootstrapCorlib_ResolveInterface (TypeContainer root, string name)
|
||||
{
|
||||
object o = root.GetDefinition (name);
|
||||
if (o == null){
|
||||
Report.Error (518, "The predefined type `" + name + "' is not defined");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(o is Interface)){
|
||||
if (o is DeclSpace){
|
||||
DeclSpace d = (DeclSpace) o;
|
||||
|
||||
Error_TypeConflict (name, d.Location);
|
||||
} else
|
||||
Error_TypeConflict (name);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
((DeclSpace) o).DefineType ();
|
||||
}
|
||||
|
||||
//
|
||||
// Resolves a delegate during the corlib bootstrap process
|
||||
//
|
||||
static void BootstrapCorlib_ResolveDelegate (TypeContainer root, string name)
|
||||
{
|
||||
object o = root.GetDefinition (name);
|
||||
if (o == null){
|
||||
Report.Error (518, "The predefined type `" + name + "' is not defined");
|
||||
Environment.Exit (1);
|
||||
}
|
||||
|
||||
if (!(o is Delegate)){
|
||||
Error_TypeConflict (name);
|
||||
return;
|
||||
}
|
||||
|
||||
((DeclSpace) o).DefineType ();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the core types in the compiler when compiling with --nostdlib
|
||||
/// </summary>
|
||||
static public void ResolveCore ()
|
||||
{
|
||||
TypeContainer root = Tree.Types;
|
||||
|
||||
TypeManager.object_type = BootstrapCorlib_ResolveClass (root, "System.Object");
|
||||
TypeManager.value_type = BootstrapCorlib_ResolveClass (root, "System.ValueType");
|
||||
TypeManager.attribute_type = BootstrapCorlib_ResolveClass (root, "System.Attribute");
|
||||
|
||||
string [] interfaces_first_stage = {
|
||||
"System.IComparable", "System.ICloneable",
|
||||
"System.IConvertible",
|
||||
|
||||
"System.Collections.IEnumerable",
|
||||
"System.Collections.ICollection",
|
||||
"System.Collections.IEnumerator",
|
||||
"System.Collections.IList",
|
||||
"System.IAsyncResult",
|
||||
"System.IDisposable",
|
||||
|
||||
"System.Runtime.Serialization.ISerializable",
|
||||
"System.Runtime.InteropServices._Exception",
|
||||
|
||||
"System.Reflection.IReflect",
|
||||
"System.Reflection.ICustomAttributeProvider",
|
||||
|
||||
//
|
||||
// Generic types
|
||||
//
|
||||
"System.Collections.Generic.IEnumerator`1",
|
||||
"System.Collections.Generic.IEnumerable`1",
|
||||
};
|
||||
|
||||
foreach (string iname in interfaces_first_stage)
|
||||
BootstrapCorlib_ResolveInterface (root, iname);
|
||||
|
||||
//
|
||||
// These are the base value types
|
||||
//
|
||||
string [] structs_first_stage = {
|
||||
"System.Byte", "System.SByte",
|
||||
"System.Int16", "System.UInt16",
|
||||
"System.Int32", "System.UInt32",
|
||||
"System.Int64", "System.UInt64",
|
||||
};
|
||||
|
||||
foreach (string cname in structs_first_stage)
|
||||
BootstrapCorlib_ResolveStruct (root, cname);
|
||||
|
||||
//
|
||||
// Now, we can load the enumerations, after this point,
|
||||
// we can use enums.
|
||||
//
|
||||
TypeManager.InitEnumUnderlyingTypes ();
|
||||
|
||||
string [] structs_second_stage = {
|
||||
"System.Single", "System.Double",
|
||||
"System.Char", "System.Boolean",
|
||||
"System.Decimal", "System.Void",
|
||||
"System.RuntimeFieldHandle",
|
||||
"System.RuntimeArgumentHandle",
|
||||
"System.RuntimeTypeHandle",
|
||||
"System.IntPtr",
|
||||
"System.TypedReference",
|
||||
"System.ArgIterator"
|
||||
};
|
||||
|
||||
foreach (string cname in structs_second_stage)
|
||||
BootstrapCorlib_ResolveStruct (root, cname);
|
||||
|
||||
//
|
||||
// These are classes that depends on the core interfaces
|
||||
//
|
||||
string [] classes_second_stage = {
|
||||
"System.Enum",
|
||||
"System.String",
|
||||
"System.Array",
|
||||
"System.Reflection.MemberInfo",
|
||||
"System.Type",
|
||||
"System.Exception",
|
||||
"System.Activator",
|
||||
|
||||
//
|
||||
// These are not really important in the order, but they
|
||||
// are used by the compiler later on (typemanager/CoreLookupType-d)
|
||||
//
|
||||
"System.Runtime.CompilerServices.RuntimeHelpers",
|
||||
"System.Reflection.DefaultMemberAttribute",
|
||||
"System.Threading.Monitor",
|
||||
|
||||
"System.AttributeUsageAttribute",
|
||||
"System.Runtime.InteropServices.DllImportAttribute",
|
||||
"System.Runtime.CompilerServices.MethodImplAttribute",
|
||||
"System.Runtime.InteropServices.MarshalAsAttribute",
|
||||
"System.Runtime.CompilerServices.NewConstraintAttribute",
|
||||
"System.Diagnostics.ConditionalAttribute",
|
||||
"System.ObsoleteAttribute",
|
||||
"System.ParamArrayAttribute",
|
||||
"System.CLSCompliantAttribute",
|
||||
"System.Security.UnverifiableCodeAttribute",
|
||||
"System.Security.Permissions.SecurityAttribute",
|
||||
"System.Runtime.CompilerServices.IndexerNameAttribute",
|
||||
"System.Runtime.CompilerServices.DecimalConstantAttribute",
|
||||
"System.Runtime.InteropServices.InAttribute",
|
||||
"System.Runtime.InteropServices.OutAttribute",
|
||||
"System.Runtime.InteropServices.StructLayoutAttribute",
|
||||
"System.Runtime.InteropServices.FieldOffsetAttribute",
|
||||
"System.InvalidOperationException",
|
||||
"System.NotSupportedException",
|
||||
"System.MarshalByRefObject",
|
||||
"System.Security.CodeAccessPermission"
|
||||
};
|
||||
|
||||
foreach (string cname in classes_second_stage)
|
||||
BootstrapCorlib_ResolveClass (root, cname);
|
||||
|
||||
BootstrapCorlib_ResolveStruct (root, "System.Nullable`1");
|
||||
|
||||
BootstrapCorlib_ResolveDelegate (root, "System.AsyncCallback");
|
||||
|
||||
// These will be defined indirectly during the previous ResolveDelegate.
|
||||
// However make sure the rest of the checks happen.
|
||||
string [] delegate_types = { "System.Delegate", "System.MulticastDelegate" };
|
||||
foreach (string cname in delegate_types)
|
||||
BootstrapCorlib_ResolveClass (root, cname);
|
||||
}
|
||||
|
||||
// <summary>
|
||||
// Closes all open types
|
||||
// </summary>
|
||||
//
|
||||
// <remarks>
|
||||
// We usually use TypeBuilder types. When we are done
|
||||
// creating the type (which will happen after we have added
|
||||
// methods, fields, etc) we need to "Define" them before we
|
||||
// can save the Assembly
|
||||
// </remarks>
|
||||
static public void CloseTypes ()
|
||||
{
|
||||
TypeContainer root = Tree.Types;
|
||||
|
||||
if (root.Enums != null)
|
||||
foreach (Enum en in root.Enums)
|
||||
en.CloseType ();
|
||||
|
||||
if (attribute_types != null)
|
||||
foreach (TypeContainer tc in attribute_types)
|
||||
tc.CloseType ();
|
||||
|
||||
//
|
||||
// We do this in two passes, first we close the structs,
|
||||
// then the classes, because it seems the code needs it this
|
||||
// way. If this is really what is going on, we should probably
|
||||
// make sure that we define the structs in order as well.
|
||||
//
|
||||
foreach (TypeContainer tc in type_container_resolve_order){
|
||||
if (tc.Kind == Kind.Struct && tc.Parent == tree.Types){
|
||||
tc.CloseType ();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (TypeContainer tc in type_container_resolve_order){
|
||||
if (!(tc.Kind == Kind.Struct && tc.Parent == tree.Types))
|
||||
tc.CloseType ();
|
||||
}
|
||||
|
||||
if (root.Delegates != null)
|
||||
foreach (Delegate d in root.Delegates)
|
||||
d.CloseType ();
|
||||
|
||||
|
||||
//
|
||||
// If we have a <PrivateImplementationDetails> class, close it
|
||||
//
|
||||
if (helper_classes != null){
|
||||
foreach (TypeBuilder type_builder in helper_classes)
|
||||
type_builder.CreateType ();
|
||||
}
|
||||
|
||||
attribute_types = null;
|
||||
type_container_resolve_order = null;
|
||||
helper_classes = null;
|
||||
//tree = null;
|
||||
TypeManager.CleanUp ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to register classes that need to be closed after all the
|
||||
/// user defined classes
|
||||
/// </summary>
|
||||
public static void RegisterHelperClass (TypeBuilder helper_class)
|
||||
{
|
||||
if (helper_classes == null)
|
||||
helper_classes = new ArrayList ();
|
||||
helper_classes.Add (helper_class);
|
||||
}
|
||||
|
||||
static void Report1530 (Location loc)
|
||||
{
|
||||
Report.Error (1530, loc, "Keyword new not allowed for namespace elements");
|
||||
}
|
||||
|
||||
static public void PopulateCoreType (TypeContainer root, string name)
|
||||
{
|
||||
DeclSpace ds = (DeclSpace) root.GetDefinition (name);
|
||||
|
||||
ds.DefineMembers (root);
|
||||
ds.Define ();
|
||||
}
|
||||
|
||||
static public void BootCorlib_PopulateCoreTypes ()
|
||||
{
|
||||
TypeContainer root = tree.Types;
|
||||
|
||||
PopulateCoreType (root, "System.Object");
|
||||
PopulateCoreType (root, "System.ValueType");
|
||||
PopulateCoreType (root, "System.Attribute");
|
||||
}
|
||||
|
||||
// <summary>
|
||||
// Populates the structs and classes with fields and methods
|
||||
// </summary>
|
||||
//
|
||||
// This is invoked after all interfaces, structs and classes
|
||||
// have been defined through `ResolveTree'
|
||||
static public void PopulateTypes ()
|
||||
{
|
||||
TypeContainer root = Tree.Types;
|
||||
|
||||
if (attribute_types != null)
|
||||
foreach (TypeContainer tc in attribute_types)
|
||||
tc.DefineMembers (root);
|
||||
|
||||
if (type_container_resolve_order != null){
|
||||
if (RootContext.StdLib){
|
||||
foreach (TypeContainer tc in type_container_resolve_order)
|
||||
tc.DefineMembers (root);
|
||||
} else {
|
||||
foreach (TypeContainer tc in type_container_resolve_order) {
|
||||
// When compiling corlib, these types have already been
|
||||
// populated from BootCorlib_PopulateCoreTypes ().
|
||||
if (((tc.Name == "System.Object") ||
|
||||
(tc.Name == "System.Attribute") ||
|
||||
(tc.Name == "System.ValueType")))
|
||||
continue;
|
||||
|
||||
tc.DefineMembers (root);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList delegates = root.Delegates;
|
||||
if (delegates != null){
|
||||
foreach (Delegate d in delegates)
|
||||
if ((d.ModFlags & Modifiers.NEW) == 0)
|
||||
d.DefineMembers (root);
|
||||
else
|
||||
Report1530 (d.Location);
|
||||
}
|
||||
|
||||
ArrayList enums = root.Enums;
|
||||
if (enums != null){
|
||||
foreach (Enum en in enums)
|
||||
if ((en.ModFlags & Modifiers.NEW) == 0)
|
||||
en.DefineMembers (root);
|
||||
else
|
||||
Report1530 (en.Location);
|
||||
}
|
||||
|
||||
//
|
||||
// Check for cycles in the struct layout
|
||||
//
|
||||
if (type_container_resolve_order != null){
|
||||
Hashtable seen = new Hashtable ();
|
||||
foreach (TypeContainer tc in type_container_resolve_order)
|
||||
TypeManager.CheckStructCycles (tc, seen);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// A generic hook delegate
|
||||
//
|
||||
public delegate void Hook ();
|
||||
|
||||
//
|
||||
// A hook invoked when the code has been generated.
|
||||
//
|
||||
public static event Hook EmitCodeHook;
|
||||
|
||||
//
|
||||
// DefineTypes is used to fill in the members of each type.
|
||||
//
|
||||
static public void DefineTypes ()
|
||||
{
|
||||
TypeContainer root = Tree.Types;
|
||||
|
||||
if (attribute_types != null)
|
||||
foreach (TypeContainer tc in attribute_types)
|
||||
tc.Define ();
|
||||
|
||||
if (type_container_resolve_order != null){
|
||||
foreach (TypeContainer tc in type_container_resolve_order) {
|
||||
// When compiling corlib, these types have already been
|
||||
// populated from BootCorlib_PopulateCoreTypes ().
|
||||
if (!RootContext.StdLib &&
|
||||
((tc.Name == "System.Object") ||
|
||||
(tc.Name == "System.Attribute") ||
|
||||
(tc.Name == "System.ValueType")))
|
||||
continue;
|
||||
|
||||
if ((tc.ModFlags & Modifiers.NEW) == 0)
|
||||
tc.Define ();
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList delegates = root.Delegates;
|
||||
if (delegates != null){
|
||||
foreach (Delegate d in delegates)
|
||||
if ((d.ModFlags & Modifiers.NEW) == 0)
|
||||
d.Define ();
|
||||
}
|
||||
|
||||
ArrayList enums = root.Enums;
|
||||
if (enums != null){
|
||||
foreach (Enum en in enums)
|
||||
if ((en.ModFlags & Modifiers.NEW) == 0)
|
||||
en.Define ();
|
||||
}
|
||||
}
|
||||
|
||||
static public void EmitCode ()
|
||||
{
|
||||
if (attribute_types != null)
|
||||
foreach (TypeContainer tc in attribute_types)
|
||||
tc.EmitType ();
|
||||
|
||||
CodeGen.Assembly.Emit (Tree.Types);
|
||||
CodeGen.Module.Emit (Tree.Types);
|
||||
|
||||
if (Tree.Types.Enums != null) {
|
||||
foreach (Enum e in Tree.Types.Enums)
|
||||
e.Emit ();
|
||||
}
|
||||
|
||||
if (type_container_resolve_order != null) {
|
||||
foreach (TypeContainer tc in type_container_resolve_order)
|
||||
tc.EmitType ();
|
||||
}
|
||||
|
||||
if (Tree.Types.Delegates != null) {
|
||||
foreach (Delegate d in Tree.Types.Delegates)
|
||||
d.Emit ();
|
||||
}
|
||||
//
|
||||
// Run any hooks after all the types have been defined.
|
||||
// This is used to create nested auxiliary classes for example
|
||||
//
|
||||
|
||||
if (EmitCodeHook != null)
|
||||
EmitCodeHook ();
|
||||
}
|
||||
|
||||
//
|
||||
// Public Field, used to track which method is the public entry
|
||||
// point.
|
||||
//
|
||||
static public MethodInfo EntryPoint;
|
||||
|
||||
//
|
||||
// Track the location of the entry point.
|
||||
//
|
||||
static public Location EntryPointLocation;
|
||||
|
||||
//
|
||||
// These are used to generate unique names on the structs and fields.
|
||||
//
|
||||
static int field_count;
|
||||
|
||||
//
|
||||
// Makes an initialized struct, returns the field builder that
|
||||
// references the data. Thanks go to Sergey Chaban for researching
|
||||
// how to do this. And coming up with a shorter mechanism than I
|
||||
// was able to figure out.
|
||||
//
|
||||
// This works but makes an implicit public struct $ArrayType$SIZE and
|
||||
// makes the fields point to it. We could get more control if we did
|
||||
// use instead:
|
||||
//
|
||||
// 1. DefineNestedType on the impl_details_class with our struct.
|
||||
//
|
||||
// 2. Define the field on the impl_details_class
|
||||
//
|
||||
static public FieldBuilder MakeStaticData (byte [] data)
|
||||
{
|
||||
FieldBuilder fb;
|
||||
|
||||
if (impl_details_class == null){
|
||||
impl_details_class = CodeGen.Module.Builder.DefineType (
|
||||
"<PrivateImplementationDetails>",
|
||||
TypeAttributes.NotPublic,
|
||||
TypeManager.object_type);
|
||||
|
||||
RegisterHelperClass (impl_details_class);
|
||||
}
|
||||
|
||||
fb = impl_details_class.DefineInitializedData (
|
||||
"$$field-" + (field_count++), data,
|
||||
FieldAttributes.Static | FieldAttributes.Assembly);
|
||||
|
||||
return fb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using Generics;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
public class Bar : Foo
|
||||
{
|
||||
public void Hello (Stack<int> stack)
|
||||
{
|
||||
Console.WriteLine ("Hello Generic World!");
|
||||
Console.WriteLine (stack);
|
||||
Console.WriteLine (stack.GetType ());
|
||||
}
|
||||
|
||||
public Stack<int> Test ()
|
||||
{
|
||||
return Driver.int_stack;
|
||||
}
|
||||
|
||||
public static void Main ()
|
||||
{
|
||||
Foo foo = new Bar ();
|
||||
Driver.Init (foo);
|
||||
Stack<int> a = Driver.int_stack;
|
||||
Console.WriteLine ("STACK: {0}", a);
|
||||
foo.Hello (a);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,618 @@
|
||||
//
|
||||
// support.cs: Support routines to work around the fact that System.Reflection.Emit
|
||||
// can not introspect types that are being constructed
|
||||
//
|
||||
// Author:
|
||||
// Miguel de Icaza ([email protected])
|
||||
//
|
||||
// (C) 2001 Ximian, Inc (http://www.ximian.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Reflection.Emit;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Mono.CSharp {
|
||||
|
||||
public interface ParameterData {
|
||||
Type ParameterType (int pos);
|
||||
GenericConstraints GenericConstraints (int pos);
|
||||
int Count { get; }
|
||||
bool HasParams { get; }
|
||||
string ParameterName (int pos);
|
||||
string ParameterDesc (int pos);
|
||||
Parameter.Modifier ParameterModifier (int pos);
|
||||
}
|
||||
|
||||
public class ReflectionParameters : ParameterData {
|
||||
ParameterInfo [] pi;
|
||||
Type[] type_params;
|
||||
bool last_arg_is_params = false;
|
||||
bool is_varargs = false;
|
||||
ParameterData gpd;
|
||||
|
||||
public ReflectionParameters (MethodBase mb)
|
||||
{
|
||||
object [] attrs;
|
||||
|
||||
ParameterInfo [] pi = mb.GetParameters ();
|
||||
is_varargs = (mb.CallingConvention & CallingConventions.VarArgs) != 0;
|
||||
|
||||
this.pi = pi;
|
||||
int count = pi.Length-1;
|
||||
|
||||
if (count < 0)
|
||||
return;
|
||||
|
||||
if (mb.Mono_IsInflatedMethod) {
|
||||
MethodInfo generic = mb.GetGenericMethodDefinition ();
|
||||
gpd = Invocation.GetParameterData (generic);
|
||||
|
||||
last_arg_is_params = gpd.HasParams;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mb.IsGenericMethodDefinition)
|
||||
type_params = mb.GetGenericArguments ();
|
||||
|
||||
attrs = pi [count].GetCustomAttributes (TypeManager.param_array_type, true);
|
||||
if (attrs == null)
|
||||
return;
|
||||
|
||||
if (attrs.Length == 0)
|
||||
return;
|
||||
|
||||
last_arg_is_params = true;
|
||||
}
|
||||
|
||||
public Type ParameterType (int pos)
|
||||
{
|
||||
if (last_arg_is_params && pos >= pi.Length - 1)
|
||||
return pi [pi.Length - 1].ParameterType;
|
||||
else if (is_varargs && pos >= pi.Length)
|
||||
return TypeManager.runtime_argument_handle_type;
|
||||
else {
|
||||
Type t = pi [pos].ParameterType;
|
||||
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
public GenericConstraints GenericConstraints (int pos)
|
||||
{
|
||||
if (gpd != null)
|
||||
return gpd.GenericConstraints (pos);
|
||||
|
||||
if (type_params == null)
|
||||
return null;
|
||||
|
||||
return new ReflectionConstraints (type_params [pos]);
|
||||
}
|
||||
|
||||
public string ParameterName (int pos)
|
||||
{
|
||||
if (gpd != null)
|
||||
return gpd.ParameterName (pos);
|
||||
|
||||
if (last_arg_is_params && pos >= pi.Length - 1)
|
||||
return pi [pi.Length - 1].Name;
|
||||
else if (is_varargs && pos >= pi.Length)
|
||||
return "__arglist";
|
||||
else
|
||||
return pi [pos].Name;
|
||||
}
|
||||
|
||||
public string ParameterDesc (int pos)
|
||||
{
|
||||
if (is_varargs && pos >= pi.Length)
|
||||
return "";
|
||||
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
|
||||
if (pi [pos].IsIn)
|
||||
sb.Append ("in ");
|
||||
|
||||
Type partype = ParameterType (pos);
|
||||
if (partype.IsByRef){
|
||||
partype = TypeManager.GetElementType (partype);
|
||||
if (pi [pos].IsOut)
|
||||
sb.Append ("out ");
|
||||
else
|
||||
sb.Append ("ref ");
|
||||
}
|
||||
|
||||
if (pos >= pi.Length - 1 && last_arg_is_params)
|
||||
sb.Append ("params ");
|
||||
|
||||
sb.Append (TypeManager.CSharpName (partype));
|
||||
|
||||
return sb.ToString ();
|
||||
|
||||
}
|
||||
|
||||
public Parameter.Modifier ParameterModifier (int pos)
|
||||
{
|
||||
if (last_arg_is_params && pos >= pi.Length - 1)
|
||||
return Parameter.Modifier.PARAMS;
|
||||
else if (is_varargs && pos >= pi.Length)
|
||||
return Parameter.Modifier.ARGLIST;
|
||||
|
||||
if (gpd != null)
|
||||
return gpd.ParameterModifier (pos);
|
||||
|
||||
Type t = pi [pos].ParameterType;
|
||||
if (t.IsByRef){
|
||||
if ((pi [pos].Attributes & ParameterAttributes.Out) != 0)
|
||||
return Parameter.Modifier.ISBYREF | Parameter.Modifier.OUT;
|
||||
else
|
||||
return Parameter.Modifier.ISBYREF | Parameter.Modifier.REF;
|
||||
}
|
||||
|
||||
return Parameter.Modifier.NONE;
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return is_varargs ? pi.Length + 1 : pi.Length;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasParams {
|
||||
get {
|
||||
return this.last_arg_is_params;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class InternalParameters : ParameterData {
|
||||
Type [] param_types;
|
||||
bool has_varargs;
|
||||
int count;
|
||||
|
||||
public readonly Parameters Parameters;
|
||||
public readonly TypeParameter[] TypeParameters;
|
||||
|
||||
public InternalParameters (Type [] param_types, Parameters parameters)
|
||||
{
|
||||
this.param_types = param_types;
|
||||
this.Parameters = parameters;
|
||||
|
||||
has_varargs = parameters.HasArglist;
|
||||
|
||||
if (param_types == null)
|
||||
count = 0;
|
||||
else
|
||||
count = param_types.Length;
|
||||
}
|
||||
|
||||
public InternalParameters (Type [] param_types, Parameters parameters,
|
||||
TypeParameter [] type_params)
|
||||
: this (param_types, parameters)
|
||||
{
|
||||
this.TypeParameters = type_params;
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return has_varargs ? count + 1 : count;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasParams {
|
||||
get {
|
||||
return Parameters.ArrayParameter != null;
|
||||
}
|
||||
}
|
||||
|
||||
Parameter GetParameter (int pos)
|
||||
{
|
||||
Parameter [] fixed_pars = Parameters.FixedParameters;
|
||||
if (fixed_pars != null){
|
||||
int len = fixed_pars.Length;
|
||||
if (pos < len)
|
||||
return Parameters.FixedParameters [pos];
|
||||
}
|
||||
|
||||
return Parameters.ArrayParameter;
|
||||
}
|
||||
|
||||
public Type ParameterType (int pos)
|
||||
{
|
||||
if (has_varargs && pos >= count)
|
||||
return TypeManager.runtime_argument_handle_type;
|
||||
|
||||
if (param_types == null)
|
||||
return null;
|
||||
|
||||
return GetParameter (pos).ExternalType ();
|
||||
}
|
||||
|
||||
public GenericConstraints GenericConstraints (int pos)
|
||||
{
|
||||
if (TypeParameters == null)
|
||||
return null;
|
||||
|
||||
return TypeParameters [pos].Constraints;
|
||||
}
|
||||
|
||||
public string ParameterName (int pos)
|
||||
{
|
||||
if (has_varargs && pos >= count)
|
||||
return "__arglist";
|
||||
|
||||
return GetParameter (pos).Name;
|
||||
}
|
||||
|
||||
public string ParameterDesc (int pos)
|
||||
{
|
||||
if (has_varargs && pos >= count)
|
||||
return "__arglist";
|
||||
|
||||
string tmp = String.Empty;
|
||||
Parameter p = GetParameter (pos);
|
||||
|
||||
//
|
||||
// We need to and for REF/OUT, because if either is set the
|
||||
// extra flag ISBYREF will be set as well
|
||||
//
|
||||
if ((p.ModFlags & Parameter.Modifier.REF) != 0)
|
||||
tmp = "ref ";
|
||||
else if ((p.ModFlags & Parameter.Modifier.OUT) != 0)
|
||||
tmp = "out ";
|
||||
else if (p.ModFlags == Parameter.Modifier.PARAMS)
|
||||
tmp = "params ";
|
||||
|
||||
Type t = ParameterType (pos);
|
||||
|
||||
return tmp + TypeManager.CSharpName (t);
|
||||
}
|
||||
|
||||
public Parameter.Modifier ParameterModifier (int pos)
|
||||
{
|
||||
if (has_varargs && pos >= count)
|
||||
return Parameter.Modifier.ARGLIST;
|
||||
|
||||
Parameter.Modifier mod = GetParameter (pos).ModFlags;
|
||||
|
||||
if ((mod & (Parameter.Modifier.REF | Parameter.Modifier.OUT)) != 0)
|
||||
mod |= Parameter.Modifier.ISBYREF;
|
||||
|
||||
return mod;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ReflectionConstraints : GenericConstraints
|
||||
{
|
||||
GenericParameterAttributes attrs;
|
||||
Type base_type;
|
||||
Type class_constraint;
|
||||
Type[] iface_constraints;
|
||||
|
||||
public ReflectionConstraints (Type t)
|
||||
{
|
||||
Type[] constraints = t.GetGenericParameterConstraints ();
|
||||
if ((constraints.Length > 0) && !constraints [0].IsInterface) {
|
||||
class_constraint = constraints [0];
|
||||
iface_constraints = new Type [constraints.Length - 1];
|
||||
Array.Copy (constraints, 1, iface_constraints, 0, constraints.Length - 1);
|
||||
} else
|
||||
iface_constraints = constraints;
|
||||
attrs = t.GenericParameterAttributes;
|
||||
|
||||
if (HasValueTypeConstraint)
|
||||
base_type = TypeManager.value_type;
|
||||
else if (class_constraint != null)
|
||||
base_type = class_constraint;
|
||||
else
|
||||
base_type = TypeManager.object_type;
|
||||
}
|
||||
|
||||
public override GenericParameterAttributes Attributes {
|
||||
get { return attrs; }
|
||||
}
|
||||
|
||||
public override Type ClassConstraint {
|
||||
get { return class_constraint; }
|
||||
}
|
||||
|
||||
public override Type EffectiveBaseClass {
|
||||
get { return base_type; }
|
||||
}
|
||||
|
||||
public override Type[] InterfaceConstraints {
|
||||
get { return iface_constraints; }
|
||||
}
|
||||
}
|
||||
|
||||
class PtrHashtable : Hashtable {
|
||||
sealed class PtrComparer : IComparer {
|
||||
private PtrComparer () {}
|
||||
|
||||
public static PtrComparer Instance = new PtrComparer ();
|
||||
|
||||
public int Compare (object x, object y)
|
||||
{
|
||||
if (x == y)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public PtrHashtable ()
|
||||
{
|
||||
comparer = PtrComparer.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Hashtable whose keys are character arrays with the same length
|
||||
*/
|
||||
class CharArrayHashtable : Hashtable {
|
||||
sealed class ArrComparer : IComparer {
|
||||
private int len;
|
||||
|
||||
public ArrComparer (int len) {
|
||||
this.len = len;
|
||||
}
|
||||
|
||||
public int Compare (object x, object y)
|
||||
{
|
||||
char[] a = (char[])x;
|
||||
char[] b = (char[])y;
|
||||
|
||||
for (int i = 0; i < len; ++i)
|
||||
if (a [i] != b [i])
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private int len;
|
||||
|
||||
protected override int GetHash (Object key)
|
||||
{
|
||||
char[] arr = (char[])key;
|
||||
int h = 0;
|
||||
|
||||
for (int i = 0; i < len; ++i)
|
||||
h = (h << 5) - h + arr [i];
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
public CharArrayHashtable (int len)
|
||||
{
|
||||
this.len = len;
|
||||
comparer = new ArrComparer (len);
|
||||
}
|
||||
}
|
||||
|
||||
struct Pair {
|
||||
public object First;
|
||||
public object Second;
|
||||
|
||||
public Pair (object f, object s)
|
||||
{
|
||||
First = f;
|
||||
Second = s;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is a wrapper around StreamReader which is seekable.
|
||||
/// </summary>
|
||||
public class SeekableStreamReader
|
||||
{
|
||||
public SeekableStreamReader (StreamReader reader)
|
||||
{
|
||||
this.reader = reader;
|
||||
this.buffer = new char [DefaultCacheSize];
|
||||
|
||||
// Compute the preamble size
|
||||
|
||||
// Let the StreamWriter autodetect the encoder
|
||||
reader.Peek ();
|
||||
|
||||
reader.BaseStream.Position = 0;
|
||||
Encoding enc = reader.CurrentEncoding;
|
||||
// First of all, get at least a char
|
||||
|
||||
byte[] auxb = new byte [50];
|
||||
int num_bytes = 0;
|
||||
int num_chars = 0;
|
||||
int br = 0;
|
||||
do {
|
||||
br = reader.BaseStream.Read (auxb, num_bytes, auxb.Length - num_bytes);
|
||||
num_bytes += br;
|
||||
num_chars = enc.GetCharCount (auxb, 0, num_bytes);
|
||||
}
|
||||
while (num_chars == 0 && br > 0);
|
||||
|
||||
if (num_chars != 0)
|
||||
{
|
||||
// Now, check which bytes at the beginning have no effect in the
|
||||
// char count
|
||||
|
||||
int p = 0;
|
||||
while (enc.GetCharCount (auxb, p, num_bytes-p) >= num_chars)
|
||||
p++;
|
||||
|
||||
preamble_size = p - 1;
|
||||
reader.BaseStream.Position = 0;
|
||||
reader.DiscardBufferedData ();
|
||||
|
||||
buffer_start = preamble_size;
|
||||
}
|
||||
}
|
||||
|
||||
public SeekableStreamReader (Stream stream, Encoding encoding, bool detect_encoding_from_bytemarks)
|
||||
: this (new StreamReader (stream, encoding, detect_encoding_from_bytemarks))
|
||||
{ }
|
||||
|
||||
StreamReader reader;
|
||||
|
||||
private const int DefaultCacheSize = 1024;
|
||||
|
||||
char[] buffer;
|
||||
int buffer_start; // in bytes
|
||||
int buffer_size; // in bytes
|
||||
int char_count; // count buffer[] valid characters
|
||||
int pos; // index into buffer[]
|
||||
int preamble_size;
|
||||
|
||||
/// <remarks>
|
||||
/// The difference to the StreamReader's BaseStream.Position is that this one is reliable; ie. it
|
||||
// always reports the correct position and if it's modified, it also takes care of the buffered data.
|
||||
/// </remarks>
|
||||
public int Position {
|
||||
get {
|
||||
return buffer_start + reader.CurrentEncoding.GetByteCount (buffer, 0, pos);
|
||||
}
|
||||
|
||||
set {
|
||||
// This one is easy: we're modifying the position within our current
|
||||
// buffer.
|
||||
if ((value >= buffer_start) && (value < buffer_start + buffer_size)) {
|
||||
int byte_offset = value - buffer_start;
|
||||
|
||||
// pos is an index into a char
|
||||
// buffer so it might be
|
||||
// greater than the buffer
|
||||
// length now, if the buffer
|
||||
// contains multibyte chars
|
||||
pos = byte_offset;
|
||||
|
||||
// encoded characters can take
|
||||
// more than 1 byte length.
|
||||
while ((pos > buffer.Length) ||
|
||||
reader.CurrentEncoding.GetByteCount (buffer, 0, pos) > byte_offset) {
|
||||
pos--;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == 0) // Skip preamble
|
||||
value = preamble_size;
|
||||
|
||||
// Ok, now we need to seek.
|
||||
reader.DiscardBufferedData ();
|
||||
reader.BaseStream.Position = buffer_start = value;
|
||||
char_count = buffer_size = pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private bool ReadBuffer ()
|
||||
{
|
||||
pos = 0;
|
||||
buffer_start += buffer_size;
|
||||
char_count = reader.Read (buffer, 0, buffer.Length);
|
||||
buffer_size = reader.CurrentEncoding.GetByteCount (buffer, 0, char_count);
|
||||
return buffer_size > 0;
|
||||
}
|
||||
|
||||
public int Peek ()
|
||||
{
|
||||
if ((pos >= char_count) && !ReadBuffer ())
|
||||
return -1;
|
||||
|
||||
return buffer [pos];
|
||||
}
|
||||
|
||||
public int Read ()
|
||||
{
|
||||
if ((pos >= char_count) && !ReadBuffer ())
|
||||
return -1;
|
||||
|
||||
return buffer [pos++];
|
||||
}
|
||||
}
|
||||
|
||||
public class DoubleHash {
|
||||
const int DEFAULT_INITIAL_BUCKETS = 100;
|
||||
|
||||
public DoubleHash () : this (DEFAULT_INITIAL_BUCKETS) {}
|
||||
|
||||
public DoubleHash (int size)
|
||||
{
|
||||
count = size;
|
||||
buckets = new Entry [size];
|
||||
}
|
||||
|
||||
int count;
|
||||
Entry [] buckets;
|
||||
int size = 0;
|
||||
|
||||
class Entry {
|
||||
public object key1;
|
||||
public object key2;
|
||||
public int hash;
|
||||
public object value;
|
||||
public Entry next;
|
||||
|
||||
public Entry (object key1, object key2, int hash, object value, Entry next)
|
||||
{
|
||||
this.key1 = key1;
|
||||
this.key2 = key2;
|
||||
this.hash = hash;
|
||||
this.next = next;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Lookup (object a, object b, out object res)
|
||||
{
|
||||
int h = (a.GetHashCode () ^ b.GetHashCode ()) & 0x7FFFFFFF;
|
||||
|
||||
for (Entry e = buckets [h % count]; e != null; e = e.next) {
|
||||
if (e.hash == h && e.key1.Equals (a) && e.key2.Equals (b)) {
|
||||
res = e.value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
res = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Insert (object a, object b, object value)
|
||||
{
|
||||
// Is it an existing one?
|
||||
|
||||
int h = (a.GetHashCode () ^ b.GetHashCode ()) & 0x7FFFFFFF;
|
||||
|
||||
for (Entry e = buckets [h % count]; e != null; e = e.next) {
|
||||
if (e.hash == h && e.key1.Equals (a) && e.key2.Equals (b))
|
||||
e.value = value;
|
||||
}
|
||||
|
||||
int bucket = h % count;
|
||||
buckets [bucket] = new Entry (a, b, h, value, buckets [bucket]);
|
||||
|
||||
// Grow whenever we double in size
|
||||
if (size++ == count) {
|
||||
count <<= 1;
|
||||
count ++;
|
||||
|
||||
Entry [] newBuckets = new Entry [count];
|
||||
foreach (Entry root in buckets) {
|
||||
Entry e = root;
|
||||
while (e != null) {
|
||||
int newLoc = e.hash % count;
|
||||
Entry n = e.next;
|
||||
e.next = newBuckets [newLoc];
|
||||
newBuckets [newLoc] = e;
|
||||
e = n;
|
||||
}
|
||||
}
|
||||
|
||||
buckets = newBuckets;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// symbolwriter.cs: The symbol writer
|
||||
//
|
||||
// Author:
|
||||
// Martin Baulig ([email protected])
|
||||
//
|
||||
// (C) 2003 Ximian, Inc.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
|
||||
namespace Mono.CSharp {
|
||||
public class SymbolWriter : MonoSymbolWriter {
|
||||
delegate int GetILOffsetFunc (ILGenerator ig);
|
||||
delegate Guid GetGuidFunc (ModuleBuilder mb);
|
||||
|
||||
GetILOffsetFunc get_il_offset_func;
|
||||
GetGuidFunc get_guid_func;
|
||||
|
||||
ModuleBuilder module_builder;
|
||||
|
||||
protected SymbolWriter (ModuleBuilder module_builder, string filename)
|
||||
: base (filename)
|
||||
{
|
||||
this.module_builder = module_builder;
|
||||
}
|
||||
|
||||
bool Initialize ()
|
||||
{
|
||||
MethodInfo mi = typeof (ILGenerator).GetMethod (
|
||||
"Mono_GetCurrentOffset",
|
||||
BindingFlags.Static | BindingFlags.NonPublic);
|
||||
if (mi == null)
|
||||
return false;
|
||||
|
||||
get_il_offset_func = (GetILOffsetFunc) System.Delegate.CreateDelegate (
|
||||
typeof (GetILOffsetFunc), mi);
|
||||
|
||||
mi = typeof (ModuleBuilder).GetMethod (
|
||||
"Mono_GetGuid",
|
||||
BindingFlags.Static | BindingFlags.NonPublic);
|
||||
if (mi == null)
|
||||
return false;
|
||||
|
||||
get_guid_func = (GetGuidFunc) System.Delegate.CreateDelegate (
|
||||
typeof (GetGuidFunc), mi);
|
||||
|
||||
Location.DefineSymbolDocuments (this);
|
||||
Namespace.DefineNamespaces (this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void DefineLocalVariable (string name, LocalBuilder builder)
|
||||
{
|
||||
SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (
|
||||
module_builder);
|
||||
sighelper.AddArgument (builder.LocalType);
|
||||
byte[] signature = sighelper.GetSignature ();
|
||||
|
||||
DefineLocalVariable (name, signature);
|
||||
}
|
||||
|
||||
public void MarkSequencePoint (ILGenerator ig, int row, int column)
|
||||
{
|
||||
int offset = get_il_offset_func (ig);
|
||||
MarkSequencePoint (offset, row, column);
|
||||
}
|
||||
|
||||
public void WriteSymbolFile ()
|
||||
{
|
||||
Guid guid = get_guid_func (module_builder);
|
||||
WriteSymbolFile (guid);
|
||||
}
|
||||
|
||||
public static SymbolWriter GetSymbolWriter (ModuleBuilder module,
|
||||
string filename)
|
||||
{
|
||||
SymbolWriter writer = new SymbolWriter (module, filename);
|
||||
if (!writer.Initialize ())
|
||||
return null;
|
||||
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
//
|
||||
// tree.cs: keeps a tree representation of the generated code
|
||||
//
|
||||
// Author: Miguel de Icaza ([email protected])
|
||||
//
|
||||
// Licensed under the terms of the GNU GPL
|
||||
//
|
||||
// (C) 2001 Ximian, Inc (http://www.ximian.com)
|
||||
//
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.IO;
|
||||
|
||||
namespace Mono.CSharp
|
||||
{
|
||||
|
||||
public interface ITreeDump {
|
||||
int Dump (Tree tree, StreamWriter output);
|
||||
void ParseOptions (string options);
|
||||
}
|
||||
|
||||
// <summary>
|
||||
//
|
||||
// We store here all the toplevel types that we have parsed,
|
||||
// this is the root of all information we have parsed.
|
||||
//
|
||||
// </summary>
|
||||
|
||||
public class Tree {
|
||||
TypeContainer root_types;
|
||||
|
||||
// <summary>
|
||||
// Keeps track of all the types definied (classes, structs, ifaces, enums)
|
||||
// </summary>
|
||||
Hashtable decls;
|
||||
|
||||
public Tree ()
|
||||
{
|
||||
root_types = new RootTypes ();
|
||||
|
||||
decls = new Hashtable ();
|
||||
}
|
||||
|
||||
DoubleHash decl_ns_name = new DoubleHash ();
|
||||
|
||||
public void RecordDecl (string name, DeclSpace ds)
|
||||
{
|
||||
DeclSpace other = (DeclSpace) decls [name];
|
||||
if (other != null){
|
||||
PartialContainer other_pc = other as PartialContainer;
|
||||
if ((ds is TypeContainer) && (other_pc != null)) {
|
||||
Report.Error (
|
||||
260, ds.Location, "Missing partial modifier " +
|
||||
"on declaration of type `{0}'; another " +
|
||||
"partial implementation of this type exists",
|
||||
name);
|
||||
|
||||
Report.LocationOfPreviousError (other.Location);
|
||||
return;
|
||||
}
|
||||
|
||||
Report.SymbolRelatedToPreviousError (
|
||||
other.Location, other.GetSignatureForError ());
|
||||
|
||||
Report.Error (
|
||||
101, ds.Location,
|
||||
"There is already a definition for `" + name + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
ds.RecordDecl ();
|
||||
|
||||
int p = name.LastIndexOf ('.');
|
||||
if (p == -1)
|
||||
decl_ns_name.Insert ("", name, ds);
|
||||
else {
|
||||
decl_ns_name.Insert (name.Substring (0, p), name.Substring (p+1), ds);
|
||||
}
|
||||
|
||||
decls.Add (name, ds);
|
||||
}
|
||||
|
||||
public DeclSpace LookupByNamespace (string ns, string name)
|
||||
{
|
||||
object res;
|
||||
|
||||
decl_ns_name.Lookup (ns, name, out res);
|
||||
return (DeclSpace) res;
|
||||
}
|
||||
|
||||
//
|
||||
// FIXME: Why are we using Types?
|
||||
//
|
||||
public TypeContainer Types {
|
||||
get {
|
||||
return root_types;
|
||||
}
|
||||
}
|
||||
|
||||
public Hashtable Decls {
|
||||
get {
|
||||
return decls;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class RootTypes : TypeContainer
|
||||
{
|
||||
public RootTypes ()
|
||||
: base (null, null, MemberName.Null, null, Kind.Root, Location.Null)
|
||||
{
|
||||
ec = new EmitContext (null, this, Location.Null, null, null, 0, false);
|
||||
}
|
||||
|
||||
public override void Register ()
|
||||
{
|
||||
throw new InvalidOperationException ();
|
||||
}
|
||||
|
||||
public override PendingImplementation GetPendingImplementations ()
|
||||
{
|
||||
throw new InvalidOperationException ();
|
||||
}
|
||||
|
||||
public override bool IsClsCompliaceRequired (DeclSpace ds)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
config.make
|
||||
pre-config.make
|
||||
semantic.cache
|
||||
@@ -1,203 +1,3 @@
|
||||
2008-06-30 Marek Safar <[email protected]>
|
||||
|
||||
* platforms/linux.make: Enable mcs optimizations.
|
||||
|
||||
2008-06-03 Zoltan Varga <[email protected]>
|
||||
|
||||
* rules.make (PROFILE): Reapply the PROFILE=net_2_0 change. One can still
|
||||
build 1.1 libraries using make PROFILE=default.
|
||||
|
||||
2008-05-27 Raja R Harinath <[email protected]>
|
||||
|
||||
* executable.make ($(PROGRAM_config)): Depend on directory
|
||||
creation stamp.
|
||||
|
||||
2008-04-09 Gert Driesen <[email protected]>
|
||||
|
||||
* library.make: hidden -bootstrap option for gacutil is no longer
|
||||
necessary.
|
||||
|
||||
2008-03-24 Zoltan Varga <[email protected]>
|
||||
|
||||
* library.make (check): Add a standard check target and make it the same as
|
||||
run-test.
|
||||
|
||||
2008-03-22 Zoltan Varga <[email protected]>
|
||||
|
||||
* profiles/net_3_5.make (PROFILE_MCS_FLAGS): Get rid of obsolete
|
||||
-langversion:linq option.
|
||||
|
||||
Fri Mar 14 09:31:59 CET 2008 Paolo Molaro <[email protected]>
|
||||
|
||||
* rules.make, library.make: move GACUTIL definition into rules.make as
|
||||
it's used also by the tools. Add the hidden -bootstrap option.
|
||||
|
||||
2008-02-18 Raja R Harinath <[email protected]>
|
||||
|
||||
* rules.make (%/.stamp): Unify all directory creation targets here.
|
||||
|
||||
2008-02-17 Raja R Harinath <[email protected]>
|
||||
|
||||
* profiles/net_2_1_bootstrap.make: New.
|
||||
* profiles/net_2_1_raw.make: New. The untuned 2.1 profile.
|
||||
* profiles/net_2_1.make: New. The tuned 2.1 profile.
|
||||
* Makefile (PROFILES): Update.
|
||||
|
||||
2007-12-06 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* profiles/net_3_5.make : fixed net_2_0 path.
|
||||
|
||||
2007-12-03 Marek Safar <[email protected]>
|
||||
|
||||
* Makefile.make: Distribute 3.5 profile
|
||||
|
||||
2007-11-08 Wade Berrier <[email protected]>
|
||||
|
||||
* config-default.make: add sysconfdir dir (for mconfig/config.xml)
|
||||
|
||||
2007-11-01 Marek Safar <[email protected]>
|
||||
|
||||
* corcompare.make: Build corcompare into same directory.
|
||||
|
||||
2007-10-27 Marek Safar <[email protected]>
|
||||
|
||||
* profiles/net_2_0_bootstrap.make: Fixed generics compiler name.
|
||||
|
||||
2007-10-27 Marek Safar <[email protected]>
|
||||
|
||||
* rules.make: Changed gmcs location.
|
||||
|
||||
2007-10-27 Marek Safar <[email protected]>
|
||||
|
||||
* executable.make: Added KEEP_OUTPUT_FILE_COPY to avoid move and copy
|
||||
back compiler executables.
|
||||
|
||||
2007-09-21 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile (PROFILES): Remove 'atomic' profiles.
|
||||
* profiles/atomic.make, profiles/bootstrap.make: Remove.
|
||||
|
||||
2007-09-04 Wade Berrier <[email protected]>
|
||||
|
||||
* library.make: Glob for .sources for all profiles.
|
||||
Use tools/removecomments.sh to account for '#include' and
|
||||
comments, which are only used in the jvm profile at this point
|
||||
|
||||
2007-09-01 Jb Evain <[email protected]>
|
||||
|
||||
* Makefile: consider the net_2_1 profile.
|
||||
|
||||
2007-08-12 Marek Safar <[email protected]>
|
||||
|
||||
* library.make: Includes new `corcompare' target.
|
||||
|
||||
* corcompare.make: I got tired of hacking corcompare stuff again and
|
||||
again.
|
||||
|
||||
2007-08-11 Jb Evain <[email protected]>
|
||||
|
||||
* profiles/net_2_1: allow 2.1 assemblies in the GAC.
|
||||
|
||||
2007-07-27 Jb Evain <[email protected]>
|
||||
|
||||
* profiles/net_2_1: use smcs to compile the .net 2.1 assemblies.
|
||||
|
||||
2007-07-23 Raja R Harinath <[email protected]>
|
||||
|
||||
* library.make (install-local) [GAC]: If LIBRARY_PACKAGE is set to
|
||||
'none' don't install a symlink from a package directory into the gac.
|
||||
|
||||
2007-07-11 Jb Evain <[email protected]>
|
||||
|
||||
* profiles/net_2_1.make: work on the 2_1 profile.
|
||||
|
||||
2007-06-12 Marek Safar <[email protected]>
|
||||
|
||||
* rules.make: Added FRAMEWORK_VERSION_MAJOR.
|
||||
|
||||
2007-05-11 Raja R Harinath <[email protected]>
|
||||
|
||||
* Makefile (dist-local): Remove special-case code.
|
||||
* rules.make ($(depsdir)): New rule to create the dependencies
|
||||
directory on demand.
|
||||
* library.make, executable.make: Make generated files depend on
|
||||
$(depsdir).
|
||||
* profiles/basic.make: Likewise.
|
||||
|
||||
* profiles/net_2_0_bootstrap.make: Move rules for mcs.exe to
|
||||
mcs/Makefile.
|
||||
* library.make (the_libdir, build_libdir): New. Create these
|
||||
directories on demand instead of worrying about keeping the list
|
||||
of profiles uptodate.
|
||||
* executable.make (prog_dir): Likewise.
|
||||
|
||||
2007-03-17 Marek Sieradzki <[email protected]>
|
||||
|
||||
* library.make: Show correct log (TestResult-ondotnet-PROFILE...) for
|
||||
make run-test-ondotnet.
|
||||
|
||||
Fri Nov 24 18:38:31 CET 2006 Paolo Molaro <[email protected]>
|
||||
|
||||
* library.make: added ability to pass flags to the mono runtime when
|
||||
running the test suite.
|
||||
|
||||
2006-09-06 Kornél Pál <[email protected]>
|
||||
|
||||
* TestConfiguration.cs: Moved to Npgsql.
|
||||
|
||||
2006-09-05 Kornél Pál <[email protected]>
|
||||
|
||||
* config-default.make: Use UTF-8 as the default encoding for compilers.
|
||||
|
||||
2006-09-04 Raja R Harinath <[email protected]>
|
||||
|
||||
* library.make (TEST_HARNESS_VERBOSE): New user toggle. If
|
||||
defined, NUnit will print the names of the unit tests as they are
|
||||
run. Can be used to narrow down infloops.
|
||||
(TEST_HARNESS_EXCLUDE): Provide a way to override the list of
|
||||
excluded unit test categories.
|
||||
|
||||
2006-04-11 Raja R Harinath <[email protected]>
|
||||
|
||||
* profiles/default.make (BOOTSTRAP_PROFILE): Define.
|
||||
* profiles/net_2_0.make (BOOTSTRAP_PROFILE): Define.
|
||||
* rules.make (INTERNAL_RESGEN): Pick from bootstrap profile.
|
||||
|
||||
2006-01-19 Raja R Harinath <[email protected]>
|
||||
|
||||
* library.make (test_lib): Don't allow to be overridden.
|
||||
(test_against, test_dep): Remove.
|
||||
|
||||
2006-01-11 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* executable.make: allow installing a different .config file for
|
||||
executables such as nunit-console.exe that should use a different one
|
||||
depending on the profile.
|
||||
|
||||
2006-01-05 Raja R Harinath <[email protected]>
|
||||
|
||||
* library.make (run-test-lib, run-test-ondotnet-lib): Workaround a
|
||||
sed limitation when printing the testsuite log.
|
||||
|
||||
2005-12-22 Raja R Harinath <[email protected]>
|
||||
|
||||
* library.make (lib_dir): Define to 'compat' if LIBRARY_COMPAT is
|
||||
defined, 'lib' otherwise.
|
||||
(the_lib): Use it to decide where to place the output library.
|
||||
(LIBRARY_PACKAGE): New define. Install development symlinks for
|
||||
compat libraries in a different directory.
|
||||
|
||||
2005-12-03 Kornél Pál <[email protected]>
|
||||
|
||||
* config-default.make: Corrected default CODEPAGE comment to ISO-8859-1
|
||||
(Latin 1).
|
||||
|
||||
2005-11-22 Vladislav Spivak <[email protected]>
|
||||
* Missed dependency.
|
||||
<profile>.sources file is supporting #include directive
|
||||
Usually it includes common .sources file.
|
||||
Let's make it dependency of <profile>.sources
|
||||
|
||||
2005-10-03 Raja R Harinath <[email protected]>
|
||||
|
||||
* profiles/basic.make (monolite_flag, use_monolite): New. Used to
|
||||
|
||||
@@ -16,29 +16,20 @@ common/Consts.cs: common/Consts.cs.in $(wildcard config.make)
|
||||
|
||||
PLATFORMS = linux win32
|
||||
PROFILES = \
|
||||
basic \
|
||||
net_1_1_bootstrap \
|
||||
default \
|
||||
net_2_0_bootstrap \
|
||||
net_2_0 \
|
||||
net_2_1_bootstrap \
|
||||
net_2_1_raw \
|
||||
net_2_1 \
|
||||
net_1_0 \
|
||||
net_3_5
|
||||
basic net_1_1_bootstrap default net_2_0_bootstrap net_2_0 \
|
||||
atomic net_1_0
|
||||
|
||||
COMMON_SRCS = \
|
||||
Consts.cs.in \
|
||||
Locale.cs \
|
||||
MonoTODOAttribute.cs
|
||||
MonoTODOAttribute.cs \
|
||||
TestConfiguration.cs
|
||||
|
||||
DISTFILES = \
|
||||
README.makefiles \
|
||||
README.platforms \
|
||||
README.configury \
|
||||
config-default.make \
|
||||
corcompare.make \
|
||||
corcompare-api.xsl \
|
||||
executable.make \
|
||||
library.make \
|
||||
rules.make \
|
||||
@@ -46,4 +37,4 @@ DISTFILES = \
|
||||
$(PLATFORMS:%=platforms/%.make) $(PROFILES:%=profiles/%.make)
|
||||
|
||||
dist-local: dist-default
|
||||
|
||||
$(MKINSTALLDIRS) $(distdir)/deps
|
||||
@@ -1,49 +1,3 @@
|
||||
2008-04-13 Jb Evain <[email protected]>
|
||||
|
||||
* Consts.cs.in: update the 2.1 profile versions.
|
||||
Merged from the Moonlight 2 branch.
|
||||
|
||||
2008-04-09 Andreas Nahr <[email protected]>
|
||||
|
||||
* Consts.cs.in: Add common strings for assembly attributes
|
||||
|
||||
2007-12-31 Gert Driesen <[email protected]>
|
||||
|
||||
* Consts.cs.in: Add corlib assembly name.
|
||||
|
||||
2007-12-04 Marek Safar <[email protected]>
|
||||
|
||||
* Consts.cs.in: Update 3.5 to RTM version number.
|
||||
|
||||
2007-08-20 Marek Safar <[email protected]>
|
||||
|
||||
* Consts.cs.in: Add NET_3_5 constants.
|
||||
|
||||
2007-06-12 Marek Safar <[email protected]>
|
||||
|
||||
* Consts.cs.in: Add NET_2_1 constants.
|
||||
|
||||
2007-06-01 Atsushi Enomoto <[email protected]>
|
||||
|
||||
* MonoTODOAttribute.cs : fixed regression that those derived todo
|
||||
attribute types are not reported in the class status pages.
|
||||
|
||||
2006-12-14 Eyal Alaluf <[email protected]>
|
||||
|
||||
* MonoTODOAttribute.cs: Add MonoDocumentationNoteAttribute,
|
||||
MonoExtensionAttribute, MonoInternalNoteAttribute,
|
||||
MonoLimitationAttribute and MonoNotSupportedAttribute. These
|
||||
attribute will be used to describe the status of the Mono APIs.
|
||||
|
||||
2006-09-06 Kornél Pál <[email protected]>
|
||||
|
||||
* Makefile: Removed TestConfiguration.cs.
|
||||
|
||||
2006-06-07 Kornél Pál <[email protected]>
|
||||
|
||||
* Consts.cs.in: Removed RuntimeVersion as it should be the same as
|
||||
FxFileVersion. Use FxFileVersion for Environment.Version.
|
||||
|
||||
2005-11-05 Kornél Pál <[email protected]>
|
||||
|
||||
* Consts.cs.in: Removed obsolete using System.Runtime.InteropServices.
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// Consts.cs.in
|
||||
//
|
||||
// Author:
|
||||
// Kornél Pál <http://www.kornelpal.hu/>
|
||||
// Kornél Pál <http://www.kornelpal.hu/>
|
||||
//
|
||||
// Copyright (C) 2005-2006 Kornél Pál
|
||||
// Copyright (C) 2005 Kornél Pál
|
||||
//
|
||||
|
||||
//
|
||||
@@ -47,40 +47,28 @@ internal
|
||||
//
|
||||
|
||||
public const string MonoVersion = "@MONO_VERSION@";
|
||||
public const string MonoCompany = "MONO development team";
|
||||
public const string MonoProduct = "MONO Common language infrastructure";
|
||||
public const string MonoCopyright = "(c) various MONO Authors";
|
||||
|
||||
#if NET_3_5
|
||||
// Versions of .NET Framework 3.5 RTM
|
||||
public const string FxVersion = "3.5.0.0";
|
||||
public const string FxFileVersion = "3.5.21022.8";
|
||||
|
||||
public const string VsVersion = "0.0.0.0"; // Useless ?
|
||||
#elif NET_2_1
|
||||
// Versions of .NET Framework for SilverLight
|
||||
public const string FxVersion = "2.0.5.0";
|
||||
public const string VsVersion = "9.0.0.0"; // TODO:
|
||||
public const string FxFileVersion = "2.0.30226.2";
|
||||
public const string VsFileVersion = "9.0.50727.42"; // TODO:
|
||||
#elif NET_2_0 || BOOTSTRAP_NET_2_0
|
||||
// Versions of .NET Framework 2.0 RTM
|
||||
#if NET_2_0 || BOOTSTRAP_NET_2_0
|
||||
// Environment.Version of .NET Framework 2.0 RTM
|
||||
public const string RuntimeVersion = "2.0.50727.42";
|
||||
public const string FxVersion = "2.0.0.0";
|
||||
public const string VsVersion = "8.0.0.0";
|
||||
public const string FxFileVersion = "2.0.50727.42";
|
||||
public const string VsFileVersion = "8.0.50727.42";
|
||||
#elif NET_1_1
|
||||
// Versions of .NET Framework 1.1 SP1
|
||||
#elif NET_1_1 || TARGET_JVM
|
||||
// Environment.Version of .NET Framework 1.1 SP1
|
||||
public const string RuntimeVersion = "1.1.4322.2032";
|
||||
public const string FxVersion = "1.0.5000.0";
|
||||
public const string VsVersion = "7.0.5000.0";
|
||||
public const string FxFileVersion = "1.1.4322.2032";
|
||||
public const string VsFileVersion = "7.10.6001.4";
|
||||
public const string VsFileVersion = "7.10.3052.4";
|
||||
#elif NET_1_0
|
||||
// Versions of .NET Framework 1.0 SP3
|
||||
// Environment.Version of .NET Framework 1.0 SP3
|
||||
public const string RuntimeVersion = "1.0.3705.6018";
|
||||
public const string FxVersion = "1.0.3300.0";
|
||||
public const string VsVersion = "7.0.3300.0";
|
||||
public const string FxFileVersion = "1.0.3705.6018";
|
||||
public const string VsFileVersion = "7.0.9951.0";
|
||||
public const string VsFileVersion = "7.0.9466.0";
|
||||
#else
|
||||
#error No profile symbols defined.
|
||||
#endif
|
||||
@@ -98,7 +86,6 @@ internal
|
||||
public const string AssemblyMono_Http = "Mono.Http, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=0738eb9f132ed756";
|
||||
public const string AssemblyMono_Posix = "Mono.Posix, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=0738eb9f132ed756";
|
||||
public const string AssemblyMono_Security = "Mono.Security, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=0738eb9f132ed756";
|
||||
public const string AssemblyCorlib = "mscorlib, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=b77a5c561934e089";
|
||||
public const string AssemblySystem = "System, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=b77a5c561934e089";
|
||||
public const string AssemblySystem_Data = "System.Data, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=b77a5c561934e089";
|
||||
public const string AssemblySystem_Design = "System.Design, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
//
|
||||
// MonoTODOAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Author:
|
||||
// Ravi Pratap ([email protected])
|
||||
// Eyal Alaluf <[email protected]>
|
||||
//
|
||||
// (C) Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
|
||||
// Copyright (C) 2006 Mainsoft, Inc (http://www.mainsoft.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
@@ -35,7 +33,7 @@
|
||||
namespace System {
|
||||
|
||||
[AttributeUsage (AttributeTargets.All, AllowMultiple=true)]
|
||||
internal class MonoTODOAttribute : Attribute {
|
||||
internal sealed class MonoTODOAttribute : Attribute {
|
||||
|
||||
string comment;
|
||||
|
||||
@@ -48,73 +46,8 @@ namespace System {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public virtual string Comment {
|
||||
public string Comment {
|
||||
get { return comment; }
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage (AttributeTargets.All, AllowMultiple=true)]
|
||||
internal class MonoDocumentationNoteAttribute : MonoTODOAttribute {
|
||||
|
||||
public MonoDocumentationNoteAttribute (string comment)
|
||||
: base (comment)
|
||||
{
|
||||
}
|
||||
|
||||
public override string Comment {
|
||||
get { return base.Comment; }
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage (AttributeTargets.All, AllowMultiple=true)]
|
||||
internal class MonoExtensionAttribute : MonoTODOAttribute {
|
||||
|
||||
public MonoExtensionAttribute (string comment)
|
||||
: base (comment)
|
||||
{
|
||||
}
|
||||
|
||||
public override string Comment {
|
||||
get { return base.Comment; }
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage (AttributeTargets.All, AllowMultiple=true)]
|
||||
internal class MonoInternalNoteAttribute : MonoTODOAttribute {
|
||||
|
||||
public MonoInternalNoteAttribute (string comment)
|
||||
: base (comment)
|
||||
{
|
||||
}
|
||||
|
||||
public override string Comment {
|
||||
get { return base.Comment; }
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage (AttributeTargets.All, AllowMultiple=true)]
|
||||
internal class MonoLimitationAttribute : MonoTODOAttribute {
|
||||
|
||||
public MonoLimitationAttribute (string comment)
|
||||
: base (comment)
|
||||
{
|
||||
}
|
||||
|
||||
public override string Comment {
|
||||
get { return base.Comment; }
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage (AttributeTargets.All, AllowMultiple=true)]
|
||||
internal class MonoNotSupportedAttribute : MonoTODOAttribute {
|
||||
|
||||
public MonoNotSupportedAttribute (string comment)
|
||||
: base (comment)
|
||||
{
|
||||
}
|
||||
|
||||
public override string Comment {
|
||||
get { return base.Comment; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ using NUnit.Framework;
|
||||
using NUnit.Core;
|
||||
|
||||
|
||||
namespace NpgsqlTests {
|
||||
namespace System {
|
||||
class TestConfiguration {
|
||||
public static string NpgsqlConnectionString {
|
||||
get {
|
||||
@@ -6,8 +6,8 @@
|
||||
# DO NOT EDIT THIS FILE! Create config.make and override settings
|
||||
# there.
|
||||
|
||||
# Use UTF-8 as the default encoding for compilers
|
||||
CODEPAGE = 65001
|
||||
# Use ISO-28591 as the default encoding for compilers
|
||||
CODEPAGE = 28591
|
||||
|
||||
RUNTIME_FLAGS =
|
||||
TEST_HARNESS = $(topdir)/class/lib/$(PROFILE)/nunit-console.exe
|
||||
@@ -18,7 +18,6 @@ CFLAGS = -g -O2
|
||||
prefix = /usr/local
|
||||
exec_prefix = $(prefix)
|
||||
mono_libdir = $(exec_prefix)/lib
|
||||
sysconfdir = $(prefix)/etc
|
||||
#RUNTIME = mono
|
||||
RUNTIME = false
|
||||
TEST_RUNTIME = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$(TEST_MONO_PATH)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) --debug
|
||||
|
||||
@@ -1,568 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
<xsl:param name="source-name" select="(fillme)" />
|
||||
<xsl:output method="html" indent="no"/>
|
||||
<!-- <xsl:output method="xml"/>-->
|
||||
<xsl:strip-space elements="*"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:variable name="assembly-name" select="substring-before ($source-name, '.src')" />
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
Mono Class Library Status for <xsl:value-of select="$assembly-name" />
|
||||
</title>
|
||||
<script src="cm/cormissing.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="cm/cormissing.css"></link>
|
||||
<style type="text/css"><![CDATA[
|
||||
div.links {
|
||||
background-color: #CCFFCC;
|
||||
}
|
||||
div.links ul li {
|
||||
display: inline;
|
||||
padding: 5px;
|
||||
}
|
||||
]]></style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="links">
|
||||
<ul>
|
||||
<li><a href="System.Runtime.Serialization.html">Runtime.Serialization</a></li>
|
||||
<li><a href="System.IdentityModel.html">IdentityModel</a></li>
|
||||
<li><a href="System.IdentityModel.Selectors.html">IdentityModel.Selectors</a></li>
|
||||
<li><a href="System.ServiceModel.html">ServiceModel</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="main">
|
||||
<p>
|
||||
<h1>Mono Class Library Status for <xsl:value-of select="$assembly-name" /></h1>
|
||||
</p>
|
||||
<p>
|
||||
<table>
|
||||
<tr>
|
||||
<td> <input type="checkbox" ID="todo" onClick="selectTodo();" checked="1"/> </td>
|
||||
<td> <img src="cm/st.gif"/> </td>
|
||||
<td> TODO </td>
|
||||
<td width="20"/>
|
||||
<td> <input type="checkbox" ID="missing" onClick="selectMissing();" checked="1"/> </td>
|
||||
<td> <img src="cm/sm.gif"/> </td>
|
||||
<td> Missing </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <input type="checkbox" ID="extra" onClick="selectExtra();" checked="1"/> </td>
|
||||
<td> <img src="cm/sx.gif"/> </td>
|
||||
<td> Extra </td>
|
||||
<td width="20"/>
|
||||
<td> <input type="checkbox" ID="errors" onClick="selectErrors();" checked="1"/> </td>
|
||||
<td> <img src="cm/se.gif"/> </td>
|
||||
<td> Errors </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> <img src="cm/sc.gif"/> </td>
|
||||
<td> Completed </td>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<select id="FilteredAttributes">
|
||||
<option>System.Runtime.InteropServices.ComVisibleAttribute</option>
|
||||
<option>System.Diagnostics.DebuggerDisplayAttribute</option>
|
||||
<option>System.Diagnostics.DebuggerTypeProxyAttribute</option>
|
||||
</select>
|
||||
<input type="button" onclick="removeAndFilter()" value="Unfilter attribute" />
|
||||
</p>
|
||||
<p>
|
||||
<input type="text" id="NewFilterTarget" length="60" />
|
||||
<input type="button" onclick="addAndFilter()" value="Add to attribute filter" />
|
||||
</p>
|
||||
<p>Target Reference:
|
||||
<input type="radio" id="TargetMonodoc" name="TargetDoc" value="0" />monodoc
|
||||
<input type="radio" id="TargetMsdn1" name="TargetDoc" value="1" />msdn
|
||||
<input type="radio" id="TargetMsdn2" name="TargetDoc" value="2" checked="checked" />msdn2
|
||||
<input type="radio" id="TargetWinsdk" name="TargetDoc" value="3" checked="checked" />Windows SDK
|
||||
</p>
|
||||
|
||||
<DIV ID="ROOT">
|
||||
<xsl:apply-templates/>
|
||||
</DIV>
|
||||
<p>
|
||||
Legend :<BR/>
|
||||
<table>
|
||||
<tr>
|
||||
<td> <img src="cm/y.gif"/> </td>
|
||||
<td> Assembly </td>
|
||||
<td width="20"/>
|
||||
<td> <img src="cm/n.gif"/> </td>
|
||||
<td> Namespace </td>
|
||||
<td width="20"/>
|
||||
<td> <img src="cm/c.gif"/> </td>
|
||||
<td> Class </td>
|
||||
<td width="20"/>
|
||||
<td> <img src="cm/s.gif"/> </td>
|
||||
<td> Struct </td>
|
||||
<tr>
|
||||
</tr>
|
||||
<td> <img src="cm/i.gif"/> </td>
|
||||
<td> Interface </td>
|
||||
<td width="20"/>
|
||||
<td> <img src="cm/d.gif"/> </td>
|
||||
<td> Delegate </td>
|
||||
<td width="20"/>
|
||||
<td> <img src="cm/en.gif"/> </td>
|
||||
<td> Enum </td>
|
||||
<td width="20"/>
|
||||
<td> <img src="cm/m.gif"/> </td>
|
||||
<td> Method </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <img src="cm/f.gif"/> </td>
|
||||
<td> Field </td>
|
||||
<td width="20"/>
|
||||
<td> <img src="cm/p.gif"/> </td>
|
||||
<td> Property </td>
|
||||
<td width="20"/>
|
||||
<td> <img src="cm/e.gif"/> </td>
|
||||
<td> Event </td>
|
||||
<td width="20"/>
|
||||
<td> <img src="cm/r.gif"/> </td>
|
||||
<td> Attribute </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <img src="cm/w.gif" /> </td>
|
||||
<td colspan="10"> Generic Constraints</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<!-- assembly -->
|
||||
<xsl:template match="/assemblies">
|
||||
<xsl:apply-templates select="assembly">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="assembly">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">y</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- namespace -->
|
||||
<xsl:template match="namespaces">
|
||||
<xsl:apply-templates select="namespace">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="namespace">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">n</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="namespace/classes">
|
||||
<xsl:apply-templates select="class[@type='interface']">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates select="class[@type='class']">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates select="class[@type='struct']">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates select="class[@type='delegate']">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates select="class[@type='enum']">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- class -->
|
||||
<xsl:template match="class[@type='class']">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">c</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="(@missing_total or @todo_total or @extra_total or @warning_total or @error) and not(@presence)">
|
||||
<xsl:apply-templates select="attributes"/>
|
||||
<xsl:apply-templates select="interfaces"/>
|
||||
<xsl:apply-templates select="constructors"/>
|
||||
<xsl:apply-templates select="./*[local-name() != 'attributes' and local-name() != 'constructors' and local-name() != 'interfaces']"/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- struct -->
|
||||
<xsl:template match="class[@type='struct'][@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">s</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<!-- interface types -->
|
||||
<xsl:template match="class[@type='interface']">
|
||||
<xsl:apply-templates select="class[@type='interface']">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="class[@type='interface'][@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">i</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
<!-- interfaces implemented by Types -->
|
||||
<xsl:template match="interface">
|
||||
<xsl:apply-templates select="interface">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="interface[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">i</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- generic constraints -->
|
||||
<xsl:template match="generic-type-constraints">
|
||||
<xsl:apply-templates select="generic-type-constraint">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="generic-type-constraint[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">w</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<!-- delegate -->
|
||||
<xsl:template match="class[@type='delegate'][@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">d</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- enumeration -->
|
||||
<xsl:template match="class[@type='enum'][@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">en</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- method -->
|
||||
<xsl:template match="methods">
|
||||
<xsl:apply-templates select="method">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="method[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">m</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- property -->
|
||||
<xsl:template match="properties">
|
||||
<xsl:apply-templates select="property">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="property[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">p</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- event -->
|
||||
<xsl:template match="events">
|
||||
<xsl:apply-templates select="event">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="event[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">e</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- constructor -->
|
||||
<xsl:template match="constructors">
|
||||
<xsl:apply-templates select="constructor">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="constructor[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">x</xsl:with-param>
|
||||
<xsl:with-param name="image">m</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- field -->
|
||||
<xsl:template match="fields">
|
||||
<xsl:apply-templates select="field">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="field[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">f</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
<!-- accessor -->
|
||||
<xsl:template match="property/methods">
|
||||
<xsl:apply-templates select="method">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="property[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]/methods/method[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">o</xsl:with-param>
|
||||
<xsl:with-param name="image">m</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- attribute -->
|
||||
<xsl:template match="attributes">
|
||||
<xsl:apply-templates select="attribute">
|
||||
<xsl:sort select="@name"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="attribute[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
|
||||
<DIV>
|
||||
<xsl:call-template name="ELEMENT">
|
||||
<xsl:with-param name="class">r</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</DIV>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<!-- support templates -->
|
||||
|
||||
<xsl:template name="ELEMENT">
|
||||
<xsl:param name="class"/>
|
||||
<xsl:param name="image"/>
|
||||
<xsl:attribute name="class">
|
||||
<xsl:value-of select="$class"/>
|
||||
<xsl:if test="./node() and local-name() != 'assembly'">_</xsl:if>
|
||||
</xsl:attribute>
|
||||
<xsl:call-template name="toggle"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@error and @error != 'todo'">
|
||||
<xsl:element name="img">
|
||||
<xsl:attribute name="src">cm/se.gif</xsl:attribute>
|
||||
<xsl:attribute name="class">t</xsl:attribute>
|
||||
<xsl:attribute name="title"><xsl:call-template name="warning-hover" /></xsl:attribute>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:when test="@error = 'todo'">
|
||||
<xsl:element name="img">
|
||||
<xsl:attribute name="src">cm/st.gif</xsl:attribute>
|
||||
<xsl:attribute name="class">t</xsl:attribute>
|
||||
<xsl:if test="@comment">
|
||||
<xsl:attribute name="title"><xsl:value-of select="@comment"/></xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="not(@comment)">
|
||||
<xsl:attribute name="title">No TODO description</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:when test="@presence = 'missing'">
|
||||
<img src="cm/sm.gif" class="t"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@presence = 'extra'">
|
||||
<img src="cm/sx.gif" class="t"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<img src="cm/sc.gif" class="t"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$image">
|
||||
<img src="cm/{$image}.gif" class="t"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<img src="cm/{$class}.gif" class="t"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:call-template name="name"/>
|
||||
<xsl:if test="not(@presence)">
|
||||
<xsl:call-template name="status"/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="status">
|
||||
<xsl:if test="@complete_total and @complete_total != 0">
|
||||
<SPAN class="st">
|
||||
<img src="cm/sc.gif"/>
|
||||
<xsl:text>: </xsl:text>
|
||||
<xsl:value-of select="@complete_total"/>
|
||||
<xsl:text>%</xsl:text>
|
||||
</SPAN>
|
||||
</xsl:if>
|
||||
<xsl:if test="@todo_total">
|
||||
<SPAN class="st">
|
||||
<img src="cm/st.gif"/>: <xsl:value-of select="@todo_total"/>
|
||||
</SPAN>
|
||||
</xsl:if>
|
||||
<xsl:if test="@missing_total">
|
||||
<SPAN class="st">
|
||||
<img src="cm/sm.gif"/>: <xsl:value-of select="@missing_total"/>
|
||||
</SPAN>
|
||||
</xsl:if>
|
||||
<xsl:if test="@extra_total">
|
||||
<SPAN class="st">
|
||||
<img src="cm/sx.gif"/>: <xsl:value-of select="@extra_total"/>
|
||||
</SPAN>
|
||||
</xsl:if>
|
||||
<xsl:if test="@warning_total">
|
||||
<SPAN class="st">
|
||||
<img src="cm/se.gif"/>: <xsl:value-of select="@warning_total"/>
|
||||
</SPAN>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="toggle">
|
||||
<xsl:choose>
|
||||
<xsl:when test="not(@presence) and .//*[@missing_total or @todo_total or @extra_total or @warning_total or @error or @presence]">
|
||||
<xsl:choose>
|
||||
<xsl:when test="local-name() != 'assembly'">
|
||||
<img src="cm/tp.gif" class="t"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<img src="cm/tm.gif" class="t"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<img src="cm/tb.gif"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="name">
|
||||
<xsl:if test="@name">
|
||||
<SPAN class="l"><xsl:value-of select="@name"/></SPAN>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="warning-hover">
|
||||
<xsl:for-each select="warnings/warning">
|
||||
<xsl:text>WARNING: </xsl:text>
|
||||
<xsl:value-of select="@text"/>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -1,25 +0,0 @@
|
||||
API_INFO = $(MONO_PATH) $(RUNTIME) $(topdir)/class/lib/$(PROFILE)/mono-api-info.exe
|
||||
API_DIFF = $(MONO_PATH) $(RUNTIME) $(topdir)/tools/corcompare/mono-api-diff.exe
|
||||
TRANSFORM = $(MONO_PATH) $(RUNTIME) $(topdir)/tools/corcompare/transform.exe
|
||||
|
||||
OBJECTS = $(topdir)/build/corcompare/$(LIBRARY_NAME:.dll=.html)
|
||||
|
||||
corcompare: $(OBJECTS)
|
||||
|
||||
$(OBJECTS): $(patsubst $(topdir)/build/corcompare/%.html,%.src, $(OBJECTS))
|
||||
|
||||
.PRECIOUS: $(topdir)/build/corcompare/%.html
|
||||
$(topdir)/build/corcompare/%.html: %.src
|
||||
$(TRANSFORM) $< $(topdir)/build/corcompare-api.xsl source-name=$(notdir $<) > $@
|
||||
|
||||
.PRECIOUS: %.src
|
||||
%.src: %.xml
|
||||
$(API_DIFF) masterinfos/$(PROFILE)/$(notdir $<) $< > $@ || (rm -rf $@ && exit 1)
|
||||
|
||||
.PRECIOUS: %.xml
|
||||
%.xml: $(topdir)/class/lib/$(PROFILE)/%.dll
|
||||
$(API_INFO) $< > $@ || (rm -f $@ && exit 1)
|
||||
|
||||
CLEAN_FILES += $(topdir)/build/corcompare/$(LIBRARY_NAME:.dll=.html) $(LIBRARY_NAME:.dll=.src) $(LIBRARY_NAME:.dll=.xmlsrc)
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 150 B |
@@ -1,199 +0,0 @@
|
||||
.y IMG
|
||||
{
|
||||
border: 0px;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
margin-right: 4px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.y, .y_,
|
||||
.n, .n_,
|
||||
.c, .c_,
|
||||
.c, .c_,
|
||||
.d, .d_,
|
||||
.en, .en_,
|
||||
.i, .i_,
|
||||
.s, .s_,
|
||||
.e, .e_,
|
||||
.f, .f_,
|
||||
.m, .m_,
|
||||
.o, .o_,
|
||||
.p, .p_,
|
||||
.r, .r_,
|
||||
.x, .x_,
|
||||
.w, .w_
|
||||
{
|
||||
FONT: 10px 'Verdana';
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.y_ .n,
|
||||
.y_ .n_,
|
||||
.n_ .c,
|
||||
.n_ .c_,
|
||||
.n_ .s,
|
||||
.n_ .s_,
|
||||
.n_ .d,
|
||||
.n_ .d_,
|
||||
.n_ .en,
|
||||
.n_ .en_,
|
||||
.n_ .i,
|
||||
.n_ .i_,
|
||||
.c_ .c,
|
||||
.c_ .c_,
|
||||
.c_ .e,
|
||||
.c_ .e_,
|
||||
.c_ .f,
|
||||
.c_ .f_,
|
||||
.c_ .m,
|
||||
.c_ .m_,
|
||||
.c_ .o,
|
||||
.c_ .o_,
|
||||
.c_ .p,
|
||||
.c_ .p_,
|
||||
.c_ .r,
|
||||
.c_ .r_,
|
||||
.c_ .x,
|
||||
.c_ .x_,
|
||||
.c_ .i,
|
||||
.c_ .i_,
|
||||
.c_ .w,
|
||||
.c_ .w_,
|
||||
.d_ .c,
|
||||
.d_ .c_,
|
||||
.d_ .e,
|
||||
.d_ .e_,
|
||||
.d_ .f,
|
||||
.d_ .f_,
|
||||
.d_ .m,
|
||||
.d_ .m_,
|
||||
.d_ .o,
|
||||
.d_ .o_,
|
||||
.d_ .p,
|
||||
.d_ .p_,
|
||||
.d_ .r,
|
||||
.d_ .r_,
|
||||
.d_ .x,
|
||||
.d_ .x_,
|
||||
.d_ .w,
|
||||
.d_ .w_,
|
||||
.en_ .c,
|
||||
.en_ .c_,
|
||||
.en_ .e,
|
||||
.en_ .e_,
|
||||
.en_ .f,
|
||||
.en_ .f_,
|
||||
.en_ .m,
|
||||
.en_ .m_,
|
||||
.en_ .o,
|
||||
.en_ .o_,
|
||||
.en_ .p,
|
||||
.en_ .p_,
|
||||
.en_ .r,
|
||||
.en_ .r_,
|
||||
.en_ .x,
|
||||
.en_ .x_,
|
||||
.en_ .w,
|
||||
.en_ .w_,
|
||||
.i_ .c,
|
||||
.i_ .c_,
|
||||
.i_ .e,
|
||||
.i_ .e_,
|
||||
.i_ .f,
|
||||
.i_ .f_,
|
||||
.i_ .m,
|
||||
.i_ .m_,
|
||||
.i_ .o,
|
||||
.i_ .o_,
|
||||
.i_ .p,
|
||||
.i_ .p_,
|
||||
.i_ .r,
|
||||
.i_ .r_,
|
||||
.i_ .x,
|
||||
.i_ .x_,
|
||||
.i_ .w,
|
||||
.i_ .w_,
|
||||
.i_ .i,
|
||||
.i_ .i_,
|
||||
.s_ .c,
|
||||
.s_ .c_,
|
||||
.s_ .e,
|
||||
.s_ .e_,
|
||||
.s_ .f,
|
||||
.s_ .f_,
|
||||
.s_ .m,
|
||||
.s_ .m_,
|
||||
.s_ .o,
|
||||
.s_ .o_,
|
||||
.s_ .p,
|
||||
.s_ .p_,
|
||||
.s_ .r,
|
||||
.s_ .r_,
|
||||
.s_ .s,
|
||||
.s_ .s_,
|
||||
.s_ .x,
|
||||
.s_ .x_,
|
||||
.s_ .i,
|
||||
.s_ .i_,
|
||||
.s_ .w,
|
||||
.s_ .w_,
|
||||
|
||||
.e_ .r,
|
||||
.e_ .r_,
|
||||
.e_ .o,
|
||||
.e_ .o_,
|
||||
.f_ .r,
|
||||
.f_ .r_,
|
||||
.f_ .o,
|
||||
.f_ .o_,
|
||||
.m_ .r,
|
||||
.m_ .r_,
|
||||
.m_ .o,
|
||||
.m_ .o_,
|
||||
.o_ .r,
|
||||
.o_ .r_,
|
||||
.o_ .o,
|
||||
.o_ .o_,
|
||||
.p_ .r,
|
||||
.p_ .r_,
|
||||
.p_ .o,
|
||||
.p_ .o_,
|
||||
.r_ .r,
|
||||
.r_ .r_,
|
||||
.r_ .o,
|
||||
.r_ .o_,
|
||||
.x_ .r,
|
||||
.x_ .r_,
|
||||
.x_ .o,
|
||||
.x_ .o_
|
||||
.w_ .r,
|
||||
.w_ .r_,
|
||||
.w_ .o,
|
||||
.w_ .o_
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.t
|
||||
{
|
||||
cursor: pointer;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.filter
|
||||
{
|
||||
cursor: pointer;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
||||
.st
|
||||
{
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.l
|
||||
{
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -1,593 +0,0 @@
|
||||
// FIXME:
|
||||
// It still does not update icons previous to a type/member name when
|
||||
// certain icon kinds are unchecked (when an item has "todo" and "missing",
|
||||
// the default display is "missing" and when "missing" is unchecked it
|
||||
// should turn into "todo").
|
||||
|
||||
function toggle (elt)
|
||||
{
|
||||
if (elt == null)
|
||||
return;
|
||||
|
||||
var eltLink = firstElement (elt);
|
||||
if (eltLink != null && eltLink.className == 't') // toggle
|
||||
{
|
||||
var ich = elt.className.indexOf ('_');
|
||||
if (ich < 0)
|
||||
{
|
||||
eltLink.src = 'cm/tp.gif';
|
||||
elt.className += '_';
|
||||
}
|
||||
else
|
||||
{
|
||||
eltLink.src = 'cm/tm.gif';
|
||||
elt.className = elt.className.slice (0, ich);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setView (elt, fView)
|
||||
{
|
||||
var eltLink = firstElement (elt);
|
||||
if (eltLink != null && eltLink.className == 't') // toggle
|
||||
{
|
||||
var ich = elt.className.indexOf ('_');
|
||||
if (ich < 0 && !fView)
|
||||
{
|
||||
eltLink.src = 'cm/tp.gif';
|
||||
elt.className += '_';
|
||||
}
|
||||
else if (ich >= 0 && fView)
|
||||
{
|
||||
eltLink.src = 'cm/tm.gif';
|
||||
elt.className = elt.className.slice (0, ich);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function firstElement (elt)
|
||||
{
|
||||
var c = elt.firstChild;
|
||||
while (c != null) {
|
||||
if (c.nodeType == 1) // Node.ELEMENT_NODE (IE6 does not recognize it)
|
||||
return c;
|
||||
c = c.nextSibling;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function trimSrc (strSrc)
|
||||
{
|
||||
return strSrc.slice (strSrc.lastIndexOf ('/') + 1, strSrc.lastIndexOf ('.'));
|
||||
}
|
||||
|
||||
function getChildrenByTagName (elt, strTag)
|
||||
{
|
||||
strTag = strTag.toLowerCase ();
|
||||
var rgChildren = new Array ();
|
||||
var eltChild = firstElement (elt);
|
||||
while (eltChild)
|
||||
{
|
||||
if (eltChild.tagName && eltChild.tagName.toLowerCase () == strTag)
|
||||
rgChildren.push (eltChild);
|
||||
eltChild = eltChild.nextSibling;
|
||||
}
|
||||
return rgChildren;
|
||||
}
|
||||
|
||||
function viewAll (elt, dictTypes, attrFilters)
|
||||
{
|
||||
var fView = isShown (elt, dictTypes, attrFilters);
|
||||
|
||||
var aCounts = new Array (4);
|
||||
for (i = 0; i < 4; i++)
|
||||
aCounts [i] = 0;
|
||||
var rgElts = getChildrenByTagName (elt, 'DIV');
|
||||
for (iElt in rgElts) {
|
||||
var aChildRet = viewAll (rgElts [iElt], dictTypes, attrFilters);
|
||||
if (aChildRet != null) {
|
||||
fView = true;
|
||||
for (i = 0; i < 4; i++)
|
||||
aCounts [i] += aChildRet [i];
|
||||
}
|
||||
}
|
||||
|
||||
elt.style.display = fView ? '' : 'none';
|
||||
|
||||
if (!fView)
|
||||
return null;
|
||||
|
||||
rgShownDivs = getChildrenByTagName (elt, 'DIV');
|
||||
for (i = 0; i < rgShownDivs.length; i++) {
|
||||
var cDiv = rgShownDivs [i];
|
||||
if (cDiv.style.display == 'none')
|
||||
continue;
|
||||
incrementCount (cDiv, aCounts, dictTypes);
|
||||
}
|
||||
|
||||
// update the numbers
|
||||
rgSpans = getChildrenByTagName (elt, 'SPAN');
|
||||
for (iSpan in rgSpans) {
|
||||
var cSpan = rgSpans [iSpan];
|
||||
var cImage = firstElement (cSpan);
|
||||
if (cImage == null)
|
||||
continue;
|
||||
switch (trimSrc (cImage.src)) {
|
||||
case 'st': cSpan.lastChild.nodeValue = ": " + aCounts [0]; break;
|
||||
case 'sm': cSpan.lastChild.nodeValue = ": " + aCounts [1]; break;
|
||||
case 'sx': cSpan.lastChild.nodeValue = ": " + aCounts [2]; break;
|
||||
case 'se': cSpan.lastChild.nodeValue = ": " + aCounts [3]; break;
|
||||
}
|
||||
}
|
||||
return aCounts;
|
||||
}
|
||||
|
||||
function isShown (elt, dictTypes, attrFilters)
|
||||
{
|
||||
if (!isShownMarkType (elt, dictTypes))
|
||||
return false;
|
||||
|
||||
// Check attributes that are being filtered out.
|
||||
var rgSpans = getChildrenByTagName (elt, 'SPAN');
|
||||
var cSpans = rgSpans.length;
|
||||
for (var iSpan = 0; iSpan < cSpans; iSpan++)
|
||||
{
|
||||
var strSpan = rgSpans [iSpan].firstChild.nodeValue;
|
||||
for (strzzz in attrFilters)
|
||||
if (strSpan == strzzz)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function isShownMarkType (elt, dictTypes)
|
||||
{
|
||||
var rgImages = getChildrenByTagName (elt, 'IMG');
|
||||
var cImages = rgImages.length;
|
||||
for (var iImage = 0; iImage < cImages; iImage++)
|
||||
{
|
||||
var strImage = trimSrc (rgImages [iImage].src);
|
||||
if (dictTypes [strImage])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function incrementCount (cDiv, aCounts, dictTypes)
|
||||
{
|
||||
switch (cDiv.className) {
|
||||
case 'y': case 'y_': // assembly
|
||||
case 'n': case 'n_': // namespace
|
||||
// types
|
||||
case 'c': case 'c_': case 'i': case 'i_':
|
||||
case 'en': case 'en_': case 'd': case 'd_':
|
||||
// members
|
||||
case 'r': case 'r_': case 'x': case 'x_': case 'm': case 'm_':
|
||||
case 'f': case 'f_': case 'e': case 'e_': case 'p': case 'p_':
|
||||
case 'o': case 'o_':
|
||||
var rgImgs = getChildrenByTagName (cDiv, 'IMG');
|
||||
for (iImg = 0; iImg < rgImgs.length; iImg++) {
|
||||
var cImg = rgImgs [iImg];
|
||||
if (cImg.className != 't')
|
||||
continue;
|
||||
var stype = trimSrc (cImg.src);
|
||||
if (!dictTypes [stype])
|
||||
continue;
|
||||
switch (stype) {
|
||||
case "st": aCounts [0]++; break;
|
||||
case "sm": aCounts [1]++; break;
|
||||
case "sx": aCounts [2]++; break;
|
||||
case "se": aCounts [3]++; break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* just for debugging use now.
|
||||
function firstInnerText (elt)
|
||||
{
|
||||
var s = elt.innerText;
|
||||
if (s != null)
|
||||
return s;
|
||||
var n = elt.firstChild;
|
||||
while (n != null) {
|
||||
s = n.nodeValue;
|
||||
if (s != null && s.replace (/^\s+/g, '') != '')
|
||||
return s;
|
||||
s = firstInnerText (n);
|
||||
if (s != null)
|
||||
return s;
|
||||
n = n.nextSibling;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
*/
|
||||
|
||||
function getView (elt)
|
||||
{
|
||||
var eltLink = firstElement (elt);
|
||||
if (eltLink != null && eltLink.className == 't') // toggle
|
||||
{
|
||||
var ich = elt.className.indexOf ('_');
|
||||
if (ich < 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getParentDiv (elt)
|
||||
{
|
||||
if (elt)
|
||||
{
|
||||
do
|
||||
{
|
||||
elt = elt.parentNode;
|
||||
}
|
||||
while (elt && elt.tagName != 'DIV');
|
||||
}
|
||||
|
||||
return elt;
|
||||
}
|
||||
|
||||
function getName (elt)
|
||||
{
|
||||
var rgSpans = getChildrenByTagName (elt, 'SPAN');
|
||||
for (var iSpan = 0; iSpan < rgSpans.length; iSpan ++)
|
||||
{
|
||||
var span = rgSpans [iSpan];
|
||||
if (span.className == 'l') // label
|
||||
{
|
||||
if (span.innerText)
|
||||
return span.innerText;
|
||||
else
|
||||
return span.firstChild.nodeValue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function clickHandler (evt)
|
||||
{
|
||||
var elt;
|
||||
if (document.layers)
|
||||
elt = evt.taget;
|
||||
else if (window.event && window.event.srcElement)
|
||||
{
|
||||
elt = window.event.srcElement;
|
||||
evt = window.event;
|
||||
}
|
||||
else if (evt && evt.stopPropagation)
|
||||
elt = evt.target;
|
||||
|
||||
if (!elt.className && elt.parentNode)
|
||||
elt = elt.parentNode;
|
||||
|
||||
if (elt.className == 'l') // label
|
||||
{
|
||||
var strClass;
|
||||
var strField;
|
||||
var strNamespace;
|
||||
var strAssembly;
|
||||
var strFieldType;
|
||||
|
||||
elt = getParentDiv (elt);
|
||||
var strEltClass = elt.className;
|
||||
if (strEltClass.charAt (strEltClass.length - 1) == '_')
|
||||
strEltClass = strEltClass.slice (0, strEltClass.length - 1);
|
||||
|
||||
if (strEltClass == 'x') // constructor
|
||||
{
|
||||
strField = 'ctor';
|
||||
elt = getParentDiv (elt);
|
||||
}
|
||||
else
|
||||
if (strEltClass == 'm' || // method
|
||||
strEltClass == 'p' || // property
|
||||
strEltClass == 'e' || // event
|
||||
strEltClass == 'f') // field
|
||||
{
|
||||
strFieldType = strEltClass;
|
||||
strField = getName (elt);
|
||||
var match = strField.match ( /[\.A-Z0-9_]*/i );
|
||||
if (match)
|
||||
strField = match [0];
|
||||
elt = getParentDiv (elt);
|
||||
|
||||
}
|
||||
|
||||
var strEltClass = elt.className;
|
||||
if (strEltClass.charAt (strEltClass.length - 1) == '_')
|
||||
strEltClass = strEltClass.slice (0, strEltClass.length - 1);
|
||||
|
||||
if (strEltClass == 'c' || // class
|
||||
strEltClass == 's' || // struct
|
||||
strEltClass == 'i' || // struct
|
||||
strEltClass == 'd' || // delegate
|
||||
strEltClass == 'en') // enum
|
||||
{
|
||||
strClass = getName (elt);
|
||||
if (strEltClass == 'en')
|
||||
strField = null;
|
||||
elt = getParentDiv (elt);
|
||||
}
|
||||
|
||||
var strEltClass = elt.className;
|
||||
if (strEltClass.charAt (strEltClass.length - 1) == '_')
|
||||
strEltClass = strEltClass.slice (0, strEltClass.length - 1);
|
||||
|
||||
if (strEltClass == 'n')
|
||||
{
|
||||
strNamespace = getName (elt);
|
||||
elt = getParentDiv (elt);
|
||||
}
|
||||
|
||||
var strEltClass = elt.className;
|
||||
if (strEltClass.charAt (strEltClass.length - 1) == '_')
|
||||
strEltClass = strEltClass.slice (0, strEltClass.length - 1);
|
||||
|
||||
if (strEltClass == 'y')
|
||||
{
|
||||
strAssembly = getName (elt);
|
||||
}
|
||||
|
||||
if (evt.ctrlKey)
|
||||
{
|
||||
var strRoot = 'http://anonsvn.mono-project.com/viewcvs/trunk/mcs/class/';
|
||||
var strExtra = '';
|
||||
|
||||
if (strAssembly)
|
||||
{
|
||||
if (strAssembly == 'mscorlib')
|
||||
strAssembly = 'corlib';
|
||||
else if (strAssembly == 'System.Xml')
|
||||
strAssembly = 'System.XML';
|
||||
|
||||
strRoot = strRoot + strAssembly + '/';
|
||||
if (strNamespace)
|
||||
{
|
||||
strRoot = strRoot + strNamespace + '/';
|
||||
if (strClass)
|
||||
{
|
||||
strRoot += strClass + '.cs';
|
||||
strExtra += '?view=markup';
|
||||
}
|
||||
}
|
||||
window.open (strRoot + strExtra, 'CVS');
|
||||
}
|
||||
}
|
||||
else if (strNamespace)
|
||||
{
|
||||
if (document.getElementById ('TargetMsdn1').checked)
|
||||
{
|
||||
var re = /\./g ;
|
||||
strNamespace = strNamespace.toLowerCase ().replace (re, '');
|
||||
if (strClass)
|
||||
strNamespace += strClass.toLowerCase () + 'class';
|
||||
if (strField)
|
||||
strNamespace += strField;
|
||||
if (strClass || strField)
|
||||
strNamespace += 'topic';
|
||||
|
||||
window.open ('http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrf' + strNamespace + '.asp', 'MSDN');
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strClass)
|
||||
strNamespace += '.' + strClass;
|
||||
if (strField)
|
||||
strNamespace += '.' + strField;
|
||||
if (document.getElementById ('TargetMonodoc').checked)
|
||||
{
|
||||
var category = null;
|
||||
if (strClass == null)
|
||||
category = "N:";
|
||||
else if (strField == null)
|
||||
category = "T:";
|
||||
else {
|
||||
switch (strFieldType) {
|
||||
case 'f': category = "F:"; break;
|
||||
case 'p': category = "P:"; break;
|
||||
case 'm': category = "M:"; break;
|
||||
case 'e': category = "E:"; break;
|
||||
}
|
||||
}
|
||||
if (category != null)
|
||||
window.open ('http://www.go-mono.com/docs/monodoc.ashx?link=' + category + strNamespace);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.open ('http://msdn2.microsoft.com/library/' + strNamespace + '.aspx', 'MSDN');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (elt.parentNode && elt.parentNode.className == 't') // toggle
|
||||
elt = elt.parentNode;
|
||||
else if (elt.className != 't') // toggle
|
||||
return;
|
||||
|
||||
while (elt != null && elt.tagName != 'DIV')
|
||||
elt = elt.parentNode;
|
||||
|
||||
if (evt.shiftKey)
|
||||
{
|
||||
var rgElts = getChildrenByTagName (elt, 'DIV');
|
||||
var cElts = rgElts.length;
|
||||
if (cElts != 0)
|
||||
{
|
||||
var fView = false;
|
||||
var iElt;
|
||||
for (iElt = 0; iElt < cElts; iElt ++)
|
||||
{
|
||||
if (getView (rgElts [iElt]))
|
||||
{
|
||||
fView = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (iElt = 0; iElt < cElts; iElt ++)
|
||||
{
|
||||
setView (rgElts [iElt], !fView);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (evt.ctrlKey)
|
||||
{
|
||||
setView (elt, true);
|
||||
var eltParent = getParentDiv (elt);
|
||||
while (eltParent)
|
||||
{
|
||||
var rgSiblings = getChildrenByTagName (eltParent, 'DIV');
|
||||
var cSiblings = rgSiblings.length;
|
||||
for (var iSibling = 0; iSibling < cSiblings; iSibling++)
|
||||
{
|
||||
var eltSibling = rgSiblings [iSibling];
|
||||
if (eltSibling != elt)
|
||||
{
|
||||
setView (eltSibling, false);
|
||||
}
|
||||
}
|
||||
elt = eltParent;
|
||||
eltParent = getParentDiv (elt);
|
||||
}
|
||||
}
|
||||
else
|
||||
toggle (elt);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function filterTree ()
|
||||
{
|
||||
var eltMissing = document.getElementById ('missing');
|
||||
var eltTodo = document.getElementById ('todo');
|
||||
var eltExtra = document.getElementById ('extra');
|
||||
var eltErrors = document.getElementById ('errors');
|
||||
var eltComVisible = document.getElementById ('ComVisible');
|
||||
var eltDebuggerDisplay = document.getElementById ('DebuggerDisplay');
|
||||
|
||||
var dictTypes = new Object ();
|
||||
if (eltMissing.checked)
|
||||
dictTypes ['sm'] = true;
|
||||
if (eltTodo.checked)
|
||||
dictTypes ['st'] = true;
|
||||
if (eltErrors.checked)
|
||||
dictTypes ['se'] = true;
|
||||
if (eltExtra.checked)
|
||||
dictTypes ['sx'] = true;
|
||||
// dictTypes ['sc'] = true;
|
||||
|
||||
var attrFilters = new Object ();
|
||||
var rgOptions = getChildrenByTagName (document.getElementById ('FilteredAttributes'), "option");
|
||||
for (i = 0; i < rgOptions.length; i++)
|
||||
attrFilters [rgOptions [i].firstChild.nodeValue.replace (/\s+/g, '')] = true;
|
||||
viewAll (document.getElementById ('ROOT'), dictTypes, attrFilters);
|
||||
}
|
||||
|
||||
function addAndFilter ()
|
||||
{
|
||||
var newInput = document.getElementById ('NewFilterTarget');
|
||||
var newAttr = newInput.value;
|
||||
if (newAttr.length > 0) {
|
||||
var selection = document.getElementById ('FilteredAttributes');
|
||||
var newElem = document.createElement ('option');
|
||||
newElem.appendChild (document.createTextNode (newAttr));
|
||||
selection.appendChild (newElem);
|
||||
newInput.value = '';
|
||||
filterTree ();
|
||||
}
|
||||
}
|
||||
|
||||
function removeAndFilter ()
|
||||
{
|
||||
var selection = document.getElementById ('FilteredAttributes');
|
||||
if (selection.selectedIndex >= 0) {
|
||||
var newInput = document.getElementById ('NewFilterTarget');
|
||||
if (newInput.value.length == 0)
|
||||
newInput.value = selection.options [selection.selectedIndex].firstChild.nodeValue;
|
||||
selection.removeChild (selection.options [selection.selectedIndex]);
|
||||
filterTree ();
|
||||
}
|
||||
}
|
||||
|
||||
function selectMissing ()
|
||||
{
|
||||
toggleFilter ('missing');
|
||||
}
|
||||
|
||||
function selectTodo ()
|
||||
{
|
||||
toggleFilter ('todo');
|
||||
}
|
||||
|
||||
function selectExtra ()
|
||||
{
|
||||
toggleFilter ('extra');
|
||||
}
|
||||
|
||||
function selectErrors ()
|
||||
{
|
||||
toggleFilter ('errors');
|
||||
}
|
||||
|
||||
function toggleAttributeFilter (attrName)
|
||||
{
|
||||
toggleFilter (attrName);
|
||||
}
|
||||
|
||||
function toggleFilter (strFilter)
|
||||
{
|
||||
var eltTodo = document.getElementById ('todo');
|
||||
var eltMissing = document.getElementById ('missing');
|
||||
var eltExtra = document.getElementById ('extra');
|
||||
var eltErrors = document.getElementById ('errors');
|
||||
|
||||
var eltToggle = document.getElementById (strFilter);
|
||||
if (window && window.event && window.event.shiftKey)
|
||||
{
|
||||
eltMissing.checked = eltTodo.checked = eltExtra.checked = eltErrors.checked = false;
|
||||
eltToggle.checked = true;
|
||||
}
|
||||
else
|
||||
if (!eltTodo.checked && !eltMissing.checked && !eltExtra.checked && !eltErrors.checked)
|
||||
{
|
||||
eltMissing.checked = eltTodo.checked = eltExtra.checked = eltErrors.checked = true;
|
||||
eltToggle.checked = false;
|
||||
}
|
||||
filterTree ();
|
||||
}
|
||||
|
||||
function onLoad ()
|
||||
{
|
||||
var eltMissing = document.getElementById ('missing');
|
||||
var eltTodo = document.getElementById ('todo');
|
||||
var eltExtra = document.getElementById ('extra');
|
||||
var eltErrors = document.getElementById ('errors');
|
||||
eltMissing.checked = eltTodo.checked = eltExtra.checked = eltErrors.checked = true;
|
||||
filterTree ();
|
||||
}
|
||||
|
||||
if (document.layers)
|
||||
{
|
||||
document.captureEvents (Event.MOUSEUP);
|
||||
document.onmouseup = clickHandler;
|
||||
}
|
||||
else if (document.attachEvent)
|
||||
{
|
||||
document.attachEvent('onclick', clickHandler);
|
||||
}
|
||||
else if (document.addEventListener)
|
||||
{
|
||||
document.addEventListener('click', clickHandler, false);
|
||||
}
|
||||
else
|
||||
document.onclick = clickHandler;
|
||||
|
||||
|
Before Width: | Height: | Size: 137 B |
|
Before Width: | Height: | Size: 861 B |
|
Before Width: | Height: | Size: 111 B |
|
Before Width: | Height: | Size: 90 B |
|
Before Width: | Height: | Size: 90 B |
|
Before Width: | Height: | Size: 101 B |
|
Before Width: | Height: | Size: 65 B |
|
Before Width: | Height: | Size: 111 B |
|
Before Width: | Height: | Size: 73 B |
|
Before Width: | Height: | Size: 127 B |
|
Before Width: | Height: | Size: 70 B |
|
Before Width: | Height: | Size: 73 B |
|
Before Width: | Height: | Size: 76 B |
|
Before Width: | Height: | Size: 101 B |
|
Before Width: | Height: | Size: 73 B |
|
Before Width: | Height: | Size: 49 B |
|
Before Width: | Height: | Size: 64 B |
|
Before Width: | Height: | Size: 67 B |
|
Before Width: | Height: | Size: 240 B |
|
Before Width: | Height: | Size: 92 B |
|
Before Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 49 B |
@@ -0,0 +1,4 @@
|
||||
*.makefrag
|
||||
*.response
|
||||
*.stamp
|
||||
*.was_signed
|
||||
@@ -2,13 +2,9 @@
|
||||
#
|
||||
# The rules for building a program.
|
||||
|
||||
base_prog = $(notdir $(PROGRAM))
|
||||
prog_dir := $(filter-out . ./, $(dir $(PROGRAM)))
|
||||
base_prog = $(shell basename $(PROGRAM))
|
||||
sourcefile = $(base_prog).sources
|
||||
base_prog_config := $(wildcard $(base_prog).config.$(PROFILE))
|
||||
ifndef base_prog_config
|
||||
base_prog_config := $(wildcard $(base_prog).config)
|
||||
endif
|
||||
ifdef base_prog_config
|
||||
PROGRAM_config := $(PROGRAM).config
|
||||
endif
|
||||
@@ -22,12 +18,6 @@ response = $(depsdir)/$(base_prog).response
|
||||
executable_CLEAN_FILES += $(response)
|
||||
endif
|
||||
|
||||
ifdef KEEP_OUTPUT_FILE_COPY
|
||||
COPY_CMD = cp
|
||||
else
|
||||
COPY_CMD = mv
|
||||
endif
|
||||
|
||||
makefrag = $(depsdir)/$(PROFILE)_$(base_prog).makefrag
|
||||
pdb = $(patsubst %.exe,%.pdb,$(PROGRAM))
|
||||
mdb = $(patsubst %.exe,%.mdb,$(PROGRAM))
|
||||
@@ -87,17 +77,17 @@ ifndef PROGRAM_COMPILE
|
||||
PROGRAM_COMPILE = $(CSCOMPILE)
|
||||
endif
|
||||
|
||||
$(PROGRAM): $(BUILT_SOURCES) $(EXTRA_SOURCES) $(response) $(prog_dir:=/.stamp)
|
||||
$(PROGRAM): $(BUILT_SOURCES) $(EXTRA_SOURCES) $(response)
|
||||
$(PROGRAM_COMPILE) -target:exe -out:$(base_prog) $(BUILT_SOURCES) $(EXTRA_SOURCES) @$(response)
|
||||
ifneq ($(base_prog),$(PROGRAM))
|
||||
$(COPY_CMD) $(base_prog) $(PROGRAM)
|
||||
test ! -f $(base_prog).mdb || $(COPY_CMD) $(base_prog).mdb $(PROGRAM).mdb
|
||||
mv $(base_prog) $(PROGRAM)
|
||||
test ! -f $(base_prog).mdb || mv $(base_prog).mdb $(PROGRAM).mdb
|
||||
endif
|
||||
|
||||
ifdef PROGRAM_config
|
||||
ifneq ($(base_prog_config),$(PROGRAM_config))
|
||||
executable_CLEAN_FILES += $(PROGRAM_config)
|
||||
$(PROGRAM_config): $(base_prog_config) $(dir $(PROGRAM_config))/.stamp
|
||||
$(PROGRAM_config): $(base_prog_config)
|
||||
cp $(base_prog_config) $(PROGRAM_config)
|
||||
endif
|
||||
endif
|
||||
@@ -115,8 +105,4 @@ endif
|
||||
-include $(makefrag)
|
||||
|
||||
all-local: $(makefrag)
|
||||
|
||||
ifneq ($(response),$(sourcefile))
|
||||
$(response): $(topdir)/build/executable.make $(depsdir)/.stamp
|
||||
endif
|
||||
$(makefrag): $(topdir)/build/executable.make $(depsdir)/.stamp
|
||||
$(makefrag): $(topdir)/build/executable.make
|
||||
@@ -14,9 +14,8 @@ sourcefile = $(LIBRARY).sources
|
||||
PROFILE_sources = $(PROFILE)_$(LIBRARY).sources
|
||||
ifeq ($(wildcard $(PROFILE_sources)), $(PROFILE_sources))
|
||||
PROFILE_excludes = $(wildcard $(PROFILE)_$(LIBRARY).exclude.sources)
|
||||
COMMON_sourcefile := $(sourcefile)
|
||||
sourcefile = $(depsdir)/$(PROFILE)_$(LIBRARY).sources
|
||||
$(sourcefile): $(PROFILE_sources) $(PROFILE_excludes) $(COMMON_sourcefile)
|
||||
$(sourcefile): $(PROFILE_sources) $(PROFILE_excludes)
|
||||
@echo Creating the per profile list $@ ...
|
||||
$(topdir)/tools/gensources.sh $(PROFILE_sources) $(PROFILE_excludes) > $@
|
||||
endif
|
||||
@@ -38,22 +37,14 @@ ifndef LIBRARY_NAME
|
||||
LIBRARY_NAME = $(LIBRARY)
|
||||
endif
|
||||
|
||||
ifdef LIBRARY_COMPAT
|
||||
lib_dir = compat
|
||||
else
|
||||
lib_dir = lib
|
||||
endif
|
||||
|
||||
makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
|
||||
the_libdir = $(topdir)/class/$(lib_dir)/$(PROFILE)/
|
||||
the_lib = $(the_libdir)$(LIBRARY_NAME)
|
||||
the_lib = $(topdir)/class/lib/$(PROFILE)/$(LIBRARY_NAME)
|
||||
the_pdb = $(the_lib:.dll=.pdb)
|
||||
the_mdb = $(the_lib).mdb
|
||||
library_CLEAN_FILES += $(makefrag) $(the_lib) $(the_pdb) $(the_mdb)
|
||||
|
||||
ifdef LIBRARY_NEEDS_POSTPROCESSING
|
||||
build_libdir = fixup/$(PROFILE)/
|
||||
build_lib = $(build_libdir)$(LIBRARY_NAME)
|
||||
build_lib = fixup/$(PROFILE)/$(LIBRARY_NAME)
|
||||
library_CLEAN_FILES += $(build_lib) $(build_lib:.dll=.pdb)
|
||||
else
|
||||
build_lib = $(the_lib)
|
||||
@@ -65,20 +56,33 @@ test_nunit_dep = $(test_nunit_lib:%=$(topdir)/class/lib/$(PROFILE)/%)
|
||||
test_nunit_ref = $(test_nunit_dep:%=-r:%)
|
||||
library_CLEAN_FILES += TestResult*.xml
|
||||
|
||||
ifndef test_against
|
||||
test_against = $(the_lib)
|
||||
test_dep = $(the_lib)
|
||||
endif
|
||||
|
||||
ifndef test_lib
|
||||
test_lib = $(LIBRARY:.dll=_test_$(PROFILE).dll)
|
||||
test_sourcefile = $(LIBRARY:.dll=_test.dll.sources)
|
||||
else
|
||||
test_sourcefile = $(test_lib).sources
|
||||
endif
|
||||
test_pdb = $(test_lib:.dll=.pdb)
|
||||
test_response = $(depsdir)/$(test_lib).response
|
||||
test_makefrag = $(depsdir)/$(test_lib).makefrag
|
||||
test_flags = -r:$(the_lib) $(test_nunit_ref) $(TEST_MCS_FLAGS)
|
||||
test_flags = -r:$(test_against) $(test_nunit_ref) $(TEST_MCS_FLAGS)
|
||||
library_CLEAN_FILES += $(LIBRARY:.dll=_test*.dll) $(LIBRARY:.dll=_test*.pdb) $(test_response) $(test_makefrag)
|
||||
|
||||
ifndef btest_lib
|
||||
btest_lib = $(LIBRARY:.dll=_btest_$(PROFILE).dll)
|
||||
btest_sourcefile = $(LIBRARY:.dll=_btest.dll.sources)
|
||||
else
|
||||
btest_sourcefile = $(btest_lib).sources
|
||||
endif
|
||||
btest_pdb = $(btest_lib:.dll=.pdb)
|
||||
btest_response = $(depsdir)/$(btest_lib).response
|
||||
btest_makefrag = $(depsdir)/$(btest_lib).makefrag
|
||||
btest_flags = -r:$(the_lib) $(test_nunit_ref) $(TEST_MBAS_FLAGS)
|
||||
btest_flags = -r:$(test_against) $(test_nunit_ref) $(TEST_MBAS_FLAGS)
|
||||
library_CLEAN_FILES += $(LIBRARY:.dll=_btest*.dll) $(LIBRARY:.dll=_btest*.pdb) $(btest_response) $(btest_makefrag)
|
||||
|
||||
ifndef HAVE_CS_TESTS
|
||||
@@ -90,6 +94,13 @@ endif
|
||||
|
||||
endif
|
||||
|
||||
ifdef NO_INSTALL
|
||||
GACUTIL = :
|
||||
else
|
||||
gacutil = $(topdir)/class/lib/net_1_1_bootstrap/gacutil.exe
|
||||
GACUTIL = MONO_PATH="$(topdir)/class/lib/net_1_1_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(gacutil)
|
||||
endif
|
||||
|
||||
ifdef NO_SIGN_ASSEMBLY
|
||||
SN = :
|
||||
else
|
||||
@@ -143,23 +154,11 @@ ifndef RUNTIME_HAS_CONSISTENT_GACDIR
|
||||
gacdir_flag = /gacdir $(GACDIR)
|
||||
endif
|
||||
|
||||
ifndef LIBRARY_PACKAGE
|
||||
ifdef LIBRARY_COMPAT
|
||||
LIBRARY_PACKAGE = compat-$(FRAMEWORK_VERSION)
|
||||
else
|
||||
LIBRARY_PACKAGE = $(FRAMEWORK_VERSION)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (none, $(LIBRARY_PACKAGE))
|
||||
package_flag = /package $(LIBRARY_PACKAGE)
|
||||
endif
|
||||
|
||||
install-local: $(gacutil)
|
||||
$(GACUTIL) /i $(the_lib) /f $(gacdir_flag) /root $(GACROOT) $(package_flag)
|
||||
$(GACUTIL) /i $(the_lib) /f $(gacdir_flag) /root $(GACROOT) /package $(FRAMEWORK_VERSION)
|
||||
|
||||
uninstall-local: $(gacutil)
|
||||
-$(GACUTIL) /u $(LIBRARY_NAME:.dll=) $(gacdir_flag) /root $(GACROOT) $(package_flag)
|
||||
-$(GACUTIL) /u $(LIBRARY_NAME:.dll=) $(gacdir_flag) /root $(GACROOT) /package $(FRAMEWORK_VERSION)
|
||||
|
||||
endif
|
||||
endif
|
||||
@@ -190,39 +189,25 @@ test_assemblies += $(btest_lib)
|
||||
endif
|
||||
|
||||
ifdef test_assemblies
|
||||
check: run-test
|
||||
test-local: $(test_assemblies)
|
||||
run-test-local: run-test-lib
|
||||
run-test-ondotnet-local: run-test-ondotnet-lib
|
||||
|
||||
TEST_HARNESS_EXCLUDES = /exclude:NotWorking,ValueAdd,CAS,InetAccess
|
||||
TEST_HARNESS_EXCLUDES_ONDOTNET = /exclude:NotDotNet,CAS
|
||||
|
||||
ifdef TEST_HARNESS_VERBOSE
|
||||
TEST_HARNESS_OUTPUT = /labels
|
||||
TEST_HARNESS_OUTPUT_ONDOTNET = /labels
|
||||
TEST_HARNESS_POSTPROC = :
|
||||
TEST_HARNESS_POSTPROC_ONDOTNET = :
|
||||
else
|
||||
TEST_HARNESS_OUTPUT = /output:TestResult-$(PROFILE).log
|
||||
TEST_HARNESS_OUTPUT_ONDOTNET = /output:TestResult-ondotnet-$(PROFILE).log
|
||||
TEST_HARNESS_POSTPROC = (echo ''; cat TestResult-$(PROFILE).log) | sed '1,/^Tests run: /d'
|
||||
TEST_HARNESS_POSTPROC_ONDOTNET = (echo ''; cat TestResult-ondotnet-$(PROFILE).log) | sed '1,/^Tests run: /d'
|
||||
endif
|
||||
|
||||
## FIXME: i18n problem in the 'sed' command below
|
||||
run-test-lib: test-local
|
||||
ok=:; \
|
||||
MONO_REGISTRY_PATH="$(HOME)/.mono/registry" $(TEST_RUNTIME) $(RUNTIME_FLAGS) $(TEST_HARNESS) $(TEST_HARNESS_FLAGS) $(LOCAL_TEST_HARNESS_FLAGS) $(TEST_HARNESS_EXCLUDES) $(TEST_HARNESS_OUTPUT) /xml:TestResult-$(PROFILE).xml $(test_assemblies) || ok=false; \
|
||||
$(TEST_HARNESS_POSTPROC) ; $$ok
|
||||
$(TEST_RUNTIME) $(TEST_HARNESS) $(TEST_HARNESS_FLAGS) $(LOCAL_TEST_HARNESS_FLAGS) /output:TestResult-$(PROFILE).log /exclude:NotWorking,ValueAdd,CAS,InetAccess /xml:TestResult-$(PROFILE).xml $(test_assemblies) || ok=false; \
|
||||
sed '1,/^Tests run: /d' TestResult-$(PROFILE).log; \
|
||||
$$ok
|
||||
|
||||
run-test-ondotnet-lib: test-local
|
||||
ok=:; \
|
||||
$(TEST_HARNESS) $(TEST_HARNESS_FLAGS) $(LOCAL_TEST_HARNESS_ONDOTNET_FLAGS) $(TEST_HARNESS_EXCLUDES_ONDOTNET) $(TEST_HARNESS_OUTPUT_ONDOTNET) /xml:TestResult-ondotnet-$(PROFILE).xml $(test_assemblies) || ok=false; \
|
||||
$(TEST_HARNESS_POSTPROC_ONDOTNET) ; $$ok
|
||||
$(TEST_HARNESS) $(TEST_HARNESS_FLAGS) $(LOCAL_TEST_HARNESS_ONDOTNET_FLAGS) /exclude=NotDotNet,CAS /output:TestResult-ondotnet-$(PROFILE).log /xml:TestResult-ondotnet-$(PROFILE).xml $(test_assemblies) || ok=false; \
|
||||
sed '1,/^Tests run: /d' TestResult-ondotnet-$(PROFILE).log; \
|
||||
$$ok
|
||||
endif
|
||||
|
||||
DISTFILES = $(wildcard *$(LIBRARY)*.sources) $(EXTRA_DISTFILES)
|
||||
DISTFILES = $(sourcefile) $(EXTRA_DISTFILES)
|
||||
|
||||
TEST_FILES =
|
||||
|
||||
@@ -235,10 +220,9 @@ TEST_FILES += `sed -e '/^$$/d' -e 's,^,Test/,' $(btest_sourcefile)`
|
||||
DISTFILES += $(btest_sourcefile)
|
||||
endif
|
||||
|
||||
# make dist will collect files in .sources files from all profiles
|
||||
dist-local: dist-default
|
||||
subs=' ' ; \
|
||||
for f in `$(topdir)/tools/removecomments.sh $(wildcard *$(LIBRARY).sources)` $(TEST_FILES) ; do \
|
||||
for f in `cat $(sourcefile)` $(TEST_FILES) ; do \
|
||||
case $$f in \
|
||||
../*) : ;; \
|
||||
*) dest=`dirname $$f` ; \
|
||||
@@ -291,9 +275,7 @@ endif
|
||||
|
||||
# The library
|
||||
|
||||
$(the_lib): $(the_libdir)/.stamp
|
||||
|
||||
$(build_lib): $(response) $(sn) $(BUILT_SOURCES) $(build_libdir:=/.stamp)
|
||||
$(build_lib): $(response) $(sn) $(BUILT_SOURCES)
|
||||
ifdef LIBRARY_USE_INTERMEDIATE_FILE
|
||||
$(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$(LIBRARY_NAME) $(BUILT_SOURCES_cmdline) @$(response)
|
||||
$(SN) $(SNFLAGS) $(LIBRARY_NAME) $(LIBRARY_SNK)
|
||||
@@ -322,7 +304,7 @@ endif
|
||||
|
||||
ifdef HAVE_CS_TESTS
|
||||
|
||||
$(test_lib): $(the_lib) $(test_response) $(test_nunit_dep)
|
||||
$(test_lib): $(test_dep) $(test_response) $(test_nunit_dep)
|
||||
$(TEST_COMPILE) -target:library -out:$@ $(test_flags) @$(test_response)
|
||||
|
||||
$(test_response): $(test_sourcefile)
|
||||
@@ -339,7 +321,7 @@ endif
|
||||
|
||||
ifdef HAVE_VB_TESTS
|
||||
|
||||
$(btest_lib): $(the_lib) $(btest_response) $(test_nunit_dep)
|
||||
$(btest_lib): $(test_dep) $(btest_response) $(test_nunit_dep)
|
||||
$(BTEST_COMPILE) -target:library -out:$@ $(btest_flags) @$(btest_response)
|
||||
|
||||
$(btest_response): $(btest_sourcefile)
|
||||
@@ -354,11 +336,5 @@ $(btest_makefrag): $(btest_response)
|
||||
|
||||
endif
|
||||
|
||||
## Include corcompare stuff
|
||||
include $(topdir)/build/corcompare.make
|
||||
|
||||
all-local: $(makefrag) $(test_makefrag) $(btest_makefrag)
|
||||
ifneq ($(response),$(sourcefile))
|
||||
$(response): $(topdir)/build/library.make $(depsdir)/.stamp
|
||||
endif
|
||||
$(makefrag) $(test_response) $(test_makefrag) $(btest_response) $(btest_makefrag): $(topdir)/build/library.make $(depsdir)/.stamp
|
||||
$(makefrag) $(test_makefrag) $(btest_makefrag): $(topdir)/build/library.make
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
|
||||
PLATFORM_DEBUG_FLAGS = -debug
|
||||
PLATFORM_MCS_FLAGS = -optimize
|
||||
PLATFORM_MCS_FLAGS =
|
||||
PLATFORM_RUNTIME = $(RUNTIME)
|
||||
PLATFORM_CORLIB = mscorlib.dll
|
||||
|
||||
|
||||