mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-18 03:51:19 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64f045b986 | ||
|
|
d5631ee2a6 | ||
|
|
444eaef7de | ||
|
|
4ac3e74b2c | ||
|
|
ad659f3a5c | ||
|
|
6621fbeb7b | ||
|
|
43907341f0 | ||
|
|
9274d95d5f | ||
|
|
d1c74ad254 | ||
|
|
245249106c | ||
|
|
6a07d34bc8 | ||
|
|
f78f915a4e | ||
|
|
04a2d46835 | ||
|
|
0c26f66c0e | ||
|
|
e8c36a30f7 | ||
|
|
c405df6c89 | ||
|
|
d952408b45 | ||
|
|
d65f4ad268 | ||
|
|
9d4b9c5ed8 | ||
|
|
7059614e3a | ||
|
|
29ca124da5 | ||
|
|
a5a6e65de0 | ||
|
|
3d4ad69752 | ||
|
|
f6ad1aa045 | ||
|
|
0bd026b0b5 | ||
|
|
8d0d7aee01 | ||
|
|
cbb12bed7b | ||
|
|
79fd57e6f1 | ||
|
|
653d9b8951 | ||
|
|
5f3abc4fe4 | ||
|
|
209ba3996a | ||
|
|
06f7dd3fc4 | ||
|
|
fb489fae22 | ||
|
|
7231a2e606 | ||
|
|
bfdc16656d | ||
|
|
a9d4d0bfa3 | ||
|
|
b21b6ce374 | ||
|
|
9dbbf9af39 | ||
|
|
ca57ca7215 | ||
|
|
60c5cea58f | ||
|
|
964beac183 | ||
|
|
c8c0d4c686 | ||
|
|
3d01665a68 | ||
|
|
fd0576d5a1 | ||
|
|
928e3753ab | ||
|
|
01c127b14e | ||
|
|
bf9c5ac50f | ||
|
|
5e6bc44634 | ||
|
|
0ea0bb6823 | ||
|
|
6ff4f0d165 | ||
|
|
0d6b705d6f | ||
|
|
c7443a190a | ||
|
|
029ff9b9f4 | ||
|
|
ab2dd91b35 | ||
|
|
7e771a3cdf | ||
|
|
260054f385 | ||
|
|
c019dacc11 | ||
|
|
434ae3d9c2 | ||
|
|
4beb7ab705 | ||
|
|
810fad1ed9 | ||
|
|
8199cba724 | ||
|
|
7253c44b34 | ||
|
|
61ac96f496 | ||
|
|
84570ffb93 | ||
|
|
1d44ba22a5 | ||
|
|
057a9ed68d | ||
|
|
52f09e41d0 | ||
|
|
bcdd136b2d | ||
|
|
b30f057280 | ||
|
|
27a9c4a5d0 | ||
|
|
5e0ee04d51 | ||
|
|
851ab61b7a | ||
|
|
a4083fe77d | ||
|
|
e660bf8aca | ||
|
|
2b3d9079e2 | ||
|
|
a4d064ed4e | ||
|
|
53d9fc14ad | ||
|
|
ed14894a33 | ||
|
|
14fdf85cbd | ||
|
|
f388ef6c2c | ||
|
|
04961930be | ||
|
|
e684bbfe57 | ||
|
|
248aeba2c7 | ||
|
|
78604dca27 | ||
|
|
6bae1bb5c3 | ||
|
|
f7c769111a | ||
|
|
2a332a7951 | ||
|
|
c330e594e4 | ||
|
|
0f1268df35 | ||
|
|
49310de53e | ||
|
|
a19d806bb1 | ||
|
|
ddbc3e479b | ||
|
|
2aa5af6c2f | ||
|
|
1fe06b40e8 | ||
|
|
b78eb3caad | ||
|
|
c84551fd73 | ||
|
|
25b0805e20 | ||
|
|
a3a68d4083 | ||
|
|
776a60617a | ||
|
|
095322953b | ||
|
|
3a5f48bced | ||
|
|
b598aee4dc | ||
|
|
98ff1ec075 | ||
|
|
c5f5d263d7 | ||
|
|
4d06d66e19 | ||
|
|
487e9a1f0a | ||
|
|
c9316a0bcc | ||
|
|
3a40dfbb24 | ||
|
|
2ff17cce11 | ||
|
|
ff738c616f | ||
|
|
6f76bef3f9 | ||
|
|
d17d1101a4 | ||
|
|
7954648dbe | ||
|
|
96bc53e927 | ||
|
|
d5c12cf568 | ||
|
|
92dd07a485 | ||
|
|
0d7102d039 | ||
|
|
fa30544d3c | ||
|
|
b44bd65f75 | ||
|
|
f7d12c2b05 | ||
|
|
7288206bdf | ||
|
|
bb874a687b | ||
|
|
5df3e05e0e | ||
|
|
6fdae5d654 | ||
|
|
bdabf74a88 | ||
|
|
fd42bcd36c | ||
|
|
b26531ebba | ||
|
|
2a3bedbf8c | ||
|
|
e61d54040f | ||
|
|
870f4582ab | ||
|
|
06c93cd2cf | ||
|
|
5da7907603 | ||
|
|
68f5d0926d | ||
|
|
c9f58f07fe | ||
|
|
dc671b1b4a | ||
|
|
44f95d3311 | ||
|
|
e10b6ddad7 | ||
|
|
65292a69c8 | ||
|
|
7890fd60c5 | ||
|
|
d8096023f2 | ||
|
|
79d5f2e009 | ||
|
|
7628c67ef8 | ||
|
|
b6b047eed9 | ||
|
|
4cb8b2e6f3 | ||
|
|
237cee6dc6 | ||
|
|
e1d8ee37b1 | ||
|
|
84bf2fd468 | ||
|
|
d945da7eeb | ||
|
|
85b7cae565 | ||
|
|
26ee955aca | ||
|
|
b509f42a7e | ||
|
|
717982c7cf | ||
|
|
931e044108 | ||
|
|
e171f51df0 | ||
|
|
d326d51789 | ||
|
|
ffd50c266e | ||
|
|
63c0a5d6d2 | ||
|
|
06205b5084 | ||
|
|
1bbc6a8a1b | ||
|
|
d106cf2a5a | ||
|
|
ded054284e | ||
|
|
4ed8473ce9 | ||
|
|
e30361a696 | ||
|
|
6b51a1df2f | ||
|
|
3aed7ab3c9 | ||
|
|
9d534c9413 | ||
|
|
adb66a513a | ||
|
|
c11559c7ef | ||
|
|
32e235d68b | ||
|
|
ba625becd6 | ||
|
|
5588a6f078 | ||
|
|
5d600522ed | ||
|
|
2427b2b861 | ||
|
|
11aeecfa3a | ||
|
|
e27b81a652 | ||
|
|
8f3f18568c | ||
|
|
f886d89ef7 | ||
|
|
44ea00024a | ||
|
|
4aabcf3455 | ||
|
|
a22f24834e | ||
|
|
cea5d2223b | ||
|
|
bc1373c0d8 | ||
|
|
c8d96f618a | ||
|
|
c530931921 | ||
|
|
e373b1cf49 | ||
|
|
ba5de9d036 | ||
|
|
a51e35bbec | ||
|
|
681aff17d2 | ||
|
|
d1703c40ef | ||
|
|
c53bce8e0a | ||
|
|
3aad88e828 | ||
|
|
2037a51576 | ||
|
|
8d8cae9016 | ||
|
|
4106e07cca | ||
|
|
963f28f38b | ||
|
|
bd045fc008 | ||
|
|
cff2890d8d | ||
|
|
101eaf3215 | ||
|
|
5cfa597a30 | ||
|
|
84be0b20e5 | ||
|
|
e7de26c774 | ||
|
|
8a31a4b263 | ||
|
|
06e2e82bb0 | ||
|
|
47429fb521 | ||
|
|
42459678e9 | ||
|
|
44dc98ddd1 | ||
|
|
32832e39bb | ||
|
|
de60018067 | ||
|
|
06e3b0379b | ||
|
|
2626e53a2e | ||
|
|
5015ec260b | ||
|
|
91f700f9d4 | ||
|
|
63f589c152 | ||
|
|
c223d5999b | ||
|
|
6d8bafaa07 | ||
|
|
5625f3afe8 | ||
|
|
59959cefb2 | ||
|
|
217ec2ce11 | ||
|
|
4f47316df0 | ||
|
|
589a83dfa4 | ||
|
|
b54ac46230 | ||
|
|
7c22cb0135 | ||
|
|
8e890a3bf8 | ||
|
|
b80ffc9882 | ||
|
|
61c8b99b3f | ||
|
|
4a60b3f3fa | ||
|
|
d2bb6fe8e1 | ||
|
|
9f384277cd | ||
|
|
10b7c361bb | ||
|
|
1e535e61d3 | ||
|
|
fb42e1e12b | ||
|
|
7358969934 | ||
|
|
89c7bb82d4 | ||
|
|
c28b4ea9d7 | ||
|
|
b80d1ca6eb | ||
|
|
5f80fd9448 | ||
|
|
e53a4c3776 | ||
|
|
69a95ff53d | ||
|
|
5025f28490 | ||
|
|
e3c340f1c1 | ||
|
|
2fdbdc2bc0 | ||
|
|
2875496241 | ||
|
|
f98dc57542 | ||
|
|
905e43efe2 | ||
|
|
b6a25dfdd2 | ||
|
|
16c125bc9b | ||
|
|
33d466d421 | ||
|
|
4b0101dd80 | ||
|
|
84e9b39b17 | ||
|
|
8a5647b1d6 | ||
|
|
733d3f45d1 | ||
|
|
29ffd5258c | ||
|
|
e845f96a79 | ||
|
|
51e0ca445a | ||
|
|
f95ed5726f | ||
|
|
03af9e4c5d | ||
|
|
921a0951d8 | ||
|
|
c6ee6980ce | ||
|
|
429c26b022 | ||
|
|
5b4ab167be | ||
|
|
58e8a395c4 | ||
|
|
0e93173683 | ||
|
|
20f6a72044 | ||
|
|
552a1f5c7e | ||
|
|
d3b4997ff1 | ||
|
|
722e143cc0 | ||
|
|
0875d61ca2 | ||
|
|
0d8e8f7df9 | ||
|
|
135e5eb0df | ||
|
|
b2ba1f46f7 | ||
|
|
15e954d508 | ||
|
|
86bc7170e5 | ||
|
|
3779a70dcc | ||
|
|
160cf6a24e | ||
|
|
1cd68dd08c | ||
|
|
0ee4f2dbd1 | ||
|
|
44d00f87d5 | ||
|
|
b214e1e693 | ||
|
|
cda5880b42 | ||
|
|
e97de6b450 | ||
|
|
d8034534d0 | ||
|
|
b49c845d35 | ||
|
|
b6a60964d8 | ||
|
|
3b5c655c05 | ||
|
|
3b6f5c3308 | ||
|
|
579a0ca72b | ||
|
|
577dfd5d78 | ||
|
|
57dae7a311 | ||
|
|
a21c08a924 | ||
|
|
e763cd5010 | ||
|
|
964d3433d8 | ||
|
|
89f92560a1 | ||
|
|
b1752875e8 | ||
|
|
2a308efd0a | ||
|
|
bff2b8d6c4 | ||
|
|
9f2d34d689 | ||
|
|
37edaa18f7 | ||
|
|
77d12442c4 | ||
|
|
3ad4bb8e3d | ||
|
|
67c7faf279 | ||
|
|
7757931e8e | ||
|
|
5a55034e93 | ||
|
|
bab18ab6d2 | ||
|
|
4c601b8522 | ||
|
|
36e827b0be | ||
|
|
e137468dc6 | ||
|
|
aa92238b98 | ||
|
|
093a537205 | ||
|
|
fe1653eae0 | ||
|
|
58f029f2d1 | ||
|
|
f16036819a | ||
|
|
784d21f5fd | ||
|
|
c101a18be3 | ||
|
|
f038e86294 | ||
|
|
ef47ac3d22 | ||
|
|
95617646ba | ||
|
|
652ff412d2 | ||
|
|
8ca77a27fa | ||
|
|
3b8eeb54d3 | ||
|
|
6e23108f39 | ||
|
|
052fd53f21 | ||
|
|
164ba0d204 | ||
|
|
8853b1acb3 | ||
|
|
d2bc3285b1 | ||
|
|
019cca88ce | ||
|
|
b2ac405dbb | ||
|
|
24ef405181 | ||
|
|
e2aecacc87 | ||
|
|
d6038fc397 | ||
|
|
0d7b33cbc9 | ||
|
|
f40fc6829d | ||
|
|
eb12be05d9 | ||
|
|
f68a0cd137 | ||
|
|
815ec755b4 | ||
|
|
f751095363 | ||
|
|
30f3260cc1 | ||
|
|
50a2d76b29 | ||
|
|
006d9f248d | ||
|
|
f16e13ead3 | ||
|
|
904b7563aa | ||
|
|
05378ccef9 | ||
|
|
911929eed1 | ||
|
|
ae557e488d | ||
|
|
d88e223dd4 | ||
|
|
1867fd1486 | ||
|
|
1f42b9026c | ||
|
|
4b649e0805 | ||
|
|
2ce8ebda5f | ||
|
|
3b7c1f8741 | ||
|
|
faa1dd5646 | ||
|
|
21b9ee9deb | ||
|
|
db99cebd57 | ||
|
|
a8c3708337 | ||
|
|
b40cb0cc14 | ||
|
|
5640b0a889 | ||
|
|
693cbe7207 | ||
|
|
93d6cc3bf9 | ||
|
|
0474947f86 | ||
|
|
0013378bfa | ||
|
|
0e5aff05c4 | ||
|
|
38a79cb7b8 | ||
|
|
fc767570a8 |
No files matched your search
@@ -6,7 +6,6 @@ configure.in crlf=input
|
||||
*.h crlf
|
||||
*.cs crlf
|
||||
*.sh crlf
|
||||
*.il crlf
|
||||
|
||||
.gitattributes crlf
|
||||
ChangeLog crlf
|
||||
@@ -17,7 +16,6 @@ ChangeLog crlf
|
||||
*.bat -crlf
|
||||
*.sln -crlf
|
||||
*.*proj* -crlf
|
||||
*.xml -crlf
|
||||
|
||||
# CRLF Handling
|
||||
# -------------
|
||||
|
||||
@@ -35,4 +35,3 @@
|
||||
/ltsugar.m4
|
||||
/lt~obsolete.m4
|
||||
/ltversion.m4
|
||||
*~
|
||||
+3093
File diff suppressed because it is too large.
Load diff
+1
-7
@@ -11,13 +11,7 @@ The Boehm licensing information is in the libgc directory
|
||||
The SGen Garbage Collector is under the terms of the MIT X11
|
||||
license
|
||||
|
||||
The class libraries under mono/mcs are unless otherwise stated
|
||||
under the MIT X11 license.
|
||||
|
||||
Open source Microsoft code is licensed under the original terms
|
||||
which is either MS-PL for older components, or dual licensed
|
||||
MS-PL/Apache2 licensed.
|
||||
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
|
||||
@@ -98,13 +98,6 @@ For comments, corrections and updates, please contact [email protected]
|
||||
ICSharpCode.SharpZipLib, GPL with exceptions.
|
||||
See: mcs/class/ICSharpCode.SharpZipLib/README
|
||||
|
||||
** mcs/class/System.Core/System/TimeZoneInfo.Android.cs
|
||||
|
||||
This is a port of Apache 2.0-licensed Android code, and thus is
|
||||
licensed under the Apache 2.0 license:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
|
||||
** mcs/tools
|
||||
|
||||
|
||||
+12
-30
@@ -1,34 +1,25 @@
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
ACLOCAL_AMFLAGS = -I .
|
||||
|
||||
MOONLIGHT_SUBDIRS = $(libgc_dir) eglib/src mono
|
||||
MOONLIGHT_SUBDIRS = $(libgc_dir) eglib mono $(ikvm_native_dir) data
|
||||
|
||||
if CROSS_COMPILING
|
||||
SUBDIRS = po $(libgc_dir) eglib mono $(ikvm_native_dir) data runtime scripts man samples msvc $(docs_dir)
|
||||
SUBDIRS = po $(libgc_dir) eglib mono $(ikvm_native_dir) data runtime scripts man samples web msvc $(docs_dir)
|
||||
# Keep in sync with SUBDIRS
|
||||
## 'tools' is not normally built
|
||||
DIST_SUBDIRS = po libgc eglib mono ikvm-native data runtime scripts man samples tools msvc docs
|
||||
DIST_SUBDIRS = po libgc eglib mono ikvm-native data runtime scripts man samples web tools msvc docs
|
||||
else
|
||||
if ONLY_MOONLIGHT
|
||||
SUBDIRS = $(MOONLIGHT_SUBDIRS) runtime
|
||||
else
|
||||
SUBDIRS = po $(libgc_dir) eglib mono $(ikvm_native_dir) support data runtime scripts man samples msvc $(docs_dir)
|
||||
SUBDIRS = po $(libgc_dir) eglib mono $(ikvm_native_dir) support data runtime scripts man samples web msvc $(docs_dir)
|
||||
# Keep in sync with SUBDIRS
|
||||
## 'tools' is not normally built
|
||||
DIST_SUBDIRS = po libgc eglib mono ikvm-native support data runtime scripts man samples tools msvc docs
|
||||
DIST_SUBDIRS = po libgc eglib mono ikvm-native support data runtime scripts man samples web tools msvc docs
|
||||
endif
|
||||
endif
|
||||
|
||||
EXTRA_DIST= \
|
||||
LICENSE \
|
||||
autogen.sh \
|
||||
build-mingw32.sh \
|
||||
mkinstalldirs \
|
||||
mono-uninstalled.pc.in \
|
||||
nls.m4 \
|
||||
po.m4 \
|
||||
progtest.m4 \
|
||||
winconfig.h
|
||||
EXTRA_DIST= nls.m4 po.m4 progtest.m4 mono-uninstalled.pc.in build-mingw32.sh LICENSE mkinstalldirs autogen.sh
|
||||
|
||||
DISTCHECK_CONFIGURE_FLAGS = EXTERNAL_MCS=false EXTERNAL_RUNTIME=false
|
||||
|
||||
@@ -82,26 +73,17 @@ bootstrap-world: compiler-tests
|
||||
if MOONLIGHT
|
||||
moon-do-build: config.h
|
||||
@list='$(MOONLIGHT_SUBDIRS)'; for subdir in $$list; do \
|
||||
case "x$$subdir" in \
|
||||
xmono ) target="moon-do-build";; \
|
||||
* ) target="all";; \
|
||||
esac; \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target); \
|
||||
echo "Making all in $$subdir"; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) all); \
|
||||
done;
|
||||
(cd runtime && $(MAKE) $(AM_MAKEFLAGS) moon-do-build)
|
||||
cd $(mcs_topdir) && NO_DIR_CHECK=1 $(MAKE) PROFILE=moonlight_raw all
|
||||
|
||||
moon-do-clean:
|
||||
@list='$(MOONLIGHT_SUBDIRS)'; for subdir in $$list; do \
|
||||
case "x$$subdir" in \
|
||||
xmono ) target="moon-do-clean";; \
|
||||
* ) target="clean";; \
|
||||
esac; \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target); \
|
||||
echo "Making clean in $$subdir"; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) clean); \
|
||||
done;
|
||||
(cd runtime && $(MAKE) $(AM_MAKEFLAGS) moon-do-clean)
|
||||
|
||||
cd $(mcs_topdir) && NO_DIR_CHECK=1 $(MAKE) PROFILE=moonlight_raw clean
|
||||
endif
|
||||
|
||||
win32getdeps:
|
||||
|
||||
@@ -11,6 +11,16 @@ This is Mono.
|
||||
a. Build Requirements
|
||||
---------------------
|
||||
|
||||
To build Mono, you will need the following components:
|
||||
|
||||
* pkg-config
|
||||
|
||||
Available from: http://www.freedesktop.org/Software/pkgconfig
|
||||
|
||||
* glib 2.4
|
||||
|
||||
Available from: http://www.gtk.org/
|
||||
|
||||
On Itanium, you must obtain libunwind:
|
||||
|
||||
http://www.hpl.hp.com/research/linux/libunwind/download.php4
|
||||
@@ -25,15 +35,7 @@ This is Mono.
|
||||
* libgdiplus
|
||||
|
||||
If you want to get support for System.Drawing, you will need to get
|
||||
Libgdiplus. This library in turn requires glib and pkg-config:
|
||||
|
||||
* pkg-config
|
||||
|
||||
Available from: http://www.freedesktop.org/Software/pkgconfig
|
||||
|
||||
* glib 2.4
|
||||
|
||||
Available from: http://www.gtk.org/
|
||||
Libgdiplus.
|
||||
|
||||
* libzlib
|
||||
|
||||
@@ -72,18 +74,15 @@ This is Mono.
|
||||
make V=1
|
||||
|
||||
|
||||
c. Building the software from GIT
|
||||
|
||||
c. Building the software from SVN
|
||||
---------------------------------
|
||||
|
||||
If you are building the software from GIT, make sure that you
|
||||
If you are building the software from SVN, make sure that you
|
||||
have up-to-date mcs and mono sources:
|
||||
|
||||
If you are an anonymous user:
|
||||
git clone git://github.com/mono/mono.git
|
||||
|
||||
If you are a Mono contributors with read/write privileges:
|
||||
git clone [email protected]:mono/mono.git
|
||||
|
||||
svn co svn+ssh://[email protected]/source/trunk/mono
|
||||
svn co svn+ssh://[email protected]/source/trunk/mcs
|
||||
|
||||
Then, go into the mono directory, and configure:
|
||||
|
||||
@@ -130,16 +129,16 @@ This is Mono.
|
||||
distribution, which contains just enough to run the 'mcs'
|
||||
compiler. You do this with:
|
||||
|
||||
# Run the following line after ./autogen.sh
|
||||
make get-monolite-latest
|
||||
|
||||
This will download and automatically gunzip and untar the
|
||||
tarball, and place the files appropriately so that you can then
|
||||
just run:
|
||||
|
||||
make EXTERNAL_MCS=${PWD}/mcs/class/lib/monolite/gmcs.exe
|
||||
make
|
||||
|
||||
And that will use the files downloaded by 'make get-monolite-latest.
|
||||
To ensure that you're using the 'monolite' distribution, you can
|
||||
also try passing EXTERNAL_MCS=false on the make command-line.
|
||||
|
||||
Testing and Installation
|
||||
------------------------
|
||||
@@ -165,13 +164,10 @@ This is Mono.
|
||||
|
||||
make install
|
||||
|
||||
You can verify your installation by using the mono-test-install
|
||||
script, it can diagnose some common problems with Mono's install.
|
||||
|
||||
Failure to follow these steps may result in a broken installation.
|
||||
|
||||
d. Configuration Options
|
||||
------------------------
|
||||
d. Common Configuration Options
|
||||
-------------------------------
|
||||
|
||||
The following are the configuration options that someone
|
||||
building Mono might want to use:
|
||||
@@ -305,21 +301,6 @@ This is Mono.
|
||||
System.dll, System.Code.dll and System.Xml.Core.dll) and turn
|
||||
on the LINQ extensions for the compiler.
|
||||
|
||||
--with-moon-gc=boehm,sgen
|
||||
|
||||
Select the GC to use for Moonlight.
|
||||
|
||||
boehm:
|
||||
Selects the Boehm Garbage Collector, with the same flags
|
||||
as the regular Mono build. This is the default.
|
||||
|
||||
sgen:
|
||||
Selects the new SGen Garbage Collector, which provides
|
||||
Generational GC support, using the same flags as the
|
||||
mono-sgen build.
|
||||
|
||||
This defaults to `boehm'.
|
||||
|
||||
--with-libgdiplus=installed,sibling,<path>
|
||||
|
||||
This is used to configure where should Mono look for
|
||||
@@ -586,3 +567,4 @@ This is Mono.
|
||||
same prefix than this module gets.
|
||||
|
||||
|
||||
|
||||
+41
-104
@@ -2,7 +2,7 @@
|
||||
CURDIR="`pwd`"
|
||||
MINGW=i386-mingw32msvc
|
||||
CROSS_DIR=/opt/cross/$MINGW
|
||||
EXTRA_CROSS_DIR=
|
||||
COPY_DLLS="libgio*.dll libglib*.dll libgmodule*.dll libgthread*.dll libgobject*.dll"
|
||||
INSTALL_DESTDIR="$CURDIR/mono-win32"
|
||||
PROFILES="default net_2_0 net_3_5 net_4_0 moonlight"
|
||||
TEMPORARY_PKG_CONFIG_DIR=/tmp/$RANDOM-pkg-config-$RANDOM
|
||||
@@ -17,119 +17,62 @@ function cleanup ()
|
||||
fi
|
||||
}
|
||||
|
||||
function check_pkg_config_dir ()
|
||||
{
|
||||
local DIR="$1"
|
||||
local DIR_PREFIX="$2"
|
||||
|
||||
if [ ! -d "$DIR" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
install -d -m 755 "$TEMPORARY_PKG_CONFIG_DIR"
|
||||
for pc in "$DIR"/*.pc; do
|
||||
if [ -f $pc ]; then
|
||||
pcname="`basename $pc`"
|
||||
sed -e "s;^prefix=.*;prefix=$DIR_PREFIX;g" < $pc > "$TEMPORARY_PKG_CONFIG_DIR"/$pcname
|
||||
fi;
|
||||
done
|
||||
|
||||
if [ -z "$CROSS_PKG_CONFIG_DIR" ]; then
|
||||
CROSS_PKG_CONFIG_DIR="$TEMPORARY_PKG_CONFIG_DIR"
|
||||
fi
|
||||
}
|
||||
|
||||
function show_build_info ()
|
||||
{
|
||||
cat <<EOF
|
||||
Installation prefix: $MONO_PREFIX
|
||||
CPPFLAGS: ${CPPFLAGS:=not set}
|
||||
LDFLAGS: ${LDFLAGS:=not set}
|
||||
MONO_PATH: ${MONO_PATH:=not set}
|
||||
EOF
|
||||
}
|
||||
|
||||
function setup ()
|
||||
{
|
||||
local pcname
|
||||
|
||||
CROSS_BIN_DIR="$CROSS_DIR/bin"
|
||||
CROSS_DLL_DIR="$CROSS_DIR/bin"
|
||||
CROSS_PKG_CONFIG_DIR=$CROSS_DIR/lib/pkgconfig
|
||||
PATH=$CROSS_BIN_DIR:$PATH
|
||||
|
||||
MONO_VERSION=`grep AM_INIT_AUTOMAKE configure.in | cut -d ',' -f 2|tr -d '\)'`
|
||||
|
||||
if [ -d ./.git ]; then
|
||||
MONO_GIT_COMMIT="`git log -1 --format=format:%t`"
|
||||
MONO_GIT_BRANCH="`git branch|grep '\*'|cut -d ' ' -f 2`"
|
||||
MONO_RELEASE="$MONO_VERSION-$MONO_GIT_BRANCH-$MONO_GIT_COMMIT"
|
||||
export PATH
|
||||
if [ -d ./.git/svn ]; then
|
||||
SVN_INFO='git svn info'
|
||||
elif [ -d ./.svn ]; then
|
||||
SVN_INFO='svn info'
|
||||
else
|
||||
MONO_RELEASE="$MONO_VERSION"
|
||||
SVN_INFO=""
|
||||
fi
|
||||
|
||||
MONO_PREFIX="$MONO_PREFIX/mono-$MONO_RELEASE"
|
||||
if [ -n "$SVN_INFO" ]; then
|
||||
MONO_SVN_REVISION=`$SVN_INFO | grep Revision | sed 's/.*: //'`
|
||||
MONO_BRANCH=`$SVN_INFO | grep URL | sed -e 's;.*source/;;g' -e 's;/mono;;g'`
|
||||
else
|
||||
MONO_SVN_REVISION="rUNKNOWN"
|
||||
MONO_BRANCH="tarball"
|
||||
fi
|
||||
|
||||
MONO_VERSION=`grep AM_INIT_AUTOMAKE configure.in | cut -d ',' -f 2|tr -d '\)'`
|
||||
MONO_RELEASE="$MONO_VERSION-$MONO_BRANCH-r$MONO_SVN_REVISION"
|
||||
MONO_PREFIX="/mono-$MONO_RELEASE"
|
||||
|
||||
NOCONFIGURE=yes
|
||||
export NOCONFIGURE
|
||||
|
||||
check_pkg_config_dir "$CROSS_DIR/lib/pkgconfig" "$CROSS_DIR"
|
||||
|
||||
if [ -n "$EXTRA_CROSS_DIR" -a -d "$EXTRA_CROSS_DIR" ]; then
|
||||
if [ -d "$EXTRA_CROSS_DIR/bin" ]; then
|
||||
PATH="$EXTRA_CROSS_DIR/bin":$PATH
|
||||
fi
|
||||
|
||||
check_pkg_config_dir "$EXTRA_CROSS_DIR/lib/pkgconfig" "$EXTRA_CROSS_DIR"
|
||||
|
||||
if [ -d "$EXTRA_CROSS_DIR/include" ]; then
|
||||
if [ -z "$CPPFLAGS" ]; then
|
||||
CPPFLAGS="-I \"$EXTRA_CROSS_DIR/include\""
|
||||
else
|
||||
CPPFLAGS="-I \"$EXTRA_CROSS_DIR/include\" $CFLAGS"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -d "$EXTRA_CROSS_DIR/lib" ]; then
|
||||
if [ -z "$LDFLAGS" ]; then
|
||||
LDFLAGS="-I \"$EXTRA_CROSS_DIR/lib\""
|
||||
else
|
||||
LDFLAGS="-I \"$EXTRA_CROSS_DIR/lib\" $LDFLAGS"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -d "$EXTRA_CROSS_DIR/share/aclocal" ]; then
|
||||
if [ -z "$MONO_PATH" ]; then
|
||||
MONO_PATH="\"$EXTRA_CROSS_DIR\""
|
||||
else
|
||||
MONO_PATH="\"$EXTRA_CROSS_DIR\":$MONO_PATH"
|
||||
fi
|
||||
fi
|
||||
if [ -d "$CROSS_PKG_CONFIG_DIR" ]; then
|
||||
install -d -m 755 "$TEMPORARY_PKG_CONFIG_DIR"
|
||||
for pc in "$CROSS_PKG_CONFIG_DIR"/*.pc; do
|
||||
pcname="`basename $pc`"
|
||||
sed -e "s;^prefix=.*;prefix=$CROSS_DIR;g" < $pc > "$TEMPORARY_PKG_CONFIG_DIR"/$pcname
|
||||
done
|
||||
CROSS_PKG_CONFIG_DIR="$TEMPORARY_PKG_CONFIG_DIR"
|
||||
fi
|
||||
|
||||
export PATH MONO_PATH CPPFLAGS
|
||||
show_build_info
|
||||
|
||||
echo Mono Win32 installation prefix: $MONO_PREFIX
|
||||
}
|
||||
|
||||
function build ()
|
||||
{
|
||||
if [ -f ./Makefile ]; then
|
||||
make distclean
|
||||
fi
|
||||
|
||||
if [ -d ./autom4te.cache ]; then
|
||||
rm -rf ./autom4te.cache
|
||||
fi
|
||||
|
||||
if [ -f ./config.status ]; then
|
||||
for f in `find -name config.status -type f`; do
|
||||
rm $f
|
||||
done
|
||||
fi
|
||||
|
||||
./autogen.sh
|
||||
|
||||
BUILD="`./config.guess`"
|
||||
|
||||
if [ -f ./Makefile ]; then
|
||||
make distclean
|
||||
rm -rf autom4te.cache
|
||||
fi
|
||||
|
||||
if [ ! -d "$CURDIR/build-cross-windows" ]; then
|
||||
mkdir "$CURDIR/build-cross-windows"
|
||||
fi
|
||||
@@ -162,28 +105,27 @@ function doinstall ()
|
||||
cd "$CURDIR/build-cross-windows"
|
||||
make DESTDIR="$INSTALL_DESTDIR" USE_BATCH_FILES=yes install
|
||||
|
||||
if test -d $CURDIR/mcs; then
|
||||
mcsdir=$CURDIR/mcs
|
||||
else
|
||||
mcsdir=$CURDIR/../mcs
|
||||
fi
|
||||
cd "$CURDIR/../mcs/mcs"
|
||||
|
||||
cd "$mcsdir/mcs"
|
||||
for p in $PROFILES; do
|
||||
make DESTDIR="$INSTALL_DESTDIR" PROFILE=$p install || echo "mcs profile $p installation failed"
|
||||
done
|
||||
|
||||
cd "$mcsdir/class"
|
||||
cd "$CURDIR/../mcs/class"
|
||||
for p in $PROFILES; do
|
||||
make DESTDIR="$INSTALL_DESTDIR" PROFILE=$p install || echo "class library profile $p installation failed"
|
||||
done
|
||||
|
||||
cd "$mcsdir/tools"
|
||||
cd "$CURDIR/../mcs/tools"
|
||||
for p in $PROFILES; do
|
||||
make DESTDIR="$INSTALL_DESTDIR" PROFILE=$p install || echo "tools profile $p installation failed"
|
||||
done
|
||||
|
||||
cd "$CURDIR/mono-win32"
|
||||
for dll in $COPY_DLLS; do
|
||||
cp -ap "$CROSS_DLL_DIR"/$dll "$INSTALL_DESTDIR/$MONO_PREFIX/bin"
|
||||
done
|
||||
|
||||
rm -f "$CURDIR/mono-win32-$MONO_RELEASE".zip
|
||||
zip -9r "$CURDIR/mono-win32-$MONO_RELEASE".zip .
|
||||
|
||||
@@ -197,9 +139,7 @@ Usage: build-mingw32.sh [OPTIONS]
|
||||
where OPTIONS are:
|
||||
|
||||
-d DIR Sets the location of directory where MINGW is installed [$CROSS_DIR]
|
||||
-e DIR Sets the location of directory where additional cross develoment packages are installed [${EXTRA_CROSS_DIR:=none}]
|
||||
-m MINGW Sets the MINGW target name to be passed to configure [$MINGW]
|
||||
-p PREFIX Prefix at which Mono is to be installed. Build will append the 'mono-X.Y' string to that path
|
||||
EOF
|
||||
|
||||
exit 1
|
||||
@@ -209,12 +149,10 @@ trap cleanup 0
|
||||
|
||||
pushd . > /dev/null
|
||||
|
||||
while getopts "d:m:e:p:" opt; do
|
||||
while getopts "d:m:h" opt; do
|
||||
case "$opt" in
|
||||
d) CROSS_DIR="$OPTARG" ;;
|
||||
m) MINGW="$OPTARG" ;;
|
||||
e) EXTRA_CROSS_DIR="$OPTARG" ;;
|
||||
p) MONO_PREFIX="$OPTARG" ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
done
|
||||
@@ -222,6 +160,5 @@ done
|
||||
setup
|
||||
build
|
||||
doinstall
|
||||
show_build_info
|
||||
|
||||
popd > /dev/null
|
||||
+48
-117
@@ -6,7 +6,7 @@ AC_CANONICAL_SYSTEM
|
||||
m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
|
||||
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AM_INIT_AUTOMAKE(mono,2.10)
|
||||
AM_INIT_AUTOMAKE(mono,2.8.2)
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
API_VER=2.0
|
||||
@@ -86,7 +86,7 @@ case "$host" in
|
||||
host_win32=yes
|
||||
if test "x$cross_compiling" = "xno"; then
|
||||
target_win32=yes
|
||||
if test "x$host" == "x$build"; then
|
||||
if test "x$host" == "x$target"; then
|
||||
AC_DEFINE(TARGET_WIN32,1,[Target OS is Win32])
|
||||
fi
|
||||
CC="gcc -mno-cygwin -g"
|
||||
@@ -94,7 +94,6 @@ case "$host" in
|
||||
# So libgc configure gets -mno-cygwin
|
||||
export CC
|
||||
export CXX
|
||||
CFLAGS_FOR_EGLIB="$CFLAGS_FOR_EGLIB -mno-cygwin"
|
||||
else
|
||||
target_win32=yes
|
||||
AC_DEFINE(TARGET_WIN32,1,[Target OS is Win32/MinGW])
|
||||
@@ -181,6 +180,7 @@ case "$host" in
|
||||
libmono_cflags="-D_REENTRANT"
|
||||
libdl="-ldl"
|
||||
libgc_threads=pthreads
|
||||
AOT_SUPPORTED="yes"
|
||||
use_sigposix=yes
|
||||
;;
|
||||
*-*-nacl*)
|
||||
@@ -192,11 +192,11 @@ case "$host" in
|
||||
libmono_cflags="-D_REENTRANT"
|
||||
libdl=
|
||||
libgc_threads=pthreads
|
||||
AOT_SUPPORTED="yes"
|
||||
gc_default=boehm
|
||||
use_sigposix=yes
|
||||
ikvm_native=no
|
||||
AC_DEFINE(DISABLE_SOCKETS,1,[Disable sockets support])
|
||||
AC_DEFINE(DISABLE_ATTACH, 1, [Disable agent attach support])
|
||||
;;
|
||||
*-*-hpux*)
|
||||
host_win32=no
|
||||
@@ -379,15 +379,15 @@ AC_CHECK_HEADERS(sys/user.h, [], [],
|
||||
AC_CHECK_HEADER(zlib.h, [have_zlib=yes], [have_zlib=no])
|
||||
if test x$have_zlib = xyes; then
|
||||
AC_TRY_COMPILE([#include <zlib.h>], [
|
||||
void main () {
|
||||
#if defined(ZLIB_VERNUM) && (ZLIB_VERNUM >= 0x1230)
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#error No good zlib found
|
||||
#endif
|
||||
],[
|
||||
AC_MSG_RESULT(Using system zlib)
|
||||
zlib_msg="system zlib"
|
||||
AC_DEFINE(HAVE_SYS_ZLIB,1,[Have system zlib])
|
||||
],[
|
||||
AC_MSG_RESULT(Using embedded zlib)
|
||||
have_zlib=no
|
||||
@@ -591,6 +591,27 @@ AC_SUBST(GMODULE_LIBS)
|
||||
AC_SUBST(BUILD_GLIB_CFLAGS)
|
||||
AC_SUBST(BUILD_GLIB_LIBS)
|
||||
|
||||
if test x$cross_compiling$host_win32 = xnoyes; then
|
||||
AC_MSG_CHECKING(for cygwin glib2-dev package)
|
||||
if [ cygcheck --f /usr/lib/libglib-2.0.dll.a | grep -q glib2-devel ]; then
|
||||
AC_MSG_RESULT(found)
|
||||
AC_MSG_ERROR([Mono cannot be built with the cygwin glib2-devel package installed, because that package doesn't work with -mno-cygwin. Please uninstall it then re-run configure.])
|
||||
else
|
||||
AC_MSG_RESULT(not found, ok)
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(for broken gwin32.h)
|
||||
glib_include=`$PKG_CONFIG --cflags-only-I glib-2.0 | sed -e 's/ -I.*//g' | sed -e 's/-I//g'`
|
||||
if test -f $glib_include/glib/gwin32.h; then
|
||||
if [ grep ftruncate $glib_include/glib/gwin32.h | grep -q define ]; then
|
||||
AC_MSG_RESULT(failed)
|
||||
hashmark='#'
|
||||
AC_MSG_ERROR([Your version of gwin32.h is broken and will cause compilation errors when building mono. Please fix it by deleting the line: '$hashmark define ftruncate...' from '$glib_include/glib/gwin32.h' then re-run configure.])
|
||||
fi
|
||||
fi
|
||||
AC_MSG_RESULT(ok)
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(gc, [ --with-gc=boehm,included,none Controls the Boehm GC config, default=included],[gc=$with_gc],[gc=$gc_default])
|
||||
|
||||
# Enable support for fast thread-local storage
|
||||
@@ -602,27 +623,17 @@ AC_ARG_WITH(tls, [ --with-tls=__thread,pthread select Thread Local Storage i
|
||||
AC_ARG_WITH(sigaltstack, [ --with-sigaltstack=yes,no enable/disable support for sigaltstack (defaults to yes)],[],[with_sigaltstack=yes])
|
||||
|
||||
AC_ARG_WITH(static_mono, [ --with-static_mono=yes,no link mono statically to libmono (faster) (defaults to yes)],[],[with_static_mono=yes])
|
||||
AC_ARG_WITH(shared_mono, [ --with-shared_mono=yes,no build a shared libmono library (defaults to yes)],[],[with_shared_mono=yes])
|
||||
|
||||
if test "x$enable_static" = "xno"; then
|
||||
with_static_mono=no
|
||||
fi
|
||||
|
||||
if test "x$enable_shared" = "xno"; then
|
||||
with_shared_mono=no
|
||||
fi
|
||||
|
||||
case $host in
|
||||
*nacl* ) with_shared_mono=yes;;
|
||||
esac
|
||||
|
||||
if test "x$host_win32" = "xyes"; then
|
||||
# Boehm GC requires the runtime to be in its own dll
|
||||
with_static_mono=no
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(STATIC_MONO, test x$with_static_mono != xno)
|
||||
AM_CONDITIONAL(SHARED_MONO, test x$with_shared_mono != xno)
|
||||
AC_ARG_ENABLE(mcs-build, [ --disable-mcs-build disable the build of the mcs directory], try_mcs_build=$enableval, enable_mcs_build=yes)
|
||||
|
||||
AC_ARG_WITH(xen_opt, [ --with-xen_opt=yes,no Enable Xen-specific behaviour (defaults to yes)],[],[with_xen_opt=yes])
|
||||
@@ -651,19 +662,23 @@ if test x$enable_small_config = xyes; then
|
||||
CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -DSMALL_CONFIG"
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(system-aot, [ --enable-system-aot Enable the Ahead-Of-Time compilation of system assemblies during the build (on by default on some platforms)], enable_system_aot=$enableval, enable_system_aot=default)
|
||||
if test x$AOT_SUPPORTED != xyes; then
|
||||
AOT_SUPPORTED=no
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(system-aot, [ --enable-system-aot Enable the Ahead-Of-Time compilation of system assemblies during the build (on by default on some platforms)], enable_system_aot=$enableval, enable_system_aot=$AOT_SUPPORTED)
|
||||
|
||||
DISABLED_FEATURES=none
|
||||
|
||||
AC_ARG_ENABLE(minimal, [ --enable-minimal=LIST drop support for LIST subsystems.
|
||||
LIST is a comma-separated list from: aot, profiler, decimal, pinvoke, debug,
|
||||
reflection_emit, reflection_emit_save, large_code, logging, com, ssa, generics, attach, jit, simd, soft_debug, normalization, assembly_remapping.],
|
||||
reflection_emit, reflection_emit_save, large_code, logging, com, ssa, generics, attach, jit, simd, soft_debug, normalization.],
|
||||
[
|
||||
for feature in `echo "$enable_minimal" | sed -e "s/,/ /g"`; do
|
||||
eval "mono_feature_disable_$feature='yes'"
|
||||
done
|
||||
DISABLED_FEATURES=$enable_minimal
|
||||
disabled="Disabled: $enable_minimal"
|
||||
disabled="Disabled: $enable_minimal"
|
||||
],[])
|
||||
|
||||
AC_DEFINE_UNQUOTED(DISABLED_FEATURES, "$DISABLED_FEATURES", [String of disabled features])
|
||||
@@ -777,11 +792,6 @@ if test "x$mono_feature_disable_normalization" = "xyes"; then
|
||||
AC_MSG_NOTICE([Disabled String normalization support.])
|
||||
fi
|
||||
|
||||
if test "x$mono_feature_disable_assembly_remapping" = "xyes"; then
|
||||
AC_DEFINE(DISABLE_ASSEMBLY_REMAPPING, 1, [Disable assembly remapping.])
|
||||
AC_MSG_NOTICE([Disabled Assembly remapping.])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(for visibility __attribute__)
|
||||
AC_TRY_COMPILE([], [
|
||||
void __attribute__ ((visibility ("hidden"))) doit (void) {}
|
||||
@@ -851,14 +861,6 @@ case "x$gc" in
|
||||
if test "x$found_gc_enable" = "xyes"; then
|
||||
BOEHM_DEFINES="-DHAVE_GC_ENABLE $BOEHM_DEFINES"
|
||||
fi
|
||||
|
||||
# check whether we need to explicitly allow
|
||||
# thread registering
|
||||
AC_CHECK_LIB(gc, GC_allow_register_threads, found_allow_register_threads="yes",,$libdl)
|
||||
if test "x$found_allow_register_threads" = "xyes"; then
|
||||
AC_DEFINE(HAVE_GC_ALLOW_REGISTER_THREADS, 1, [GC requires thread registration])
|
||||
fi
|
||||
|
||||
;;
|
||||
|
||||
xincluded)
|
||||
@@ -997,11 +999,9 @@ if test x$target_win32 = xno; then
|
||||
AC_CHECK_FUNCS(getpriority)
|
||||
AC_CHECK_FUNCS(setpriority)
|
||||
AC_CHECK_FUNCS(dl_iterate_phdr)
|
||||
AC_CHECK_FUNCS(dladdr)
|
||||
AC_CHECK_FUNCS(sysconf)
|
||||
|
||||
AC_CHECK_FUNCS(sched_setaffinity)
|
||||
AC_CHECK_FUNCS(sched_getcpu)
|
||||
|
||||
dnl ****************************************************************
|
||||
dnl *** Check for sched_setaffinity from glibc versions before ***
|
||||
@@ -1754,11 +1754,6 @@ if test x$target_win32 = xno; then
|
||||
dnl * on xp+
|
||||
AC_DEFINE(HAVE_GETPROCESSID, 1, [Define if GetProcessId is available])
|
||||
else
|
||||
dnl *********************************
|
||||
dnl *** Checks for Windows compilation ***
|
||||
dnl *********************************
|
||||
AC_CHECK_HEADERS(winternl.h)
|
||||
|
||||
jdk_headers_found=no
|
||||
AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32", AC_ERROR(bad mingw install?))
|
||||
AC_CHECK_LIB(psapi, main, LIBS="$LIBS -lpsapi", AC_ERROR(bad mingw install?))
|
||||
@@ -1842,7 +1837,6 @@ fi
|
||||
|
||||
AC_CHECK_FUNCS(round)
|
||||
AC_CHECK_FUNCS(rint)
|
||||
AC_CHECK_FUNCS(execvp)
|
||||
|
||||
dnl ****************************
|
||||
dnl *** Look for /dev/random ***
|
||||
@@ -1855,7 +1849,7 @@ try_dev_random=$enableval, try_dev_random=yes)
|
||||
|
||||
AC_MSG_RESULT($try_dev_random)
|
||||
|
||||
case "{$build}" in
|
||||
case "{$target}" in
|
||||
*-openbsd*)
|
||||
NAME_DEV_RANDOM="/dev/srandom"
|
||||
;;
|
||||
@@ -1998,7 +1992,6 @@ dnl *** NaCl ***
|
||||
dnl **************
|
||||
|
||||
AC_ARG_ENABLE(nacl_codegen, [ --enable-nacl-codegen Enable Native Client code generation], enable_nacl_codegen=$enableval, enable_nacl_codegen=no)
|
||||
AC_ARG_ENABLE(nacl_gc, [ --enable-nacl-gc Enable Native Client garbage collection], enable_nacl_gc=$enableval, enable_nacl_gc=no)
|
||||
|
||||
AM_CONDITIONAL(NACL_CODEGEN, test x$enable_nacl_codegen != xno)
|
||||
if test "x$enable_nacl_codegen" = "xyes"; then
|
||||
@@ -2007,10 +2000,6 @@ if test "x$enable_nacl_codegen" = "xyes"; then
|
||||
AC_DEFINE(TARGET_NACL, 1, [...])
|
||||
else
|
||||
MONO_NACL_ALIGN_MASK_OFF=0
|
||||
CPPFLAGS="$CPPFLAGS -D__default_codegen__"
|
||||
fi
|
||||
if test "x$enable_nacl_gc" = "xyes"; then
|
||||
CPPFLAGS="$CPPFLAGS -finstrument-for-thread-suspension -D__native_client_gc__"
|
||||
fi
|
||||
AC_SUBST(MONO_NACL_ALIGN_MASK_OFF)
|
||||
|
||||
@@ -2018,7 +2007,7 @@ dnl **************
|
||||
dnl *** LLVM ***
|
||||
dnl **************
|
||||
|
||||
AC_ARG_ENABLE(llvm,[ --enable-llvm Enable the LLVM back-end], enable_llvm=$enableval, enable_llvm=no)
|
||||
AC_ARG_ENABLE(llvm,[ --enable-llvm Enable the experimental LLVM back-end], enable_llvm=$enableval, enable_llvm=no)
|
||||
AC_ARG_ENABLE(loadedllvm,[ --enable-loadedllvm Load the LLVM back-end dynamically], enable_llvm=$enableval && enable_loadedllvm=$enableval, enable_loadedllvm=no)
|
||||
|
||||
if test "x$enable_llvm" = "xyes"; then
|
||||
@@ -2140,11 +2129,7 @@ case "$host" in
|
||||
haiku*)
|
||||
LIBC=libroot.so
|
||||
;;
|
||||
linux*)
|
||||
sgen_supported=true
|
||||
AOT_SUPPORTED="yes"
|
||||
;;
|
||||
darwin*|openbsd*|freebsd*)
|
||||
linux*|darwin*|openbsd*)
|
||||
sgen_supported=true
|
||||
;;
|
||||
esac
|
||||
@@ -2155,20 +2140,10 @@ case "$host" in
|
||||
JIT_SUPPORTED=yes
|
||||
jit_wanted=true
|
||||
case $host_os in
|
||||
linux*)
|
||||
sgen_supported=true
|
||||
AOT_SUPPORTED="yes"
|
||||
;;
|
||||
darwin*|openbsd*|freebsd*)
|
||||
linux*|darwin*|openbsd*)
|
||||
sgen_supported=true
|
||||
;;
|
||||
esac
|
||||
case "$host" in
|
||||
x86_64-*-nacl*)
|
||||
AC_DEFINE(__mono_ilp32__, 1, [64 bit mode with 4 byte longs and pointers])
|
||||
sizeof_register=8
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
ia64-*-*)
|
||||
TARGET=IA64
|
||||
@@ -2320,14 +2295,6 @@ if test "x$host" != "x$target"; then
|
||||
sizeof_register=8
|
||||
target_byte_order=G_BIG_ENDIAN
|
||||
;;
|
||||
x86_64-*-nacl)
|
||||
TARGET=AMD64
|
||||
arch_target=amd64
|
||||
AC_DEFINE(TARGET_AMD64, 1, [...])
|
||||
AC_DEFINE(MONO_CROSS_COMPILE,1,[The runtime is compiled for cross-compiling mode])
|
||||
AC_DEFINE(__mono_ilp32__, 1, [64 bit mode with 4 byte longs and pointers])
|
||||
sizeof_register=8
|
||||
;;
|
||||
*)
|
||||
AC_MSG_WARN([Cross compiling is only supported for targets matching 'powerpc64-{ps3,xbox360}-linux-gnu'])
|
||||
esac
|
||||
@@ -2380,13 +2347,8 @@ fi
|
||||
dnl
|
||||
dnl Simple Generational checks (sgen)
|
||||
dnl
|
||||
if $sgen_supported; then
|
||||
build_sgen_default=yes
|
||||
else
|
||||
build_sgen_default=no
|
||||
fi
|
||||
SGEN_DEFINES=
|
||||
AC_ARG_WITH(sgen, [ --with-sgen=yes,no Extra Generational GC, default=yes],[buildsgen=$with_sgen],[buildsgen=$build_sgen_default])
|
||||
AC_ARG_WITH(sgen, [ --with-sgen=yes,no Extra Generational GC, default=yes],[buildsgen=$with_sgen],[buildsgen=yes])
|
||||
if test x$buildsgen = xyes; then
|
||||
if $sgen_supported; then
|
||||
SGEN_DEFINES="-DHAVE_SGEN_GC -DHAVE_MOVING_COLLECTOR -DHAVE_WRITE_BARRIERS"
|
||||
@@ -2521,11 +2483,6 @@ if test "x$try_mono_debugger" = "xyes"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# disable the debugger entirely when building with moonlight
|
||||
if test "x$with_moonlight" != "xno"; then
|
||||
mono_debugger_supported=no
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(if the Mono Debugger is supported on this platform)
|
||||
if test "x$mono_debugger_supported" = "xyes"; then
|
||||
BOEHM_DEFINES="$BOEHM_DEFINES -DMONO_DEBUGGER_SUPPORTED"
|
||||
@@ -2585,10 +2542,6 @@ case "x$gc" in
|
||||
if test x$TARGET = xSPARC -o x$TARGET = xSPARC64; then
|
||||
LIBGC_CPPFLAGS=`echo $LIBGC_CPPFLAGS | sed -e 's/-D_FILE_OFFSET_BITS=64//g'`
|
||||
fi
|
||||
# Don't pass -finstrument-for-thread-suspension in,
|
||||
# if these are instrumented it will be very bad news
|
||||
# (infinite recursion, undefined parking behavior, etc)
|
||||
LIBGC_CPPFLAGS=`echo $LIBGC_CPPFLAGS | sed -e 's/-finstrument-for-thread-suspension//g'`
|
||||
ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads=$libgc_threads $libgc_configure_args \"CPPFLAGS_FOR_LIBGC=$LIBGC_CPPFLAGS\" \"CFLAGS_FOR_LIBGC=$CFLAGS_FOR_LIBGC\""
|
||||
AC_CONFIG_SUBDIRS(libgc)
|
||||
;;
|
||||
@@ -2596,8 +2549,7 @@ esac
|
||||
|
||||
#AC_ARG_WITH(profile2, [ --with-profile2=yes,no If you want to install the 2.0 FX (defaults to yes)], [], [with_profile2=yes])
|
||||
AC_ARG_WITH(profile4, [ --with-profile4=yes,no If you want to install the 4.0 FX (defaults to yes)], [], [with_profile4=yes])
|
||||
AC_ARG_WITH(monodroid, [ --with-monodroid=yes,no If you want to build the MonoDroid 2.1 assemblies (defaults to no)], [], [with_monodroid=no])
|
||||
AC_ARG_WITH(monotouch, [ --with-monotouch=yes,no If you want to build the MonoTouch 2.1 assemblies (defaults to no)], [], [with_monotouch=no])
|
||||
AC_ARG_WITH(monotouch, [ --with-monotouch=yes,no If you want to build the raw MonoTouch 2.1 assemblies (defaults to no)], [], [with_monotouch=no])
|
||||
|
||||
OPROFILE=no
|
||||
AC_ARG_WITH(oprofile,[ --with-oprofile=no,<oprofile install dir> Enable oprofile support (defaults to no)],[
|
||||
@@ -2628,23 +2580,16 @@ AC_ARG_WITH(mcs_docs,[ --with-mcs-docs=yes,no If you want to build the
|
||||
DISABLE_MCS_DOCS=yes
|
||||
fi
|
||||
])
|
||||
if test x$with_profile4 != xyes; then
|
||||
DISABLE_MCS_DOCS=yes
|
||||
fi
|
||||
|
||||
MOONLIGHT_DEFINES=
|
||||
AC_ARG_WITH(moonlight, [ --with-moonlight=yes|no|only If you want to build Mono for Moonlight (defaults to no)],[
|
||||
if test x$with_moonlight != xno; then
|
||||
MOONLIGHT_DEFINES="-DMOONLIGHT -DDISABLE_ASSEMBLY_REMAPPING "
|
||||
if test "x$with_moonlight" = "xyes"; then
|
||||
AC_DEFINE(MOONLIGHT,1,[Building for Moonlight])
|
||||
elif test "x$with_moonlight" = "xonly"; then
|
||||
AC_DEFINE(MOONLIGHT,1,[Building for Moonlight])
|
||||
fi
|
||||
], [with_moonlight=no])
|
||||
AC_SUBST(MOONLIGHT_DEFINES)
|
||||
|
||||
AC_ARG_WITH(moon_gc, [ --with-moon-gc=boehm,sgen Select the gc to use with Moonlight (defaults to boehm)],[
|
||||
if test "x$with_moon_gc" != "xsgen"; then
|
||||
with_moon_gc=boehm
|
||||
fi
|
||||
], [with_moon_gc=boehm])
|
||||
|
||||
|
||||
AC_CHECK_HEADER([malloc.h],
|
||||
[AC_DEFINE([HAVE_USR_INCLUDE_MALLOC_H], [1],
|
||||
@@ -2672,11 +2617,7 @@ libmono_ldflags="$libmono_ldflags $LIBS"
|
||||
|
||||
AM_CONDITIONAL(MOONLIGHT, [test "x$with_moonlight" != "xno"])
|
||||
AM_CONDITIONAL(ONLY_MOONLIGHT, [test "x$with_moonlight" = "xonly"])
|
||||
AM_CONDITIONAL(MOONLIGHT_BOEHM, [test "x$with_moon_gc" = "xboehm"])
|
||||
AM_CONDITIONAL(MOONLIGHT_SGEN, [test "x$with_moon_gc" = "xsgen"])
|
||||
|
||||
AM_CONDITIONAL(INSTALL_4_0, [test "x$with_profile4" = xyes])
|
||||
AM_CONDITIONAL(INSTALL_MONODROID, [test "x$with_monodroid" = xyes])
|
||||
AM_CONDITIONAL(INSTALL_MONOTOUCH, [test "x$with_monotouch" = xyes])
|
||||
|
||||
AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
|
||||
@@ -2882,6 +2823,7 @@ mono/profiler/Makefile
|
||||
ikvm-native/Makefile
|
||||
scripts/Makefile
|
||||
man/Makefile
|
||||
web/Makefile
|
||||
docs/Makefile
|
||||
data/Makefile
|
||||
data/net_2_0/Makefile
|
||||
@@ -2889,7 +2831,6 @@ data/net_4_0/Makefile
|
||||
data/net_2_0/Browsers/Makefile
|
||||
data/mint.pc
|
||||
data/mono-2.pc
|
||||
data/monosgen-2.pc
|
||||
data/mono.pc
|
||||
data/mono-cairo.pc
|
||||
data/mono-nunit.pc
|
||||
@@ -2973,16 +2914,7 @@ fi
|
||||
echo "PLATFORM = darwin" >> $mcs_topdir/build/config.make
|
||||
fi
|
||||
|
||||
if test x$AOT_SUPPORTED = xyes -a x$enable_system_aot = xdefault; then
|
||||
enable_system_aot=yes
|
||||
fi
|
||||
|
||||
if test "x$enable_loadedllvm" = "xyes"; then
|
||||
# This seems to fail on the x86 buildbots
|
||||
enable_system_aot=no
|
||||
fi
|
||||
|
||||
if test x$host_win32 = xno -a x$platform_darwin != xyes -a x$enable_system_aot = xyes; then
|
||||
if test x$host_win32 = xno -a x$platform_darwin != xyes -a "x$AOT_SUPPORTED" = "xyes" -a x$enable_system_aot = xyes; then
|
||||
echo "ENABLE_AOT = 1" >> $mcs_topdir/build/config.make
|
||||
fi
|
||||
|
||||
@@ -3033,8 +2965,7 @@ echo "
|
||||
LLVM Back End: $enable_llvm (dynamically loaded: $enable_loadedllvm)
|
||||
|
||||
Libraries:
|
||||
Moon Profile: $with_moonlight ($with_moon_gc)
|
||||
MonoDroid: $with_monodroid
|
||||
Moon Profile: $with_moonlight
|
||||
MonoTouch: $with_monotouch
|
||||
JNI support: $jdk_headers_found
|
||||
libgdiplus: $libgdiplus_msg
|
||||
|
||||
+4
-10
@@ -9,7 +9,7 @@ monodir = $(sysconfdir)/mono
|
||||
EXTRA_DIST = \
|
||||
config.in \
|
||||
browscap.ini mono.supp mono.d README ChangeLog \
|
||||
mono.pc.in mono-2.pc.in monosgen-2.pc.in mint.pc.in dotnet.pc.in dotnet35.pc.in wcf.pc.in monodoc.pc.in \
|
||||
mono.pc.in mono-2.pc.in mint.pc.in dotnet.pc.in dotnet35.pc.in wcf.pc.in monodoc.pc.in \
|
||||
mono-nunit.pc.in mono-cairo.pc.in mono-options.pc.in cecil.pc.in \
|
||||
mono-lineeditor.pc.in system.web.extensions_1.0.pc.in system.web.extensions.design_1.0.pc.in\
|
||||
dtrace-prelink.sh mono.web.pc.in system.web.mvc.pc.in system.web.mvc2.pc.in \
|
||||
@@ -19,26 +19,20 @@ EXTRA_DIST = \
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
|
||||
if SUPPORT_SGEN
|
||||
SGENPCFILE=monosgen-2.pc
|
||||
else
|
||||
SGENPCFILE=
|
||||
endif
|
||||
|
||||
if JIT_SUPPORTED
|
||||
if INTERP_SUPPORTED
|
||||
pkgconfig_DATA= mono.pc mono-2.pc mint.pc dotnet.pc dotnet35.pc wcf.pc mono-nunit.pc mono-cairo.pc mono-options.pc cecil.pc monodoc.pc mono-lineeditor.pc system.web.extensions_1.0.pc \
|
||||
system.web.extensions.design_1.0.pc mono.web.pc system.web.mvc.pc system.web.mvc2.pc $(SGENPCFILE)
|
||||
system.web.extensions.design_1.0.pc mono.web.pc system.web.mvc.pc system.web.mvc2.pc
|
||||
else
|
||||
pkgconfig_DATA= mono.pc mono-2.pc dotnet.pc dotnet35.pc wcf.pc mono-nunit.pc mono-cairo.pc mono-options.pc cecil.pc monodoc.pc mono-lineeditor.pc system.web.extensions_1.0.pc \
|
||||
system.web.extensions.design_1.0.pc mono.web.pc system.web.mvc.pc system.web.mvc2.pc $(SGENPCFILE)
|
||||
system.web.extensions.design_1.0.pc mono.web.pc system.web.mvc.pc system.web.mvc2.pc
|
||||
endif
|
||||
else
|
||||
pkgconfig_DATA= mint.pc mono-nunit.pc mono-cairo.pc mono-options.pc cecil.pc monodoc.pc mono-lineeditor.pc
|
||||
endif
|
||||
|
||||
DISTCLEANFILES= mono-2.pc mono.pc mint.pc dotnet.pc dotnet35.pc wcf.pc mono-nunit.pc mono-cairo.pc mono-options.pc cecil.pc monodoc.pc mono-lineeditor.pc system.web.extensions_1.0.pc \
|
||||
system.web.extensions.design_1.0.pc mono.web.pc system.web.mvc.pc system.web.mvc2.pc $(SGENPCFILE)
|
||||
system.web.extensions.design_1.0.pc mono.web.pc system.web.mvc.pc system.web.mvc2.pc
|
||||
|
||||
mono_DATA = config \
|
||||
browscap.ini
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
assemblies_dir=@prefix@/lib/mono
|
||||
Libraries=${assemblies_dir}/gac/Mono.Cecil/0.9.4.0__0738eb9f132ed756/Mono.Cecil.dll
|
||||
Libraries=${assemblies_dir}/gac/Mono.Cecil/0.6.9.0__0738eb9f132ed756/Mono.Cecil.dll
|
||||
|
||||
Name: Mono Internal -- Do not use.
|
||||
Description: Mono Internal Libraries -- Do not use
|
||||
|
||||
@@ -288,8 +288,6 @@ def lookup_pretty_printer(val):
|
||||
return ObjectPrinter (val)
|
||||
if t == "string":
|
||||
return StringPrinter (val)
|
||||
if t == "MonoString *":
|
||||
return StringPrinter (val)
|
||||
if t == "MonoMethod *":
|
||||
return MonoMethodPrinter (val)
|
||||
if t == "MonoClass *":
|
||||
|
||||
@@ -4,4 +4,4 @@ Sources=${assemblies_dir}/Options.cs
|
||||
|
||||
Name: Mono.Options
|
||||
Description: Command Line Parsing Library
|
||||
Version: 0.2.2
|
||||
Version: 0.2.1
|
||||
@@ -1,11 +0,0 @@
|
||||
prefix=${pcfiledir}/../..
|
||||
exec_prefix=${pcfiledir}/../..
|
||||
libdir=${prefix}/@reloc_libdir@
|
||||
includedir=${prefix}/include/mono-@API_VER@
|
||||
sysconfdir=@sysconfdir@
|
||||
|
||||
Name: Mono
|
||||
Description: Mono Runtime
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} @export_ldflags@ -lmonosgen-@API_VER@ @libmono_ldflags@
|
||||
Cflags: -I${includedir} @libmono_cflags@
|
||||
@@ -94,9 +94,6 @@
|
||||
<section name="extensions" type="System.ServiceModel.Configuration.ExtensionsSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<section name="serviceHostingEnvironment" type="System.ServiceModel.Configuration.ServiceHostingEnvironmentSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<section name="services" type="System.ServiceModel.Configuration.ServicesSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<section name="standardEndpoints" type="System.ServiceModel.Configuration.StandardEndpointsSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
|
||||
<section name="routing" type="System.ServiceModel.Routing.Configuration.RoutingSection, System.ServiceModel.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
|
||||
<section name="protocolMapping" type="System.ServiceModel.Configuration.ProtocolMappingSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
|
||||
</sectionGroup>
|
||||
<sectionGroup name="system.transactions" type="System.Transactions.Configuration.TransactionsSectionGroup, System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null">
|
||||
<section name="defaultSettings" type="System.Transactions.Configuration.DefaultSettingsSection, System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null"/>
|
||||
@@ -290,15 +287,6 @@
|
||||
<bindingExtensions>
|
||||
<add name="webHttpBinding" type="System.ServiceModel.Configuration.WebHttpBindingCollectionElement, System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
|
||||
</bindingExtensions>
|
||||
<endpointExtensions>
|
||||
<add name="dynamicEndpoint" type="System.ServiceModel.Discovery.Configuration.DynamicEndpointCollectionElement, System.ServiceModel.Discovery, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
|
||||
<add name="discoveryEndpoint" type="System.ServiceModel.Discovery.Configuration.DiscoveryEndpointCollectionElement, System.ServiceModel.Discovery, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
|
||||
<add name="udpDiscoveryEndpoint" type="System.ServiceModel.Discovery.Configuration.UdpDiscoveryEndpointCollectionElement, System.ServiceModel.Discovery, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
|
||||
<add name="announcementEndpoint" type="System.ServiceModel.Discovery.Configuration.AnnouncementEndpointCollectionElement, System.ServiceModel.Discovery, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
|
||||
<add name="udpAnnouncementEndpoint" type="System.ServiceModel.Discovery.Configuration.UdpAnnouncementEndpointCollectionElement, System.ServiceModel.Discovery, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
|
||||
<add name="webHttpEndpoint" type="System.ServiceModel.Configuration.WebHttpEndpointCollectionElement, System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
|
||||
<add name="webScriptEndpoint" type="System.ServiceModel.Configuration.WebScriptEndpointCollectionElement, System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
|
||||
</endpointExtensions>
|
||||
</extensions>
|
||||
</system.serviceModel>
|
||||
</configuration>
|
||||
|
||||
@@ -19,4 +19,3 @@
|
||||
/config.h
|
||||
/config.status
|
||||
/INSTALL
|
||||
dolt*
|
||||
@@ -0,0 +1,8 @@
|
||||
set(SUBDIRS src test)
|
||||
|
||||
autoheader("config.h" null)
|
||||
|
||||
foreach(subdir ${SUBDIRS})
|
||||
add_subdirectory(${subdir})
|
||||
endforeach()
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
if HOST_WIN32
|
||||
SUBDIRS = src
|
||||
else
|
||||
if PLATFORM_DARWIN
|
||||
SUBDIRS = src
|
||||
else
|
||||
if CROSS_COMPILING
|
||||
SUBDIRS = src
|
||||
else
|
||||
SUBDIRS = src test
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
EXTRA_DIST = autogen.sh README NEWS AUTHORS ChangeLog winconfig.h
|
||||
|
||||
@@ -1,181 +0,0 @@
|
||||
dnl dolt, a replacement for libtool
|
||||
dnl Copyright © 2007-2008 Josh Triplett <[email protected]>
|
||||
dnl Copying and distribution of this file, with or without modification,
|
||||
dnl are permitted in any medium without royalty provided the copyright
|
||||
dnl notice and this notice are preserved.
|
||||
dnl
|
||||
dnl To use dolt, invoke the DOLT macro immediately after the libtool macros.
|
||||
dnl Optionally, copy this file into acinclude.m4, to avoid the need to have it
|
||||
dnl installed when running autoconf on your project.
|
||||
|
||||
AC_DEFUN([DOLT], [
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
# dolt, a replacement for libtool
|
||||
# Josh Triplett <[email protected]>
|
||||
AC_PATH_PROG(DOLT_BASH, bash)
|
||||
AC_MSG_CHECKING([if dolt supports this host])
|
||||
dolt_supported=yes
|
||||
if test x$DOLT_BASH = x; then
|
||||
dolt_supported=no
|
||||
fi
|
||||
if test x$GCC != xyes; then
|
||||
dolt_supported=no
|
||||
fi
|
||||
case $host in
|
||||
i?86-*-linux*|x86_64-*-linux*|powerpc-*-linux*|powerpc64-*-linux* \
|
||||
|amd64-*-freebsd*|i?86-*-freebsd*|ia64-*-freebsd*|arm*-*-linux*|sparc*-*-linux*|mips*-*-linux*)
|
||||
pic_options='-fPIC'
|
||||
;;
|
||||
?86-pc-cygwin*|i?86-pc-cygwin*)
|
||||
pic_options='-DDLL_EXPORT'
|
||||
;;
|
||||
i?86-apple-darwin*)
|
||||
pic_options='-fno-common'
|
||||
;;
|
||||
*)
|
||||
dolt_supported=no
|
||||
;;
|
||||
esac
|
||||
if test x$dolt_supported = xno ; then
|
||||
AC_MSG_RESULT([no, falling back to libtool])
|
||||
LTCOMPILE='$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(COMPILE)'
|
||||
LTCXXCOMPILE='$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXXCOMPILE)'
|
||||
else
|
||||
AC_MSG_RESULT([yes, replacing libtool])
|
||||
|
||||
dnl Start writing out doltcompile.
|
||||
cat <<__DOLTCOMPILE__EOF__ >doltcompile
|
||||
#!$DOLT_BASH
|
||||
__DOLTCOMPILE__EOF__
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
args=("$[]@")
|
||||
for ((arg=0; arg<${#args@<:@@@:>@}; arg++)) ; do
|
||||
if test x"${args@<:@$arg@:>@}" = x-o ; then
|
||||
objarg=$((arg+1))
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test x$objarg = x ; then
|
||||
echo 'Error: no -o on compiler command line' 1>&2
|
||||
exit 1
|
||||
fi
|
||||
lo="${args@<:@$objarg@:>@}"
|
||||
obj="${lo%.lo}"
|
||||
if test x"$lo" = x"$obj" ; then
|
||||
echo "Error: libtool object file name \"$lo\" does not end in .lo" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
objbase="${obj##*/}"
|
||||
__DOLTCOMPILE__EOF__
|
||||
|
||||
dnl Write out shared compilation code.
|
||||
if test x$enable_shared = xyes; then
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
libobjdir="${obj%$objbase}.libs"
|
||||
if test ! -d "$libobjdir" ; then
|
||||
mkdir_out="$(mkdir "$libobjdir" 2>&1)"
|
||||
mkdir_ret=$?
|
||||
if test "$mkdir_ret" -ne 0 && test ! -d "$libobjdir" ; then
|
||||
echo "$mkdir_out" 1>&2
|
||||
exit $mkdir_ret
|
||||
fi
|
||||
fi
|
||||
pic_object="$libobjdir/$objbase.o"
|
||||
args@<:@$objarg@:>@="$pic_object"
|
||||
__DOLTCOMPILE__EOF__
|
||||
cat <<__DOLTCOMPILE__EOF__ >>doltcompile
|
||||
"\${args@<:@@@:>@}" $pic_options -DPIC || exit \$?
|
||||
__DOLTCOMPILE__EOF__
|
||||
fi
|
||||
|
||||
dnl Write out static compilation code.
|
||||
dnl Avoid duplicate compiler output if also building shared objects.
|
||||
if test x$enable_static = xyes; then
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
non_pic_object="$obj.o"
|
||||
args@<:@$objarg@:>@="$non_pic_object"
|
||||
__DOLTCOMPILE__EOF__
|
||||
if test x$enable_shared = xyes; then
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
"${args@<:@@@:>@}" >/dev/null 2>&1 || exit $?
|
||||
__DOLTCOMPILE__EOF__
|
||||
else
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
"${args@<:@@@:>@}" || exit $?
|
||||
__DOLTCOMPILE__EOF__
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl Write out the code to write the .lo file.
|
||||
dnl The second line of the .lo file must match "^# Generated by .*libtool"
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
{
|
||||
echo "# $lo - a libtool object file"
|
||||
echo "# Generated by doltcompile, not libtool"
|
||||
__DOLTCOMPILE__EOF__
|
||||
|
||||
if test x$enable_shared = xyes; then
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
echo "pic_object='.libs/${objbase}.o'"
|
||||
__DOLTCOMPILE__EOF__
|
||||
else
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
echo pic_object=none
|
||||
__DOLTCOMPILE__EOF__
|
||||
fi
|
||||
|
||||
if test x$enable_static = xyes; then
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
echo "non_pic_object='${objbase}.o'"
|
||||
__DOLTCOMPILE__EOF__
|
||||
else
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
echo non_pic_object=none
|
||||
__DOLTCOMPILE__EOF__
|
||||
fi
|
||||
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
} > "$lo"
|
||||
__DOLTCOMPILE__EOF__
|
||||
|
||||
dnl Done writing out doltcompile; substitute it for libtool compilation.
|
||||
chmod +x doltcompile
|
||||
LTCOMPILE='$(top_builddir)/doltcompile $(COMPILE)'
|
||||
LTCXXCOMPILE='$(top_builddir)/doltcompile $(CXXCOMPILE)'
|
||||
|
||||
dnl automake ignores LTCOMPILE and LTCXXCOMPILE when it has separate CFLAGS for
|
||||
dnl a target, so write out a libtool wrapper to handle that case.
|
||||
dnl Note that doltlibtool does not handle inferred tags or option arguments
|
||||
dnl without '=', because automake does not use them.
|
||||
cat <<__DOLTLIBTOOL__EOF__ > doltlibtool
|
||||
#!$DOLT_BASH
|
||||
__DOLTLIBTOOL__EOF__
|
||||
cat <<'__DOLTLIBTOOL__EOF__' >>doltlibtool
|
||||
top_builddir_slash="${0%%doltlibtool}"
|
||||
: ${top_builddir_slash:=./}
|
||||
args=()
|
||||
modeok=false
|
||||
tagok=false
|
||||
for arg in "$[]@"; do
|
||||
case "$arg" in
|
||||
--mode=compile) modeok=true ;;
|
||||
--tag=CC|--tag=CXX) tagok=true ;;
|
||||
--quiet) ;;
|
||||
*) args@<:@${#args[@]}@:>@="$arg" ;;
|
||||
esac
|
||||
done
|
||||
if $modeok && $tagok ; then
|
||||
. ${top_builddir_slash}doltcompile "${args@<:@@@:>@}"
|
||||
else
|
||||
exec ${top_builddir_slash}libtool "$[]@"
|
||||
fi
|
||||
__DOLTLIBTOOL__EOF__
|
||||
|
||||
dnl Done writing out doltlibtool; substitute it for libtool.
|
||||
chmod +x doltlibtool
|
||||
LIBTOOL='$(top_builddir)/doltlibtool'
|
||||
fi
|
||||
AC_SUBST(LTCOMPILE)
|
||||
AC_SUBST(LTCXXCOMPILE)
|
||||
# end dolt
|
||||
])
|
||||
+3
-22
@@ -7,16 +7,14 @@ AM_MAINTAINER_MODE
|
||||
|
||||
AC_PROG_CC
|
||||
AM_PROG_LIBTOOL
|
||||
# Use dolt (http://dolt.freedesktop.org/) instead of libtool for building.
|
||||
DOLT
|
||||
CFLAGS="$CFLAGS -O0"
|
||||
CFLAGS="$CFLAGS -g -O0 -D_GNU_SOURCE"
|
||||
GNUC_PRETTY=
|
||||
GNUC_UNUSED=
|
||||
BREAKPOINT="G_STMT_START { raise (SIGTRAP); } G_STMT_END"
|
||||
if test x$GCC = xyes; then
|
||||
GNUC_UNUSED='__attribute__((__unused__))'
|
||||
GNUC_NORETURN='__attribute__((__noreturn__))'
|
||||
case $host_cpu in
|
||||
case $target_cpu in
|
||||
i*86|x86_64) BREAKPOINT="G_STMT_START { __asm__ (\"int \$03\"); } G_STMT_END" ;;
|
||||
esac
|
||||
fi
|
||||
@@ -34,25 +32,15 @@ if test "x$CFLAGS_FOR_EGLIB" != "x"; then
|
||||
CFLAGS=$CFLAGS_FOR_EGLIB
|
||||
fi
|
||||
|
||||
CFLAGS="$CFLAGS -g -D_GNU_SOURCE"
|
||||
|
||||
AM_CONDITIONAL(CROSS_COMPILING, [test x$cross_compiling = xyes])
|
||||
AC_C_BIGENDIAN([ORDER=G_BIG_ENDIAN],[ORDER=G_LITTLE_ENDIAN])
|
||||
|
||||
platform_darwin=no
|
||||
|
||||
case $host in
|
||||
*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
|
||||
PATHSEP='\\'
|
||||
SEARCHSEP=';'
|
||||
OS="WIN32"
|
||||
;;
|
||||
*-*darwin*)
|
||||
platform_darwin=yes
|
||||
PATHSEP='/'
|
||||
SEARCHSEP=':'
|
||||
OS="UNIX"
|
||||
;;
|
||||
*)
|
||||
PATHSEP='/'
|
||||
SEARCHSEP=':'
|
||||
@@ -86,7 +74,6 @@ AC_SUBST(SEARCHSEP)
|
||||
AC_SUBST(OS)
|
||||
AM_CONDITIONAL(HOST_WIN32, test x$OS = xWIN32)
|
||||
AM_CONDITIONAL(TARGET_WIN32, test x$OS = xWIN32)
|
||||
AM_CONDITIONAL(PLATFORM_DARWIN, test x$platform_darwin = xyes)
|
||||
|
||||
AC_CHECK_SIZEOF(int)
|
||||
AC_CHECK_SIZEOF(void *)
|
||||
@@ -94,10 +81,6 @@ AC_CHECK_FUNCS(strndup strlcpy getpwuid_r strtok_r rewinddir vasprintf)
|
||||
AM_CONDITIONAL(NEED_VASPRINTF, test x$have_vasprintf = x )
|
||||
AC_CHECK_LIB(iconv, iconv_open, LIBS="$LIBS -liconv")
|
||||
AC_CHECK_LIB(iconv, libiconv_open, LIBS="$LIBS -liconv")
|
||||
AC_CHECK_LIB(iconv, iconv_open, ICONV_LIBS="-liconv")
|
||||
AC_CHECK_LIB(iconv, libiconv_open, ICONV_LIBS="-liconv")
|
||||
AC_SUBST(ICONV_LIBS)
|
||||
LIBS="$LIBS $ICONV_LIBS"
|
||||
AC_SEARCH_LIBS(sqrtf, m)
|
||||
|
||||
# nanosleep may not be part of libc, also search it in other libraries
|
||||
@@ -126,9 +109,7 @@ if test "x$have_iso_varargs" = "xyes"; then
|
||||
fi
|
||||
AC_SUBST(G_HAVE_ISO_VARARGS)
|
||||
|
||||
AC_CHECK_HEADERS(getopt.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h localcharset.h sys/types.h)
|
||||
AC_CHECK_HEADER(alloca.h, [HAVE_ALLOCA_H=1], [HAVE_ALLOCA_H=0])
|
||||
AC_SUBST(HAVE_ALLOCA_H)
|
||||
AC_CHECK_HEADERS(getopt.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h localcharset.h)
|
||||
|
||||
if test $ac_cv_sizeof_void_p != $ac_cv_sizeof_int; then
|
||||
GPOINTER_TO_INT="((gint)(long) (ptr))"
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
set(win_files
|
||||
gdate-win32.c gdir-win32.c gfile-win32.c gmisc-win32.c
|
||||
gmodule-win32.c gtimer-win32.c)
|
||||
|
||||
set(unix_files
|
||||
gdate-unix.c gdir-unix.c gfile-unix.c gmisc-unix.c
|
||||
gmodule-unix.c gtimer-unix.c)
|
||||
|
||||
if (MSVC)
|
||||
set(os_files ${win_files})
|
||||
else(MSVC)
|
||||
set(os_files ${unix_files})
|
||||
endif(MSVC)
|
||||
|
||||
set(libeglib_la_SOURCES
|
||||
${os_files}
|
||||
eglib-config.h
|
||||
sort.frag.h
|
||||
glib.h
|
||||
garray.c
|
||||
gerror.c
|
||||
ghashtable.c
|
||||
gmem.c
|
||||
gmodule.h
|
||||
goutput.c
|
||||
gstr.c
|
||||
gslist.c
|
||||
gstring.c
|
||||
gptrarray.c
|
||||
glist.c
|
||||
gqueue.c
|
||||
gpath.c
|
||||
gshell.c
|
||||
gspawn.c
|
||||
gfile.c
|
||||
gfile-posix.c
|
||||
gpattern.c
|
||||
gmarkup.c
|
||||
gutf8.c
|
||||
gunicode.c
|
||||
unicode-data.h)
|
||||
|
||||
set(EXTRA_DIST eglib-config.h.in eglib-config.hw ${win_files} ${unix_files})
|
||||
|
||||
INCLUDE_DIRECTORIES(../ ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
ADD_DEFINITIONS(${CFLAGS} -D_FORTIFY_SOURCE=2)
|
||||
ADD_LIBRARY(eglib-static STATIC ${libeglib_la_SOURCES})
|
||||
ADD_LIBRARY(eglib SHARED ${libeglib_la_SOURCES})
|
||||
|
||||
@@ -24,11 +24,11 @@ os_files = $(unix_files)
|
||||
endif
|
||||
|
||||
libeglib_la_SOURCES = \
|
||||
eglib-config.h \
|
||||
eglib-remap.h \
|
||||
sort.frag.h \
|
||||
glib.h \
|
||||
garray.c \
|
||||
gbytearray.c \
|
||||
gerror.c \
|
||||
ghashtable.c \
|
||||
gmem.c \
|
||||
@@ -53,14 +53,14 @@ libeglib_la_SOURCES = \
|
||||
$(os_files) \
|
||||
$(vasprintf_files)
|
||||
|
||||
libeglib_la_CFLAGS = -g -Wall -D_FORTIFY_SOURCE=2
|
||||
libeglib_la_CFLAGS = -Wall -D_FORTIFY_SOURCE=2
|
||||
libeglib_static_la_SOURCES=$(libeglib_la_SOURCES)
|
||||
libeglib_static_la_CFLAGS = $(libeglib_la_CFLAGS)
|
||||
|
||||
INCLUDES = -I$(srcdir)
|
||||
|
||||
if HOST_WIN32
|
||||
libeglib_la_LIBADD = -lm $(ICONV_LIBS) -lpsapi
|
||||
libeglib_la_LIBADD = -lm -liconv -lpsapi
|
||||
endif
|
||||
|
||||
libeglib_static_la_LIBADD = $(libeglib_la_LIBADD)
|
||||
|
||||
@@ -19,10 +19,6 @@
|
||||
#define GINT_TO_POINTER(v) @GINT_TO_POINTER@
|
||||
#define GUINT_TO_POINTER(v) @GUINT_TO_POINTER@
|
||||
|
||||
#if @HAVE_ALLOCA_H@ == 1
|
||||
#define G_HAVE_ALLOCA_H
|
||||
#endif
|
||||
|
||||
typedef unsigned @GSIZE@ gsize;
|
||||
typedef signed @GSIZE@ gssize;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#define g_array_append monoeg_g_array_append
|
||||
#define g_array_append_vals monoeg_g_array_append_vals
|
||||
#define g_array_free monoeg_g_array_free
|
||||
#define g_array_insert_vals monoeg_g_array_insert_vals
|
||||
@@ -21,7 +20,6 @@
|
||||
#define g_direct_hash monoeg_g_direct_hash
|
||||
#define g_error_free monoeg_g_error_free
|
||||
#define g_error_new monoeg_g_error_new
|
||||
#define g_error_vnew monoeg_g_error_vnew
|
||||
#define g_file_error_from_errno monoeg_g_file_error_from_errno
|
||||
#define g_file_get_contents monoeg_g_file_get_contents
|
||||
#define g_file_open_tmp monoeg_g_file_open_tmp
|
||||
@@ -53,9 +51,6 @@
|
||||
#define g_hash_table_remove monoeg_g_hash_table_remove
|
||||
#define g_hash_table_size monoeg_g_hash_table_size
|
||||
#define g_hash_table_print_stats monoeg_g_hash_table_print_stats
|
||||
#define g_hash_table_remove_all monoeg_g_hash_table_remove_all
|
||||
#define g_hash_table_iter_init monoeg_g_hash_table_iter_init
|
||||
#define g_hash_table_iter_next monoeg_g_hash_table_iter_next
|
||||
#define g_int_equal monoeg_g_int_equal
|
||||
#define g_int_hash monoeg_g_int_hash
|
||||
#define g_list_alloc monoeg_g_list_alloc
|
||||
@@ -121,7 +116,6 @@
|
||||
#define g_ptr_array_sort_with_data monoeg_g_ptr_array_sort_with_data
|
||||
#define g_queue_free monoeg_g_queue_free
|
||||
#define g_queue_is_empty monoeg_g_queue_is_empty
|
||||
#define g_queue_foreach monoeg_g_queue_foreach
|
||||
#define g_queue_new monoeg_g_queue_new
|
||||
#define g_queue_pop_head monoeg_g_queue_pop_head
|
||||
#define g_queue_push_head monoeg_g_queue_push_head
|
||||
@@ -225,11 +219,7 @@
|
||||
#define g_malloc0 monoeg_malloc0
|
||||
#define g_ptr_array_grow monoeg_ptr_array_grow
|
||||
#define g_realloc monoeg_realloc
|
||||
#define g_try_malloc monoeg_try_malloc
|
||||
#define g_try_realloc monoeg_try_realloc
|
||||
#define g_strdup monoeg_strdup
|
||||
#define g_ucs4_to_utf16_len monoeg_ucs4_to_utf16_len
|
||||
#define g_utf16_to_ucs4_len monoeg_utf16_to_ucs4_len
|
||||
#define g_byte_array_free monoeg_g_byte_array_free
|
||||
#define g_byte_array_new monoeg_g_byte_array_new
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@
|
||||
typedef struct {
|
||||
GArray array;
|
||||
gboolean clear_;
|
||||
guint element_size;
|
||||
gboolean element_size;
|
||||
gboolean zero_terminated;
|
||||
gint capacity;
|
||||
} GArrayPriv;
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Arrays
|
||||
*
|
||||
* Author:
|
||||
* Geoff Norton ([email protected])
|
||||
*
|
||||
* (C) 2010 Novell, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
|
||||
#define INITIAL_CAPACITY 16
|
||||
|
||||
static void
|
||||
ensure_capacity (GByteArray *array,
|
||||
int capacity)
|
||||
{
|
||||
int new_capacity = MAX (array->len, INITIAL_CAPACITY);
|
||||
|
||||
if (capacity < array->len)
|
||||
return;
|
||||
|
||||
while (new_capacity < capacity) {
|
||||
new_capacity <<= 1;
|
||||
}
|
||||
capacity = new_capacity;
|
||||
array->data = (guint8*) g_realloc (array->data, capacity);
|
||||
|
||||
memset (array->data + array->len, 0, capacity - array->len);
|
||||
array->len = capacity;
|
||||
}
|
||||
|
||||
GByteArray *
|
||||
g_byte_array_new ()
|
||||
{
|
||||
GByteArray *rv = g_new0 (GByteArray, 1);
|
||||
|
||||
ensure_capacity (rv, INITIAL_CAPACITY);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
guint8*
|
||||
g_byte_array_free (GByteArray *array,
|
||||
gboolean free_segment)
|
||||
{
|
||||
guint8* rv = NULL;
|
||||
|
||||
g_return_val_if_fail (array != NULL, NULL);
|
||||
|
||||
if (free_segment)
|
||||
g_free (array->data);
|
||||
else
|
||||
rv = array->data;
|
||||
|
||||
g_free (array);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
GByteArray *
|
||||
g_array_append (GByteArray *array,
|
||||
guint8 *data,
|
||||
guint len)
|
||||
{
|
||||
g_return_val_if_fail (array != NULL, NULL);
|
||||
|
||||
ensure_capacity (array, array->len + len);
|
||||
|
||||
memmove (array->data + array->len, data, len);
|
||||
|
||||
array->len += len;
|
||||
|
||||
return array;
|
||||
}
|
||||
+1
-15
@@ -47,20 +47,6 @@ g_error_new (gpointer domain, gint code, const char *format, ...)
|
||||
return err;
|
||||
}
|
||||
|
||||
static GError *
|
||||
g_error_vnew (gpointer domain, gint code, const char *format, va_list ap)
|
||||
{
|
||||
GError *err = g_new (GError, 1);
|
||||
|
||||
err->domain = domain;
|
||||
err->code = code;
|
||||
|
||||
if (vasprintf (&err->message, format, ap) == -1)
|
||||
err->message = g_strdup_printf ("internal: invalid format string %s", format);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void
|
||||
g_clear_error (GError **error)
|
||||
{
|
||||
@@ -86,7 +72,7 @@ g_set_error (GError **err, gpointer domain, gint code, const gchar *format, ...)
|
||||
|
||||
if (err) {
|
||||
va_start (args, format);
|
||||
*err = g_error_vnew (domain, code, format, args);
|
||||
*err = g_error_new (domain, code, format, args);
|
||||
va_end (args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,12 +51,6 @@ struct _GHashTable {
|
||||
GDestroyNotify value_destroy_func, key_destroy_func;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
GHashTable *ht;
|
||||
int slot_index;
|
||||
Slot *slot;
|
||||
} Iter;
|
||||
|
||||
static const guint prime_tbl[] = {
|
||||
11, 19, 37, 73, 109, 163, 251, 367, 557, 823, 1237,
|
||||
1861, 2777, 4177, 6247, 9371, 14057, 21089, 31627,
|
||||
@@ -340,23 +334,6 @@ g_hash_table_find (GHashTable *hash, GHRFunc predicate, gpointer user_data)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
g_hash_table_remove_all (GHashTable *hash)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_return_if_fail (hash != NULL);
|
||||
|
||||
for (i = 0; i < hash->table_size; i++){
|
||||
Slot *s;
|
||||
|
||||
while (hash->table [i]) {
|
||||
s = hash->table [i];
|
||||
g_hash_table_remove (hash, s->key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
g_hash_table_remove (GHashTable *hash, gconstpointer key)
|
||||
{
|
||||
@@ -523,47 +500,6 @@ g_hash_table_print_stats (GHashTable *table)
|
||||
printf ("Size: %d Table Size: %d Max Chain Length: %d at %d\n", table->in_use, table->table_size, max_chain_size, max_chain_index);
|
||||
}
|
||||
|
||||
void
|
||||
g_hash_table_iter_init (GHashTableIter *it, GHashTable *hash_table)
|
||||
{
|
||||
Iter *iter = (Iter*)it;
|
||||
|
||||
memset (iter, 0, sizeof (Iter));
|
||||
iter->ht = hash_table;
|
||||
iter->slot_index = -1;
|
||||
}
|
||||
|
||||
gboolean g_hash_table_iter_next (GHashTableIter *it, gpointer *key, gpointer *value)
|
||||
{
|
||||
Iter *iter = (Iter*)it;
|
||||
|
||||
GHashTable *hash = iter->ht;
|
||||
|
||||
g_assert (iter->slot_index != -2);
|
||||
g_assert (sizeof (Iter) <= sizeof (GHashTableIter));
|
||||
|
||||
if (!iter->slot) {
|
||||
while (TRUE) {
|
||||
iter->slot_index ++;
|
||||
if (iter->slot_index >= hash->table_size) {
|
||||
iter->slot_index = -2;
|
||||
return FALSE;
|
||||
}
|
||||
if (hash->table [iter->slot_index])
|
||||
break;
|
||||
}
|
||||
iter->slot = hash->table [iter->slot_index];
|
||||
}
|
||||
|
||||
if (key)
|
||||
*key = iter->slot->key;
|
||||
if (value)
|
||||
*value = iter->slot->value;
|
||||
iter->slot = iter->slot->next;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
g_direct_equal (gconstpointer v1, gconstpointer v2)
|
||||
{
|
||||
|
||||
+6
-56
@@ -16,10 +16,6 @@
|
||||
/* For pid_t */
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -28,10 +24,6 @@
|
||||
#include <eglib-remap.h>
|
||||
#endif
|
||||
|
||||
#ifdef G_HAVE_ALLOCA_H
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
|
||||
#ifndef offsetof
|
||||
# define offsetof(s_name,n_name) (size_t)(char *)&(((s_name*)0)->m_name)
|
||||
#endif
|
||||
@@ -93,6 +85,7 @@ typedef int32_t gboolean;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Macros
|
||||
*/
|
||||
@@ -130,11 +123,11 @@ typedef int32_t gboolean;
|
||||
* Allocation
|
||||
*/
|
||||
void g_free (void *ptr);
|
||||
gpointer g_realloc (gpointer obj, gsize size);
|
||||
gpointer g_malloc (gsize x);
|
||||
gpointer g_malloc0 (gsize x);
|
||||
gpointer g_try_malloc (gsize x);
|
||||
gpointer g_try_realloc (gpointer obj, gsize size);
|
||||
static inline gpointer g_realloc (gpointer obj, gsize size) { if (!size) {g_free (obj); return 0;} return realloc (obj, size);}
|
||||
static inline gpointer g_malloc (gsize x) {if (x) return malloc (x); else return 0;}
|
||||
static inline gpointer g_malloc0 (gsize x) {if (x) return calloc(1,x); else return 0;}
|
||||
#define g_try_malloc(x) g_malloc(x)
|
||||
#define g_try_realloc(obj,size) g_realloc((obj),(size))
|
||||
|
||||
#define g_new(type,size) ((type *) g_malloc (sizeof (type) * (size)))
|
||||
#define g_new0(type,size) ((type *) g_malloc0 (sizeof (type)* (size)))
|
||||
@@ -185,14 +178,6 @@ gchar* g_win32_getlocale(void);
|
||||
* Hashtables
|
||||
*/
|
||||
typedef struct _GHashTable GHashTable;
|
||||
typedef struct _GHashTableIter GHashTableIter;
|
||||
|
||||
/* Private, but needed for stack allocation */
|
||||
struct _GHashTableIter
|
||||
{
|
||||
gpointer dummy [8];
|
||||
};
|
||||
|
||||
typedef void (*GFunc) (gpointer data, gpointer user_data);
|
||||
typedef gint (*GCompareFunc) (gconstpointer a, gconstpointer b);
|
||||
typedef gint (*GCompareDataFunc) (gconstpointer a, gconstpointer b, gpointer user_data);
|
||||
@@ -213,15 +198,11 @@ gboolean g_hash_table_lookup_extended (GHashTable *hash, gconstpointer ke
|
||||
void g_hash_table_foreach (GHashTable *hash, GHFunc func, gpointer user_data);
|
||||
gpointer g_hash_table_find (GHashTable *hash, GHRFunc predicate, gpointer user_data);
|
||||
gboolean g_hash_table_remove (GHashTable *hash, gconstpointer key);
|
||||
void g_hash_table_remove_all (GHashTable *hash);
|
||||
guint g_hash_table_foreach_remove (GHashTable *hash, GHRFunc func, gpointer user_data);
|
||||
guint g_hash_table_foreach_steal (GHashTable *hash, GHRFunc func, gpointer user_data);
|
||||
void g_hash_table_destroy (GHashTable *hash);
|
||||
void g_hash_table_print_stats (GHashTable *table);
|
||||
|
||||
void g_hash_table_iter_init (GHashTableIter *iter, GHashTable *hash_table);
|
||||
gboolean g_hash_table_iter_next (GHashTableIter *iter, gpointer *key, gpointer *value);
|
||||
|
||||
guint g_spaced_primes_closest (guint x);
|
||||
|
||||
#define g_hash_table_insert(h,k,v) g_hash_table_insert_replace ((h),(k),(v),FALSE)
|
||||
@@ -453,20 +434,6 @@ GList *g_list_insert_before (GList *list,
|
||||
GList *g_list_sort (GList *sort,
|
||||
GCompareFunc func);
|
||||
|
||||
/*
|
||||
* ByteArray
|
||||
*/
|
||||
|
||||
typedef struct _GByteArray GByteArray;
|
||||
struct _GByteArray {
|
||||
guint8 *data;
|
||||
gint len;
|
||||
};
|
||||
|
||||
GByteArray *g_byte_array_new (void);
|
||||
GByteArray* g_byte_array_append (GByteArray *array, const guint8 *data, guint len);
|
||||
guint8* g_byte_array_free (GByteArray *array, gboolean free_segment);
|
||||
|
||||
/*
|
||||
* Array
|
||||
*/
|
||||
@@ -529,7 +496,6 @@ void g_queue_push_tail (GQueue *queue,
|
||||
gboolean g_queue_is_empty (GQueue *queue);
|
||||
GQueue *g_queue_new (void);
|
||||
void g_queue_free (GQueue *queue);
|
||||
void g_queue_foreach (GQueue *queue, GFunc func, gpointer user_data);
|
||||
|
||||
/*
|
||||
* Messages
|
||||
@@ -576,8 +542,6 @@ void g_assertion_message (const gchar *format, ...) G_GNUC_NORETURN
|
||||
#endif /* ndef HAVE_C99_SUPPORT */
|
||||
#define g_log_set_handler(a,b,c,d)
|
||||
|
||||
#define G_GNUC_INTERNAL
|
||||
|
||||
/*
|
||||
* Conversions
|
||||
*/
|
||||
@@ -927,30 +891,16 @@ glong g_utf8_strlen (const gchar *str, gssize max);
|
||||
# define GUINT16_TO_LE(x) (x)
|
||||
# define GUINT_TO_LE(x) (x)
|
||||
# define GUINT32_TO_BE(x) GUINT32_SWAP_LE_BE(x)
|
||||
# define GUINT16_FROM_BE(x) GUINT16_SWAP_LE_BE(x)
|
||||
# define GUINT32_FROM_BE(x) GUINT32_SWAP_LE_BE(x)
|
||||
# define GUINT64_FROM_BE(x) GUINT64_SWAP_LE_BE(x)
|
||||
# define GINT16_FROM_BE(x) GUINT16_SWAP_LE_BE(x)
|
||||
# define GINT32_FROM_BE(x) GUINT32_SWAP_LE_BE(x)
|
||||
# define GINT64_FROM_BE(x) GUINT64_SWAP_LE_BE(x)
|
||||
#else
|
||||
# define GUINT32_TO_LE(x) GUINT32_SWAP_LE_BE(x)
|
||||
# define GUINT64_TO_LE(x) GUINT64_SWAP_LE_BE(x)
|
||||
# define GUINT16_TO_LE(x) GUINT16_SWAP_LE_BE(x)
|
||||
# define GUINT_TO_LE(x) GUINT32_SWAP_LE_BE(x)
|
||||
# define GUINT32_TO_BE(x) (x)
|
||||
# define GUINT16_FROM_BE(x) (x)
|
||||
# define GUINT32_FROM_BE(x) (x)
|
||||
# define GUINT64_FROM_BE(x) (x)
|
||||
# define GINT16_FROM_BE(x) (x)
|
||||
# define GINT32_FROM_BE(x) (x)
|
||||
# define GINT64_FROM_BE(x) (x)
|
||||
#endif
|
||||
|
||||
#define GINT64_FROM_LE(x) (GUINT64_TO_LE (x))
|
||||
#define GINT32_FROM_LE(x) (GUINT32_TO_LE (x))
|
||||
#define GINT16_FROM_LE(x) (GUINT16_TO_LE (x))
|
||||
|
||||
#define GUINT32_FROM_LE(x) (GUINT32_TO_LE (x))
|
||||
#define GUINT64_FROM_LE(x) (GUINT64_TO_LE (x))
|
||||
#define GUINT16_FROM_LE(x) (GUINT16_TO_LE (x))
|
||||
|
||||
@@ -51,55 +51,3 @@ g_memdup (gconstpointer mem, guint byte_size)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
gpointer g_realloc (gpointer obj, gsize size)
|
||||
{
|
||||
gpointer ptr;
|
||||
if (!size) {
|
||||
g_free (obj);
|
||||
return 0;
|
||||
}
|
||||
ptr = realloc (obj, size);
|
||||
if (ptr)
|
||||
return ptr;
|
||||
g_error ("Could not allocate %i bytes", size);
|
||||
}
|
||||
|
||||
gpointer
|
||||
g_malloc (gsize x)
|
||||
{
|
||||
gpointer ptr;
|
||||
if (!x)
|
||||
return 0;
|
||||
ptr = malloc (x);
|
||||
if (ptr)
|
||||
return ptr;
|
||||
g_error ("Could not allocate %i bytes", x);
|
||||
}
|
||||
|
||||
gpointer g_malloc0 (gsize x)
|
||||
{
|
||||
gpointer ptr;
|
||||
if (!x)
|
||||
return 0;
|
||||
ptr = calloc(1,x);
|
||||
if (ptr)
|
||||
return ptr;
|
||||
g_error ("Could not allocate %i bytes", x);
|
||||
}
|
||||
|
||||
gpointer g_try_malloc (gsize x)
|
||||
{
|
||||
if (x)
|
||||
return malloc (x);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
gpointer g_try_realloc (gpointer obj, gsize size)
|
||||
{
|
||||
if (!size) {
|
||||
g_free (obj);
|
||||
return 0;
|
||||
}
|
||||
return realloc (obj, size);
|
||||
}
|
||||
+1
-1
@@ -153,6 +153,6 @@ g_assertion_message (const gchar *format, ...)
|
||||
va_start (args, format);
|
||||
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, args);
|
||||
va_end (args);
|
||||
abort ();
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
@@ -105,9 +105,3 @@ g_queue_free (GQueue *queue)
|
||||
g_list_free (queue->head);
|
||||
g_free (queue);
|
||||
}
|
||||
|
||||
void
|
||||
g_queue_foreach (GQueue *queue, GFunc func, gpointer user_data)
|
||||
{
|
||||
g_list_foreach (queue->head, func, user_data);
|
||||
}
|
||||
@@ -69,10 +69,6 @@ g_strdupv (gchar **str_array)
|
||||
guint length;
|
||||
gchar **ret;
|
||||
guint i;
|
||||
|
||||
if (!str_array)
|
||||
return NULL;
|
||||
|
||||
length = g_strv_length(str_array);
|
||||
ret = g_new0(gchar *, length + 1);
|
||||
for (i = 0; str_array[i]; i++) {
|
||||
|
||||
+2
-2
@@ -65,7 +65,7 @@ utf8_to_utf16_len (const gchar *str, glong len, glong *items_read, GError **erro
|
||||
glong in_pos, ret;
|
||||
|
||||
if (len < 0)
|
||||
len = (glong) strlen (str);
|
||||
len = strlen (str);
|
||||
|
||||
in_pos = 0;
|
||||
ret = 0;
|
||||
@@ -215,7 +215,7 @@ g_utf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_wr
|
||||
*error = NULL;
|
||||
|
||||
if (len < 0)
|
||||
len = (glong) strlen (str);
|
||||
len = strlen (str);
|
||||
|
||||
if (items_read)
|
||||
*items_read = 0;
|
||||
|
||||
@@ -9,7 +9,7 @@ int vasprintf(char **ret, const char *fmt, va_list ap)
|
||||
size_t buflen;
|
||||
va_list ap2;
|
||||
|
||||
#if defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR)
|
||||
#ifdef _MSC_VER
|
||||
ap2 = ap;
|
||||
len = _vscprintf(fmt, ap2); // NOTE MS specific extension ( :-( )
|
||||
#else
|
||||
|
||||
@@ -29,7 +29,7 @@ SOURCES = \
|
||||
|
||||
test_eglib_SOURCES = $(SOURCES)
|
||||
|
||||
test_eglib_CFLAGS = -Wall -D_FORTIFY_SOURCE=2 -I$(srcdir)/../src -I../src -DDRIVER_NAME=\"EGlib\"
|
||||
test_eglib_CFLAGS = -Wall -Werror -D_FORTIFY_SOURCE=2 -I$(srcdir)/../src -I../src -DDRIVER_NAME=\"EGlib\"
|
||||
test_eglib_LDADD = ../src/libeglib.la
|
||||
|
||||
run-eglib: all
|
||||
|
||||
@@ -131,45 +131,12 @@ RESULT hash_grow (void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RESULT hash_iter (void)
|
||||
{
|
||||
#if !defined(GLIB_MAJOR_VERSION) || GLIB_CHECK_VERSION(2, 16, 0)
|
||||
GHashTable *hash = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
|
||||
GHashTableIter iter;
|
||||
int i, sum, keys_sum, values_sum;
|
||||
gpointer key, value;
|
||||
|
||||
sum = 0;
|
||||
for (i = 0; i < 1000; i++) {
|
||||
sum += i;
|
||||
g_hash_table_insert (hash, GUINT_TO_POINTER (i), GUINT_TO_POINTER (i));
|
||||
}
|
||||
|
||||
keys_sum = values_sum = 0;
|
||||
g_hash_table_iter_init (&iter, hash);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value)) {
|
||||
if (key != value)
|
||||
return FAILED ("key != value");
|
||||
keys_sum += GPOINTER_TO_UINT (key);
|
||||
values_sum += GPOINTER_TO_UINT (value);
|
||||
}
|
||||
if (keys_sum != sum || values_sum != sum)
|
||||
return FAILED ("Did not find all key-value pairs");
|
||||
g_hash_table_destroy (hash);
|
||||
return NULL;
|
||||
#else
|
||||
/* GHashTableIter was added in glib 2.16 */
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static Test hashtable_tests [] = {
|
||||
{"t1", hash_t1},
|
||||
{"t2", hash_t2},
|
||||
{"grow", hash_grow},
|
||||
{"default", hash_default},
|
||||
{"null_lookup", hash_null_lookup},
|
||||
{"iter", hash_iter},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -621,30 +621,6 @@ test_ascii_strdown ()
|
||||
return OK;
|
||||
}
|
||||
|
||||
RESULT
|
||||
test_strdupv ()
|
||||
{
|
||||
gchar **one;
|
||||
gchar **two;
|
||||
gint len;
|
||||
|
||||
one = g_strdupv (NULL);
|
||||
if (one)
|
||||
return FAILED ("Should have been NULL");
|
||||
|
||||
one = g_malloc (sizeof (gchar *));
|
||||
*one = NULL;
|
||||
two = g_strdupv (one);
|
||||
if (!two)
|
||||
FAILED ("Should have been not NULL");
|
||||
len = g_strv_length (two);
|
||||
if (len)
|
||||
FAILED ("Should have been 0");
|
||||
g_strfreev (two);
|
||||
g_strfreev (one);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Test strutil_tests [] = {
|
||||
{"g_strfreev", test_strfreev},
|
||||
{"g_strconcat", test_concat},
|
||||
@@ -663,7 +639,6 @@ static Test strutil_tests [] = {
|
||||
{"g_strescape", test_strescape},
|
||||
{"g_ascii_strncasecmp", test_ascii_strncasecmp },
|
||||
{"g_ascii_strdown", test_ascii_strdown },
|
||||
{"g_strdupv", test_strdupv },
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
ADD_DEFINITIONS(${GMODULE_CFLAGS})
|
||||
ADD_LIBRARY(ikvm_native SHARED jni.c os.c jni.h)
|
||||
TARGET_LINK_LIBRARIES(ikvm_native ${GMODULE_LIBS})
|
||||
@@ -22,4 +22,3 @@
|
||||
/autom4te.cache
|
||||
/libgc-mono.pc
|
||||
/libgc-mono-*.tar.gz
|
||||
dolt*
|
||||
@@ -0,0 +1,196 @@
|
||||
# based on configure.in/Makefile.am, which is:
|
||||
|
||||
# Copyright (c) 1999-2001 by Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
||||
# OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||||
#
|
||||
# Permission is hereby granted to use or copy this program
|
||||
# for any purpose, provided the above notices are retained on all copies.
|
||||
# Permission to modify the code and to distribute modified code is granted,
|
||||
# provided the above notices are retained, and a notice that the code was
|
||||
# modified is included with the above copyright notice.
|
||||
#
|
||||
# Original author: Tom Tromey
|
||||
# Modified by: Grzegorz Jakacki <jakacki at acm dot org>
|
||||
|
||||
# This is in sync with the configure.in/Makefile.am at r135583
|
||||
|
||||
#
|
||||
# This is a cmake build file for libgc
|
||||
# Only the functionality needed by mono is supported
|
||||
#
|
||||
|
||||
# FIXME:
|
||||
add_definitions("-g -O2")
|
||||
|
||||
set(THREADS ${libgc_threads})
|
||||
|
||||
set(THREADDLLIBS "")
|
||||
|
||||
if (THREADS STREQUAL "no" OR THREADS STREQUAL "none" OR THREADS STREQUAL "single")
|
||||
set(THREADS none)
|
||||
endif()
|
||||
|
||||
if (THREADS STREQUAL "posix" OR THREADS STREQUAL "pthreads")
|
||||
set(THREADS posix)
|
||||
set(THREADDLLIBS "-lpthread")
|
||||
if (${host} MATCHES "x86-.*-linux.*|ia64-.*-linux.*|i386-.*-linux.*|i486-.*-linux.*|i586-.*-linux.*|i686-.*-linux.*|x86_64-.*-linux.*|alpha.*-.*-linux.*|s390.*-.*-linux.*|sparc.*-.*-linux.*|powerpc-.*-linux.*")
|
||||
add_definitions(-DGC_LINUX_THREADS -D_REENTRANT)
|
||||
set(parallel_mark_supported yes)
|
||||
add_definitions(-DTHREAD_LOCAL_ALLOC)
|
||||
elseif(${host} MATCHES ".*-linux.*")
|
||||
add_definitions(-DGC_LINUX_THREADS -D_REENTRANT)
|
||||
elseif(${host} MATCHES ".*-aix.*")
|
||||
add_definitions(-DGC_AIX_THREADS -D_REENTRANT)
|
||||
elseif(${host} MATCHES ".*-hpux.*")
|
||||
message("Only HP/UX 11 threads are supported.")
|
||||
add_definitions(-DGC_HPUX_THREADS -D_REENTRANT -D_POSIX_C_SOURCE=199506L)
|
||||
add_definitions(-DTHREAD_LOCAL_ALLOC)
|
||||
set(parallel_mark_supported yes)
|
||||
set(THREADDLLIBS "-lpthread -lrt")
|
||||
elseif(${host} ".*-.*-freebsd.*")
|
||||
add_definitions(-DGC_FREEBSD_THREADS)
|
||||
message(FATAL_ERROR "todo")
|
||||
### if test "x$PTHREAD_CFLAGS" != "x"; then
|
||||
### INCLUDES="$INCLUDES $PTHREAD_CFLAGS"
|
||||
### fi
|
||||
### if test "x$PTHREAD_LIBS" = "x"; then
|
||||
### THREADDLLIBS=-pthread
|
||||
### else
|
||||
### THREADDLLIBS="$PTHREAD_LIBS"
|
||||
### fi
|
||||
elseif(${host} ".*-.*-freebsd.*")
|
||||
add_definitions(-DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS)
|
||||
elseif(${host} ".*-.*-irix.*")
|
||||
add_definitions(-DGC_IRIX_THREADS)
|
||||
elseif(${host} ".*-.*-cygwin.*")
|
||||
add_definitons(-DGC_WIN32_THREADS)
|
||||
elseif(${host} ".*-.*-darwin.*")
|
||||
add_definitons(-DGC_DARWIN_THREADS -DTHREAD_LOCAL_ALLOC)
|
||||
set(parallel_mark_supported yes)
|
||||
elseif(${host} ".*-.*-netbsd.*")
|
||||
add_definitions(-DGC_NETBSD_THREADS -DTHREAD_LOCAL_ALLOC)
|
||||
set(parallel_mark_supported yes)
|
||||
elseif(${host} ".*-.*-osf.*")
|
||||
add_definitions(GC_OSF1_THREADS -DTHREAD_LOCAL_ALLOC)
|
||||
set(parallel_mark_supported yes)
|
||||
add_definitions(-pthread)
|
||||
set(THREADDLLIBS "-lpthread -lrt")
|
||||
else()
|
||||
message(FATAL_ERROR "Pthreads not supported by the GC on this platform.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(THREADS STREQUAL "win32")
|
||||
add_definitions(GC_WIN32_THREADS)
|
||||
# Wine getenv may not return NULL for missing entry
|
||||
add_definitions(NO_GETENV)
|
||||
if (enable_win32_dllmain)
|
||||
add_definitions(gc_inside_dll)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${host} MATCHES "powerpc-.*-darwin.*")
|
||||
set(powerpc_darwin yes)
|
||||
endif()
|
||||
|
||||
if(parallel_mark_supported AND enable_parallel_mark)
|
||||
add_definitions("-DPARALLEL_MARK")
|
||||
endif()
|
||||
|
||||
# Configuration of machine-dependent code
|
||||
|
||||
ac_msg_checking("which machine-dependent code should be used")
|
||||
|
||||
###AC_MSG_CHECKING(
|
||||
###machdep=
|
||||
###case "$host" in
|
||||
### alpha-*-openbsd*)
|
||||
### machdep="alpha_mach_dep.lo"
|
||||
### if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
|
||||
### AC_MSG_WARN(OpenBSD/Alpha without dlopen(). Shared library support is disabled)
|
||||
### fi
|
||||
### ;;
|
||||
### alpha*-*-linux*)
|
||||
### machdep="alpha_mach_dep.lo"
|
||||
### ;;
|
||||
### i?86-*-solaris2.[[89]]|i?86-*-solaris2.1?)
|
||||
### AC_DEFINE(SOLARIS25_PROC_VDB_BUG_FIXED)
|
||||
### ;;
|
||||
### mipstx39-*-elf*)
|
||||
### machdep="mips_ultrix_mach_dep.lo"
|
||||
### AC_DEFINE(STACKBASE, __stackbase)
|
||||
### AC_DEFINE(DATASTART_IS_ETEXT)
|
||||
### ;;
|
||||
### mips-dec-ultrix*)
|
||||
### machdep="mips_ultrix_mach-dep.lo"
|
||||
### ;;
|
||||
### mips-nec-sysv*|mips-unknown-sysv*)
|
||||
### ;;
|
||||
### mips*-*-linux*)
|
||||
### ;;
|
||||
### mips-*-*)
|
||||
### machdep="mips_sgi_mach_dep.lo"
|
||||
### AC_DEFINE(NO_EXECUTE_PERMISSION)
|
||||
### ;;
|
||||
### sparc-*-netbsd*)
|
||||
### machdep="sparc_netbsd_mach_dep.lo"
|
||||
### ;;
|
||||
### sparc-sun-solaris2.3)
|
||||
### machdep="sparc_mach_dep.lo"
|
||||
### AC_DEFINE(SUNOS53_SHARED_LIB)
|
||||
### ;;
|
||||
### sparc*-sun-solaris2.*)
|
||||
### machdep="sparc_mach_dep.lo"
|
||||
### ;;
|
||||
### ia64-*-*)
|
||||
### machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
|
||||
### ;;
|
||||
###esac
|
||||
if(NOT machdep)
|
||||
set(machdep "mach_dep.c")
|
||||
endif()
|
||||
ac_msg_result("${machdep}")
|
||||
|
||||
ac_msg_checking("for threads package to use")
|
||||
ac_msg_result("${THREADS}")
|
||||
|
||||
# Include defines that have become de facto standard.
|
||||
# ALL_INTERIOR_POINTERS can be overridden in startup code.
|
||||
add_definitions(-DSILENT -DNO_SIGNALS -DNO_EXECUTE_PERMISSION)
|
||||
# AC_DEFINE(ALL_INTERIOR_POINTERS)
|
||||
|
||||
# By default, make the library as general as possible.
|
||||
add_definitions(-DJAVA_FINALIZATION -DGC_GCJ_SUPPORT -DATOMIC_UNCOLLECTABLE)
|
||||
|
||||
add_definitions(-D_IN_LIBGC)
|
||||
|
||||
set(SUBDIRS include doc)
|
||||
|
||||
foreach(dir ${SUBDIRS})
|
||||
add_subdirectory(${dir})
|
||||
endforeach()
|
||||
|
||||
set(top_srcdir ../)
|
||||
|
||||
# .. is needed for mono/utils/mono-compiler.h
|
||||
INCLUDE_DIRECTORIES(. .. include)
|
||||
add_definitions(${CPPFLAGS})
|
||||
|
||||
if(powerpc_darwin)
|
||||
set(asm_libgc_sources powerpc_darwin_mach_dep.s)
|
||||
endif()
|
||||
|
||||
set(libmonogc_la_SOURCES
|
||||
allchblk.c alloc.c blacklst.c checksums.c dbg_mlc.c
|
||||
dyn_load.c finalize.c gc_dlopen.c gcj_mlc.c headers.c
|
||||
malloc.c mallocx.c mark.c mark_rts.c misc.c new_hblk.c
|
||||
obj_map.c os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c
|
||||
solaris_pthreads.c solaris_threads.c specific.c stubborn.c typd_mlc.c
|
||||
backgraph.c win32_threads.c
|
||||
pthread_support.c pthread_stop_world.c darwin_stop_world.c
|
||||
${asm_libgc_sources} ${machdep})
|
||||
|
||||
add_library(monogc-static STATIC ${libmonogc_la_SOURCES})
|
||||
target_link_libraries (${THREADDLLIBS} ${UNWINDLIBS})
|
||||
+7
-9
@@ -36,10 +36,8 @@ EXTRA_DIST =
|
||||
|
||||
if POWERPC_DARWIN
|
||||
asm_libgc_sources = powerpc_darwin_mach_dep.s
|
||||
endif
|
||||
|
||||
if TARGET_IA64
|
||||
asm_libgc_sources = ia64_save_regs_in_stack.s
|
||||
else
|
||||
asm_libgc_sources =
|
||||
endif
|
||||
|
||||
libmonogc_la_SOURCES = allchblk.c alloc.c blacklst.c checksums.c dbg_mlc.c \
|
||||
@@ -49,12 +47,12 @@ obj_map.c os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c \
|
||||
solaris_pthreads.c solaris_threads.c specific.c stubborn.c typd_mlc.c \
|
||||
backgraph.c win32_threads.c \
|
||||
pthread_support.c pthread_stop_world.c darwin_stop_world.c \
|
||||
openbsd_stop_world.c mach_dep.c $(asm_libgc_sources)
|
||||
openbsd_stop_world.c $(asm_libgc_sources)
|
||||
|
||||
# Include THREADDLLIBS here to ensure that the correct versions of
|
||||
# linuxthread semaphore functions get linked:
|
||||
libmonogc_la_LIBADD = $(THREADDLLIBS) $(UNWINDLIBS)
|
||||
libmonogc_la_DEPENDENCIES =
|
||||
libmonogc_la_LIBADD = @addobjs@ $(THREADDLLIBS) $(UNWINDLIBS)
|
||||
libmonogc_la_DEPENDENCIES = @addobjs@
|
||||
libmonogc_la_LDFLAGS = -version-info 1:2:0
|
||||
|
||||
EXTRA_libmonogc_la_SOURCES = alpha_mach_dep.S \
|
||||
@@ -95,7 +93,7 @@ endif
|
||||
#TESTS = gctest $(extra_checks)
|
||||
|
||||
## FIXME: relies on internal code generated by automake.
|
||||
all_objs = $(libgc_la_OBJECTS)
|
||||
all_objs = @addobjs@ $(libgc_la_OBJECTS)
|
||||
$(all_objs) : include/private/gcconfig.h include/private/gc_priv.h \
|
||||
include/private/gc_hdrs.h include/gc.h include/gc_gcj.h include/gc_mark.h
|
||||
|
||||
@@ -115,7 +113,7 @@ endif
|
||||
|
||||
## We have our own definition of LTCOMPILE because we want to use our
|
||||
## CFLAGS, not those passed in from the top level make.
|
||||
LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(INCLUDES) \
|
||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) \
|
||||
-I$(top_srcdir)/include $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CFLAGS) $(MY_CFLAGS) $(GC_CFLAGS)
|
||||
LINK = $(LIBTOOL) --mode=link $(CC) $(AM_CFLAGS) $(MY_CFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
+43
-177
@@ -1,181 +1,47 @@
|
||||
dnl dolt, a replacement for libtool
|
||||
dnl Copyright © 2007-2008 Josh Triplett <[email protected]>
|
||||
dnl Copying and distribution of this file, with or without modification,
|
||||
dnl are permitted in any medium without royalty provided the copyright
|
||||
dnl notice and this notice are preserved.
|
||||
dnl
|
||||
dnl To use dolt, invoke the DOLT macro immediately after the libtool macros.
|
||||
dnl Optionally, copy this file into acinclude.m4, to avoid the need to have it
|
||||
dnl installed when running autoconf on your project.
|
||||
#
|
||||
#
|
||||
# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
||||
# OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||||
#
|
||||
# Permission is hereby granted to use or copy this program
|
||||
# for any purpose, provided the above notices are retained on all copies.
|
||||
# Permission to modify the code and to distribute modified code is granted,
|
||||
# provided the above notices are retained, and a notice that the code was
|
||||
# modified is included with the above copyright notice.
|
||||
#
|
||||
# Modified by: Grzegorz Jakacki <jakacki at acm dot org>
|
||||
|
||||
AC_DEFUN([DOLT], [
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
# dolt, a replacement for libtool
|
||||
# Josh Triplett <[email protected]>
|
||||
AC_PATH_PROG(DOLT_BASH, bash)
|
||||
AC_MSG_CHECKING([if dolt supports this host])
|
||||
dolt_supported=yes
|
||||
if test x$DOLT_BASH = x; then
|
||||
dolt_supported=no
|
||||
fi
|
||||
if test x$GCC != xyes; then
|
||||
dolt_supported=no
|
||||
fi
|
||||
case $host in
|
||||
i?86-*-linux*|x86_64-*-linux*|powerpc-*-linux*|powerpc64-*-linux* \
|
||||
|amd64-*-freebsd*|i?86-*-freebsd*|ia64-*-freebsd*|arm*-*-linux*|sparc*-*-linux*|mips*-*-linux*)
|
||||
pic_options='-fPIC'
|
||||
;;
|
||||
?86-pc-cygwin*|i?86-pc-cygwin*)
|
||||
pic_options='-DDLL_EXPORT'
|
||||
;;
|
||||
i?86-apple-darwin*)
|
||||
pic_options='-fno-common'
|
||||
;;
|
||||
*)
|
||||
dolt_supported=no
|
||||
;;
|
||||
esac
|
||||
if test x$dolt_supported = xno ; then
|
||||
AC_MSG_RESULT([no, falling back to libtool])
|
||||
LTCOMPILE='$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(COMPILE)'
|
||||
LTCXXCOMPILE='$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXXCOMPILE)'
|
||||
else
|
||||
AC_MSG_RESULT([yes, replacing libtool])
|
||||
# GC_SET_VERSION
|
||||
# sets and AC_DEFINEs GC_VERSION_MAJOR, GC_VERSION_MINOR and GC_ALPHA_VERSION
|
||||
# based on the contents of PACKAGE_VERSION; PACKAGE_VERSION must conform to
|
||||
# [0-9]+[.][0-9]+(alpha[0.9]+)?
|
||||
# in lex syntax; if there is no alpha number, GC_ALPHA_VERSION is empty
|
||||
#
|
||||
AC_DEFUN(GC_SET_VERSION, [
|
||||
AC_MSG_CHECKING(GC version numbers)
|
||||
GC_VERSION_MAJOR=`echo $PACKAGE_VERSION | sed 's/^\([[0-9]][[0-9]]*\)[[.]].*$/\1/g'`
|
||||
GC_VERSION_MINOR=`echo $PACKAGE_VERSION | sed 's/^[[^.]]*[[.]]\([[0-9]][[0-9]]*\).*$/\1/g'`
|
||||
GC_ALPHA_VERSION=`echo $PACKAGE_VERSION | sed 's/^[[^.]]*[[.]][[0-9]]*//'`
|
||||
|
||||
dnl Start writing out doltcompile.
|
||||
cat <<__DOLTCOMPILE__EOF__ >doltcompile
|
||||
#!$DOLT_BASH
|
||||
__DOLTCOMPILE__EOF__
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
args=("$[]@")
|
||||
for ((arg=0; arg<${#args@<:@@@:>@}; arg++)) ; do
|
||||
if test x"${args@<:@$arg@:>@}" = x-o ; then
|
||||
objarg=$((arg+1))
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test x$objarg = x ; then
|
||||
echo 'Error: no -o on compiler command line' 1>&2
|
||||
exit 1
|
||||
fi
|
||||
lo="${args@<:@$objarg@:>@}"
|
||||
obj="${lo%.lo}"
|
||||
if test x"$lo" = x"$obj" ; then
|
||||
echo "Error: libtool object file name \"$lo\" does not end in .lo" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
objbase="${obj##*/}"
|
||||
__DOLTCOMPILE__EOF__
|
||||
case "$GC_ALPHA_VERSION" in
|
||||
alpha*)
|
||||
GC_ALPHA_VERSION=`echo $GC_ALPHA_VERSION \
|
||||
| sed 's/alpha\([[0-9]][[0-9]]*\)/\1/'` ;;
|
||||
*) GC_ALPHA_MAJOR='' ;;
|
||||
esac
|
||||
|
||||
dnl Write out shared compilation code.
|
||||
if test x$enable_shared = xyes; then
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
libobjdir="${obj%$objbase}.libs"
|
||||
if test ! -d "$libobjdir" ; then
|
||||
mkdir_out="$(mkdir "$libobjdir" 2>&1)"
|
||||
mkdir_ret=$?
|
||||
if test "$mkdir_ret" -ne 0 && test ! -d "$libobjdir" ; then
|
||||
echo "$mkdir_out" 1>&2
|
||||
exit $mkdir_ret
|
||||
fi
|
||||
fi
|
||||
pic_object="$libobjdir/$objbase.o"
|
||||
args@<:@$objarg@:>@="$pic_object"
|
||||
__DOLTCOMPILE__EOF__
|
||||
cat <<__DOLTCOMPILE__EOF__ >>doltcompile
|
||||
"\${args@<:@@@:>@}" $pic_options -DPIC || exit \$?
|
||||
__DOLTCOMPILE__EOF__
|
||||
fi
|
||||
|
||||
dnl Write out static compilation code.
|
||||
dnl Avoid duplicate compiler output if also building shared objects.
|
||||
if test x$enable_static = xyes; then
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
non_pic_object="$obj.o"
|
||||
args@<:@$objarg@:>@="$non_pic_object"
|
||||
__DOLTCOMPILE__EOF__
|
||||
if test x$enable_shared = xyes; then
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
"${args@<:@@@:>@}" >/dev/null 2>&1 || exit $?
|
||||
__DOLTCOMPILE__EOF__
|
||||
else
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
"${args@<:@@@:>@}" || exit $?
|
||||
__DOLTCOMPILE__EOF__
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl Write out the code to write the .lo file.
|
||||
dnl The second line of the .lo file must match "^# Generated by .*libtool"
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
{
|
||||
echo "# $lo - a libtool object file"
|
||||
echo "# Generated by doltcompile, not libtool"
|
||||
__DOLTCOMPILE__EOF__
|
||||
|
||||
if test x$enable_shared = xyes; then
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
echo "pic_object='.libs/${objbase}.o'"
|
||||
__DOLTCOMPILE__EOF__
|
||||
else
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
echo pic_object=none
|
||||
__DOLTCOMPILE__EOF__
|
||||
fi
|
||||
|
||||
if test x$enable_static = xyes; then
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
echo "non_pic_object='${objbase}.o'"
|
||||
__DOLTCOMPILE__EOF__
|
||||
else
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
echo non_pic_object=none
|
||||
__DOLTCOMPILE__EOF__
|
||||
fi
|
||||
|
||||
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
|
||||
} > "$lo"
|
||||
__DOLTCOMPILE__EOF__
|
||||
|
||||
dnl Done writing out doltcompile; substitute it for libtool compilation.
|
||||
chmod +x doltcompile
|
||||
LTCOMPILE='$(top_builddir)/doltcompile $(COMPILE)'
|
||||
LTCXXCOMPILE='$(top_builddir)/doltcompile $(CXXCOMPILE)'
|
||||
|
||||
dnl automake ignores LTCOMPILE and LTCXXCOMPILE when it has separate CFLAGS for
|
||||
dnl a target, so write out a libtool wrapper to handle that case.
|
||||
dnl Note that doltlibtool does not handle inferred tags or option arguments
|
||||
dnl without '=', because automake does not use them.
|
||||
cat <<__DOLTLIBTOOL__EOF__ > doltlibtool
|
||||
#!$DOLT_BASH
|
||||
__DOLTLIBTOOL__EOF__
|
||||
cat <<'__DOLTLIBTOOL__EOF__' >>doltlibtool
|
||||
top_builddir_slash="${0%%doltlibtool}"
|
||||
: ${top_builddir_slash:=./}
|
||||
args=()
|
||||
modeok=false
|
||||
tagok=false
|
||||
for arg in "$[]@"; do
|
||||
case "$arg" in
|
||||
--mode=compile) modeok=true ;;
|
||||
--tag=CC|--tag=CXX) tagok=true ;;
|
||||
--quiet) ;;
|
||||
*) args@<:@${#args[@]}@:>@="$arg" ;;
|
||||
esac
|
||||
done
|
||||
if $modeok && $tagok ; then
|
||||
. ${top_builddir_slash}doltcompile "${args@<:@@@:>@}"
|
||||
else
|
||||
exec ${top_builddir_slash}libtool "$[]@"
|
||||
fi
|
||||
__DOLTLIBTOOL__EOF__
|
||||
|
||||
dnl Done writing out doltlibtool; substitute it for libtool.
|
||||
chmod +x doltlibtool
|
||||
LIBTOOL='$(top_builddir)/doltlibtool'
|
||||
fi
|
||||
AC_SUBST(LTCOMPILE)
|
||||
AC_SUBST(LTCXXCOMPILE)
|
||||
# end dolt
|
||||
if test :$GC_VERSION_MAJOR: = :: \
|
||||
-o :$GC_VERSION_MINOR: = :: ;
|
||||
then
|
||||
AC_MSG_RESULT(invalid)
|
||||
AC_MSG_ERROR([nonconforming PACKAGE_VERSION='$PACKAGE_VERSION'])
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED(GC_VERSION_MAJOR, $GC_VERSION_MAJOR)
|
||||
AC_DEFINE_UNQUOTED(GC_VERSION_MINOR, $GC_VERSION_MINOR)
|
||||
if test :$GC_ALPHA_VERSION: != :: ; then
|
||||
AC_DEFINE_UNQUOTED(GC_ALPHA_VERSION, $GC_ALPHA_VERSION)
|
||||
fi
|
||||
AC_MSG_RESULT(major=$GC_VERSION_MAJOR minor=$GC_VERSION_MINOR \
|
||||
${GC_ALPHA_VERSION:+alpha=}$GC_ALPHA_VERSION)
|
||||
])
|
||||
+3
-16
@@ -94,7 +94,7 @@ case "$THREADS" in
|
||||
fi
|
||||
AC_DEFINE(THREAD_LOCAL_ALLOC)
|
||||
;;
|
||||
*-*-linux* | *-*-nacl*)
|
||||
*-*-linux*)
|
||||
AC_DEFINE(GC_LINUX_THREADS)
|
||||
AC_DEFINE(_REENTRANT)
|
||||
;;
|
||||
@@ -337,11 +337,7 @@ case "$host" in
|
||||
machdep="sparc_mach_dep.lo"
|
||||
;;
|
||||
ia64-*-*)
|
||||
machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
|
||||
target_ia64=true
|
||||
;;
|
||||
*-*-nacl*)
|
||||
AC_DEFINE(NO_EXECUTE_PERMISSION)
|
||||
machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
|
||||
;;
|
||||
esac
|
||||
if test x"$machdep" = x; then
|
||||
@@ -349,21 +345,12 @@ AC_MSG_RESULT($machdep)
|
||||
machdep="mach_dep.lo"
|
||||
fi
|
||||
addobjs="$addobjs $machdep"
|
||||
#
|
||||
# Adding object files directly to _LIBADD breaks -j builds, so we need to add the sources
|
||||
# instead, but _SOURCES can't contain autoconf substitutions, so add them using automake
|
||||
# conditionals.
|
||||
#
|
||||
#AC_SUBST(addobjs)
|
||||
AC_SUBST(addobjs)
|
||||
AC_SUBST(addincludes)
|
||||
AC_SUBST(addlibs)
|
||||
AC_SUBST(addtests)
|
||||
|
||||
AM_CONDITIONAL(TARGET_IA64,test x$target_ia64 = xtrue)
|
||||
|
||||
AC_PROG_LIBTOOL
|
||||
# Use dolt (http://dolt.freedesktop.org/) instead of libtool for building.
|
||||
DOLT
|
||||
|
||||
#
|
||||
# Check for AViiON Machines running DGUX
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "private/gc_priv.h"
|
||||
|
||||
# if defined(DYNAMIC_LOADING) && (defined(GC_PTHREADS) && !defined(GC_DARWIN_THREADS)) \
|
||||
# if (defined(GC_PTHREADS) && !defined(GC_DARWIN_THREADS)) \
|
||||
|| defined(GC_SOLARIS_THREADS)
|
||||
|
||||
# if defined(dlopen) && !defined(GC_USE_LD_WRAP)
|
||||
|
||||
@@ -59,11 +59,6 @@
|
||||
#endif
|
||||
int GC_pthread_join(pthread_t thread, void **retval);
|
||||
int GC_pthread_detach(pthread_t thread);
|
||||
#if defined(__native_client__) || defined(NACL)
|
||||
void GC_pthread_exit(void *status);
|
||||
# undef pthread_exit
|
||||
# define pthread_exit GC_pthread_exit
|
||||
#endif
|
||||
|
||||
#if defined(GC_OSF1_THREADS) \
|
||||
&& defined(_PTHREAD_USE_MANGLED_NAMES_) && !defined(_PTHREAD_USE_PTDNAM_)
|
||||
|
||||
@@ -1962,8 +1962,6 @@ void GC_err_puts GC_PROTO((GC_CONST char *s));
|
||||
/* SPARC/Linux doesn't properly define SIGPWR in <signal.h>.
|
||||
* It is aliased to SIGLOST in asm/signal.h, though. */
|
||||
# define SIG_SUSPEND SIGLOST
|
||||
# elif defined(NACL)
|
||||
# define SIG_SUSPEND 0
|
||||
# else
|
||||
/* Linuxthreads itself uses SIGUSR1 and SIGUSR2. */
|
||||
# define SIG_SUSPEND SIGPWR
|
||||
|
||||
@@ -65,11 +65,6 @@
|
||||
# endif
|
||||
|
||||
/* Determine the machine type: */
|
||||
# if defined(__native_client__)
|
||||
# define NACL
|
||||
# define I386
|
||||
# define mach_type_known
|
||||
# endif
|
||||
# if defined(__arm__) || defined(__thumb__)
|
||||
# define ARM32
|
||||
# if !defined(LINUX) && !defined(NETBSD) && !defined(DARWIN)
|
||||
@@ -1091,19 +1086,13 @@
|
||||
# endif
|
||||
|
||||
# ifdef I386
|
||||
# if defined( NACL )
|
||||
# define MACH_TYPE "NACL"
|
||||
# define MACH_TYPE "I386"
|
||||
# if defined(__LP64__) || defined(_WIN64)
|
||||
# define CPP_WORDSZ 64
|
||||
# define ALIGNMENT 8
|
||||
# else
|
||||
# define CPP_WORDSZ 32
|
||||
# define ALIGNMENT 4
|
||||
# else
|
||||
# define MACH_TYPE "I386"
|
||||
# if defined(__LP64__) || defined(_WIN64)
|
||||
# define CPP_WORDSZ 64
|
||||
# define ALIGNMENT 8
|
||||
# else
|
||||
# define CPP_WORDSZ 32
|
||||
# define ALIGNMENT 4
|
||||
# endif
|
||||
/* Appears to hold for all "32 bit" compilers */
|
||||
/* except Borland. The -a4 option fixes */
|
||||
/* Borland. */
|
||||
@@ -1199,32 +1188,7 @@
|
||||
# define HEAP_START DATAEND
|
||||
# endif /* USE_MMAP */
|
||||
# endif /* DGUX */
|
||||
# ifdef NACL
|
||||
# define OS_TYPE "NACL"
|
||||
extern int etext[];
|
||||
# define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
|
||||
extern int _end[];
|
||||
# define DATAEND (_end)
|
||||
# ifdef STACK_GRAN
|
||||
# undef STACK_GRAN
|
||||
# endif /* STACK_GRAN */
|
||||
# define STACK_GRAN 0x10000
|
||||
# define HEURISTIC1
|
||||
# ifdef USE_MMAP
|
||||
# undef USE_MMAP
|
||||
# endif
|
||||
# ifdef USE_MUNMAP
|
||||
# undef USE_MUNMAP
|
||||
# endif
|
||||
# ifdef USE_MMAP_ANON
|
||||
# undef USE_MMAP_ANON
|
||||
# endif
|
||||
# ifdef USE_MMAP_FIXED
|
||||
# undef USE_MMAP_FIXED
|
||||
# endif
|
||||
# define GETPAGESIZE() 65536
|
||||
# define MAX_NACL_GC_THREADS 1024
|
||||
# endif
|
||||
|
||||
# ifdef LINUX
|
||||
# ifndef __GNUC__
|
||||
/* The Intel compiler doesn't like inline assembly */
|
||||
@@ -2307,7 +2271,7 @@
|
||||
# if defined(GC_IRIX_THREADS) && !defined(IRIX5)
|
||||
--> inconsistent configuration
|
||||
# endif
|
||||
# if defined(GC_LINUX_THREADS) && !(defined(LINUX) || defined(NACL))
|
||||
# if defined(GC_LINUX_THREADS) && !defined(LINUX)
|
||||
--> inconsistent configuration
|
||||
# endif
|
||||
# if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
|
||||
|
||||
@@ -7,15 +7,6 @@ struct thread_stop_info {
|
||||
/* last successfully handled a suspend */
|
||||
/* signal. */
|
||||
ptr_t stack_ptr; /* Valid only when stopped. */
|
||||
#ifdef NACL
|
||||
/* Grab NACL_GC_REG_STORAGE_SIZE pointers off the stack when going into */
|
||||
/* a syscall. 20 is more than we need, but it's an overestimate in case*/
|
||||
/* the instrumented function uses any callee saved registers, they may */
|
||||
/* be pushed to the stack much earlier. Also, on amd64 'push' puts 8 */
|
||||
/* bytes on the stack even though our pointers are 4 bytes. */
|
||||
#define NACL_GC_REG_STORAGE_SIZE 20
|
||||
ptr_t reg_storage[NACL_GC_REG_STORAGE_SIZE];
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -28,9 +28,6 @@ typedef struct GC_Thread_Rep {
|
||||
/* guaranteed to be dead, but we may */
|
||||
/* not yet have registered the join.) */
|
||||
pthread_t id;
|
||||
#ifdef PLATFORM_ANDROID
|
||||
pid_t kernel_id;
|
||||
#endif
|
||||
/* Extra bookkeeping information the stopping code uses */
|
||||
struct thread_stop_info stop_info;
|
||||
|
||||
@@ -92,9 +89,6 @@ typedef struct GC_Thread_Rep {
|
||||
|
||||
# define THREAD_TABLE_SZ 128 /* Must be power of 2 */
|
||||
extern volatile GC_thread GC_threads[THREAD_TABLE_SZ];
|
||||
#ifdef NACL
|
||||
extern __thread GC_thread gc_thread_self;
|
||||
#endif
|
||||
|
||||
extern GC_bool GC_thr_initialized;
|
||||
|
||||
|
||||
+1
-20
@@ -133,7 +133,7 @@
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
#if defined( UNIX_LIKE ) || defined(NACL)
|
||||
#ifdef UNIX_LIKE
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
@@ -618,12 +618,6 @@ void GC_enable_signals(void)
|
||||
/* longjmp implementations. Most systems appear not to have */
|
||||
/* a signal 32. */
|
||||
# define SIGSETMASK(old, new) (old) = sigsetmask(new)
|
||||
# elif defined(NACL)
|
||||
/* We don't use signals in NaCl. */
|
||||
# define SIGSET_T int
|
||||
# define SIG_DEL(set, signal)
|
||||
# define SIG_FILL(set)
|
||||
# define SIGSETMASK(old, new)
|
||||
# else
|
||||
/* Use POSIX/SYSV interface */
|
||||
# define SIGSET_T sigset_t
|
||||
@@ -2073,21 +2067,8 @@ void GC_remap(ptr_t start, word bytes)
|
||||
int result;
|
||||
|
||||
if (0 == start_addr) return;
|
||||
#ifdef NACL
|
||||
{
|
||||
/* NaCl doesn't expose mprotect, but mmap should work fine */
|
||||
void * mmap_result;
|
||||
mmap_result = mmap(start_addr, len, PROT_READ | PROT_WRITE | OPT_PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_FIXED | OPT_MAP_ANON,
|
||||
zero_fd, 0/* offset */);
|
||||
if (mmap_result != (void *)start_addr) ABORT("mmap as mprotect failed");
|
||||
/* Fake the return value as if mprotect succeeded. */
|
||||
result = 0;
|
||||
}
|
||||
#else /* NACL */
|
||||
result = mprotect(start_addr, len,
|
||||
PROT_READ | PROT_WRITE | OPT_PROT_EXEC);
|
||||
#endif /* NACL */
|
||||
if (result != 0) {
|
||||
GC_err_printf3(
|
||||
"Mprotect failed at 0x%lx (length %ld) with errno %ld\n",
|
||||
|
||||
+3
-184
@@ -9,7 +9,6 @@
|
||||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
/* work around a dlopen issue (bug #75390), undefs to avoid warnings with redefinitions */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
@@ -23,19 +22,6 @@
|
||||
#include "include/libgc-mono-debugger.h"
|
||||
#endif
|
||||
|
||||
#ifdef NACL
|
||||
int nacl_park_threads_now = 0;
|
||||
pthread_t nacl_thread_parker = -1;
|
||||
|
||||
int nacl_thread_parked[MAX_NACL_GC_THREADS];
|
||||
int nacl_thread_used[MAX_NACL_GC_THREADS];
|
||||
int nacl_thread_parking_inited = 0;
|
||||
int nacl_num_gc_threads = 0;
|
||||
pthread_mutex_t nacl_thread_alloc_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
__thread int nacl_thread_idx = -1;
|
||||
__thread GC_thread nacl_gc_thread_self = NULL;
|
||||
#endif
|
||||
|
||||
#if DEBUG_THREADS
|
||||
|
||||
#ifndef NSIG
|
||||
@@ -50,7 +36,6 @@ __thread GC_thread nacl_gc_thread_self = NULL;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef NACL
|
||||
void GC_print_sig_mask()
|
||||
{
|
||||
sigset_t blocked;
|
||||
@@ -64,7 +49,7 @@ void GC_print_sig_mask()
|
||||
}
|
||||
GC_printf0("\n");
|
||||
}
|
||||
#endif /* NACL */
|
||||
|
||||
#endif
|
||||
|
||||
/* Remove the signals that we want to allow in thread stopping */
|
||||
@@ -131,7 +116,6 @@ sem_t GC_suspend_ack_sem;
|
||||
|
||||
static void _GC_suspend_handler(int sig)
|
||||
{
|
||||
#ifndef NACL
|
||||
int dummy;
|
||||
pthread_t my_thread = pthread_self();
|
||||
GC_thread me;
|
||||
@@ -201,8 +185,6 @@ static void _GC_suspend_handler(int sig)
|
||||
#if DEBUG_THREADS
|
||||
GC_printf1("Continuing 0x%lx\n", my_thread);
|
||||
#endif
|
||||
|
||||
#endif /* NACL */
|
||||
}
|
||||
|
||||
void GC_suspend_handler(int sig)
|
||||
@@ -296,10 +278,6 @@ static void pthread_push_all_stacks()
|
||||
# else
|
||||
GC_push_all_stack(lo, hi);
|
||||
# endif
|
||||
# ifdef NACL
|
||||
/* Push reg_storage as roots, this will cover the reg context */
|
||||
GC_push_all_stack(p -> stop_info.reg_storage, p -> stop_info.reg_storage + NACL_GC_REG_STORAGE_SIZE);
|
||||
# endif
|
||||
# ifdef IA64
|
||||
# if DEBUG_THREADS
|
||||
GC_printf3("Reg stack for thread 0x%lx = [%lx,%lx)\n",
|
||||
@@ -337,29 +315,11 @@ void GC_push_all_stacks()
|
||||
pthread_t GC_stopping_thread;
|
||||
int GC_stopping_pid;
|
||||
|
||||
#ifdef PLATFORM_ANDROID
|
||||
static
|
||||
int android_thread_kill(pid_t tid, int sig)
|
||||
{
|
||||
int ret;
|
||||
int old_errno = errno;
|
||||
|
||||
ret = tkill(tid, sig);
|
||||
if (ret < 0) {
|
||||
ret = errno;
|
||||
errno = old_errno;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* We hold the allocation lock. Suspend all threads that might */
|
||||
/* still be running. Return the number of suspend signals that */
|
||||
/* were sent. */
|
||||
int GC_suspend_all()
|
||||
{
|
||||
#ifndef NACL
|
||||
int n_live_threads = 0;
|
||||
int i;
|
||||
GC_thread p;
|
||||
@@ -378,12 +338,8 @@ int GC_suspend_all()
|
||||
#if DEBUG_THREADS
|
||||
GC_printf1("Sending suspend signal to 0x%lx\n", p -> id);
|
||||
#endif
|
||||
|
||||
#ifndef PLATFORM_ANDROID
|
||||
|
||||
result = pthread_kill(p -> id, SIG_SUSPEND);
|
||||
#else
|
||||
result = android_thread_kill(p -> kernel_id, SIG_SUSPEND);
|
||||
#endif
|
||||
switch(result) {
|
||||
case ESRCH:
|
||||
/* Not really there anymore. Possible? */
|
||||
@@ -398,15 +354,11 @@ int GC_suspend_all()
|
||||
}
|
||||
}
|
||||
return n_live_threads;
|
||||
#else /* NACL */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Caller holds allocation lock. */
|
||||
static void pthread_stop_world()
|
||||
{
|
||||
#ifndef NACL
|
||||
int i;
|
||||
int n_live_threads;
|
||||
int code;
|
||||
@@ -458,128 +410,8 @@ static void pthread_stop_world()
|
||||
GC_printf1("World stopped from 0x%lx\n", pthread_self());
|
||||
#endif
|
||||
GC_stopping_thread = 0; /* debugging only */
|
||||
#else /* NACL */
|
||||
GC_thread p;
|
||||
int i;
|
||||
|
||||
#if DEBUG_THREADS
|
||||
GC_printf1("pthread_stop_world: num_threads %d\n", nacl_num_gc_threads - 1);
|
||||
#endif
|
||||
nacl_thread_parker = pthread_self();
|
||||
nacl_park_threads_now = 1;
|
||||
|
||||
while (1) {
|
||||
#define NACL_PARK_WAIT_NANOSECONDS 100000
|
||||
int num_threads_parked = 0;
|
||||
struct timespec ts;
|
||||
int num_used = 0;
|
||||
/* Check the 'parked' flag for each thread the GC knows about */
|
||||
for (i = 0; i < MAX_NACL_GC_THREADS && num_used < nacl_num_gc_threads; i++) {
|
||||
if (nacl_thread_used[i] == 1) {
|
||||
num_used++;
|
||||
if (nacl_thread_parked[i] == 1) {
|
||||
num_threads_parked++;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* -1 for the current thread */
|
||||
if (num_threads_parked >= nacl_num_gc_threads - 1)
|
||||
break;
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = NACL_PARK_WAIT_NANOSECONDS;
|
||||
#if DEBUG_THREADS
|
||||
GC_printf1("sleeping waiting for %d threads to park...\n", nacl_num_gc_threads - num_threads_parked - 1);
|
||||
#endif
|
||||
nanosleep(&ts, 0);
|
||||
}
|
||||
|
||||
#endif /* NACL */
|
||||
}
|
||||
|
||||
|
||||
#ifdef NACL
|
||||
|
||||
#if __x86_64__
|
||||
|
||||
#define NACL_STORE_REGS() \
|
||||
do { \
|
||||
asm("push %rbx");\
|
||||
asm("push %rbp");\
|
||||
asm("push %r12");\
|
||||
asm("push %r13");\
|
||||
asm("push %r14");\
|
||||
asm("push %r15");\
|
||||
asm("mov %%esp, %0" : "=m" (nacl_gc_thread_self->stop_info.stack_ptr));\
|
||||
memcpy(nacl_gc_thread_self->stop_info.reg_storage, nacl_gc_thread_self->stop_info.stack_ptr, NACL_GC_REG_STORAGE_SIZE * sizeof(ptr_t));\
|
||||
asm("add $48, %esp");\
|
||||
asm("add %r15, %rsp");\
|
||||
} while (0)
|
||||
|
||||
#elif __i386__
|
||||
|
||||
#define NACL_STORE_REGS() \
|
||||
do { \
|
||||
asm("push %ebx");\
|
||||
asm("push %ebp");\
|
||||
asm("push %esi");\
|
||||
asm("push %edi");\
|
||||
asm("mov %%esp, %0" : "=m" (nacl_gc_thread_self->stop_info.stack_ptr));\
|
||||
memcpy(nacl_gc_thread_self->stop_info.reg_storage, nacl_gc_thread_self->stop_info.stack_ptr, NACL_GC_REG_STORAGE_SIZE * sizeof(ptr_t));\
|
||||
asm("add $16, %esp");\
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
void nacl_pre_syscall_hook()
|
||||
{
|
||||
int local_dummy = 0;
|
||||
if (nacl_thread_idx != -1) {
|
||||
NACL_STORE_REGS();
|
||||
nacl_gc_thread_self->stop_info.stack_ptr = (ptr_t)(&local_dummy);
|
||||
nacl_thread_parked[nacl_thread_idx] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void nacl_post_syscall_hook()
|
||||
{
|
||||
/* Calling __nacl_suspend_thread_if_needed() right away should guarantee we don't mutate the GC set. */
|
||||
__nacl_suspend_thread_if_needed();
|
||||
if (nacl_thread_idx != -1) {
|
||||
nacl_thread_parked[nacl_thread_idx] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void __nacl_suspend_thread_if_needed() {
|
||||
if (nacl_park_threads_now) {
|
||||
pthread_t self = pthread_self();
|
||||
int local_dummy = 0;
|
||||
/* Don't try to park the thread parker. */
|
||||
if (nacl_thread_parker == self)
|
||||
return;
|
||||
|
||||
/* This can happen when a thread is created */
|
||||
/* outside of the GC system (wthread mostly). */
|
||||
if (nacl_thread_idx < 0)
|
||||
return;
|
||||
|
||||
/* If it was already 'parked', we're returning from a syscall, */
|
||||
/* so don't bother storing registers again, the GC has a set. */
|
||||
if (!nacl_thread_parked[nacl_thread_idx]) {
|
||||
NACL_STORE_REGS();
|
||||
nacl_gc_thread_self->stop_info.stack_ptr = (ptr_t)(&local_dummy);
|
||||
}
|
||||
nacl_thread_parked[nacl_thread_idx] = 1;
|
||||
while (nacl_park_threads_now)
|
||||
; /* spin */
|
||||
nacl_thread_parked[nacl_thread_idx] = 0;
|
||||
|
||||
/* Clear out the reg storage for next suspend. */
|
||||
memset(nacl_gc_thread_self->stop_info.reg_storage, 0, NACL_GC_REG_STORAGE_SIZE * sizeof(ptr_t));
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* NACL */
|
||||
|
||||
/* Caller holds allocation lock. */
|
||||
void GC_stop_world()
|
||||
{
|
||||
@@ -612,7 +444,6 @@ void GC_stop_world()
|
||||
/* the world stopped. */
|
||||
static void pthread_start_world()
|
||||
{
|
||||
#ifndef NACL
|
||||
pthread_t my_thread = pthread_self();
|
||||
register int i;
|
||||
register GC_thread p;
|
||||
@@ -635,12 +466,8 @@ static void pthread_start_world()
|
||||
#if DEBUG_THREADS
|
||||
GC_printf1("Sending restart signal to 0x%lx\n", p -> id);
|
||||
#endif
|
||||
|
||||
#ifndef PLATFORM_ANDROID
|
||||
|
||||
result = pthread_kill(p -> id, SIG_THR_RESTART);
|
||||
#else
|
||||
result = android_thread_kill(p -> kernel_id, SIG_THR_RESTART);
|
||||
#endif
|
||||
switch(result) {
|
||||
case ESRCH:
|
||||
/* Not really there anymore. Possible? */
|
||||
@@ -673,12 +500,6 @@ static void pthread_start_world()
|
||||
#if DEBUG_THREADS
|
||||
GC_printf0("World started\n");
|
||||
#endif
|
||||
#else /* NACL */
|
||||
# if DEBUG_THREADS
|
||||
GC_printf0("World starting\n");
|
||||
# endif
|
||||
nacl_park_threads_now = 0;
|
||||
#endif /* NACL */
|
||||
}
|
||||
|
||||
void GC_start_world()
|
||||
@@ -692,7 +513,6 @@ void GC_start_world()
|
||||
}
|
||||
|
||||
static void pthread_stop_init() {
|
||||
#ifndef NACL
|
||||
struct sigaction act;
|
||||
|
||||
if (sem_init(&GC_suspend_ack_sem, 0, 0) != 0)
|
||||
@@ -733,7 +553,6 @@ static void pthread_stop_init() {
|
||||
GC_printf0("Will retry suspend signal if necessary.\n");
|
||||
}
|
||||
# endif
|
||||
#endif /* NACL */
|
||||
}
|
||||
|
||||
/* We hold the allocation lock. */
|
||||
|
||||
@@ -164,9 +164,6 @@
|
||||
# endif
|
||||
# undef pthread_join
|
||||
# undef pthread_detach
|
||||
# if defined(NACL)
|
||||
# undef pthread_exit
|
||||
# endif
|
||||
# if defined(GC_OSF1_THREADS) && defined(_PTHREAD_USE_MANGLED_NAMES_) \
|
||||
&& !defined(_PTHREAD_USE_PTDNAM_)
|
||||
/* Restore the original mangled names on Tru64 UNIX. */
|
||||
@@ -679,52 +676,6 @@ void GC_mark_thread_local_free_lists(void)
|
||||
|
||||
static struct GC_Thread_Rep first_thread;
|
||||
|
||||
#ifdef NACL
|
||||
extern int nacl_thread_parked[MAX_NACL_GC_THREADS];
|
||||
extern int nacl_thread_used[MAX_NACL_GC_THREADS];
|
||||
extern int nacl_thread_parking_inited;
|
||||
extern int nacl_num_gc_threads;
|
||||
extern pthread_mutex_t nacl_thread_alloc_lock;
|
||||
extern __thread int nacl_thread_idx;
|
||||
extern __thread GC_thread nacl_gc_thread_self;
|
||||
|
||||
void nacl_initialize_gc_thread()
|
||||
{
|
||||
int i;
|
||||
pthread_mutex_lock(&nacl_thread_alloc_lock);
|
||||
if (!nacl_thread_parking_inited)
|
||||
{
|
||||
for (i = 0; i < MAX_NACL_GC_THREADS; i++) {
|
||||
nacl_thread_used[i] = 0;
|
||||
nacl_thread_parked[i] = 0;
|
||||
}
|
||||
nacl_thread_parking_inited = 1;
|
||||
}
|
||||
GC_ASSERT(nacl_num_gc_threads <= MAX_NACL_GC_THREADS);
|
||||
for (i = 0; i < MAX_NACL_GC_THREADS; i++) {
|
||||
if (nacl_thread_used[i] == 0) {
|
||||
nacl_thread_used[i] = 1;
|
||||
nacl_thread_idx = i;
|
||||
nacl_num_gc_threads++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&nacl_thread_alloc_lock);
|
||||
}
|
||||
|
||||
void nacl_shutdown_gc_thread()
|
||||
{
|
||||
pthread_mutex_lock(&nacl_thread_alloc_lock);
|
||||
GC_ASSERT(nacl_thread_idx >= 0 && nacl_thread_idx < MAX_NACL_GC_THREADS);
|
||||
GC_ASSERT(nacl_thread_used[nacl_thread_idx] != 0);
|
||||
nacl_thread_used[nacl_thread_idx] = 0;
|
||||
nacl_thread_idx = -1;
|
||||
nacl_num_gc_threads--;
|
||||
pthread_mutex_unlock(&nacl_thread_alloc_lock);
|
||||
}
|
||||
|
||||
#endif /* NACL */
|
||||
|
||||
/* Add a thread to GC_threads. We assume it wasn't already there. */
|
||||
/* Caller holds allocation lock. */
|
||||
GC_thread GC_new_thread(pthread_t id)
|
||||
@@ -742,15 +693,8 @@ GC_thread GC_new_thread(pthread_t id)
|
||||
}
|
||||
if (result == 0) return(0);
|
||||
result -> id = id;
|
||||
#ifdef PLATFORM_ANDROID
|
||||
result -> kernel_id = gettid();
|
||||
#endif
|
||||
result -> next = GC_threads[hv];
|
||||
GC_threads[hv] = result;
|
||||
#ifdef NACL
|
||||
nacl_gc_thread_self = result;
|
||||
nacl_initialize_gc_thread();
|
||||
#endif
|
||||
GC_ASSERT(result -> flags == 0 && result -> thread_blocked == 0);
|
||||
return(result);
|
||||
}
|
||||
@@ -764,11 +708,6 @@ void GC_delete_thread(pthread_t id)
|
||||
register GC_thread p = GC_threads[hv];
|
||||
register GC_thread prev = 0;
|
||||
|
||||
#ifdef NACL
|
||||
nacl_shutdown_gc_thread();
|
||||
nacl_gc_thread_self = NULL;
|
||||
#endif
|
||||
|
||||
while (!pthread_equal(p -> id, id)) {
|
||||
prev = p;
|
||||
p = p -> next;
|
||||
@@ -1176,7 +1115,6 @@ void GC_init_parallel()
|
||||
|
||||
|
||||
#if !defined(GC_DARWIN_THREADS) && !defined(GC_OPENBSD_THREADS)
|
||||
#ifndef NACL
|
||||
int WRAP_FUNC(pthread_sigmask)(int how, const sigset_t *set, sigset_t *oset)
|
||||
{
|
||||
sigset_t fudged_set;
|
||||
@@ -1188,7 +1126,6 @@ int WRAP_FUNC(pthread_sigmask)(int how, const sigset_t *set, sigset_t *oset)
|
||||
}
|
||||
return(REAL_FUNC(pthread_sigmask)(how, set, oset));
|
||||
}
|
||||
#endif
|
||||
#endif /* !GC_DARWIN_THREADS */
|
||||
|
||||
/* Wrappers for functions that are likely to block for an appreciable */
|
||||
@@ -1319,17 +1256,6 @@ int WRAP_FUNC(pthread_join)(pthread_t thread, void **retval)
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef NACL
|
||||
/* Native Client doesn't support pthread cleanup functions, */
|
||||
/* so wrap pthread_exit and manually cleanup the thread. */
|
||||
void
|
||||
WRAP_FUNC(pthread_exit)(void *status)
|
||||
{
|
||||
GC_thread_exit_proc(0);
|
||||
REAL_FUNC(pthread_exit)(status);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
WRAP_FUNC(pthread_detach)(pthread_t thread)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,6 @@ man_MANS = \
|
||||
mdvalidater.1 \
|
||||
mkbundle.1 \
|
||||
mono.1 \
|
||||
mprof-report.1 \
|
||||
mono-cil-strip.1 \
|
||||
mono-config.5 \
|
||||
monodocer.1 \
|
||||
|
||||
+1
-18
@@ -1,10 +1,8 @@
|
||||
.\"
|
||||
.\" certmgr manual page.
|
||||
.\" Copyright 2004-2005 Novell
|
||||
.\" Copyright 2010 Pablo Ruiz
|
||||
.\" Author:
|
||||
.\" Sebastien Pouliot <[email protected]>
|
||||
.\" Pablo Ruiz Garcia <[email protected]>
|
||||
.\"
|
||||
.TH Mono "certmgr"
|
||||
.SH NAME
|
||||
@@ -26,9 +24,7 @@ server certificates.
|
||||
List the certificates, CTL or CTL in the specified store.
|
||||
.TP
|
||||
.I "-add"
|
||||
Add a certificate, CRL or CTL to specified store. If filename it's a pkcs12
|
||||
or pfx file, and it contains a private key, it will be imported to local key
|
||||
pair container.
|
||||
Add a certificate, CRL or CTL to specified store.
|
||||
.TP
|
||||
.I "-del"
|
||||
Remove a certificate, CRL or CTL from specified store. You must specify the
|
||||
@@ -48,11 +44,6 @@ This action assume an certificate (-c) object type and will import the
|
||||
certificates in appropriate stores (i.e. server certificate in the
|
||||
OtherPeople store, the root certificate in the Trust store, any other
|
||||
intermediate certificates in the IntermediateCA store).
|
||||
.TP
|
||||
.I "-importKey"
|
||||
Allows importing a private key from a pkcs12 file into a local key pair
|
||||
store. (Usefull when you already have the key's corresponding certificate
|
||||
installed at the specific store.)
|
||||
|
||||
.SH OBJECT TYPES
|
||||
.TP
|
||||
@@ -75,9 +66,6 @@ Use the machine's certificate stores (instead of the default user's stores).
|
||||
.I "-v"
|
||||
More details displayed on the console.
|
||||
.TP
|
||||
.I "-p password"
|
||||
Use the specify password when accessing a pkcs12 file.
|
||||
.TP
|
||||
.I "-help", "-h", "-?", "/?"
|
||||
Display help about this tool.
|
||||
|
||||
@@ -100,9 +88,6 @@ The filenames either starts with
|
||||
(subject key identifier).
|
||||
.TP
|
||||
The rest of the filename is the base64-encoded value (tbp or ski).
|
||||
.TP
|
||||
Private key data is stored under
|
||||
.I ~/.config/.mono/keypairs/
|
||||
|
||||
.SH EXAMPLES
|
||||
.TP
|
||||
@@ -155,8 +140,6 @@ element of your machine.config file.
|
||||
|
||||
.SH AUTHOR
|
||||
Written by Sebastien Pouliot
|
||||
|
||||
Minor additions by Pablo Ruiz García
|
||||
.SH COPYRIGHT
|
||||
Copyright (C) 2004-2005 Novell.
|
||||
.SH MAILING LISTS
|
||||
|
||||
+1
-19
@@ -6,7 +6,7 @@
|
||||
.SH NAME
|
||||
csharp, gsharp \- Interactive C# Shell
|
||||
.SH SYNOPSIS
|
||||
.B csharp [--attach PID] [-e EXPRESSION] [file1 [file2]]
|
||||
.B csharp [--attach PID] [file1 [file2]]
|
||||
[options]
|
||||
.P
|
||||
.B gsharp [file1 [file2]]
|
||||
@@ -29,22 +29,7 @@ target process.
|
||||
.PP
|
||||
Files specified in the command line will be loaded and executed as
|
||||
scripts.
|
||||
.PP
|
||||
Starting with Mono 2.10, the
|
||||
.I csharp
|
||||
command can be used as an interpreter executed by executables flagged
|
||||
with the Unix execute attribute. To do this, make the first line of
|
||||
your C# source code look like this:
|
||||
.nf
|
||||
"#!/usr/bin/csharp"
|
||||
Console.WriteLine ("Hello, World");
|
||||
.fi
|
||||
.SH OPTIONS
|
||||
The commands accept all of the commands that are available to the
|
||||
.I mcs
|
||||
command, so you can reference assemblies, specify paths, language
|
||||
level and so on from the command line. In addition, the following
|
||||
command line options are supported:
|
||||
.TP
|
||||
.I "\-\-attach"
|
||||
This is an advanced option and should only be used if you have a deep
|
||||
@@ -57,9 +42,6 @@ special measures to avoid crashing the target application while using
|
||||
it. For example, you might have to take the proper locks before
|
||||
issuing any commands that might affect the target process state, or
|
||||
sending commands through a method dispatcher.
|
||||
.TP
|
||||
.I "\-e" EXPRESSION
|
||||
This will evaluate the specified C# EXPRESSION and exit
|
||||
.SH OPERATION
|
||||
Once you launch the csharp command, you will be greeted with the
|
||||
interactive prompt:
|
||||
|
||||
@@ -351,11 +351,6 @@ shell will perform globbing, so you might want to use it like this:
|
||||
$ mcs -recurse:'*.cs'
|
||||
.fi
|
||||
.TP
|
||||
.I \-sdk:VERSION
|
||||
Used to specify the version of Base Class Library assemblies. The possible
|
||||
values are: 2 (default), 4. The version number means which .NET version
|
||||
should the produced assembly be compatible with.
|
||||
.TP
|
||||
.I \-\-shell
|
||||
Starts up the compiler in interactive mode, providing a C# shell for
|
||||
statements and expressions. A shortcut is to use the
|
||||
|
||||
+406
-72
@@ -422,10 +422,6 @@ Turns on profiling. For more information about profiling applications
|
||||
and code coverage see the sections "PROFILING" and "CODE COVERAGE"
|
||||
below.
|
||||
.TP
|
||||
This option can be used multiple times, each time will load an
|
||||
additional profiler. This allows developers to use modules that
|
||||
extend the JIT through the Mono profiling interface.
|
||||
.TP
|
||||
\fB--trace[=expression]\fR
|
||||
Shows method names as they are invoked. By default all methods are
|
||||
traced.
|
||||
@@ -638,22 +634,412 @@ Note that the statistical profiler has a very low overhead and should
|
||||
be the preferred profiler to use (for better output use the full path
|
||||
to the mono binary when running and make sure you have installed the
|
||||
addr2line utility that comes from the binutils package).
|
||||
.SH LOG PROFILER
|
||||
This is the most advanced profiler.
|
||||
.SH LOGGING PROFILER
|
||||
.PP
|
||||
The Mono \f[I]log\f[] profiler can be used to collect a lot of
|
||||
information about a program running in the Mono runtime.
|
||||
This data can be used (both while the process is running and later)
|
||||
to do analyses of the program behaviour, determine resource usage,
|
||||
performance issues or even look for particular execution patterns.
|
||||
The
|
||||
.I logging profiler
|
||||
is a general purpose profiler that can track many different kinds of
|
||||
events and logs those into a file as the program executes. This is
|
||||
different than previous profilers in Mono that kept the information in
|
||||
memory and rendered a summary of the results when the program shut
|
||||
down.
|
||||
.PP
|
||||
This is accomplished by logging the events provided by the Mono
|
||||
runtime through the profiling interface and periodically writing
|
||||
them to a file which can be later inspected with the mprof-report(1)
|
||||
tool.
|
||||
Using the logging profiler means that useful information can be
|
||||
gathered for long-running applications, applications that terminate
|
||||
abormally (crashes, segfaults, complicated tear down processes) or
|
||||
when no data about the shutdown is required.
|
||||
.PP
|
||||
More information about how to use the log profiler is available on the
|
||||
mprof-report(1) page.
|
||||
The data collected by the running threads is kept independent of each
|
||||
other to minimize the runtime overhead and the information dumped into
|
||||
the log at regular intervals.
|
||||
.PP
|
||||
A sample use is very simple:
|
||||
.nf
|
||||
$ mono --profile=logging program.exe
|
||||
|
||||
$ mprof-decoder program.mprof
|
||||
.fi
|
||||
.PP
|
||||
In the above example the logging profiler is used in its default mode
|
||||
that merely records GC statistics for the execution of program.exe.
|
||||
The profiling data collected is stored in the file program.mprof. The
|
||||
mprof-decoder tool is then used to analyze the data.
|
||||
.PP
|
||||
You can instruct the logging profiler to record different one or more
|
||||
sets of events. These are the modes supported:
|
||||
.IP
|
||||
.I Statistical Profiling (stat)
|
||||
the program instruction pointer is periodically sampled to determine
|
||||
where the program is spending most of its time. Statistical
|
||||
profiling has a very low impact on a running application and it is
|
||||
very useful to get a general picture of where time is being spent on a
|
||||
program.
|
||||
.IP
|
||||
If call chains are requested, for each sample the profiler gets a
|
||||
partial stack trace (limited by the specified depth) so that
|
||||
caller-callee information is available.
|
||||
.IP
|
||||
.I Instrumenting:
|
||||
each method enter and exit is logged with a timestamp; further processing of
|
||||
the data can show the methods that took the longer to execute, with complete
|
||||
accounting for callers and callees. However, this way of profiling is rather
|
||||
intrusive and slows down the application significantly.
|
||||
.IP
|
||||
.I Allocation:
|
||||
each allocation is logged.
|
||||
.IP
|
||||
.I Allocation summary:
|
||||
shows, for each collection, a summary of the heap contents broken down by
|
||||
class (for each class the number of allocated and released objects is
|
||||
given, together with their aggregated size in bytes).
|
||||
.IP
|
||||
.I Heap snapshot mode:
|
||||
dumps the whole heap contents at every collection (or at user specified
|
||||
collections). It is also possible to request a collection and snapshot dump
|
||||
with a signal.
|
||||
.PP
|
||||
Moreover, other events can be logged and analyzed, like jit time for each
|
||||
method, load and unload for assemblies, modules and and individual classes,
|
||||
and appdomain and thread creation and destruction.
|
||||
.PP
|
||||
This profiler is activated passing the \fB--profile=logging\fR option to
|
||||
the mono runtime, and is controlled attaching further options, like
|
||||
\fB--profile=logging:statistical\fR for doing statistical profiling (multiple
|
||||
options are separated by commas).
|
||||
.PP
|
||||
As a quick primer, here are a few examples of the most common usage modes:
|
||||
.PP
|
||||
To perform statistical profiling:
|
||||
.nf
|
||||
|
||||
mono --profile=logging:stat program.exe
|
||||
.fi
|
||||
.PP
|
||||
To perform statistical profiling, inspecting call chains up to depth 8:
|
||||
.nf
|
||||
|
||||
mono --profile=logging:stat=8 program.exe
|
||||
.fi
|
||||
.PP
|
||||
To profile allocations (by default the call stack will be analized for
|
||||
each allocation, producing detailed caller method attribution infornation):
|
||||
.nf
|
||||
|
||||
mono --profile=logging:allocations program.exe
|
||||
.fi
|
||||
.PP
|
||||
To profile garbage collection activity at a high level (collection time and objects freed
|
||||
at each collection for each class are reported, but heap snapshots are not saved to disk):
|
||||
.nf
|
||||
|
||||
mono --profile=logging:allocations-summary program.exe
|
||||
.fi
|
||||
.PP
|
||||
To perform heap profiling taking heap snapshots:
|
||||
.nf
|
||||
|
||||
mono --profile=logging:heap=all program.exe
|
||||
.fi
|
||||
.PP
|
||||
To write the resulting data to a different file:
|
||||
.nf
|
||||
|
||||
mono --profile=logging:output=mydata.mprof program.exe
|
||||
.fi
|
||||
.PP
|
||||
Then you would need to invoke the decoder \fImprof-decoder(1)\fR
|
||||
on the output file to see the profiling results, or to examine heap
|
||||
snapshots and allocations in detail \fImprof-heap-viewer(1)\fR.
|
||||
.PP
|
||||
The operating modes described above are the default ones, and are sufficient
|
||||
to use the profiler.
|
||||
.PP
|
||||
To further customize the profiler behavior there are more options, described
|
||||
below.
|
||||
.PP
|
||||
These options can be individually enabled and disabled prefixing them
|
||||
with an (optional) '+' character or a '-' character. For instance,
|
||||
the "allocations" option by default records also the full call stack
|
||||
at each allocation. If only the caller is wanted, one should use
|
||||
"allocations,-save-allocation-stack", or to disable call tracking
|
||||
completely (making the profiler less intrusive)
|
||||
"allocations,-save-allocation-caller,-save-allocation-stack". In
|
||||
practice the "allocation" option by default behaves like
|
||||
"allocations,save-allocation-caller,save-allocation-stack", but the
|
||||
user can tune this to his needs.
|
||||
.PP
|
||||
These are all the available options, organized by category:
|
||||
.PP
|
||||
\fBExecution profiling modes\fR
|
||||
.RS
|
||||
.ne 8
|
||||
.TP
|
||||
\fIstatistical\fR, \fIstat\fR or \fIs\fR
|
||||
Performs statistical profiling. This is a lightweight profiling
|
||||
mechanism and it has a much lower overhead than the \fIenter-leave\fR
|
||||
profiling as it works by sampling where the program is spending its
|
||||
time by using a timer.
|
||||
If specified with \fIs=<number>\fR, also inspect call chains up to level
|
||||
<number>.
|
||||
.TP
|
||||
\fIenter-leave\fR, \fIcalls\fR or \fIc\fR
|
||||
Measure the time spent inside each method call, this is done by
|
||||
logging the time when a method enters and when the method leaves.
|
||||
This can be a time consuming operation.
|
||||
.TP
|
||||
\fIjit\fR, \fIj\fR
|
||||
Collect information about time spent by the JIT engine compiling
|
||||
methods.
|
||||
.ne
|
||||
.RE
|
||||
.PP
|
||||
\fBAllocation profiling modes\fR
|
||||
.RS
|
||||
.ne 8
|
||||
.TP
|
||||
\fIallocations\fR, \fIalloc\fR or \fIa\fR
|
||||
Collect information about each allocation (object class and size).
|
||||
By default this also implies "+save-allocation-caller" and
|
||||
"+save-allocation-stack".
|
||||
.TP
|
||||
\fIsave-allocation-caller\fR, \fIsac\fR
|
||||
Save the direct caller of each allocation. The profiler filters out wrapper
|
||||
methods, and also recognizes if the allocation has been performed by the
|
||||
runtime while jitting a method.
|
||||
.TP
|
||||
\fIsave-allocation-stack\fR, \fIsas\fR
|
||||
Save the full managed execution stack at each allocation.
|
||||
While the "sac" option saves the direct caller, this one records the whole
|
||||
stack trace.
|
||||
Note that in the call stack the wrapper methods are not filtered out.
|
||||
Anyway the "sac" and "sas" options can be combined, and the decoder will
|
||||
attribute the allocation to the correct method even if the wrapper is at the
|
||||
top of the stack trace.
|
||||
.TP
|
||||
\fIallocations-summary\fR or \fIas\fR
|
||||
At each collection dump a summary
|
||||
of the heap contents (for each class, the number and collective size of all
|
||||
live and freed heap objects). This very lightweight compared to full heap
|
||||
snapshots.
|
||||
.TP
|
||||
\fIunreachable\fR, \fIfree\fR or \fIf\fR
|
||||
Performs a lightweight profile of the garbage collector. On each
|
||||
collection performed by the GC, the list of unreachable objects is
|
||||
recorded, and for each object the class and size is provided. This
|
||||
information can be used to compute the heap size broken down by class
|
||||
(combined with "a" can give the same information of "as", but the log
|
||||
file contains info about each individual object, while in "as" the
|
||||
processing is done directly at runtime and the log file contains only
|
||||
the summarized data broken down by class).
|
||||
.TP
|
||||
\fIgc\fR or \fIg\fR
|
||||
Measure the time spent in each collection, and also trace heap resizes.
|
||||
.TP
|
||||
\fIheap-shot[=ARG]\fR, \fIheap[=ARG]\fR or \fIh[=ARH]\fR
|
||||
Performs full heap profiling. In this case on each
|
||||
collection a full heap snapshot is recorded to disk.
|
||||
Inside the snapshots, each object reference is still represented so
|
||||
that it's possible to investigate who is responsible for keeping objects
|
||||
alive.
|
||||
.PP
|
||||
If the value of ARG is
|
||||
.B all,
|
||||
a heap snapshot is taken at each collection.
|
||||
.PP
|
||||
If the value is an integer
|
||||
.B n,
|
||||
a snapshot will be taken at the first
|
||||
.B n
|
||||
collections (like setting
|
||||
.B gcd=n
|
||||
);
|
||||
.PP
|
||||
If no additional argument is given to the heap option, the only way to take
|
||||
heap snapshots is to requeste them using the runtime socket based command
|
||||
interface described below (see "Profiler activity control").
|
||||
.PP
|
||||
Heap profiling also enables full allocation profiling (with call
|
||||
stacks), and each allocation can be related to its corresponding
|
||||
object in the snapshots, enabling investigations like "find all
|
||||
objects of a given class allocated by a given method and still live at
|
||||
a given collection, and then find all objects referencing them".
|
||||
.PP
|
||||
This kind of heap snapshot analysis is performed using the mprof-heap-viewer(1)
|
||||
application.
|
||||
.PP
|
||||
The number of heap snapshots taken (and the moment in which they are taken)
|
||||
can be further customized with the following options:
|
||||
.TP
|
||||
\fIgc-dumps=N\fR, \fIgc-d=N\fR, \fIgcd=N\fR
|
||||
states the number of snapshots that must be dumped (since the application
|
||||
starts). Zero means no dumps at all, -1 means dump at all collections.
|
||||
.TP
|
||||
These options exist because it can happen that the user wants to investigate
|
||||
what happens during collections but without forcing a collection using the
|
||||
command interface, because forcing a collection alters the program behavior.
|
||||
Of course it is possible to simply take a snapshot at every collection, but
|
||||
in some workloads this is could not be feasible (too much data).
|
||||
So we have this "garbage collection dumps" counter to control how many
|
||||
snapshots to take.
|
||||
.ne
|
||||
.RE
|
||||
.PP
|
||||
\fBProfiler activity control\fR
|
||||
.RS
|
||||
.ne 8
|
||||
.TP
|
||||
\fIoutput=FILE\fR, \fIout=FILE\fR or \fIo=FILE\fR
|
||||
Use this option to provide the output file name for the profile log.
|
||||
If this option is not specified, it will default to "<program-name>.mprof".
|
||||
.TP
|
||||
\fIoutput-suffix=SUFFIX\fR, \fIsuffix=SUFFIX\fR or \fIos=SUFFIX\fR: makes
|
||||
the output file name equals to "<program-name>-SUFFIX.mprof".
|
||||
.TP
|
||||
\fIstart-enabled\fR or \fIse\fR: start with the profiler active
|
||||
(which is the default).
|
||||
.TP
|
||||
\fIstart-disabled\fR or \fIsd\fR: start with the profiler inactive.
|
||||
.TP
|
||||
\fIforce-accurate-timer\fR (or \fIfac\fR): the profiler by default uses
|
||||
rtdsc to acquire timestamps for frequent events, but this can be imprecise;
|
||||
using this option you force the use of "gettimeofday" at every event, which
|
||||
is more accurate but much slower.
|
||||
.TP
|
||||
\fIcommand-port=port\fR or \fIcp=port\fR (where port is an integer between
|
||||
1024 nd 65535):
|
||||
Choose a TCP port where the profiler will listen for user commands.
|
||||
The protocol is ASCII based and line oriented (one line per command), and the
|
||||
profiler answers with one line containing either "OK" or "ERROR" to each
|
||||
received command.
|
||||
.PP
|
||||
The user can telnet to this port and give commands manually, or a GUI can
|
||||
use this facility to control the profiler at runtime.
|
||||
.PP
|
||||
The available commands are:
|
||||
.TP
|
||||
\fIenable\fR: Enables the profiler.
|
||||
.TP
|
||||
\fIdisable\fR: Disables the profiler.
|
||||
.TP
|
||||
\fIheap-snapshot\fR: Takes a heap snapshot now (forces a full garbage collection).
|
||||
.TP
|
||||
\fIheap-snapshot-counter=arg\fR: Set the counter of the next heap snapshots
|
||||
that must be taken, where arg can be "all" (take a snapshot at every
|
||||
collection), "none" (do not take snapshots), or an integer "n" (take a heap
|
||||
snapshot for the next "n" collections).
|
||||
.ne
|
||||
.RE
|
||||
.PP
|
||||
\fBInternal buffer sizes\fR
|
||||
.RS
|
||||
.ne 8
|
||||
.TP
|
||||
\fIper-thread-buffer-size=N\fR, \fItbs=N\fR
|
||||
Use to specify the number of events that a thread buffer
|
||||
can hold. When the thread buffer is full, a log block is
|
||||
written to disk.
|
||||
.Sp
|
||||
This defaults to tbs=10000.
|
||||
.TP
|
||||
\fIstatistical-thread-buffer-size=N\fR, \fIsbs=N\fR
|
||||
The number of statistical samples that
|
||||
are held in memory before they are dumped to disk (the system does
|
||||
double-buffering and the statistical samples are written by a helper
|
||||
thread, so the statistical profiler never stops and is able to profile
|
||||
the profiler itself).
|
||||
.Sp
|
||||
This defaults to sbs=10000.
|
||||
.TP
|
||||
\fIwrite-buffer-size\fR, \fIwbs\fR
|
||||
Specifies the size in bytes of the internal write buffers.
|
||||
.Sp
|
||||
This defaults to wbs=1024.
|
||||
.ne
|
||||
.RE
|
||||
.PP
|
||||
In its current state, this profiler can also perform heap analysis
|
||||
like the HeapShot profiler, but there is no UI to process this
|
||||
information.
|
||||
.PP
|
||||
Another known issue is that if the timer is not strictly monotonic (like
|
||||
rtdsc), differences between times can underflow (they are handled as
|
||||
unsigned integers) and weird numbers can show up in the logs.
|
||||
.PP
|
||||
Finally, it can happen that when exceptions are thrown the profiler temporarily
|
||||
loses track of the execution stack and misattributes the caller for a few
|
||||
allocations (and method execution time).
|
||||
.PP
|
||||
The output file contains compressed events, to process the data you should
|
||||
use tools like the "Mono.Profiler" tool provided on the Mono SVN
|
||||
repository.
|
||||
.PP
|
||||
More explanations are provided here: "http://www.mono-project.com/LoggingProfiler".
|
||||
.SH EXTERNAL PROFILERS
|
||||
There are a number of external profilers that have been developed for
|
||||
Mono, we will update this section to contain the profilers.
|
||||
.PP
|
||||
The heap Shot profiler can track all live objects, and references to
|
||||
these objects, and includes a GUI tool, this is our recommended
|
||||
profiler.
|
||||
To install you must download the profiler
|
||||
from Mono's SVN:
|
||||
.nf
|
||||
svn co svn://anonsvn.mono-project.com/source/trunk/heap-shot
|
||||
cd heap-shot
|
||||
./autogen
|
||||
make
|
||||
make install
|
||||
.fi
|
||||
.PP
|
||||
See the included documentation for details on using it.
|
||||
.PP
|
||||
The Live Type profiler shows at every GC iteration all of the live
|
||||
objects of a given type. To install you must download the profiler
|
||||
from Mono's SVN:
|
||||
.nf
|
||||
svn co svn://anonsvn.mono-project.com/source/trunk/heap-prof
|
||||
cd heap-prof
|
||||
./autogen
|
||||
make
|
||||
make install
|
||||
.fi
|
||||
.PP
|
||||
To use the profiler, execute:
|
||||
.nf
|
||||
mono --profile=desc-heap program.exe
|
||||
.fi
|
||||
.PP
|
||||
The output of this profiler looks like this:
|
||||
.nf
|
||||
Checkpoint at 102 for heap-resize
|
||||
System.MonoType : 708
|
||||
System.Threading.Thread : 352
|
||||
System.String : 3230
|
||||
System.String[] : 104
|
||||
Gnome.ModuleInfo : 112
|
||||
System.Object[] : 160
|
||||
System.Collections.Hashtable : 96
|
||||
System.Int32[] : 212
|
||||
System.Collections.Hashtable+Slot[] : 296
|
||||
System.Globalization.CultureInfo : 108
|
||||
System.Globalization.NumberFormatInfo : 144
|
||||
.fi
|
||||
.PP
|
||||
The first line describes the iteration number for the GC, in this case
|
||||
checkpoint 102.
|
||||
.PP
|
||||
Then on each line the type is displayed as well as the number of bytes
|
||||
that are being consumed by live instances of this object.
|
||||
.PP
|
||||
The AOT profiler is used to feed back information to the AOT compiler
|
||||
about how to order code based on the access patterns for pages. To
|
||||
use it, use:
|
||||
.nf
|
||||
mono --profile=aot program.exe
|
||||
.fi
|
||||
The output of this profile can be fed back into Mono's AOT compiler to
|
||||
order the functions on the disk to produce precompiled images that
|
||||
have methods in sequential pages.
|
||||
.SH CUSTOM PROFILERS
|
||||
Mono provides a mechanism for loading other profiling modules which in
|
||||
the form of shared libraries. These profiling modules can hook up to
|
||||
@@ -1002,35 +1388,7 @@ The default is 512 megabytes.
|
||||
Specifies which write barrier to use. Options are `cardtable' and
|
||||
`remset'. The card table barrier is faster but less precise, and only
|
||||
supported for the Mark&Sweep major collector on 32 bit platforms. The
|
||||
default is `cardtable' if it is supported, otherwise `remset'. The cardtable
|
||||
write barrier is faster and has a more stable and usually smaller
|
||||
memory footprint. If the program causes too much pinning during
|
||||
thread scan, it might be faster to enable remset.
|
||||
.TP
|
||||
\fBevacuation-threshold=\fIthreshold\fR
|
||||
Sets the evacuation threshold in percent. This option is only available
|
||||
on the Mark&Sweep major collectors. The value must be an
|
||||
integer in the range 0 to 100. The default is 66. If the sweep phase of
|
||||
the collection finds that the occupancy of a specific heap block type is
|
||||
less than this percentage, it will do a copying collection for that block
|
||||
type in the next major collection, thereby restoring occupancy to close
|
||||
to 100 percent. A value of 0 turns evacuation off.
|
||||
.TP
|
||||
\fB(no-)concurrent-sweep\fR
|
||||
Enables or disables concurrent sweep for the Mark&Sweep collector. If
|
||||
enabled, the sweep phase of the garbage collection is done in a thread
|
||||
concurrently with the application. Concurrent sweep is disabled by
|
||||
default.
|
||||
.TP
|
||||
\fBstack-mark=\fImark-mode\fR
|
||||
Specifies how application threads should be scanned. Options are
|
||||
`precise` and `conservative`. Precise marking allow the collector
|
||||
to know what values on stack are references and what are not.
|
||||
Conservative marking threats all values as potentially references
|
||||
and leave them untouched. Precise marking reduces floating garbage
|
||||
and can speed up nursery collection and allocation rate, it has
|
||||
the downside of requiring a significant extra memory per compiled
|
||||
method. The right option, unfortunately, requires experimentation.
|
||||
default is `cardtable' if it is supported, otherwise `remset'.
|
||||
.ne
|
||||
.RE
|
||||
.TP
|
||||
@@ -1303,36 +1661,11 @@ trading off the small leaks for the increased performance
|
||||
unload the application domains on production systems, it is worth
|
||||
using this feature).
|
||||
.TP
|
||||
\fBdyn-runtime-invoke\fR
|
||||
Instructs the runtime to try to use a generic runtime-invoke wrapper
|
||||
instead of creating one invoke wrapper.
|
||||
.TP
|
||||
\fBgdb\fR
|
||||
Equivalent to setting the \fBMONO_XDEBUG\fR variable, this emits
|
||||
symbols into a shared library as the code is JITed that can be loaded
|
||||
into GDB to inspect symbols.
|
||||
.TP
|
||||
\fBgen-seq-points\fR
|
||||
Automatically generates sequence points where the
|
||||
IL stack is empty. These are places where the debugger can set a
|
||||
breakpoint.
|
||||
.TP
|
||||
\fBexplicit-null-checks\fR
|
||||
Makes the JIT generate an explicit NULL check on variable dereferences
|
||||
instead of depending on the operating system to raise a SIGSEGV or
|
||||
another form of trap event when an invalid memory location is
|
||||
accessed.
|
||||
.TP
|
||||
\fBhandle-sigint\fR
|
||||
Captures the interrupt signal (Control-C) and displays a stack trace
|
||||
when pressed. Useful to find out where the program is executing at a
|
||||
given point. This only displays the stack trace of a single thread.
|
||||
.TP
|
||||
\fBinit-stacks\FR
|
||||
Instructs the runtime to initialize the stack with
|
||||
some known values (0x2a on x86-64) at the start of a method to assist
|
||||
in debuggin the JIT engine.
|
||||
.TP
|
||||
\fBkeep-delegates\fR
|
||||
This option will leak delegate trampolines that are no longer
|
||||
referenced as to present the user with more information about a
|
||||
@@ -1356,6 +1689,7 @@ This option will disable the GDB backtrace emitted by the runtime
|
||||
after a SIGSEGV or SIGABRT in unmanaged code.
|
||||
.TP
|
||||
\fBsuspend-on-sigsegv\fR
|
||||
|
||||
This option will suspend the program when a native SIGSEGV is received.
|
||||
This is useful for debugging crashes which do not happen under gdb,
|
||||
since a live process contains more information than a core file.
|
||||
@@ -1450,7 +1784,7 @@ Mono JIT by default turns this on.
|
||||
\fBMONO_XDEBUG\fR
|
||||
When the the MONO_XDEBUG env var is set, debugging info for JITted
|
||||
code is emitted into a shared library, loadable into gdb. This enables,
|
||||
for example, to see managed frame names on gdb backtraces.
|
||||
for example, to see managed frame names on gdb backtraces.
|
||||
.TP
|
||||
\fBMONO_VERBOSE_METHOD\fR
|
||||
Enables the maximum JIT verbosity for the specified method. This is
|
||||
|
||||
@@ -1,524 +0,0 @@
|
||||
.TH mprof-report 1 ""
|
||||
.SH The Mono log profiler
|
||||
.PP
|
||||
The Mono \f[I]log\f[] profiler can be used to collect a lot of
|
||||
information about a program running in the Mono runtime.
|
||||
This data can be used (both while the process is running and later)
|
||||
to do analyses of the program behaviour, determine resource usage,
|
||||
performance issues or even look for particular execution patterns.
|
||||
.PP
|
||||
This is accomplished by logging the events provided by the Mono
|
||||
runtime through the profiling interface and periodically writing
|
||||
them to a file which can be later inspected with the command line
|
||||
\f[I]mprof-report\f[] program or with a GUI (not developed yet).
|
||||
.PP
|
||||
The events collected include (among others):
|
||||
.IP \[bu] 2
|
||||
method enter and leave
|
||||
.IP \[bu] 2
|
||||
object allocation
|
||||
.IP \[bu] 2
|
||||
garbage collection
|
||||
.IP \[bu] 2
|
||||
JIT compilation
|
||||
.IP \[bu] 2
|
||||
metadata loading
|
||||
.IP \[bu] 2
|
||||
lock contention
|
||||
.IP \[bu] 2
|
||||
exceptions
|
||||
.PP
|
||||
In addition, the profiler can periodically collect info about all
|
||||
the objects present in the heap at the end of a garbage collection
|
||||
(this is called heap shot and currently implemented only for the
|
||||
sgen garbage collector).
|
||||
Another available profiler mode is the \f[I]sampling\f[] or
|
||||
\f[I]statistical\f[] mode: periodically the program is sampled and
|
||||
the information about what the program was busy with is saved.
|
||||
This allows to get information about the program behaviour without
|
||||
degrading its performance too much (usually less than 10%).
|
||||
.SS Basic profiler usage
|
||||
.PP
|
||||
The simpler way to use the profiler is the following:
|
||||
.PP
|
||||
\f[B]mono\ --profile=log\ program.exe\f[]
|
||||
.PP
|
||||
At the end of the execution the file \f[I]output.mlpd\f[] will be
|
||||
found in the current directory.
|
||||
A summary report of the data can be printed by running:
|
||||
.PP
|
||||
\f[B]mprof-report\ output.mlpd\f[]
|
||||
.PP
|
||||
With this invocation a huge amount of data is collected about the
|
||||
program execution and collecting and saving this data can
|
||||
significantly slow down program execution.
|
||||
If saving the profiling data is not needed, a report can be
|
||||
generated directly with:
|
||||
.PP
|
||||
\f[B]mono\ --profile=log:report\ program.exe\f[]
|
||||
.PP
|
||||
If the information about allocations is not of interest, it can be
|
||||
excluded:
|
||||
.PP
|
||||
\f[B]mono\ --profile=log:noalloc\ program.exe\f[]
|
||||
.PP
|
||||
On the other hand, if method call timing is not important, while
|
||||
allocations are, the needed info can be gathered with:
|
||||
.PP
|
||||
\f[B]mono\ --profile=log:nocalls\ program.exe\f[]
|
||||
.PP
|
||||
You will still be able to inspect information about the sequence of
|
||||
calls that lead to each allocation because at each object
|
||||
allocation a stack trace is collected if full enter/leave
|
||||
information is not available.
|
||||
.PP
|
||||
To periodically collect heap shots (and exclude method and
|
||||
allocation events) use the following options (making sure you run
|
||||
with the sgen garbage collector):
|
||||
.PP
|
||||
\f[B]mono\ --gc=sgen\ --profile=log:heapshot\ program.exe\f[]
|
||||
.PP
|
||||
To perform a sampling profiler run, use the \f[I]sample\f[] option:
|
||||
.PP
|
||||
\f[B]mono\ --profile=log:sample\ program.exe\f[]
|
||||
.SS Profiler option documentation
|
||||
.PP
|
||||
By default the \f[I]log\f[] profiler will gather all the events
|
||||
provided by the Mono runtime and write them to a file named
|
||||
\f[I]output.mlpd\f[].
|
||||
When no option is specified, it is equivalent to using:
|
||||
.PP
|
||||
\f[B]--profile=log:calls,alloc,output=output.mlpd,maxframes=8,calldepth=100\f[]
|
||||
.PP
|
||||
The following options can be used to modify this default behaviour.
|
||||
Each option is separated from the next by a \f[B],\f[] character,
|
||||
with no spaces and all the options are included after the
|
||||
\f[I]log:\f[] profile module specifier.
|
||||
.IP \[bu] 2
|
||||
\f[I]help\f[]: display concise help info about each available
|
||||
option
|
||||
.IP \[bu] 2
|
||||
\f[I][no]alloc\f[]: \f[I]noalloc\f[] disables collecting object
|
||||
allocation info, \f[I]alloc\f[] enables it if it was disabled by
|
||||
another option like \f[I]heapshot\f[].
|
||||
.IP \[bu] 2
|
||||
\f[I][no]calls\f[]: \f[I]nocalls\f[] disables collecting method
|
||||
enter and leave events.
|
||||
When this option is used at each object allocation and at some
|
||||
other events (like lock contentions and exception throws) a stack
|
||||
trace is collected by default.
|
||||
See the \f[I]maxframes\f[] option to control this behaviour.
|
||||
\f[I]calls\f[] enables method enter/leave events if they were
|
||||
disabled by another option like \f[I]heapshot\f[].
|
||||
.IP \[bu] 2
|
||||
\f[I]heapshot[=MODE]\f[]: collect heap shot data at each major
|
||||
collection.
|
||||
The frequency of the heap shots can be changed with the
|
||||
\f[I]MODE\f[] parameter.
|
||||
When this option is used allocation events and method enter/leave
|
||||
events are not recorded by default: if they are needed, they need
|
||||
to be enabled explicitly.
|
||||
The optional parameter \f[I]MODE\f[] can modify the default heap
|
||||
shot frequency.
|
||||
heapshot can be used multiple times with different modes: in that
|
||||
case a heap shot is taken if either of the conditions are met.
|
||||
MODE can be one of:
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
\f[I]NUM\f[]ms: perform a heap shot if at least \f[I]NUM\f[]
|
||||
milliseconds passed since the last one.
|
||||
.IP \[bu] 2
|
||||
\f[I]NUM\f[]gc: perform a heap shot every \f[I]NUM\f[] major
|
||||
garbage collections
|
||||
.IP \[bu] 2
|
||||
\f[I]ondemand\f[]: perform a heap shot when such a command is sent
|
||||
to the control port
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
\f[I]sample[=TYPE[/FREQ]]\f[]: collect statistical samples of the
|
||||
program behaviour.
|
||||
The default is to collect a 1000 times per second the instruction
|
||||
pointer.
|
||||
This is equivalent to the value \[lq]cycles/1000\[rq] for
|
||||
\f[I]TYPE\f[].
|
||||
On some systems, like with recent Linux kernels, it is possible to
|
||||
cause the sampling to happen for other events provided by the
|
||||
performance counters of the cpu.
|
||||
In this case, \f[I]TYPE\f[] can be one of:
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
\f[I]cycles\f[]: processor cycles
|
||||
.IP \[bu] 2
|
||||
\f[I]instr\f[]: executed instructions
|
||||
.IP \[bu] 2
|
||||
\f[I]cacherefs\f[]: cache references
|
||||
.IP \[bu] 2
|
||||
\f[I]cachemiss\f[]: cache misses
|
||||
.IP \[bu] 2
|
||||
\f[I]branches\f[]: executed branches
|
||||
.IP \[bu] 2
|
||||
\f[I]branchmiss\f[]: mispredicted branches
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
\f[I]time=TIMER\f[]: use the TIMER timestamp mode.
|
||||
TIMER can have the following values:
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
\f[I]fast\f[]: a usually faster but possibly more inaccurate timer
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
\f[I]maxframes=NUM\f[]: when a stack trace needs to be performed,
|
||||
collect \f[I]NUM\f[] frames at the most.
|
||||
The default is 8.
|
||||
.IP \[bu] 2
|
||||
\f[I]calldepth=NUM\f[]: ignore method enter/leave events when the
|
||||
call chain depth is bigger than NUM.
|
||||
.IP \[bu] 2
|
||||
\f[I]zip\f[]: automatically compress the output data in gzip
|
||||
format.
|
||||
.IP \[bu] 2
|
||||
\f[I]output=OUTSPEC\f[]: instead of writing the profiling data to
|
||||
the output.mlpd file, substitute \f[I]%p\f[] in \f[I]OUTSPEC\f[]
|
||||
with the current process id and \f[I]%t\f[] with the current date
|
||||
and time, then do according to \f[I]OUTSPEC\f[]:
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
if \f[I]OUTSPEC\f[] begins with a \f[I]|\f[] character, execute the
|
||||
rest as a program and feed the data to its standard input
|
||||
.IP \[bu] 2
|
||||
if \f[I]OUTSPEC\f[] begins with a \f[I]-\f[] character, use the
|
||||
rest of OUTSPEC as the filename, but force overwrite any existing
|
||||
file by that name
|
||||
.IP \[bu] 2
|
||||
otherwise write the data the the named file: note that is a file by
|
||||
that name already exists, a warning is issued and profiling is
|
||||
disabled.
|
||||
.RE
|
||||
.IP \[bu] 2
|
||||
\f[I]report\f[]: the profiling data is sent to mprof-report, which
|
||||
will print a summary report.
|
||||
This is equivalent to the option: \f[B]output=mprof-report\ -\f[].
|
||||
If the \f[I]output\f[] option is specified as well, the report will
|
||||
be written to the output file instead of the console.
|
||||
.IP \[bu] 2
|
||||
\f[I]port=PORT\f[]: specify the tcp/ip port to use for the
|
||||
listening command server.
|
||||
Currently not available for windows.
|
||||
This server is started for example when heapshot=ondemand is used:
|
||||
it will read commands line by line.
|
||||
The following commands are available:
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
\f[I]heapshot\f[]: perform a heapshot as soon as possible
|
||||
.RE
|
||||
.SS Analyzing the profile data
|
||||
.PP
|
||||
Currently there is a command line program (\f[I]mprof-report\f[])
|
||||
to analyze the data produced by the profiler.
|
||||
This is ran automatically when the \f[I]report\f[] profiler option
|
||||
is used.
|
||||
Simply run:
|
||||
.PP
|
||||
\f[B]mprof-report\ output.mlpd\f[]
|
||||
.PP
|
||||
to see a summary report of the data included in the file.
|
||||
.SS Trace information for events
|
||||
.PP
|
||||
Often it is important for some events, like allocations, lock
|
||||
contention and exception throws to know where they happened.
|
||||
Or we may want to see what sequence of calls leads to a particular
|
||||
method invocation.
|
||||
To see this info invoke mprof-report as follows:
|
||||
.PP
|
||||
\f[B]mprof-report\ --traces\ output.mlpd\f[]
|
||||
.PP
|
||||
The maximum number of methods in each stack trace can be specified
|
||||
with the \f[I]\[em]maxframes=NUM\f[] option:
|
||||
.PP
|
||||
\f[B]mprof-report\ --traces\ --maxframes=4\ output.mlpd\f[]
|
||||
.PP
|
||||
The stack trace info will be available if method enter/leave events
|
||||
have been recorded or if stack trace collection wasn't explicitly
|
||||
disabled with the \f[I]maxframes=0\f[] profiler option.
|
||||
Note that the profiler will collect up to 8 frames by default at
|
||||
specific events when the \f[I]nocalls\f[] option is used, so in
|
||||
that case, if more stack frames are required in mprof-report, a
|
||||
bigger value for maxframes when profiling must be used, too.
|
||||
.PP
|
||||
The \f[I]\[em]traces\f[] option also controls the reverse reference
|
||||
feature in the heapshot report: for each class it reports how many
|
||||
references to objects of that class come from other classes.
|
||||
.SS Sort order for methods and allocations
|
||||
.PP
|
||||
When a list of methods is printed the default sort order is based
|
||||
on the total time spent in the method.
|
||||
This time is wall clock time (that is, it includes the time spent,
|
||||
for example, in a sleep call, even if actual cpu time would be
|
||||
basically 0).
|
||||
Also, if the method has been ran on different threads, the time
|
||||
will be a sum of the time used in each thread.
|
||||
.PP
|
||||
To change the sort order, use the option:
|
||||
.PP
|
||||
\f[B]--method-sort=MODE\f[]
|
||||
.PP
|
||||
where \f[I]MODE\f[] can be:
|
||||
.IP \[bu] 2
|
||||
\f[I]self\f[]: amount of time spent in the method itself and not in
|
||||
its callees
|
||||
.IP \[bu] 2
|
||||
\f[I]calls\f[]: the number of method invocations
|
||||
.IP \[bu] 2
|
||||
\f[I]total\f[]: the total time spent in the method.
|
||||
.PP
|
||||
Object allocation lists are sorted by default depending on the
|
||||
total amount of bytes used by each type.
|
||||
.PP
|
||||
To change the sort order of object allocations, use the option:
|
||||
.PP
|
||||
\f[B]--alloc-sort=MODE\f[]
|
||||
.PP
|
||||
where \f[I]MODE\f[] can be:
|
||||
.IP \[bu] 2
|
||||
\f[I]count\f[]: the number of allocated objects of the given type
|
||||
.IP \[bu] 2
|
||||
\f[I]bytes\f[]: the total number of bytes used by objects of the
|
||||
given type
|
||||
.SS Selecting what data to report
|
||||
.PP
|
||||
The profiler by default collects data about many runtime subsystems
|
||||
and mprof-report prints a summary of all the subsystems that are
|
||||
found in the data file.
|
||||
It is possible to tell mprof-report to only show information about
|
||||
some of them with the following option:
|
||||
.PP
|
||||
\f[B]--reports=R1[,R2...]\f[]
|
||||
.PP
|
||||
where the report names R1, R2 etc.
|
||||
can be:
|
||||
.IP \[bu] 2
|
||||
\f[I]header\f[]: information about program startup and profiler
|
||||
version
|
||||
.IP \[bu] 2
|
||||
\f[I]jit\f[]: JIT compiler information
|
||||
.IP \[bu] 2
|
||||
\f[I]sample\f[]: statistical sampling information
|
||||
.IP \[bu] 2
|
||||
\f[I]gc\f[]: garbage collection information
|
||||
.IP \[bu] 2
|
||||
\f[I]alloc\f[]: object allocation information
|
||||
.IP \[bu] 2
|
||||
\f[I]call\f[]: method profiling information
|
||||
.IP \[bu] 2
|
||||
\f[I]metadata\f[]: metadata events like image loads
|
||||
.IP \[bu] 2
|
||||
\f[I]exception\f[]: exception throw and handling information
|
||||
.IP \[bu] 2
|
||||
\f[I]monitor\f[]: lock contention information
|
||||
.IP \[bu] 2
|
||||
\f[I]thread\f[]: thread information
|
||||
.IP \[bu] 2
|
||||
\f[I]heapshot\f[]: live heap usage at heap shots
|
||||
.PP
|
||||
It is possible to limit some of the data displayed to a timeframe
|
||||
of the program execution with the option:
|
||||
.PP
|
||||
\f[B]--time=FROM-TO\f[]
|
||||
.PP
|
||||
where \f[I]FROM\f[] and \f[I]TO\f[] are seconds since application
|
||||
startup (they can be floating point numbers).
|
||||
.PP
|
||||
Another interesting option is to consider only events happening on
|
||||
a particular thread with the following option:
|
||||
.PP
|
||||
\f[B]--thread=THREADID\f[]
|
||||
.PP
|
||||
where \f[I]THREADID\f[] is one of the numbers listed in the thread
|
||||
summary report (or a thread name when present).
|
||||
.PP
|
||||
By default long lists of methods or other information like object
|
||||
allocations are limited to the most important data.
|
||||
To increase the amount of information printed you can use the
|
||||
option:
|
||||
.PP
|
||||
\f[B]--verbose\f[]
|
||||
.SS Track individual objects
|
||||
.PP
|
||||
Instead of printing the usual reports from the profiler data, it is
|
||||
possible to track some interesting information about some specific
|
||||
object addresses.
|
||||
The objects are selected based on their address with the
|
||||
\f[I]\[em]track\f[] option as follows:
|
||||
.PP
|
||||
\f[B]--track=0xaddr1[,0xaddr2,...]\f[]
|
||||
.PP
|
||||
The reported info (if available in the data file), will be class
|
||||
name, size, creation time, stack trace of creation (with the
|
||||
\f[I]\[em]traces\f[] option), etc.
|
||||
If heapshot data is available it will be possible to also track
|
||||
what other objects reference one of the listed addresses.
|
||||
.PP
|
||||
The object addresses can be gathered either from the profiler
|
||||
report in some cases (like in the monitor lock report), from the
|
||||
live application or they can be selected with the
|
||||
\f[I]\[em]find=FINDSPEC\f[] option.
|
||||
FINDSPEC can be one of the following:
|
||||
.IP \[bu] 2
|
||||
\f[I]S:SIZE\f[]: where the object is selected if it's size is at
|
||||
least \f[I]SIZE\f[]
|
||||
.IP \[bu] 2
|
||||
\f[I]T:NAME\f[]: where the object is selected if \f[I]NAME\f[]
|
||||
partially matches its class name
|
||||
.PP
|
||||
This option can be specified multiple times with one of the
|
||||
different kinds of FINDSPEC.
|
||||
For example, the following:
|
||||
.PP
|
||||
\f[B]--find=S:10000\ --find=T:Byte[]\f[]
|
||||
.PP
|
||||
will find all the byte arrays that are at least 10000 bytes in
|
||||
size.
|
||||
.PP
|
||||
Note that with a moving garbage collector the object address can
|
||||
change, so you may need to track the changed address manually.
|
||||
It can also happen that multiple objects are allocated at the same
|
||||
address, so the output from this option can become large.
|
||||
.SS Saving a profiler report
|
||||
.PP
|
||||
By default mprof-report will print the summary data to the console.
|
||||
To print it to a file, instead, use the option:
|
||||
.PP
|
||||
\f[B]--out=FILENAME\f[]
|
||||
.SS Dealing with profiler slowness
|
||||
.PP
|
||||
If the profiler needs to collect lots of data, the execution of the
|
||||
program will slow down significantly, usually 10 to 20 times
|
||||
slower.
|
||||
There are several ways to reduce the impact of the profiler on the
|
||||
program execution.
|
||||
.SS Use the statistical sampling mode
|
||||
.PP
|
||||
Statistical sampling allows executing a program under the profiler
|
||||
with minimal performance overhead (usually less than 10%).
|
||||
This mode allows checking where the program is spending most of
|
||||
it's execution time without significantly perturbing its behaviour.
|
||||
.SS Collect less data
|
||||
.PP
|
||||
Collecting method enter/leave events can be very expensive,
|
||||
especially in programs that perform many millions of tiny calls.
|
||||
The profiler option \f[I]nocalls\f[] can be used to avoid
|
||||
collecting this data or it can be limited to only a few call levels
|
||||
with the \f[I]calldepth\f[] option.
|
||||
.PP
|
||||
Object allocation information is expensive as well, though much
|
||||
less than method enter/leave events.
|
||||
If it's not needed, it can be skipped with the \f[I]noalloc\f[]
|
||||
profiler option.
|
||||
Note that when method enter/leave events are discarded, by default
|
||||
stack traces are collected at each allocation and this can be
|
||||
expensive as well.
|
||||
The impact of stack trace information can be reduced by setting a
|
||||
low value with the \f[I]maxframes\f[] option or by eliminating them
|
||||
completely, by setting it to 0.
|
||||
.PP
|
||||
The other major source of data is the heapshot profiler option:
|
||||
especially if the managed heap is big, since every object needs to
|
||||
be inspected.
|
||||
The \f[I]MODE\f[] parameter of the \f[I]heapshot\f[] option can be
|
||||
used to reduce the frequency of the heap shots.
|
||||
.SS Reduce the timestamp overhead
|
||||
.PP
|
||||
On many operating systems or architectures what actually slows down
|
||||
profiling is the function provided by the system to get timestamp
|
||||
information.
|
||||
The \f[I]time=fast\f[] profiler option can be usually used to speed
|
||||
up this operation, but, depending on the system, time accounting
|
||||
may have some level of approximation (though statistically the data
|
||||
should be still fairly valuable).
|
||||
.SS Dealing with the size of the data files
|
||||
.PP
|
||||
When collecting a lot of information about a profiled program, huge
|
||||
data files can be generated.
|
||||
There are a few ways to minimize the amount of data, for example by
|
||||
not collecting some of the more space-consuming information or by
|
||||
compressing the information on the fly or by just generating a
|
||||
summary report.
|
||||
.SS Reducing the amount of data
|
||||
.PP
|
||||
Method enter/leave events can be excluded completely with the
|
||||
\f[I]nocalls\f[] option or they can be limited to just a few levels
|
||||
of calls with the \f[I]calldepth\f[] option.
|
||||
For example, the option:
|
||||
.PP
|
||||
\f[B]calldepth=10\f[]
|
||||
.PP
|
||||
will ignore the method events when there are more than 10 managed
|
||||
stack frames.
|
||||
This is very useful for programs that have deep recursion or for
|
||||
programs that perform many millions of tiny calls deep enough in
|
||||
the call stack.
|
||||
The optimal number for the calldepth option depends on the program
|
||||
and it needs to be balanced between providing enough profiling
|
||||
information and allowing fast execution speed.
|
||||
.PP
|
||||
Note that by default, if method events are not recorded at all, the
|
||||
profiler will collect stack trace information at events like
|
||||
allocations.
|
||||
To avoid gathering this data, use the \f[I]maxframes=0\f[] profiler
|
||||
option.
|
||||
.PP
|
||||
Allocation events can be eliminated with the \f[I]noalloc\f[]
|
||||
option.
|
||||
.PP
|
||||
Heap shot data can also be huge: by default it is collected at each
|
||||
major collection.
|
||||
To reduce the frequency, you can specify a heapshot mode: for
|
||||
example to collect every 5 collections (including major and minor):
|
||||
.PP
|
||||
\f[B]heapshot=5gc\f[]
|
||||
.PP
|
||||
or when at least 5 seconds passed since the last heap shot:
|
||||
.PP
|
||||
\f[B]heapshot=5000ms\f[]
|
||||
.SS Compressing the data
|
||||
.PP
|
||||
To reduce the amout of disk space used by the data, the data can be
|
||||
compressed either after it has been generated with the gzip
|
||||
command:
|
||||
.PP
|
||||
\f[B]gzip\ -9\ output.mlpd\f[]
|
||||
.PP
|
||||
or it can be compressed automatically by using the \f[I]zip\f[]
|
||||
profiler option.
|
||||
Note that in this case there could be a significant slowdown of the
|
||||
profiled program.
|
||||
.PP
|
||||
The mprof-report program will tranparently deal with either
|
||||
compressed or uncompressed data files.
|
||||
.SS Generating only a summary report
|
||||
.PP
|
||||
Often it's enough to look at the profiler summary report to
|
||||
diagnose an issue and in this case it's possible to avoid saving
|
||||
the profiler data file to disk.
|
||||
This can be accomplished with the \f[I]report\f[] profiler option,
|
||||
which will basically send the data to the mprof-report program for
|
||||
display.
|
||||
.PP
|
||||
To have more control of what summary information is reported (or to
|
||||
use a completely different program to decode the profiler data),
|
||||
the \f[I]output\f[] profiler option can be used, with \f[B]|\f[] as
|
||||
the first character: the rest of the output name will be executed
|
||||
as a program with the data fed in on the standard input.
|
||||
.PP
|
||||
For example, to print only the Monitor summary with stack trace
|
||||
information, you could use it like this:
|
||||
.PP
|
||||
\f[B]output=|mprof-report\ --reports=monitor\ --traces\ -\f[]
|
||||
.SH WEB SITE
|
||||
http://www.mono-project.com/Profiler
|
||||
.SH SEE ALSO
|
||||
.PP
|
||||
mono(1)
|
||||
.SH AUTHORS
|
||||
Paolo Molaro.
|
||||
|
||||
+3
-8
@@ -73,10 +73,9 @@ to $prefix/lib/mono/xbuild . When used in Import, like:
|
||||
|
||||
xbuild tries various values for the msbuild property $(MSBuildExtensionsPath), in order:
|
||||
|
||||
1. /Library/Frameworks/Mono.framework/External/xbuild on Mac OSX.
|
||||
2. Paths specified in the environment variable $MSBuildExtensionsPath.
|
||||
3. $XDG_CONFIG_HOME/xbuild/tasks (or Environment.SpecialFolder.ApplicationData)
|
||||
4. $prefix/lib/mono/xbuild (default location)
|
||||
1. Paths specified in the environment variable $MSBuildExtensionsPath.
|
||||
2. $XDG_CONFIG_HOME/xbuild/tasks (or Environment.SpecialFolder.ApplicationData)
|
||||
3. $prefix/lib/mono/xbuild (default location)
|
||||
|
||||
Anywhere else in the project files, $(MSBuildExtensionsPath) will always resolve to the default
|
||||
location. This is a xbuild-only feature.
|
||||
@@ -112,10 +111,6 @@ For example, you could set this variable from your shell:
|
||||
You can disable the built-in color scheme by setting this variable to
|
||||
"disable".
|
||||
|
||||
.SH NOTES
|
||||
On Mac OSX, for locating pkg-config (.pc) files, xbuild additionally
|
||||
looks in "/Library/Frameworks/Mono.framework/External/pkgconfig" .
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR mono(1), mcs(1)
|
||||
.SH COPYRIGHT
|
||||
|
||||
+2
-1
@@ -13,8 +13,9 @@ tests/?mcs.log
|
||||
tests/gtest-*.dll
|
||||
tests/test-*.dll
|
||||
tests/xml-*.xml
|
||||
tests/?xml-*.xml
|
||||
tests/test-*.netmodule
|
||||
tests/gxml-*.xml
|
||||
tests/test-*.xml
|
||||
tests/data.xml
|
||||
class/Mono.Data.Sqlite/test.db
|
||||
class/Mono.CSharp/Mono.CSharp.dll.sources
|
||||
|
||||
+20
-13
@@ -3,13 +3,16 @@ thisdir := .
|
||||
SUBDIRS := build jay mcs class nunit24 ilasm tools tests errors docs
|
||||
|
||||
basic_SUBDIRS := build jay mcs class tools
|
||||
net_2_0_SUBDIRS := build class nunit24 ilasm tools tests errors mcs
|
||||
moonlight_raw_SUBDIRS := build class tools mcs
|
||||
moonlight_SUBDIRS := tools
|
||||
monodroid_SUBDIRS := build class mcs
|
||||
monotouch_SUBDIRS := build class mcs
|
||||
net_2_0_bootstrap_SUBDIRS := build tools
|
||||
net_2_0_SUBDIRS := build mcs class nunit24 ilasm tools tests errors
|
||||
moonlight_bootstrap_SUBDIRS := build mcs class
|
||||
moonlight_raw_SUBDIRS := build mcs class tools
|
||||
moonlight_SUBDIRS := tools tests errors
|
||||
monotouch_SUBDIRS := build mcs class
|
||||
monotouch_bootstrap_SUBDIRS := build mcs class
|
||||
net_3_5_SUBDIRS := build class tools/xbuild
|
||||
net_4_0_SUBDIRS := build class nunit24 ilasm tools tests errors mcs docs
|
||||
net_4_0_bootstrap_SUBDIRS := build mcs class tools
|
||||
net_4_0_SUBDIRS := build mcs class nunit24 ilasm tools tests errors docs
|
||||
|
||||
# List of test subdirs that should pass 100%
|
||||
centum_tests := \
|
||||
@@ -100,13 +103,16 @@ profiles-do--run-test:
|
||||
|
||||
# Orchestrate the bootstrap here.
|
||||
_boot_ = all clean install
|
||||
$(_boot_:%=profile-do--net_4_0--%): profile-do--net_4_0--%: profile-do--basic--%
|
||||
$(_boot_:%=profile-do--net_4_0--%): profile-do--net_4_0--%: profile-do--net_4_0_bootstrap--%
|
||||
$(_boot_:%=profile-do--net_4_0_bootstrap--%): profile-do--net_4_0_bootstrap--%: profile-do--net_2_0--%
|
||||
$(_boot_:%=profile-do--net_3_5--%): profile-do--net_3_5--%: profile-do--net_2_0--%
|
||||
$(_boot_:%=profile-do--moonlight--%): profile-do--moonlight--%: profile-do--moonlight_raw--%
|
||||
$(_boot_:%=profile-do--monodroid--%): profile-do--monodroid--%: profile-do--basic--%
|
||||
$(_boot_:%=profile-do--monotouch--%): profile-do--monotouch--%: profile-do--basic--%
|
||||
$(_boot_:%=profile-do--moonlight_raw--%): profile-do--moonlight_raw--%: profile-do--basic--%
|
||||
$(_boot_:%=profile-do--net_2_0--%): profile-do--net_2_0--%: profile-do--basic--%
|
||||
$(_boot_:%=profile-do--moonlight--%): profile-do--moonlight--%: profile-do--moonlight_raw--%
|
||||
$(_boot_:%=profile-do--monotouch--%): profile-do--monotouch--%: profile-do--monotouch_bootstrap--%
|
||||
$(_boot_:%=profile-do--monotouch_bootstrap--%): profile-do--monotouch_bootstrap--%: profile-do--net_2_0--%
|
||||
$(_boot_:%=profile-do--moonlight_raw--%): profile-do--moonlight_raw--%: profile-do--moonlight_bootstrap--%
|
||||
$(_boot_:%=profile-do--moonlight_bootstrap--%): profile-do--moonlight_bootstrap--%: profile-do--basic--%
|
||||
$(_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--basic--%
|
||||
|
||||
testcorlib:
|
||||
@cd class/corlib && $(MAKE) test run-test
|
||||
@@ -132,7 +138,8 @@ DISTFILES = \
|
||||
MonoIcon.png \
|
||||
README \
|
||||
ScalableMonoIcon.svg \
|
||||
winexe.in
|
||||
winexe.in \
|
||||
nunit.key
|
||||
|
||||
dist-local: dist-default
|
||||
|
||||
|
||||
@@ -17,10 +17,13 @@ common/Consts.cs: common/Consts.cs.in $(wildcard config.make)
|
||||
PLATFORMS = darwin linux win32
|
||||
PROFILES = \
|
||||
basic \
|
||||
net_2_0_bootstrap \
|
||||
net_2_0 \
|
||||
moonlight_bootstrap \
|
||||
moonlight_raw \
|
||||
moonlight \
|
||||
net_3_5 \
|
||||
net_4_0_bootstrap \
|
||||
net_4_0
|
||||
|
||||
COMMON_SRCS = \
|
||||
|
||||
@@ -39,7 +39,7 @@ static class Consts
|
||||
public const string MonoProduct = "MONO Common language infrastructure";
|
||||
public const string MonoCopyright = "(c) various MONO Authors";
|
||||
|
||||
#if NET_4_0
|
||||
#if NET_4_0 || BOOTSTRAP_NET_4_0
|
||||
public const string FxVersion = "4.0.0.0";
|
||||
public const string FxFileVersion = "4.0.30319.1";
|
||||
|
||||
@@ -62,7 +62,7 @@ static class Consts
|
||||
public const string VsVersion = "9.0.0.0"; // unused, but needed for compilation
|
||||
public const string FxFileVersion = "4.0.50524.0";
|
||||
public const string VsFileVersion = "9.0.50727.42"; // unused, but needed for compilation
|
||||
#elif NET_2_0
|
||||
#elif NET_2_0 || BOOTSTRAP_NET_2_0
|
||||
// Versions of .NET Framework 2.0 RTM
|
||||
public const string FxVersion = "2.0.0.0";
|
||||
public const string VsVersion = "8.0.0.0";
|
||||
@@ -82,7 +82,9 @@ static class Consts
|
||||
|
||||
public const string AssemblyI18N = "I18N, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=0738eb9f132ed756";
|
||||
public const string AssemblyMicrosoft_VisualStudio = "Microsoft.VisualStudio, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
|
||||
#if NET_2_0
|
||||
public const string AssemblyMicrosoft_VisualStudio_Web = "Microsoft.VisualStudio.Web, Version=" + VsVersion + ", Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
|
||||
#endif
|
||||
public const string AssemblyMicrosoft_VSDesigner = "Microsoft.VSDesigner, Version=" + VsVersion + ", Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
|
||||
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";
|
||||
@@ -100,7 +102,7 @@ static class Consts
|
||||
public const string AssemblySystem_ServiceProcess = "System.ServiceProcess, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
|
||||
public const string AssemblySystem_Web = "System.Web, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
|
||||
public const string AssemblySystem_Windows_Forms = "System.Windows.Forms, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=b77a5c561934e089";
|
||||
#if NET_4_0
|
||||
#if NET_4_0 || BOOTSTRAP_NET_4_0
|
||||
public const string AssemblySystem_2_0 = "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
|
||||
public const string AssemblySystemCore_3_5 = "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
|
||||
public const string AssemblySystem_Core = "System.Core, Version=" + FxVersion + ", Culture=neutral, PublicKeyToken=b77a5c561934e089";
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
//
|
||||
|
||||
namespace System {
|
||||
#pragma warning disable 436
|
||||
|
||||
[AttributeUsage (AttributeTargets.All, AllowMultiple=true)]
|
||||
internal class MonoTODOAttribute : Attribute {
|
||||
|
||||
@@ -97,5 +97,4 @@ namespace System {
|
||||
{
|
||||
}
|
||||
}
|
||||
#pragma warning restore 436
|
||||
}
|
||||
@@ -233,8 +233,6 @@ $(the_lib): $(build_lib)
|
||||
$(Q) test ! -f $(build_lib:.dll=.pdb) || mv $(build_lib:.dll=.pdb) $(the_lib:.dll=.pdb)
|
||||
endif
|
||||
|
||||
library_CLEAN_FILES += $(PROFILE)_aot.log
|
||||
|
||||
ifdef PLATFORM_AOT_SUFFIX
|
||||
Q_AOT=$(if $(V),,@echo "AOT [$(PROFILE)] $(notdir $(@))";)
|
||||
$(the_lib)$(PLATFORM_AOT_SUFFIX): $(the_lib)
|
||||
@@ -252,7 +250,7 @@ endif
|
||||
makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
|
||||
library_CLEAN_FILES += $(makefrag)
|
||||
$(makefrag): $(sourcefile)
|
||||
# @echo Creating $@ ...
|
||||
@echo Creating $@ ...
|
||||
@sed 's,^,$(build_lib): ,' $< >$@
|
||||
@if test ! -f $(sourcefile).makefrag; then :; else \
|
||||
cat $(sourcefile).makefrag >> $@ ; \
|
||||
@@ -270,7 +268,7 @@ $(response): $(sourcefile)
|
||||
@echo Converting $(sourcefile) to $@ ...
|
||||
@cat $(sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
|
||||
endif
|
||||
|
||||
|
||||
endif
|
||||
|
||||
-include $(makefrag)
|
||||
|
||||
@@ -8,7 +8,7 @@ use_monolite := $(wildcard $(monolite_flag))
|
||||
|
||||
ifdef use_monolite
|
||||
PROFILE_RUNTIME = $(with_mono_path_monolite) $(RUNTIME)
|
||||
BOOTSTRAP_MCS = $(PROFILE_RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/monolite/mcs.exe
|
||||
BOOTSTRAP_MCS = $(PROFILE_RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/monolite/gmcs.exe
|
||||
else
|
||||
PROFILE_RUNTIME = $(EXTERNAL_RUNTIME)
|
||||
BOOTSTRAP_MCS = $(EXTERNAL_MCS)
|
||||
@@ -60,7 +60,7 @@ do-profile-check: $(depsdir)/.stamp
|
||||
$(MAKE) $(MAKE_Q) $(PROFILE_OUT) || ok=false; \
|
||||
rm -f $(PROFILE_EXE) $(PROFILE_OUT); \
|
||||
if $$ok; then :; else \
|
||||
if test -f $(topdir)/class/lib/monolite/mcs.exe; then \
|
||||
if test -f $(topdir)/class/lib/monolite/gmcs.exe; then \
|
||||
$(MAKE) -s do-profile-check-monolite ; \
|
||||
else \
|
||||
echo "*** The compiler '$(BOOTSTRAP_MCS)' doesn't appear to be usable." 1>&2; \
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#! -*- makefile -*-
|
||||
|
||||
BOOTSTRAP_PROFILE = basic
|
||||
|
||||
BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
|
||||
profile-check:
|
||||
@:
|
||||
|
||||
DEFAULT_REFERENCES = -r:mscorlib.dll
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MOBILE -d:MONODROID -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES)
|
||||
FRAMEWORK_VERSION = 2.1
|
||||
NO_TEST = yes
|
||||
|
||||
# the tuner takes care of the install
|
||||
NO_INSTALL = yes
|
||||
@@ -1,15 +1,17 @@
|
||||
#! -*- makefile -*-
|
||||
|
||||
BOOTSTRAP_PROFILE = basic
|
||||
my_runtime = $(RUNTIME) $(RUNTIME_FLAGS) --security=temporary-smcs-hack
|
||||
INTERNAL_SMCS = $(my_runtime) $(topdir)/class/lib/$(PROFILE)/smcs.exe
|
||||
|
||||
BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
BOOTSTRAP_PROFILE = monotouch_bootstrap
|
||||
|
||||
BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(my_runtime) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/smcs.exe
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_SMCS)
|
||||
|
||||
profile-check:
|
||||
@:
|
||||
|
||||
DEFAULT_REFERENCES = -r:mscorlib.dll
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MOBILE -d:MONOTOUCH -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES)
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MONOTOUCH
|
||||
FRAMEWORK_VERSION = 2.1
|
||||
NO_TEST = yes
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#! -*- makefile -*-
|
||||
|
||||
INTERNAL_SMCS = $(RUNTIME) $(RUNTIME_FLAGS) --security=temporary-smcs-hack $(topdir)/class/lib/$(PROFILE)/smcs.exe
|
||||
|
||||
BOOTSTRAP_PROFILE = net_2_0
|
||||
BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_SMCS)
|
||||
|
||||
# We can enable this if System.dll depends on features of the mscorlib.dll from this profile
|
||||
#PROFILE_MCS_HAS_BOOTSTRAP_FALLBACK = yes
|
||||
|
||||
profile-check:
|
||||
@:
|
||||
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MONOTOUCH
|
||||
FRAMEWORK_VERSION = 2.1
|
||||
NO_TEST = yes
|
||||
|
||||
# the tuner takes care of the install
|
||||
NO_INSTALL = yes
|
||||
@@ -0,0 +1,21 @@
|
||||
#! -*- makefile -*-
|
||||
|
||||
INTERNAL_SMCS = $(RUNTIME) $(RUNTIME_FLAGS) --security=temporary-smcs-hack $(topdir)/class/lib/$(PROFILE)/smcs.exe
|
||||
INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/basic/gmcs.exe
|
||||
|
||||
BOOTSTRAP_PROFILE = basic
|
||||
BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_SMCS)
|
||||
|
||||
# We can enable this if System.dll depends new features of the mscorlib.dll from this profile
|
||||
#PROFILE_MCS_HAS_BOOTSTRAP_FALLBACK = yes
|
||||
|
||||
profile-check:
|
||||
@:
|
||||
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MOONLIGHT
|
||||
FRAMEWORK_VERSION = 2.1
|
||||
NO_TEST = yes
|
||||
|
||||
# the tuner takes care of the install
|
||||
NO_INSTALL = yes
|
||||
@@ -1,15 +1,17 @@
|
||||
#! -*- makefile -*-
|
||||
|
||||
BOOTSTRAP_PROFILE = basic
|
||||
my_runtime = $(RUNTIME) $(RUNTIME_FLAGS) --security=temporary-smcs-hack
|
||||
INTERNAL_SMCS = $(my_runtime) $(topdir)/class/lib/$(PROFILE)/smcs.exe
|
||||
|
||||
BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
BOOTSTRAP_PROFILE = moonlight_bootstrap
|
||||
|
||||
BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(my_runtime) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/smcs.exe
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_SMCS)
|
||||
|
||||
profile-check:
|
||||
@:
|
||||
|
||||
DEFAULT_REFERENCES = -r:mscorlib.dll
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MOONLIGHT -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES)
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MOONLIGHT
|
||||
FRAMEWORK_VERSION = 2.1
|
||||
NO_TEST = yes
|
||||
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
# -*- makefile -*-
|
||||
|
||||
BOOTSTRAP_PROFILE = basic
|
||||
BUILD_TOOLS_PROFILE = net_2_0_bootstrap
|
||||
BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
|
||||
# nuttzing!
|
||||
|
||||
profile-check:
|
||||
@:
|
||||
|
||||
DEFAULT_REFERENCES = -r:mscorlib.dll
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES)
|
||||
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -nowarn:1699
|
||||
FRAMEWORK_VERSION = 2.0
|
||||
@@ -0,0 +1,18 @@
|
||||
# -*- makefile -*-
|
||||
|
||||
#
|
||||
# Note that we're using the .NET 1.1 MCS but MONO_PATH points to the net_2_0_bootstrap directory.
|
||||
# We do it this way to get assembly version references right.
|
||||
#
|
||||
BOOTSTRAP_PROFILE = basic
|
||||
BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/gmcs.exe
|
||||
MCS = $(BOOTSTRAP_MCS)
|
||||
|
||||
profile-check:
|
||||
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0
|
||||
FRAMEWORK_VERSION = 2.0
|
||||
NO_SIGN_ASSEMBLY = yes
|
||||
NO_TEST = yes
|
||||
NO_INSTALL = yes
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
# -*- makefile -*-
|
||||
|
||||
BOOTSTRAP_PROFILE = basic
|
||||
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/net_2_0/gmcs.exe
|
||||
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$(topdir)/class/lib/net_2_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
# nuttzing!
|
||||
|
||||
profile-check:
|
||||
@:
|
||||
|
||||
DEFAULT_REFERENCES = -r:mscorlib.dll
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_5 -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) -lib:$(topdir)/class/lib/net_2_0 $(DEFAULT_REFERENCES)
|
||||
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_5
|
||||
FRAMEWORK_VERSION = 3.5
|
||||
|
||||
TEST_HARNESS = $(topdir)/class/lib/net_2_0/nunit-console.exe
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
# -*- makefile -*-
|
||||
|
||||
BOOTSTRAP_PROFILE = basic
|
||||
INTERNAL_DMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/dmcs.exe
|
||||
|
||||
BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_GMCS)
|
||||
BOOTSTRAP_PROFILE = net_4_0_bootstrap
|
||||
|
||||
BOOTSTAP_DMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/dmcs.exe
|
||||
BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(BOOTSTAP_DMCS)
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_DMCS)
|
||||
|
||||
# nuttzing!
|
||||
|
||||
profile-check:
|
||||
@:
|
||||
|
||||
DEFAULT_REFERENCES = -r:mscorlib.dll
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_0 -d:NET_3_5 -d:NET_4_0 -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES)
|
||||
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_0 -d:NET_3_5 -d:NET_4_0 -nowarn:1699
|
||||
FRAMEWORK_VERSION = 4.0
|
||||
@@ -0,0 +1,17 @@
|
||||
# -*- makefile -*-
|
||||
|
||||
BOOTSTRAP_PROFILE = net_2_0
|
||||
BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/gmcs.exe
|
||||
MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/dmcs.exe
|
||||
|
||||
# we have BOOTSTRAP_PROFILE listed in the MONO_PATH of MCS
|
||||
PROFILE_MCS_HAS_BOOTSTRAP_FALLBACK = yes
|
||||
|
||||
profile-check:
|
||||
|
||||
PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:BOOTSTRAP_NET_4_0
|
||||
FRAMEWORK_VERSION = 4.0
|
||||
NO_SIGN_ASSEMBLY = yes
|
||||
NO_TEST = yes
|
||||
NO_INSTALL = yes
|
||||
|
||||
@@ -36,13 +36,14 @@ INSTALL_DATA = $(INSTALL) -c -m 644
|
||||
INSTALL_BIN = $(INSTALL) -c -m 755
|
||||
INSTALL_LIB = $(INSTALL_BIN)
|
||||
MKINSTALLDIRS = $(SHELL) $(topdir)/mkinstalldirs
|
||||
INTERNAL_MCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/mcs.exe
|
||||
INTERNAL_MBAS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/mbas/mbas.exe
|
||||
INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/basic/mcs.exe
|
||||
INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/gmcs.exe
|
||||
INTERNAL_ILASM = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/ilasm.exe
|
||||
corlib = mscorlib.dll
|
||||
|
||||
ifndef BUILD_TOOLS_PROFILE
|
||||
BUILD_TOOLS_PROFILE = basic
|
||||
BUILD_TOOLS_PROFILE = $(BOOTSTRAP_PROFILE)
|
||||
endif
|
||||
|
||||
INTERNAL_RESGEN = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/resgen.exe
|
||||
@@ -196,6 +197,11 @@ dist-default:
|
||||
$(MKINSTALLDIRS) $(@D)
|
||||
touch $@
|
||||
|
||||
# Useful
|
||||
|
||||
withmcs:
|
||||
$(MAKE) MCS='$(INTERNAL_MCS)' BOOTSTRAP_MCS='$(INTERNAL_MCS)' all
|
||||
|
||||
## Documentation stuff
|
||||
|
||||
Q_MDOC =$(if $(V),,@echo "MDOC [$(PROFILE)] $(notdir $(@))";)
|
||||
|
||||
@@ -109,11 +109,11 @@ $(test_lib): $(the_assembly) $(test_response) $(test_nunit_dep)
|
||||
$(TEST_COMPILE) -target:library -out:$@ $(test_flags) $(LOCAL_TEST_COMPILER_ONDOTNET_FLAGS) @$(test_response)
|
||||
|
||||
$(test_response): $(test_sourcefile)
|
||||
# @echo Creating $@ ...
|
||||
@echo Creating $@ ...
|
||||
@sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
|
||||
|
||||
$(test_makefrag): $(test_response)
|
||||
# @echo Creating $@ ...
|
||||
@echo Creating $@ ...
|
||||
@sed 's,^,$(test_lib): ,' $< >$@
|
||||
|
||||
-include $(test_makefrag)
|
||||
|
||||
@@ -447,7 +447,7 @@ namespace I18N.CJK
|
||||
// Decoder that handles a rolling Shift-JIS state.
|
||||
sealed class CP932Decoder : DbcsEncoding.DbcsDecoder
|
||||
{
|
||||
private new JISConvert convert;
|
||||
private JISConvert convert;
|
||||
private int last_byte_count;
|
||||
private int last_byte_chars;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace I18N.Common
|
||||
{
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
|
||||
// This class provides an internal list of handlers, for runtime
|
||||
// engines that do not implement the altered "GetFile" semantics.
|
||||
@@ -210,20 +210,19 @@ public sealed class Handlers
|
||||
"I18N.West.ENCibm865"
|
||||
};
|
||||
|
||||
static Dictionary<string, string> aliases;
|
||||
static Hashtable aliases;
|
||||
public static string GetAlias (string name)
|
||||
{
|
||||
if (aliases == null)
|
||||
BuildHash ();
|
||||
|
||||
string v;
|
||||
aliases.TryGetValue (name, out v);
|
||||
return v;
|
||||
return aliases [name] as string;
|
||||
}
|
||||
|
||||
static void BuildHash ()
|
||||
{
|
||||
aliases = new Dictionary<string, string> (StringComparer.OrdinalIgnoreCase);
|
||||
aliases = new Hashtable (new CaseInsensitiveHashCodeProvider (),
|
||||
new CaseInsensitiveComparer ());
|
||||
|
||||
aliases.Add ("arabic", "iso_8859_6");
|
||||
aliases.Add ("csISOLatinArabic", "iso_8859_6");
|
||||
|
||||
@@ -48,12 +48,11 @@ using System.Runtime.CompilerServices;
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
#if NET_4_0
|
||||
[assembly: AssemblyVersion("4.84.0.0")]
|
||||
#elif NET_2_0
|
||||
#if NET_2_0
|
||||
[assembly: AssemblyVersion("2.84.0.0")]
|
||||
#else
|
||||
#error "No profile"
|
||||
// not worrying about the NET_1_0 profile for now.
|
||||
[assembly: AssemblyVersion("0.84.0.0")]
|
||||
#endif
|
||||
|
||||
[assembly: AssemblyDelaySign(true)]
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IKVM.Reflection
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class AmbiguousMatchException : Exception
|
||||
{
|
||||
public AmbiguousMatchException()
|
||||
{
|
||||
}
|
||||
|
||||
public AmbiguousMatchException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public AmbiguousMatchException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
private AmbiguousMatchException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IKVM.Reflection
|
||||
{
|
||||
public abstract class Assembly : ICustomAttributeProvider
|
||||
{
|
||||
internal readonly Universe universe;
|
||||
|
||||
internal Assembly(Universe universe)
|
||||
{
|
||||
this.universe = universe;
|
||||
}
|
||||
|
||||
public abstract Type[] GetTypes();
|
||||
public abstract string FullName { get; }
|
||||
public abstract AssemblyName GetName();
|
||||
public abstract string ImageRuntimeVersion { get; }
|
||||
public abstract Module ManifestModule { get; }
|
||||
public abstract MethodInfo EntryPoint { get; }
|
||||
public abstract string Location { get; }
|
||||
public abstract AssemblyName[] GetReferencedAssemblies();
|
||||
public abstract Module[] GetModules(bool getResourceModules);
|
||||
public abstract Module[] GetLoadedModules(bool getResourceModules);
|
||||
public abstract Module GetModule(string name);
|
||||
public abstract string[] GetManifestResourceNames();
|
||||
public abstract ManifestResourceInfo GetManifestResourceInfo(string resourceName);
|
||||
public abstract System.IO.Stream GetManifestResourceStream(string resourceName);
|
||||
|
||||
internal abstract Type GetTypeImpl(string typeName);
|
||||
|
||||
public Module[] GetModules()
|
||||
{
|
||||
return GetModules(true);
|
||||
}
|
||||
|
||||
public Module[] GetLoadedModules()
|
||||
{
|
||||
return GetLoadedModules(true);
|
||||
}
|
||||
|
||||
public AssemblyName GetName(bool copiedName)
|
||||
{
|
||||
return GetName();
|
||||
}
|
||||
|
||||
public bool ReflectionOnly
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public Type[] GetExportedTypes()
|
||||
{
|
||||
List<Type> list = new List<Type>();
|
||||
foreach (Type type in GetTypes())
|
||||
{
|
||||
if (type.IsVisible)
|
||||
{
|
||||
list.Add(type);
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public Type GetType(string typeName)
|
||||
{
|
||||
return GetType(typeName, false);
|
||||
}
|
||||
|
||||
public Type GetType(string typeName, bool throwOnError)
|
||||
{
|
||||
TypeNameParser parser = TypeNameParser.Parse(typeName, throwOnError);
|
||||
if (parser.Error)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (parser.AssemblyName != null)
|
||||
{
|
||||
if (throwOnError)
|
||||
{
|
||||
throw new ArgumentException("Type names passed to Assembly.GetType() must not specify an assembly.");
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return parser.Expand(GetTypeImpl(parser.FirstNamePart), this, throwOnError, typeName);
|
||||
}
|
||||
|
||||
public virtual Module LoadModule(string moduleName, byte[] rawModule)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public Module LoadModule(string moduleName, byte[] rawModule, byte[] rawSymbolStore)
|
||||
{
|
||||
return LoadModule(moduleName, rawModule);
|
||||
}
|
||||
|
||||
public bool IsDefined(Type attributeType, bool inherit)
|
||||
{
|
||||
return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit).Count != 0;
|
||||
}
|
||||
|
||||
public IList<CustomAttributeData> __GetCustomAttributes(Type attributeType, bool inherit)
|
||||
{
|
||||
return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit);
|
||||
}
|
||||
|
||||
public static string CreateQualifiedName(string assemblyName, string typeName)
|
||||
{
|
||||
return assemblyName == null ? typeName : typeName + ", " + assemblyName;
|
||||
}
|
||||
|
||||
public static Assembly GetAssembly(Type type)
|
||||
{
|
||||
return type.Assembly;
|
||||
}
|
||||
|
||||
public string CodeBase
|
||||
{
|
||||
get
|
||||
{
|
||||
string path = this.Location.Replace(System.IO.Path.DirectorySeparatorChar, '/');
|
||||
if (!path.StartsWith("/"))
|
||||
{
|
||||
path = "/" + path;
|
||||
}
|
||||
return "file://" + path;
|
||||
}
|
||||
}
|
||||
|
||||
internal abstract IList<CustomAttributeData> GetCustomAttributesData(Type attributeType);
|
||||
}
|
||||
}
|
||||
@@ -1,209 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Configuration.Assemblies;
|
||||
using System.IO;
|
||||
using IKVM.Reflection.Reader;
|
||||
|
||||
namespace IKVM.Reflection
|
||||
{
|
||||
public sealed class AssemblyName : ICloneable
|
||||
{
|
||||
private readonly System.Reflection.AssemblyName name;
|
||||
private string culture;
|
||||
|
||||
private AssemblyName(System.Reflection.AssemblyName name, string culture)
|
||||
{
|
||||
this.name = name;
|
||||
this.culture = culture;
|
||||
}
|
||||
|
||||
public AssemblyName()
|
||||
{
|
||||
name = new System.Reflection.AssemblyName();
|
||||
}
|
||||
|
||||
public AssemblyName(string assemblyName)
|
||||
{
|
||||
name = new System.Reflection.AssemblyName(assemblyName);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string str = name.ToString();
|
||||
if (culture != null)
|
||||
{
|
||||
str = str.Replace("Culture=neutral", "Culture=" + culture);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name.Name; }
|
||||
set { name.Name = value; }
|
||||
}
|
||||
|
||||
public CultureInfo CultureInfo
|
||||
{
|
||||
get { return name.CultureInfo; }
|
||||
set
|
||||
{
|
||||
name.CultureInfo = value;
|
||||
culture = null;
|
||||
}
|
||||
}
|
||||
|
||||
internal string Culture
|
||||
{
|
||||
set
|
||||
{
|
||||
culture = value;
|
||||
name.CultureInfo = CultureInfo.InvariantCulture;
|
||||
}
|
||||
}
|
||||
|
||||
public Version Version
|
||||
{
|
||||
get { return name.Version; }
|
||||
set { name.Version = value; }
|
||||
}
|
||||
|
||||
public StrongNameKeyPair KeyPair
|
||||
{
|
||||
get { return name.KeyPair == null ? null : new StrongNameKeyPair(name.KeyPair); }
|
||||
set { name.KeyPair = value == null ? null : value.keyPair; }
|
||||
}
|
||||
|
||||
public string CodeBase
|
||||
{
|
||||
get { return name.CodeBase; }
|
||||
set { name.CodeBase = value; }
|
||||
}
|
||||
|
||||
public ProcessorArchitecture ProcessorArchitecture
|
||||
{
|
||||
get { return (ProcessorArchitecture)name.ProcessorArchitecture; }
|
||||
set { name.ProcessorArchitecture = (System.Reflection.ProcessorArchitecture)value; }
|
||||
}
|
||||
|
||||
public AssemblyNameFlags Flags
|
||||
{
|
||||
get { return (AssemblyNameFlags)name.Flags; }
|
||||
set { name.Flags = (System.Reflection.AssemblyNameFlags)value; }
|
||||
}
|
||||
|
||||
public AssemblyVersionCompatibility VersionCompatibility
|
||||
{
|
||||
get { return name.VersionCompatibility; }
|
||||
set { name.VersionCompatibility = value; }
|
||||
}
|
||||
|
||||
public byte[] GetPublicKey()
|
||||
{
|
||||
return name.GetPublicKey();
|
||||
}
|
||||
|
||||
public void SetPublicKey(byte[] publicKey)
|
||||
{
|
||||
name.SetPublicKey(publicKey);
|
||||
}
|
||||
|
||||
public byte[] GetPublicKeyToken()
|
||||
{
|
||||
return name.GetPublicKeyToken();
|
||||
}
|
||||
|
||||
public void SetPublicKeyToken(byte[] publicKeyToken)
|
||||
{
|
||||
name.SetPublicKeyToken(publicKeyToken);
|
||||
}
|
||||
|
||||
public AssemblyHashAlgorithm HashAlgorithm
|
||||
{
|
||||
get { return name.HashAlgorithm; }
|
||||
set { name.HashAlgorithm = value; }
|
||||
}
|
||||
|
||||
public string FullName
|
||||
{
|
||||
get
|
||||
{
|
||||
string str = name.FullName;
|
||||
if (culture != null)
|
||||
{
|
||||
str = str.Replace("Culture=neutral", "Culture=" + culture);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
AssemblyName other = obj as AssemblyName;
|
||||
return other != null && other.FullName == this.FullName;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return FullName.GetHashCode();
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new AssemblyName((System.Reflection.AssemblyName)name.Clone(), culture);
|
||||
}
|
||||
|
||||
public static bool ReferenceMatchesDefinition(AssemblyName reference, AssemblyName definition)
|
||||
{
|
||||
return System.Reflection.AssemblyName.ReferenceMatchesDefinition(reference.name, definition.name);
|
||||
}
|
||||
|
||||
public static AssemblyName GetAssemblyName(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
path = Path.GetFullPath(path);
|
||||
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
ModuleReader module = new ModuleReader(null, null, fs, path);
|
||||
if (module.Assembly == null)
|
||||
{
|
||||
throw new BadImageFormatException("Module does not contain a manifest");
|
||||
}
|
||||
return module.Assembly.GetName();
|
||||
}
|
||||
}
|
||||
catch (IOException x)
|
||||
{
|
||||
throw new FileNotFoundException(x.Message, x);
|
||||
}
|
||||
catch (UnauthorizedAccessException x)
|
||||
{
|
||||
throw new FileNotFoundException(x.Message, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace IKVM.Reflection
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class BadImageFormatException : Exception
|
||||
{
|
||||
public BadImageFormatException()
|
||||
{
|
||||
}
|
||||
|
||||
public BadImageFormatException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public BadImageFormatException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
private BadImageFormatException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2010 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace IKVM.Reflection
|
||||
{
|
||||
public abstract class Binder
|
||||
{
|
||||
protected Binder()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public abstract MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state);
|
||||
public abstract FieldInfo BindToField(BindingFlags bindingAttr, FieldInfo[] match, object value, CultureInfo culture);
|
||||
public abstract object ChangeType(object value, Type type, CultureInfo culture);
|
||||
public abstract void ReorderArgumentArray(ref object[] args, object state);
|
||||
public abstract MethodBase SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers);
|
||||
public abstract PropertyInfo SelectProperty(BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers);
|
||||
}
|
||||
}
|
||||
@@ -1,224 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IKVM.Reflection
|
||||
{
|
||||
public abstract class ConstructorInfo : MethodBase
|
||||
{
|
||||
public static readonly string ConstructorName = ".ctor";
|
||||
public static readonly string TypeConstructorName = ".cctor";
|
||||
|
||||
internal abstract MethodInfo GetMethodInfo();
|
||||
|
||||
internal override MethodBase BindTypeParameters(Type type)
|
||||
{
|
||||
return new ConstructorInfoImpl((MethodInfo)GetMethodInfo().BindTypeParameters(type));
|
||||
}
|
||||
|
||||
public sealed override MemberTypes MemberType
|
||||
{
|
||||
get { return MemberTypes.Constructor; }
|
||||
}
|
||||
|
||||
public override bool ContainsGenericParameters
|
||||
{
|
||||
get { return GetMethodInfo().ContainsGenericParameters; }
|
||||
}
|
||||
|
||||
public sealed override ParameterInfo[] GetParameters()
|
||||
{
|
||||
ParameterInfo[] parameters = GetMethodInfo().GetParameters();
|
||||
for (int i = 0; i < parameters.Length; i++)
|
||||
{
|
||||
parameters[i] = new ParameterInfoWrapper(this, parameters[i]);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
private sealed class ParameterInfoWrapper : ParameterInfo
|
||||
{
|
||||
private readonly ConstructorInfo ctor;
|
||||
private readonly ParameterInfo forward;
|
||||
|
||||
internal ParameterInfoWrapper(ConstructorInfo ctor, ParameterInfo forward)
|
||||
{
|
||||
this.ctor = ctor;
|
||||
this.forward = forward;
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return forward.Name; }
|
||||
}
|
||||
|
||||
public override Type ParameterType
|
||||
{
|
||||
get { return forward.ParameterType; }
|
||||
}
|
||||
|
||||
public override ParameterAttributes Attributes
|
||||
{
|
||||
get { return forward.Attributes; }
|
||||
}
|
||||
|
||||
public override int Position
|
||||
{
|
||||
get { return forward.Position; }
|
||||
}
|
||||
|
||||
public override object RawDefaultValue
|
||||
{
|
||||
get { return forward.RawDefaultValue; }
|
||||
}
|
||||
|
||||
public override Type[] GetOptionalCustomModifiers()
|
||||
{
|
||||
return forward.GetOptionalCustomModifiers();
|
||||
}
|
||||
|
||||
public override Type[] GetRequiredCustomModifiers()
|
||||
{
|
||||
return forward.GetRequiredCustomModifiers();
|
||||
}
|
||||
|
||||
public override MemberInfo Member
|
||||
{
|
||||
get { return ctor; }
|
||||
}
|
||||
|
||||
public override int MetadataToken
|
||||
{
|
||||
get { return forward.MetadataToken; }
|
||||
}
|
||||
|
||||
internal override Module Module
|
||||
{
|
||||
get { return ctor.Module; }
|
||||
}
|
||||
|
||||
internal override IList<CustomAttributeData> GetCustomAttributesData(Type attributeType)
|
||||
{
|
||||
return forward.GetCustomAttributesData(attributeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sealed class ConstructorInfoImpl : ConstructorInfo
|
||||
{
|
||||
private readonly MethodInfo method;
|
||||
|
||||
internal ConstructorInfoImpl(MethodInfo method)
|
||||
{
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
ConstructorInfoImpl other = obj as ConstructorInfoImpl;
|
||||
return other != null && other.method.Equals(method);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return method.GetHashCode();
|
||||
}
|
||||
|
||||
public override MethodBody GetMethodBody()
|
||||
{
|
||||
return method.GetMethodBody();
|
||||
}
|
||||
|
||||
public override CallingConventions CallingConvention
|
||||
{
|
||||
get { return method.CallingConvention; }
|
||||
}
|
||||
|
||||
public override MethodAttributes Attributes
|
||||
{
|
||||
get { return method.Attributes; }
|
||||
}
|
||||
|
||||
public override MethodImplAttributes GetMethodImplementationFlags()
|
||||
{
|
||||
return method.GetMethodImplementationFlags();
|
||||
}
|
||||
|
||||
internal override int ParameterCount
|
||||
{
|
||||
get { return method.ParameterCount; }
|
||||
}
|
||||
|
||||
public override Type DeclaringType
|
||||
{
|
||||
get { return method.DeclaringType; }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return method.Name; }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return method.ToString();
|
||||
}
|
||||
|
||||
public override Module Module
|
||||
{
|
||||
get { return method.Module; }
|
||||
}
|
||||
|
||||
public override int MetadataToken
|
||||
{
|
||||
get { return method.MetadataToken; }
|
||||
}
|
||||
|
||||
internal override MethodInfo GetMethodInfo()
|
||||
{
|
||||
return method;
|
||||
}
|
||||
|
||||
internal override IList<CustomAttributeData> GetCustomAttributesData(Type attributeType)
|
||||
{
|
||||
return method.GetCustomAttributesData(attributeType);
|
||||
}
|
||||
|
||||
internal override MethodInfo GetMethodOnTypeDefinition()
|
||||
{
|
||||
return method.GetMethodOnTypeDefinition();
|
||||
}
|
||||
|
||||
internal override MethodSignature MethodSignature
|
||||
{
|
||||
get { return method.MethodSignature; }
|
||||
}
|
||||
|
||||
internal override int ImportTo(Emit.ModuleBuilder module)
|
||||
{
|
||||
return method.ImportTo(module);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,612 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009-2010 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using IKVM.Reflection.Reader;
|
||||
using IKVM.Reflection.Emit;
|
||||
using IKVM.Reflection.Metadata;
|
||||
|
||||
namespace IKVM.Reflection
|
||||
{
|
||||
public sealed class CustomAttributeData
|
||||
{
|
||||
internal static readonly IList<CustomAttributeData> EmptyList = new List<CustomAttributeData>(0).AsReadOnly();
|
||||
private Module module;
|
||||
private int index;
|
||||
private ConstructorInfo lazyConstructor;
|
||||
private IList<CustomAttributeTypedArgument> lazyConstructorArguments;
|
||||
private IList<CustomAttributeNamedArgument> lazyNamedArguments;
|
||||
|
||||
internal CustomAttributeData(Module module, int index)
|
||||
{
|
||||
this.module = module;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
internal CustomAttributeData(ConstructorInfo constructor, object[] args, List<CustomAttributeNamedArgument> namedArguments)
|
||||
{
|
||||
this.lazyConstructor = constructor;
|
||||
MethodSignature sig = constructor.MethodSignature;
|
||||
List<CustomAttributeTypedArgument> list = new List<CustomAttributeTypedArgument>();
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
{
|
||||
list.Add(new CustomAttributeTypedArgument(sig.GetParameterType(i), args[i]));
|
||||
}
|
||||
lazyConstructorArguments = list.AsReadOnly();
|
||||
if (namedArguments == null)
|
||||
{
|
||||
this.lazyNamedArguments = Empty<CustomAttributeNamedArgument>.Array;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.lazyNamedArguments = namedArguments.AsReadOnly();
|
||||
}
|
||||
}
|
||||
|
||||
internal CustomAttributeData(Assembly asm, ConstructorInfo constructor, ByteReader br)
|
||||
{
|
||||
this.lazyConstructor = constructor;
|
||||
if (br.Length == 0)
|
||||
{
|
||||
// it's legal to have an empty blob
|
||||
lazyConstructorArguments = Empty<CustomAttributeTypedArgument>.Array;
|
||||
lazyNamedArguments = Empty<CustomAttributeNamedArgument>.Array;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (br.ReadUInt16() != 1)
|
||||
{
|
||||
throw new BadImageFormatException();
|
||||
}
|
||||
lazyConstructorArguments = ReadConstructorArguments(asm, br, constructor);
|
||||
lazyNamedArguments = ReadNamedArguments(asm, br, br.ReadUInt16(), constructor.DeclaringType);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append('[');
|
||||
sb.Append(Constructor.DeclaringType.FullName);
|
||||
sb.Append('(');
|
||||
string sep = "";
|
||||
foreach (CustomAttributeTypedArgument arg in ConstructorArguments)
|
||||
{
|
||||
sb.Append(sep);
|
||||
sep = ", ";
|
||||
AppendValue(sb, arg);
|
||||
}
|
||||
foreach (CustomAttributeNamedArgument named in NamedArguments)
|
||||
{
|
||||
sb.Append(sep);
|
||||
sep = ", ";
|
||||
sb.Append(named.MemberInfo.Name);
|
||||
sb.Append(" = ");
|
||||
AppendValue(sb, named.TypedValue);
|
||||
}
|
||||
sb.Append(')');
|
||||
sb.Append(']');
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static void AppendValue(StringBuilder sb, CustomAttributeTypedArgument arg)
|
||||
{
|
||||
if (arg.ArgumentType == arg.ArgumentType.Module.universe.System_String)
|
||||
{
|
||||
sb.Append('"').Append(arg.Value).Append('"');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (arg.ArgumentType.IsEnum)
|
||||
{
|
||||
sb.Append('(');
|
||||
sb.Append(arg.ArgumentType.FullName);
|
||||
sb.Append(')');
|
||||
}
|
||||
sb.Append(arg.Value);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void ReadDeclarativeSecurity(Assembly asm, List<CustomAttributeData> list, int action, ByteReader br)
|
||||
{
|
||||
Universe u = asm.universe;
|
||||
if (br.PeekByte() == '.')
|
||||
{
|
||||
br.ReadByte();
|
||||
int count = br.ReadCompressedInt();
|
||||
for (int j = 0; j < count; j++)
|
||||
{
|
||||
Type type = ReadType(asm, br);
|
||||
ConstructorInfo constructor;
|
||||
if (type == u.System_Security_Permissions_HostProtectionAttribute && action == (int)System.Security.Permissions.SecurityAction.LinkDemand)
|
||||
{
|
||||
constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { u.System_Security_Permissions_SecurityAction }, null);
|
||||
}
|
||||
// LAMESPEC there is an additional length here (probably of the named argument list)
|
||||
ByteReader slice = br.Slice(br.ReadCompressedInt());
|
||||
// LAMESPEC the count of named arguments is a compressed integer (instead of UInt16 as NumNamed in custom attributes)
|
||||
list.Add(new CustomAttributeData(constructor, action, ReadNamedArguments(asm, slice, slice.ReadCompressedInt(), type)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// .NET 1.x format (xml)
|
||||
char[] buf = new char[br.Length / 2];
|
||||
for (int i = 0; i < buf.Length; i++)
|
||||
{
|
||||
buf[i] = br.ReadChar();
|
||||
}
|
||||
string xml = new String(buf);
|
||||
ConstructorInfo constructor = u.System_Security_Permissions_PermissionSetAttribute.GetConstructor(new Type[] { u.System_Security_Permissions_SecurityAction });
|
||||
List<CustomAttributeNamedArgument> args = new List<CustomAttributeNamedArgument>();
|
||||
args.Add(new CustomAttributeNamedArgument(u.System_Security_Permissions_PermissionSetAttribute.GetProperty("XML"),
|
||||
new CustomAttributeTypedArgument(u.System_String, xml)));
|
||||
list.Add(new CustomAttributeData(constructor, action, args));
|
||||
}
|
||||
}
|
||||
|
||||
private CustomAttributeData(ConstructorInfo constructor, int securityAction, IList<CustomAttributeNamedArgument> namedArguments)
|
||||
{
|
||||
Universe u = constructor.Module.universe;
|
||||
this.lazyConstructor = constructor;
|
||||
List<CustomAttributeTypedArgument> list = new List<CustomAttributeTypedArgument>();
|
||||
list.Add(new CustomAttributeTypedArgument(u.System_Security_Permissions_SecurityAction, securityAction));
|
||||
this.lazyConstructorArguments = list.AsReadOnly();
|
||||
this.lazyNamedArguments = namedArguments;
|
||||
}
|
||||
|
||||
private static Type ReadFieldOrPropType(Assembly asm, ByteReader br)
|
||||
{
|
||||
Universe u = asm.universe;
|
||||
switch (br.ReadByte())
|
||||
{
|
||||
case Signature.ELEMENT_TYPE_BOOLEAN:
|
||||
return u.System_Boolean;
|
||||
case Signature.ELEMENT_TYPE_CHAR:
|
||||
return u.System_Char;
|
||||
case Signature.ELEMENT_TYPE_I1:
|
||||
return u.System_SByte;
|
||||
case Signature.ELEMENT_TYPE_U1:
|
||||
return u.System_Byte;
|
||||
case Signature.ELEMENT_TYPE_I2:
|
||||
return u.System_Int16;
|
||||
case Signature.ELEMENT_TYPE_U2:
|
||||
return u.System_UInt16;
|
||||
case Signature.ELEMENT_TYPE_I4:
|
||||
return u.System_Int32;
|
||||
case Signature.ELEMENT_TYPE_U4:
|
||||
return u.System_UInt32;
|
||||
case Signature.ELEMENT_TYPE_I8:
|
||||
return u.System_Int64;
|
||||
case Signature.ELEMENT_TYPE_U8:
|
||||
return u.System_UInt64;
|
||||
case Signature.ELEMENT_TYPE_R4:
|
||||
return u.System_Single;
|
||||
case Signature.ELEMENT_TYPE_R8:
|
||||
return u.System_Double;
|
||||
case Signature.ELEMENT_TYPE_STRING:
|
||||
return u.System_String;
|
||||
case Signature.ELEMENT_TYPE_SZARRAY:
|
||||
return ReadFieldOrPropType(asm, br).MakeArrayType();
|
||||
case 0x55:
|
||||
return ReadType(asm, br);
|
||||
case 0x50:
|
||||
return u.System_Type;
|
||||
case 0x51:
|
||||
return u.System_Object;
|
||||
default:
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
private static CustomAttributeTypedArgument ReadFixedArg(Assembly asm, ByteReader br, Type type)
|
||||
{
|
||||
Universe u = asm.universe;
|
||||
if (type == u.System_String)
|
||||
{
|
||||
return new CustomAttributeTypedArgument(type, br.ReadString());
|
||||
}
|
||||
else if (type == u.System_Type)
|
||||
{
|
||||
return new CustomAttributeTypedArgument(type, ReadType(asm, br));
|
||||
}
|
||||
else if (type == u.System_Object)
|
||||
{
|
||||
return ReadFixedArg(asm, br, ReadFieldOrPropType(asm, br));
|
||||
}
|
||||
else if (type.IsArray)
|
||||
{
|
||||
int length = br.ReadInt32();
|
||||
if (length == -1)
|
||||
{
|
||||
return new CustomAttributeTypedArgument(type, null);
|
||||
}
|
||||
Type elementType = type.GetElementType();
|
||||
CustomAttributeTypedArgument[] array = new CustomAttributeTypedArgument[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
array[i] = ReadFixedArg(asm, br, elementType);
|
||||
}
|
||||
return new CustomAttributeTypedArgument(type, array);
|
||||
}
|
||||
else if (type.IsEnum)
|
||||
{
|
||||
return new CustomAttributeTypedArgument(type, ReadFixedArg(asm, br, type.GetEnumUnderlyingTypeImpl()).Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (Type.GetTypeCode(type))
|
||||
{
|
||||
case TypeCode.Boolean:
|
||||
return new CustomAttributeTypedArgument(type, br.ReadByte() != 0);
|
||||
case TypeCode.Char:
|
||||
return new CustomAttributeTypedArgument(type, br.ReadChar());
|
||||
case TypeCode.Single:
|
||||
return new CustomAttributeTypedArgument(type, br.ReadSingle());
|
||||
case TypeCode.Double:
|
||||
return new CustomAttributeTypedArgument(type, br.ReadDouble());
|
||||
case TypeCode.SByte:
|
||||
return new CustomAttributeTypedArgument(type, br.ReadSByte());
|
||||
case TypeCode.Int16:
|
||||
return new CustomAttributeTypedArgument(type, br.ReadInt16());
|
||||
case TypeCode.Int32:
|
||||
return new CustomAttributeTypedArgument(type, br.ReadInt32());
|
||||
case TypeCode.Int64:
|
||||
return new CustomAttributeTypedArgument(type, br.ReadInt64());
|
||||
case TypeCode.Byte:
|
||||
return new CustomAttributeTypedArgument(type, br.ReadByte());
|
||||
case TypeCode.UInt16:
|
||||
return new CustomAttributeTypedArgument(type, br.ReadUInt16());
|
||||
case TypeCode.UInt32:
|
||||
return new CustomAttributeTypedArgument(type, br.ReadUInt32());
|
||||
case TypeCode.UInt64:
|
||||
return new CustomAttributeTypedArgument(type, br.ReadUInt64());
|
||||
default:
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Type ReadType(Assembly asm, ByteReader br)
|
||||
{
|
||||
string typeName = br.ReadString();
|
||||
if (typeName == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (typeName.Length > 0 && typeName[typeName.Length - 1] == 0)
|
||||
{
|
||||
// there are broken compilers that emit an extra NUL character after the type name
|
||||
typeName = typeName.Substring(0, typeName.Length - 1);
|
||||
}
|
||||
return asm.universe.GetType(asm, typeName, true);
|
||||
}
|
||||
|
||||
private static IList<CustomAttributeTypedArgument> ReadConstructorArguments(Assembly asm, ByteReader br, ConstructorInfo constructor)
|
||||
{
|
||||
MethodSignature sig = constructor.MethodSignature;
|
||||
int count = sig.GetParameterCount();
|
||||
List<CustomAttributeTypedArgument> list = new List<CustomAttributeTypedArgument>(count);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
list.Add(ReadFixedArg(asm, br, sig.GetParameterType(i)));
|
||||
}
|
||||
return list.AsReadOnly();
|
||||
}
|
||||
|
||||
private static IList<CustomAttributeNamedArgument> ReadNamedArguments(Assembly asm, ByteReader br, int named, Type type)
|
||||
{
|
||||
List<CustomAttributeNamedArgument> list = new List<CustomAttributeNamedArgument>(named);
|
||||
for (int i = 0; i < named; i++)
|
||||
{
|
||||
byte fieldOrProperty = br.ReadByte();
|
||||
Type fieldOrPropertyType = ReadFieldOrPropType(asm, br);
|
||||
string name = br.ReadString();
|
||||
CustomAttributeTypedArgument value = ReadFixedArg(asm, br, fieldOrPropertyType);
|
||||
MemberInfo member;
|
||||
switch (fieldOrProperty)
|
||||
{
|
||||
case 0x53:
|
||||
member = GetField(type, name);
|
||||
break;
|
||||
case 0x54:
|
||||
member = GetProperty(type, name);
|
||||
break;
|
||||
default:
|
||||
throw new BadImageFormatException();
|
||||
}
|
||||
if (member == null)
|
||||
{
|
||||
throw new BadImageFormatException();
|
||||
}
|
||||
list.Add(new CustomAttributeNamedArgument(member, value));
|
||||
}
|
||||
return list.AsReadOnly();
|
||||
}
|
||||
|
||||
private static FieldInfo GetField(Type type, string name)
|
||||
{
|
||||
for (; type != null; type = type.BaseType)
|
||||
{
|
||||
foreach (FieldInfo field in type.__GetDeclaredFields())
|
||||
{
|
||||
if (field.IsPublic && !field.IsStatic && field.Name == name)
|
||||
{
|
||||
return field;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static PropertyInfo GetProperty(Type type, string name)
|
||||
{
|
||||
for (; type != null; type = type.BaseType)
|
||||
{
|
||||
foreach (PropertyInfo property in type.__GetDeclaredProperties())
|
||||
{
|
||||
if (property.IsPublic && !property.IsStatic && property.Name == name)
|
||||
{
|
||||
return property;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void __ReadTypeName(out string ns, out string name)
|
||||
{
|
||||
if (lazyConstructor == null)
|
||||
{
|
||||
ModuleReader mod = module as ModuleReader;
|
||||
if (mod != null)
|
||||
{
|
||||
int methodToken = mod.CustomAttribute.records[index].Type;
|
||||
if ((methodToken >> 24) == MemberRefTable.Index)
|
||||
{
|
||||
int methodIndex = (methodToken & 0xFFFFFF) - 1;
|
||||
int typeToken = mod.MemberRef.records[methodIndex].Class;
|
||||
if ((typeToken >> 24) == TypeRefTable.Index)
|
||||
{
|
||||
int typeIndex = (typeToken & 0xFFFFFF) - 1;
|
||||
int typeNameSpace = mod.TypeRef.records[typeIndex].TypeNameSpace;
|
||||
ns = typeNameSpace == 0 ? null : mod.GetString(typeNameSpace);
|
||||
name = mod.GetString(mod.TypeRef.records[typeIndex].TypeName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ns = Constructor.DeclaringType.Namespace;
|
||||
name = Constructor.DeclaringType.Name;
|
||||
}
|
||||
|
||||
public ConstructorInfo Constructor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (lazyConstructor == null)
|
||||
{
|
||||
lazyConstructor = (ConstructorInfo)module.ResolveMethod(module.CustomAttribute.records[index].Type);
|
||||
}
|
||||
return lazyConstructor;
|
||||
}
|
||||
}
|
||||
|
||||
public IList<CustomAttributeTypedArgument> ConstructorArguments
|
||||
{
|
||||
get
|
||||
{
|
||||
if (lazyConstructorArguments == null)
|
||||
{
|
||||
LazyParseArguments();
|
||||
}
|
||||
return lazyConstructorArguments;
|
||||
}
|
||||
}
|
||||
|
||||
public IList<CustomAttributeNamedArgument> NamedArguments
|
||||
{
|
||||
get
|
||||
{
|
||||
if (lazyNamedArguments == null)
|
||||
{
|
||||
LazyParseArguments();
|
||||
}
|
||||
return lazyNamedArguments;
|
||||
}
|
||||
}
|
||||
|
||||
private void LazyParseArguments()
|
||||
{
|
||||
ByteReader br = module.GetBlob(module.CustomAttribute.records[index].Value);
|
||||
if (br.Length == 0)
|
||||
{
|
||||
// it's legal to have an empty blob
|
||||
lazyConstructorArguments = Empty<CustomAttributeTypedArgument>.Array;
|
||||
lazyNamedArguments = Empty<CustomAttributeNamedArgument>.Array;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (br.ReadUInt16() != 1)
|
||||
{
|
||||
throw new BadImageFormatException();
|
||||
}
|
||||
lazyConstructorArguments = ReadConstructorArguments(module.Assembly, br, Constructor);
|
||||
lazyNamedArguments = ReadNamedArguments(module.Assembly, br, br.ReadUInt16(), Constructor.DeclaringType);
|
||||
}
|
||||
}
|
||||
|
||||
public CustomAttributeBuilder __ToBuilder()
|
||||
{
|
||||
object[] args = new object[ConstructorArguments.Count];
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
{
|
||||
args[i] = ConstructorArguments[i].Value;
|
||||
}
|
||||
List<PropertyInfo> namedProperties = new List<PropertyInfo>();
|
||||
List<object> propertyValues = new List<object>();
|
||||
List<FieldInfo> namedFields = new List<FieldInfo>();
|
||||
List<object> fieldValues = new List<object>();
|
||||
foreach (CustomAttributeNamedArgument named in NamedArguments)
|
||||
{
|
||||
if (named.MemberInfo is PropertyInfo)
|
||||
{
|
||||
namedProperties.Add((PropertyInfo)named.MemberInfo);
|
||||
propertyValues.Add(named.TypedValue.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
namedFields.Add((FieldInfo)named.MemberInfo);
|
||||
fieldValues.Add(named.TypedValue.Value);
|
||||
}
|
||||
}
|
||||
return new CustomAttributeBuilder(Constructor, args, namedProperties.ToArray(), propertyValues.ToArray(), namedFields.ToArray(), fieldValues.ToArray());
|
||||
}
|
||||
|
||||
public static IList<CustomAttributeData> GetCustomAttributes(MemberInfo member)
|
||||
{
|
||||
return member.GetCustomAttributesData(null);
|
||||
}
|
||||
|
||||
public static IList<CustomAttributeData> GetCustomAttributes(Assembly assembly)
|
||||
{
|
||||
return assembly.GetCustomAttributesData(null);
|
||||
}
|
||||
|
||||
public static IList<CustomAttributeData> GetCustomAttributes(Module module)
|
||||
{
|
||||
return module.GetCustomAttributesData(null);
|
||||
}
|
||||
|
||||
public static IList<CustomAttributeData> GetCustomAttributes(ParameterInfo parameter)
|
||||
{
|
||||
return parameter.GetCustomAttributesData(null);
|
||||
}
|
||||
|
||||
public static IList<CustomAttributeData> __GetCustomAttributes(Assembly assembly, Type attributeType, bool inherit)
|
||||
{
|
||||
return assembly.GetCustomAttributesData(attributeType);
|
||||
}
|
||||
|
||||
public static IList<CustomAttributeData> __GetCustomAttributes(Module module, Type attributeType, bool inherit)
|
||||
{
|
||||
return module.GetCustomAttributesData(attributeType);
|
||||
}
|
||||
|
||||
public static IList<CustomAttributeData> __GetCustomAttributes(ParameterInfo parameter, Type attributeType, bool inherit)
|
||||
{
|
||||
return parameter.GetCustomAttributesData(attributeType);
|
||||
}
|
||||
|
||||
public static IList<CustomAttributeData> __GetCustomAttributes(MemberInfo member, Type attributeType, bool inherit)
|
||||
{
|
||||
if (!inherit || !IsInheritableAttribute(attributeType))
|
||||
{
|
||||
return member.GetCustomAttributesData(attributeType);
|
||||
}
|
||||
List<CustomAttributeData> list = new List<CustomAttributeData>();
|
||||
for (; ; )
|
||||
{
|
||||
list.AddRange(member.GetCustomAttributesData(attributeType));
|
||||
Type type = member as Type;
|
||||
if (type != null)
|
||||
{
|
||||
type = type.BaseType;
|
||||
if (type == null)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
member = type;
|
||||
continue;
|
||||
}
|
||||
MethodInfo method = member as MethodInfo;
|
||||
if (method != null)
|
||||
{
|
||||
MemberInfo prev = member;
|
||||
method = method.GetBaseDefinition();
|
||||
if (method == null || method == prev)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
member = method;
|
||||
continue;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
public static IList<CustomAttributeData> __GetDeclarativeSecurity(Assembly assembly)
|
||||
{
|
||||
return assembly.ManifestModule.GetDeclarativeSecurity(0x20000001);
|
||||
}
|
||||
|
||||
public static IList<CustomAttributeData> __GetDeclarativeSecurity(Type type)
|
||||
{
|
||||
if ((type.Attributes & TypeAttributes.HasSecurity) != 0)
|
||||
{
|
||||
return type.Module.GetDeclarativeSecurity(type.MetadataToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
return EmptyList;
|
||||
}
|
||||
}
|
||||
|
||||
public static IList<CustomAttributeData> __GetDeclarativeSecurity(MethodBase method)
|
||||
{
|
||||
if ((method.Attributes & MethodAttributes.HasSecurity) != 0)
|
||||
{
|
||||
return method.Module.GetDeclarativeSecurity(method.MetadataToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
return EmptyList;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsInheritableAttribute(Type attribute)
|
||||
{
|
||||
Type attributeUsageAttribute = attribute.Module.universe.System_AttributeUsageAttribute;
|
||||
IList<CustomAttributeData> attr = attribute.GetCustomAttributesData(attributeUsageAttribute);
|
||||
if (attr.Count != 0)
|
||||
{
|
||||
foreach (CustomAttributeNamedArgument named in attr[0].NamedArguments)
|
||||
{
|
||||
if (named.MemberInfo.Name == "Inherited")
|
||||
{
|
||||
return (bool)named.TypedValue.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace IKVM.Reflection
|
||||
{
|
||||
public struct CustomAttributeNamedArgument
|
||||
{
|
||||
private readonly MemberInfo member;
|
||||
private readonly CustomAttributeTypedArgument value;
|
||||
|
||||
internal CustomAttributeNamedArgument(MemberInfo member, CustomAttributeTypedArgument value)
|
||||
{
|
||||
this.member = member;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return this == obj as CustomAttributeNamedArgument?;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return member.GetHashCode() ^ 53 * value.GetHashCode();
|
||||
}
|
||||
|
||||
public MemberInfo MemberInfo
|
||||
{
|
||||
get { return member; }
|
||||
}
|
||||
|
||||
public CustomAttributeTypedArgument TypedValue
|
||||
{
|
||||
get { return value; }
|
||||
}
|
||||
|
||||
public static bool operator ==(CustomAttributeNamedArgument arg1, CustomAttributeNamedArgument arg2)
|
||||
{
|
||||
return arg1.member.Equals(arg2.member) && arg1.value == arg2.value;
|
||||
}
|
||||
|
||||
public static bool operator !=(CustomAttributeNamedArgument arg1, CustomAttributeNamedArgument arg2)
|
||||
{
|
||||
return !(arg1 == arg2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace IKVM.Reflection
|
||||
{
|
||||
public struct CustomAttributeTypedArgument
|
||||
{
|
||||
private readonly Type type;
|
||||
private readonly object value;
|
||||
|
||||
internal CustomAttributeTypedArgument(Type type, object value)
|
||||
{
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return this == obj as CustomAttributeTypedArgument?;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return type.GetHashCode() ^ 77 * (value == null ? 0 : value.GetHashCode());
|
||||
}
|
||||
|
||||
public Type ArgumentType
|
||||
{
|
||||
get { return type; }
|
||||
}
|
||||
|
||||
public Object Value
|
||||
{
|
||||
get { return value; }
|
||||
}
|
||||
|
||||
public static bool operator ==(CustomAttributeTypedArgument arg1, CustomAttributeTypedArgument arg2)
|
||||
{
|
||||
return arg1.type.Equals(arg2.type) && (arg1.value == arg2.value || (arg1.value != null && arg1.value.Equals(arg2.value)));
|
||||
}
|
||||
|
||||
public static bool operator !=(CustomAttributeTypedArgument arg1, CustomAttributeTypedArgument arg2)
|
||||
{
|
||||
return !(arg1 == arg2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,721 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2008-2010 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration.Assemblies;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security;
|
||||
using IKVM.Reflection.Metadata;
|
||||
using IKVM.Reflection.Impl;
|
||||
using IKVM.Reflection.Writer;
|
||||
|
||||
namespace IKVM.Reflection.Emit
|
||||
{
|
||||
public sealed class AssemblyBuilder : Assembly
|
||||
{
|
||||
private readonly string name;
|
||||
private ushort majorVersion;
|
||||
private ushort minorVersion;
|
||||
private ushort buildVersion;
|
||||
private ushort revisionVersion;
|
||||
private string culture;
|
||||
private AssemblyNameFlags flags;
|
||||
private AssemblyHashAlgorithm hashAlgorithm;
|
||||
private StrongNameKeyPair keyPair;
|
||||
private byte[] publicKey;
|
||||
internal readonly string dir;
|
||||
private readonly PermissionSet requiredPermissions;
|
||||
private readonly PermissionSet optionalPermissions;
|
||||
private readonly PermissionSet refusedPermissions;
|
||||
private PEFileKinds fileKind = PEFileKinds.Dll;
|
||||
private MethodInfo entryPoint;
|
||||
private VersionInfo versionInfo;
|
||||
private ResourceSection unmanagedResources;
|
||||
private string imageRuntimeVersion;
|
||||
internal int mdStreamVersion = 0x20000;
|
||||
private Module pseudoManifestModule;
|
||||
private readonly List<ResourceFile> resourceFiles = new List<ResourceFile>();
|
||||
private readonly List<ModuleBuilder> modules = new List<ModuleBuilder>();
|
||||
private readonly List<Module> addedModules = new List<Module>();
|
||||
private readonly List<CustomAttributeBuilder> customAttributes = new List<CustomAttributeBuilder>();
|
||||
private readonly List<CustomAttributeBuilder> declarativeSecurity = new List<CustomAttributeBuilder>();
|
||||
private readonly List<Type> typeForwarders = new List<Type>();
|
||||
|
||||
private struct ResourceFile
|
||||
{
|
||||
internal string Name;
|
||||
internal string FileName;
|
||||
internal ResourceAttributes Attributes;
|
||||
}
|
||||
|
||||
internal AssemblyBuilder(Universe universe, AssemblyName name, string dir, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions)
|
||||
: base(universe)
|
||||
{
|
||||
this.name = name.Name;
|
||||
SetVersionHelper(name.Version);
|
||||
if (name.CultureInfo != null && !string.IsNullOrEmpty(name.CultureInfo.Name))
|
||||
{
|
||||
this.culture = name.CultureInfo.Name;
|
||||
}
|
||||
this.flags = name.Flags;
|
||||
this.hashAlgorithm = name.HashAlgorithm;
|
||||
if (this.hashAlgorithm == AssemblyHashAlgorithm.None)
|
||||
{
|
||||
this.hashAlgorithm = AssemblyHashAlgorithm.SHA1;
|
||||
}
|
||||
this.keyPair = name.KeyPair;
|
||||
if (this.keyPair != null)
|
||||
{
|
||||
this.publicKey = this.keyPair.PublicKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] publicKey = name.GetPublicKey();
|
||||
if (publicKey != null && publicKey.Length != 0)
|
||||
{
|
||||
this.publicKey = (byte[])publicKey.Clone();
|
||||
}
|
||||
}
|
||||
this.dir = dir ?? ".";
|
||||
this.requiredPermissions = requiredPermissions;
|
||||
this.optionalPermissions = optionalPermissions;
|
||||
this.refusedPermissions = refusedPermissions;
|
||||
if (universe.HasMscorlib && universe.Mscorlib.ImageRuntimeVersion != null)
|
||||
{
|
||||
this.imageRuntimeVersion = universe.Mscorlib.ImageRuntimeVersion;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.imageRuntimeVersion = typeof(object).Assembly.ImageRuntimeVersion;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetVersionHelper(Version version)
|
||||
{
|
||||
if (version == null)
|
||||
{
|
||||
majorVersion = 0;
|
||||
minorVersion = 0;
|
||||
buildVersion = 0;
|
||||
revisionVersion = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
majorVersion = (ushort)version.Major;
|
||||
minorVersion = (ushort)version.Minor;
|
||||
buildVersion = version.Build == -1 ? (ushort)0 : (ushort)version.Build;
|
||||
revisionVersion = version.Revision == -1 ? (ushort)0 : (ushort)version.Revision;
|
||||
}
|
||||
}
|
||||
|
||||
public void __SetAssemblyVersion(Version version)
|
||||
{
|
||||
AssemblyName oldName = GetName();
|
||||
SetVersionHelper(version);
|
||||
universe.RenameAssembly(this, oldName);
|
||||
}
|
||||
|
||||
public void __SetAssemblyCulture(string cultureName)
|
||||
{
|
||||
AssemblyName oldName = GetName();
|
||||
this.culture = cultureName;
|
||||
universe.RenameAssembly(this, oldName);
|
||||
}
|
||||
|
||||
public void __SetAssemblyKeyPair(StrongNameKeyPair keyPair)
|
||||
{
|
||||
AssemblyName oldName = GetName();
|
||||
this.keyPair = keyPair;
|
||||
if (keyPair != null)
|
||||
{
|
||||
this.publicKey = keyPair.PublicKey;
|
||||
}
|
||||
universe.RenameAssembly(this, oldName);
|
||||
}
|
||||
|
||||
// this is used in combination with delay signing
|
||||
public void __SetAssemblyPublicKey(byte[] publicKey)
|
||||
{
|
||||
AssemblyName oldName = GetName();
|
||||
this.publicKey = publicKey == null ? null : (byte[])publicKey.Clone();
|
||||
universe.RenameAssembly(this, oldName);
|
||||
}
|
||||
|
||||
public void __SetAssemblyAlgorithmId(AssemblyHashAlgorithm hashAlgorithm)
|
||||
{
|
||||
this.hashAlgorithm = hashAlgorithm;
|
||||
}
|
||||
|
||||
public void __SetAssemblyFlags(AssemblyNameFlags flags)
|
||||
{
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
public override AssemblyName GetName()
|
||||
{
|
||||
AssemblyName n = new AssemblyName();
|
||||
n.Name = name;
|
||||
n.Version = new Version(majorVersion, minorVersion, buildVersion, revisionVersion);
|
||||
n.Culture = culture;
|
||||
n.HashAlgorithm = hashAlgorithm;
|
||||
n.Flags = flags;
|
||||
n.SetPublicKey(publicKey != null ? (byte[])publicKey.Clone() : Empty<byte>.Array);
|
||||
n.KeyPair = keyPair;
|
||||
return n;
|
||||
}
|
||||
|
||||
public override string FullName
|
||||
{
|
||||
get { return GetName().FullName; }
|
||||
}
|
||||
|
||||
public override string Location
|
||||
{
|
||||
get { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
public ModuleBuilder DefineDynamicModule(string name, string fileName)
|
||||
{
|
||||
return DefineDynamicModule(name, fileName, false);
|
||||
}
|
||||
|
||||
public ModuleBuilder DefineDynamicModule(string name, string fileName, bool emitSymbolInfo)
|
||||
{
|
||||
ModuleBuilder module = new ModuleBuilder(this, name, fileName, emitSymbolInfo);
|
||||
modules.Add(module);
|
||||
return module;
|
||||
}
|
||||
|
||||
public ModuleBuilder GetDynamicModule(string name)
|
||||
{
|
||||
foreach (ModuleBuilder module in modules)
|
||||
{
|
||||
if (module.Name == name)
|
||||
{
|
||||
return module;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
|
||||
{
|
||||
SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute));
|
||||
}
|
||||
|
||||
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
|
||||
{
|
||||
customAttributes.Add(customBuilder);
|
||||
}
|
||||
|
||||
public void __AddDeclarativeSecurity(CustomAttributeBuilder customBuilder)
|
||||
{
|
||||
declarativeSecurity.Add(customBuilder);
|
||||
}
|
||||
|
||||
public void __AddTypeForwarder(Type type)
|
||||
{
|
||||
typeForwarders.Add(type);
|
||||
}
|
||||
|
||||
public void SetEntryPoint(MethodInfo entryMethod)
|
||||
{
|
||||
SetEntryPoint(entryMethod, PEFileKinds.ConsoleApplication);
|
||||
}
|
||||
|
||||
public void SetEntryPoint(MethodInfo entryMethod, PEFileKinds fileKind)
|
||||
{
|
||||
this.entryPoint = entryMethod;
|
||||
this.fileKind = fileKind;
|
||||
}
|
||||
|
||||
public void Save(string assemblyFileName)
|
||||
{
|
||||
Save(assemblyFileName, PortableExecutableKinds.ILOnly, ImageFileMachine.I386);
|
||||
}
|
||||
|
||||
public void Save(string assemblyFileName, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
|
||||
{
|
||||
ModuleBuilder manifestModule = null;
|
||||
|
||||
foreach (ModuleBuilder moduleBuilder in modules)
|
||||
{
|
||||
moduleBuilder.PopulatePropertyAndEventTables();
|
||||
|
||||
if (manifestModule == null
|
||||
&& string.Compare(moduleBuilder.fileName, assemblyFileName, StringComparison.OrdinalIgnoreCase) == 0)
|
||||
{
|
||||
manifestModule = moduleBuilder;
|
||||
}
|
||||
}
|
||||
|
||||
if (manifestModule == null)
|
||||
{
|
||||
manifestModule = DefineDynamicModule("RefEmit_OnDiskManifestModule", assemblyFileName, false);
|
||||
}
|
||||
|
||||
AssemblyTable.Record assemblyRecord = new AssemblyTable.Record();
|
||||
assemblyRecord.HashAlgId = (int)hashAlgorithm;
|
||||
assemblyRecord.Name = manifestModule.Strings.Add(name);
|
||||
assemblyRecord.MajorVersion = majorVersion;
|
||||
assemblyRecord.MinorVersion = minorVersion;
|
||||
assemblyRecord.BuildNumber = buildVersion;
|
||||
assemblyRecord.RevisionNumber = revisionVersion;
|
||||
if (publicKey != null)
|
||||
{
|
||||
assemblyRecord.PublicKey = manifestModule.Blobs.Add(ByteBuffer.Wrap(publicKey));
|
||||
assemblyRecord.Flags = (int)(flags | AssemblyNameFlags.PublicKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
assemblyRecord.Flags = (int)(flags & ~AssemblyNameFlags.PublicKey);
|
||||
}
|
||||
if (culture != null)
|
||||
{
|
||||
assemblyRecord.Culture = manifestModule.Strings.Add(culture);
|
||||
}
|
||||
int token = 0x20000000 + manifestModule.AssemblyTable.AddRecord(assemblyRecord);
|
||||
|
||||
#pragma warning disable 618
|
||||
// this values are obsolete, but we already know that so we disable the warning
|
||||
System.Security.Permissions.SecurityAction requestMinimum = System.Security.Permissions.SecurityAction.RequestMinimum;
|
||||
System.Security.Permissions.SecurityAction requestOptional = System.Security.Permissions.SecurityAction.RequestOptional;
|
||||
System.Security.Permissions.SecurityAction requestRefuse = System.Security.Permissions.SecurityAction.RequestRefuse;
|
||||
#pragma warning restore 618
|
||||
if (requiredPermissions != null)
|
||||
{
|
||||
manifestModule.AddDeclarativeSecurity(token, requestMinimum, requiredPermissions);
|
||||
}
|
||||
if (optionalPermissions != null)
|
||||
{
|
||||
manifestModule.AddDeclarativeSecurity(token, requestOptional, optionalPermissions);
|
||||
}
|
||||
if (refusedPermissions != null)
|
||||
{
|
||||
manifestModule.AddDeclarativeSecurity(token, requestRefuse, refusedPermissions);
|
||||
}
|
||||
|
||||
if (versionInfo != null)
|
||||
{
|
||||
versionInfo.SetName(GetName());
|
||||
versionInfo.SetFileName(assemblyFileName);
|
||||
foreach (CustomAttributeBuilder cab in customAttributes)
|
||||
{
|
||||
// .NET doesn't support copying blob custom attributes into the version info
|
||||
if (!cab.HasBlob)
|
||||
{
|
||||
versionInfo.SetAttribute(cab);
|
||||
}
|
||||
}
|
||||
ByteBuffer versionInfoData = new ByteBuffer(512);
|
||||
versionInfo.Write(versionInfoData);
|
||||
if (unmanagedResources == null)
|
||||
{
|
||||
unmanagedResources = new ResourceSection();
|
||||
}
|
||||
unmanagedResources.AddVersionInfo(versionInfoData);
|
||||
}
|
||||
|
||||
foreach (CustomAttributeBuilder cab in customAttributes)
|
||||
{
|
||||
// we intentionally don't filter out the version info (pseudo) custom attributes (to be compatible with .NET)
|
||||
manifestModule.SetCustomAttribute(0x20000001, cab);
|
||||
}
|
||||
|
||||
manifestModule.AddDeclarativeSecurity(0x20000001, declarativeSecurity);
|
||||
|
||||
foreach (Type type in typeForwarders)
|
||||
{
|
||||
manifestModule.AddTypeForwarder(type);
|
||||
}
|
||||
|
||||
foreach (ResourceFile resfile in resourceFiles)
|
||||
{
|
||||
int fileToken = AddFile(manifestModule, resfile.FileName, 1 /*ContainsNoMetaData*/);
|
||||
ManifestResourceTable.Record rec = new ManifestResourceTable.Record();
|
||||
rec.Offset = 0;
|
||||
rec.Flags = (int)resfile.Attributes;
|
||||
rec.Name = manifestModule.Strings.Add(resfile.Name);
|
||||
rec.Implementation = fileToken;
|
||||
manifestModule.ManifestResource.AddRecord(rec);
|
||||
}
|
||||
|
||||
int entryPointToken = 0;
|
||||
|
||||
foreach (ModuleBuilder moduleBuilder in modules)
|
||||
{
|
||||
moduleBuilder.FillAssemblyRefTable();
|
||||
if (moduleBuilder != manifestModule)
|
||||
{
|
||||
int fileToken;
|
||||
if (entryPoint != null && entryPoint.Module == moduleBuilder)
|
||||
{
|
||||
ModuleWriter.WriteModule(null, null, moduleBuilder, fileKind, portableExecutableKind, imageFileMachine, moduleBuilder.unmanagedResources, entryPoint.MetadataToken);
|
||||
entryPointToken = fileToken = AddFile(manifestModule, moduleBuilder.fileName, 0 /*ContainsMetaData*/);
|
||||
}
|
||||
else
|
||||
{
|
||||
ModuleWriter.WriteModule(null, null, moduleBuilder, fileKind, portableExecutableKind, imageFileMachine, moduleBuilder.unmanagedResources, 0);
|
||||
fileToken = AddFile(manifestModule, moduleBuilder.fileName, 0 /*ContainsMetaData*/);
|
||||
}
|
||||
moduleBuilder.ExportTypes(fileToken, manifestModule);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Module module in addedModules)
|
||||
{
|
||||
int fileToken = AddFile(manifestModule, module.FullyQualifiedName, 0 /*ContainsMetaData*/);
|
||||
module.ExportTypes(fileToken, manifestModule);
|
||||
}
|
||||
|
||||
if (entryPointToken == 0 && entryPoint != null)
|
||||
{
|
||||
entryPointToken = entryPoint.MetadataToken;
|
||||
}
|
||||
|
||||
// finally, write the manifest module
|
||||
ModuleWriter.WriteModule(keyPair, publicKey, manifestModule, fileKind, portableExecutableKind, imageFileMachine, unmanagedResources ?? manifestModule.unmanagedResources, entryPointToken);
|
||||
}
|
||||
|
||||
private int AddFile(ModuleBuilder manifestModule, string fileName, int flags)
|
||||
{
|
||||
SHA1Managed hash = new SHA1Managed();
|
||||
string fullPath = fileName;
|
||||
if (dir != null)
|
||||
{
|
||||
fullPath = Path.Combine(dir, fileName);
|
||||
}
|
||||
using (FileStream fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
using (CryptoStream cs = new CryptoStream(Stream.Null, hash, CryptoStreamMode.Write))
|
||||
{
|
||||
byte[] buf = new byte[8192];
|
||||
ModuleWriter.HashChunk(fs, cs, buf, (int)fs.Length);
|
||||
}
|
||||
}
|
||||
FileTable.Record file = new FileTable.Record();
|
||||
file.Flags = flags;
|
||||
file.Name = manifestModule.Strings.Add(Path.GetFileName(fileName));
|
||||
file.HashValue = manifestModule.Blobs.Add(ByteBuffer.Wrap(hash.Hash));
|
||||
return 0x26000000 + manifestModule.File.AddRecord(file);
|
||||
}
|
||||
|
||||
public void AddResourceFile(string name, string fileName)
|
||||
{
|
||||
AddResourceFile(name, fileName, ResourceAttributes.Public);
|
||||
}
|
||||
|
||||
public void AddResourceFile(string name, string fileName, ResourceAttributes attribs)
|
||||
{
|
||||
ResourceFile resfile = new ResourceFile();
|
||||
resfile.Name = name;
|
||||
resfile.FileName = fileName;
|
||||
resfile.Attributes = attribs;
|
||||
resourceFiles.Add(resfile);
|
||||
}
|
||||
|
||||
public void DefineVersionInfoResource()
|
||||
{
|
||||
versionInfo = new VersionInfo();
|
||||
}
|
||||
|
||||
public void DefineVersionInfoResource(string product, string productVersion, string company, string copyright, string trademark)
|
||||
{
|
||||
versionInfo = new VersionInfo();
|
||||
versionInfo.product = product;
|
||||
versionInfo.informationalVersion = productVersion;
|
||||
versionInfo.company = company;
|
||||
versionInfo.copyright = copyright;
|
||||
versionInfo.trademark = trademark;
|
||||
}
|
||||
|
||||
public void __DefineIconResource(byte[] iconFile)
|
||||
{
|
||||
unmanagedResources = new ResourceSection();
|
||||
unmanagedResources.AddIcon(iconFile);
|
||||
}
|
||||
|
||||
public void __DefineUnmanagedResource(byte[] resource)
|
||||
{
|
||||
// The standard .NET DefineUnmanagedResource(byte[]) is useless, because it embeds "resource" (as-is) as the .rsrc section,
|
||||
// but it doesn't set the PE file Resource Directory entry to point to it. That's why we have a renamed version, which behaves
|
||||
// like DefineUnmanagedResource(string).
|
||||
unmanagedResources = new ResourceSection();
|
||||
unmanagedResources.ExtractResources(resource);
|
||||
}
|
||||
|
||||
public void DefineUnmanagedResource(string resourceFileName)
|
||||
{
|
||||
// This method reads the specified resource file (Win32 .res file) and converts it into the appropriate format and embeds it in the .rsrc section,
|
||||
// also setting the Resource Directory entry.
|
||||
__DefineUnmanagedResource(File.ReadAllBytes(resourceFileName));
|
||||
}
|
||||
|
||||
public override Type[] GetTypes()
|
||||
{
|
||||
List<Type> list = new List<Type>();
|
||||
foreach (ModuleBuilder module in modules)
|
||||
{
|
||||
module.GetTypesImpl(list);
|
||||
}
|
||||
foreach (Module module in addedModules)
|
||||
{
|
||||
module.GetTypesImpl(list);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
internal override Type GetTypeImpl(string typeName)
|
||||
{
|
||||
foreach (ModuleBuilder mb in modules)
|
||||
{
|
||||
Type type = mb.GetTypeImpl(typeName);
|
||||
if (type != null)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
foreach (Module module in addedModules)
|
||||
{
|
||||
Type type = module.GetTypeImpl(typeName);
|
||||
if (type != null)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string ImageRuntimeVersion
|
||||
{
|
||||
get { return imageRuntimeVersion; }
|
||||
}
|
||||
|
||||
public void __SetImageRuntimeVersion(string imageRuntimeVersion, int mdStreamVersion)
|
||||
{
|
||||
this.imageRuntimeVersion = imageRuntimeVersion;
|
||||
this.mdStreamVersion = mdStreamVersion;
|
||||
}
|
||||
|
||||
public override Module ManifestModule
|
||||
{
|
||||
get
|
||||
{
|
||||
if (pseudoManifestModule == null)
|
||||
{
|
||||
pseudoManifestModule = new ManifestModule(this);
|
||||
}
|
||||
return pseudoManifestModule;
|
||||
}
|
||||
}
|
||||
|
||||
public override MethodInfo EntryPoint
|
||||
{
|
||||
get { return entryPoint; }
|
||||
}
|
||||
|
||||
public override AssemblyName[] GetReferencedAssemblies()
|
||||
{
|
||||
return Empty<AssemblyName>.Array;
|
||||
}
|
||||
|
||||
public override Module[] GetLoadedModules(bool getResourceModules)
|
||||
{
|
||||
return GetModules(getResourceModules);
|
||||
}
|
||||
|
||||
public override Module[] GetModules(bool getResourceModules)
|
||||
{
|
||||
List<Module> list = new List<Module>();
|
||||
foreach (ModuleBuilder module in modules)
|
||||
{
|
||||
if (getResourceModules || !module.IsResource())
|
||||
{
|
||||
list.Add(module);
|
||||
}
|
||||
}
|
||||
foreach (Module module in addedModules)
|
||||
{
|
||||
if (getResourceModules || !module.IsResource())
|
||||
{
|
||||
list.Add(module);
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public override Module GetModule(string name)
|
||||
{
|
||||
foreach (ModuleBuilder module in modules)
|
||||
{
|
||||
if (module.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return module;
|
||||
}
|
||||
}
|
||||
foreach (Module module in addedModules)
|
||||
{
|
||||
if (module.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return module;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Module __AddModule(RawModule module)
|
||||
{
|
||||
Module mod = module.ToModule(this);
|
||||
addedModules.Add(mod);
|
||||
return mod;
|
||||
}
|
||||
|
||||
public override ManifestResourceInfo GetManifestResourceInfo(string resourceName)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override string[] GetManifestResourceNames()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override Stream GetManifestResourceStream(string resourceName)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
internal override IList<CustomAttributeData> GetCustomAttributesData(Type attributeType)
|
||||
{
|
||||
List<CustomAttributeData> list = new List<CustomAttributeData>();
|
||||
foreach (CustomAttributeBuilder cab in customAttributes)
|
||||
{
|
||||
if (attributeType == null || attributeType.IsAssignableFrom(cab.Constructor.DeclaringType))
|
||||
{
|
||||
list.Add(cab.ToData(this));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
sealed class ManifestModule : Module
|
||||
{
|
||||
private readonly AssemblyBuilder assembly;
|
||||
private readonly Guid guid = Guid.NewGuid();
|
||||
|
||||
internal ManifestModule(AssemblyBuilder assembly)
|
||||
: base(assembly.universe)
|
||||
{
|
||||
this.assembly = assembly;
|
||||
}
|
||||
|
||||
public override int MDStreamVersion
|
||||
{
|
||||
get { return assembly.mdStreamVersion; }
|
||||
}
|
||||
|
||||
public override Assembly Assembly
|
||||
{
|
||||
get { return assembly; }
|
||||
}
|
||||
|
||||
internal override Type GetTypeImpl(string typeName)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
internal override void GetTypesImpl(List<Type> list)
|
||||
{
|
||||
}
|
||||
|
||||
public override string FullyQualifiedName
|
||||
{
|
||||
get { return Path.Combine(assembly.dir, "RefEmit_InMemoryManifestModule"); }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "<In Memory Module>"; }
|
||||
}
|
||||
|
||||
public override Guid ModuleVersionId
|
||||
{
|
||||
get { return guid; }
|
||||
}
|
||||
|
||||
public override Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
public override MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
public override FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
public override MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
public override string ResolveString(int metadataToken)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
public override Type[] __ResolveOptionalParameterTypes(int metadataToken)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
public override string ScopeName
|
||||
{
|
||||
get { return "RefEmit_InMemoryManifestModule"; }
|
||||
}
|
||||
|
||||
public override AssemblyName[] __GetReferencedAssemblies()
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
internal override Type GetModuleType()
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
internal override IKVM.Reflection.Reader.ByteReader GetBlob(int blobIndex)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2008 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace IKVM.Reflection.Emit
|
||||
{
|
||||
public sealed class ConstructorBuilder : ConstructorInfo
|
||||
{
|
||||
private readonly MethodBuilder methodBuilder;
|
||||
|
||||
internal ConstructorBuilder(MethodBuilder mb)
|
||||
{
|
||||
this.methodBuilder = mb;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
ConstructorBuilder other = obj as ConstructorBuilder;
|
||||
return other != null && other.methodBuilder.Equals(methodBuilder);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return methodBuilder.GetHashCode();
|
||||
}
|
||||
|
||||
public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, string strParamName)
|
||||
{
|
||||
return methodBuilder.DefineParameter(position, attributes, strParamName);
|
||||
}
|
||||
|
||||
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
|
||||
{
|
||||
methodBuilder.SetCustomAttribute(customBuilder);
|
||||
}
|
||||
|
||||
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
|
||||
{
|
||||
methodBuilder.SetCustomAttribute(con, binaryAttribute);
|
||||
}
|
||||
|
||||
public void __AddDeclarativeSecurity(CustomAttributeBuilder customBuilder)
|
||||
{
|
||||
methodBuilder.__AddDeclarativeSecurity(customBuilder);
|
||||
}
|
||||
|
||||
public void AddDeclarativeSecurity(System.Security.Permissions.SecurityAction securityAction, System.Security.PermissionSet permissionSet)
|
||||
{
|
||||
methodBuilder.AddDeclarativeSecurity(securityAction, permissionSet);
|
||||
}
|
||||
|
||||
public void SetImplementationFlags(MethodImplAttributes attributes)
|
||||
{
|
||||
methodBuilder.SetImplementationFlags(attributes);
|
||||
}
|
||||
|
||||
public ILGenerator GetILGenerator()
|
||||
{
|
||||
return methodBuilder.GetILGenerator();
|
||||
}
|
||||
|
||||
public ILGenerator GetILGenerator(int streamSize)
|
||||
{
|
||||
return methodBuilder.GetILGenerator(streamSize);
|
||||
}
|
||||
|
||||
public override CallingConventions CallingConvention
|
||||
{
|
||||
get { return methodBuilder.CallingConvention; }
|
||||
}
|
||||
|
||||
public override MethodAttributes Attributes
|
||||
{
|
||||
get { return methodBuilder.Attributes; }
|
||||
}
|
||||
|
||||
public override MethodImplAttributes GetMethodImplementationFlags()
|
||||
{
|
||||
return methodBuilder.GetMethodImplementationFlags();
|
||||
}
|
||||
|
||||
public Type ReturnType
|
||||
{
|
||||
get { return methodBuilder.ReturnType; }
|
||||
}
|
||||
|
||||
internal override int ParameterCount
|
||||
{
|
||||
get { return methodBuilder.ParameterCount; }
|
||||
}
|
||||
|
||||
public override Type DeclaringType
|
||||
{
|
||||
get { return methodBuilder.DeclaringType; }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return methodBuilder.Name; }
|
||||
}
|
||||
|
||||
public override int MetadataToken
|
||||
{
|
||||
get { return methodBuilder.MetadataToken; }
|
||||
}
|
||||
|
||||
public override Module Module
|
||||
{
|
||||
get { return methodBuilder.Module; }
|
||||
}
|
||||
|
||||
public Module GetModule()
|
||||
{
|
||||
return methodBuilder.GetModule();
|
||||
}
|
||||
|
||||
public MethodToken GetToken()
|
||||
{
|
||||
return methodBuilder.GetToken();
|
||||
}
|
||||
|
||||
public override MethodBody GetMethodBody()
|
||||
{
|
||||
return methodBuilder.GetMethodBody();
|
||||
}
|
||||
|
||||
public bool InitLocals
|
||||
{
|
||||
get { return methodBuilder.InitLocals; }
|
||||
set { methodBuilder.InitLocals = value; }
|
||||
}
|
||||
|
||||
internal override MethodInfo GetMethodInfo()
|
||||
{
|
||||
return methodBuilder;
|
||||
}
|
||||
|
||||
internal override MethodInfo GetMethodOnTypeDefinition()
|
||||
{
|
||||
return methodBuilder;
|
||||
}
|
||||
|
||||
internal override MethodSignature MethodSignature
|
||||
{
|
||||
get { return methodBuilder.MethodSignature; }
|
||||
}
|
||||
|
||||
internal override int ImportTo(ModuleBuilder module)
|
||||
{
|
||||
return module.ImportMember(methodBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,492 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2008 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using IKVM.Reflection.Writer;
|
||||
|
||||
namespace IKVM.Reflection.Emit
|
||||
{
|
||||
public sealed class CustomAttributeBuilder
|
||||
{
|
||||
private readonly ConstructorInfo con;
|
||||
private readonly byte[] blob;
|
||||
private readonly object[] constructorArgs;
|
||||
private readonly PropertyInfo[] namedProperties;
|
||||
private readonly object[] propertyValues;
|
||||
private readonly FieldInfo[] namedFields;
|
||||
private readonly object[] fieldValues;
|
||||
|
||||
internal CustomAttributeBuilder(ConstructorInfo con, byte[] blob)
|
||||
{
|
||||
this.con = con;
|
||||
this.blob = blob;
|
||||
}
|
||||
|
||||
public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs)
|
||||
: this(con, constructorArgs, null, null, null,null)
|
||||
{
|
||||
}
|
||||
|
||||
public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs, FieldInfo[] namedFields, object[] fieldValues)
|
||||
: this(con, constructorArgs, null, null, namedFields, fieldValues)
|
||||
{
|
||||
}
|
||||
|
||||
public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs, PropertyInfo[] namedProperties, object[] propertyValues)
|
||||
: this(con, constructorArgs, namedProperties, propertyValues, null, null)
|
||||
{
|
||||
}
|
||||
|
||||
public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs, PropertyInfo[] namedProperties, object[] propertyValues, FieldInfo[] namedFields, object[] fieldValues)
|
||||
{
|
||||
this.con = con;
|
||||
this.constructorArgs = constructorArgs;
|
||||
this.namedProperties = namedProperties;
|
||||
this.propertyValues = propertyValues;
|
||||
this.namedFields = namedFields;
|
||||
this.fieldValues = fieldValues;
|
||||
}
|
||||
|
||||
private sealed class BlobWriter
|
||||
{
|
||||
private readonly ModuleBuilder moduleBuilder;
|
||||
private readonly CustomAttributeBuilder cab;
|
||||
private readonly ByteBuffer bb;
|
||||
|
||||
internal BlobWriter(ModuleBuilder moduleBuilder, CustomAttributeBuilder cab, ByteBuffer bb)
|
||||
{
|
||||
this.moduleBuilder = moduleBuilder;
|
||||
this.cab = cab;
|
||||
this.bb = bb;
|
||||
}
|
||||
|
||||
internal void WriteCustomAttributeBlob()
|
||||
{
|
||||
// prolog
|
||||
WriteUInt16(1);
|
||||
ParameterInfo[] pi = cab.con.GetParameters();
|
||||
for (int i = 0; i < pi.Length; i++)
|
||||
{
|
||||
WriteFixedArg(pi[i].ParameterType, cab.constructorArgs[i]);
|
||||
}
|
||||
WriteNamedArguments(false);
|
||||
}
|
||||
|
||||
internal void WriteNamedArguments(bool forDeclSecurity)
|
||||
{
|
||||
// NumNamed
|
||||
int named = 0;
|
||||
if (cab.namedFields != null)
|
||||
{
|
||||
named += cab.namedFields.Length;
|
||||
}
|
||||
if (cab.namedProperties != null)
|
||||
{
|
||||
named += cab.namedProperties.Length;
|
||||
}
|
||||
if (forDeclSecurity)
|
||||
{
|
||||
WritePackedLen(named);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteUInt16((ushort)named);
|
||||
}
|
||||
if (cab.namedFields != null)
|
||||
{
|
||||
for (int i = 0; i < cab.namedFields.Length; i++)
|
||||
{
|
||||
WriteNamedArg(0x53, cab.namedFields[i].FieldType, cab.namedFields[i].Name, cab.fieldValues[i]);
|
||||
}
|
||||
}
|
||||
if (cab.namedProperties != null)
|
||||
{
|
||||
for (int i = 0; i < cab.namedProperties.Length; i++)
|
||||
{
|
||||
WriteNamedArg(0x54, cab.namedProperties[i].PropertyType, cab.namedProperties[i].Name, cab.propertyValues[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteNamedArg(byte fieldOrProperty, Type type, string name, object value)
|
||||
{
|
||||
WriteByte(fieldOrProperty);
|
||||
WriteFieldOrPropType(type);
|
||||
WriteString(name);
|
||||
WriteFixedArg(type, value);
|
||||
}
|
||||
|
||||
private void WriteByte(byte value)
|
||||
{
|
||||
bb.Write(value);
|
||||
}
|
||||
|
||||
private void WriteUInt16(ushort value)
|
||||
{
|
||||
bb.Write(value);
|
||||
}
|
||||
|
||||
private void WriteInt32(int value)
|
||||
{
|
||||
bb.Write(value);
|
||||
}
|
||||
|
||||
private void WriteFixedArg(Type type, object value)
|
||||
{
|
||||
Universe u = moduleBuilder.universe;
|
||||
if (type == u.System_String)
|
||||
{
|
||||
WriteString((string)value);
|
||||
}
|
||||
else if (type == u.System_Type)
|
||||
{
|
||||
WriteTypeName((Type)value);
|
||||
}
|
||||
else if (type == u.System_Object)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
type = u.System_String;
|
||||
}
|
||||
else if (value is Type)
|
||||
{
|
||||
// value.GetType() would return a subclass of Type, but we don't want to deal with that
|
||||
type = u.System_Type;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = u.Import(value.GetType());
|
||||
}
|
||||
WriteFieldOrPropType(type);
|
||||
WriteFixedArg(type, value);
|
||||
}
|
||||
else if (type.IsArray)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
WriteInt32(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Array array = (Array)value;
|
||||
Type elemType = type.GetElementType();
|
||||
WriteInt32(array.Length);
|
||||
foreach (object val in array)
|
||||
{
|
||||
WriteFixedArg(elemType, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type.IsEnum)
|
||||
{
|
||||
WriteFixedArg(type.GetEnumUnderlyingTypeImpl(), value);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (Type.GetTypeCode(type))
|
||||
{
|
||||
case TypeCode.Boolean:
|
||||
WriteByte((bool)value ? (byte)1 : (byte)0);
|
||||
break;
|
||||
case TypeCode.Char:
|
||||
WriteUInt16((char)value);
|
||||
break;
|
||||
case TypeCode.SByte:
|
||||
WriteByte((byte)(sbyte)value);
|
||||
break;
|
||||
case TypeCode.Byte:
|
||||
WriteByte((byte)value);
|
||||
break;
|
||||
case TypeCode.Int16:
|
||||
WriteUInt16((ushort)(short)value);
|
||||
break;
|
||||
case TypeCode.UInt16:
|
||||
WriteUInt16((ushort)value);
|
||||
break;
|
||||
case TypeCode.Int32:
|
||||
WriteInt32((int)value);
|
||||
break;
|
||||
case TypeCode.UInt32:
|
||||
WriteInt32((int)(uint)value);
|
||||
break;
|
||||
case TypeCode.Int64:
|
||||
WriteInt64((long)value);
|
||||
break;
|
||||
case TypeCode.UInt64:
|
||||
WriteInt64((long)(ulong)value);
|
||||
break;
|
||||
case TypeCode.Single:
|
||||
WriteSingle((float)value);
|
||||
break;
|
||||
case TypeCode.Double:
|
||||
WriteDouble((double)value);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteInt64(long value)
|
||||
{
|
||||
bb.Write(value);
|
||||
}
|
||||
|
||||
private void WriteSingle(float value)
|
||||
{
|
||||
bb.Write(value);
|
||||
}
|
||||
|
||||
private void WriteDouble(double value)
|
||||
{
|
||||
bb.Write(value);
|
||||
}
|
||||
|
||||
private void WriteTypeName(Type type)
|
||||
{
|
||||
string name = null;
|
||||
if (type != null)
|
||||
{
|
||||
if (type.Assembly == moduleBuilder.Assembly)
|
||||
{
|
||||
name = type.FullName;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = type.AssemblyQualifiedName;
|
||||
}
|
||||
}
|
||||
WriteString(name);
|
||||
}
|
||||
|
||||
private void WriteString(string val)
|
||||
{
|
||||
bb.Write(val);
|
||||
}
|
||||
|
||||
private void WritePackedLen(int len)
|
||||
{
|
||||
bb.WriteCompressedInt(len);
|
||||
}
|
||||
|
||||
private void WriteFieldOrPropType(Type type)
|
||||
{
|
||||
Universe u = type.Module.universe;
|
||||
if (type == u.System_Type)
|
||||
{
|
||||
WriteByte(0x50);
|
||||
}
|
||||
else if (type == u.System_Object)
|
||||
{
|
||||
WriteByte(0x51);
|
||||
}
|
||||
else if (type.IsArray)
|
||||
{
|
||||
WriteByte(0x1D);
|
||||
WriteFieldOrPropType(type.GetElementType());
|
||||
}
|
||||
else if (type.IsEnum)
|
||||
{
|
||||
WriteByte(0x55);
|
||||
WriteTypeName(type);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (Type.GetTypeCode(type))
|
||||
{
|
||||
case TypeCode.Boolean:
|
||||
WriteByte(0x02);
|
||||
break;
|
||||
case TypeCode.Char:
|
||||
WriteByte(0x03);
|
||||
break;
|
||||
case TypeCode.SByte:
|
||||
WriteByte(0x04);
|
||||
break;
|
||||
case TypeCode.Byte:
|
||||
WriteByte(0x05);
|
||||
break;
|
||||
case TypeCode.Int16:
|
||||
WriteByte(0x06);
|
||||
break;
|
||||
case TypeCode.UInt16:
|
||||
WriteByte(0x07);
|
||||
break;
|
||||
case TypeCode.Int32:
|
||||
WriteByte(0x08);
|
||||
break;
|
||||
case TypeCode.UInt32:
|
||||
WriteByte(0x09);
|
||||
break;
|
||||
case TypeCode.Int64:
|
||||
WriteByte(0x0A);
|
||||
break;
|
||||
case TypeCode.UInt64:
|
||||
WriteByte(0x0B);
|
||||
break;
|
||||
case TypeCode.Single:
|
||||
WriteByte(0x0C);
|
||||
break;
|
||||
case TypeCode.Double:
|
||||
WriteByte(0x0D);
|
||||
break;
|
||||
case TypeCode.String:
|
||||
WriteByte(0x0E);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsPseudoCustomAttribute
|
||||
{
|
||||
get { return con.DeclaringType.IsPseudoCustomAttribute; }
|
||||
}
|
||||
|
||||
internal ConstructorInfo Constructor
|
||||
{
|
||||
get { return con; }
|
||||
}
|
||||
|
||||
internal int WriteBlob(ModuleBuilder moduleBuilder)
|
||||
{
|
||||
ByteBuffer bb = new ByteBuffer(100);
|
||||
if (blob != null)
|
||||
{
|
||||
bb.Write(blob);
|
||||
}
|
||||
else
|
||||
{
|
||||
BlobWriter bw = new BlobWriter(moduleBuilder, this, bb);
|
||||
bw.WriteCustomAttributeBlob();
|
||||
}
|
||||
return moduleBuilder.Blobs.Add(bb);
|
||||
}
|
||||
|
||||
internal object GetConstructorArgument(int pos)
|
||||
{
|
||||
return constructorArgs[pos];
|
||||
}
|
||||
|
||||
internal int ConstructorArgumentCount
|
||||
{
|
||||
get { return constructorArgs == null ? 0 : constructorArgs.Length; }
|
||||
}
|
||||
|
||||
internal T? GetFieldValue<T>(string name) where T : struct
|
||||
{
|
||||
object val = GetFieldValue(name);
|
||||
if (val is T)
|
||||
{
|
||||
return (T)val;
|
||||
}
|
||||
else if (val != null)
|
||||
{
|
||||
if (typeof(T).IsEnum)
|
||||
{
|
||||
Debug.Assert(Enum.GetUnderlyingType(typeof(T)) == val.GetType());
|
||||
return (T)Enum.ToObject(typeof(T), val);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(Enum.GetUnderlyingType(val.GetType()) == typeof(T));
|
||||
return (T)Convert.ChangeType(val, typeof(T));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
internal object GetFieldValue(string name)
|
||||
{
|
||||
if (namedFields != null)
|
||||
{
|
||||
for (int i = 0; i < namedFields.Length; i++)
|
||||
{
|
||||
if (namedFields[i].Name == name)
|
||||
{
|
||||
return fieldValues[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
internal void WriteNamedArgumentsForDeclSecurity(ModuleBuilder moduleBuilder, ByteBuffer bb)
|
||||
{
|
||||
BlobWriter bw = new BlobWriter(moduleBuilder, this, bb);
|
||||
bw.WriteNamedArguments(true);
|
||||
}
|
||||
|
||||
internal CustomAttributeData ToData(Assembly asm)
|
||||
{
|
||||
if (blob != null)
|
||||
{
|
||||
return new CustomAttributeData(asm, con, new IKVM.Reflection.Reader.ByteReader(blob, 0, blob.Length));
|
||||
}
|
||||
else
|
||||
{
|
||||
List<CustomAttributeNamedArgument> namedArgs = new List<CustomAttributeNamedArgument>();
|
||||
if (namedProperties != null)
|
||||
{
|
||||
for (int i = 0; i < namedProperties.Length; i++)
|
||||
{
|
||||
namedArgs.Add(new CustomAttributeNamedArgument(namedProperties[i], new CustomAttributeTypedArgument(namedProperties[i].PropertyType, propertyValues[i])));
|
||||
}
|
||||
}
|
||||
if (namedFields != null)
|
||||
{
|
||||
for (int i = 0; i < namedFields.Length; i++)
|
||||
{
|
||||
namedArgs.Add(new CustomAttributeNamedArgument(namedFields[i], new CustomAttributeTypedArgument(namedFields[i].FieldType, fieldValues[i])));
|
||||
}
|
||||
}
|
||||
return new CustomAttributeData(con, constructorArgs, namedArgs);
|
||||
}
|
||||
}
|
||||
|
||||
internal bool HasBlob
|
||||
{
|
||||
get { return blob != null; }
|
||||
}
|
||||
|
||||
internal CustomAttributeBuilder DecodeBlob(Assembly asm)
|
||||
{
|
||||
if (blob == null)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ToData(asm).__ToBuilder();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2010 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace IKVM.Reflection.Emit
|
||||
{
|
||||
public sealed class EnumBuilder : Type
|
||||
{
|
||||
private readonly TypeBuilder typeBuilder;
|
||||
private readonly FieldBuilder fieldBuilder;
|
||||
|
||||
internal EnumBuilder(TypeBuilder typeBuilder, FieldBuilder fieldBuilder)
|
||||
{
|
||||
this.typeBuilder = typeBuilder;
|
||||
this.fieldBuilder = fieldBuilder;
|
||||
}
|
||||
|
||||
public override Type UnderlyingSystemType
|
||||
{
|
||||
get { return typeBuilder.UnderlyingSystemType; }
|
||||
}
|
||||
|
||||
public override Type BaseType
|
||||
{
|
||||
get { return typeBuilder.BaseType; }
|
||||
}
|
||||
|
||||
public override TypeAttributes Attributes
|
||||
{
|
||||
get { return typeBuilder.Attributes; }
|
||||
}
|
||||
|
||||
public override Module Module
|
||||
{
|
||||
get { return typeBuilder.Module; }
|
||||
}
|
||||
|
||||
public FieldBuilder DefineLiteral(string literalName, object literalValue)
|
||||
{
|
||||
FieldBuilder fb = typeBuilder.DefineField(literalName, typeBuilder, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
|
||||
fb.SetConstant(literalValue);
|
||||
return fb;
|
||||
}
|
||||
|
||||
public Type CreateType()
|
||||
{
|
||||
return typeBuilder.CreateType();
|
||||
}
|
||||
|
||||
public TypeToken TypeToken
|
||||
{
|
||||
get { return typeBuilder.TypeToken; }
|
||||
}
|
||||
|
||||
public FieldBuilder UnderlyingField
|
||||
{
|
||||
get { return fieldBuilder; }
|
||||
}
|
||||
|
||||
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
|
||||
{
|
||||
typeBuilder.SetCustomAttribute(con, binaryAttribute);
|
||||
}
|
||||
|
||||
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
|
||||
{
|
||||
typeBuilder.SetCustomAttribute(customBuilder);
|
||||
}
|
||||
|
||||
public override Type GetEnumUnderlyingType()
|
||||
{
|
||||
return fieldBuilder.FieldType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2008 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
|
||||
namespace IKVM.Reflection.Emit
|
||||
{
|
||||
public enum AssemblyBuilderAccess
|
||||
{
|
||||
Save = 2,
|
||||
ReflectionOnly = 6,
|
||||
}
|
||||
|
||||
public enum OpCodeType
|
||||
{
|
||||
Annotation = 0,
|
||||
Macro = 1,
|
||||
Nternal = 2,
|
||||
Objmodel = 3,
|
||||
Prefix = 4,
|
||||
Primitive = 5,
|
||||
}
|
||||
|
||||
public enum OperandType
|
||||
{
|
||||
InlineBrTarget = 0,
|
||||
InlineField = 1,
|
||||
InlineI = 2,
|
||||
InlineI8 = 3,
|
||||
InlineMethod = 4,
|
||||
InlineNone = 5,
|
||||
InlinePhi = 6,
|
||||
InlineR = 7,
|
||||
InlineSig = 9,
|
||||
InlineString = 10,
|
||||
InlineSwitch = 11,
|
||||
InlineTok = 12,
|
||||
InlineType = 13,
|
||||
InlineVar = 14,
|
||||
ShortInlineBrTarget = 15,
|
||||
ShortInlineI = 16,
|
||||
ShortInlineR = 17,
|
||||
ShortInlineVar = 18,
|
||||
}
|
||||
|
||||
public enum FlowControl
|
||||
{
|
||||
Branch = 0,
|
||||
Break = 1,
|
||||
Call = 2,
|
||||
Cond_Branch = 3,
|
||||
Meta = 4,
|
||||
Next = 5,
|
||||
Return = 7,
|
||||
Throw = 8,
|
||||
}
|
||||
|
||||
public enum PackingSize
|
||||
{
|
||||
Unspecified = 0,
|
||||
Size1 = 1,
|
||||
Size2 = 2,
|
||||
Size4 = 4,
|
||||
Size8 = 8,
|
||||
Size16 = 16,
|
||||
Size32 = 32,
|
||||
Size64 = 64,
|
||||
Size128 = 128,
|
||||
}
|
||||
|
||||
public enum PEFileKinds
|
||||
{
|
||||
Dll = 1,
|
||||
ConsoleApplication = 2,
|
||||
WindowApplication = 3,
|
||||
}
|
||||
|
||||
public enum StackBehaviour
|
||||
{
|
||||
Pop0 = 0,
|
||||
Pop1 = 1,
|
||||
Pop1_pop1 = 2,
|
||||
Popi = 3,
|
||||
Popi_pop1 = 4,
|
||||
Popi_popi = 5,
|
||||
Popi_popi8 = 6,
|
||||
Popi_popi_popi = 7,
|
||||
Popi_popr4 = 8,
|
||||
Popi_popr8 = 9,
|
||||
Popref = 10,
|
||||
Popref_pop1 = 11,
|
||||
Popref_popi = 12,
|
||||
Popref_popi_popi = 13,
|
||||
Popref_popi_popi8 = 14,
|
||||
Popref_popi_popr4 = 15,
|
||||
Popref_popi_popr8 = 16,
|
||||
Popref_popi_popref = 17,
|
||||
Push0 = 18,
|
||||
Push1 = 19,
|
||||
Push1_push1 = 20,
|
||||
Pushi = 21,
|
||||
Pushi8 = 22,
|
||||
Pushr4 = 23,
|
||||
Pushr8 = 24,
|
||||
Pushref = 25,
|
||||
Varpop = 26,
|
||||
Varpush = 27,
|
||||
Popref_popi_pop1 = 28,
|
||||
}
|
||||
}
|
||||
@@ -1,250 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using IKVM.Reflection.Metadata;
|
||||
using IKVM.Reflection.Writer;
|
||||
|
||||
namespace IKVM.Reflection.Emit
|
||||
{
|
||||
public sealed class EventBuilder : EventInfo
|
||||
{
|
||||
private readonly TypeBuilder typeBuilder;
|
||||
private readonly string name;
|
||||
private EventAttributes attributes;
|
||||
private readonly int eventtype;
|
||||
private MethodBuilder addOnMethod;
|
||||
private MethodBuilder removeOnMethod;
|
||||
private MethodBuilder fireMethod;
|
||||
private List<MethodBuilder> otherMethods;
|
||||
private int lazyPseudoToken;
|
||||
|
||||
internal EventBuilder(TypeBuilder typeBuilder, string name, EventAttributes attributes, Type eventtype)
|
||||
{
|
||||
this.typeBuilder = typeBuilder;
|
||||
this.name = name;
|
||||
this.attributes = attributes;
|
||||
this.eventtype = typeBuilder.ModuleBuilder.GetTypeTokenForMemberRef(eventtype);
|
||||
}
|
||||
|
||||
public void SetAddOnMethod(MethodBuilder mdBuilder)
|
||||
{
|
||||
addOnMethod = mdBuilder;
|
||||
}
|
||||
|
||||
public void SetRemoveOnMethod(MethodBuilder mdBuilder)
|
||||
{
|
||||
removeOnMethod = mdBuilder;
|
||||
}
|
||||
|
||||
public void SetRaiseMethod(MethodBuilder mdBuilder)
|
||||
{
|
||||
fireMethod = mdBuilder;
|
||||
}
|
||||
|
||||
public void AddOtherMethod(MethodBuilder mdBuilder)
|
||||
{
|
||||
if (otherMethods == null)
|
||||
{
|
||||
otherMethods = new List<MethodBuilder>();
|
||||
}
|
||||
otherMethods.Add(mdBuilder);
|
||||
}
|
||||
|
||||
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
|
||||
{
|
||||
SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute));
|
||||
}
|
||||
|
||||
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
|
||||
{
|
||||
Universe u = typeBuilder.ModuleBuilder.universe;
|
||||
if (customBuilder.Constructor.DeclaringType == u.System_Runtime_CompilerServices_SpecialNameAttribute)
|
||||
{
|
||||
attributes |= EventAttributes.SpecialName;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lazyPseudoToken == 0)
|
||||
{
|
||||
lazyPseudoToken = typeBuilder.ModuleBuilder.AllocPseudoToken();
|
||||
}
|
||||
typeBuilder.ModuleBuilder.SetCustomAttribute(lazyPseudoToken, customBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
public override EventAttributes Attributes
|
||||
{
|
||||
get { return attributes; }
|
||||
}
|
||||
|
||||
public override MethodInfo GetAddMethod(bool nonPublic)
|
||||
{
|
||||
return nonPublic || (addOnMethod != null && addOnMethod.IsPublic) ? addOnMethod : null;
|
||||
}
|
||||
|
||||
public override MethodInfo GetRemoveMethod(bool nonPublic)
|
||||
{
|
||||
return nonPublic || (removeOnMethod != null && removeOnMethod.IsPublic) ? removeOnMethod : null;
|
||||
}
|
||||
|
||||
public override MethodInfo GetRaiseMethod(bool nonPublic)
|
||||
{
|
||||
return nonPublic || (fireMethod != null && fireMethod.IsPublic) ? fireMethod : null;
|
||||
}
|
||||
|
||||
public override MethodInfo[] GetOtherMethods(bool nonPublic)
|
||||
{
|
||||
List<MethodInfo> list = new List<MethodInfo>();
|
||||
if (otherMethods != null)
|
||||
{
|
||||
foreach (MethodInfo method in otherMethods)
|
||||
{
|
||||
if (nonPublic || method.IsPublic)
|
||||
{
|
||||
list.Add(method);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public override Type DeclaringType
|
||||
{
|
||||
get { return typeBuilder; }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return name; }
|
||||
}
|
||||
|
||||
public override Module Module
|
||||
{
|
||||
get { return typeBuilder.ModuleBuilder; }
|
||||
}
|
||||
|
||||
public EventToken GetEventToken()
|
||||
{
|
||||
if (lazyPseudoToken == 0)
|
||||
{
|
||||
lazyPseudoToken = typeBuilder.ModuleBuilder.AllocPseudoToken();
|
||||
}
|
||||
return new EventToken(lazyPseudoToken);
|
||||
}
|
||||
|
||||
public override Type EventHandlerType
|
||||
{
|
||||
get { return typeBuilder.ModuleBuilder.ResolveType(eventtype); }
|
||||
}
|
||||
|
||||
internal void Bake()
|
||||
{
|
||||
EventTable.Record rec = new EventTable.Record();
|
||||
rec.EventFlags = (short)attributes;
|
||||
rec.Name = typeBuilder.ModuleBuilder.Strings.Add(name);
|
||||
rec.EventType = eventtype;
|
||||
int token = 0x14000000 | typeBuilder.ModuleBuilder.Event.AddRecord(rec);
|
||||
|
||||
if (lazyPseudoToken != 0)
|
||||
{
|
||||
typeBuilder.ModuleBuilder.RegisterTokenFixup(lazyPseudoToken, token);
|
||||
}
|
||||
|
||||
if (addOnMethod != null)
|
||||
{
|
||||
AddMethodSemantics(MethodSemanticsTable.AddOn, addOnMethod.MetadataToken, token);
|
||||
}
|
||||
if (removeOnMethod != null)
|
||||
{
|
||||
AddMethodSemantics(MethodSemanticsTable.RemoveOn, removeOnMethod.MetadataToken, token);
|
||||
}
|
||||
if (fireMethod != null)
|
||||
{
|
||||
AddMethodSemantics(MethodSemanticsTable.Fire, fireMethod.MetadataToken, token);
|
||||
}
|
||||
if (otherMethods != null)
|
||||
{
|
||||
foreach (MethodBuilder method in otherMethods)
|
||||
{
|
||||
AddMethodSemantics(MethodSemanticsTable.Other, method.MetadataToken, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddMethodSemantics(short semantics, int methodToken, int propertyToken)
|
||||
{
|
||||
MethodSemanticsTable.Record rec = new MethodSemanticsTable.Record();
|
||||
rec.Semantics = semantics;
|
||||
rec.Method = methodToken;
|
||||
rec.Association = propertyToken;
|
||||
typeBuilder.ModuleBuilder.MethodSemantics.AddRecord(rec);
|
||||
}
|
||||
|
||||
internal override bool IsPublic
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((addOnMethod != null && addOnMethod.IsPublic) || (removeOnMethod != null && removeOnMethod.IsPublic) || (fireMethod != null && fireMethod.IsPublic))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (otherMethods != null)
|
||||
{
|
||||
foreach (MethodBuilder method in otherMethods)
|
||||
{
|
||||
if (method.IsPublic)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal override bool IsStatic
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((addOnMethod != null && addOnMethod.IsStatic) || (removeOnMethod != null && removeOnMethod.IsStatic) || (fireMethod != null && fireMethod.IsStatic))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (otherMethods != null)
|
||||
{
|
||||
foreach (MethodBuilder method in otherMethods)
|
||||
{
|
||||
if (method.IsStatic)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2008 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using IKVM.Reflection.Metadata;
|
||||
using IKVM.Reflection.Writer;
|
||||
|
||||
namespace IKVM.Reflection.Emit
|
||||
{
|
||||
public sealed class FieldBuilder : FieldInfo
|
||||
{
|
||||
private readonly TypeBuilder typeBuilder;
|
||||
private readonly string name;
|
||||
private readonly int pseudoToken;
|
||||
private FieldAttributes attribs;
|
||||
private readonly int nameIndex;
|
||||
private readonly int signature;
|
||||
private readonly FieldSignature fieldSig;
|
||||
|
||||
internal FieldBuilder(TypeBuilder type, string name, Type fieldType, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attribs)
|
||||
{
|
||||
this.typeBuilder = type;
|
||||
this.name = name;
|
||||
this.pseudoToken = type.ModuleBuilder.AllocPseudoToken();
|
||||
this.nameIndex = type.ModuleBuilder.Strings.Add(name);
|
||||
this.fieldSig = FieldSignature.Create(fieldType, optionalCustomModifiers, requiredCustomModifiers);
|
||||
ByteBuffer sig = new ByteBuffer(5);
|
||||
fieldSig.WriteSig(this.typeBuilder.ModuleBuilder, sig);
|
||||
this.signature = this.typeBuilder.ModuleBuilder.Blobs.Add(sig);
|
||||
this.attribs = attribs;
|
||||
this.typeBuilder.ModuleBuilder.Field.AddVirtualRecord();
|
||||
}
|
||||
|
||||
public void SetConstant(object defaultValue)
|
||||
{
|
||||
attribs |= FieldAttributes.HasDefault;
|
||||
typeBuilder.ModuleBuilder.AddConstant(pseudoToken, defaultValue);
|
||||
}
|
||||
|
||||
public override object GetRawConstantValue()
|
||||
{
|
||||
return typeBuilder.Module.Constant.GetRawConstantValue(typeBuilder.Module, this.MetadataToken);
|
||||
}
|
||||
|
||||
public void __SetDataAndRVA(byte[] data)
|
||||
{
|
||||
attribs |= FieldAttributes.HasFieldRVA;
|
||||
FieldRVATable.Record rec = new FieldRVATable.Record();
|
||||
rec.RVA = typeBuilder.ModuleBuilder.initializedData.Position;
|
||||
rec.Field = pseudoToken;
|
||||
typeBuilder.ModuleBuilder.FieldRVA.AddRecord(rec);
|
||||
typeBuilder.ModuleBuilder.initializedData.Write(data);
|
||||
}
|
||||
|
||||
public override void __GetDataFromRVA(byte[] data, int offset, int length)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
|
||||
{
|
||||
SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute));
|
||||
}
|
||||
|
||||
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
|
||||
{
|
||||
Universe u = this.Module.universe;
|
||||
if (customBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_FieldOffsetAttribute)
|
||||
{
|
||||
customBuilder = customBuilder.DecodeBlob(this.Module.Assembly);
|
||||
SetOffset((int)customBuilder.GetConstructorArgument(0));
|
||||
}
|
||||
else if (customBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_MarshalAsAttribute)
|
||||
{
|
||||
MarshalSpec.SetMarshalAsAttribute(typeBuilder.ModuleBuilder, pseudoToken, customBuilder);
|
||||
attribs |= FieldAttributes.HasFieldMarshal;
|
||||
}
|
||||
else if (customBuilder.Constructor.DeclaringType == u.System_NonSerializedAttribute)
|
||||
{
|
||||
attribs |= FieldAttributes.NotSerialized;
|
||||
}
|
||||
else if (customBuilder.Constructor.DeclaringType == u.System_Runtime_CompilerServices_SpecialNameAttribute)
|
||||
{
|
||||
attribs |= FieldAttributes.SpecialName;
|
||||
}
|
||||
else
|
||||
{
|
||||
typeBuilder.ModuleBuilder.SetCustomAttribute(pseudoToken, customBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetOffset(int iOffset)
|
||||
{
|
||||
FieldLayoutTable.Record rec = new FieldLayoutTable.Record();
|
||||
rec.Offset = iOffset;
|
||||
rec.Field = pseudoToken;
|
||||
typeBuilder.ModuleBuilder.FieldLayout.AddRecord(rec);
|
||||
}
|
||||
|
||||
public override FieldAttributes Attributes
|
||||
{
|
||||
get { return attribs; }
|
||||
}
|
||||
|
||||
public override Type DeclaringType
|
||||
{
|
||||
get { return typeBuilder.IsModulePseudoType ? null : typeBuilder; }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return name; }
|
||||
}
|
||||
|
||||
public override int MetadataToken
|
||||
{
|
||||
get { return pseudoToken; }
|
||||
}
|
||||
|
||||
public override Module Module
|
||||
{
|
||||
get { return typeBuilder.Module; }
|
||||
}
|
||||
|
||||
public FieldToken GetToken()
|
||||
{
|
||||
return new FieldToken(pseudoToken);
|
||||
}
|
||||
|
||||
internal void WriteFieldRecords(MetadataWriter mw)
|
||||
{
|
||||
mw.Write((short)attribs);
|
||||
mw.WriteStringIndex(nameIndex);
|
||||
mw.WriteBlobIndex(signature);
|
||||
}
|
||||
|
||||
internal void FixupToken(int token)
|
||||
{
|
||||
typeBuilder.ModuleBuilder.RegisterTokenFixup(this.pseudoToken, token);
|
||||
}
|
||||
|
||||
internal override FieldSignature FieldSignature
|
||||
{
|
||||
get { return fieldSig; }
|
||||
}
|
||||
|
||||
internal override int ImportTo(ModuleBuilder other)
|
||||
{
|
||||
if (typeBuilder.IsGenericTypeDefinition)
|
||||
{
|
||||
return other.ImportMember(TypeBuilder.GetField(typeBuilder, this));
|
||||
}
|
||||
else if (other == typeBuilder.ModuleBuilder)
|
||||
{
|
||||
return pseudoToken;
|
||||
}
|
||||
else
|
||||
{
|
||||
return other.ImportMethodOrField(typeBuilder, name, fieldSig);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,693 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2008-2010 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
[email protected]
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Diagnostics.SymbolStore;
|
||||
using IKVM.Reflection.Metadata;
|
||||
using IKVM.Reflection.Writer;
|
||||
|
||||
namespace IKVM.Reflection.Emit
|
||||
{
|
||||
public sealed class MethodBuilder : MethodInfo
|
||||
{
|
||||
private readonly TypeBuilder typeBuilder;
|
||||
private readonly string name;
|
||||
private readonly int nameIndex;
|
||||
private readonly int pseudoToken;
|
||||
private int signature;
|
||||
private Type returnType;
|
||||
private Type[] parameterTypes;
|
||||
private Type[][][] modifiers; // see PackedCustomModifiers
|
||||
private MethodAttributes attributes;
|
||||
private MethodImplAttributes implFlags;
|
||||
private ILGenerator ilgen;
|
||||
private int rva;
|
||||
private readonly CallingConventions callingConvention;
|
||||
private List<ParameterBuilder> parameters;
|
||||
private GenericTypeParameterBuilder[] gtpb;
|
||||
private List<CustomAttributeBuilder> declarativeSecurity;
|
||||
private MethodSignature methodSignature;
|
||||
private bool initLocals = true;
|
||||
|
||||
internal MethodBuilder(TypeBuilder typeBuilder, string name, MethodAttributes attributes, CallingConventions callingConvention)
|
||||
{
|
||||
this.typeBuilder = typeBuilder;
|
||||
this.name = name;
|
||||
this.pseudoToken = typeBuilder.ModuleBuilder.AllocPseudoToken();
|
||||
// because all the MethodBuilders constitute a virtual MethodDef table, we cannot allocate the string during WriteMethodDefRecord,
|
||||
// since by then the metadata has already been frozen
|
||||
this.nameIndex = typeBuilder.ModuleBuilder.Strings.Add(name);
|
||||
this.attributes = attributes;
|
||||
if ((attributes & MethodAttributes.Static) == 0)
|
||||
{
|
||||
callingConvention |= CallingConventions.HasThis;
|
||||
}
|
||||
this.callingConvention = callingConvention;
|
||||
}
|
||||
|
||||
public ILGenerator GetILGenerator()
|
||||
{
|
||||
return GetILGenerator(16);
|
||||
}
|
||||
|
||||
public ILGenerator GetILGenerator(int streamSize)
|
||||
{
|
||||
if (ilgen == null)
|
||||
{
|
||||
ilgen = new ILGenerator(typeBuilder.ModuleBuilder, streamSize);
|
||||
}
|
||||
return ilgen;
|
||||
}
|
||||
|
||||
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
|
||||
{
|
||||
SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute));
|
||||
}
|
||||
|
||||
private void SetDllImportPseudoCustomAttribute(CustomAttributeBuilder customBuilder)
|
||||
{
|
||||
CallingConvention? callingConvention = customBuilder.GetFieldValue<CallingConvention>("CallingConvention");
|
||||
CharSet? charSet = customBuilder.GetFieldValue<CharSet>("CharSet");
|
||||
SetDllImportPseudoCustomAttribute((string)customBuilder.GetConstructorArgument(0),
|
||||
(string)customBuilder.GetFieldValue("EntryPoint"),
|
||||
callingConvention,
|
||||
charSet,
|
||||
(bool?)customBuilder.GetFieldValue("BestFitMapping"),
|
||||
(bool?)customBuilder.GetFieldValue("ThrowOnUnmappableChar"),
|
||||
(bool?)customBuilder.GetFieldValue("SetLastError"),
|
||||
(bool?)customBuilder.GetFieldValue("PreserveSig"),
|
||||
(bool?)customBuilder.GetFieldValue("ExactSpelling"));
|
||||
}
|
||||
|
||||
internal void SetDllImportPseudoCustomAttribute(string dllName, string entryName, CallingConvention? nativeCallConv, CharSet? nativeCharSet,
|
||||
bool? bestFitMapping, bool? throwOnUnmappableChar, bool? setLastError, bool? preserveSig, bool? exactSpelling)
|
||||
{
|
||||
const short NoMangle = 0x0001;
|
||||
const short CharSetMask = 0x0006;
|
||||
const short CharSetNotSpec = 0x0000;
|
||||
const short CharSetAnsi = 0x0002;
|
||||
const short CharSetUnicode = 0x0004;
|
||||
const short CharSetAuto = 0x0006;
|
||||
const short SupportsLastError = 0x0040;
|
||||
const short CallConvMask = 0x0700;
|
||||
const short CallConvWinapi = 0x0100;
|
||||
const short CallConvCdecl = 0x0200;
|
||||
const short CallConvStdcall = 0x0300;
|
||||
const short CallConvThiscall = 0x0400;
|
||||
const short CallConvFastcall = 0x0500;
|
||||
// non-standard flags
|
||||
const short BestFitOn = 0x0010;
|
||||
const short BestFitOff = 0x0020;
|
||||
const short CharMapErrorOn = 0x1000;
|
||||
const short CharMapErrorOff = 0x2000;
|
||||
int name = this.nameIndex;
|
||||
short flags = CharSetNotSpec | CallConvWinapi;
|
||||
if (bestFitMapping.HasValue)
|
||||
{
|
||||
flags |= bestFitMapping.Value ? BestFitOn : BestFitOff;
|
||||
}
|
||||
if (throwOnUnmappableChar.HasValue)
|
||||
{
|
||||
flags |= throwOnUnmappableChar.Value ? CharMapErrorOn : CharMapErrorOff;
|
||||
}
|
||||
if (nativeCallConv.HasValue)
|
||||
{
|
||||
flags &= ~CallConvMask;
|
||||
switch (nativeCallConv.Value)
|
||||
{
|
||||
case System.Runtime.InteropServices.CallingConvention.Cdecl:
|
||||
flags |= CallConvCdecl;
|
||||
break;
|
||||
case System.Runtime.InteropServices.CallingConvention.FastCall:
|
||||
flags |= CallConvFastcall;
|
||||
break;
|
||||
case System.Runtime.InteropServices.CallingConvention.StdCall:
|
||||
flags |= CallConvStdcall;
|
||||
break;
|
||||
case System.Runtime.InteropServices.CallingConvention.ThisCall:
|
||||
flags |= CallConvThiscall;
|
||||
break;
|
||||
case System.Runtime.InteropServices.CallingConvention.Winapi:
|
||||
flags |= CallConvWinapi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nativeCharSet.HasValue)
|
||||
{
|
||||
flags &= ~CharSetMask;
|
||||
switch (nativeCharSet.Value)
|
||||
{
|
||||
case CharSet.Ansi:
|
||||
case CharSet.None:
|
||||
flags |= CharSetAnsi;
|
||||
break;
|
||||
case CharSet.Auto:
|
||||
flags |= CharSetAuto;
|
||||
break;
|
||||
case CharSet.Unicode:
|
||||
flags |= CharSetUnicode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (entryName != null)
|
||||
{
|
||||
name = this.ModuleBuilder.Strings.Add(entryName);
|
||||
}
|
||||
if (exactSpelling.HasValue && exactSpelling.Value)
|
||||
{
|
||||
flags |= NoMangle;
|
||||
}
|
||||
if (!preserveSig.HasValue || preserveSig.Value)
|
||||
{
|
||||
implFlags |= MethodImplAttributes.PreserveSig;
|
||||
}
|
||||
if (setLastError.HasValue && setLastError.Value)
|
||||
{
|
||||
flags |= SupportsLastError;
|
||||
}
|
||||
ImplMapTable.Record rec = new ImplMapTable.Record();
|
||||
rec.MappingFlags = flags;
|
||||
rec.MemberForwarded = pseudoToken;
|
||||
rec.ImportName = name;
|
||||
rec.ImportScope = this.ModuleBuilder.ModuleRef.FindOrAddRecord(dllName == null ? 0 : this.ModuleBuilder.Strings.Add(dllName));
|
||||
this.ModuleBuilder.ImplMap.AddRecord(rec);
|
||||
}
|
||||
|
||||
private void SetMethodImplAttribute(CustomAttributeBuilder customBuilder)
|
||||
{
|
||||
MethodImplOptions opt;
|
||||
switch (customBuilder.Constructor.ParameterCount)
|
||||
{
|
||||
case 0:
|
||||
opt = 0;
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
object val = customBuilder.GetConstructorArgument(0);
|
||||
if (val is short)
|
||||
{
|
||||
opt = (MethodImplOptions)(short)val;
|
||||
}
|
||||
else if (val is int)
|
||||
{
|
||||
opt = (MethodImplOptions)(int)val;
|
||||
}
|
||||
else
|
||||
{
|
||||
opt = (MethodImplOptions)val;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
MethodCodeType? type = customBuilder.GetFieldValue<MethodCodeType>("MethodCodeType");
|
||||
implFlags = (MethodImplAttributes)opt;
|
||||
if (type.HasValue)
|
||||
{
|
||||
implFlags |= (MethodImplAttributes)type;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
|
||||
{
|
||||
Universe u = this.ModuleBuilder.universe;
|
||||
Type type = customBuilder.Constructor.DeclaringType;
|
||||
if (type == u.System_Runtime_InteropServices_DllImportAttribute)
|
||||
{
|
||||
attributes |= MethodAttributes.PinvokeImpl;
|
||||
SetDllImportPseudoCustomAttribute(customBuilder.DecodeBlob(this.Module.Assembly));
|
||||
}
|
||||
else if (type == u.System_Runtime_CompilerServices_MethodImplAttribute)
|
||||
{
|
||||
SetMethodImplAttribute(customBuilder.DecodeBlob(this.Module.Assembly));
|
||||
}
|
||||
else if (type == u.System_Runtime_InteropServices_PreserveSigAttribute)
|
||||
{
|
||||
implFlags |= MethodImplAttributes.PreserveSig;
|
||||
}
|
||||
else if (type == u.System_Runtime_CompilerServices_SpecialNameAttribute)
|
||||
{
|
||||
attributes |= MethodAttributes.SpecialName;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == u.System_Security_SuppressUnmanagedCodeSecurityAttribute)
|
||||
{
|
||||
attributes |= MethodAttributes.HasSecurity;
|
||||
}
|
||||
this.ModuleBuilder.SetCustomAttribute(pseudoToken, customBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
public void __AddDeclarativeSecurity(CustomAttributeBuilder customBuilder)
|
||||
{
|
||||
attributes |= MethodAttributes.HasSecurity;
|
||||
if (declarativeSecurity == null)
|
||||
{
|
||||
declarativeSecurity = new List<CustomAttributeBuilder>();
|
||||
}
|
||||
declarativeSecurity.Add(customBuilder);
|
||||
}
|
||||
|
||||
public void AddDeclarativeSecurity(System.Security.Permissions.SecurityAction securityAction, System.Security.PermissionSet permissionSet)
|
||||
{
|
||||
this.ModuleBuilder.AddDeclarativeSecurity(pseudoToken, securityAction, permissionSet);
|
||||
this.attributes |= MethodAttributes.HasSecurity;
|
||||
}
|
||||
|
||||
public void SetImplementationFlags(MethodImplAttributes attributes)
|
||||
{
|
||||
implFlags = attributes;
|
||||
}
|
||||
|
||||
public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, string strParamName)
|
||||
{
|
||||
// the parameter is named "position", but it is actually a sequence number (i.e. 0 = return parameter, 1 = first parameter)
|
||||
int sequence = position--;
|
||||
if (parameters == null)
|
||||
{
|
||||
parameters = new List<ParameterBuilder>();
|
||||
}
|
||||
this.ModuleBuilder.Param.AddVirtualRecord();
|
||||
ParameterBuilder pb = new ParameterBuilder(this.ModuleBuilder, sequence, attributes, strParamName);
|
||||
if (parameters.Count == 0 || position > parameters[parameters.Count - 1].Position)
|
||||
{
|
||||
parameters.Add(pb);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < parameters.Count; i++)
|
||||
{
|
||||
if (parameters[i].Position > position)
|
||||
{
|
||||
parameters.Insert(i, pb);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return pb;
|
||||
}
|
||||
|
||||
public void SetParameters(params Type[] parameterTypes)
|
||||
{
|
||||
this.parameterTypes = Util.Copy(parameterTypes);
|
||||
}
|
||||
|
||||
public void SetReturnType(Type returnType)
|
||||
{
|
||||
this.returnType = returnType ?? this.Module.universe.System_Void;
|
||||
}
|
||||
|
||||
public void SetSignature(Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
|
||||
{
|
||||
this.returnType = returnType ?? this.Module.universe.System_Void;
|
||||
this.parameterTypes = Util.Copy(parameterTypes);
|
||||
this.modifiers = PackedCustomModifiers.CreateFromExternal(returnTypeOptionalCustomModifiers, returnTypeRequiredCustomModifiers,
|
||||
parameterTypeOptionalCustomModifiers, parameterTypeRequiredCustomModifiers, this.parameterTypes.Length);
|
||||
}
|
||||
|
||||
public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names)
|
||||
{
|
||||
gtpb = new GenericTypeParameterBuilder[names.Length];
|
||||
for (int i = 0; i < names.Length; i++)
|
||||
{
|
||||
gtpb[i] = new GenericTypeParameterBuilder(names[i], null, this, i);
|
||||
}
|
||||
return (GenericTypeParameterBuilder[])gtpb.Clone();
|
||||
}
|
||||
|
||||
public override MethodInfo MakeGenericMethod(params Type[] typeArguments)
|
||||
{
|
||||
return new GenericMethodInstance(typeBuilder, this, typeArguments);
|
||||
}
|
||||
|
||||
public override MethodInfo GetGenericMethodDefinition()
|
||||
{
|
||||
if (gtpb == null)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Type[] GetGenericArguments()
|
||||
{
|
||||
return Util.Copy(gtpb);
|
||||
}
|
||||
|
||||
internal override Type GetGenericMethodArgument(int index)
|
||||
{
|
||||
return gtpb[index];
|
||||
}
|
||||
|
||||
internal override int GetGenericMethodArgumentCount()
|
||||
{
|
||||
return gtpb == null ? 0 : gtpb.Length;
|
||||
}
|
||||
|
||||
public override Type ReturnType
|
||||
{
|
||||
get { return returnType; }
|
||||
}
|
||||
|
||||
public override ParameterInfo ReturnParameter
|
||||
{
|
||||
get { return new ParameterInfoImpl(this, -1); }
|
||||
}
|
||||
|
||||
public override MethodAttributes Attributes
|
||||
{
|
||||
get { return attributes; }
|
||||
}
|
||||
|
||||
public void __SetAttributes(MethodAttributes attributes)
|
||||
{
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
public override MethodImplAttributes GetMethodImplementationFlags()
|
||||
{
|
||||
return implFlags;
|
||||
}
|
||||
|
||||
private sealed class ParameterInfoImpl : ParameterInfo
|
||||
{
|
||||
private readonly MethodBuilder method;
|
||||
private readonly int parameter;
|
||||
|
||||
internal ParameterInfoImpl(MethodBuilder method, int parameter)
|
||||
{
|
||||
this.method = method;
|
||||
this.parameter = parameter;
|
||||
}
|
||||
|
||||
private ParameterBuilder ParameterBuilder
|
||||
{
|
||||
get
|
||||
{
|
||||
if (method.parameters != null)
|
||||
{
|
||||
foreach (ParameterBuilder pb in method.parameters)
|
||||
{
|
||||
if (pb.Position == parameter)
|
||||
{
|
||||
return pb;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
ParameterBuilder pb = this.ParameterBuilder;
|
||||
return pb != null ? pb.Name : null;
|
||||
}
|
||||
}
|
||||
|
||||
public override Type ParameterType
|
||||
{
|
||||
get { return parameter == -1 ? method.returnType : method.parameterTypes[parameter]; }
|
||||
}
|
||||
|
||||
public override ParameterAttributes Attributes
|
||||
{
|
||||
get
|
||||
{
|
||||
ParameterBuilder pb = this.ParameterBuilder;
|
||||
return pb != null ? (ParameterAttributes)pb.Attributes : ParameterAttributes.None;
|
||||
}
|
||||
}
|
||||
|
||||
public override int Position
|
||||
{
|
||||
get { return parameter; }
|
||||
}
|
||||
|
||||
public override object RawDefaultValue
|
||||
{
|
||||
get
|
||||
{
|
||||
ParameterBuilder pb = this.ParameterBuilder;
|
||||
if (pb != null && (pb.Attributes & (int)ParameterAttributes.HasDefault) != 0)
|
||||
{
|
||||
return method.ModuleBuilder.Constant.GetRawConstantValue(method.ModuleBuilder, pb.PseudoToken);
|
||||
}
|
||||
if (pb != null && (pb.Attributes & (int)ParameterAttributes.Optional) != 0)
|
||||
{
|
||||
return Missing.Value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Type[] GetCustomModifiers(int optOrReq)
|
||||
{
|
||||
if (method.modifiers == null || method.modifiers[parameter + 1] == null)
|
||||
{
|
||||
return Type.EmptyTypes;
|
||||
}
|
||||
return Util.Copy(method.modifiers[parameter + 1][optOrReq]);
|
||||
}
|
||||
|
||||
public override Type[] GetOptionalCustomModifiers()
|
||||
{
|
||||
return GetCustomModifiers(0);
|
||||
}
|
||||
|
||||
public override Type[] GetRequiredCustomModifiers()
|
||||
{
|
||||
return GetCustomModifiers(1);
|
||||
}
|
||||
|
||||
public override MemberInfo Member
|
||||
{
|
||||
get { return method; }
|
||||
}
|
||||
|
||||
public override int MetadataToken
|
||||
{
|
||||
get
|
||||
{
|
||||
ParameterBuilder pb = this.ParameterBuilder;
|
||||
return pb != null ? pb.PseudoToken : 0x08000000;
|
||||
}
|
||||
}
|
||||
|
||||
internal override Module Module
|
||||
{
|
||||
get { return method.Module; }
|
||||
}
|
||||
}
|
||||
|
||||
public override ParameterInfo[] GetParameters()
|
||||
{
|
||||
ParameterInfo[] parameters = new ParameterInfo[parameterTypes.Length];
|
||||
for (int i = 0; i < parameters.Length; i++)
|
||||
{
|
||||
parameters[i] = new ParameterInfoImpl(this, i);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
internal override int ParameterCount
|
||||
{
|
||||
get { return parameterTypes.Length; }
|
||||
}
|
||||
|
||||
public override Type DeclaringType
|
||||
{
|
||||
get { return typeBuilder.IsModulePseudoType ? null : typeBuilder; }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return name; }
|
||||
}
|
||||
|
||||
public override CallingConventions CallingConvention
|
||||
{
|
||||
get { return callingConvention; }
|
||||
}
|
||||
|
||||
public override int MetadataToken
|
||||
{
|
||||
get { return pseudoToken; }
|
||||
}
|
||||
|
||||
public override bool IsGenericMethod
|
||||
{
|
||||
get { return gtpb != null; }
|
||||
}
|
||||
|
||||
public override bool IsGenericMethodDefinition
|
||||
{
|
||||
get { return gtpb != null; }
|
||||
}
|
||||
|
||||
public override Module Module
|
||||
{
|
||||
get { return typeBuilder.Module; }
|
||||
}
|
||||
|
||||
public Module GetModule()
|
||||
{
|
||||
return typeBuilder.Module;
|
||||
}
|
||||
|
||||
public MethodToken GetToken()
|
||||
{
|
||||
return new MethodToken(pseudoToken);
|
||||
}
|
||||
|
||||
public override MethodBody GetMethodBody()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool InitLocals
|
||||
{
|
||||
get { return initLocals; }
|
||||
set { initLocals = value; }
|
||||
}
|
||||
|
||||
internal void Bake()
|
||||
{
|
||||
this.signature = this.ModuleBuilder.GetSignatureBlobIndex(this.MethodSignature);
|
||||
|
||||
if (ilgen != null)
|
||||
{
|
||||
if (this.ModuleBuilder.symbolWriter != null)
|
||||
{
|
||||
this.ModuleBuilder.symbolWriter.OpenMethod(new SymbolToken(-pseudoToken | 0x06000000));
|
||||
}
|
||||
rva = ilgen.WriteBody(initLocals);
|
||||
if (this.ModuleBuilder.symbolWriter != null)
|
||||
{
|
||||
this.ModuleBuilder.symbolWriter.CloseMethod();
|
||||
}
|
||||
ilgen = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
rva = -1;
|
||||
}
|
||||
|
||||
if (declarativeSecurity != null)
|
||||
{
|
||||
this.ModuleBuilder.AddDeclarativeSecurity(pseudoToken, declarativeSecurity);
|
||||
}
|
||||
}
|
||||
|
||||
internal ModuleBuilder ModuleBuilder
|
||||
{
|
||||
get { return typeBuilder.ModuleBuilder; }
|
||||
}
|
||||
|
||||
internal void WriteMethodDefRecord(int baseRVA, MetadataWriter mw, ref int paramList)
|
||||
{
|
||||
if (rva != -1)
|
||||
{
|
||||
mw.Write(rva + baseRVA);
|
||||
}
|
||||
else
|
||||
{
|
||||
mw.Write(0);
|
||||
}
|
||||
mw.Write((short)implFlags);
|
||||
mw.Write((short)attributes);
|
||||
mw.WriteStringIndex(nameIndex);
|
||||
mw.WriteBlobIndex(signature);
|
||||
mw.WriteParam(paramList);
|
||||
if (parameters != null)
|
||||
{
|
||||
paramList += parameters.Count;
|
||||
}
|
||||
}
|
||||
|
||||
internal void WriteParamRecords(MetadataWriter mw)
|
||||
{
|
||||
if (parameters != null)
|
||||
{
|
||||
foreach (ParameterBuilder pb in parameters)
|
||||
{
|
||||
pb.WriteParamRecord(mw);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void FixupToken(int token, ref int parameterToken)
|
||||
{
|
||||
typeBuilder.ModuleBuilder.RegisterTokenFixup(this.pseudoToken, token);
|
||||
if (parameters != null)
|
||||
{
|
||||
foreach (ParameterBuilder pb in parameters)
|
||||
{
|
||||
pb.FixupToken(parameterToken++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override MethodSignature MethodSignature
|
||||
{
|
||||
get
|
||||
{
|
||||
if (methodSignature == null)
|
||||
{
|
||||
methodSignature = MethodSignature.MakeFromBuilder(returnType, parameterTypes, modifiers, callingConvention, gtpb == null ? 0 : gtpb.Length);
|
||||
}
|
||||
return methodSignature;
|
||||
}
|
||||
}
|
||||
|
||||
internal override int ImportTo(ModuleBuilder other)
|
||||
{
|
||||
if (typeBuilder.IsGenericTypeDefinition)
|
||||
{
|
||||
return other.ImportMember(TypeBuilder.GetMethod(typeBuilder, this));
|
||||
}
|
||||
else if (other == typeBuilder.ModuleBuilder)
|
||||
{
|
||||
return pseudoToken;
|
||||
}
|
||||
else
|
||||
{
|
||||
return other.ImportMethodOrField(typeBuilder, name, this.MethodSignature);
|
||||
}
|
||||
}
|
||||
|
||||
internal void CheckBaked()
|
||||
{
|
||||
typeBuilder.CheckBaked();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 4691 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user