Compare commits

..
Author SHA1 Message Date
nobody 0ed4ed7b6a This commit was manufactured by cvs2svn to create tag 'MONO_BETA2'.
svn path=/tags/MONO_BETA2/mcs/; revision=28524
2004-05-31 02:31:16 +00:00
472 changed files with 22621 additions and 96247 deletions

No files matched your search

+8 -11
View File
@@ -1,26 +1,23 @@
Makefile
Makefile.in
_tmpinst
aclocal.m4
autom4te.cache
config.cache
config.guess
config.h
config.h.in
config.h.in
config.log
config.status
config.sub
configure
libtool
ltconfig
ltmain.sh
mint.pc
ltconfig
Makefile
Makefile.in
mono-*.tar.gz
mono.pc
mono.spec
semantic.cache
stamp-h
stamp-h.in
mono.pc
mono.spec
autom4te.cache
mint.pc
stamp-h1
tmpinst-dir.stamp
config.h.in
-452
View File
@@ -1,455 +1,3 @@
2004-11-08 Jonathan Pryor <[email protected]>
* configure.in: Add new function/header/type checks for use by
MonoPosixHelper (the support directory).
* support/Makefile.am: Add sys-sendfile.c to the build.
* support/dirent.c, support/fcntl.c, support/unistd.c: Remove compile-time
checks for -64 apis (pread64, etc.), as they're superfluous. GLibc
#defines the functions to the appropriate -64 counterpart when necessary,
and Darwin is intrinsically large-file-aware, so manual checking on my
part is redundant and unnecessary.
* support/grp.c: Add checks for non-portable functions getgrnam_r,
getgrgid_r.
* support/pwd.c: Add checks for non-portable functions getpwnam_r,
getpwuid_r.
* support/map.c: Remove <poll.h> include. Building on Tigar (Mac OS X 10.4
beta) breaks when both <poll.h> and <sys/poll.h> are included, so only use
<sys/poll.h>.
* support/mph.h: Clean up macro handling for type overflow checking.
2004-11-08 Raja R Harinath <[email protected]>
* configure.in (mcs_topdir, mcs_topdir_from_srcdir): New 'subst'ed
variables. Used to support both an in-tree mcs/ and a sibling
mcs/ directory.
* Makefile.am (mcs_topdir): Remove.
(dist-hook): Distribute mcs/ as a subdirectory.
* runtime/Makefile.am ($(monoone_DATA) $(monotwo_DATA) $(monobins_DATA)):
Use mcs_topdir and mcs_topdir_from_srcdir.
* runtime/net_1_1/Makefile.am (mscorlib.dll $(gac_assemblies) $(mdb_files)):
Likewise.
(all-local): Depend on $(mdb_files) too.
* runtime/net_2_0/Makefile.am: Likewise.
2004-11-05 Zoltan Varga <[email protected]>
* runtime/net_2_0/Makefile.am (install-data-local):
* runtime/net_1_1/Makefile.am (install-data-local): Applied patch
from Götz Waschk ([email protected]). Make this work
with DESTDIR.
2004-11-05 Jonathan Pryor <[email protected]>
* support/.cvsignore: Ignore generated files.
* support/Makefile.am: Add new INCLUDE directives (for glib headers),
source; bump library version (so we don't clobber previous versions of
libMonoPosixHelper.so).
* support/dirent.c: New file; <dirent.h> wrapper functions;
BSD portability fixes.
* support/errno.c: New file; <errno.h> wrapper functions
* support/fcntl.c: New file; <fcntl.h> wrapper functions;
BSD portability fixes.
* support/grp.c: New file; <grp.h> wrapper functions;
BSD portability fixes.
* support/map.c: Updated macro mapping functions (more enums mapped, more
error checking, etc.).
* support/map.h: Updated macro mapping functions
* support/old-map.c: Previous map.c implementation, for backward compatibility
Remove spurious warning about redefining _GNU_SOURCE.
* support/old-map.h: Previous map.h implementation, for backward compatibility
* support/mph.h: New file; Utility types, macros;
BSD portability fixes.
* support/pwd.c: New file; <pwd.h> wrapper functions;
BSD portability fixes.
* support/stdio.c: New file; <stdio.h> wrapper functions
* support/stdlib.c: New file; <stdlib.h> wrapper functions
* support/sys-mman.c: New file; <sys/mman.h> wrapper functions
* support/sys-mount.c: New file; <sys/mount.h> wrapper functions;
BSD portability fixes.
* support/sys-sendfile.c: New file; <sys/sendfile.h> wrapper functions;
BSD portability fixes.
* support/sys-stat.c: New file; <sys/stat.h> wrapper functions
* support/sys-wait.c: New file; <sys/wait.h> wrapper functions
* support/time.c: New file; <time.h> wrapper functions;
BSD portability fixes.
* support/unistd.c: New file; <unistd.h> wrapper functions;
BSD portability fixes.
2004-10-31 Zoltan Varga <[email protected]>
* configure.in: Fix up --with-jit=no so it actually works. Fixes
#61320.
2004-10-29 Gonzalo Paniagua Javier <[email protected]>
* man/mono.1: documented MONO_THREADS_PER_CPU.
2004-10-29 Zoltan Varga <[email protected]>
* configure.in: Add INCLUDED_LIBGC automake conditional.
2004-10-24 Jonathan Pryor <[email protected]>
* man/mono.1: Add documentation for the MONO_TRACE environment variable.
2004-10-14 Joe Shaw <[email protected]>
* man/mono.1: Fix the syntax of the M: trace syntax
2004-10-10 Zoltan Varga <[email protected]>
* configure.in: Add some checks for cygwin weirdness.
2004-10-08 Zoltan Varga <[email protected]>
* support/Makefile.am (libMonoPosixHelper_la_SOURCES): Do not build
zlib_macros if zlib.h is not found.
* configure.in: Add check for zlib.h.
2004-09-28 Neale Ferguson <[email protected]>
* mini-s390.c: Fix AND_IMM/OR_IMM/DIV_IMM/REM_IMM
2004-09-28 Raja R Harinath <[email protected]>
* Makefile.am ($(tmpinst)/bin/pedump): New.
(mcs-do-run-test-profiles): Depend on it.
2004-09-27 Raja R Harinath <[email protected]>
* Makefile.am (mono-do-testjit): New target, unused for now. Runs
the mono testsuite in tests/.
(tmpinst-dir): Create etc/mono/2.0.
($(tmpinst)/bin/ilasm, $(tmpinst)/etc/mono/2.0/machine.config): New.
2004-09-21 Neale Ferguson <[email protected]>
* configure.in: Cater for S/390 on Linux
2004-09-21 <[email protected]>
* configure.in: Link with ole32 on windows.
2004-09-20 Jackson Harper <[email protected]>
* support/map.c/h: Add poll events map functions. Use values
instead of names for defines.
2004-09-17 Martin Baulig <[email protected]>
* Makefile.am (mcs-do-compiler-tests): Reverted Raja's latest
change in this target.
2004-09-14 Raja R Harinath <[email protected]>
* Makefile.am (mcs-do-full-build): Pass NO_SIGN_ASSEMBLIES=yes to
reduce the number of passes. We will get the assemblies signed in
the 'populate-runtime-subdir' phase.
(mcs-do-run-test-profiles): Rename from mcs-do-run-tests. Use
'test-profiles' to test all profiles.
(mcs-do-compiler-tests): Use 'compiler-tests' target in mcs/.
(bootstrap-check): Update.
* runtime/Makefile.am ($(monoone_DATA) $(monotwo_DATA) $(monobins_DATA)):
Simplify.
2004-09-10 Zoltan Varga <[email protected]>
* Makefile.am (populate-runtime-subdir): Avoid -path argument to find
since it is not supported on solaris.
2004-09-03 Martin Baulig <[email protected]>
* Makefile.am (bootstrap-world): New target.
2004-09-02 Martin Baulig <[email protected]>
* runtime/net_1_1/Makefile.am (install-data-local): Install
mscorlib.dll.mdb into $(corlibdir).
* runtime/net_2_0/Makefile.am: Likewise.
2004-08-30 Zoltan Varga <[email protected]>
* scripts/mcs.in: Remove obsolete comment.
2004-08-27 Lluis Sanchez Gual <[email protected]>
* data/net_1_1/DefaultWsdlHelpGenerator.aspx: Little fix.
* data/net_2_0/DefaultWsdlHelpGenerator.aspx: Added information about
basic profile compliance.
* data/net_2_0/machine.config: Use 2.0 assembly versions.
2004-08-26 Raja R Harinath <[email protected]>
* Makefile.am (mcs-do-run-test): Depend on '$(tmpinst)/bin/mbas'.
($(tmpinst)/bin/mbas): Create temporary wrapper file, so that the
testcases pick the built 'mbas.exe'.
2004-08-17 Zoltan Varga <[email protected]>
* mono/os/gc_wrapper.h: Only use thread local alloc if using the included libgc, since the
stock one has broken headers.
* configure.in (PLATFORM_WIN32): Make the included libgc the default on windows.
2004-08-17 Dick Porter <[email protected]>
* configure.in: Correct intl library for FreeBSD and OpenBSD.
Fixes bug 62884, patch by Tom McLaughlin ([email protected]).
2004-08-16 Zoltan Varga <[email protected]>
* configure.in: Set new automake variable LIBGC_STATIC_LIBS.
2004-08-14 Zoltan Varga <[email protected]>
* configure.in (HAVE_KW_THREAD): Pass USE_COMPILER_TLS to libgc if
__thread works.
2004-08-11 Zoltan Varga <[email protected]>
* configure.in: Fix __thread test.
2004-08-07 Zoltan Varga <[email protected]>
* configure.in: Add proper checks for the 'undefined reference to '__tls_get_addr' problem.
2004-08-06 Geoff Norton <[email protected]>
* configure.in: Add a kqueue check
2004-08-03 Neale Ferguson <[email protected]>
* configure.in: Enable S/390 64-bit JIT.
2004-07-31 Zoltan Varga <[email protected]>
* configure.in: Enable AMD64 JIT.
2004-07-30 Martin Baulig <[email protected]>
* Makefile.am: The symbol writer is now called
Mono.CompilerServices.SymbolWriter.dll.
2004-07-30 Raja R Harinath <[email protected]>
* runtime/Makefile.am (monoone_DATA): Add mcs.exe.config.
(gmcs_exe): Add gmcs.exe.config.
($(monoone_DATA) $(monotwo_DATA) ...): Add location of the .config
files too.
2004-07-29 Lluis Sanchez Gual <[email protected]>
* Makefile.am: Copy machine.config in the correct _tmpinst subdirectory.
2004-07-28 Lluis Sanchez Gual <[email protected]>
* configure.in: Added data/net_1_1 and data/net_2_0 to the build.
* data/Makefile.am: Removed installation of machine.config and
DefaultWsdlHelpGenerator.aspx. Those now are in a version-specific
directory.
* data/net_1_1/Makefile.am, data/net_2_0/Makefile.am: new makefiles for
installing 1.1 and 2.0 makefiles.
* runtime/net_1_1/Makefile.am, runtime/net_2_0/Makefile.am: Install mscorlib
at the correct version specific directory.
2004-07-27 John Merryweather Cooper <[email protected]>
* configure.in: Disable __thread test (TLS) for FreeBSD as
it succeeds on FreeBSD 5.x when it should fail. Fix pthread
library detection for FreeBSD 4.x since pthread is embedded
in libc_r on this platform. Fix some typos in my host
regexes for freebsd.
2004-07-23 Dick Porter <[email protected]>
* configure.in: Changes for FreeBSD thread support by John
Merryweather Cooper <[email protected]>.
2004-07-15 Jackson Harper <[email protected]>
* man/gacutil.1: MONO_GAC_PREFIX not MONO_GAC_PATH
2004-07-12 Massimiliano Mantione <[email protected]>
* docs/abc-removal.txt: Updated documentation for ABC removal.
2004-07-12 Massimiliano Mantione <[email protected]>
* mono/mini/abcremoval.c: Rewritten most of ABC removal.
* mono/mini/abcremoval.h: Rewritten most of ABC removal.
* mono/mini/build_relations_propagation_table.pl: Deleted (unneeded after the rewrite).
* mono/mini/propagated_relations_table.def: Deleted (unneeded after the rewrite).
2004-07-03 Zoltan Varga <[email protected]>
* configure.in: Add --with-tls option to replace the misnamed
--with-nptl option.
2004-07-02 Raja R Harinath <[email protected]>
* Makefile.am (mcs-do-basic-build, mcs-do-short-build):
Pass NO_SIGN_ASSEMBLY=yes to sub-make.
($(tmpinst)/bin/mono) [PLATFORM_WIN32]: Make it work.
2004-07-02 Zoltan Varga <[email protected]>
* man/mono.1: Added 'aot' to trace options.
2004-06-30 Zoltan Varga <[email protected]>
* configure.in: Fix trunc check + add SPARC64 defines.
2004-06-29 Jackson Harper <[email protected]>
* man/gacutil.1: Update man with new command line options.
2004-06-29 Raja R Harinath <[email protected]>
Atsushi Enomoto <[email protected]>
* runtime/net_1_1/Makefile.am (GAC_ROOT_DIR): Renamed from GAC_DIR.
(GAC_DIR): New define that doesn't include $(DESTDIR).
(install-data-local,uninstall-local): Use them. Use in-tree mono
runtime, not the installed one.
2004-06-29 Raja R Harinath <[email protected]>
* runtime/Makefile.am (gmcs_exe): New. Set only if not W32.
(monotwo_DATA): Use it.
From Atsushi Enomoto.
2004-06-24 Raja R Harinath <[email protected]>
* runtime/net_2_0/Makefile.am (gac_assemblies_list): Put back
ICSharpCode.SharpZipLib, not that it has a different version.
2004-06-24 Raja R Harinath <[email protected]>
* Makefile.am (MCS_DIRS, MCS_FILES): Add back Mono.CSharp.Debugger.
(tmpinst-dir-contents, $(tmpinst)/bin/mono.bat): Remove mono.bat
in W32. Use 'mono' and 'mcs' in W32 too.
(bootstrap) [PLATFORM_WIN32]: Back to single stage bootstrap.
* runtime/net_2_0/Makefile.am (gac_assemblies_list): Don't mention
nunit.*, IBM.Data.DB2, ICSharpCode.SharpZipLib.
Fix for #60443, the GAC .DLL-Hell.
2004-06-22 Raja R Harinath <[email protected]>
* Makefile.am (bootstrap) [PLATFORM_WIN32]: Make two-stage.
2004-06-18 Jackson Harper <[email protected]>
* man/mono.1: Add MONO_LOG_LEVEL and MONO_LOG_MASK. Add
instructions on setting multiple mask values.
Fri Jun 18 19:39:09 CEST 2004 Paolo Molaro <[email protected]>
* Makefile.am: process data before runtime, so the config file is
installed and gacutil has a chance to work (finding symlink).
2004-06-18 Raja R Harinath <[email protected]>
* runtime/Makefile.am ($(monoone_DATA) $(monotwo_DATA) $(monobins_DATA)):
Test if files exist in the mcs/ tree before creating symlinks.
Remove symlinks before creating them again.
* runtime/net_1_1/Makefile.am (mscorlib.dll $(gac_assemblies)): Likewise.
* runtime/net_2_0/Makefile.am (mscorlib.dll $(gac_assemblies)): Likewise.
2004-06-18 Raja R Harinath <[email protected]>
* scripts/Makefile.am (REWRITE): New. Common rewriting 'sed' command.
(bin_SCRIPTS): Unify all the script generating rules into one.
2004-06-16 Raja R Harinath <[email protected]>
* Makefile.am (bootstrap) [PLATFORM_WIN32]: Open code. Don't
build and populate net_2_0 profile.
(populate-runtime-subdir): Make into subroutine that takes list of
profiles to populate.
(faststrap): Update.
(MCS_DIRS, MCS_FILES, MONO_CSHARP_DEBUGGER_DIR, MONO_CSHARP_DEBUGGER_FILE):
Avoid automake conditional/+= problems.
(populate-runtime-subdir): Rewrite sanity check.
2004-06-16 Raja R Harinath <[email protected]>
Include prototype completely-untested 'make bootstrap' support for W32.
* Makefile.am (bootstrap): Define to fasterstrap for W32.
(MCS_DIRS, MCS_FILES): Don't refer to Mono.CSharp.Debugger in W32.
(tmpinst-dir): Change sub-make invoke to ...
(tmpinst-dir-contents): ... this. Build 'mono.bat' in W32 instead
of 'mono' and 'mcs'.
($(tmpinst)/bin/mono.bat): New.
2004-06-15 Dick Porter <[email protected]>
* configure.in: Check for struct ip_mreqn and struct ip_mreq on
windows too. Fixes bug 55040.
Mon Jun 14 18:38:34 CEST 2004 Paolo Molaro <[email protected]>
* configure.in: better explain that --with-nptl is not related to
NPTL, but to __thread support. Set sigaltstack support to off by
default.
2004-06-12 Raja R Harinath <[email protected]>
* Makefile.am (populate-runtime-subdir): Add _tmpinst directory
to the PATH.
2004-06-11 Jackson Harper <[email protected]>
* runtime/net_2_0/Makefile.am:
* runtime/net_1_1/Makefile.am: Remove signing patches
2004-06-11 Jackson Harper <[email protected]>
* man/mono.1: Add documentation for MONO_GAC_PREFIX.
* runtime/net_2_0/Makefile.am:
* runtime/net_1_1/Makefile.am: Sign assemblies before
installing. Do not sign ziplib, npgsql, or nunit assemblies. Sign mscorlib.
2004-06-11 Raja R Harinath <[email protected]>
* Makefile.am (populate-runtime-subdir): New target. Does a
controlled "make install" in the 'mcs/' directory to populate the
'runtime' directory.
(fasterstrap): Use it.
2004-06-10 Raja R Harinath <[email protected]>
* runtime/Makefile.am ($(monoone_DATA),$(monotwo_DATA),$(monobins_DATA)):
Don't copy from prefix. Use $(LN_S) to point to the mcs/ tree.
* runtime/net_1_1/Makefile.am (mscorlib.dll,$(gac_assemblies)):
Use $(LN_S) to point to the mcs/ tree, rather than copying.
* runtime/net_2_0/Makefile.am (mscorlib.dll,$(gac_assemblies)): Likewise.
2004-06-10 Raja R Harinath <[email protected]>
Support the new assembly signing setup in mcs/.
* Makefile.am (mcs-do-basic-build): Pass 'USE_BOOT_COMPILE' to sub-makes.
($(tmpinst)/etc/mono/machine.config): New target.
(tmpinst-dir.stamp): Remove and rewrite into ...
($(tmpinst)/bin/mcs): ... this and ...
($(tmpinst)/bin/mono): ... this. Update to use the in-tree machine.config.
(tmpinst-dir): Rewrite to invoke above $(tmpinst)/... targets directly.
* configure.in (AC_PROG_LN_S): New check to define $(LN_S).
Thu Jun 3 14:39:17 CEST 2004 Paolo Molaro <[email protected]>
* configure.in: libc setting for NetBSD (patch from [email protected]).
2004-06-01 Raja R Harinath <[email protected]>
* Makefile.am (bootstrap,faststrap,fasterstrap): Refactor.
Fix 'faststrap' to be corlib-version-change-safe.
(one-stage-strap,two-stage-strap,three-stage-strap): Remove.
(monolite-bootstrap): Update.
2004-05-31 Gonzalo Paniagua Javier <[email protected]>
* configure.in: fixlets for windows.
2004-05-29 Zoltan Varga <[email protected]>
* configure.in: export CC instead of passing it to libgc/configure.
+102 -185
View File
@@ -1,19 +1,13 @@
AUTOMAKE_OPTIONS = foreign
ACLOCAL_AMFLAGS = -I .
SUBDIRS = $(libgc_dir) mono $(ikvm_jni_dir) docs data runtime scripts man samples support web
SUBDIRS = @libgc_dir@ mono @ikvm_jni_dir@ docs runtime scripts man data samples support web
# Keep in sync with SUBDIRS
## 'tools' is not normally built
DIST_SUBDIRS = libgc mono ikvm-jni docs data runtime scripts man samples support web tools
DIST_SUBDIRS = libgc mono ikvm-jni docs runtime scripts man data samples support web tools
EXTRA_DIST= mono.pc.in mono.spec.in mint.pc.in
# Distribute the 'mcs' tree too
dist-hook:
test -d $(distdir)/mcs || mkdir $(distdir)/mcs
d=`cd $(distdir)/mcs && pwd`; cd $(mcs_topdir) && $(MAKE) distdir=$$d dist-recursive
pkgconfigdir = $(libdir)/pkgconfig
if JIT_SUPPORTED
pkgconfig_DATA= mono.pc mint.pc
@@ -23,15 +17,16 @@ endif
DISTCLEANFILES= mono.pc mint.pc
#
# The following targets are used to compile and install
# The following target is used to compile and install
# mono and mcs without running into the out-of-sync
# problems by doing the compilation in the right order.
#
.PHONY: bootstrap faststrap fasterstrap bootstrap-clean bootstrap-check get-monolite-latest monolite-bootstrap
.PHONY: tmpinst-dir tmpinst-mcs-basic-build tmpinst-mcs-short-build tmpinst-mcs-full-build tmpinst-monolite
.PHONY: mono-do-runtime-only mcs-do-basic-build mcs-do-short-build mcs-do-full-build mcs-do-clean-profiles mcs-do-run-test
.PHONY: populate-runtime-subdir
mcs_topdir=$(top_srcdir)/../mcs
.PHONY: tmpinst-dir tmpinst-basic-build tmpinst-short-build tmpinst-full-build
.PHONY: bootstrap faststrap fasterstrap one-stage-strap two-stage-strap three-stage-strap bootstrap-clean bootstrap-check
.PHONY: mono-do-basic-build mcs-do-basic-build mcs-do-short-build mcs-do-full-build mcs-do-clean-profiles mcs-do-run-test
if USE_JIT
mono_runtime = mono/mini/mono
@@ -39,197 +34,119 @@ else
mono_runtime = mono/interpreter/mint
endif
# Minimal set of directories to build, and files used to run the 'mcs' compiler
MCS_BASIC_DIRS = jay mcs class/corlib class/System
MCS_BASIC_FILES = \
$(mcs_topdir)/mcs/mcs.exe \
$(mcs_topdir)/class/lib/default/mscorlib.dll \
$(mcs_topdir)/class/lib/default/System.dll
bootstrap: three-stage-strap
# Set of directories and files the 'mcs' compiler can use
## We build class/System twice to resolve the cyclic dependency of class/System.XML
MCS_DIRS = $(MCS_BASIC_DIRS) class/System.XML class/System class/Mono.CSharp.Debugger
MCS_FILES = $(MCS_BASIC_FILES) \
$(mcs_topdir)/class/lib/default/System.Xml.dll \
$(mcs_topdir)/class/lib/default/Mono.CompilerServices.SymbolWriter.dll
faststrap: mono-do-basic-build
$(MAKE) two-stage-strap
tmpinst = _tmpinst
fasterstrap: mono-do-basic-build
$(MAKE) one-stage-strap
if PLATFORM_WIN32
three-stage-strap: tmpinst-basic-build
$(MAKE) two-stage-strap
populate_profiles = default:net_1_1
two-stage-strap: tmpinst-short-build
$(MAKE) one-stage-strap
# bootstraps using the .NET C# compiler
bootstrap: tmpinst-dir mono-do-runtime-only
$(MAKE) fasterstrap
else
populate_profiles = default:net_1_1 net_2_0:net_2_0
bootstrap: tmpinst-mcs-basic-build mono-do-runtime-only
$(MAKE) tmpinst-mcs-short-build
$(MAKE) fasterstrap
endif
faststrap: tmpinst-mcs-short-build
$(MAKE) mono-do-runtime-only
$(MAKE) fasterstrap
fasterstrap: tmpinst-mcs-full-build
$(MAKE) populate-runtime-subdir
one-stage-strap: tmpinst-full-build
rm -f $(top_srcdir)/runtime/*/*.dll $(top_srcdir)/runtime/*.exe
$(MAKE)
bootstrap-clean: clean mcs-do-clean-profiles
bootstrap-check: check mcs-do-run-test
bootstrap-check: check mcs-do-run-test-profiles #mono-do-testjit
# (takes advantage of 'make -j': independent subtasks are separate dependencies)
tmpinst-basic-build: mcs-do-basic-build mono-do-basic-build tmpinst-dir
mv -f $(mcs_topdir)/mcs/mcs.exe \
$(mcs_topdir)/class/lib/default/mscorlib.dll \
$(mcs_topdir)/class/lib/default/System.dll \
_tmpinst/lib
mono-do-testjit: $(tmpinst)/bin/ilasm
tmpinst=`cd $(tmpinst) && pwd` ; \
tmpinst-short-build: mcs-do-short-build
mv -f $(mcs_topdir)/mcs/mcs.exe \
$(mcs_topdir)/class/lib/default/mscorlib.dll \
$(mcs_topdir)/class/lib/default/System.dll \
$(mcs_topdir)/class/lib/default/System.Xml.dll \
$(mcs_topdir)/class/lib/default/Mono.CSharp.Debugger.dll \
_tmpinst/lib
tmpinst-full-build: mcs-do-full-build
cp -f $(mcs_topdir)/mcs/mcs.exe \
$(mcs_topdir)/class/lib/default/mscorlib.dll \
$(mcs_topdir)/class/lib/default/System.dll \
$(mcs_topdir)/class/lib/default/System.Xml.dll \
$(mcs_topdir)/class/lib/default/Mono.CSharp.Debugger.dll \
_tmpinst/lib
# Build enough of 'mono' to run the stage1 mcs.exe
mono-do-basic-build: $(CONFIG_HEADER)
if test -z "$(libgc_dir)"; then :; else cd libgc && $(MAKE) ; fi
cd mono && $(MAKE)
# Build stripped down versions of 'mcs', 'mscorlib.dll' and 'System.dll' with installed 'mcs'
## remove System.Xml.dll since it's a soft-dependency of System.dll
mcs-do-basic-build:
rm -f $(mcs_topdir)/mcs/mcs.exe $(mcs_topdir)/class/lib/default/mscorlib.dll
rm -f $(mcs_topdir)/class/lib/default/System.dll $(mcs_topdir)/class/lib/default/System.Xml.dll
cd $(mcs_topdir)/jay && $(MAKE)
cd $(mcs_topdir)/mcs && $(MAKE) PROFILE=default BOOTSTRAP_MCS="mcs -d:BOOTSTRAP_WITH_OLDLIB"
cd $(mcs_topdir)/class/corlib && $(MAKE) PROFILE=default BOOTSTRAP_MCS="mcs -d:BOOTSTRAP_WITH_OLDLIB"
cd $(mcs_topdir)/class/System && $(MAKE) PROFILE=default BOOTSTRAP_MCS="mcs -d:BOOTSTRAP_WITH_OLDLIB"
mcs-do-short-build:
tmpinst=`cd _tmpinst && pwd` ; \
PATH=$$tmpinst/bin:$$PATH; export PATH ; \
for dir in jay mcs class/corlib class/System class/System.XML class/System class/Mono.CSharp.Debugger; do \
(cd $(mcs_topdir)/$$dir && $(MAKE) PROFILE=default) || exit 1 ; \
done
mcs-do-full-build:
tmpinst=`cd _tmpinst && pwd` ; \
PATH=$$tmpinst/bin:$$PATH ; export PATH ; \
cd mono/tests && $(MAKE) test
cd $(mcs_topdir) && $(MAKE) all-profiles
mcs-do-clean-profiles:
cd $(mcs_topdir) && $(MAKE) clean-profiles
mcs-do-run-test: tmpinst-dir
tmpinst=`cd _tmpinst && pwd` ; \
PATH=$$tmpinst/bin:$$PATH ; export PATH ; \
cd $(mcs_topdir) && $(MAKE) PROFILE=default run-test
tmpinst-dir.stamp: Makefile.am
set -e ; \
rootme=`pwd`; tmpinst=$$rootme/_tmpinst ; \
mkdir -p $$tmpinst $$tmpinst/bin $$tmpinst/lib ; \
echo '#! /bin/sh' > $$tmpinst/bin/mono ; \
echo 'if test -z "$$MONO_PATH" ; then MONO_PATH="'"$$tmpinst/lib"'"' >> $$tmpinst/bin/mono ; \
echo 'else MONO_PATH=$${MONO_PATH}:"'"$$tmpinst/lib"'" ; fi' >> $$tmpinst/bin/mono ; \
echo 'export MONO_PATH' >> $$tmpinst/bin/mono ; \
echo 'exec "'"$$rootme/libtool"'" --mode=execute "'"$$rootme/$(mono_runtime)"'" "$$@"' >> $$tmpinst/bin/mono ; \
echo '#! /bin/sh' > $$tmpinst/bin/mcs ; \
echo 'exec "'"$$tmpinst/bin/mono"'" "'"$$tmpinst/lib/mcs.exe"'" "$$@"' >> $$tmpinst/bin/mcs ; \
chmod +x $$tmpinst/bin/mono $$tmpinst/bin/mcs
echo "stamp" > $@
tmpinst-dir: tmpinst-dir.stamp
@if test -d _tmpinst; then :; else rm -f tmpinst-dir.stamp; $(MAKE) tmpinst-dir.stamp; fi
# building with monolite
get-monolite-latest:
wget -O $(srcdir)/../monolite-latest.tar.gz http://www.go-mono.com/daily/monolite-latest.tar.gz
monolite-bootstrap: tmpinst-monolite mono-do-runtime-only
rm -f $(MCS_FILES)
$(MAKE) tmpinst-mcs-short-build
$(MAKE) fasterstrap
compiler-tests:
$(MAKE) mcs-do-clean-profiles
$(MAKE) bootstrap
$(MAKE) mcs-do-compiler-tests
bootstrap-world: compiler-tests
$(MAKE) install
# internal targets
tmpinst-mcs-basic-build: mcs-do-basic-build tmpinst-dir
mv -f $(MCS_BASIC_FILES) $(tmpinst)/lib
tmpinst-mcs-short-build: mcs-do-short-build tmpinst-dir
mv -f $(MCS_FILES) $(tmpinst)/lib
tmpinst-mcs-full-build: mcs-do-full-build tmpinst-dir
cp -f $(MCS_FILES) $(tmpinst)/lib
tmpinst-monolite: tmpinst-dir
-rm -f $(tmpinst)/lib/mcs.exe $(tmpinst)/lib/*.dll
-rm -fr $(tmpinst)/monolite-*
srcdir=`cd $(srcdir) && pwd` && cd $(tmpinst) && ( gzip -d -c $$srcdir/../monolite-latest.tar.gz | tar xf - )
mv -f $(tmpinst)/monolite-*/mcs.exe $(tmpinst)/monolite-*/*.dll $(tmpinst)/lib
rm -fr $(tmpinst)/monolite-*
-rm -f _tmpinst/lib/mcs.exe _tmpinst/lib/*.dll
-rm -fr _tmpinst/monolite-*
srcdir=`cd $(srcdir) && pwd` && cd _tmpinst && ( gzip -d -c $$srcdir/../monolite-latest.tar.gz | tar xf - )
mv -f _tmpinst/monolite-*/mcs.exe _tmpinst/monolite-*/*.dll _tmpinst/lib
rm -fr _tmpinst/monolite-*
# Build enough of 'mono' to run the stage1 mcs.exe
mono-do-runtime-only: $(CONFIG_HEADER)
for dir in $(libgc_dir) mono data; do \
(cd $$dir && $(MAKE)) || exit 1 ; \
done
mcs-do-basic-build:
rm -f $(MCS_FILES)
for dir in $(MCS_BASIC_DIRS); do \
(cd $(mcs_topdir)/$$dir && $(MAKE) PROFILE=default NO_SIGN_ASSEMBLY=yes USE_BOOT_COMPILE=yes BOOTSTRAP_MCS="mcs -d:BOOTSTRAP_WITH_OLDLIB") || exit 1 ; \
done
mcs-do-short-build:
tmpinst=`cd $(tmpinst) && pwd` ; \
PATH=$$tmpinst/bin:$$PATH; export PATH ; \
for dir in $(MCS_DIRS); do \
(cd $(mcs_topdir)/$$dir && $(MAKE) PROFILE=default NO_SIGN_ASSEMBLY=yes) || exit 1 ; \
done
mcs-do-full-build:
tmpinst=`cd $(tmpinst) && pwd` ; \
PATH=$$tmpinst/bin:$$PATH ; export PATH ; \
cd $(mcs_topdir) && $(MAKE) NO_SIGN_ASSEMBLY=yes all-profiles
mcs-do-clean-profiles:
cd $(mcs_topdir) && $(MAKE) clean-profiles
mcs-do-run-test-profiles: tmpinst-dir $(tmpinst)/bin/mbas $(tmpinst)/bin/ilasm $(tmpinst)/bin/pedump
tmpinst=`cd $(tmpinst) && pwd` ; \
PATH=$$tmpinst/bin:$$PATH ; export PATH ; \
cd $(mcs_topdir) && $(MAKE) run-test-profiles
mcs-do-compiler-tests:
tmpinst=`cd $(tmpinst) && pwd` ; \
PATH=$$tmpinst/bin:$$PATH ; export PATH ; \
cd $(mcs_topdir) && $(MAKE) compiler-tests
populate-runtime-subdir:
test -n '$(populate_profiles)'
@srcdir=`cd $(srcdir) && pwd`; tmpinst=`pwd`/$(tmpinst) ; \
PATH=$$tmpinst/bin:$$PATH ; export PATH ; \
for profile in $(populate_profiles); do \
( set fnord `echo $$profile | sed 's,:, ,g'` && \
echo "cd $(mcs_topdir) && $(MAKE) PROGRAM_INSTALL_DIR=$$srcdir/runtime PROFILE=$$2 LIBRARY_INSTALL_DIR=$$srcdir/runtime/$$3 prefix=$$tmpinst/prefix install" && \
cd $(mcs_topdir) && \
$(MAKE) PROGRAM_INSTALL_DIR=$$srcdir/runtime PROFILE=$$2 LIBRARY_INSTALL_DIR=$$srcdir/runtime/$$3 prefix=$$tmpinst/prefix install ) || exit 1 ; \
done
find $(tmpinst)/prefix -type f -name '*jay*' -exec rm -f '{}' ';'
for i in `find $(tmpinst)/prefix -type d -name '*jay*' -print`; do rm -f $$i/*; done
test -z "`find $(tmpinst)/prefix -type f -print`"
rm -rf $(tmpinst)/prefix
tmpinst-dir:
mkdir -p $(tmpinst) $(tmpinst)/bin $(tmpinst)/lib $(tmpinst)/etc/mono/1.0 $(tmpinst)/etc/mono/2.0
$(MAKE) tmpinst-dir-contents
tmpinst-dir-contents: $(tmpinst)/bin/mono $(tmpinst)/bin/mcs $(tmpinst)/etc/mono/1.0/machine.config $(tmpinst)/etc/mono/2.0/machine.config
if PLATFORM_WIN32
$(tmpinst)/bin/mono: $(srcdir)/Makefile.am
echo '#! /bin/sh' > $@
echo 'builddir="'`pwd`'"; win_builddir="'`cygpath -w -a .`'"' >> $@
echo 'tmpinst="$$win_builddir\\$(tmpinst)"' >> $@
echo 'if test -z "$$MONO_PATH" ; then MONO_PATH="$$tmpinst\\lib"; else MONO_PATH="$${MONO_PATH};$$tmpinst\\lib" ; fi' >> $@
echo 'MONO_CFG_DIR="$$tmpinst\\etc"' >> $@
echo 'export MONO_PATH MONO_CFG_DIR' >> $@
echo 'exec "$$builddir/libtool" --mode=execute "$$builddir/$(mono_runtime).exe" "$$@"' >> $@
chmod +x $@
else
$(tmpinst)/bin/mono: $(srcdir)/Makefile.am
echo '#! /bin/sh' > $@
echo 'builddir="'`pwd`'"; tmpinst=$$builddir/$(tmpinst)' >> $@
echo 'if test -z "$$MONO_PATH" ; then MONO_PATH=$$tmpinst/lib; else MONO_PATH=$${MONO_PATH}:$$tmpinst/lib ; fi' >> $@
echo 'MONO_CFG_DIR=$$tmpinst/etc' >> $@
echo 'export MONO_PATH MONO_CFG_DIR' >> $@
echo 'exec "$$builddir/libtool" --mode=execute "$$builddir/$(mono_runtime)" --config "$$builddir/data/config" "$$@"' >> $@
chmod +x $@
endif
$(tmpinst)/bin/pedump: $(srcdir)/Makefile.am
(b=`pwd`; echo '#! /bin/sh'; echo 'exec "'"$$b/libtool"'" --mode=execute "'"$$b/mono/metadata/pedump"'" "$$@"') > $@
chmod +x $@
$(tmpinst)/bin/mcs: $(srcdir)/Makefile.am
(t=`cd $(tmpinst) && pwd`; echo '#! /bin/sh'; echo 'exec "'"$$t/bin/mono"'" "'"$$t/lib/mcs.exe"'" "$$@"') > $@
chmod +x $@
# Used only by 'bootstrap-check' -- so, can safely use runtime/.
$(tmpinst)/bin/mbas $(tmpinst)/bin/ilasm: $(srcdir)/Makefile.am
t=`cd $(tmpinst) && pwd`; r=`cd $(srcdir)/runtime && pwd`; \
( echo '#! /bin/sh'; echo 'exec "'"$$t/bin/mono"'" "'"$$r/$(@F).exe"'" "$$@"' ) > $@
chmod +x $@
$(tmpinst)/etc/mono/1.0/machine.config: $(srcdir)/data/net_1_1/machine.config
rm -f $@
srcdir=`cd $(srcdir) && pwd`; cd $(tmpinst)/etc/mono/1.0 && $(LN_S) $$srcdir/data/net_1_1/machine.config machine.config
$(tmpinst)/etc/mono/2.0/machine.config: $(srcdir)/data/net_2_0/machine.config
rm -f $@
srcdir=`cd $(srcdir) && pwd`; cd $(tmpinst)/etc/mono/2.0 && $(LN_S) $$srcdir/data/net_2_0/machine.config machine.config
monolite-bootstrap: tmpinst-monolite mono-do-basic-build
rm -f $(mcs_topdir)/mcs/mcs.exe $(mcs_topdir)/class/lib/default/mscorlib.dll
rm -f $(mcs_topdir)/class/lib/default/System.dll $(mcs_topdir)/class/lib/default/System.Xml.dll Mono.CSharp.Debugger.dll
$(MAKE) two-stage-strap
# Obsolete target -- don't use.
.PHONY: fullbuild
+25 -280
View File
@@ -1,11 +1,9 @@
AC_INIT(README)
AC_CANONICAL_SYSTEM
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(mono,1.1.2.99)
AM_INIT_AUTOMAKE(mono,0.94)
AM_MAINTAINER_MODE
AC_PROG_LN_S
dnl
dnl libgc checks
dnl
@@ -42,7 +40,7 @@ case "$host" in
*-*-mingw*|*-*-cygwin*)
platform_win32=yes
AC_DEFINE(PLATFORM_WIN32,1,[Platform is Win32])
CC="gcc -mno-cygwin -g"
CC="gcc -mno-cygwin"
HOST_CC="gcc"
# So libgc configure gets -mno-cygwin
export CC
@@ -51,10 +49,7 @@ case "$host" in
CPPFLAGS="$CPPFLAGS -DWIN32_THREADS"
libdl=
libgc_threads=win32
gc_default=included
with_nptl=default
with_sigaltstack=no
LN_S=cp
gc_default=boehm
;;
*-*-*netbsd*)
platform_win32=no
@@ -66,62 +61,7 @@ case "$host" in
libdl=
libgc_threads=no
;;
# these flags will work for all versions of -STABLE
#
*-*-*freebsd4*)
platform_win32=no
if test "x$PTHREAD_CFLAGS" = "x"; then
CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS"
libmono_cflags="-D_THREAD_SAFE"
else
CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
libmono_cflags="$PTHREAD_CFLAGS"
fi
if test "x$PTHREAD_LIBS" = "x"; then
LDFLAGS="$LDFLAGS -pthread"
libmono_ldflags="-pthread"
else
LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
libmono_ldflags="$PTHREAD_LIBS"
fi
need_link_unlink=yes
AC_DEFINE(PTHREAD_POINTER_ID)
libdl=
libgc_threads=pthreads
# TLS isn't implemented at all on -STABLE
with_nptl=no
with_tls=pthread
;;
# older versions of -CURRENT will break with these flags but testing
# indicates these older versions won't run Mono anyway
#
*-*-*freebsd5*)
platform_win32=no
if test "x$PTHREAD_CFLAGS" = "x"; then
CPPFLAGS="$CPPFLAGS -DGC_FREEBSD_THREADS"
libmono_cflags=
else
CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS -DGC_FREEBSD_THREADS"
libmono_cflags="$PTHREAD_CFLAGS"
fi
if test "x$PTHREAD_LIBS" = "x"; then
LDFLAGS="$LDFLAGS -lpthread"
libmono_ldflags="-lpthread"
else
LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
libmono_ldflags="$PTHREAD_LIBS"
fi
need_link_unlink=yes
AC_DEFINE(PTHREAD_POINTER_ID)
libdl=
libgc_threads=pthreads
# TLS is only partially implemented on -CURRENT (compiler support
# but NOT library support)
#
with_nptl=no
with_tls=pthread
;;
*-*-*openbsd*)
*-*-*freebsd*|*-*-*openbsd*)
platform_win32=no
CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_FREEBSD_THREADS"
libmono_cflags="-D_THREAD_SAFE"
@@ -230,9 +170,8 @@ AM_CONDITIONAL(NO_VERSION_SCRIPT, test x$no_version_script = xyes)
AC_CHECK_HEADERS(sys/filio.h sys/sockio.h netdb.h utime.h semaphore.h sys/un.h)
AC_CHECK_HEADER(zlib.h, [have_zlib=yes], [have_zlib=no])
AM_CONDITIONAL(HAVE_ZLIB, test x$have_zlib = xyes)
# for mono/mini/tramp-x86.c
AC_CHECK_HEADERS(valgrind/memcheck.h)
# for mono/metadata/debug-symfile.c
AC_CHECK_HEADERS(elf.h)
@@ -259,19 +198,6 @@ else
fi
CFLAGS="$CFLAGS -g $WARN"
# Where's the 'mcs' source tree?
if test -d $srcdir/mcs; then
mcsdir=mcs
else
mcsdir=../mcs
fi
mcs_topdir='$(top_srcdir)/'$mcsdir
mcs_topdir_from_srcdir='$(top_builddir)/'$mcsdir
AC_SUBST([mcs_topdir])
AC_SUBST([mcs_topdir_from_srcdir])
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test "x$PKG_CONFIG" = "xno"; then
AC_MSG_ERROR([You need to install pkg-config])
@@ -312,50 +238,16 @@ AC_SUBST(GLIB_LIBS)
AC_SUBST(GMODULE_CFLAGS)
AC_SUBST(GMODULE_LIBS)
if test x$platform_win32 = xyes; 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],[gc=$with_gc],[gc=$gc_default])
# Enable support for fast thread-local storage
# Some systems have broken support, so we allow to disable it.
AC_ARG_WITH(tls, [ --with-tls=__thread,pthread select Thread Local Storage implementation],[],[with_tls=__thread])
# Kept for compatibility
AC_ARG_WITH(nptl, [ --with-nptl=yes,no deprecated, use --with-tls instead],[],[with_nptl=default])
if test "x$with_nptl" != "xdefault"; then
if test "x$with_nptl" = "xyes"; then
AC_MSG_WARN([--with-nptl=yes is deprecated, use --with-tls=__thread option instead.])
with_tls=__thread
fi
if test "x$with_nptl" = "xno"; then
AC_MSG_WARN([--with-nptl=no is deprecated, use --with-tls=pthread option instead.])
with_tls=pthread
fi
fi
# Enable support for NPTL only features like fast thread-local storage
# We can't reliably detect nptl at compile & run time
# so this option will stay until nptl becomes more widespread
AC_ARG_WITH(nptl, [ --with-nptl=yes,no enable/disable support for NPTL],[],[with_nptl=yes])
# Enable support for using sigaltstack for SIGSEGV and stack overflow handling
# This does not work on some platforms (bug #55253)
AC_ARG_WITH(sigaltstack, [ --with-sigaltstack=yes,no enable/disable support for sigaltstack],[],[with_sigaltstack=no])
AC_ARG_WITH(sigaltstack, [ --with-sigaltstack=yes,no enable/disable support for sigaltstack],[],[with_sigaltstack=yes])
# assembly bundle support, see metadata/make-bundle.pl for more info
AC_ARG_WITH(bundle, [ --with-bundle=bundle_template],[
@@ -367,7 +259,6 @@ AM_CONDITIONAL(WITH_BUNDLE, test x$with_bundle != xno)
LIBGC_CFLAGS=
LIBGC_LIBS=
LIBGC_STATIC_LIBS=
libgc_dir=
case "x$gc" in
xboehm|xbohem|xyes)
@@ -384,7 +275,6 @@ case "x$gc" in
AC_DEFINE(HAVE_BOEHM_GC)
AC_SUBST(HAVE_BOEHM_GC)
LIBGC_LIBS="-lgc $libdl"
LIBGC_STATIC_LIBS="$LIBGC_LIBS"
# AC_CHECK_FUNCS does not work for some reason...
AC_CHECK_LIB(gc, GC_gcj_malloc, found_gcj_malloc="yes",,$libdl)
@@ -407,7 +297,6 @@ case "x$gc" in
LIBGC_CFLAGS='-I$(top_srcdir)/libgc/include'
LIBGC_LIBS='$(top_builddir)/libgc/libmonogc.la'
LIBGC_STATIC_LIBS='$(top_builddir)/libgc/libmonogc-static.la'
AC_DEFINE(HAVE_BOEHM_GC)
AC_SUBST(HAVE_BOEHM_GC)
@@ -435,7 +324,6 @@ ac_configure_args="$ac_configure_args --disable-embed-check --with-libgc-threads
AM_CONDITIONAL(INCLUDED_LIBGC, test x$use_included_gc = xyes)
AC_SUBST(LIBGC_CFLAGS)
AC_SUBST(LIBGC_LIBS)
AC_SUBST(LIBGC_STATIC_LIBS)
AC_SUBST(libgc_dir)
dnl
@@ -504,7 +392,6 @@ if test x$platform_win32 = xno; then
AC_CHECK_FUNCS(getpwuid_r)
AC_CHECK_FUNCS(getresuid)
AC_CHECK_FUNCS(setresuid)
AC_CHECK_FUNCS(kqueue)
dnl ******************************************************************
dnl *** Check for large file support ***
@@ -747,17 +634,7 @@ if test x$platform_win32 = xno; then
dnl *****************************
dnl *** Checks for libpthread ***
dnl *****************************
# on FreeBSD -STABLE, the pthreads functions all reside in libc_r
# and libpthread does not exist
#
case "${host}" in
*-*-*freebsd4*)
AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread")
;;
*)
AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
;;
esac
AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
AC_CHECK_HEADERS(pthread.h)
AC_CHECK_FUNCS(pthread_mutex_timedlock)
AC_CHECK_FUNCS(pthread_getattr_np pthread_attr_get_np)
@@ -778,7 +655,7 @@ if test x$platform_win32 = xno; then
dnl *** Checks for working __thread ***
dnl ***********************************
AC_MSG_CHECKING(for working __thread)
if test "x$with_tls" != "x__thread"; then
if test "x$with_nptl" != "xyes"; then
AC_MSG_RESULT(disabled)
else
AC_TRY_RUN([
@@ -812,9 +689,9 @@ if test x$platform_win32 = xno; then
}
], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_KW_THREAD)
], [
AC_MSG_RESULT(no)
with_tls=pthread
])
fi
@@ -1020,53 +897,9 @@ if test x$platform_win32 = xno; then
fi
AC_DEFINE_UNQUOTED(SIGVAL_PTR,$SIGVAL_PTR,[Pointer field name in 'union sigval'])
fi
dnl **********************************
dnl *** Checks for MonoPosixHelper ***
dnl **********************************
AC_CHECK_FUNCS(posix_fadvise)
AC_CHECK_FUNCS(posix_fallocate)
AC_CHECK_FUNCS(fgetgrent)
AC_CHECK_FUNCS(fgetpwent)
AC_CHECK_FUNCS(fgetpwent)
AC_CHECK_HEADERS(sys/sendfile.h)
AC_CHECK_FUNCS(sendfile)
AC_CHECK_FUNCS(stime)
AC_CHECK_FUNCS(ttyname_r)
AC_CHECK_SIZEOF(size_t)
else
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?))
AC_CHECK_LIB(ole32, main, LIBS="$LIBS -lole32", AC_ERROR(bad mingw install?))
dnl *********************************
dnl *** Check for struct ip_mreqn ***
dnl *********************************
AC_MSG_CHECKING(for struct ip_mreqn)
AC_TRY_COMPILE([#include <ws2tcpip.h>], [
struct ip_mreqn mreq;
mreq.imr_address.s_addr = 0;
], [
# Yes, we have it...
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_STRUCT_IP_MREQN)
], [
# We'll just have to try and use struct ip_mreq
AC_MSG_RESULT(no)
AC_MSG_CHECKING(for struct ip_mreq)
AC_TRY_COMPILE([#include <ws2tcpip.h>], [
struct ip_mreq mreq;
mreq.imr_interface.s_addr = 0;
], [
# Yes, we have it...
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_STRUCT_IP_MREQ)
], [
# No multicast support
AC_MSG_RESULT(no)
])
])
fi
dnl socklen_t check
@@ -1084,22 +917,9 @@ ac_cv_c_socklen_t=yes
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(for array element initalizer support)
AC_TRY_COMPILE([#include <sys/socket.h>], [
const int array[] = {[1] = 2,};
], [
# Yes, we have it...
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_ARRAY_ELEM_INIT,1,[Supports C99 array initialization])
], [
# We'll have to use signals
AC_MSG_RESULT(no)
])
AC_CHECK_FUNCS(trunc, , AC_MSG_CHECKING(for trunc in math.h)
# Simply calling trunc (0.0) is no good since gcc will optimize the call away
AC_TRY_LINK([#include <math.h>],
[ static void *p = &trunc; ],
[ trunc(0.0); ],
[
AC_DEFINE(HAVE_TRUNC)
AC_MSG_RESULT(yes)
@@ -1129,7 +949,7 @@ case "{$target}" in
dnl Win32 does not have /dev/random, they have their own method...
*-*-mingw*|*-*-cygwin*)
ac_cv_have_dev_random=no
ac_cv_have_dev_random = no
;;
dnl Everywhere else, it's /dev/random
@@ -1220,7 +1040,6 @@ ACCESS_UNALIGNED="yes"
JIT_SUPPORTED=no
LIBC="libc.so.6"
INTL="libc.so.6"
jit_wanted=false
case "$host" in
@@ -1237,28 +1056,20 @@ case "$host" in
x86_64-*-* | amd64-*-*)
TARGET=AMD64;
arch_target=amd64;
JIT_SUPPORTED=yes
jit_wanted=true
JIT_SUPPORTED=no
;;
sparc*-*-*)
if test "x$ac_cv_sizeof_void_p" = "x8"; then
TARGET=SPARC64
else
TARGET=SPARC
fi
TARGET=SPARC;
arch_target=sparc;
JIT_SUPPORTED=yes
ACCESS_UNALIGNED="no"
LIBC="libc.so"
INTL="libintl.so"
jit_wanted=true
;;
alpha*-*-linux* | alpha*-*-osf*)
TARGET=ALPHA;
ACCESS_UNALIGNED="no"
JIT_SUPPORTED=no
arch_target=alpha;
;;
# alpha*-*-linux* | alpha*-*-osf*)
# TARGET=ALPHA;
# ACCESS_UNALIGNED="no"
# ;;
# ia64-*-linux* | ia64-*-hpux*)
# TARGET=IA64;
# arch_target=ia64;
@@ -1278,11 +1089,6 @@ case "$host" in
LIBC="libc.sl"
ACCESS_UNALIGNED="no"
;;
hppa*linux*)
TARGET=HPPA;
arch_target=hppa;
ACCESS_UNALIGNED="no"
;;
macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | \
powerpc-*-sysv* | powerpc-*-darwin*)
TARGET=POWERPC;
@@ -1301,20 +1107,10 @@ case "$host" in
ACCESS_UNALIGNED="no"
JIT_SUPPORTED=yes
;;
s390x-*-linux*)
TARGET=S390x;
arch_target=s390x;
ACCESS_UNALIGNED="no"
JIT_SUPPORTED=yes
;;
esac
AC_ARG_WITH(jit, [ --with-jit=yes,no If you want to build scripts that default to the JIT],[
if test x$withval = xyes; then
jit_wanted=true
else
jit_wanted=false
fi
jit_wanted=true
])
USEJIT=false
@@ -1337,54 +1133,10 @@ case "$host" in
powerpc-*-darwin*)
libsuffix=".dylib"
LIBC="libc.dylib"
INTL="libintl.dylib"
;;
*-*-*netbsd*)
LIBC="libc.so.12"
INTL="libintl.so.0"
;;
*-*-*freebsd*)
LIBC="libc.so"
INTL="libintl.so"
;;
*-*-*openbsd*)
LIBC="libc.so"
INTL="libintl.so"
;;
esac
AC_SUBST(libsuffix)
if test "x$TARGET" != "xAMD64"; then
# valgrind headers don't compile under x86-64
AC_CHECK_HEADERS(valgrind/memcheck.h)
fi
if test "x$TARGET" = "xAMD64" -o "x$TARGET" = "xX86"; then
if test "x$with_tls" = "x__thread"; then
#
# On some linux distributions, TLS works in executables, but linking
# against a shared library containing TLS fails with:
# undefined reference to `__tls_get_addr'
#
rm -f conftest.c conftest.so conftest
echo "static __thread int foo; void main () { foo = 5; }" > conftest.c
gcc -fPIC --shared -o conftest.so conftest.c > /dev/null 2>&1
gcc -o conftest conftest.so > /dev/null 2>&1
if test ! -f conftest; then
AC_MSG_WARN([Disabling usage of __thread.]);
with_tls=pthread
fi
rm -f conftest.c conftest.so conftest
fi
fi
if test "x$with_tls" = "x__thread"; then
AC_DEFINE(HAVE_KW_THREAD)
# Pass the information to libgc
CPPFLAGS="$CPPFLAGS -DUSE_COMPILER_TLS"
export CPPFLAGS
fi
if test ${TARGET} = ARM; then
dnl ******************************************
dnl *** Check to see what FPU is available ***
@@ -1425,7 +1177,6 @@ AM_CONDITIONAL(INSTALL_2_0, test x$PREVIEW = xyes)
AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
AM_CONDITIONAL(SPARC64, test x$TARGET = xSPARC64)
AM_CONDITIONAL(X86, test x$TARGET = xX86)
AM_CONDITIONAL(AMD64, test x$TARGET = xAMD64)
AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
@@ -1434,14 +1185,11 @@ AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
AM_CONDITIONAL(ARM, test x$TARGET = xARM)
AM_CONDITIONAL(S390, test x$TARGET = xS390)
AM_CONDITIONAL(S390x, test x$TARGET = xS390x)
AM_CONDITIONAL(HPPA, test x$TARGET = xHPPA)
AM_CONDITIONAL(JIT_SUPPORTED, test x$JIT_SUPPORTED = xyes)
AM_CONDITIONAL(INCLUDED_LIBGC, test x$gc = xincluded)
AC_SUBST(LIBC)
AC_SUBST(INTL)
AC_SUBST(arch_target)
AC_SUBST(CFLAGS)
@@ -1467,7 +1215,6 @@ mono/arch/hppa/Makefile
mono/arch/ppc/Makefile
mono/arch/sparc/Makefile
mono/arch/s390/Makefile
mono/arch/s390x/Makefile
mono/arch/arm/Makefile
mono/arch/alpha/Makefile
mono/interpreter/Makefile
@@ -1489,8 +1236,6 @@ man/Makefile
web/Makefile
docs/Makefile
data/Makefile
data/net_1_1/Makefile
data/net_2_0/Makefile
samples/Makefile
support/Makefile
data/config
@@ -1500,10 +1245,10 @@ tools/locale-builder/Makefile
])
echo "
mcs source: $mcs_topdir
GC: $gc
ICU: $enable_icu
TLS: $with_tls
NPTL: $with_nptl
SIGALTSTACK: $with_sigaltstack
Engine: $jit_status
2.0 Alpha: $PREVIEW
+1
View File
@@ -2,3 +2,4 @@ Makefile.in
Makefile
config
.cvsignore
browscap.ini
@@ -940,23 +940,15 @@ public class HtmlSampleGenerator: SampleGenerator
}
// Serialize headers
bool writtenHeader = false;
foreach (object ob in msgbin.Extensions)
{
SoapHeaderBinding hb = ob as SoapHeaderBinding;
if (hb == null) continue;
if (!writtenHeader) {
xtw.WriteStartElement ("soap", "Header", SoapEnvelopeNamespace);
writtenHeader = true;
}
xtw.WriteStartElement ("soap", "Header", SoapEnvelopeNamespace);
WriteHeader (xtw, hb);
}
if (writtenHeader)
xtw.WriteEndElement ();
}
// Serialize body
xtw.WriteStartElement ("soap", "Body", SoapEnvelopeNamespace);
+10 -3
View File
@@ -1,10 +1,17 @@
SUBDIRS = net_1_1 net_2_0
monodir = $(sysconfdir)/mono
EXTRA_DIST = config.in \
browscap.ini
machine.config \
DefaultWsdlHelpGenerator.aspx \
browscap.ini.gz
mono_DATA = config \
machine.config \
DefaultWsdlHelpGenerator.aspx \
browscap.ini
CLEANFILES = browscap.ini
browscap.ini: browscap.ini.gz
gunzip -c $^ > $@
-12301
View File
File diff suppressed because it is too large. Load diff
Binary file not shown.
-1
View File
@@ -1,7 +1,6 @@
<configuration>
<dllmap dll="cygwin1.dll" target="@LIBC@" />
<dllmap dll="libc" target="@LIBC@" />
<dllmap dll="libintl" target="@INTL@" />
<dllmap dll="libxslt.dll" target="libxslt@libsuffix@" />
<dllmap dll="libmySQL.dll" target="libmysqlclient@libsuffix@" />
<dllmap dll="odbc32.dll" target="libodbc@libsuffix@" />
@@ -35,8 +35,6 @@
type="System.Web.Configuration.CustomErrorsConfigHandler, System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="pages"
type="System.Web.Configuration.PagesConfigurationHandler, System.Web, Version=1.0.5000.0, Culture=neutral" />
<section name="clientTarget"
type="System.Web.Configuration.ClientTargetSectionHandler, System.Web, Version=1.0.5000.0, Culture=neutral" />
</sectionGroup>
<sectionGroup name="system.net">
<section name="settings"
@@ -152,12 +150,6 @@
enableSessionState="true"
autoEventWireup="true"
validateRequest="true" />
<clientTarget>
<add alias="ie5" userAgent="Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)" />
<add alias="ie4" userAgent="Mozilla/4.0 (compatible; MSIE 4.0; Windows NT 4.0)" />
<add alias="uplevel" userAgent="Mozilla/4.0 (compatible; MSIE 4.0; Windows NT 4.0)" />
<add alias="downlevel" userAgent="Unknown" />
</clientTarget>
</system.web>
<system.runtime.remoting>
@@ -198,19 +190,6 @@
</system.diagnostics>
<system.drawing>
</system.drawing>
<strongNames>
<pubTokenMapping>
<!-- ECMA key -->
<map Token="b77a5c561934e089" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
<!-- Microsoft (final) key -->
<map Token="b03f5f7f11d50a3a" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
<!-- Microsoft (Web Service Enhancement) key -->
<map Token="31bf3856ad364e35" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
<!-- IBM (DB2 Data Provider) key -->
<map Token="7c307b91aa13d208" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
</pubTokenMapping>
</strongNames>
</configuration>
-2
View File
@@ -1,2 +0,0 @@
Makefile
Makefile.in
-8
View File
@@ -1,8 +0,0 @@
monodir = $(sysconfdir)/mono/1.0
EXTRA_DIST = machine.config \
DefaultWsdlHelpGenerator.aspx
mono_DATA = machine.config \
DefaultWsdlHelpGenerator.aspx
-2
View File
@@ -1,2 +0,0 @@
Makefile
Makefile.in
File diff suppressed because it is too large. Load diff
-8
View File
@@ -1,8 +0,0 @@
monodir = $(sysconfdir)/mono/2.0
EXTRA_DIST = machine.config \
DefaultWsdlHelpGenerator.aspx
mono_DATA = machine.config \
DefaultWsdlHelpGenerator.aspx
-216
View File
@@ -1,216 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="appSettings" type="System.Configuration.NameValueFileSectionHandler, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="system.diagnostics" type="System.Diagnostics.DiagnosticsConfigurationHandler, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="system.runtime.remoting" type="System.Configuration.IgnoreSectionHandler, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowLocation="false"/>
<sectionGroup name="system.web">
<section name="httpHandlers"
type="System.Web.Configuration.HttpHandlersSectionHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="httpModules"
type="System.Web.Configuration.HttpModulesConfigurationHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="machineKey"
type="System.Web.Configuration.MachineKeyConfigHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="authentication"
type="System.Web.Configuration.AuthenticationConfigHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="authorization"
type="System.Web.Configuration.AuthorizationConfigHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="globalization"
type="System.Web.Configuration.GlobalizationConfigurationHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="sessionState"
type="System.Web.SessionState.SessionStateSectionHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="trace"
type="System.Web.Configuration.TraceConfigurationHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="webServices"
type="System.Web.Services.Configuration.WebServicesConfigurationSectionHandler, System.Web.Services, Version=2.0.3600.0 Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="webControls"
type="System.Web.Configuration.WebControlsSectionHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="compilation"
type="System.Web.Configuration.CompilationConfigurationHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="httpRuntime"
type="System.Web.Configuration.HttpRuntimeConfigurationHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="customErrors"
type="System.Web.Configuration.CustomErrorsConfigHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="pages"
type="System.Web.Configuration.PagesConfigurationHandler, System.Web, Version=2.0.3600.0, Culture=neutral" />
<section name="clientTarget"
type="System.Web.Configuration.ClientTargetSectionHandler, System.Web, Version=2.0.3600.0, Culture=neutral" />
</sectionGroup>
<sectionGroup name="system.net">
<section name="settings"
type="System.Net.Configuration.NetConfigurationHandler, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="connectionManagement"
type="System.Net.Configuration.ConnectionManagementHandler, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="authenticationModules"
type="System.Net.Configuration.NetAuthenticationModuleHandler, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="defaultProxy"
type="System.Net.Configuration.DefaultProxyHandler, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="webRequestModules"
type="System.Net.Configuration.WebRequestModuleHandler, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</sectionGroup>
<section name="system.drawing" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<system.net>
<connectionManagement>
<add address="*" maxconnection="2" />
</connectionManagement>
<authenticationModules>
<add type="System.Net.BasicClient, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add type="System.Net.DigestClient, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add type="System.Net.NtlmClient, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</authenticationModules>
<defaultProxy>
<proxy />
<!-- bypassonlocal and proxyaddress are ok -->
<!-- usessystemdefault is not supported -->
</defaultProxy>
<webRequestModules>
<add prefix="http" type="System.Net.HttpRequestCreator, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add prefix="https" type="System.Net.HttpRequestCreator, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add prefix="file" type="System.Net.FileWebRequestCreator, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</webRequestModules>
<settings>
<ipv6 enabled="false"/>
</settings>
</system.net>
<system.web>
<httpHandlers>
<add verb="*" path="Trace.axd" type="System.Web.Handlers.TraceHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add verb="*" path="*.asmx" validate="false" type="System.Web.Services.Protocols.WebServiceHandlerFactory, System.Web.Services, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add verb="*" path="*.ashx" type="System.Web.UI.SimpleHandlerFactory, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add verb="GET" path="WebResource.axd" type="System.Web.Handlers.AssemblyResourceLoader, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add verb="*" path="*.asax" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add verb="*" path="*.ascx" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add verb="*" path="*.config" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add verb="*" path="*.cs" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add verb="*" path="*.rem" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory, System.Runtime.Remoting, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="false" />
<add verb="*" path="*.soap" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory, System.Runtime.Remoting, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="false" />
<add verb="GET,HEAD" path="*" type="System.Web.StaticFileHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add verb="*" path="*" type="System.Web.HttpMethodNotAllowedHandler, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</httpHandlers>
<httpModules>
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add name="Session" type="System.Web.SessionState.SessionStateModule, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add name="OutputCache" type="System.Web.Caching.OutputCacheModule, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</httpModules>
<authentication mode="Forms">
<forms name=".MONOAUTH" loginUrl="login.aspx" protection="All" timeout="30" path="/">
<credentials passwordFormat="Clear">
<!--<user name="gonzalo" password="gonz"/>-->
</credentials>
</forms>
</authentication>
<machineKey validationKey="AutoGenerate" decryptionKey="AutoGenerate" validation="SHA1" />
<globalization requestEncoding="utf-8"
responseEncoding="utf-8"
fileEncoding="utf-8"/>
<!--
culture="en-US"
uiculture="en-US" />
-->
<sessionState mode="InProc" />
<webServices>
<protocols>
<add name="HttpSoap"/>
<add name="HttpPost"/>
<add name="HttpGet"/>
<add name="Documentation"/>
</protocols>
<wsdlHelpGenerator href="DefaultWsdlHelpGenerator.aspx" />
</webServices>
<webControls clientScriptsLocation="/web_scripts" />
<compilation debug="false" defaultLanguage="c#">
<compilers>
<compiler language="cs;c#;csharp" extension=".cs" warningLevel="1" compilerOptions=""
type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
warningLevel="1" compilerOptions=""
type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</compilers>
<assemblies>
<!--<add assembly="mscorlib" /> -->
<add assembly="System" />
<add assembly="System.Xml" />
<add assembly="System.Data" />
<add assembly="System.Web" />
<add assembly="System.Web.Services" />
<add assembly="System.Drawing" />
<add assembly="*" /> <!-- Add assemblies in bin directory -->
</assemblies>
</compilation>
<httpRuntime executionTimeout="90"
maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100" />
<pages buffer="true"
enableSessionState="true"
autoEventWireup="true"
validateRequest="true" />
<clientTarget>
<add alias="ie5" userAgent="Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)" />
<add alias="ie4" userAgent="Mozilla/4.0 (compatible; MSIE 4.0; Windows NT 4.0)" />
<add alias="uplevel" userAgent="Mozilla/4.0 (compatible; MSIE 4.0; Windows NT 4.0)" />
<add alias="downlevel" userAgent="Unknown" />
</clientTarget>
</system.web>
<system.runtime.remoting>
<application>
<channels>
<channel ref="http client" displayName="http client (delay loaded)" delayLoadAsClientChannel="true" />
<channel ref="tcp client" displayName="tcp client (delay loaded)" delayLoadAsClientChannel="true" />
</channels>
</application>
<channels>
<channel id="http" type="System.Runtime.Remoting.Channels.Http.HttpChannel, System.Runtime.Remoting, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<channel id="http client" type="System.Runtime.Remoting.Channels.Http.HttpClientChannel, System.Runtime.Remoting, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<channel id="http server" type="System.Runtime.Remoting.Channels.Http.HttpServerChannel, System.Runtime.Remoting, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<channel id="tcp" type="System.Runtime.Remoting.Channels.Tcp.TcpChannel, System.Runtime.Remoting, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<channel id="tcp client" type="System.Runtime.Remoting.Channels.Tcp.TcpClientChannel, System.Runtime.Remoting, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<channel id="tcp server" type="System.Runtime.Remoting.Channels.Tcp.TcpServerChannel, System.Runtime.Remoting, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</channels>
<channelSinkProviders>
<clientProviders>
<formatter id="soap" type="System.Runtime.Remoting.Channels.SoapClientFormatterSinkProvider, System.Runtime.Remoting, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<formatter id="binary" type="System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider, System.Runtime.Remoting, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</clientProviders>
<serverProviders>
<formatter id="soap" type="System.Runtime.Remoting.Channels.SoapServerFormatterSinkProvider, System.Runtime.Remoting, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<formatter id="binary" type="System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider, System.Runtime.Remoting, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<provider id="wsdl" type="System.Runtime.Remoting.MetadataServices.SdlChannelSinkProvider, System.Runtime.Remoting, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</serverProviders>
</channelSinkProviders>
</system.runtime.remoting>
<appSettings>
<!--<add key="yourkey" value="your value" /> -->
<!--<remove key="a key defined higher in the hierarchy" /> -->
<!--<clear/> Removes all defined settings -->
</appSettings>
<system.diagnostics>
<trace autoflush="false" indentsize="4" />
</system.diagnostics>
<system.drawing>
</system.drawing>
<strongNames>
<pubTokenMapping>
<!-- ECMA key -->
<map Token="b77a5c561934e089" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
<!-- Microsoft (final) key -->
<map Token="b03f5f7f11d50a3a" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
<!-- Microsoft (Web Service Enhancement) key -->
<map Token="31bf3856ad364e35" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
<!-- IBM (DB2 Data Provider) key -->
<map Token="7c307b91aa13d208" PublicKey="002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df" />
</pubTokenMapping>
</strongNames>
</configuration>
+301 -78
View File
@@ -30,10 +30,8 @@ Unfortunately, analyzing complex expressions is not so easy (see below for
details), so the capabilities of this "abc remover" are limited.
These are simple guidelines:
- Only expressions of the following kinds are handled:
- constant
- variable [+/- constant]
- Only comparisons between "handled" expressions are understood.
- Only simple comparisons between variables are understood.
- Only increment-decrement operations are handled.
- "switch" statements are not yet handled.
This means that code like this will be handled well:
@@ -61,24 +59,16 @@ for (int i = l; i > 0; i--) {
a [i] = .....
}
The following two examples would work:
for (int i = 0; i < (a.Length -1); i++) .....
for (int i = 0; i < a.Length; i += 2) .....
But just something like this
int delta = -1;
for (int i = 0; i < (a.Length + delta); i++) .....
for (int i = 0; i < (a.Length -1); i++) .....
or like this
int delta = +2;
for (int i = 0; i < a.Length; i += delta) .....
for (int i = 0; i < a.Length; i += 2) .....
would not work, the check would stay there, sorry :-(
(unless a combination of cfold, consprop and copyprop is used, too, which
would make the constant value of "delta" explicit).
Just to make you understand how things are tricky... this would work!
@@ -91,9 +81,26 @@ for (int i = 0; i < limit; i++) {
A detailed explanation of the reason why things are done like this is given
below...
All in all, the compiling phase is generally non so fast, and the abc removed
are so few, that there is hardly a performance gain in using the "abcrem"
flag in the compiling options for short programs like the ones I tried.
Anyway, various bound checks *are* removed, and this is good :-)
------------------------------------------------------------------------------
THE ALGORITHM
Unfortunately, this time google has not been my friend, and I did not
find an algorithm I could reasonably implement in the time frame I had,
so I had to invent one. The two cleasses of algorithms I found were either
simply an analisys of variable ranges (which is not very different from
what I'm doing), or they were based on type systems richer than the .NET
one (particularly, they required integer types to have an explicit range,
which could be related to array ranges). By the way, it seems that the
gcj people do not have an array bound check removal optimization (they
just have a compiler flag that unconditionally removes all the checks,
but this is not what we want).
This array bound check removal (abc removal) algorithm is based on
symbolic execution concepts. I handle the removal like an "unreachable
code elimination" (and in fact the optimization could be extended to remove
@@ -195,9 +202,9 @@ one of the definitions of i is a PHI that can be either 0 or "i + 1".
Now, we know that mathematically "i = i + 1" does not make sense, and in
fact symbolic values are not "equations", they are "symbolic definitions".
The actual symbolic value of i is a generic "n", where "n" is the number of
The symbolic value of i is a generic "n", where "n" is the number of
iterations of the loop, but this is terrible to handle (and in more complex
examples the symbolic value of i simply cannot be written, because i is
examples the symbolic definition of i simply cannot be written, because i is
calculated in an iterative way).
However, the definition "i = i + 1" tells us something about i: it tells us
@@ -220,25 +227,13 @@ conditions that could have caused to the removal of an abc, but will
not remove checks "by mistake" (so the resulting code will be in any case
correct).
The expressions we handle are the following (all of integer type):
- constant
- variable
- variable + constant
- constant + variable
- variable - constant
In a first attempt, we can consider only conditions that have the simple
possible form, which is "(compare simpleExpression simpleExpression)",
where "simpleExpression" is either "(ldind.* local[*])" or
"(ldlen (ldind.ref local[*]))" (or a constant, of course).
And, of course, PHI definitions.
Any other expression causes the introduction of an "any" value in the
evaluation, which makes all values that depend from it unknown as well.
We will call these kind of definitions "summarizable" definitions.
In a first attempt, we can consider only branch conditions that have the
simplest possible form (the comparison of two summarizable expressions).
We can also simplify the effect of variable definitions, keeping only
what is relevant to know: their value range with respect to zero and with
respect to the length of the array we are currently handling.
We can also "summarize" variable definitions, keeping only what is relevant
to know: if they are greater or smaller than zero or other variables.
One particular note on PHI functions: they work (obviously) like the logical
"or" of their definitions, and therefore are equivalent to the "logical or"
@@ -250,53 +245,281 @@ if the recursive definition (which, as we said above, must happen because
of a loop) always "grows" or "gets smaller". In all other cases, we decide
we cannot handle it.
So, the algorithm to optimize one method could be something like:
One critical thing, once we have defined all these data structures, is how
the evaluation is actually performed.
In a first attempt I coded a "brute force" approach, which for each BB
tried to examine all possible conditions between all variables, filling
a sort of "evaluation matrix". The problem was that the complexity of this
evaluation was quadratic (or worse) on the number of variables, and that
many wariables were examined even if they were not involved in any array
access.
Following the ABCD paper (http://citeseer.ist.psu.edu/bodik00abcd.html),
I rewrote the algorithm in a more "sparse" way.
Now, the main data structure is a graph of relations between variables, and
each attempt to remove a check performs a traversal of the graph, looking
for a path from the index to the array length that satisfies the properties
"index >= 0" and "index < length". If such a path is found, the check is
removed. It is true that in theory *each* traversal has a complexity which
is exponential on the number of variables, but in practice the graph is not
very connected, so the traversal terminates quickly.
[1] Build the SSA representation.
[2] Analyze each BB. Particularly, do the following:
[2a] summarize its exit conditions
[2b] summarize all the variable definitions occurring in the BB
[2c] check if it contains array accesses (only as optimization, so that
step 3 will be performed only when necessary)
[3] Perform the removal. For each BB that contains array accesses, do:
[3a] build an evaluation area where for each variable we keep track
of its relations with zero and with each other variable.
[3b] populate the evaluation area with the initial data (the variable
definitions and the complete entry condition of the BB)
[3c] propagate the relations between variables (so that from "a<b" and
"b<c" we know that "a<c") in the evaluation area
[3d] for each array access in the BB, use the evaluation area to "match
conditions", to see if the goal functions are satisfied
Then, the algorithm to optimize one method looks like this:
------------------------------------------------------------------------------
LOW LEVEL DESIGN DECISIONS
[1] Preparation:
[1a] Build the SSA representation.
[1b] Prepare the evaluation graph (empty)
[1b] Summarize each varible definition, and put the resulting relations
in the evaluation graph
[2] Analyze each BB, starting from the entry point and following the
dominator tree:
[2a] Summarize its entry condition, and put the resulting relations
in the evaluation graph (this is the reason why the BBs are examined
following the dominator tree, so that conditions are added to the
graph in a "cumulative" way)
[2b] Scan the BB instructions, and for each array access perform step [3]
[2c] Process children BBs following the dominator tree (step [2])
[2d] Remove from the evaluation area the conditions added at step [2a]
(so that backtracking along the tree the area is properly cleared)
[3] Attempt the removal:
[3a] Summarize the index expression, to see if we can handle it; there
are three cases: the index is either a constant, or a variable (with
an optional delta) or cannot be handled (is a "any")
[3b] If the index can be handled, traverse the evaluation area searching
a path from the index variable to the array length (if the index is
a constant, just examine the array length to see if it has some
relation with this constant)
[3c] Use the results of step [3b] to decide if the check is redundant
One of the problems I had to solve was the representation of the relations
between symbolic values.
The "canonical" solution would be to have a complex, potentially recursive
data structure, somewhat similar to MonoInst, and use it all the time (maybe
MonoInst could be used "as is").
The problem is that, at this point, the software would have to "play" with
these structures, for instance to deduce "b < a-1" from "a > b+1", because we
are interested in what value b has, and not a. And maybe the software should
be able to do this without modifying the original condition, because it was
used elsewhere (or could be reused).
Then, the software should also be able to apply logical relations to
conditions (like "(a>0)||(c<1)"), and manipulate them, too.
In my opinion, an optimizer written in this way risks to be too complex, and
its performance not acceptable in a JIT compiler.
Therefore, I decided to represent values in a "summarized" way.
For instance, "x = a + 1" becomes "x > a" (and, by the way, "x = x + 1"
would look like "x > x", which means that "x grows").
So, each variable value is simply a "relation" of the variable with other
variables or constants. Anything more complex is ignored.
Relations are represented with flags (EQ, LT and GT), so that it is easy
to combine them logically (it is enough to perform the bitwise operations
on the flags). The condition (EQ|LT|GT) means we know nothing special, any
value is possible. The empty condition would mean an unreachable statement
(because no value is acceptable).
There is still the problem of identifying variables, and where to store all
these relations. After some thinking, I decided that a "brute force" approach
is the easier, and probably also the fastest. In practice, I keep in memory
an array of "variable relations", where for each variable I record its
relation with the constants 0 and 1 and an array of its relations with all
other variables. The evaluation area, therefore, looks like a square matrix
as large as the number of variables. I *know* that the matrix is rather sparse
(in the sense that only few of its cells are significant), but I decided that
this data structure was the simplest and more efficient anyway. After all,
each cell takes just one byte, and any other data structure must be some
kind of associative array (like a g_hash_table). Such a data structue is
difficult to use with a MonoMemPool, and in the end is slower than a plain
array, and has the storage overhead of all the pointers... in the end, maybe
the full matrix is not a waste at all.
<note>
After a few benchmarks, I clearly see that the matrix works well if the
variables are not too much, otherwise it gets "too sparse", and much time
is wasted in the propagation phase. Maybe the data structure could be changed
after a more careful evaluation of the problem...
</note>
With these assumptions, all the memory used to represent values, conditions
and the evaluation area can be allocated in advance (from a MonoMemPool), and
used for all the analysis of one method. Moreover, the performance of logical
operations is high (they are simple bitwise operations on bytes).
<note>
For the propagation phase, there was a function I could not easily code
with bitwise operations. As that phase is a real pain for the performance
(the complexity is quadratic, and it must be executed iteratively until
nothing changes), I decided to code it in perl, and generate a precomputed
table then used by the C code (just 64 bytes). I think this is faster than
all those branches... Really, I could think again to phases 3c and 3d (see
above), maybe there is a better way to do them.
</note>
Of course not all expressions can be handled by the summarization, so the
optimizer is not as effective as a full blown theorem prover...
Another thing related to design... the implementation is as less intrusive
as possible.
I "patched" the main files to add an option for abc removal, and handle it
just like any other option, and then wrote all the relevant code in two
separated files (one header for data structures, and a C file for the code).
If the patch turns out to be useful also for other pourposes (like a more
generic "unreachable code elimination", that detects branches that will never
be taken using the analysis of variable values), it will not be difficult
to integrate the branch summarizations into the BasicBlock data structures,
and so on.
One last thing... in some places, I knowingly coded in an inefficient way.
For instance, "remove_abc_from_block" does something only if the flag
"has_array_access_instructions" is true, but I call it anyway, letting it
do nothing (calling it conditionally would be better). There are several
things like this in the code, but I was in a hurry, and preferred to make
the code more readable (it is already difficult to understand as it is).
------------------------------------------------------------------------------
WHEN IS ABC REMOVAL POSSIBLE? WHEN IS IT USEFUL?
Warning! Random ideas ahead!
In general, managed code should be safe, so abc removal is possible only if
there already is some branch in the method that does the check.
So, one check on the index is "mandatory", the abc removal can only avoid a
second one (which is useless *because* of the first one).
If in the code there is not a conditional branch that "avoids" to access
an array out of its bounds, in general the abc removal cannot occur.
It could happen, however, that one method is called from another one, and
the check on the index is performed in the caller.
For instance:
void
caller( int[] a, int n ) {
if ( n <= a.Length ) {
for ( int i = 0; i < n; i++ ) {
callee( a, i );
}
}
}
void callee( int[] a, int i ) {
Console.WriteLine( "a [i] = " + a [i] );
}
In this case, it should be possible to have two versions of the callee, one
without checks, to be called from methods that do the check themselves, and
another to be called otherwise.
This kind of optimization could be profile driven: if one method is executed
several times, wastes CPU time for bound checks, and is mostly called from
another one, it could make sense to analyze the situation in detail.
However, one simple way to perform this optimization would be to inline
the callee (so that the abc removal algorithm can see both methods at once).
The biggest benefits of abc removal can be seen for array accesses that
occur "often", like the ones inside inner loops. This is why I tried to
handle "recursive" variable definitions, because without them you cannot
optimize inside loops, which is also where you need it most.
Another possible optimization (alwais related to loops) is the following:
void method( int[] a, int n ) {
for ( int i = 0; i < n; i++ ) {
Console.WriteLine( "a [i] = " + a [i] );
}
}
In this case, the check on n is missing, so the abc could not be removed.
However, this would mean that i will be checked twice at each loop iteration,
one against n, and the other against a.Length. The code could be transformed
like this:
void method( int[] a, int n ) {
if ( n < a.Length ) {
for ( int i = 0; i < n; i++ ) {
Console.WriteLine( "a [i] = " + a [i] ); // Remove abc
}
} else {
for ( int i = 0; i < n; i++ ) {
Console.WriteLine( "a [i] = " + a [i] ); // Leave abc
}
}
}
This could result in performance improvements (again, probably this
optimization should be profile driven).
------------------------------------------------------------------------------
OPEN ISSUES
There are several issues that should still be addressed...
One is related to aliasing. For now, I decided to operate only on local
variables, and ignore aliasing problems (and alias analisys has not yet
been implemented anyway).
Actually, I identified the local arrays with their length, because I
totally ignore the contents of arrays (and objects in general).
Also, in several places in the code I only handle some cases, and ignore
other more complex ones, which could anyway work (there are comments where
this happens). Anyway, this is not harmful (the code is not as effective
as it could be).
Another possible improvement is the explicit handling of all constants.
For now, code like
void
method () {
int[] a = new int [16];
for ( int i = 0; i < 16; i++ ) {
a [i] = i;
}
}
is not handled, because the two constants "16" are lost when variable
relations are summarized (actually they are not lost, they are stored in the
summarized values, but they are not yet used correctly).
The worst thing, anyway, is that for now I fail completely in distinguishing
between signed and unsigned variables/operations/conditions, and between
different integer sizes (in bytes). I did this on pourpose, just for lack of
time, but this can turn out to be terribly wrong.
The problem is caused by the fact that I handle arithmetical operations and
conditions as "ideal" operations, but actually they can overflow and/or
underflow, giving "surprising" results.
For instance, look at the following two methods:
public static void testSignedOverflow()
{
Console.WriteLine( "Testing signed overflow..." );
int[] ia = new int[70000];
int i = 1;
while ( i <ia.Length )
{
try
{
Console.WriteLine( " i = " + i );
ia[i] = i;
}
catch ( IndexOutOfRangeException e )
{
Console.WriteLine( "Yes, we had an overflow (i = " + i + ")" );
}
i *= 60000;
}
Console.WriteLine( "Testing signed overflow done." );
}
public static void testUnsignedOverflow()
{
Console.WriteLine( "Testing unsigned overflow..." );
int[] ia = new int[70000];
uint i = 1;
while ( i <ia.Length )
{
try
{
Console.WriteLine( " i = " + i );
ia[i] = (int) i;
}
catch ( IndexOutOfRangeException e )
{
Console.WriteLine( "Yes, we had an overflow (i = " + i + ")" );
}
i *= 60000;
}
Console.WriteLine( "Testing unsigned overflow done." );
}
In the "testSignedOverflow" method, the exception will be thrown, while
in the "testUnsignedOverflow" everything will go on smoothly.
The problem is that the test "i <ia.Length" is a signed comparison in the
first case, and will not exit from the loop if the index is negative.
Therefore, in the first method, the abc should not be removed.
In practice, the abc removal code should try to predict if any given
expression could over/under-flow, and act accordingly.
For now, I made so that the only accepted expressions are plain increments
and decrements of variables (which cannot over/under-flow without being
trapped by the existing conditions). Anyway, this issue should be analyzed
better.
By the way, in summarizations there is a field that keeps track of the
relation with "1", which I planned to use exactly to summarize products and
quotients, but it is never used (as I said, only increment and decrement
operations are properly summarized).
+1 -14
View File
@@ -69,16 +69,7 @@
not interfere with code in other domains. This is useful if
you want to host different applications in your program.
Now, it is necessary to transfer control to Mono, and setup
the threading infrastructure, you do this like this:
void *user_data = NULL;
mono_runtime_exec_managed_code (domain, main_thread_handler, user_data);
Where your main_thread_handler can load your assembly and execute it:
static void main_thread_handler (gpointer user_data)
Then you can load an assembly containing code into the domain:
MonoAssembly *assembly;
@@ -121,10 +112,6 @@
layer, so in each file where you use pthread.h you should
include the <gc/gc.h> file.
If you can not do this for any reasons, just remember that you
can not store pointers to Mono Objects on the stack, you can
store them safely in the heap, or in global variables though
* Exposing C code to the CIL universe
The Mono runtime provides two mechanisms to expose C code to
-96
View File
@@ -1,96 +0,0 @@
Handling GC allocated objects in C
As part of an effort to improve our GC, we need to keep track
precisely of where objects are stored, so we can incrementally move
from the current conservative GC to a more advanced precise and moving GC.
Previously, all global C variables were considered GC roots, but this makes
the GC less efficient and increases the chances false references are found
to GC memory, hence retaining more memory than needed.
We need to tell the GC that some object is supposed to be kept alive
as if it was referenced in a global variable.
For Mono embedders
------------------
In C#, if you say:
class T {
static object o;
}
Any object which is stored in `o' is considered to be alive -- it will
not be collected. `o' is a member of the root set for the GC.
However, in C code, this is not the case. If you have:
static MonoObject* o = NULL;
The object in `o' will *NOT* be scanned.
If you need to store an object in a C variable and prevent it from being
collected, you need to acquire a GC handle for it.
guint32 handle = mono_gchandle_new (my_object, TRUE);
TRUE means the object will be pinned, so it won't move in memory
when we'll use a moving GC. You can access the MonoObject* referenced by
a handle with:
MonoObject* obj = mono_gchandle_get_target (handle);
When you don't need the handle anymore you need to call:
mono_gchandle_free (handle);
Note that if you assign a new object to the C var, you need to get a new
handle, it's not enough to store a new object in the C var.
So code that looked like this:
static MonoObject* o = NULL;
...
o = mono_object_new (...);
/* use o */
...
/* when done to allow the GC to collect o */
o = NULL;
should now be changed to:
static guint32 o_handle;
...
MonoObject *o = mono_object_new (...);
o_handle = mono_gchandle_new (o, TRUE);
/* use o or mono_gchandle_get_target (o_handle) */
...
/* when done to allow the GC to collect o */
mono_gchandle_free (o_handle);
For Mono runtime developers
---------------------------
There are two kinds of static vars used to store pointers to GC memory
that we need to consider:
*) objects
*) other memory chunks allocated with GC_MALLOC().
Objects should be dealt with the GC handle support as detailed above.
Other items should register the static pointer as an area to be considered
part of the root set with the following:
static gpointer my_gc_data = NULL;
...
MONO_GC_REGISTER_ROOT (my_gc_data);
my_gc_data = GC_MALLOC (...);
Note that this registration is not necessary for *LOCAL* variables,
as they are stored on the stack. It is only necessary for global variables,
as they are not a part of the GC's root set.
Once you have done the MONO_GC_REGISTER_ROOT, the variable is just like
a static variable in C#. To keep an object alive, you have the variable reference
the GC memory, to remove the reference, set the variable to NULL.
As we prepare the code for a precise GC, GC_MALLOC () will not be used anymore
in this way in most cases: we'll have a mechanism to specify exactly where
references to GC memory is stored.
+14 -35
View File
@@ -1,15 +1,20 @@
Mono Intermediate Representation Documentation
Operation: OP_ADDCC_IMM
Operation: OP_LOCALLOC
inst_left:
The value
ins->inst_left = *sp;
ins->cil_code = ip;
Add immediate that will set the carry flag.
dreg:
Destination register
inst_imm
Immediate value to add.
sreg1:
Source register to add.
This is the equivalent of alloca() in a C implementation: it
allocates a bunch of bytes on the stack dynamically. Local
variables are allocated statically in the stack instead.
It is implemented by moving the stack pointer according to the
platform ABI: you may need to keep a specific frame register
to address local variables when LOCALLOC is used (the PPC code
does this, for example: ifyou're doing the s390 port I suggest
starting from that)
Operation: OP_CALL_HANDLER.
@@ -47,29 +52,3 @@ Operation: OP_CCASTCLASS
throws an InvalidCastException exception otherwise.
Operation: OP_LOCALLOC
inst_left:
The value
ins->inst_left = *sp;
ins->cil_code = ip;
This is the equivalent of alloca() in a C implementation: it
allocates a bunch of bytes on the stack dynamically. Local
variables are allocated statically in the stack instead.
It is implemented by moving the stack pointer according to the
platform ABI: you may need to keep a specific frame register
to address local variables when LOCALLOC is used (the PPC code
does this, for example: ifyou're doing the s390 port I suggest
starting from that)
Operation: OP_SUBCC_IMM
Substract immediate that will set the borrow flag.
dreg:
Destination register
inst_imm
Immediate value to add.
sreg1:
Source register to add.
-27
View File
@@ -422,30 +422,3 @@
we replace one or more instructions with others that perform
better for the given architecture or CPU.
* 64 bit support tips, by Zoltan Varga ([email protected])
For a 64-bit port of the Mono runtime, you will typically do
the following:
* need to use inssel-long.brg instead of
inssel-long32.brg.
* need to implement lots of new opcodes:
OP_I<OP> is 32 bit op
OP_L<OP> and CEE_<OP> are 64 bit ops
The 64 bit version of an existing port might share the code
with the 32 bit port (for example SPARC/SPARV9), or it might
be separate (x86/AMD64).
That will depend on the similarities of the two instructions
sets/ABIs etc.
The runtime and most parts of the JIT are 64 bit clean
at this point, so the only parts which require changing are
the arch dependent files.
-68
View File
@@ -1,68 +0,0 @@
We need to switch to a new register allocator.
The current one is split in a global and a local register allocator.
The global one can assign only callee-saves registers and happens
on the tree-based internal representation: it assigns local variables
to hardware registers.
The local one happens on the linear representation on a per basic
block basis and assigns hard registers to virtual registers (which
hold temporary values during expression executions) and it deals also
with the platform-specific issues (fixed registers, call conventions).
Moving to a different register will help solve some of the performance
issues introduced by the above split, make the register more easily
portable and solve some of the issues generated by dealing with trees.
The general design ideas are below.
The new allocator should have a global view of all the method, so it can be
able to assign variables also to some of the volatile registers if possible,
even across basic blocks (this would improve performance).
The allocator would be driven by per-arch declarative data, so porting
should be easier: an architecture needs to specify register classes,
call convention and instructions requirements (similar to the gcc code).
The allocator should operate on the linear representation, this way it's
easier and faster to track usages more correctly. We need to assign virtual
registers on a per-method basis instead of per basic block. We can assign
virtual registers to variables, too. Note that since we fix the stack offset
of local vars only after this step (which happens after the burg rules are run),
some of the burg rules that try to optimize the code won't apply anymore:
the peephole code may need to be enhanced to do the optimizations instead.
We need to handle floating point registers in the global allocator, too.
The new allocator also needs to keep track precisely of which registers
contain references or managed pointers to allow us to move to a precise GC.
It may be worth to use a single increasing set of integers for the virtual
registers, with the class of the register stored separately (unless the
current local allocator which keeps interger and fp registers separate).
Since this is a large task, we need to do it in steps as much as possible.
The first is to run the register allocator _after_ the burg rules: this
requires a rewrite of the liveness code, too, to use linear indexes instead
of basic-block/tree number combinations. This can be done by:
*) allocating virtual regs to all the locals that can be register allocated
*) running the burg rules (some may require adjustments): the local virtual
registers are assigned starting from global-virt-regs+1, instead of the current
hardware-regs+1, so we can tell apart global and local virt regs.
*) running the liveness/whatever code is needed to allocate the global registers
*) allocate the rest of the local variables to stack slots
*) continue with the current local allocator
This work could take 2-3 weeks.
The next step is to define the kind of declarative data an architecture needs
and assigning virtual regs to all the registers and making the allocator
assign from the volatile registers, too.
Note that some of the code that is currently emitted in the arch-specific
code, will need to be emitted as instructions that the reg allocator
can inspect: think of a method that returns the first argument which is
received in a register: the current code copies it to either a local slot or
to a global reg in the prolog an copies it back to the return register
int he basic block, but since neither the regallocator nor the peephole code
knows about the prolog code, the first store cannot be optimized away.
The gcc code has some example of how to specify register classes in a
declarative way.
-77
View File
@@ -1,77 +0,0 @@
While the Boehm GC is quite good, we need to move to a
precise, generational GC for better performance and smaller
memory usage (no false-positives memory retentions with big
allocations).
This is a large task, but it can be done in steps.
1) use the GCJ support to mark reference fields in objects, so
scanning the heap is faster. This is mostly done already, needs
checking that it is always used correctly (big objects, arrays).
There are also some data structures we use in the runtime that are
currently untyped that are allocated in the Gc heap and used to
keep references to GC objects. We need to make them typed as to
precisely track GC references or make them non-GC memory,
by using more the GC hnadle support code (MonoGHashTable, MonoDomain,
etc).
2) don't include in the static roots the .bss and .data segments
to save in scanning time and limit false-positives. This is mostly
done already.
3) keep track precisely of stack locations and registers in native
code generation. This basically requires the regalloc rewrite code
first, if we don't want to duplicate much of it. This is the hardest
task of all, since proving it's correctness is very hard. Some tricks,
like having a build that injects GC.Collect() after every few simple
operations may help. We also need to decide if we want to handle safe
points at calls and back jumps only or at every instruction. The latter
case is harder to implement and requires we keep around much more data
(it potentially makes for faster stop-the-world phases).
The first case requires us to be able to advance a thread until it
reaches the next safe point: this can be done with the same techniques
used by a debugger. We already need something like this to handle
safely aborts happening in the middle of a prolog in managed code,
for example, so this could be an additional sub-task that can be done
separately from the GC work.
Note that we can adapt the libgc code to use the info we collect
when scanning the stack in managed methods and still use the conservative
approach for the unmanaged stack, until we have our own collector,
which requires we define a proper icall interface to switch from managed
to unmanaged code (hwo to we handle object references in the icall
implementations, for example).
4) we could make use of the generational capabilities of the
Boehm GC, but not with the current method involving signals which
may create incompatibilities and is not supported on all platforms.
We need to start using write barriers: they will be required anyway
for the generational GC we'll use. When a field holding a reference
is changed in an object (or an item in an array), we mark the card
or page where the field is stored as dirty. Later, when a collection
is run, only objects in pages marked as dirty are scanned for
references instead of the whole heap. This could take a few days to
implement and probably much more time to debug if all the cases were
not catched:-)
5) actually write the new generational and precise collector. There are
several examples out there as open source projects, though the CLR
needs some specific semantics so the code needs to be written from
scratch anyway. Compared to item 3 this is relatively easer and it can
be tested outside of mono, too, until mono is ready to use it.
The important features needed:
*) precise, so there is no false positive memory retention
*) generational to reduce collection times
*) pointer-hopping allocation to reduce alloc time
*) possibly per-thread lock-free allocation
*) handle weakrefs and finalizers with the CLR semantics
Note: some GC engines use a single mmap area, because it makes
handling generations and the implementation much easier, but this also
limits the expension of the heap, so people may need to use a command-line
option to set the max heap size etc. It would be better to have a design
that allows mmapping a few megabytes chunks at a time.
The different tasks can be done in parallel. 1, 2 and 4 can be done in time
for the mono 1.2 release. Parts of 3 and 5 could be done as well.
The complete switch is supposed to happen with the mono 2.0 release.
-13
View File
@@ -1,16 +1,3 @@
2004-11-07 Zoltan Varga <[email protected]>
* mono-jni.c (GET_SET_ARRAY_ELEMENTS): Fix compilation errors on
gcc 3.3.5.
2004-06-24 David Waite <[email protected]>
* mono-jni.c: change to C90-style comments from C99/C++-style
Fri Jun 18 13:46:05 CEST 2004 Paolo Molaro <[email protected]>
* mono-jni.c: updates for the API cleanups.
2004-05-05 Zoltan Varga <[email protected]>
* mono-jni.c: Implement some missing JNI functions.
+27 -27
View File
@@ -149,8 +149,8 @@ StringFromUTF8 (const char* psz)
/* TODO: */
return mono_string_new (mono_domain_get (), psz);
#if 0
/* Sun's modified UTF8 encoding is not compatible with System::Text::Encoding::UTF8, so */
/* we need to roll our own */
// Sun's modified UTF8 encoding is not compatible with System::Text::Encoding::UTF8, so
// we need to roll our own
int len, res_len, i;
int *res;
@@ -163,16 +163,16 @@ StringFromUTF8 (const char* psz)
switch (c >> 4)
{
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
/* 0xxxxxxx */
// 0xxxxxxx
break;
case 12: case 13:
/* 110x xxxx 10xx xxxx */
// 110x xxxx 10xx xxxx
char2 = *psz++;
i++;
c = (((c & 0x1F) << 6) | (char2 & 0x3F));
break;
case 14:
/* 1110 xxxx 10xx xxxx 10xx xxxx */
// 1110 xxxx 10xx xxxx 10xx xxxx
char2 = *psz++;
char3 = *psz++;
i++;
@@ -263,50 +263,50 @@ static jobject JNICALL CallObjectMethodA (JNIEnv *env, jobject obj, jmethodID me
static MonoObject *
box_Boolean (jboolean val)
{
return mono_value_box (mono_domain_get (), mono_get_boolean_class (), &val);
return mono_value_box (mono_domain_get (), mono_defaults.boolean_class, &val);
}
static MonoObject *
box_Byte (jbyte val)
{
/* Sbyte ! */
return mono_value_box (mono_domain_get (), mono_get_sbyte_class (), &val);
return mono_value_box (mono_domain_get (), mono_defaults.sbyte_class, &val);
}
static MonoObject *
box_Char (jchar val)
{
return mono_value_box (mono_domain_get (), mono_get_char_class (), &val);
return mono_value_box (mono_domain_get (), mono_defaults.char_class, &val);
}
static MonoObject *
box_Short (jshort val)
{
return mono_value_box (mono_domain_get (), mono_get_int16_class (), &val);
return mono_value_box (mono_domain_get (), mono_defaults.int16_class, &val);
}
static MonoObject *
box_Int (jint val)
{
return mono_value_box (mono_domain_get (), mono_get_int32_class (), &val);
return mono_value_box (mono_domain_get (), mono_defaults.int32_class, &val);
}
static MonoObject *
box_Long (jlong val)
{
return mono_value_box (mono_domain_get (), mono_get_int64_class (), &val);
return mono_value_box (mono_domain_get (), mono_defaults.int64_class, &val);
}
static MonoObject *
box_Float (jfloat val)
{
return mono_value_box (mono_domain_get (), mono_get_single_class (), &val);
return mono_value_box (mono_domain_get (), mono_defaults.single_class, &val);
}
static MonoObject *
box_Double (jdouble val)
{
return mono_value_box (mono_domain_get (), mono_get_double_class (), &val);
return mono_value_box (mono_domain_get (), mono_defaults.double_class, &val);
}
static int
@@ -327,7 +327,7 @@ InvokeHelper (JNIEnv *env, jobject object, jmethodID methodID, jvalue* args)
MonoObject **argarray;
MonoArray *args2;
/* assert(!pLocalRefs->PendingException); */
// assert(!pLocalRefs->PendingException);
g_assert(methodID);
argc = GetMethodArgs(methodID, sig);
@@ -368,7 +368,7 @@ InvokeHelper (JNIEnv *env, jobject object, jmethodID methodID, jvalue* args)
}
}
args2 = mono_array_new (mono_domain_get (), mono_get_object_class (), argc);
args2 = mono_array_new (mono_domain_get (), mono_defaults.object_class, argc);
for (i = 0; i < argc; ++i)
mono_array_set (args2, MonoObject*, i, argarray [i]);
@@ -475,7 +475,7 @@ METHOD_IMPL(Double,jdouble)
/* TODO: These should be put into the macros above... */
// TODO: These should be put into the macros above...
static void JNICALL CallVoidMethodA (JNIEnv *env, jobject obj, jmethodID methodID, jvalue * args) {
InvokeHelper(env, obj, methodID, args);
}
@@ -581,7 +581,7 @@ static type JNICALL GetStatic##Type##Field(JNIEnv *env, jclass clazz, jfieldID f
/* return *(cpptype*)BOXED_VALUE (jniFuncs.GetFieldValue (fieldID, jniFuncs.UnwrapRef (obj))); */
// return *(cpptype*)BOXED_VALUE (jniFuncs.GetFieldValue (fieldID, jniFuncs.UnwrapRef (obj)));
GET_SET_FIELD(Boolean,jboolean,gboolean)
GET_SET_FIELD(Byte,jbyte, gchar)
@@ -734,42 +734,42 @@ static jobjectArray JNICALL NewObjectArray (JNIEnv *env, jsize len, jclass clazz
static jbooleanArray JNICALL NewBooleanArray (JNIEnv *env, jsize len)
{
return (jbooleanArray)new_java_array (env, mono_get_boolean_class (), len);
return (jbooleanArray)new_java_array (env, mono_defaults.boolean_class, len);
}
static jbyteArray JNICALL NewByteArray (JNIEnv *env, jsize len)
{
return (jbyteArray)new_java_array (env, mono_get_sbyte_class (), len);
return (jbyteArray)new_java_array (env, mono_defaults.sbyte_class, len);
}
static jcharArray JNICALL NewCharArray (JNIEnv *env, jsize len)
{
return (jcharArray)new_java_array (env, mono_get_char_class (), len);
return (jcharArray)new_java_array (env, mono_defaults.char_class, len);
}
static jshortArray JNICALL NewShortArray (JNIEnv *env, jsize len)
{
return (jshortArray)new_java_array (env, mono_get_int16_class (), len);
return (jshortArray)new_java_array (env, mono_defaults.int16_class, len);
}
static jintArray JNICALL NewIntArray (JNIEnv *env, jsize len)
{
return (jintArray)new_java_array (env, mono_get_int32_class (), len);
return (jintArray)new_java_array (env, mono_defaults.int32_class, len);
}
static jlongArray JNICALL NewLongArray (JNIEnv *env, jsize len)
{
return (jlongArray)new_java_array (env, mono_get_int64_class (), len);
return (jlongArray)new_java_array (env, mono_defaults.int64_class, len);
}
static jfloatArray JNICALL NewFloatArray (JNIEnv *env, jsize len)
{
return (jfloatArray)new_java_array (env, mono_get_single_class (), len);
return (jfloatArray)new_java_array (env, mono_defaults.single_class, len);
}
static jdoubleArray JNICALL NewDoubleArray (JNIEnv *env, jsize len)
{
return (jdoubleArray)new_java_array (env, mono_get_double_class (), len);
return (jdoubleArray)new_java_array (env, mono_defaults.double_class, len);
}
/* Original version with copy */
@@ -841,13 +841,13 @@ static void JNICALL Get##Type##ArrayRegion (JNIEnv *env, type##Array array, jsiz
{\
MonoArray *obj; \
obj = jniFuncs.UnwrapRef (env, (void*)array); \
memcpy (buf, mono_array_addr (obj, type, start), (sizeof (type) * l)); \
memcpy (buf, mono_array_addr (obj, sizeof (type), start), (sizeof (type) * l)); \
} \
static void JNICALL Set##Type##ArrayRegion (JNIEnv *env, type##Array array, jsize start, jsize l, type *buf) \
{ \
MonoArray *obj; \
obj = jniFuncs.UnwrapRef (env, (void*)array); \
memcpy (mono_array_addr (obj, type, start), buf, (sizeof (type) * l)); \
memcpy (mono_array_addr (obj, sizeof (type), start), buf, (sizeof (type) * l)); \
}
GET_SET_ARRAY_ELEMENTS(Boolean,jboolean,gboolean)
+14 -48
View File
@@ -24,17 +24,20 @@ convention is that assemblies must also be placed in a separate
directory for being accessed to the compiler. This is done with the
-package directive to gacutil.
.PP
The tool allows for installation, removal, and listing of the
The tool allows for installationl, removal, and listing of the
contents of the assembly cache.
.PP
The GAC is relative to the Mono installation prefix:
mono_prefix/lib/mono.
.SH FLAGS
The "-user" flag enables you to install/remove the assembly into the
user's assembly cache, as opposed to the global one.
.PP
.SH COMMANDS
.I -i <assembly_path> [-check_refs] [-package NAME] [-root ROOTDIR] [-gacdir GACDIR]
.I "-i path_to_assembly" [-f] [-root ROOTDIR] [-package NAME]
.Sp
Installs an assembly into the global assembly cache. <assembly_path>
is the name of the file that contains the assembly manifest
The above installs the assembly into the GAC, use the -f flag to force
an installation an overwrite anything in there.
.Sp
The -package option can be used to also create a directory in in
prefix/lib/mono with the name NAME, and a symlink is created from
@@ -44,32 +47,18 @@ developers can reference a set of libraries at once.
The -root option is used by developers integrating this with automake
tools or packaging tools that require a prefix directory to be
specified. The root represents the "libdir" component of a prefix
(typically prefix/lib).
.Sp
The -gacdir option is used to specify the GACs base directory. Once an
assembly has been installed to a non standard gacdir the MONO_GAC_PREFIX
environment variable must be used to access the assembly.
.Sp
The -check_refs option is used to ensure that the assembly being
installed into the GAC does not reference any non strong named
assemblies. Assemblies being installed to the GAC should not reference
non strong named assemblies, however the is an optional check.
(typically prefix/lib).
.fi
.PP
.I "-l" [assembly_name] [-root ROOTDIR] [-gacdir GACDIR]
.I "-l"
.Sp
Lists the contents of the global assembly cache. When the
<assembly_name> parameter is specified only matching assemblies are
listed.
Lists the contents of the Global Assembly Cache
.PP
.I "-u" <assembly_display_name> [-package NAME] [-root ROOTDIR] [-gacdir GACDIR]
.I "-u assembly_name [-root]"
.Sp
Uninstalls an assembly from the global assembly cache.
<assembly_display_name> is the name of the assembly (partial or
fully qualified) to remove from the global assembly cache. If a
partial name is specified all matching assemblies will be
uninstalled. As opposed to the install option that takes a filename,
this takes as an argument the assembly name, which looks like this:
The above removes the given assembly name from the Global Assembly
Cache. As opposed to the install option that takes a filename, this
takes as an argument the assembly name, which looks like this:
.nf
MyLibrary.Something, version=1.0.0.0, publicKeyToken=xxxx,culture=neutral
.fi
@@ -80,29 +69,6 @@ to quote them.
The removal performs a greedy removal, if you only specifiy one
component like, "MyLibrary.Something", it will remove all versions of
the library.
.Sp
.I "-us" <assembly_path> [-package NAME] [-root ROOTDIR] [-gacdir GACDIR]
Uninstalls an assembly using the specifed assemblies full name.
<assembly path> is the path to an assembly. The full assembly name
is retrieved from the specified assembly if there is an assembly in
the GAC with a matching name, it is removed. Unlike the -u option this
option takes a file name, like this:
.nf
Example: -us myDll.dll
.fi
.Sp
.I "-ul" <assembly_list_file> [-package NAME] [-root ROOTDIR] [-gacdir GACDIR]
Uninstalls one or more assemblies from the global assembly cache.
<assembly_list_file> is the path to a test file containing a list of
assembly names on separate lines.
.nf
Example -ul assembly_list.txt
.fi
.nf
assembly_list.txt contents:
assembly1,Version=1.0.0.0,Culture=en,PublicKeyToken=0123456789abcdef
assembly2,Version=2.0.0.0,Culture=en,PublicKeyToken=0123456789abcdef
.fi
.SH FILES
On Unix assemblies are loaded from the installation lib directory. If you set
`prefix' to /usr, the assemblies will be located in /usr/lib. On
-14
View File
@@ -108,20 +108,6 @@ key containers. The option is equivalent to including [assembly:
AssemblyKeyName ("CONTAINER")] in your source code. Compiler option
takes precedence over the attributes.
.TP
.I \-langversion:TEXT
The option specifies the version of the language to use. The feature
set is different in each C# version. This switch can be used to force
the compiler to allow only a subset of the features.
The possible values are:
.nf
Default - Instruct compiler to use the latest version. Equivalent
is to omit the switch.
ISO-1 - Restrict compiler to use only ISO standardized features.
The usage of features such as generics, static classes, anonymous
methods will lead to error.
.TP
.I -lib:PATHLIST
Each path specified in the comma-separated list will direct the
compiler to look for libraries in that specified path.
+2 -55
View File
@@ -1,9 +1,8 @@
.\"
.\" mono-config configuration page.
.\" mono configuration page.
.\" (C) Ximian, Inc.
.\" Author:
.\" Miguel de Icaza ([email protected])
.\" Paolo Molaro ([email protected])
.\"
.TH Mono "Mono 1.0"
.SH NAME
@@ -13,9 +12,6 @@ The Mono runtime will load configuration data from the
installation prefix /etc/mono/config file, the ~/.mono/config or from
the file pointed by the MONO_CONFIG environment variable.
.PP
For each assembly loaded a config file with the name:
/path/to/the/assembly.exe.config is loaded, too.
.PP
This file controls the behavior of the runtime.
.PP
The file contains an XML-like file with various sections, all of them
@@ -28,37 +24,6 @@ You use the dllmap directive to map shared libraries referenced by
P/Invoke in your assemblies to a different shared library.
.PP
This is typically used to map Windows libraries to Unix library names.
The
.B dllmap
element takes two attributes:
.TP
.I dll
This should be the same string used in the DllImport attribute
.TP
.I target
This should be the name of the library where the function can be found:
this name should be suitable for use with the platform native shared library
loading routines (dlopen etc.), so you may want to check the manpages for that, too.
.SH <dllentry> directive
This directive can be used to map a specific dll/function pair to a different
library and also a different function name. It should appear inside a
.B dllmap
element with only the dll attribute specified.
.PP
The
.B dllentry
element takes 3 attributes:
.TP
.I dll
This is the target library, where the function can be found.
.TP
.I name
This is the name of the fuction as it appears in the metadata: it is the name
of the P/Invoke method.
.TP
.I target
This is the name of the function to lookup instead of the name specified in the
P/Invoke method.
.SH EXAMPLES
The following example maps references to the `cygwin1.dll' shared
library to the `libc.so.6' file.
@@ -67,23 +32,5 @@ library to the `libc.so.6' file.
<dllmap dll="cygwin1.dll" target="libc.so.6"/>
</configuration>
.fi
.PP
This one maps the following C# method:
.nf
[DllImport ("libc")]
static extern void somefunction ();
.fi
to
.B differentfunction
in
.B libdifferent.so.
.nf
<configuration>
<dllmap dll="libc">
<dllentry dll="libdifferent.so" name="somefunction" target="differentfunction" />
</dllmap>
</configuration>
.fi
.SH SEE ALSO
.BR mono(1), monodis(1), mint(1)
.BR mono(1), monodis(1), mint(1)
+28 -88
View File
@@ -210,7 +210,7 @@ And individual methods are referenced with the M: prefix, and the
standar method notation:
.nf
mono --trace=M:System.Console:WriteLine app.exe
mono --trace=M:System.Console.WriteLine app.exe
.fi
As previously noted, various rules can be specified at once:
@@ -232,40 +232,16 @@ Finally, namespaces can be specified using the N: prefix:
mono --trace=N:System.Xml
.fi
.SH DEBUGGING
.PP
If you are interested in debugging P/Invoke problems with your
application, you might want to use:
.nf
$ MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" mono glue.exe
.fi
.SH SERIALIZATION
Mono's XML serialization engine by default will use a reflection-based
approach to serialize which might be slow for continous processing
(web service applications). The serialization engine will determine
when a class must use a hand-tuned serializer based on a few
parameters and if needed it will produce a customized C# serializer
for your types at runtime. This customized serializer then gets
dynamically loaded into your application.
.PP
You can control this with the MONO_XMLSERIALIZER_THS environment
variable.
.PP
The possible values are `no' to disable the use of a C# customized
serializer, or an integer that is the minimum number of uses before
the runtime will produce a custom serializer (0 will produce a
custom serializer on the first access, 50 will produce a serializer on
the 50th use).
.SH ENVIRONMENT VARIABLES
.TP
.I "GC_DONT_GC"
Turns off the garbage collection in Mono. This should be only used
for debugging purposes
.TP
.I "MONO_ASPNET_NODELETE"
If set to any value, temporary source files generated by ASP.NET support
classes will not be removed. They will be kept in the user's temporary
directory.
.I "MONO_PATH"
Provides a search path to the runtime where to look for library files.
Directories are separated by the platform path separator (colons on unix). Example:
.B /home/username/lib:/usr/local/mono/lib
.TP
.I "MONO_CFG_DIR"
If set, this variable overrides the default system configuration directory
@@ -293,65 +269,18 @@ Windows I/O Emulation layer, and handles (files, events, mutexes,
pipes) will not be shared across processes. Process creation is also
disabled. This option is only available on Unix.
.TP
.I "MONO_EGD_SOCKET"
For platforms that do not otherwise have a way of obtaining random bytes
this can be set to the name of a file system socket on which an egd or
prngd daemon is listening.
.TP
.I "MONO_EXTERNAL_ENCODINGS"
If set, contains a colon-separated list of text encodings to try when
turning externally-generated text (e.g. command-line arguments or
filenames) into Unicode. The encoding names come from the list
provided by iconv, and the special case "default_locale" which refers
to the current locale's default encoding.
.IP
.TP
When reading externally-generated text strings UTF-8 is tried first,
and then this list is tried in order with the first successful
conversion ending the search. When writing external text (e.g. new
filenames or arguments to new processes) the first item in this list
is used, or UTF-8 if the environment variable is not set.
.TP
.I "MONO_GAC_PREFIX"
Provides a prefix the runtime uses to look for Global Assembly Caches.
Directories are separated by the platform path separator (colons on
unix). MONO_GAC_PREFIX should point to the top directory of a prefixed
install. Or to the directory provided in the gacutil /gacdir command. Example:
.B /home/username/.mono:/usr/local/mono/
.TP
.I "MONO_LOG_LEVEL"
If set, the logging level is changed to the set value. Possible values
are "error", "critical", "warning", "message", "info", "debug". The
default value is "error". Messages with a logging level greater then
or equal to the log level will be printed to stdout/stderr.
.PP
Use info to track the dynamic loading of assemblies.
.TP
.I "MONO_LOG_MASK"
If set, the log mask is changed to the set value. Possible values are
"asm" (assembly loader), "type", "dll" (native library loader), "gc"
(garbage collector), "cfg" (config file loader), "aot" (precompiler), "all".
The default value is "all". Changing the mask value allows you to display only
messages for a certain component. You can use multiple masks by comma
separating them. For example to see config file messages and assembly loader
messages set you mask to "asm,cfg".
.TP
.I "MONO_MANAGED_WATCHER"
If set to any value, System.IO.FileSystemWatcher will use the default
managed implementation (slow). If unset, mono will try to use FAM under
Unix systems and native API calls on Windows, falling back to the
managed implementation on error.
.TP
.I "MONO_THREADS_PER_CPU"
Sets the maximum number of threads in the threadpool per CPU. The default is
50 for non-windows systems and 25 for windows.
.TP
.I "MONO_TRACE"
If set, enables the System.Diagnostics.DefaultTraceListener, which will
print the output of the System.Diagnostics Trace and Debug classes.
It can be set to a filename, and to Console.Out or Console.Error to display
output to standard output or standard error, respectively.
See the System.Diagnostics.DefaultTraceListener documentation for more
information.
.TP
.I "MONO_SHARED_DIR"
If set its the directory where the ".wapi" handle state is stored.
@@ -359,18 +288,29 @@ This is the directory where the Windows I/O Emulation layer stores its
shared state data (files, events, mutexes, pipes). By default Mono
will store the ".wapi" directory in the users's home directory.
.TP
.I "MONO_PATH"
Provides a search path to the runtime where to look for library files.
Directories are separated by the platform path separator (colons on unix). Example:
.B /home/username/lib:/usr/local/mono/lib
.I "MONO_UNMANAGED_XSLT"
If set any value, System.Xml.Xsl.XslTransform uses libxslt-based
transformation engine (a.k.a Unmanaged XSLT). Unmanaged XSLT has
long been used for XSLT engine while Managed XSLT engine is so
new and might have some bugs. Basically we recommend Managed XSLT
solution, but if it contains some blocking bugs, then you can also
use traditional libxslt. If you want to use msxsl:script, you have
to select Managed XSLT.
.TP
.I "MONO_XMLSERIALIZER_THS"
Controls the threshold for the XmlSerializer to produce a custom
serializer for a given class instead of using the Reflection-based
interpreter. The possible values are `no' to disable the use of a
custom serializer or a number to indicate when the XmlSerializer
should start serializing. The default value is 50, which means that
the a custom serializer will be produced on the 50th use.
.I "MONO_MANAGED_WATCHER"
If set to any value, System.IO.FileSystemWatcher will use the default
managed implementation (slow). If unset, mono will try to use FAM under
Unix systems and native API calls on Windows, falling back to the
managed implementation on error.
.TP
.I "MONO_CODEDOM_NODELETE"
If set to any value, the C# CodeDom compiler will not remove the temporary
source files generated.
.TP
.I "MONO_EGD_SOCKET"
For platforms that do not otherwise have a way of obtaining random bytes
this can be set to the name of a file system socket on which an egd or
prngd daemon is listening.
.SH FILES
On Unix assemblies are loaded from the installation lib directory. If you set
`prefix' to /usr, the assemblies will be located in /usr/lib. On
+10 -48
View File
@@ -1,9 +1,8 @@
.\"
.\" sn manual page.
.\" Copyright 2003 Motus Technologies
.\" Copyright 2004 Novell
.\" Author:
.\" Sebastien Pouliot <sebastien@ximian.com>
.\" Sebastien Pouliot (spouliot@motus.com)
.\"
.TH Mono "sn"
.SH NAME
@@ -14,33 +13,24 @@ sn \- Digitally sign/verify/compare strongname on CLR assemblies.
.SH DESCRIPTION
Digitally sign, verify or compare, CLR assemblies using strongnames.
.SH CONFIGURATION OPTIONS
Configuration options are stored in the machine.config configuration file
under /configuration/strongNames.
.TP
.I "-c provider"
Change the default CSP (Crypto Service Provider). Currently not supported
in Mono.
Change the default CSP (Crypto Service Provider).
.TP
.I "-m [y|n]"
Use a machine [y] key container or a user [n] key container. Currently not
supported in Mono.
Use a machine [y] key container or a user [n] key container.
.TP
.I "-Vl"
List the verification options. The list is kept under /configuration/
strongNames/verificationSettings in machine.config.
List the verification options.
.TP
.I "-Vr assembly [userlist]"
Exempt the specified assembly from verification for the specified user list.
Currently not supported by sn, you must edit machine.config manually if you
require this.
.TP
.I "-Vu assembly"
Remove the exemption entry for the specified assembly. Currently not
supported by sn, you must edit machine.config manually if you require this.
Remove the exemption entry for the specified assembly.
.TP
.I "-Vx"
Remove all exemptions entries. Currently not supported by sn, you must edit
machine.config manually if you require this.
Remove all exemptions entries.
.SH CSP RELATED OPTIONS
.TP
.I "-d container"
@@ -72,14 +62,11 @@ Compare if assembly1 and assembly are the same exception for their signature.
This is done by comparing the hash of the metadata of both assembly.
.TP
.I "-k keypair.snk"
Create a new strongname keypair (a 1024 bits RSA keypair) in the specified
file.
Create a new strongname keypair in the specified file.
.TP
.I "-R assembly keypair.snk"
Resign the specified assembly using the specified strongname keypair file
(SNK). You can only sign an assembly with the private key (SNK) that match
the public key inside the assembly (unless it's public key token has been
remapped in machine.config).
(SNK).
.TP
.I "-Rc assembly container"
Resign the specified assembly using the specified strongname container.
@@ -96,10 +83,10 @@ Show the public key from the specified assembly.
.I "-Tp assembly"
Show the public key and the public key token from the specified assembly.
.TP
.I "-v assembly"
.I "-V assembly"
Verify the specified assembly signature.
.TP
.I "-vf assembly"
.I "-Vf assembly"
Verify the specified assembly signature (even if disabled).
.SH HELP OPTIONS
.TP
@@ -117,35 +104,10 @@ Display convertion related help about this tool.
.TP
.I "-h sn", "-? sn"
Display strongname related help about this tool.
.SH CONFIGURATION FILE
.TP
Strongnames configuration is kept in "machine.config" file. Currently two
features can be configured.
.TP
.I "/configuration/strongNames/pubTokenMapping"
This mechanism let Mono remap a public key token, like the ECMA token, to
another public key for verification. This is useful in two scenarios. First
assemblies signed with the "ECMA key" needs to be verified by the "runtime"
key (as the ECMA key isn't a public key). Second, many assemblies are signed
with private keys that Mono can't use (e.g. System.Security.dll assembly).
A new key cannot be used because it should change thr strongname (a new key
pair would have a new public key which would produce a new token). Public
key token remapping is the solution for both problems. Each token must be
configured in a "map" entry similar to this one: <map Token="b77a5c561934e089"
PublicKey="00..." />
.TP
.I "/configuration/strongNames/verificationSettings"
It is often useful during development to use delay signed assemblies.
Normally* the runtime wouldn't allow delay-signed assemblies to be loaded.
This feature allows some delay-signed assemblies (based on their public key
token, optionally assembly name and user name) to be used like they were
fully signed assemblies. [*] Note that Mono 1.0 "runtime" doesn't validate
strongname signatures so this option shouldn't be required in most scenarios.
.SH AUTHOR
Written by Sebastien Pouliot
.SH COPYRIGHT
Copyright (C) 2003 Motus Technologies.
Copyright (C) 2004 Novell.
Released under BSD license.
.SH MAILING LISTS
Visit http://mail.ximian.com/mailman/mono-list for details.
+45 -27
View File
@@ -1,18 +1,18 @@
.TH sqlsharp 1 "21 October 2004"
.TH sqlsharp 1 "10 December 2002"
.SH NAME
sqlsharp \- Mono SQL Query command-line tool
sqlsharp \- Mono SQL# command-line SQL Query tool
.SH SYNOPSIS
.B sqlsharp
[\-f filename] [\-o filename] [\-s]
.SH DESCRIPTION
sqlsharp is a Mono SQL tool used for entering SQL queries
to a database using Mono data providers.
sqlsharp is the Mono SQL# tool used for entering SQL queries
to a database using Mono ADO.NET providers.
.PP
.SH OPTIONS
The following options are supported:
.TP
.I "-f filename"
Output file to load SQL commands from.
Output file to load SQL# commands from.
.TP
.I "-o filename"
Output file to send results.
@@ -21,7 +21,7 @@ Output file to send results.
Silent mode.
.PP
.SH HOW TO USE
The SQL tool accepts commands via its command line interface. Commands
The SQL# tool accepts commands via its command line interface. Commands
begin with a backslash followed by the command name.
.PP
Example:
@@ -344,25 +344,28 @@ ption defaulting to true.
PROVIDER NAME NAMESPACE ASSEMBLY
Oracle Oracle 8i System.Data.OracleClient System.Data.OracleClient
PostgreSql NetPostgreSQL Npgsql Npgsql
MySQL ByteFX MySQL ByteFX.Data.MySqlClient ByteFX.Data
Internal
--------
OleDb OLE DB System.Data.OleDb System.Data
SqlClient MS SQL 7/2000 System.Data.SqlClient System.Data
Odbc ODBC System.Data.Odbc System.Data
External to System.Data
-----------------------
MySql MySQL Mono.Data.MySql Mono.Data.MySql
Sqlite SQL Lite Mono.Data.SqliteClient Mono.Data.SqliteClient
Sybase Sybase Mono.Data.SybaseClient Mono.Data.SybaseClient
OleDb OLE DB System.Data.OleDb System.Data
Tds TDS Generic Mono.Data.TdsClient Mono.Data.TdsClient
MSOdbc MS ODBC Microsoft.Data.Odbc Microsoft.Data.Odbc
Firebird Firebird SQL FirebirdSql.Data.FirebirdSql FirebirdSql.Data.Firebird
PostgreSql M PostgreSQL Mono.Data.PostgreSqlClient Mono.Data.PostgreSqlClient
DB2 IBM DB2 Mono.Data.DB2Client Mono.Data.DB2Client
Oracle Oracle 8i System.Data.OracleClient System.Data.OracleClient
NOTES
External to Mono
----------------
Npgsql maps to PostgreSql above.
MySqlNet maps to MySql above.
Odbc is treated as an external provider for .NET 1.1 and above.
MSODBC is an external provider for compatibility with .NET 1.0
Firebird is not included with Mono.
Npgsql NetPostgreSQL Npgsql Npgsql
MySQLNet ByteFX MySQL ByteFX.Data.MySQL ByteFX.Data
.fi
.SH CONNECTION STRING SAMPLES
@@ -382,6 +385,20 @@ or Mono.Data.TdsClient provider:
Server=DANPC;Database=pubs;User ID=saPassword=
PostgreSQL via Mono.Data.PostgreSqlClient provider:
host=localhost;dbname=test;user=postgres;password=fun2db
or
Server=localhost;Database=test;User ID=postgres;Password=fun2db
MySQL via Mono.Data.MySql provider:
Server=localhost;Database=test;User ID=mysql;Password=
ODBC via System.Data.Odbc provider using
a DSN named "MSSQLDSN" I set up
@@ -410,6 +427,11 @@ Oracle via System.Data.OracleClient
Data Source=testdb;User ID=scott;Password=tiger
IBM DB2 Universal Database via Mono.Data.DB2Client
DSN=sample;User ID=db2admin;Password=mysecret
Npgsql (.NET PostgreSQL) from
http://gborg.postgresql.org/project/npgsql/projdisplay.php
@@ -421,24 +443,20 @@ http://sourceforge.net/projects/mysqlnet/
Server=localhost;Database=test;User ID=mysql;Password=
FirebirdSql via FirebirdSql.Data.Firebird (not included with Mono)
Database=C:\\FIREBIRD\\EXAMPLES\\EMPLOYEE.FDB;User=SYSDBA;Password=masterkey;Dialect=3;Server=localhost
.fi
.SH TRACING SUPPORT
No support for tracing right now.
.SH AUTHORS
The Mono SQL Query Tool was written
The Mono SQL# Tool was written
.nf
by Daniel Morgan <danielmorg[email protected]>
by Daniel Morgan <danmorg@sc.rr.com>
.fi
.PP
.SH LICENSE
The Mono SQL Query Tool is released under the terms of the GNU GPL.
The Mono SQL# Tool is released under the terms of the GNU GPL.
Please read the accompanying `COPYING' file for details. Alternative
licenses are available from Novell or Daniel Morgan.
licenses are available from Ximian or Daniel Morgan.
.SH BUGS
To report bugs in the compiler, you can use `bug-buddy', or you can
file bug reports in our bug tracking system:
@@ -454,7 +472,7 @@ http://mail.ximian.com/mailman/mono-list
.SH WEB SITE
For details, visit:
.nf
http://www.mono-project.com
http://www.go-mono.com
.fi
.PP
.SH SEE ALSO
+5 -12
View File
@@ -1,4 +1,4 @@
\"
.\"
.\" wsdl manual page.
.\" (C) 2003 Novell, Inc.
.\" Author:
@@ -13,13 +13,9 @@ wsdl \- Mono's Web Service Proxy Generator
[options] [path | url]
.SH DESCRIPTION
.I wsdl
is a tool for generating proxy classes that can be used to access to
web services. The tool reads a WSDL document from the provided path
or url, and downloads referenced schemas or other WSDL documents if
needed.
.PP
This tool is used to target the 1.x API, for targetting the 2.x API,
please use the wsdl2 tool.
is a tool for generating proxy classes that can be used to access to web services.
The tool reads a WSDL document from the provided path or url, and downloads
referenced schemas or other WSDL documents if needed.
.PP
.SH OPTIONS
The following options are available:
@@ -33,9 +29,6 @@ Specifies a base URL for the service. The final URL will be constructed by
combining this value with the URL read from the
.I -appsettingurlkey
option, and the
.I "-type:typename, assembly"
Generate a proxy for a compiled web service class. The URL parameter
can be used to providethe location of the service.
.I location
attribute specified in the WSDL document.
.TP
@@ -80,4 +73,4 @@ Lluis Sanchez Gual ([email protected])
wsdl is released under the terms of the GNU GPL.
.PP
.SH SEE ALSO
disco(1), soapsuds(1), mono(1), mcs(1), wsdl2(1)
disco(1), soapsuds(1), mono(1), mcs(1)
-79
View File
@@ -1,79 +0,0 @@
.\"
.\" wsdl manual page.
.\" (C) 2003 Novell, Inc.
.\" Author:
.\" Lluis Sanchez Gual ([email protected])
.\"
.TH wsdl 1
.SH NAME
wsdl \- Mono's Web Service Proxy Generator
.SH SYNOPSIS
.PP
.B wsdl
[options] [path | url]
.SH DESCRIPTION
.I wsdl
is a tool for generating proxy classes that can be used to access to web services.
The tool reads a WSDL document from the provided path or url, and downloads
referenced schemas or other WSDL documents if needed.
.PP
This tool is used to target the 2.x API, for targetting the 1.x API,
please use the wsdl tool.
.PP
.SH OPTIONS
The following options are available:
.TP
.I "-appsettingurlkey:key" "-urlkey:key"
Specifies that the url for the services should be read from the <appsettings> section
of the configuration file, using the provided key.
.TP
.I "-appsettingbaseurl:url", "-baseurl:url"
Specifies a base URL for the service. The final URL will be constructed by
combining this value with the URL read from the
.I -appsettingurlkey
option, and the
.I location
attribute specified in the WSDL document.
.TP
.I "-language:language", "-l"
Language of the code to generate. It can be CS (default) or VB.
.TP
.I "-namespace:name", "-n:name"
The namespace of the generated classes. If none is specified, the default
namespace is used.
.TP
.I "-out:filename", "-o:filename"
The target file for generated code.
.TP
.I "-protocol:protocol", "-p:protocol"
The protocol for which to generate code. It can be Soap (default), HttpGet or
HttpPost.
.TP
.I "-sample:METHOD"
This will display XML request and reply of the sample invocations to
that SOAP message. You can use the -protocol: option to render the
message in different forms.
.TP
.I "-server"
Generate a server skeleton instead of a client proxy.
.TP
.I "-nologo"
Supress the startup logo.
.TP
.I "-u:username", "-user:username"
The user name to use when connecting to the server.
.TP
.I "-p:password", "-password:password"
The password to use when connecting to the server.
.TP
.I "-d:domain", "-domain:domain"
The domain to use when connecting to the server.
.PP
.SH AUTHORS
Lluis Sanchez Gual ([email protected])
.PP
.SH LICENSE
wsdl is released under the terms of the GNU GPL.
.PP
.SH SEE ALSO
disco(1), soapsuds(1), mono(1), mcs(1), wsdl(1)
+1 -1
View File
@@ -50,7 +50,7 @@ Specifies the namespace of the XML schema element for which a class or a dataset
Specifies the programming language to use for the generated code. The only supported languages are CS (C#) and VB (Visual Basic.NET).
.TP
.I "/generator:type,assembly" "/g:type,assembly"
Indicates xsd.exe to use custom CodeDomProvider to generate code. The type name must be full name. Assembly name is a local file name that is going to be loaded. The specified Type must have the default constructor.
Indicates xsd.exe to use custom CodeDomProvider to generate code. Type name must be full name. Assembly name is file name that xsd.exe tries to load.
.TP
.I "/outputdir:path" "/o:path"
Specifies the directory where to generate the code or schemas.
-5
View File
@@ -1,5 +0,0 @@
*.dll
*.mdb
cs-parser.cs
semantic.cache
y.output
-144
View File
@@ -1,144 +0,0 @@
thisdir := gmcs
SUBDIRS :=
include ../build/rules.make
COMPILER_SOURCES = \
AssemblyInfo.cs \
anonymous.cs \
assign.cs \
attribute.cs \
driver.cs \
cs-tokenizer.cs \
cfold.cs \
class.cs \
codegen.cs \
const.cs \
constant.cs \
convert.cs \
decl.cs \
delegate.cs \
enum.cs \
ecore.cs \
expression.cs \
flowanalysis.cs \
generic.cs \
iterators.cs \
literal.cs \
location.cs \
modifiers.cs \
namespace.cs \
parameter.cs \
pending.cs \
report.cs \
rootcontext.cs \
statement.cs \
support.cs \
typemanager.cs \
symbolwriter.cs \
tree.cs \
CryptoConvert.cs \
$(topdir)/class/Mono.CSharp.Debugger/MonoSymbolFile.cs \
$(topdir)/class/Mono.CSharp.Debugger/MonoSymbolTable.cs \
$(topdir)/class/Mono.CSharp.Debugger/MonoSymbolWriter.cs
all_sources = $(COMPILER_SOURCES) cs-parser.cs
DISTFILES = \
$(COMPILER_SOURCES) \
cs-parser.jay \
gmcs.exe.config
# compiler.csproj \
# compiler.doc \
# compiler.sln \
# NOTES \
# TODO
#uncomment to enable some debug stuff
#DEBUG_FLAGS=/define:MCS_DEBUG
all-local: gmcs.exe
PROGRAM_INSTALL_DIR = $(prefix)/lib/mono/2.0
install-local: gmcs.exe
$(MKINSTALLDIRS) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
$(INSTALL_BIN) gmcs.exe $(DESTDIR)$(PROGRAM_INSTALL_DIR)
$(INSTALL_DATA) gmcs.exe.config $(DESTDIR)$(PROGRAM_INSTALL_DIR)
$(INSTALL_DATA) gmcs.exe.mdb $(DESTDIR)$(PROGRAM_INSTALL_DIR)
uninstall-local:
-rm -f $(DESTDIR)$(PROGRAM_INSTALL_DIR)/gmcs.exe*
test-local run-test-local:
clean-local:
rm -f *.exe *.pdb cs-parser.cs y.output *.mdb
cd .. && $(MAKE) PROFILE=net_2_0_bootstrap clean
dist-local: dist-default
bootstrap_libs = mscorlib.dll System.dll System.Xml.dll Mono.CompilerServices.SymbolWriter.dll
bootstrap_libfiles = $(bootstrap_libs:%=$(topdir)/class/lib/net_2_0_bootstrap/%)
$(bootstrap_libfiles): bootstrap-libs
@:
.PHONY: bootstrap-libs
bootstrap-libs:
cd .. && $(MAKE) PROFILE=net_2_0_bootstrap all
gmcs.exe: $(all_sources) $(bootstrap_libfiles)
MONO_PATH="../class/lib/net_2_0_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" mono ../mcs/mcs.exe $(DEBUG_FLAGS) -2 /target:exe /debug /out:$@ $(all_sources)
gmcs2.exe: $(all_sources)
MONO_PATH="../class/lib/net_2_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" time mcs -2 /target:exe /debug /out:$@ $^ $(DEBUG_FLAGS)
gmcs3.exe: $(all_sources)
MONO_PATH="../class/lib/net_2_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" time $(RUNTIME) ./gmcs2.exe $(USE_MCS_FLAGS) $(DEBUG_FLAGS) -2 /target:exe /debug /out:$@ $^
gmcs4.exe: $(all_sources)
MONO_PATH="../class/lib/net_2_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" time $(RUNTIME) ./gmcs3.exe $(USE_MCS_FLAGS) $(DEBUG_FLAGS) -2 /target:exe /debug /out:$@ $^
cs-parser.cs: cs-parser.jay $(topdir)/jay/skeleton.cs
$(topdir)/jay/jay -ctv < $(topdir)/jay/skeleton.cs $< > jay-tmp.out && mv jay-tmp.out $@
# Testing targets
TIME =
# This used to be called test, but that conflicts with the global
# recursive target.
btest: gmcs2.exe gmcs3.exe gmcs4.exe
ls -l gmcs3.exe gmcs4.exe
wc:
wc -l $(all_sources)
ctest:
rm -f gmcs3.exe mcs4.exe
make btest USE_MCS_FLAGS=
# we need this because bash tries to use its own crappy timer
FRIENDLY_TIME = $(shell which time) -f'%U seconds'
do-time : mcs.exe
@ echo -n "Run 1: "
$(FRIENDLY_TIME) $(RUNTIME) ./mcs.exe $(USE_MCS_FLAGS) /target:exe /out:mcs2.exe $(all_sources) > /dev/null || (echo FAILED; exit 1)
@ echo -n "Run 2: "
@ $(FRIENDLY_TIME) $(RUNTIME) ./mcs2.exe $(USE_MCS_FLAGS) /target:exe /out:mcs3.exe $(all_sources) > /dev/null || (echo FAILED; exit 1)
@ echo -n "corlib: "
@ rm -f ../class/lib/mscorlib.dll
@ (cd ../class/corlib ; make BOOTSTRAP_MCS="$(FRIENDLY_TIME) mono ../../mcs/mcs.exe" > /dev/null ) || (echo FAILED; exit 1)
do-corlib:
@ echo -n "corlib: "
@ rm -f ../class/lib/mscorlib.dll
@ (cd ../class/corlib ; make BOOTSTRAP_MCS="$(FRIENDLY_TIME) mono ../../mcs/mcs.exe" > /dev/null ) || (echo FAILED; exit 1)
PROFILER=default
profile : gmcs2.exe
make gmcs3.exe RUNTIME="$(RUNTIME) --profile"
response:
echo $(all_sources) > res
-13
View File
@@ -1,13 +0,0 @@
Notes for Martin:
* We merged manually the patch from Sebastien from, this is the
only patch that is not part of the regular mcs/gmcs merger process.
2004-04-08 Sebastien Pouliot <[email protected]>
* codegen.cs: Fix another case where CS1548 must be reported (when
delay-sign isn't specified and no private is available #56564). Fix
loading the ECMA "key" to delay-sign an assembly. Report a CS1548
error when MCS is used on the MS runtime and we need to delay-sign
(which seems unsupported by AssemblyBuilder - see #56621).
-25
View File
@@ -1,25 +0,0 @@
This document lists some important changes between MCS and GMCS.
* Defining Types
There's a fundamental change in how we're defining types in
TypeContainer.DefineType().
In MCS, we resolve a type's parent type and the interface it
implements before actually creating the TypeBuilder. We can easily
detect "recursive" declarations (CS0146) if DefineType() is called
recursively.
This has changed in GMCS since the following type of a recursive
declaration is allowed:
class Foo<T> { }
class Bar<T> : Foo<Bar<T>> { }
To allow this, we must define Bar's TypeBuilder before resolving its
parent classes and call TypeBuilder.SetParent() later.
Last updated September 9th, 2004
Martin Baulig <[email protected]>
-13
View File
@@ -1,13 +0,0 @@
class Stack<T> {
}
class Test {
}
class T {
Stack<Test> a;
static void Main()
{
}
}
-1441
View File
File diff suppressed because it is too large. Load diff
-14
View File
@@ -1,14 +0,0 @@
<configuration>
<startup>
<supportedRuntime version="v2.0.40607"/>
</startup>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="compilerLogListener" type="System.Diagnostics.TextWriterTraceListener,System"
initializeData="mcs.log" />
<remove type="System.Diagnostics.DefaultTraceListener,System"/>
</listeners>
</trace>
</system.diagnostics>
</configuration>
-971
View File
@@ -1,971 +0,0 @@
//
// iterators.cs: Support for implementing iterators
//
// Author:
// Miguel de Icaza ([email protected])
//
// (C) 2003 Ximian, Inc.
//
// TODO:
// Flow analysis for Yield.
// Emit calls to parent object constructor.
//
// Generics note:
// Current should be defined to return T, and IEnumerator.Current returns object
//
using System;
using System.Collections;
using System.Reflection;
using System.Reflection.Emit;
namespace Mono.CSharp {
public interface IIteratorContainer {
//
// Invoked if a yield statement is found in the body
//
void SetYields ();
}
public class Yield : Statement {
public Expression expr;
ArrayList finally_blocks;
public Yield (Expression expr, Location l)
{
this.expr = expr;
loc = l;
}
public static bool CheckContext (EmitContext ec, Location loc)
{
if (ec.CurrentBranching.InFinally (true)){
Report.Error (1625, loc, "Cannot yield in the body of a " +
"finally clause");
return false;
}
if (ec.CurrentBranching.InCatch ()){
Report.Error (1631, loc, "Cannot yield in the body of a " +
"catch clause");
return false;
}
if (ec.InAnonymousMethod){
Report.Error (1621, loc, "yield statement can not appear " +
"inside an anonymoud method");
return false;
}
//
// FIXME: Missing check for Yield inside try block that contains catch clauses
//
return true;
}
public override bool Resolve (EmitContext ec)
{
expr = expr.Resolve (ec);
if (expr == null)
return false;
if (!CheckContext (ec, loc))
return false;
Iterator iterator = ec.CurrentIterator;
if (expr.Type != iterator.IteratorType){
expr = Convert.ImplicitConversionRequired (
ec, expr, iterator.IteratorType, loc);
if (expr == null)
return false;
}
ec.CurrentBranching.StealFinallyClauses (ref finally_blocks);
return true;
}
protected override void DoEmit (EmitContext ec)
{
ec.CurrentIterator.MarkYield (ec, expr, finally_blocks);
}
}
public class YieldBreak : Statement {
public YieldBreak (Location l)
{
loc = l;
}
public override bool Resolve (EmitContext ec)
{
if (!Yield.CheckContext (ec, loc))
return false;
ec.CurrentBranching.CurrentUsageVector.Goto ();
return true;
}
protected override void DoEmit (EmitContext ec)
{
ec.CurrentIterator.EmitYieldBreak (ec.ig);
}
}
public class Iterator : Class {
string original_name;
Block original_block;
Block block;
Type iterator_type;
TypeExpr iterator_type_expr;
bool is_enumerable;
bool is_static;
Hashtable fields;
//
// The state as we generate the iterator
//
Label move_next_ok, move_next_error;
ArrayList resume_points = new ArrayList ();
int pc;
//
// Context from the original method
//
TypeContainer container;
Type return_type;
Type [] param_types;
InternalParameters parameters;
Expression enumerator_type;
Expression enumerable_type;
Expression generic_enumerator_type;
Expression generic_enumerable_type;
TypeArguments generic_args;
protected enum State {
Uninitialized = -2,
After,
Running
}
static int proxy_count;
public void EmitYieldBreak (ILGenerator ig)
{
ig.Emit (OpCodes.Ldarg_0);
IntConstant.EmitInt (ig, (int) State.After);
ig.Emit (OpCodes.Stfld, pc_field.FieldBuilder);
ig.Emit (OpCodes.Br, move_next_error);
}
public void EmitMoveNext (EmitContext ec)
{
ILGenerator ig = ec.ig;
move_next_ok = ig.DefineLabel ();
move_next_error = ig.DefineLabel ();
LocalBuilder retval = ec.GetTemporaryLocal (TypeManager.int32_type);
ig.BeginExceptionBlock ();
Label dispatcher = ig.DefineLabel ();
ig.Emit (OpCodes.Br, dispatcher);
ResumePoint entry_point = new ResumePoint (null);
resume_points.Add (entry_point);
entry_point.Define (ig);
ec.EmitTopBlock (original_block, parameters, Location);
EmitYieldBreak (ig);
ig.MarkLabel (dispatcher);
Label [] labels = new Label [resume_points.Count];
for (int i = 0; i < labels.Length; i++)
labels [i] = ((ResumePoint) resume_points [i]).Label;
ig.Emit (OpCodes.Ldarg_0);
ig.Emit (OpCodes.Ldfld, pc_field.FieldBuilder);
ig.Emit (OpCodes.Switch, labels);
Label end = ig.DefineLabel ();
ig.MarkLabel (move_next_error);
ig.Emit (OpCodes.Ldc_I4_0);
ig.Emit (OpCodes.Stloc, retval);
ig.Emit (OpCodes.Leave, end);
ig.MarkLabel (move_next_ok);
ig.Emit (OpCodes.Ldc_I4_1);
ig.Emit (OpCodes.Stloc, retval);
ig.Emit (OpCodes.Leave, end);
ig.BeginFaultBlock ();
ig.Emit (OpCodes.Ldarg_0);
ig.Emit (OpCodes.Callvirt, dispose.MethodBuilder);
ig.EndExceptionBlock ();
ig.MarkLabel (end);
ig.Emit (OpCodes.Ldloc, retval);
ig.Emit (OpCodes.Ret);
}
public void EmitDispose (EmitContext ec)
{
ILGenerator ig = ec.ig;
Label end = ig.DefineLabel ();
Label dispatcher = ig.DefineLabel ();
ig.Emit (OpCodes.Br, dispatcher);
Label [] labels = new Label [resume_points.Count];
for (int i = 0; i < labels.Length; i++) {
ResumePoint point = (ResumePoint) resume_points [i];
if (point.FinallyBlocks == null) {
labels [i] = end;
continue;
}
labels [i] = ig.DefineLabel ();
ig.MarkLabel (labels [i]);
ig.BeginExceptionBlock ();
ig.BeginFinallyBlock ();
foreach (ExceptionStatement stmt in point.FinallyBlocks) {
if (stmt != null)
stmt.EmitFinally (ec);
}
ig.EndExceptionBlock ();
ig.Emit (OpCodes.Br, end);
}
ig.MarkLabel (dispatcher);
ig.Emit (OpCodes.Ldarg_0);
ig.Emit (OpCodes.Ldfld, pc_field.FieldBuilder);
ig.Emit (OpCodes.Switch, labels);
ig.Emit (OpCodes.Ldarg_0);
IntConstant.EmitInt (ig, (int) State.After);
ig.Emit (OpCodes.Stfld, pc_field.FieldBuilder);
ig.MarkLabel (end);
}
protected class ResumePoint
{
public Label Label;
public readonly ExceptionStatement[] FinallyBlocks;
public ResumePoint (ArrayList list)
{
if (list != null) {
FinallyBlocks = new ExceptionStatement [list.Count];
list.CopyTo (FinallyBlocks, 0);
}
}
public void Define (ILGenerator ig)
{
Label = ig.DefineLabel ();
ig.MarkLabel (Label);
}
}
//
// Invoked when a local variable declaration needs to be mapped to
// a field in our proxy class
//
// Prefixes registered:
// v_ for EmitContext.MapVariable
// s_ for Storage
//
public FieldBuilder MapVariable (string pfx, string name, Type t)
{
string full_name = pfx + name;
FieldBuilder fb = (FieldBuilder) fields [full_name];
if (fb != null)
return fb;
fb = TypeBuilder.DefineField (full_name, t, FieldAttributes.Private);
fields.Add (full_name, fb);
return fb;
}
//
// Called back from Yield
//
public void MarkYield (EmitContext ec, Expression expr,
ArrayList finally_blocks)
{
ILGenerator ig = ec.ig;
// Store the new current
ig.Emit (OpCodes.Ldarg_0);
expr.Emit (ec);
ig.Emit (OpCodes.Stfld, current_field.FieldBuilder);
// increment pc
pc++;
ig.Emit (OpCodes.Ldarg_0);
IntConstant.EmitInt (ig, pc);
ig.Emit (OpCodes.Stfld, pc_field.FieldBuilder);
// Return ok
ig.Emit (OpCodes.Br, move_next_ok);
ResumePoint point = new ResumePoint (finally_blocks);
resume_points.Add (point);
point.Define (ig);
}
public void MarkFinally (EmitContext ec, ArrayList finally_blocks)
{
ILGenerator ig = ec.ig;
// increment pc
pc++;
ig.Emit (OpCodes.Ldarg_0);
IntConstant.EmitInt (ig, pc);
ig.Emit (OpCodes.Stfld, pc_field.FieldBuilder);
ResumePoint point = new ResumePoint (finally_blocks);
resume_points.Add (point);
point.Define (ig);
}
private static MemberName MakeProxyName (string name)
{
int pos = name.LastIndexOf ('.');
if (pos > 0)
name = name.Substring (pos + 1);
return new MemberName ("<" + name + ">__" + (proxy_count++));
}
//
// Our constructor
//
public Iterator (TypeContainer container, string name, Type return_type,
Type [] param_types, InternalParameters parameters,
int modifiers, Block block, Location loc)
: base (container.NamespaceEntry, container, MakeProxyName (name),
Modifiers.PRIVATE, null, loc)
{
this.container = container;
this.return_type = return_type;
this.param_types = param_types;
this.parameters = parameters;
this.original_name = name;
this.original_block = block;
this.block = new Block (null);
fields = new Hashtable ();
is_static = (modifiers & Modifiers.STATIC) != 0;
}
public bool DefineIterator ()
{
if (!CheckType (return_type)) {
Report.Error (
1624, Location,
"The body of `{0}' cannot be an iterator block " +
"because '{1}' is not an iterator interface type",
original_name, TypeManager.CSharpName (return_type));
return false;
}
for (int i = 0; i < parameters.Count; i++){
Parameter.Modifier mod = parameters.ParameterModifier (i);
if ((mod & (Parameter.Modifier.REF | Parameter.Modifier.OUT)) != 0){
Report.Error (
1623, Location,
"Iterators cannot have ref or out parameters");
return false;
}
}
generic_args = new TypeArguments (Location);
generic_args.Add (new TypeExpression (iterator_type, Location));
ArrayList list = new ArrayList ();
if (is_enumerable) {
enumerable_type = new TypeExpression (
TypeManager.ienumerable_type, Location);
list.Add (enumerable_type);
generic_enumerable_type = new ConstructedType (
TypeManager.generic_ienumerable_type,
generic_args, Location);
list.Add (generic_enumerable_type);
}
enumerator_type = new TypeExpression (
TypeManager.ienumerator_type, Location);
list.Add (enumerator_type);
list.Add (new TypeExpression (TypeManager.idisposable_type, Location));
generic_enumerator_type = new ConstructedType (
TypeManager.generic_ienumerator_type,
generic_args, Location);
list.Add (generic_enumerator_type);
iterator_type_expr = new TypeExpression (iterator_type, Location);
container.AddIterator (this);
Bases = list;
return true;
}
//
// Returns the new block for the method, or null on failure
//
protected override bool DefineNestedTypes ()
{
Define_Fields ();
Define_Constructor ();
Define_Current (false);
Define_Current (true);
Define_MoveNext ();
Define_Reset ();
Define_Dispose ();
if (is_enumerable) {
Define_GetEnumerator (false);
Define_GetEnumerator (true);
}
Create_Block ();
return base.DefineNestedTypes ();
}
Field pc_field;
Field current_field;
Method dispose;
public Field this_field;
public Field[] parameter_fields;
void Create_Block ()
{
int first = is_static ? 0 : 1;
ArrayList args = new ArrayList ();
if (!is_static) {
Type t = container.TypeBuilder;
args.Add (new Argument (
new ThisParameterReference (t, 0, Location)));
}
args.Add (new Argument (new BoolLiteral (false)));
for (int i = 0; i < parameters.Count; i++) {
Type t = parameters.ParameterType (i);
args.Add (new Argument (
new SimpleParameterReference (t, first + i, Location)));
}
Expression new_expr = new New (
new TypeExpression (TypeBuilder, Location), args, Location);
block.AddStatement (new NoCheckReturn (new_expr, Location));
}
void Define_Fields ()
{
Location loc = Location.Null;
pc_field = new Field (
this, TypeManager.system_int32_expr, Modifiers.PRIVATE, "PC",
null, null, loc);
AddField (pc_field);
current_field = new Field (
this, iterator_type_expr, Modifiers.PRIVATE, "current",
null, null, loc);
AddField (current_field);
if (!is_static) {
this_field = new Field (
this,
new TypeExpression (container.TypeBuilder, Location),
Modifiers.PRIVATE, "this", null, null, loc);
AddField (this_field);
}
parameter_fields = new Field [parameters.Count];
for (int i = 0; i < parameters.Count; i++) {
string fname = String.Format (
"field{0}_{1}", i, parameters.ParameterName (i));
parameter_fields [i] = new Field (
this,
new TypeExpression (parameters.ParameterType (i), loc),
Modifiers.PRIVATE, fname, null, null, loc);
AddField (parameter_fields [i]);
}
}
void Define_Constructor ()
{
Parameters ctor_params;
ArrayList list = new ArrayList ();
if (!is_static)
list.Add (new Parameter (
new TypeExpression (container.TypeBuilder, Location),
"this", Parameter.Modifier.NONE, null));
list.Add (new Parameter (
TypeManager.system_boolean_expr, "initialized",
Parameter.Modifier.NONE, null));
Parameter[] old_fixed = parameters.Parameters.FixedParameters;
if (old_fixed != null)
list.AddRange (old_fixed);
Parameter[] fixed_params = new Parameter [list.Count];
list.CopyTo (fixed_params);
ctor_params = new Parameters (
fixed_params, parameters.Parameters.ArrayParameter,
Location);
Constructor ctor = new Constructor (
this, Name, Modifiers.PUBLIC, ctor_params,
new ConstructorBaseInitializer (
null, Parameters.EmptyReadOnlyParameters, Location),
Location);
AddConstructor (ctor);
Block block = ctor.Block = new Block (null);
if (!is_static) {
Type t = container.TypeBuilder;
Assign assign = new Assign (
new FieldExpression (this_field),
new SimpleParameterReference (t, 1, Location),
Location);
block.AddStatement (new StatementExpression (assign, Location));
}
int first = is_static ? 2 : 3;
for (int i = 0; i < parameters.Count; i++) {
Type t = parameters.ParameterType (i);
Assign assign = new Assign (
new FieldExpression (parameter_fields [i]),
new SimpleParameterReference (t, first + i, Location),
Location);
block.AddStatement (new StatementExpression (assign, Location));
}
State initial = is_enumerable ? State.Uninitialized : State.Running;
block.AddStatement (new SetState (this, initial, Location));
block.AddStatement (new If (
new SimpleParameterReference (
TypeManager.bool_type, first - 1, Location),
new SetState (this, State.Running, Location),
Location));
}
Statement Create_ThrowInvalidOperation ()
{
TypeExpr ex_type = new TypeExpression (
TypeManager.invalid_operation_exception_type, Location);
return new Throw (new New (ex_type, null, Location), Location);
}
Statement Create_ThrowNotSupported ()
{
TypeExpr ex_type = new TypeExpression (
TypeManager.not_supported_exception_type, Location);
return new Throw (new New (ex_type, null, Location), Location);
}
void Define_Current (bool is_generic)
{
MemberName left;
Expression type;
if (is_generic) {
left = new MemberName (
"System.Collections.Generic.IEnumerator",
generic_args);
type = iterator_type_expr;
} else {
left = new MemberName ("System.Collections.IEnumerator");
type = TypeManager.system_object_expr;
}
MemberName name = new MemberName (left, "Current", null);
Block get_block = new Block (null);
get_block.AddStatement (new If (
new Binary (
Binary.Operator.LessThanOrEqual,
new FieldExpression (pc_field),
new IntLiteral ((int) State.Running), Location),
Create_ThrowInvalidOperation (),
new Return (
new FieldExpression (current_field), Location),
Location));
Accessor getter = new Accessor (get_block, null, Location);
Property current = new Property (
this, type, 0, false, name, null, getter, null, Location);
AddProperty (current);
}
void Define_MoveNext ()
{
Method move_next = new Method (
this, null, TypeManager.system_boolean_expr,
Modifiers.PUBLIC, false, new MemberName ("MoveNext"),
Parameters.EmptyReadOnlyParameters, null,
Location.Null);
AddMethod (move_next);
Block block = move_next.Block = new Block (null);
MoveNextMethod inline = new MoveNextMethod (this, Location);
block.AddStatement (inline);
}
void Define_GetEnumerator (bool is_generic)
{
MemberName left;
Expression type;
if (is_generic) {
left = new MemberName (
"System.Collections.Generic.IEnumerable",
generic_args);
type = generic_enumerator_type;
} else {
left = new MemberName ("System.Collections.IEnumerable");
type = enumerator_type;
}
MemberName name = new MemberName (left, "GetEnumerator", null);
Method get_enumerator = new Method (
this, null, type, 0, false, name,
Parameters.EmptyReadOnlyParameters, null,
Location.Null);
AddMethod (get_enumerator);
get_enumerator.Block = new Block (null);
Expression ce = new MemberAccess (
new SimpleName ("System.Threading.Interlocked", Location),
"CompareExchange", Location);
Expression pc = new FieldExpression (pc_field);
Expression before = new IntLiteral ((int) State.Running);
Expression uninitialized = new IntLiteral ((int) State.Uninitialized);
ArrayList args = new ArrayList ();
args.Add (new Argument (pc, Argument.AType.Ref));
args.Add (new Argument (before, Argument.AType.Expression));
args.Add (new Argument (uninitialized, Argument.AType.Expression));
get_enumerator.Block.AddStatement (new If (
new Binary (
Binary.Operator.Equality,
new Invocation (ce, args, Location),
uninitialized, Location),
new Return (new This (block, Location), Location),
Location));
args = new ArrayList ();
if (!is_static)
args.Add (new Argument (new FieldExpression (this_field)));
args.Add (new Argument (new BoolLiteral (true)));
for (int i = 0; i < parameters.Count; i++)
args.Add (new Argument (
new FieldExpression (parameter_fields [i])));
Expression new_expr = new New (
new TypeExpression (TypeBuilder, Location), args, Location);
get_enumerator.Block.AddStatement (new Return (new_expr, Location));
}
protected class SimpleParameterReference : Expression
{
int idx;
public SimpleParameterReference (Type type, int idx, Location loc)
{
this.idx = idx;
this.loc = loc;
this.type = type;
eclass = ExprClass.Variable;
}
public override Expression DoResolve (EmitContext ec)
{
return this;
}
public override void Emit (EmitContext ec)
{
DoEmit (ec);
}
protected virtual void DoEmit (EmitContext ec)
{
ParameterReference.EmitLdArg (ec.ig, idx);
}
}
protected class ThisParameterReference : SimpleParameterReference
{
public ThisParameterReference (Type type, int idx, Location loc)
: base (type, idx, loc)
{ }
protected override void DoEmit (EmitContext ec)
{
base.DoEmit (ec);
if (ec.TypeContainer is Struct)
ec.ig.Emit (OpCodes.Ldobj, type);
}
}
protected class FieldExpression : Expression
{
Field field;
public FieldExpression (Field field)
{
this.field = field;
}
public override Expression DoResolve (EmitContext ec)
{
FieldExpr fexpr = new FieldExpr (field.FieldBuilder, loc);
fexpr.InstanceExpression = ec.GetThis (loc);
return fexpr.Resolve (ec);
}
public override void Emit (EmitContext ec)
{
throw new InvalidOperationException ();
}
}
protected class MoveNextMethod : Statement {
Iterator iterator;
public MoveNextMethod (Iterator iterator, Location loc)
{
this.loc = loc;
this.iterator = iterator;
}
public override bool Resolve (EmitContext ec)
{
ec.CurrentBranching.CurrentUsageVector.Return ();
return true;
}
protected override void DoEmit (EmitContext ec)
{
int code_flags = Modifiers.METHOD_YIELDS;
if (iterator.is_static)
code_flags |= Modifiers.STATIC;
EmitContext new_ec = new EmitContext (
iterator.container, loc, ec.ig,
TypeManager.int32_type, code_flags);
new_ec.CurrentIterator = iterator;
iterator.EmitMoveNext (new_ec);
}
}
protected class DisposeMethod : Statement {
Iterator iterator;
public DisposeMethod (Iterator iterator, Location loc)
{
this.loc = loc;
this.iterator = iterator;
}
public override bool Resolve (EmitContext ec)
{
return true;
}
protected override void DoEmit (EmitContext ec)
{
iterator.EmitDispose (ec);
}
}
protected class StatementList : Statement {
ArrayList statements;
public StatementList (Location loc)
{
this.loc = loc;
statements = new ArrayList ();
}
public void Add (Statement statement)
{
statements.Add (statement);
}
public override bool Resolve (EmitContext ec)
{
foreach (Statement stmt in statements) {
if (!stmt.Resolve (ec))
return false;
}
return true;
}
protected override void DoEmit (EmitContext ec)
{
foreach (Statement stmt in statements)
stmt.Emit (ec);
}
}
protected class SetState : Statement
{
Iterator iterator;
State state;
public SetState (Iterator iterator, State state, Location loc)
{
this.iterator = iterator;
this.state = state;
this.loc = loc;
}
public override bool Resolve (EmitContext ec)
{
return true;
}
protected override void DoEmit (EmitContext ec)
{
ec.ig.Emit (OpCodes.Ldarg_0);
IntConstant.EmitInt (ec.ig, (int) state);
ec.ig.Emit (OpCodes.Stfld, iterator.pc_field.FieldBuilder);
}
}
void Define_Reset ()
{
Method reset = new Method (
this, null, TypeManager.system_void_expr, Modifiers.PUBLIC,
false, new MemberName ("Reset"),
Parameters.EmptyReadOnlyParameters, null, Location);
AddMethod (reset);
reset.Block = new Block (null);
reset.Block.AddStatement (Create_ThrowNotSupported ());
}
void Define_Dispose ()
{
dispose = new Method (
this, null, TypeManager.system_void_expr, Modifiers.PUBLIC,
false, new MemberName ("Dispose"),
Parameters.EmptyReadOnlyParameters, null, Location);
AddMethod (dispose);
dispose.Block = new Block (null);
dispose.Block.AddStatement (new DisposeMethod (this, Location));
}
public Block Block {
get { return block; }
}
public Type IteratorType {
get { return iterator_type; }
}
//
// This return statement tricks return into not flagging an error for being
// used in a Yields method
//
class NoCheckReturn : Return {
public NoCheckReturn (Expression expr, Location loc) : base (expr, loc)
{
}
public override bool Resolve (EmitContext ec)
{
ec.InIterator = false;
bool ret_val = base.Resolve (ec);
ec.InIterator = true;
return ret_val;
}
}
bool CheckType (Type t)
{
if (t == TypeManager.ienumerable_type) {
iterator_type = TypeManager.object_type;
is_enumerable = true;
return true;
} else if (t == TypeManager.ienumerator_type) {
iterator_type = TypeManager.object_type;
is_enumerable = false;
return true;
}
if (!t.IsGenericInstance)
return false;
Type[] args = TypeManager.GetTypeArguments (t);
if (args.Length != 1)
return false;
Type gt = t.GetGenericTypeDefinition ();
if (gt == TypeManager.generic_ienumerable_type) {
iterator_type = args [0];
is_enumerable = true;
return true;
} else if (gt == TypeManager.generic_ienumerator_type) {
iterator_type = args [0];
is_enumerable = false;
return true;
}
return false;
}
}
}
-29
View File
@@ -1,29 +0,0 @@
using System;
using Generics;
namespace Test
{
public class Bar : Foo
{
public void Hello (Stack<int> stack)
{
Console.WriteLine ("Hello Generic World!");
Console.WriteLine (stack);
Console.WriteLine (stack.GetType ());
}
public Stack<int> Test ()
{
return Driver.int_stack;
}
public static void Main ()
{
Foo foo = new Bar ();
Driver.Init (foo);
Stack<int> a = Driver.int_stack;
Console.WriteLine ("STACK: {0}", a);
foo.Hello (a);
}
}
}
-103
View File
@@ -1,103 +0,0 @@
.assembly sample-stack {}
.namespace Generics
{
.class interface public abstract Foo
{
.method public virtual hidebysig newslot abstract instance default void Hello(class Generics.Stack<int32> stack)
{
}
}
.class public beforefieldinit Driver extends [mscorlib]System.Object
{
.field static public class Generics.Stack<int32> int_stack
.field static public class Generics.Stack<string> string_stack
.method public hidebysig specialname rtspecialname instance default void .ctor()
{
ldarg.0
call instance void valuetype [corlib]System.Object::.ctor()
ret
}
.method public static void Init (class Generics.Foo foo)
{
newobj instance void class Generics.Stack<int32>::.ctor ()
stsfld class Generics.Stack<int32> Generics.Driver::int_stack
newobj instance void class Generics.Stack<string>::.ctor ()
stsfld class Generics.Stack<string> Generics.Driver::string_stack
ldarg.0
ldsfld class Generics.Stack<int32> Generics.Driver::int_stack
callvirt instance void class Generics.Foo::Hello(class Generics.Stack<int32>)
ret
}
}
.class public Stack<T> extends [mscorlib]System.Object
{
.field private int32 size
.field private !0[] data
.method public instance void .ctor ()
{
ldarg.0
call instance void [mscorlib]System.Object::.ctor ()
ldarg.0
ldc.i4.s 100
newarr !0
stfld !0[] class Generics.Stack<!0>::data
ldarg.0
ldc.i4.m1
stfld int32 class Generics.Stack<!0>::size
ret
}
.method public instance void Push (!0 item)
{
.locals init (int32 temp)
ldarg.0
ldfld !0[] class Generics.Stack<!0>::data
ldarg.0
dup
ldfld int32 class Generics.Stack<!0>::size
ldc.i4.1
add
dup
stloc.0
stfld int32 class Generics.Stack<!0>::size
ldloc.0
ldarg.1
stelem !0
ret
}
.method public instance !0 Pop ()
{
.locals init (!0, int32)
ldarg.0
ldfld !0[] class Generics.Stack<!0>::data
ldarg.0
dup
ldfld int32 class Generics.Stack<!0>::size
dup
stloc.1
ldc.i4.1
sub
stfld int32 class Generics.Stack<!0>::size
ldloc.1
ldelem !0
stloc.0
ldloc.0
ret
}
}
}
-91
View File
@@ -1,91 +0,0 @@
//
// symbolwriter.cs: The symbol writer
//
// Author:
// Martin Baulig ([email protected])
//
// (C) 2003 Ximian, Inc.
//
using System;
using System.Collections;
using System.Reflection;
using System.Reflection.Emit;
using Mono.CompilerServices.SymbolWriter;
namespace Mono.CSharp {
public class SymbolWriter : MonoSymbolWriter {
delegate int GetILOffsetFunc (ILGenerator ig);
delegate Guid GetGuidFunc (ModuleBuilder mb);
GetILOffsetFunc get_il_offset_func;
GetGuidFunc get_guid_func;
ModuleBuilder module_builder;
protected SymbolWriter (ModuleBuilder module_builder, string filename)
: base (filename)
{
this.module_builder = module_builder;
}
bool Initialize ()
{
MethodInfo mi = typeof (ILGenerator).GetMethod (
"Mono_GetCurrentOffset",
BindingFlags.Static | BindingFlags.NonPublic);
if (mi == null)
return false;
get_il_offset_func = (GetILOffsetFunc) System.Delegate.CreateDelegate (
typeof (GetILOffsetFunc), mi);
mi = typeof (ModuleBuilder).GetMethod (
"Mono_GetGuid",
BindingFlags.Static | BindingFlags.NonPublic);
if (mi == null)
return false;
get_guid_func = (GetGuidFunc) System.Delegate.CreateDelegate (
typeof (GetGuidFunc), mi);
Location.DefineSymbolDocuments (this);
Namespace.DefineNamespaces (this);
return true;
}
public void DefineLocalVariable (string name, LocalBuilder builder)
{
SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (
module_builder);
sighelper.AddArgument (builder.LocalType);
byte[] signature = sighelper.GetSignature ();
DefineLocalVariable (name, signature);
}
public void MarkSequencePoint (ILGenerator ig, int row, int column)
{
int offset = get_il_offset_func (ig);
MarkSequencePoint (offset, row, column);
}
public void WriteSymbolFile ()
{
Guid guid = get_guid_func (module_builder);
WriteSymbolFile (guid);
}
public static SymbolWriter GetSymbolWriter (ModuleBuilder module,
string filename)
{
SymbolWriter writer = new SymbolWriter (module, filename);
if (!writer.Initialize ())
return null;
return writer;
}
}
}
+14
View File
@@ -0,0 +1,14 @@
compiler.pdb
compiler.exe
compiler.suo
compiler.csproj
compiler.csproj.user
cs-parser.cs
y.output
*.pdb
mcs
Web References
bin
obj
Web References
Web References
@@ -1,8 +1,8 @@
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyVersion("1.1.1")]
[assembly: AssemblyVersion("0.94")]
[assembly: AssemblyTitle ("Mono C# Compiler")]
[assembly: AssemblyDescription ("Mono C# Compiler with Generics")]
[assembly: AssemblyDescription ("Mono C# Compiler")]
[assembly: AssemblyCopyright ("2001, 2002, 2003 Ximian, Inc.")]
[assembly: AssemblyCompany ("Ximian, Inc.")]
File diff suppressed because it is too large. Load diff
File renamed without changes.
+70
View File
@@ -0,0 +1,70 @@
thisdir := mcs
SUBDIRS :=
include ../build/rules.make
BUILT_SOURCES = cs-parser.cs
EXTRA_DISTFILES = \
compiler.csproj \
compiler.doc \
compiler.sln \
cs-parser.jay \
mcs.exe.config \
NOTES \
TODO
PROGRAM = mcs.exe
PROGRAM_COMPILE = $(BOOT_COMPILE)
PROGRAM_INSTALL_DIR = $(prefix)/lib/mono/1.0
CLEAN_FILES = y.output
cs-parser.cs: cs-parser.jay $(topdir)/jay/skeleton.cs
$(topdir)/jay/jay -ctv < $(topdir)/jay/skeleton.cs $< > jay-tmp.out && mv jay-tmp.out $@
include ../build/executable.make
# Testing targets
TIME = time
# This used to be called test, but that conflicts with the global
# recursive target.
btest: mcs2.exe mcs3.exe
ls -l mcs2.exe mcs3.exe
mcs2.exe: mcs.exe
$(TIME) $(RUNTIME) ./mcs.exe $(USE_MCS_FLAGS) /target:exe /out:$@ $(BUILT_SOURCES) @$(response)
mcs3.exe: mcs2.exe
$(TIME) $(RUNTIME) ./mcs2.exe $(USE_MCS_FLAGS) /target:exe /out:$@ $(BUILT_SOURCES) @$(response)
wc:
wc -l $(BUILT_SOURCES) `cat $(sourcefile)`
ctest:
rm -f mcs2.exe mcs3.exe
$(MAKE) USE_MCS_FLAGS= btest
# we need this because bash tries to use its own crappy timer
FRIENDLY_TIME = $(shell which time) -f'%U seconds'
do-time : mcs.exe
@ echo -n "Run 1: "
@ rm -f mcs2.exe
@ $(MAKE) TIME="$(FRIENDLY_TIME)" mcs2.exe > /dev/null || (echo FAILED; exit 1)
@ echo -n "Run 2: "
@ rm -f mcs3.exe
@ $(MAKE) TIME="$(FRIENDLY_TIME)" mcs3.exe > /dev/null || (echo FAILED; exit 1)
@ $(MAKE) do-corlib
do-corlib:
@ echo -n "corlib: "
@ rm -f ../class/lib/mscorlib.dll
@ cd ../class/corlib ; $(MAKE) BOOTSTRAP_MCS="$(FRIENDLY_TIME) mono ../../mcs/mcs.exe" > /dev/null || (echo FAILED; exit 1)
PROFILER=default
profile : mcs.exe
$(RUNTIME) --profile=$(PROFILER) ./mcs.exe $(USE_MCS_FLAGS) /target:exe /out:mcs2.exe $(BUILT_SOURCES) @$(response)
+38
View File
@@ -0,0 +1,38 @@
* Notes on improving error handling in MCS
(from Axel Schreiner <[email protected]>)
I included the 'recover' example with C# as well. Currently the package
is at <http://www.cs.rit.edu/~ats/projects/jay/>. I did change some
names and the embedding that the user does somewhat, i.e., it is not
directly compatible with what you did.
Here is the important part about error recovery. To make the typical
iterations bullet-proof, code them as follows:
opt : // null
| opt WORD { yyErrorFlag = 0; }
| opt error
seq : WORD
| seq WORD { yyErrorFlag = 0; }
| error
| seq error
list : WORD
| list ',' WORD { yyErrorFlag = 0; }
| error
| list error
| list error WORD { yyErrorFlag = 0; }
| list ',' error
i.e., throw in 'error' wherever a token can be. 'yyErrorFlag' need not
be set to zero, but if it is done this way, second errors are caught
earlier. This may introduce s/r conflicts, but they tend to be harmless.
In your case -- the comment concerning error recovery at the beginning
of your compiler jay file -- just adding 'error' to the different
global things won't work. Your example will already have started to
advance in one of the rules and 'error' is then not in the lookahead of
wherever the parse then is. You need to put 'error' into the iteration
above those global things.
+58
View File
@@ -0,0 +1,58 @@
These are the sources to the Mono C# compiler
---------------------------------------------
Read the mcs/docs/compiler.txt for an overview of the compiler.
Testing the Compiler
--------------------
You might want to use the `make btest' in this directory to
have the compiler bootstrap itself, this is the basic regression
test.
Before commiting changes to MCS, make sure that all the tests
in `mcs/tests' pass, type:
cd mcs/tests
make run-test-local
There is a new set of negative tests (errors that the compiler
should flag), but not all of them pass currently:
cd mcs/errors
make run-test-local
Full Bootstrap
==============
To finally ensure the state of the compiler, it is ideal to do
a full bootstrap, to do this, do:
cd mcs
make clean;
make
make install
That installs the compiler and assemblies compiled by the new compiler.
Then, repeat that step again:
make clean
make
If things work, the compiler has not added a new regression
while building the mscorlib and the compiler itself.
Tests
=====
When bugs are fixed, new tests must be added to the
`mcs/tests' directory to excercise the problem and to guarantee
that we keep the compiler in a good state.
When an error is reported, it should be added to mcs/errors.
We try to make the errors numbers be the same as the ones in
Microsoft C#, if this is not possible, allocate a negative error
number, and list it in mcs/errors/errors.txt
+433
View File
@@ -0,0 +1,433 @@
Error Reporting:
----------------
* Make yyerror show a nice syntax error, instead of the current mess.
Iterators
---------
* `yield' is no longer a keyword, it only has special
meaning before a return or break keywords.
* Study side effects with assign
* Study TemporaryStorage/LocalStorage -> Merge/rename
* Reset should throw not implemented now.
Instance idea
-------------
It would be nice to have things that can be "instances" to have an
EmitInstance method (this would default to nothing).
The idea is to be able to use efficiently the instance data on stack
manipulations, as opposed to the current scheme, where we basically have
a few special cases.
Optimization ideas
------------------
Currently when we build a type cache, it contains private members,
internal members, and internal protected members; We should trim
these out, as it shows up on the profile.
We create too many Arraylists; When we know the size, we should create
an array;
During parsing we use arraylists to accumulate data, like this:
thing:
thing_list
: thing { $$ =new ArrayList (); $$.Add ($1); }
| thing_list thing { ArrayList a = $1; a.Add ($2); $$ = a; }
We probably could start using "Pairs" there:
thing_list
: thing { $$ = new Pair ($1, null); }
| thing_list thing { Pair p = $1; $$ = new Pair ($2, $1); }
Anonymous Methods
-----------------
Plan:
* Resolve anonymous methods before.
* Each time a Local matches, if the mode is `InAnonymous', flag
the VariableInfo for `proxying'.
* During Resolve track the depth required for local variables.
* Before Emit, create proxy classes with proper depth.
* Emit.
Open question:
Create a toplevel block for anonymous methods?
EmitContext.ResolveTypeTree
---------------------------
We should investigate its usage. The problem is that by default
this will be set when calling FindType, that triggers a more expensive
lookup.
I believe we should pass the current EmitContext (which has this turned off
by default) to ResolveType/REsolveTypeExpr and then have the routines that
need ResolveType to pass null as the emit context.
DeclareLocal audit
------------------
DeclareLocal is used in various statements. The audit should be done
in two steps:
* Identify all the declare locals.
* Identify its uses.
* Find if we can make wrapper functions for all of them.
Then we can move DeclareLocal into a helper class.
This is required to fix foreach in iterators.
Large project:
--------------
Drop FindMembers as our API and instead extract all the data
out of a type the first time into our own datastructures, and
use that to navigate and search the type instead of the
callback based FindMembers.
Martin has some some of this work with his TypeHandle code
that we could use for this.
Notes on memory allocation
--------------------------
Outdated:
A run of the AllocationProfile shows that the compiler allocates roughly
30 megabytes of strings. From those, 20 megabytes come from
LookupType.
See the notes on current_container problems below on memory usage.
LookupTypeReflection:
---------------------
With something like `System.Object', LookupTypeReflection will be called
twice: once to find out that `System' is not a type and once
for System.Object.
This is required because System.Reflection requires that the type/nested types are
not separated by a dot but by a plus sign.
A nested class would be My+Class (My being the toplevel, Class the nested one).
It is interesting to look at the most called lookups when bootstrapping MCS:
647 LTR: ArrayList
713 LTR: System.Globalization
822 LTR: System.Object+Expression
904 LTR: Mono.CSharp.ArrayList
976 LTR: System.Runtime.CompilerServices
999 LTR: Type
1118 LTR: System.Runtime
1208 LTR: Mono.CSharp.Type
1373 LTR: Mono.Languages
1599 LTR: System.Diagnostics
2036 LTR: System.Text
2302 LTR: System.Reflection.Emit
2515 LTR: System.Collections
4527 LTR: System.Reflection
22273 LTR: Mono.CSharp
24245 LTR: System
27005 LTR: Mono
Analysis:
The top 9 lookups are done for things which are not types.
Mono.CSharp.Type happens to be a common lookup: the class Type
used heavily in the compiler in the default namespace.
RED FLAG:
Then `Type' is looked up alone a lot of the time, this happens
in parameter declarations and am not entirely sure that this is
correct (FindType will pass to LookupInterfaceOrClass a the current_type.FullName,
which for some reason is null!). This seems to be a problem with a lost
piece of context during FindType.
System.Object is also used a lot as a toplevel class, and we assume it will
have children, we should just shortcut this.
A cache:
Adding a cache and adding a catch for `System.Object' to flag that it wont be the
root of a hierarchy reduced the MCS bootstrap time from 10.22 seconds to 8.90 seconds.
This cache is currently enabled with SIMPLE_SPEEDUP in typemanager.cs. Memory consumption
went down from 74 megs to 65 megs with this change.
Ideas:
------
Instead of the hack that *knows* about System.Object not having any children classes,
we should just make it simple for a probe to know that there is no need for it.
The use of DottedName
---------------------
We could probably use a different system to represent names, like this:
class Name {
string simplename;
Name parent;
}
So `System.ComponentModel' becomes:
x: (System, null)
y: (ComponentModel, x)
The problem is that we would still need to construct the name to pass to
GetType.
This has been now implemented, its called "QualifiedIdentifier"
current_container/current_namespace and the DeclSpace
-----------------------------------------------------
We are storing fully qualified names in the DeclSpace instead of the node,
this is because `current_namespace' (Namepsace) is not a DeclSpace like
`current_container'.
The reason for storing the full names today is this:
namespace X {
class Y {
}
}
namespace A {
class Y {
}
}
The problem is that we only use the namespace stack to track the "prefix"
for typecontainers, but they are not typecontainers themselves, so we have
to use fully qualified names, because both A.X and A.Y would be entered
in the toplevel type container. If we use the short names, there would be
a name clash.
To fix this problem, we have to make namespaces DeclSpaces.
The full size, contrasted with the size that could be stored is:
corlib:
Size of strings held: 368901
Size of strings short: 147863
System:
Size of strings held: 212677
Size of strings short: 97521
System.XML:
Size of strings held: 128055
Size of strings short: 35782
System.Data:
Size of strings held: 117896
Size of strings short: 36153
System.Web:
Size of strings held: 194527
Size of strings short: 58064
System.Windows.Forms:
Size of strings held: 220495
Size of strings short: 64923
TODO:
1. Create a "partial" emit context for each TypeContainer..
2. EmitContext should be partially constructed. No IL Generator.
interface_type review.
parameter_array, line 952: `note: must be a single dimension array type'. Validate this
Dead Code Elimination bugs:
---------------------------
I should also resolve all the children expressions in Switch, Fixed, Using.
Major tasks:
------------
Pinned and volatile require type modifiers that can not be encoded
with Reflection.Emit.
Properties and 17.6.3: Finish it.
Implement base indexer access.
readonly variables and ref/out
BUGS
----
* Check for Final when overriding, if the parent is Final, then we cant
allow an override.
* Interface indexers
I have not figured out why the Microsoft version puts an
`instance' attribute, and I am not generating this `instance' attribute.
Explanation: The reason for the `instance' attribute on
indexers is that indexers only apply to instances
* Break/Continue statements
A finally block should reset the InLoop/LoopBegin/LoopEnd, as
they are logically outside the scope of the loop.
* Break/continue part 2.
They should transfer control to the finally block if inside a try/catch
block.
* Method Registration and error CS111
The way we use the method registration to signal 111 is wrong.
Method registration should only be used to register methodbuilders,
we need an alternate method of checking for duplicates.
*
> // CSC sets beforefieldinit
> class X {
> // .cctor will be generated by compiler
> public static readonly object O = new System.Object ();
> public static void Main () {}
> }
>
PENDING TASKS
-------------
* Merge test 89 and test-34
* Revisit
Primary-expression, as it has now been split into
non-array-creation-expression and array-creation-expression.
* Code cleanup
The information when registering a method in InternalParameters
is duplicated, you can always get the types from the InternalParameters
* Emit modreq for volatiles
Handle modreq from public apis.
* Emit `pinned' for pinned local variables.
Both `modreq' and pinned will require special hacks in the compiler.
* Make sure that we are pinning the right variable
* Merge tree.cs, rootcontext.cs
OPTIMIZATIONS
-------------
* User Defined Conversions is doing way too many calls to do union sets that are not needed
* Add test case for destructors
* Places that use `Ldelema' are basically places where I will be
initializing a value type. I could apply an optimization to
disable the implicit local temporary from being created (by using
the method in New).
* Dropping TypeContainer as an argument to EmitContext
My theory is that I can get rid of the TypeBuilder completely from
the EmitContext, and have typecasts where it is used (from
DeclSpace to where it matters).
The only pending problem is that the code that implements Aliases
is on TypeContainer, and probably should go in DeclSpace.
* Use of local temporary in UnaryMutator
We should get rid of the Localtemporary there for some cases
This turns out to be very complex, at least for the post-version,
because this case:
a = i++
To produce optimal code, it is necessary for UnaryMutator to know
that it is being assigned to a variable (the way the stack is laid
out using dup requires the store to happen inside UnaryMutator).
* Tests
Write tests for the various reference conversions. We have
test for all the numeric conversions.
* Optimizations
In Indexers and Properties, probably support an EmitWithDup
That emits the code to call Get and then leaves a this pointer
in the stack, so that later a Store can be emitted using that
this pointer (consider Property++ or Indexer++)
* Optimizations: variable allocation.
When local variables of a type are required, we should request
the variable and later release it when we are done, so that
the same local variable slot can be reused later on.
* Add a cache for the various GetArrayMethod operations.
* MakeUnionSet Callers
If the types are the same, there is no need to compute the unionset,
we can just use the list from one of the types.
* Factor the lookup code for class declarations an interfaces
(interface.cs:GetInterfaceByName)
RECOMMENDATIONS
---------------
* Use of lexer.Location in the parser
Currently we do:
TOKEN nt TERMINAL nt TERMINAL nt3 {
$$ = new Blah ($2, $4, $6, lexer.Location);
}
This is bad, because the lexer.Location is for the last item in `nt3'
We need to change that to use this pattern:
TOKEN { oob_stack.Push (lexer.Location) } nt TERMINAL nt TERMINAL nt3 {
$$ = new Blah ($3, $5, $7, (Location) oob_stack.Pop ());
}
Notice how numbering of the arguments changes as the
{ oob_stack.Push (lexer.Location) } takes a "slot" in the productions.
* local_variable_declaration
Not sure that this grammar is correct, we might have to
resolve this during semantic analysis.
File renamed without changes.
+69 -183
View File
@@ -29,125 +29,19 @@ namespace Mono.CSharp {
/// </remarks>
public interface IAssignMethod {
//
// This is an extra version of Emit. If leave_copy is `true'
// A copy of the expression will be left on the stack at the
// end of the code generated for EmitAssign
// This method will emit the code for the actual assignment
//
void Emit (EmitContext ec, bool leave_copy);
void EmitAssign (EmitContext ec, Expression source);
//
// This method does the assignment
// `source' will be stored into the location specified by `this'
// if `leave_copy' is true, a copy of `source' will be left on the stack
// if `prepare_for_load' is true, when `source' is emitted, there will
// be data on the stack that it can use to compuatate its value. This is
// for expressions like a [f ()] ++, where you can't call `f ()' twice.
// This method is invoked before any code generation takes
// place, and it is a mechanism to inform that the expression
// will be invoked more than once, and that the method should
// use temporary values to avoid having side effects
//
void EmitAssign (EmitContext ec, Expression source, bool leave_copy, bool prepare_for_load);
/*
For simple assignments, this interface is very simple, EmitAssign is called with source
as the source expression and leave_copy and prepare_for_load false.
For compound assignments it gets complicated.
EmitAssign will be called as before, however, prepare_for_load will be
true. The @source expression will contain an expression
which calls Emit. So, the calls look like:
this.EmitAssign (ec, source, false, true) ->
source.Emit (ec); ->
[...] ->
this.Emit (ec, false); ->
end this.Emit (ec, false); ->
end [...]
end source.Emit (ec);
end this.EmitAssign (ec, source, false, true)
When prepare_for_load is true, EmitAssign emits a `token' on the stack that
Emit will use for its state.
Let's take FieldExpr as an example. assume we are emitting f ().y += 1;
Here is the call tree again. This time, each call is annotated with the IL
it produces:
this.EmitAssign (ec, source, false, true)
call f
dup
Binary.Emit ()
this.Emit (ec, false);
ldfld y
end this.Emit (ec, false);
IntConstant.Emit ()
ldc.i4.1
end IntConstant.Emit
add
end Binary.Emit ()
stfld
end this.EmitAssign (ec, source, false, true)
Observe two things:
1) EmitAssign left a token on the stack. It was the result of f ().
2) This token was used by Emit
leave_copy (in both EmitAssign and Emit) tells the compiler to leave a copy
of the expression at that point in evaluation. This is used for pre/post inc/dec
and for a = x += y. Let's do the above example with leave_copy true in EmitAssign
this.EmitAssign (ec, source, true, true)
call f
dup
Binary.Emit ()
this.Emit (ec, false);
ldfld y
end this.Emit (ec, false);
IntConstant.Emit ()
ldc.i4.1
end IntConstant.Emit
add
end Binary.Emit ()
dup
stloc temp
stfld
ldloc temp
end this.EmitAssign (ec, source, true, true)
And with it true in Emit
this.EmitAssign (ec, source, false, true)
call f
dup
Binary.Emit ()
this.Emit (ec, true);
ldfld y
dup
stloc temp
end this.Emit (ec, true);
IntConstant.Emit ()
ldc.i4.1
end IntConstant.Emit
add
end Binary.Emit ()
stfld
ldloc temp
end this.EmitAssign (ec, source, false, true)
Note that these two examples are what happens for ++x and x++, respectively.
*/
// Example: a [ g () ] ++
//
void CacheTemporaries (EmitContext ec);
}
/// <summary>
@@ -161,40 +55,16 @@ namespace Mono.CSharp {
/// The local temporary is used to alter the normal flow of code generation
/// basically it creates a local variable, and its emit instruction generates
/// code to access this value, return its address or save its value.
///
/// If `is_address' is true, then the value that we store is the address to the
/// real value, and not the value itself.
///
/// This is needed for a value type, because otherwise you just end up making a
/// copy of the value on the stack and modifying it. You really need a pointer
/// to the origional value so that you can modify it in that location. This
/// Does not happen with a class because a class is a pointer -- so you always
/// get the indirection.
///
/// The `is_address' stuff is really just a hack. We need to come up with a better
/// way to handle it.
/// </remarks>
public class LocalTemporary : Expression, IMemoryLocation {
LocalBuilder builder;
bool is_address;
public LocalTemporary (EmitContext ec, Type t) : this (ec, t, false) {}
public LocalTemporary (EmitContext ec, Type t, bool is_address)
public LocalTemporary (EmitContext ec, Type t)
{
type = t;
eclass = ExprClass.Value;
loc = Location.Null;
builder = ec.GetTemporaryLocal (is_address ? TypeManager.GetReferenceType (t): t);
this.is_address = is_address;
}
public LocalTemporary (LocalBuilder b, Type t)
{
type = t;
eclass = ExprClass.Value;
loc = Location.Null;
builder = b;
builder = ec.GetTemporaryLocal (t);
}
public void Release (EmitContext ec)
@@ -203,6 +73,14 @@ namespace Mono.CSharp {
builder = null;
}
public LocalTemporary (LocalBuilder b, Type t)
{
type = t;
eclass = ExprClass.Value;
loc = Location.Null;
builder = b;
}
public override Expression DoResolve (EmitContext ec)
{
return this;
@@ -210,39 +88,17 @@ namespace Mono.CSharp {
public override void Emit (EmitContext ec)
{
ILGenerator ig = ec.ig;
ig.Emit (OpCodes.Ldloc, builder);
// we need to copy from the pointer
if (is_address)
LoadFromPtr (ig, type);
ec.ig.Emit (OpCodes.Ldloc, builder);
}
// NB: if you have `is_address' on the stack there must
// be a managed pointer. Otherwise, it is the type from
// the ctor.
public void Store (EmitContext ec)
{
ILGenerator ig = ec.ig;
ig.Emit (OpCodes.Stloc, builder);
ec.ig.Emit (OpCodes.Stloc, builder);
}
public void AddressOf (EmitContext ec, AddressOp mode)
{
// if is_address, than this is just the address anyways,
// so we just return this.
ILGenerator ig = ec.ig;
if (is_address)
ig.Emit (OpCodes.Ldloc, builder);
else
ig.Emit (OpCodes.Ldloca, builder);
}
public bool PointsToAddress {
get {
return is_address;
}
ec.ig.Emit (OpCodes.Ldloca, builder);
}
}
@@ -385,14 +241,7 @@ namespace Mono.CSharp {
}
}
}
if (!(target is IAssignMethod) && (target.eclass != ExprClass.EventAccess)) {
Report.Error (131, loc,
"Left hand of an assignment must be a variable, " +
"a property or an indexer");
return null;
}
if (source is New && target_type.IsValueType &&
(target.eclass != ExprClass.IndexerAccess) && (target.eclass != ExprClass.PropertyAccess)){
New n = (New) source;
@@ -403,16 +252,22 @@ namespace Mono.CSharp {
return null;
}
if ((source.eclass == ExprClass.Type) && (source is TypeExpr)) {
source.Error_UnexpectedKind ("variable or value", loc);
if (!(target is IAssignMethod) && (target.eclass != ExprClass.EventAccess)) {
Report.Error (131, loc,
"Left hand of an assignment must be a variable, " +
"a property or an indexer");
return null;
} else if ((RootContext.Version == LanguageVersion.ISO_1) &&
(source is MethodGroupExpr)){
}
if ((source.eclass == ExprClass.Type) && (source is TypeExpr)) {
source.Error_UnexpectedKind ("variable or value");
return null;
} else if (!RootContext.V2 && (source is MethodGroupExpr)){
((MethodGroupExpr) source).ReportUsageError ();
return null;
}
if (target_type == source_type)
return this;
@@ -501,7 +356,7 @@ namespace Mono.CSharp {
}
Expression temp_source = (temp != null) ? temp : source;
((IAssignMethod) target).EmitAssign (ec, temp_source, false, false);
((IAssignMethod) target).EmitAssign (ec, temp_source);
return temp_source;
}
@@ -523,8 +378,20 @@ namespace Mono.CSharp {
((EventExpr) target).EmitAddOrRemove (ec, source);
return;
}
bool use_temporaries = false;
//
// FIXME! We need a way to "probe" if the process can
// just use `dup' to propagate the result
//
IAssignMethod am = (IAssignMethod) target;
if (this is CompoundAssign)
am.CacheTemporaries (ec);
if (!is_statement)
use_temporaries = true;
Expression temp_source;
if (embedded != null) {
@@ -537,8 +404,27 @@ namespace Mono.CSharp {
}
} else
temp_source = source;
am.EmitAssign (ec, temp_source, !is_statement, this is CompoundAssign);
if (use_temporaries){
//
// Doing this for every path is too expensive
// I wonder if we can work around this and have a less
// expensive path
//
LocalTemporary tempo;
tempo = new LocalTemporary (ec, source.Type);
temp_source.Emit (ec);
tempo.Store (ec);
am.EmitAssign (ec, tempo);
if (!is_statement)
tempo.Emit (ec);
tempo.Release (ec);
} else {
am.EmitAssign (ec, temp_source);
}
if (embedded != null) {
if (temp != null)
+193 -295
View File
@@ -2,7 +2,6 @@
// attribute.cs: Attribute Handler
//
// Author: Ravi Pratap ([email protected])
// Marek Safar ([email protected])
//
// Licensed under the terms of the GNU GPL
//
@@ -35,7 +34,7 @@ namespace Mono.CSharp {
{
attributes = attrs;
if (attributes != null)
attributes.CheckTargets (this);
attributes.CheckTargets (ValidAttributeTargets);
}
public Attributes OptAttributes
@@ -46,7 +45,7 @@ namespace Mono.CSharp {
set {
attributes = value;
if (attributes != null)
attributes.CheckTargets (this);
attributes.CheckTargets (ValidAttributeTargets);
}
}
@@ -56,7 +55,7 @@ namespace Mono.CSharp {
public abstract void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb);
/// <summary>
/// Returns one AttributeTarget for this element.
/// Returns combination of enabled AttributeTargets
/// </summary>
public abstract AttributeTargets AttributeTargets { get; }
@@ -66,13 +65,11 @@ namespace Mono.CSharp {
/// Gets list of valid attribute targets for explicit target declaration.
/// The first array item is default target. Don't break this rule.
/// </summary>
public abstract string[] ValidAttributeTargets { get; }
protected abstract string[] ValidAttributeTargets { get; }
};
public class Attribute {
public readonly string ExplicitTarget;
public AttributeTargets Target;
public string Target;
public readonly string Name;
public readonly ArrayList Arguments;
@@ -107,14 +104,15 @@ namespace Mono.CSharp {
Name = name;
Arguments = args;
Location = loc;
ExplicitTarget = target;
Target = target;
}
void Error_InvalidNamedArgument (string name)
{
Report.Error (617, Location, "'" + name + "' is not a valid named attribute " +
"argument. Named attribute arguments must be fields which are not " +
"readonly, static or const, or read-write properties which are not static.");
"readonly, static or const, or properties with a set accessor which "+
"are not static.");
}
static void Error_AttributeArgumentNotValid (Location loc)
@@ -124,12 +122,6 @@ namespace Mono.CSharp {
"expression or array creation expression");
}
static void Error_TypeParameterInAttribute (Location loc)
{
Report.Error (
-202, loc, "Can not use a type parameter in an attribute");
}
void Error_AttributeConstructorMismatch ()
{
Report.Error (-6, Location,
@@ -141,16 +133,18 @@ namespace Mono.CSharp {
/// </summary>
protected virtual Type CheckAttributeType (EmitContext ec, bool complain)
{
TypeExpr t1 = RootContext.LookupType (ec.DeclSpace, Name, true, Location);
Type t1 = RootContext.LookupType (ec.DeclSpace, Name, true, Location);
// FIXME: Shouldn't do this for quoted attributes: [@A]
TypeExpr t2 = RootContext.LookupType (ec.DeclSpace, Name + "Attribute", true, Location);
Type t2 = RootContext.LookupType (ec.DeclSpace, Name + "Attribute", true, Location);
String err0616 = null;
if (t1 != null && ! t1.IsAttribute) {
if (t1 != null && ! t1.IsSubclassOf (TypeManager.attribute_type)) {
t1 = null;
err0616 = "'" + Name + "': is not an attribute class";
}
if (t2 != null && ! t2.IsAttribute) {
if (t2 != null && ! t2.IsSubclassOf (TypeManager.attribute_type)) {
t2 = null;
err0616 = (err0616 != null)
? "Neither '" + Name + "' nor '" + Name + "Attribute' is an attribute class"
@@ -163,9 +157,10 @@ namespace Mono.CSharp {
return null;
}
if (t1 != null)
return t1.ResolveType (ec);
return t1;
if (t2 != null)
return t2.ResolveType (ec);
return t2;
if (err0616 != null) {
Report.Error (616, Location, err0616);
return null;
@@ -208,24 +203,10 @@ namespace Mono.CSharp {
// Given an expression, if the expression is a valid attribute-argument-expression
// returns an object that can be used to encode it, or null on failure.
//
public static bool GetAttributeArgumentExpression (Expression e, Location loc, Type arg_type, out object result)
public static bool GetAttributeArgumentExpression (Expression e, Location loc, out object result)
{
if (e is EnumConstant) {
result = e;
return true;
}
Constant constant = e as Constant;
if (constant != null) {
if (e.Type != arg_type) {
constant = Const.ChangeType (loc, constant, arg_type);
if (constant == null) {
result = null;
Error_AttributeArgumentNotValid (loc);
return false;
}
}
result = constant.GetValue ();
if (e is Constant) {
result = ((Constant) e).GetValue ();
return true;
} else if (e is TypeOf) {
result = ((TypeOf) e).TypeArg;
@@ -235,8 +216,11 @@ namespace Mono.CSharp {
if (result != null)
return true;
} else if (e is EmptyCast) {
Expression child = ((EmptyCast)e).Child;
return GetAttributeArgumentExpression (child, loc, child.Type, out result);
result = e;
if (((EmptyCast) e).Child is Constant) {
result = ((Constant) ((EmptyCast)e).Child).GetValue();
}
return true;
}
result = null;
@@ -250,21 +234,15 @@ namespace Mono.CSharp {
// Sanity check.
Type = CheckAttributeType (ec, true);
if (oldType == null && Type == null)
return null;
if (oldType != null && oldType != Type){
Report.Error (-27, Location,
if (oldType != null && oldType != Type) {
Report.Error (-6, Location,
"Attribute {0} resolved to different types at different times: {1} vs. {2}",
Name, oldType, Type);
return null;
}
if (Type.IsAbstract) {
Report.Error (653, Location, "Cannot apply attribute class '{0}' because it is abstract", Name);
return null;
}
bool MethodImplAttr = false;
bool MarshalAsAttr = false;
bool GuidAttr = false;
@@ -303,7 +281,6 @@ namespace Mono.CSharp {
}
pos_values = new object [pos_arg_count];
object[] real_pos_values = new object [pos_arg_count];
//
// First process positional arguments
@@ -320,35 +297,27 @@ namespace Mono.CSharp {
e = a.Expr;
object val;
if (!GetAttributeArgumentExpression (e, Location, a.Type, out val))
if (!GetAttributeArgumentExpression (e, Location, out val))
return null;
if (val is EnumConstant) {
EnumConstant econst = (EnumConstant) e;
pos_values [i] = val = econst.GetValue ();
real_pos_values [i] = econst.GetValueAsEnumType ();
} else {
real_pos_values [i] = pos_values [i] = val;
}
pos_values [i] = val;
if (DoCompares){
if (usage_attr)
usage_attribute = new AttributeUsageAttribute ((AttributeTargets) val);
usage_attribute = new AttributeUsageAttribute ((AttributeTargets) pos_values [0]);
else if (MethodImplAttr)
this.ImplOptions = (MethodImplOptions) val;
this.ImplOptions = (MethodImplOptions) pos_values [0];
else if (GuidAttr){
//
// we will later check the validity of the type
//
if (val is string){
if (!ValidateGuid ((string) val))
if (pos_values [0] is string){
if (!ValidateGuid ((string) pos_values [0]))
return null;
}
} else if (MarshalAsAttr)
this.UnmanagedType =
(System.Runtime.InteropServices.UnmanagedType) val;
(System.Runtime.InteropServices.UnmanagedType) pos_values [0];
}
}
@@ -397,7 +366,7 @@ namespace Mono.CSharp {
Location);
if (member != null) {
Report.Error (122, Location, "'{0}' is inaccessible due to its protection level", GetFullMemberName (member_name));
Report.Error_T (122, Location, GetFullMemberName (member_name));
return null;
}
}
@@ -408,33 +377,42 @@ namespace Mono.CSharp {
}
e = a.Expr;
if (e is TypeParameterExpr){
Error_TypeParameterInAttribute (Location);
return null;
}
if (member is PropertyExpr) {
PropertyExpr pe = (PropertyExpr) member;
PropertyInfo pi = pe.PropertyInfo;
if (!pi.CanWrite || !pi.CanRead) {
Report.SymbolRelatedToPreviousError (pi);
if (!pi.CanWrite) {
Error_InvalidNamedArgument (member_name);
return null;
}
object value;
if (!GetAttributeArgumentExpression (e, Location, pi.PropertyType, out value))
Constant c = e as Constant;
if (c != null) {
if (c.Type != pi.PropertyType) {
c = Const.ChangeType (Location, c, pi.PropertyType);
if (c == null)
return null;
}
object o = c.GetValue ();
prop_values.Add (o);
if (usage_attribute != null) {
if (member_name == "AllowMultiple")
usage_attribute.AllowMultiple = (bool) value;
usage_attribute.AllowMultiple = (bool) o;
if (member_name == "Inherited")
usage_attribute.Inherited = (bool) value;
usage_attribute.Inherited = (bool) o;
}
} else if (e is TypeOf) {
prop_values.Add (((TypeOf) e).TypeArg);
} else if (e is ArrayCreation) {
prop_values.Add (((ArrayCreation) e).EncodeAsAttribute());
} else {
Error_AttributeArgumentNotValid (Location);
return null;
}
prop_values.Add (value);
prop_infos.Add (pi);
} else if (member is FieldExpr) {
@@ -446,12 +424,26 @@ namespace Mono.CSharp {
return null;
}
object value;
if (!GetAttributeArgumentExpression (e, Location, fi.FieldType, out value))
//
// Handle charset here, and set the TypeAttributes
Constant c = e as Constant;
if (c != null) {
if (c.Type != fi.FieldType) {
c = Const.ChangeType (Location, c, fi.FieldType);
if (c == null)
return null;
}
object value = c.GetValue ();
field_values.Add (value);
} else if (e is TypeOf) {
field_values.Add (((TypeOf) e).TypeArg);
} else {
Error_AttributeArgumentNotValid (Location);
return null;
field_values.Add (value);
}
field_infos.Add (fi);
}
}
@@ -467,9 +459,10 @@ namespace Mono.CSharp {
}
MethodBase constructor = Invocation.OverloadResolve (
ec, (MethodGroupExpr) mg, pos_args, false, Location);
ec, (MethodGroupExpr) mg, pos_args, Location);
if (constructor == null) {
Error_AttributeConstructorMismatch ();
return null;
}
@@ -498,16 +491,16 @@ namespace Mono.CSharp {
continue;
if (j == group_in_params_array){
object v = real_pos_values [j];
object v = pos_values [j];
int count = pos_arg_count - j;
object [] array = new object [count];
real_pos_values [j] = array;
pos_values [j] = array;
array [0] = v;
} else {
object [] array = (object []) real_pos_values [group_in_params_array];
object [] array = (object []) pos_values [group_in_params_array];
array [j - group_in_params_array] = real_pos_values [j];
array [j - group_in_params_array] = pos_values [j];
}
}
@@ -519,8 +512,8 @@ namespace Mono.CSharp {
object [] new_pos_values = new object [argc];
for (int p = 0; p < argc; p++)
new_pos_values [p] = real_pos_values [p];
real_pos_values = new_pos_values;
new_pos_values [p] = pos_values [p];
pos_values = new_pos_values;
}
try {
@@ -537,13 +530,13 @@ namespace Mono.CSharp {
prop_infos.CopyTo (prop_info_arr, 0);
cb = new CustomAttributeBuilder (
(ConstructorInfo) constructor, real_pos_values,
(ConstructorInfo) constructor, pos_values,
prop_info_arr, prop_values_arr,
field_info_arr, field_values_arr);
}
else
cb = new CustomAttributeBuilder (
(ConstructorInfo) constructor, real_pos_values);
(ConstructorInfo) constructor, pos_values);
} catch (NullReferenceException) {
//
// Don't know what to do here
@@ -568,10 +561,10 @@ namespace Mono.CSharp {
/// <summary>
/// Get a string containing a list of valid targets for the attribute 'attr'
/// </summary>
public string GetValidTargets ()
static string GetValidTargets (Attribute attr)
{
StringBuilder sb = new StringBuilder ();
AttributeTargets targets = GetAttributeUsage ().ValidOn;
AttributeTargets targets = attr.GetAttributeUsage ().ValidOn;
if ((targets & AttributeTargets.Assembly) != 0)
sb.Append ("'assembly' ");
@@ -619,6 +612,15 @@ namespace Mono.CSharp {
}
public static void Error_AttributeNotValidForElement (Attribute a, Location loc)
{
Report.Error (
592, loc, "Attribute '" + a.Name +
"' is not valid on this declaration type. " +
"It is valid on " + GetValidTargets (a) + "declarations only.");
}
/// <summary>
/// Returns AttributeUsage attribute for this type
/// </summary>
@@ -640,38 +642,58 @@ namespace Mono.CSharp {
return attr_class.AttributeUsage;
}
/// <summary>
/// Returns custom name of indexer
/// </summary>
public string GetIndexerAttributeValue (EmitContext ec)
//
// This pulls the condition name out of a Conditional attribute
//
public string Conditional_GetConditionName ()
{
if (pos_values == null) {
// TODO: It is not neccessary to call whole Resolve (ApplyAttribute does it now) we need only ctor args.
// But because a lot of attribute class code must be rewritten will be better to wait...
Resolve (ec);
//
// So we have a Conditional, pull the data out.
//
if (Arguments == null || Arguments [0] == null){
Error_AttributeConstructorMismatch ();
return null;
}
return pos_values [0] as string;
ArrayList pos_args = (ArrayList) Arguments [0];
if (pos_args.Count != 1){
Error_AttributeConstructorMismatch ();
return null;
}
Argument arg = (Argument) pos_args [0];
if (!(arg.Expr is StringConstant)){
Error_AttributeConstructorMismatch ();
return null;
}
return ((StringConstant) arg.Expr).Value;
}
/// <summary>
/// Returns condition of ConditionalAttribute
/// </summary>
public string GetConditionalAttributeValue (DeclSpace ds)
public string IndexerName_GetIndexerName (EmitContext ec)
{
if (pos_values == null) {
EmitContext ec = new EmitContext (ds, ds, Location, null, null, 0, false);
// TODO: It is not neccessary to call whole Resolve (ApplyAttribute does it now) we need only ctor args.
// But because a lot of attribute class code must be rewritten will be better to wait...
Resolve (ec);
}
// Some error occurred
if (pos_values [0] == null)
if (Arguments == null || Arguments [0] == null){
Error_AttributeConstructorMismatch ();
return null;
return (string)pos_values [0];
}
ArrayList pos_args = (ArrayList) Arguments [0];
if (pos_args.Count != 1) {
Error_AttributeConstructorMismatch ();
return null;
}
Argument arg = (Argument) pos_args [0];
if (!arg.Resolve (ec, Location))
return null;
StringConstant sc = arg.Expr as StringConstant;
if (sc == null){
Error_AttributeConstructorMismatch ();
return null;
}
return sc.Value;
}
/// <summary>
@@ -722,14 +744,6 @@ namespace Mono.CSharp {
return (bool)pos_values [0];
}
object GetValue (object value)
{
if (value is EnumConstant)
return ((EnumConstant) value).GetValue ();
else
return value;
}
public object GetPositionalValue (int i)
{
return (pos_values == null) ? null : pos_values[i];
@@ -743,7 +757,7 @@ namespace Mono.CSharp {
i = 0;
foreach (FieldInfo fi in field_info_arr) {
if (fi.Name == name)
return GetValue (field_values_arr [i]);
return field_values_arr [i];
i++;
}
return null;
@@ -800,27 +814,18 @@ namespace Mono.CSharp {
return;
AttributeUsageAttribute usage_attr = GetAttributeUsage ();
if ((usage_attr.ValidOn & Target) == 0) {
Report.Error (592, Location, "Attribute '{0}' is not valid on this declaration type. It is valid on {1} declarations only.", Name, GetValidTargets ());
if ((usage_attr.ValidOn & ias.AttributeTargets) == 0) {
Error_AttributeNotValidForElement (this, Location);
return;
}
ias.ApplyAttributeBuilder (this, cb);
if (!usage_attr.AllowMultiple) {
ArrayList emitted_targets = (ArrayList)emitted_attr [Type];
if (emitted_targets == null) {
emitted_targets = new ArrayList ();
emitted_attr.Add (Type, emitted_targets);
} else if (emitted_targets.Contains (Target)) {
if (!usage_attr.AllowMultiple && emitted_attr.Contains (Target)) {
Report.Error (579, Location, "Duplicate '" + Name + "' attribute");
return;
}
emitted_targets.Add (Target);
}
if (!RootContext.VerifyClsCompliance)
return;
emitted_attr [Type] = Target;
// Here we are testing attribute arguments for array usage (error 3016)
if (ias.IsClsCompliaceRequired (ec.DeclSpace)) {
@@ -835,7 +840,7 @@ namespace Mono.CSharp {
return;
if (arg.Type.IsArray) {
Report.Error (3016, Location, "Arrays as attribute arguments are not CLS-compliant");
Report.Error_T (3016, Location);
return;
}
}
@@ -853,7 +858,7 @@ namespace Mono.CSharp {
return;
if (arg.Type.IsArray) {
Report.Error (3016, Location, "Arrays as attribute arguments are not CLS-compliant");
Report.Error_T (3016, Location);
return;
}
}
@@ -1074,41 +1079,31 @@ namespace Mono.CSharp {
/// <summary>
/// Checks whether attribute target is valid for the current element
/// </summary>
public void CheckTargets (Attributable member)
public void CheckTargets (string[] possible_targets)
{
string[] valid_targets = member.ValidAttributeTargets;
foreach (Attribute a in Attrs) {
if (a.ExplicitTarget == null || a.ExplicitTarget == valid_targets [0]) {
a.Target = member.AttributeTargets;
if (a.Target == null) {
a.Target = possible_targets [0];
continue;
}
// TODO: we can skip the first item
if (((IList) valid_targets).Contains (a.ExplicitTarget)) {
switch (a.ExplicitTarget) {
case "return": a.Target = AttributeTargets.ReturnValue; continue;
case "param": a.Target = AttributeTargets.Parameter; continue;
case "field": a.Target = AttributeTargets.Field; continue;
case "method": a.Target = AttributeTargets.Method; continue;
case "property": a.Target = AttributeTargets.Property; continue;
}
throw new InternalErrorException ("Unknown explicit target: " + a.ExplicitTarget);
}
if (((IList) possible_targets).Contains (a.Target))
continue;
StringBuilder sb = new StringBuilder ();
foreach (string s in valid_targets) {
foreach (string s in possible_targets) {
sb.Append (s);
sb.Append (", ");
}
sb.Remove (sb.Length - 2, 2);
Report.Error (657, a.Location, "'{0}' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are '{1}'", a.Target, sb.ToString ());
Report.Error_T (657, a.Location, a.Target, sb.ToString ());
}
}
private Attribute Search (Type t, EmitContext ec, bool complain)
{
foreach (Attribute a in Attrs) {
if (a.ResolveType (ec, complain) == t)
if (a.ResolveType (ec, false) == t)
return a;
}
return null;
@@ -1119,24 +1114,6 @@ namespace Mono.CSharp {
return Search (t, ec, true);
}
/// <summary>
/// Returns all attributes of type 't'. Use it when attribute is AllowMultiple = true
/// </summary>
public Attribute[] SearchMulti (Type t, EmitContext ec)
{
ArrayList ar = null;
foreach (Attribute a in Attrs) {
if (a.ResolveType (ec, false) == t) {
if (ar == null)
ar = new ArrayList ();
ar.Add (a);
}
}
return ar == null ? null : ar.ToArray (typeof (Attribute)) as Attribute[];
}
public void Emit (EmitContext ec, Attributable ias)
{
ListDictionary ld = new ListDictionary ();
@@ -1158,15 +1135,17 @@ namespace Mono.CSharp {
/// <summary>
/// Pulls the IndexerName attribute from an Indexer if it exists.
/// </summary>
public Attribute GetIndexerNameAttribute (EmitContext ec)
public string ScanForIndexerName (EmitContext ec)
{
Attribute a = Search (TypeManager.indexer_name_type, ec, false);
Attribute a = Search (TypeManager.indexer_name_type, ec);
if (a == null)
return null;
// Remove the attribute from the list because it is not emitted
// Remove the attribute from the list
//TODO: It is very close to hack and it can crash here
Attrs.Remove (a);
return a;
return a.IndexerName_GetIndexerName (ec);
}
}
@@ -1177,9 +1156,7 @@ namespace Mono.CSharp {
sealed class AttributeTester
{
static PtrHashtable analyzed_types = new PtrHashtable ();
static PtrHashtable analyzed_types_obsolete = new PtrHashtable ();
static PtrHashtable analyzed_member_obsolete = new PtrHashtable ();
static PtrHashtable analyzed_method_excluded = new PtrHashtable ();
private AttributeTester ()
{
@@ -1239,7 +1216,7 @@ namespace Mono.CSharp {
foreach (Parameter arg in fixedParameters) {
if (!AttributeTester.IsClsCompliant (arg.ParameterType)) {
Report.Error (3001, loc, "Argument type '{0}' is not CLS-compliant", arg.GetSignatureForError ());
Report.Error_T (3001, loc, arg.GetSignatureForError ());
return false;
}
}
@@ -1277,6 +1254,30 @@ namespace Mono.CSharp {
static object TRUE = new object ();
static object FALSE = new object ();
/// <summary>
/// Non-hierarchical CLS Compliance analyzer
/// </summary>
public static bool IsComplianceRequired (MemberInfo mi, DeclSpace ds)
{
DeclSpace temp_ds = TypeManager.LookupDeclSpace (mi.DeclaringType);
// Type is external, we can get attribute directly
if (temp_ds == null) {
object[] cls_attribute = mi.GetCustomAttributes (TypeManager.cls_compliant_attribute_type, false);
return (cls_attribute.Length == 1 && ((CLSCompliantAttribute)cls_attribute[0]).IsCompliant);
}
string tmp_name;
// Interface doesn't store full name
if (temp_ds is Interface)
tmp_name = mi.Name;
else
tmp_name = String.Concat (temp_ds.Name, ".", mi.Name);
MemberCore mc = temp_ds.GetDefinition (tmp_name) as MemberCore;
return mc.IsClsCompliaceRequired (ds);
}
public static void VerifyModulesClsCompliance ()
{
Module[] modules = TypeManager.Modules;
@@ -1287,49 +1288,12 @@ namespace Mono.CSharp {
for (int i = 1; i < modules.Length; ++i) {
Module module = modules [i];
if (!IsClsCompliant (module)) {
Report.Error (3013, "Added modules must be marked with the CLSCompliant attribute to match the assembly", module.Name);
Report.Error_T (3013, module.Name);
return;
}
}
}
/// <summary>
/// Tests container name for CLS-Compliant name (differing only in case)
/// </summary>
public static void VerifyTopLevelNameClsCompliance ()
{
Hashtable locase_table = new Hashtable ();
// Convert imported type names to lower case and ignore not cls compliant
foreach (DictionaryEntry de in TypeManager.all_imported_types) {
Type t = (Type)de.Value;
if (!AttributeTester.IsClsCompliant (t))
continue;
locase_table.Add (((string)de.Key).ToLower (System.Globalization.CultureInfo.InvariantCulture), t);
}
foreach (DictionaryEntry de in RootContext.Tree.Decls) {
DeclSpace decl = (DeclSpace)de.Value;
if (!decl.IsClsCompliaceRequired (decl))
continue;
string lcase = decl.Name.ToLower (System.Globalization.CultureInfo.InvariantCulture);
if (!locase_table.Contains (lcase)) {
locase_table.Add (lcase, decl);
continue;
}
object conflict = locase_table [lcase];
if (conflict is Type)
Report.SymbolRelatedToPreviousError ((Type)conflict);
else
Report.SymbolRelatedToPreviousError ((MemberCore)conflict);
Report.Error (3005, decl.Location, "Identifier '{0}' differing only in case is not CLS-compliant", decl.GetSignatureForError ());
}
}
static bool IsClsCompliant (ICustomAttributeProvider attribute_provider)
{
object[] CompliantAttribute = attribute_provider.GetCustomAttributes (TypeManager.cls_compliant_attribute_type, false);
@@ -1346,9 +1310,6 @@ namespace Mono.CSharp {
return ds.IsClsCompliaceRequired (ds.Parent);
}
if (type.IsGenericParameter)
return false;
object[] CompliantAttribute = type.GetCustomAttributes (TypeManager.cls_compliant_attribute_type, false);
if (CompliantAttribute.Length == 0)
return IsClsCompliant (type.Assembly);
@@ -1356,40 +1317,6 @@ namespace Mono.CSharp {
return ((CLSCompliantAttribute)CompliantAttribute[0]).IsCompliant;
}
/// <summary>
/// Returns instance of ObsoleteAttribute when type is obsolete
/// </summary>
public static ObsoleteAttribute GetObsoleteAttribute (Type type)
{
object type_obsolete = analyzed_types_obsolete [type];
if (type_obsolete == FALSE)
return null;
if (type_obsolete != null)
return (ObsoleteAttribute)type_obsolete;
ObsoleteAttribute result = null;
if (type.IsByRef || type.IsArray || type.IsPointer) {
result = GetObsoleteAttribute (TypeManager.GetElementType (type));
} else if (type.IsGenericParameter || type.IsGenericInstance)
return null;
else {
DeclSpace type_ds = TypeManager.LookupDeclSpace (type);
// Type is external, we can get attribute directly
if (type_ds == null) {
object[] attribute = type.GetCustomAttributes (TypeManager.obsolete_attribute_type, false);
if (attribute.Length == 1)
result = (ObsoleteAttribute)attribute [0];
} else {
result = type_ds.GetObsoleteAttribute (type_ds);
}
}
analyzed_types_obsolete.Add (type, result == null ? FALSE : result);
return result;
}
/// <summary>
/// Returns instance of ObsoleteAttribute when method is obsolete
/// </summary>
@@ -1399,7 +1326,7 @@ namespace Mono.CSharp {
if (mc != null)
return mc.GetObsoleteAttribute ();
// compiler generated methods are not registered by AddMethod
// TODO: remove after Constructor will be ready for IMethodData
if (mb.DeclaringType is TypeBuilder)
return null;
@@ -1418,9 +1345,6 @@ namespace Mono.CSharp {
if (type_obsolete != null)
return (ObsoleteAttribute)type_obsolete;
if ((mi.DeclaringType is TypeBuilder) || mi.DeclaringType.IsGenericInstance)
return null;
ObsoleteAttribute oa = System.Attribute.GetCustomAttribute (mi, TypeManager.obsolete_attribute_type, false) as ObsoleteAttribute;
analyzed_member_obsolete.Add (mi, oa == null ? FALSE : oa);
return oa;
@@ -1432,41 +1356,15 @@ namespace Mono.CSharp {
public static void Report_ObsoleteMessage (ObsoleteAttribute oa, string member, Location loc)
{
if (oa.IsError) {
Report.Error (619, loc, "'{0}' is obsolete: '{1}'", member, oa.Message);
Report.Error_T (619, loc, member, oa.Message);
return;
}
if (oa.Message == null) {
Report.Warning (612, loc, "'{0}' is obsolete", member);
Report.Warning_T (612, loc, member);
return;
}
if (RootContext.WarningLevel >= 2)
Report.Warning (618, loc, "'{0}' is obsolete: '{1}'", member, oa.Message);
}
public static bool IsConditionalMethodExcluded (MethodBase mb)
{
object excluded = analyzed_method_excluded [mb];
if (excluded != null)
return excluded == TRUE ? true : false;
if (mb.Mono_IsInflatedMethod)
return false;
ConditionalAttribute[] attrs = mb.GetCustomAttributes (TypeManager.conditional_attribute_type, true) as ConditionalAttribute[];
if (attrs.Length == 0) {
analyzed_method_excluded.Add (mb, FALSE);
return false;
}
foreach (ConditionalAttribute a in attrs) {
if (RootContext.AllDefines.Contains (a.ConditionString)) {
analyzed_method_excluded.Add (mb, FALSE);
return false;
}
}
analyzed_method_excluded.Add (mb, TRUE);
return true;
Report.Warning_T (618, loc, member, oa.Message);
}
}
}
-3
View File
@@ -128,9 +128,6 @@ namespace Mono.CSharp {
if (other is SByteConstant || other is ShortConstant || ic != null){
left = left.ToLong (loc);
right = right.ToLong (loc);
} else {
left = left.ToUInt (loc);
right = left.ToUInt (loc);
}
return;
File diff suppressed because it is too large. Load diff
+84 -154
View File
@@ -75,9 +75,9 @@ namespace Mono.CSharp {
//
// Initializes the symbol writer
//
static void InitializeSymbolWriter (string filename)
static void InitializeSymbolWriter ()
{
SymbolWriter = SymbolWriter.GetSymbolWriter (Module.Builder, filename);
SymbolWriter = SymbolWriter.GetSymbolWriter (Module.Builder);
//
// If we got an ISymbolWriter instance, initialize it.
@@ -96,22 +96,6 @@ namespace Mono.CSharp {
{
FileName = output;
AssemblyName an = Assembly.GetAssemblyName (name, output);
if (an.KeyPair != null) {
// If we are going to strong name our assembly make
// sure all its refs are strong named
foreach (Assembly a in TypeManager.GetAssemblies ()) {
AssemblyName ref_name = a.GetName ();
byte [] b = ref_name.GetPublicKeyToken ();
if (b == null || b.Length == 0) {
Report.Warning (1577, "Assembly generation failed " +
"-- Referenced assembly '" +
ref_name.Name +
"' does not have a strong name.");
//Environment.Exit (1);
}
}
}
current_domain = AppDomain.CurrentDomain;
@@ -145,10 +129,10 @@ namespace Mono.CSharp {
// load the default symbol writer.
//
Module.Builder = Assembly.Builder.DefineDynamicModule (
Basename (name), Basename (output), false);
Basename (name), Basename (output), want_debugging_support);
if (want_debugging_support)
InitializeSymbolWriter (output);
InitializeSymbolWriter ();
}
static public void Save (string name)
@@ -168,9 +152,6 @@ namespace Mono.CSharp {
catch (System.IO.IOException io) {
Report.Error (16, "Could not write to file `"+name+"', cause: " + io.Message);
}
if (SymbolWriter != null)
SymbolWriter.WriteSymbolFile ();
}
}
@@ -181,6 +162,7 @@ namespace Mono.CSharp {
// variable mapping.
//
public class VariableStorage {
ILGenerator ig;
FieldBuilder fb;
LocalBuilder local;
@@ -190,18 +172,19 @@ namespace Mono.CSharp {
{
count++;
if (ec.InIterator)
fb = ec.CurrentIterator.MapVariable ("s_", count.ToString (), t);
fb = IteratorHandler.Current.MapVariable ("s_", count.ToString (), t);
else
local = ec.ig.DeclareLocal (t);
ig = ec.ig;
}
public void EmitThis (ILGenerator ig)
public void EmitThis ()
{
if (fb != null)
ig.Emit (OpCodes.Ldarg_0);
}
public void EmitStore (ILGenerator ig)
public void EmitStore ()
{
if (fb == null)
ig.Emit (OpCodes.Stloc, local);
@@ -209,30 +192,22 @@ namespace Mono.CSharp {
ig.Emit (OpCodes.Stfld, fb);
}
public void EmitLoad (ILGenerator ig)
public void EmitLoad ()
{
if (fb == null)
ig.Emit (OpCodes.Ldloc, local);
else
ig.Emit (OpCodes.Ldfld, fb);
}
public void EmitLoadAddress (ILGenerator ig)
{
if (fb == null)
ig.Emit (OpCodes.Ldloca, local);
else
ig.Emit (OpCodes.Ldflda, fb);
}
public void EmitCall (ILGenerator ig, MethodInfo mi)
public void EmitCall (MethodInfo mi)
{
// FIXME : we should handle a call like tostring
// here, where boxing is needed. However, we will
// never encounter that with the current usage.
bool value_type_call;
EmitThis (ig);
EmitThis ();
if (fb == null) {
value_type_call = local.LocalType.IsValueType;
@@ -347,7 +322,7 @@ namespace Mono.CSharp {
public bool InIterator;
public bool IsLastStatement;
/// <summary>
/// Whether remapping of locals, parameters and fields is turned on.
/// Used by iterators and anonymous methods.
@@ -391,14 +366,6 @@ namespace Mono.CSharp {
/// </summary>
public bool InEnumContext;
/// <summary>
/// Trace when method is called and is obsolete then this member suppress message
/// when call is inside next [Obsolete] method or type.
/// </summary>
public bool TestObsoleteMethodUsage = true;
public Iterator CurrentIterator;
FlowBranching current_flow_branching;
public EmitContext (DeclSpace parent, DeclSpace ds, Location l, ILGenerator ig,
@@ -428,7 +395,7 @@ namespace Mono.CSharp {
InUnsafe = (code_flags & Modifiers.UNSAFE) != 0;
}
loc = l;
if (ReturnType == TypeManager.void_type)
ReturnType = null;
}
@@ -477,14 +444,6 @@ namespace Mono.CSharp {
return current_flow_branching;
}
public FlowBranchingException StartFlowBranching (ExceptionStatement stmt)
{
FlowBranchingException branching = new FlowBranchingException (
CurrentBranching, stmt);
current_flow_branching = branching;
return branching;
}
// <summary>
// Ends a code branching. Merges the state of locals and parameters
// from all the children of the ending branching.
@@ -545,7 +504,7 @@ namespace Mono.CSharp {
FlowBranching.Reachability reachability = current_flow_branching.MergeTopBlock ();
current_flow_branching = null;
DoFlowAnalysis = old_do_flow_analysis;
block.Emit (this);
@@ -554,8 +513,7 @@ namespace Mono.CSharp {
reachability.AlwaysThrows ||
reachability.IsUnreachable)
unreachable = true;
}
#if FIXME
}
} catch (Exception e) {
Console.WriteLine ("Exception caught by the compiler while compiling:");
Console.WriteLine (" Block that caused the problem begin at: " + loc);
@@ -568,9 +526,6 @@ namespace Mono.CSharp {
Console.WriteLine (Report.FriendlyStackTrace (e));
Environment.Exit (1);
#else
} finally {
#endif
}
}
@@ -622,15 +577,7 @@ namespace Mono.CSharp {
if (check_file && (CurrentFile != loc.File))
return;
CodeGen.SymbolWriter.MarkSequencePoint (ig, loc.Row, 0);
}
public void DefineLocalVariable (string name, LocalBuilder builder)
{
if (CodeGen.SymbolWriter == null)
return;
CodeGen.SymbolWriter.DefineLocalVariable (name, builder);
ig.MarkSequencePoint (null, loc.Row, 0, 0, 0);
}
/// <summary>
@@ -728,7 +675,7 @@ namespace Mono.CSharp {
public void NeedReturnLabel ()
{
if (!InIterator && !HasReturnLabel) {
if (!HasReturnLabel) {
ReturnLabel = ig.DefineLabel ();
HasReturnLabel = true;
}
@@ -739,8 +686,9 @@ namespace Mono.CSharp {
//
public FieldBuilder MapVariable (string name, Type t)
{
if (InIterator)
return CurrentIterator.MapVariable ("v_", name, t);
if (InIterator){
return IteratorHandler.Current.MapVariable ("v_", name, t);
}
throw new Exception ("MapVariable for an unknown state");
}
@@ -765,14 +713,14 @@ namespace Mono.CSharp {
public Expression RemapParameter (int idx)
{
FieldExpr fe = new FieldExprNoAddress (CurrentIterator.parameter_fields [idx].FieldBuilder, loc);
FieldExpr fe = new FieldExprNoAddress (IteratorHandler.Current.parameter_fields [idx], loc);
fe.InstanceExpression = new ProxyInstance ();
return fe.DoResolve (this);
}
public Expression RemapParameterLValue (int idx, Expression right_side)
{
FieldExpr fe = new FieldExprNoAddress (CurrentIterator.parameter_fields [idx].FieldBuilder, loc);
FieldExpr fe = new FieldExprNoAddress (IteratorHandler.Current.parameter_fields [idx], loc);
fe.InstanceExpression = new ProxyInstance ();
return fe.DoResolveLValue (this, right_side);
}
@@ -783,14 +731,17 @@ namespace Mono.CSharp {
//
public void EmitThis ()
{
ig.Emit (OpCodes.Ldarg_0);
if (InIterator && !IsStatic){
FieldBuilder this_field = CurrentIterator.this_field.FieldBuilder;
if (TypeManager.IsValueType (this_field.FieldType))
ig.Emit (OpCodes.Ldflda, this_field);
else
ig.Emit (OpCodes.Ldfld, this_field);
}
if (InIterator){
ig.Emit (OpCodes.Ldarg_0);
if (!IsStatic){
FieldBuilder this_field = IteratorHandler.Current.this_field;
if (TypeManager.IsValueType (this_field.FieldType))
ig.Emit (OpCodes.Ldflda, this_field);
else
ig.Emit (OpCodes.Ldfld, this_field);
}
} else
ig.Emit (OpCodes.Ldarg_0);
}
public Expression GetThis (Location loc)
@@ -810,6 +761,8 @@ namespace Mono.CSharp {
public abstract class CommonAssemblyModulClass: Attributable {
static string[] attribute_targets = new string [] { "assembly", "module" };
protected CommonAssemblyModulClass ():
base (null)
{
@@ -822,7 +775,7 @@ namespace Mono.CSharp {
return;
}
OptAttributes.AddAttributes (attrs);
OptAttributes.CheckTargets (this);
OptAttributes.CheckTargets (ValidAttributeTargets);
}
public virtual void Emit (TypeContainer tc)
@@ -833,29 +786,33 @@ namespace Mono.CSharp {
EmitContext ec = new EmitContext (tc, Mono.CSharp.Location.Null, null, null, 0, false);
OptAttributes.Emit (ec, this);
}
protected Attribute GetClsCompliantAttribute ()
{
if (OptAttributes == null)
return null;
EmitContext temp_ec = new EmitContext (new RootTypes (), Mono.CSharp.Location.Null, null, null, 0, false);
EmitContext temp_ec = new EmitContext (new TypeContainer (), Mono.CSharp.Location.Null, null, null, 0, false);
Attribute a = OptAttributes.Search (TypeManager.cls_compliant_attribute_type, temp_ec);
if (a != null) {
a.Resolve (temp_ec);
}
return a;
}
}
protected override string[] ValidAttributeTargets {
get {
return attribute_targets;
}
}
}
public class AssemblyClass: CommonAssemblyModulClass {
// TODO: make it private and move all builder based methods here
public AssemblyBuilder Builder;
bool is_cls_compliant;
static string[] attribute_targets = new string [] { "assembly" };
public AssemblyClass (): base ()
{
is_cls_compliant = false;
@@ -865,7 +822,7 @@ namespace Mono.CSharp {
get {
return is_cls_compliant;
}
}
}
public override AttributeTargets AttributeTargets {
get {
@@ -887,53 +844,22 @@ namespace Mono.CSharp {
is_cls_compliant = a.GetClsCompliantAttributeValue (null);
}
// fix bug #56621
private void SetPublicKey (AssemblyName an, byte[] strongNameBlob)
{
try {
// check for possible ECMA key
if (strongNameBlob.Length == 16) {
// will be rejected if not "the" ECMA key
an.SetPublicKey (strongNameBlob);
}
else {
// take it, with or without, a private key
RSA rsa = CryptoConvert.FromCapiKeyBlob (strongNameBlob);
// and make sure we only feed the public part to Sys.Ref
byte[] publickey = CryptoConvert.ToCapiPublicKeyBlob (rsa);
// AssemblyName.SetPublicKey requires an additional header
byte[] publicKeyHeader = new byte [12] { 0x00, 0x24, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00 };
byte[] encodedPublicKey = new byte [12 + publickey.Length];
Buffer.BlockCopy (publicKeyHeader, 0, encodedPublicKey, 0, 12);
Buffer.BlockCopy (publickey, 0, encodedPublicKey, 12, publickey.Length);
an.SetPublicKey (encodedPublicKey);
}
}
catch (Exception) {
Report.Error (1548, "Could not strongname the assembly. File `" +
RootContext.StrongNameKeyFile + "' incorrectly encoded.");
Environment.Exit (1);
}
}
public AssemblyName GetAssemblyName (string name, string output)
{
if (OptAttributes != null) {
foreach (Attribute a in OptAttributes.Attrs) {
if (a.Target != AttributeTargets.Assembly)
foreach (Attribute a in OptAttributes.Attrs) {
if (a.Target != "assembly")
continue;
// TODO: This code is buggy: comparing Attribute name without resolving it is wrong.
// However, this is invoked by CodeGen.Init, at which time none of the namespaces
// are loaded yet.
// TODO: This code is buggy: comparing Attribute name without resolving it is wrong.
// However, this is invoked by CodeGen.Init, at which time none of the namespaces
// are loaded yet.
switch (a.Name) {
case "AssemblyKeyFile":
case "AssemblyKeyFileAttribute":
case "System.Reflection.AssemblyKeyFileAttribute":
case "AssemblyKeyFileAttribute":
case "System.Reflection.AssemblyKeyFileAttribute":
if (RootContext.StrongNameKeyFile != null) {
Report.SymbolRelatedToPreviousError (a.Location, a.Name);
Report.Warning (1616, "Compiler option '{0}' overrides '{1}' given in source", "keyfile", "System.Reflection.AssemblyKeyFileAttribute");
Report.Warning (1616, "Compiler option -keyfile overrides " +
"AssemblyKeyFileAttribute");
}
else {
string value = a.GetString ();
@@ -942,11 +868,11 @@ namespace Mono.CSharp {
}
break;
case "AssemblyKeyName":
case "AssemblyKeyNameAttribute":
case "System.Reflection.AssemblyKeyNameAttribute":
case "AssemblyKeyNameAttribute":
case "System.Reflection.AssemblyKeyNameAttribute":
if (RootContext.StrongNameKeyContainer != null) {
Report.SymbolRelatedToPreviousError (a.Location, a.Name);
Report.Warning (1616, "keycontainer", "Compiler option '{0}' overrides '{1}' given in source", "System.Reflection.AssemblyKeyNameAttribute");
Report.Warning (1616, "Compiler option -keycontainer overrides " +
"AssemblyKeyNameAttribute");
}
else {
string value = a.GetString ();
@@ -955,8 +881,8 @@ namespace Mono.CSharp {
}
break;
case "AssemblyDelaySign":
case "AssemblyDelaySignAttribute":
case "System.Reflection.AssemblyDelaySignAttribute":
case "AssemblyDelaySignAttribute":
case "System.Reflection.AssemblyDelaySignAttribute":
RootContext.StrongNameDelaySign = a.GetBoolean ();
break;
}
@@ -998,7 +924,25 @@ namespace Mono.CSharp {
if (RootContext.StrongNameDelaySign) {
// delayed signing - DO NOT include private key
SetPublicKey (an, snkeypair);
try {
// check for possible ECMA key
if (snkeypair.Length == 16) {
// will be rejected if not "the" ECMA key
an.KeyPair = new StrongNameKeyPair (snkeypair);
}
else {
// take it, with or without, a private key
RSA rsa = CryptoConvert.FromCapiKeyBlob (snkeypair);
// and make sure we only feed the public part to Sys.Ref
byte[] publickey = CryptoConvert.ToCapiPublicKeyBlob (rsa);
an.KeyPair = new StrongNameKeyPair (publickey);
}
}
catch (Exception) {
Report.Error (1548, "Could not strongname the assembly. File `" +
RootContext.StrongNameKeyFile + "' incorrectly encoded.");
Environment.Exit (1);
}
}
else {
// no delay so we make sure we have the private key
@@ -1034,12 +978,6 @@ namespace Mono.CSharp {
{
Builder.SetCustomAttribute (customBuilder);
}
public override string[] ValidAttributeTargets {
get {
return attribute_targets;
}
}
}
public class ModuleClass: CommonAssemblyModulClass {
@@ -1047,8 +985,6 @@ namespace Mono.CSharp {
public ModuleBuilder Builder;
bool m_module_is_unsafe;
static string[] attribute_targets = new string [] { "module" };
public ModuleClass (bool is_unsafe)
{
m_module_is_unsafe = is_unsafe;
@@ -1063,7 +999,7 @@ namespace Mono.CSharp {
public override bool IsClsCompliaceRequired(DeclSpace ds)
{
return CodeGen.Assembly.IsClsCompliant;
}
}
public override void Emit (TypeContainer tc)
{
@@ -1083,17 +1019,11 @@ namespace Mono.CSharp {
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder customBuilder)
{
if (a != null && a.Type == TypeManager.cls_compliant_attribute_type) {
Report.Warning (3012, a.Location, "You must specify the CLSCompliant attribute on the assembly, not the module, to enable CLS compliance checking");
Report.Warning_T (3012, a.Location);
return;
}
Builder.SetCustomAttribute (customBuilder);
}
public override string[] ValidAttributeTargets {
get {
return attribute_targets;
}
}
}
}
+258
View File
@@ -0,0 +1,258 @@
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{896D1461-B76B-41C0-ABE6-ACA2BB4F7B5A}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "mcs"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Exe"
PreBuildEvent = ""
PostBuildEvent = ""
RootNamespace = "CIR"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = ".\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE"
DocumentationFile = ""
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "true"
NoStdLib = "false"
NoWarn = ""
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "anonymous.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "AssemblyInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "assign.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "attribute.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "cfold.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "class.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "codegen.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "const.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "constant.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "convert.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "CryptoConvert.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "cs-parser.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "cs-tokenizer.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "decl.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "delegate.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "driver.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "ecore.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "enum.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "expression.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "flowanalysis.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "genericparser.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "iterators.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "literal.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "location.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "modifiers.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "namespace.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "parameter.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "pending.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "report.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "rootcontext.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "statement.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "support.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "symbolwriter.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "tree.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "typemanager.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<Folder
RelPath = "Web References\"
WebReferences = "TRUE"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>
+114
View File
@@ -0,0 +1,114 @@
Compiler operation
The compiler has a number of phases:
* Parsing.
Initially the compiler parses all the source files and keeps a
parsed representation in memory. Very syntax error checking
is performed at this point.
The compiler stores the information in classes whose names
represent the language construct, for example, the "if"
construct is stored in an `If' class. A class is stored in a
`Class'.
* The TypeManager
The TypeManager loads all the assemblies that were referenced
by the programmer. The CLR type system is used as our
repository for types defined as well.
So the same interface that is used to query the types,
properties and flags about system types is the same interface
that we use for our types.
As we work our way through the code generation and semantic
analysis, new types are entered into the Type system through
the use of System.Reflection.Emit. The TypeManager will
lookup types on both the user defined types and on the system
defined ones.
So special care has to be used. The order in which we
proceeed from here is important.
* Base class resolution and type definition.
Once the parsing has happened, the compiler resolves the
inheritance tree for interfaces. This is done recursively
and we catch recursive interface definitions here.
After this is done, we continue on with classes. Classes have
can have an optional "parent" inherit from or the implicit
System.Object class (for normal builds, builds with /nostdlib
will allow you to compile class System.Object with no parent).
At this point we do some error checking and verify that the
inherits/implements section of a class is correct (since we
have previously built the interface inheritance).
By the time we are done, all classes, structs and interfaces
have been created using System.Reflection.Emit and registered
with the Type Manager.
This allows us to define fields and resolve argument names for
methods, properties, indexers and events.
* Field generation
Fields are generated next, we go through all the type
containers (classes and structs) and enter the fields into
their types.
* Method, Properties, Indexers and events definitions
Now all the methods, constructors, properties, indexers and
events are entered. They are only `defined' using
System.Reflection.Emit. No code generation will happen until
everything has been entered into System.Reflection.Emit.
This is important because to actually generate code we need to
know everything about the environment in which the code is
being generated.
* Code Generation
At this point all the definitions have been entered into the
type manager through System.Reflection.Emit. We can now use
System.Reflection to query all the information about the
types.
Your normal semantic analysis and code generation phase lives
here.
* Statements
Most of the statements are handled in the codegen.cs file.
* Expressions
* Error reporting
We should try to use the `Report.Error' and `Report.Warning'
classes which are part of the RootContext (there is even a
property to access it).
Error reporting should try to use the same codes that the
Microsoft compiler uses (if only so we can track which errors
we handle and which ones we dont).
If there is an error which is specific to MSC, use negative
numbers, and register the number in mcs/errors/errors.txt
Try to write a test case for any error that you run into the
code of the compiler if there is none already.
Put your test case in a file called csNNNN.cs in the
mcs/errors directory, and have the first two lines be:
// csNNNN.cs: This is the description.
// Line: XXX
Where `XXX' is the line where the error ocurrs. We will later
use this as a regression test suite for catching errors in the
compiler.
+21
View File
@@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "compiler", "compiler.csproj", "{896D1461-B76B-41C0-ABE6-ACA2BB4F7B5A}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{896D1461-B76B-41C0-ABE6-ACA2BB4F7B5A}.Debug.ActiveCfg = Debug|.NET
{896D1461-B76B-41C0-ABE6-ACA2BB4F7B5A}.Debug.Build.0 = Debug|.NET
{896D1461-B76B-41C0-ABE6-ACA2BB4F7B5A}.Release.ActiveCfg = Release|.NET
{896D1461-B76B-41C0-ABE6-ACA2BB4F7B5A}.Release.Build.0 = Release|.NET
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal
+41 -19
View File
@@ -24,12 +24,13 @@ namespace Mono.CSharp {
using System.Reflection.Emit;
using System.Collections;
public class Const : FieldMember {
public class Const : FieldBase {
public Expression Expr;
EmitContext const_ec;
bool resolved = false;
object ConstantValue = null;
Type type;
bool in_transit = false;
@@ -40,13 +41,11 @@ namespace Mono.CSharp {
Modifiers.INTERNAL |
Modifiers.PRIVATE;
public Const (TypeContainer parent, Expression constant_type, string name,
Expression expr, int mod_flags, Attributes attrs, Location loc)
: base (parent, constant_type, mod_flags, AllowedModifiers,
new MemberName (name), null, attrs, loc)
public Const (Expression constant_type, string name, Expression expr, int mod_flags,
Attributes attrs, Location loc)
: base (constant_type, mod_flags, AllowedModifiers, name, null, attrs, loc)
{
Expr = expr;
ModFlags |= Modifiers.STATIC;
}
public FieldAttributes FieldAttr {
@@ -71,14 +70,16 @@ namespace Mono.CSharp {
/// <summary>
/// Defines the constant in the @parent
/// </summary>
public override bool Define ()
public override bool Define (TypeContainer parent)
{
if (!base.Define ())
type = parent.ResolveType (Type, false, Location);
if (type == null)
return false;
const_ec = new EmitContext (Parent, Location, null, MemberType, ModFlags);
const_ec = new EmitContext (parent, Location, null, type, ModFlags);
Type ttype = MemberType;
Type ttype = type;
while (ttype.IsArray)
ttype = TypeManager.GetElementType (ttype);
@@ -90,7 +91,21 @@ namespace Mono.CSharp {
return false;
}
FieldBuilder = Parent.TypeBuilder.DefineField (Name, MemberType, FieldAttr);
Type ptype = parent.TypeBuilder.BaseType;
if (ptype != null) {
MemberList list = TypeContainer.FindMembers (
ptype, MemberTypes.Field, BindingFlags.Public,
System.Type.FilterName, Name);
if (list.Count == 0)
if ((ModFlags & Modifiers.NEW) != 0)
WarningNotHiding (parent);
} else if ((ModFlags & Modifiers.NEW) != 0)
WarningNotHiding (parent);
FieldBuilder = parent.TypeBuilder.DefineField (Name, type, FieldAttr);
TypeManager.RegisterConstant (FieldBuilder, this);
@@ -217,8 +232,15 @@ namespace Mono.CSharp {
Expr = ch_expr.Expr;
else if ((ec_expr != null) && (ec_expr.Child is Constant))
Expr = ec_expr.Child;
else if (Expr is ArrayCreation){
Report.Error (133, Location, "Arrays can not be constant");
else if (Expr is ArrayCreation) {
ArrayCreation ac = (ArrayCreation) Expr;
Expr = ac.TurnIntoConstant ();
if (Expr == null){
Report.Error (150, Location, "A constant value is expected");
value = null;
return false;
}
} else {
if (errors == Report.Errors)
Report.Error (150, Location, "A constant value is expected");
@@ -229,8 +251,8 @@ namespace Mono.CSharp {
ce = Expr as Constant;
}
if (MemberType != real_expr.Type) {
ce = ChangeType (Location, ce, MemberType);
if (type != real_expr.Type) {
ce = ChangeType (Location, ce, type);
if (ce == null){
value = null;
return false;
@@ -239,13 +261,13 @@ namespace Mono.CSharp {
}
ConstantValue = ce.GetValue ();
if (MemberType.IsEnum){
if (type.IsEnum){
//
// This sadly does not work for our user-defined enumerations types ;-(
//
try {
ConstantValue = System.Enum.ToObject (
MemberType, ConstantValue);
type, ConstantValue);
} catch (ArgumentException){
Report.Error (
-16, Location,
@@ -268,7 +290,7 @@ namespace Mono.CSharp {
/// <summary>
/// Emits the field value by evaluating the expression
/// </summary>
public override void Emit ()
public override void Emit (TypeContainer parent)
{
object value;
LookupConstantValue (out value);
@@ -277,7 +299,7 @@ namespace Mono.CSharp {
OptAttributes.Emit (const_ec, this);
}
base.Emit ();
base.Emit (parent);
}
}
}
@@ -147,10 +147,6 @@ namespace Mono.CSharp {
return null;
}
public abstract bool IsNegative {
get;
}
//
// Returns true iff 1) the stack type of this is one of Object,
// int32, int64 and 2) this == 0 or this == null.
@@ -190,12 +186,6 @@ namespace Mono.CSharp {
ec.ig.Emit (OpCodes.Ldc_I4_0);
}
public override bool IsNegative {
get {
return false;
}
}
public override bool IsZeroInteger {
get { return Value == false; }
}
@@ -256,12 +246,6 @@ namespace Mono.CSharp {
return new IntConstant (Value);
}
public override bool IsNegative {
get {
return false;
}
}
public override bool IsZeroInteger {
get { return Value == 0; }
}
@@ -351,12 +335,6 @@ namespace Mono.CSharp {
return new IntConstant (Value);
}
public override bool IsNegative {
get {
return false;
}
}
public override bool IsZeroInteger {
get { return Value == '\0'; }
}
@@ -420,12 +398,6 @@ namespace Mono.CSharp {
return new IntConstant (Value);
}
public override bool IsNegative {
get {
return Value < 0;
}
}
public override bool IsZeroInteger {
get { return Value == 0; }
}
@@ -489,12 +461,6 @@ namespace Mono.CSharp {
public override bool IsZeroInteger {
get { return Value == 0; }
}
public override bool IsNegative {
get {
return Value < 0;
}
}
}
public class UShortConstant : Constant {
@@ -552,12 +518,6 @@ namespace Mono.CSharp {
return new IntConstant (Value);
}
public override bool IsNegative {
get {
return false;
}
}
public override bool IsZeroInteger {
get { return Value == 0; }
}
@@ -676,12 +636,6 @@ namespace Mono.CSharp {
return this;
}
public override bool IsNegative {
get {
return Value < 0;
}
}
public override bool IsZeroInteger {
get { return Value == 0; }
}
@@ -742,12 +696,6 @@ namespace Mono.CSharp {
return null;
}
public override bool IsNegative {
get {
return false;
}
}
public override bool IsZeroInteger {
get { return Value == 0; }
}
@@ -823,12 +771,6 @@ namespace Mono.CSharp {
return null;
}
public override bool IsNegative {
get {
return Value < 0;
}
}
public override bool IsZeroInteger {
get { return Value == 0; }
}
@@ -891,12 +833,6 @@ namespace Mono.CSharp {
return null;
}
public override bool IsNegative {
get {
return false;
}
}
public override bool IsZeroInteger {
get { return Value == 0; }
}
@@ -951,12 +887,6 @@ namespace Mono.CSharp {
{
return null;
}
public override bool IsNegative {
get {
return Value < 0;
}
}
}
public class DoubleConstant : Constant {
@@ -1013,12 +943,6 @@ namespace Mono.CSharp {
{
return null;
}
public override bool IsNegative {
get {
return Value < 0;
}
}
}
public class DecimalConstant : Constant {
@@ -1064,12 +988,6 @@ namespace Mono.CSharp {
ig.Emit (OpCodes.Newobj, TypeManager.void_decimal_ctor_five_args);
}
public override bool IsNegative {
get {
return Value < 0;
}
}
}
public class StringConstant : Constant {
@@ -1100,12 +1018,6 @@ namespace Mono.CSharp {
else
ec.ig.Emit (OpCodes.Ldstr, Value);
}
public override bool IsNegative {
get {
return false;
}
}
}
}
+147 -281
View File
@@ -19,109 +19,13 @@ namespace Mono.CSharp {
// A container class for all the conversion operations
//
public class Convert {
static void Error_CannotConvertType (Location loc, Type source, Type target)
static public void Error_CannotConvertType (Location loc, Type source, Type target)
{
Report.Error (30, loc, "Cannot convert type '" +
TypeManager.CSharpName (source) + "' to '" +
TypeManager.CSharpName (target) + "'");
}
static Expression TypeParameter_to_Null (Expression expr, Type target_type,
Location loc)
{
if (!TypeParameter_to_Null (target_type)) {
Report.Error (403, loc, "Cannot convert null to the type " +
"parameter `{0}' becaues it could be a value " +
"type. Consider using `default ({0})' instead.",
target_type);
return null;
}
return new NullCast (expr, target_type);
}
static bool TypeParameter_to_Null (Type target_type)
{
if ((target_type.BaseType == null) ||
(target_type.BaseType == TypeManager.value_type) ||
target_type.BaseType.IsValueType)
return false;
return true;
}
static Type TypeParam_EffectiveBaseType (Type t)
{
GenericConstraints gc = TypeManager.GetTypeParameterConstraints (t);
if (gc == null)
return TypeManager.object_type;
return TypeParam_EffectiveBaseType (gc);
}
static Type TypeParam_EffectiveBaseType (GenericConstraints gc)
{
ArrayList list = new ArrayList ();
list.Add (gc.EffectiveBaseClass);
foreach (Type t in gc.InterfaceConstraints) {
if (!t.IsGenericParameter)
continue;
GenericConstraints new_gc = TypeManager.GetTypeParameterConstraints (t);
if (new_gc != null)
list.Add (TypeParam_EffectiveBaseType (new_gc));
}
return FindMostEncompassedType (list);
}
static Expression TypeParameterConversion (Expression expr, bool is_reference, Type target_type)
{
if (is_reference)
return new EmptyCast (expr, target_type);
else
return new BoxedCast (expr, target_type);
}
static Expression ImplicitTypeParameterConversion (Expression expr, Type target_type)
{
Type expr_type = expr.Type;
GenericConstraints gc = TypeManager.GetTypeParameterConstraints (expr_type);
if (gc == null) {
if (target_type == TypeManager.object_type)
return new BoxedCast (expr);
return null;
}
// We're converting from a type parameter which is known to be a reference type.
bool is_reference = gc.IsReferenceType;
Type base_type = TypeParam_EffectiveBaseType (gc);
if (TypeManager.IsSubclassOf (base_type, target_type))
return TypeParameterConversion (expr, is_reference, target_type);
if (target_type.IsInterface) {
if (TypeManager.ImplementsInterface (base_type, target_type))
return TypeParameterConversion (expr, is_reference, target_type);
foreach (Type t in gc.InterfaceConstraints) {
if (TypeManager.IsSubclassOf (t, target_type))
return TypeParameterConversion (expr, is_reference, target_type);
}
}
foreach (Type t in gc.InterfaceConstraints) {
if (!t.IsGenericParameter)
continue;
if (TypeManager.IsSubclassOf (t, target_type))
return TypeParameterConversion (expr, is_reference, target_type);
}
return null;
}
static EmptyExpression MyEmptyExpr;
static public Expression ImplicitReferenceConversion (Expression expr, Type target_type)
{
@@ -135,10 +39,7 @@ namespace Mono.CSharp {
if (expr_type == TypeManager.void_type)
return null;
if (expr_type.IsGenericParameter)
return ImplicitTypeParameterConversion (expr, target_type);
//
// notice that it is possible to write "ValueType v = 1", the ValueType here
// is an abstract class, and not really a value type, so we apply the same rules.
@@ -150,111 +51,112 @@ namespace Mono.CSharp {
if (expr_type.IsPointer)
return null;
if (TypeManager.IsValueType (expr_type))
if (expr_type.IsValueType)
return new BoxedCast (expr);
if (expr_type.IsClass || expr_type.IsInterface || expr_type == TypeManager.enum_type)
return new EmptyCast (expr, target_type);
return null;
} else if (target_type == TypeManager.value_type) {
if (TypeManager.IsValueType (expr_type))
if (expr_type.IsValueType)
return new BoxedCast (expr);
if (expr is NullLiteral)
return new NullCast (expr, target_type);
return null;
} else if (TypeManager.IsSubclassOf (expr_type, target_type)) {
} else if (expr_type.IsSubclassOf (target_type)) {
//
// Special case: enumeration to System.Enum.
// System.Enum is not a value type, it is a class, so we need
// a boxing conversion
//
if (expr_type.IsEnum || expr_type.IsGenericParameter)
if (expr_type.IsEnum)
return new BoxedCast (expr);
return new EmptyCast (expr, target_type);
}
} else {
// This code is kind of mirrored inside ImplicitStandardConversionExists
// with the small distinction that we only probe there
//
// Always ensure that the code here and there is in sync
// This code is kind of mirrored inside ImplicitStandardConversionExists
// with the small distinction that we only probe there
//
// Always ensure that the code here and there is in sync
// from the null type to any reference-type.
if (expr is NullLiteral){
if (target_type.IsPointer)
return NullPointer.Null;
// from the null type to any reference-type.
if (expr is NullLiteral){
if (target_type.IsPointer)
return NullPointer.Null;
if (!target_type.IsValueType)
return new NullCast (expr, target_type);
}
// from any class-type S to any interface-type T.
if (target_type.IsInterface) {
if (target_type != TypeManager.iconvertible_type &&
expr_type.IsValueType && (expr is Constant) &&
!(expr is IntLiteral || expr is BoolLiteral ||
expr is FloatLiteral || expr is DoubleLiteral ||
expr is LongLiteral || expr is CharLiteral ||
expr is StringLiteral || expr is DecimalLiteral ||
expr is UIntLiteral || expr is ULongLiteral)) {
return null;
if (!target_type.IsValueType)
return new NullCast (expr, target_type);
}
if (TypeManager.ImplementsInterface (expr_type, target_type)){
if (expr_type.IsGenericParameter || TypeManager.IsValueType (expr_type))
return new BoxedCast (expr, target_type);
else
return new EmptyCast (expr, target_type);
}
}
// from any class-type S to any interface-type T.
if (target_type.IsInterface) {
if (target_type != TypeManager.iconvertible_type &&
expr_type.IsValueType && (expr is Constant) &&
!(expr is IntLiteral || expr is BoolLiteral ||
expr is FloatLiteral || expr is DoubleLiteral ||
expr is LongLiteral || expr is CharLiteral ||
expr is StringLiteral || expr is DecimalLiteral ||
expr is UIntLiteral || expr is ULongLiteral)) {
return null;
}
// from any interface type S to interface-type T.
if (expr_type.IsInterface && target_type.IsInterface) {
if (TypeManager.ImplementsInterface (expr_type, target_type))
return new EmptyCast (expr, target_type);
else
return null;
}
// from an array-type S to an array-type of type T
if (expr_type.IsArray && target_type.IsArray) {
if (expr_type.GetArrayRank () == target_type.GetArrayRank ()) {
Type expr_element_type = TypeManager.GetElementType (expr_type);
if (MyEmptyExpr == null)
MyEmptyExpr = new EmptyExpression ();
MyEmptyExpr.SetType (expr_element_type);
Type target_element_type = TypeManager.GetElementType (target_type);
if (!expr_element_type.IsValueType && !target_element_type.IsValueType)
if (ImplicitStandardConversionExists (MyEmptyExpr,
target_element_type))
if (TypeManager.ImplementsInterface (expr_type, target_type)){
if (expr_type.IsClass)
return new EmptyCast (expr, target_type);
else if (expr_type.IsValueType)
return new BoxedCast (expr, target_type);
else
return new EmptyCast (expr, target_type);
}
}
// from any interface type S to interface-type T.
if (expr_type.IsInterface && target_type.IsInterface) {
if (TypeManager.ImplementsInterface (expr_type, target_type))
return new EmptyCast (expr, target_type);
else
return null;
}
}
// from an array-type to System.Array
if (expr_type.IsArray && target_type == TypeManager.array_type)
return new EmptyCast (expr, target_type);
// from an array-type S to an array-type of type T
if (expr_type.IsArray && target_type.IsArray) {
if (expr_type.GetArrayRank () == target_type.GetArrayRank ()) {
Type expr_element_type = TypeManager.GetElementType (expr_type);
if (MyEmptyExpr == null)
MyEmptyExpr = new EmptyExpression ();
MyEmptyExpr.SetType (expr_element_type);
Type target_element_type = TypeManager.GetElementType (target_type);
if (!expr_element_type.IsValueType && !target_element_type.IsValueType)
if (ImplicitStandardConversionExists (MyEmptyExpr,
target_element_type))
return new EmptyCast (expr, target_type);
}
}
// from any delegate type to System.Delegate
if ((expr_type == TypeManager.delegate_type || TypeManager.IsDelegateType (expr_type)) &&
target_type == TypeManager.delegate_type)
return new EmptyCast (expr, target_type);
// from any array-type or delegate type into System.ICloneable.
if (expr_type.IsArray ||
expr_type == TypeManager.delegate_type || TypeManager.IsDelegateType (expr_type))
if (target_type == TypeManager.icloneable_type)
// from an array-type to System.Array
if (expr_type.IsArray && target_type == TypeManager.array_type)
return new EmptyCast (expr, target_type);
// from any delegate type to System.Delegate
if ((expr_type == TypeManager.delegate_type ||
expr_type.IsSubclassOf (TypeManager.delegate_type)) &&
target_type == TypeManager.delegate_type)
return new EmptyCast (expr, target_type);
// from any array-type or delegate type into System.ICloneable.
if (expr_type.IsArray ||
expr_type == TypeManager.delegate_type ||
expr_type.IsSubclassOf (TypeManager.delegate_type))
if (target_type == TypeManager.icloneable_type)
return new EmptyCast (expr, target_type);
return null;
// from a generic type definition to a generic instance.
if (TypeManager.IsEqual (expr_type, target_type))
return new EmptyCast (expr, target_type);
}
return null;
}
@@ -266,78 +168,73 @@ namespace Mono.CSharp {
{
Type expr_type = expr.Type;
if (expr_type.IsGenericParameter)
return ImplicitTypeParameterConversion (expr, target_type) != null;
//
// This is the boxed case.
//
if (target_type == TypeManager.object_type) {
if (expr_type.IsClass || TypeManager.IsValueType (expr_type) ||
if (expr_type.IsClass || expr_type.IsValueType ||
expr_type.IsInterface || expr_type == TypeManager.enum_type)
return true;
return false;
} else if (TypeManager.IsSubclassOf (expr_type, target_type))
} else if (expr_type.IsSubclassOf (target_type))
return true;
// Please remember that all code below actually comes
// from ImplicitReferenceConversion so make sure code remains in sync
else {
// Please remember that all code below actually comes
// from ImplicitReferenceConversion so make sure code remains in sync
// from any class-type S to any interface-type T.
if (target_type.IsInterface) {
if (TypeManager.ImplementsInterface (expr_type, target_type))
return true;
}
// from any interface type S to interface-type T.
if (expr_type.IsInterface && target_type.IsInterface)
if (TypeManager.ImplementsInterface (expr_type, target_type))
return true;
// from an array-type S to an array-type of type T
if (expr_type.IsArray && target_type.IsArray) {
if (expr_type.GetArrayRank () == target_type.GetArrayRank ()) {
Type expr_element_type = expr_type.GetElementType ();
if (MyEmptyExpr == null)
MyEmptyExpr = new EmptyExpression ();
MyEmptyExpr.SetType (expr_element_type);
Type target_element_type = TypeManager.GetElementType (target_type);
if (!expr_element_type.IsValueType && !target_element_type.IsValueType)
if (ImplicitStandardConversionExists (MyEmptyExpr,
target_element_type))
return true;
// from any class-type S to any interface-type T.
if (target_type.IsInterface) {
if (TypeManager.ImplementsInterface (expr_type, target_type))
return true;
}
}
// from an array-type to System.Array
if (expr_type.IsArray && (target_type == TypeManager.array_type))
return true;
// from any interface type S to interface-type T.
if (expr_type.IsInterface && target_type.IsInterface)
if (TypeManager.ImplementsInterface (expr_type, target_type))
return true;
// from any delegate type to System.Delegate
if ((expr_type == TypeManager.delegate_type || TypeManager.IsDelegateType (expr_type)) &&
target_type == TypeManager.delegate_type)
if (target_type.IsAssignableFrom (expr_type))
// from an array-type S to an array-type of type T
if (expr_type.IsArray && target_type.IsArray) {
if (expr_type.GetArrayRank () == target_type.GetArrayRank ()) {
Type expr_element_type = expr_type.GetElementType ();
if (MyEmptyExpr == null)
MyEmptyExpr = new EmptyExpression ();
MyEmptyExpr.SetType (expr_element_type);
Type target_element_type = TypeManager.GetElementType (target_type);
if (!expr_element_type.IsValueType && !target_element_type.IsValueType)
if (ImplicitStandardConversionExists (MyEmptyExpr,
target_element_type))
return true;
}
}
// from an array-type to System.Array
if (expr_type.IsArray && (target_type == TypeManager.array_type))
return true;
// from any delegate type to System.Delegate
if ((expr_type == TypeManager.delegate_type ||
expr_type.IsSubclassOf (TypeManager.delegate_type)) &&
target_type == TypeManager.delegate_type)
if (target_type.IsAssignableFrom (expr_type))
return true;
// from any array-type or delegate type into System.ICloneable.
if (expr_type.IsArray ||
expr_type == TypeManager.delegate_type || TypeManager.IsDelegateType (expr_type))
if (target_type == TypeManager.icloneable_type)
// from any array-type or delegate type into System.ICloneable.
if (expr_type.IsArray ||
expr_type == TypeManager.delegate_type ||
expr_type.IsSubclassOf (TypeManager.delegate_type))
if (target_type == TypeManager.icloneable_type)
return true;
// from the null type to any reference-type.
if (expr is NullLiteral && !target_type.IsValueType &&
!TypeManager.IsEnumType (target_type))
return true;
// from the null type to any reference-type.
if (expr is NullLiteral && !target_type.IsValueType && !TypeManager.IsEnumType (target_type))
return true;
// from a generic type definition to a generic instance.
if (TypeManager.IsEqual (expr_type, target_type))
return true;
}
return false;
}
@@ -514,9 +411,6 @@ namespace Mono.CSharp {
/// </summary>
public static bool ImplicitConversionExists (EmitContext ec, Expression expr, Type target_type)
{
if ((expr is NullLiteral) && target_type.IsGenericParameter)
return TypeParameter_to_Null (target_type);
if (ImplicitStandardConversionExists (expr, target_type))
return true;
@@ -546,9 +440,7 @@ namespace Mono.CSharp {
if (expr_type == TypeManager.void_type)
return false;
//Console.WriteLine ("Expr is {0}", expr);
//Console.WriteLine ("{0} -> {1} ?", expr_type, target_type);
if (expr_type.Equals (target_type))
if (expr_type == target_type)
return true;
// First numeric conversions
@@ -986,7 +878,7 @@ namespace Mono.CSharp {
object r;
if ((look_for_explicit ? explicit_conv : implicit_conv).Lookup (source_type, target_type, out r))
return (MethodGroupExpr) r;
mg1 = Expression.MethodLookup (ec, source_type, op_name, loc);
if (source_type.BaseType != null)
mg2 = Expression.MethodLookup (ec, source_type.BaseType, op_name, loc);
@@ -1150,9 +1042,6 @@ namespace Mono.CSharp {
Type expr_type = expr.Type;
Expression e;
if ((expr is NullLiteral) && target_type.IsGenericParameter)
return TypeParameter_to_Null (expr, target_type, loc);
if (expr.eclass == ExprClass.MethodGroup){
if (!TypeManager.IsDelegateType (target_type)){
Report.Error (428, loc,
@@ -1164,8 +1053,8 @@ namespace Mono.CSharp {
return ImplicitDelegateCreation.Create (ec, (MethodGroupExpr) expr, target_type, loc);
}
if (expr_type.Equals (target_type) && !(expr is NullLiteral))
if (expr_type == target_type && !(expr is NullLiteral))
return expr;
e = ImplicitNumericConversion (ec, expr, target_type, loc);
@@ -1285,11 +1174,8 @@ namespace Mono.CSharp {
Type target_type, Location loc)
{
Expression e;
int errors = Report.Errors;
e = ImplicitConversion (ec, source, target_type, loc);
if (Report.Errors > errors)
return null;
if (e != null)
return e;
@@ -1533,18 +1419,11 @@ namespace Mono.CSharp {
/// </summary>
public static bool ExplicitReferenceConversionExists (Type source_type, Type target_type)
{
bool target_is_type_param = target_type.IsGenericParameter;
bool target_is_value_type = target_type.IsValueType;
if (source_type == target_type)
return true;
//
// From object to a generic parameter
//
if (source_type == TypeManager.object_type && target_is_type_param)
return true;
//
// From object to any reference type
//
@@ -1554,14 +1433,14 @@ namespace Mono.CSharp {
//
// From any class S to any class-type T, provided S is a base class of T
//
if (TypeManager.IsSubclassOf (target_type, source_type))
if (target_type.IsSubclassOf (source_type))
return true;
//
// From any interface type S to any interface T provided S is not derived from T
//
if (source_type.IsInterface && target_type.IsInterface){
if (!TypeManager.IsSubclassOf (target_type, source_type))
if (!target_type.IsSubclassOf (source_type))
return true;
}
@@ -1613,7 +1492,7 @@ namespace Mono.CSharp {
// From System delegate to any delegate-type
//
if (source_type == TypeManager.delegate_type &&
TypeManager.IsDelegateType (target_type))
target_type.IsSubclassOf (TypeManager.delegate_type))
return true;
//
@@ -1633,15 +1512,8 @@ namespace Mono.CSharp {
static Expression ExplicitReferenceConversion (Expression source, Type target_type)
{
Type source_type = source.Type;
bool target_is_type_param = target_type.IsGenericParameter;
bool target_is_value_type = target_type.IsValueType;
//
// From object to a generic parameter
//
if (source_type == TypeManager.object_type && target_is_type_param)
return new UnboxCast (source, target_type);
//
// From object to any reference type
//
@@ -1659,7 +1531,7 @@ namespace Mono.CSharp {
//
// From any class S to any class-type T, provided S is a base class of T
//
if (TypeManager.IsSubclassOf (target_type, source_type))
if (target_type.IsSubclassOf (source_type))
return new ClassCast (source, target_type);
//
@@ -1671,7 +1543,7 @@ namespace Mono.CSharp {
else
return new ClassCast (source, target_type);
}
//
// From any class type S to any interface T, provides S is not sealed
// and provided S does not implement T.
@@ -1730,7 +1602,7 @@ namespace Mono.CSharp {
// From System delegate to any delegate-type
//
if (source_type == TypeManager.delegate_type &&
TypeManager.IsDelegateType (target_type))
target_type.IsSubclassOf (TypeManager.delegate_type))
return new ClassCast (source, target_type);
//
@@ -1776,10 +1648,7 @@ namespace Mono.CSharp {
expr_type = expr.Type;
}
int errors = Report.Errors;
Expression ne = ImplicitConversionStandard (ec, expr, target_type, loc);
if (Report.Errors > errors)
return null;
if (ne != null)
return ne;
@@ -1865,7 +1734,7 @@ namespace Mono.CSharp {
}
}
}
ne = ExplicitUserConversion (ec, expr, target_type, loc);
if (ne != null)
return ne;
@@ -1884,12 +1753,9 @@ namespace Mono.CSharp {
/// Same as ExplicitConversion, only it doesn't include user defined conversions
/// </summary>
static public Expression ExplicitConversionStandard (EmitContext ec, Expression expr,
Type target_type, Location l)
Type target_type, Location l)
{
int errors = Report.Errors;
Expression ne = ImplicitConversionStandard (ec, expr, target_type, l);
if (Report.Errors > errors)
return null;
if (ne != null)
return ne;
File diff suppressed because it is too large. Load diff
@@ -40,8 +40,6 @@ namespace Mono.CSharp
bool handle_get_set = false;
bool handle_remove_add = false;
bool handle_assembly = false;
bool handle_constraints = false;
bool handle_typeof = false;
//
// Whether tokens have been seen on this line
@@ -134,26 +132,6 @@ namespace Mono.CSharp
handle_remove_add = value;
}
}
public bool ConstraintsParsing {
get {
return handle_constraints;
}
set {
handle_constraints = value;
}
}
public bool TypeOfParsing {
get {
return handle_typeof;
}
set {
handle_typeof = value;
}
}
//
// Class variables
@@ -229,7 +207,6 @@ namespace Mono.CSharp
{
keywords = new CharArrayHashtable [64];
AddKeyword ("__arglist", Token.ARGLIST);
AddKeyword ("abstract", Token.ABSTRACT);
AddKeyword ("as", Token.AS);
AddKeyword ("add", Token.ADD);
@@ -311,9 +288,7 @@ namespace Mono.CSharp
AddKeyword ("virtual", Token.VIRTUAL);
AddKeyword ("void", Token.VOID);
AddKeyword ("volatile", Token.VOLATILE);
AddKeyword ("where", Token.WHERE);
AddKeyword ("while", Token.WHILE);
AddKeyword ("partial", Token.PARTIAL);
}
//
@@ -350,9 +325,6 @@ namespace Mono.CSharp
return -1;
if (handle_assembly == false && res == Token.ASSEMBLY)
return -1;
if (handle_constraints == false && res == Token.WHERE)
return -1;
return res;
}
@@ -406,92 +378,22 @@ namespace Mono.CSharp
static bool is_identifier_part_character (char c)
{
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (c >= '0' && c <= '9') || Char.IsLetter (c);
}
public static bool IsValidIdentifier (string s)
{
if (s == null || s.Length == 0)
return false;
if (!is_identifier_start_character (s [0]))
return false;
for (int i = 1; i < s.Length; i ++)
if (! is_identifier_part_character (s [i]))
return false;
return true;
}
public static bool IsValidIdentifier (string s)
{
if (s == null || s.Length == 0)
return false;
if (!is_identifier_start_character (s [0]))
return false;
for (int i = 1; i < s.Length; i ++)
if (! is_identifier_part_character (s [i]))
return false;
return true;
}
bool parse_generic_dimension (out int dimension)
{
dimension = 1;
again:
int the_token = token ();
if (the_token == Token.OP_GENERICS_GT)
return true;
else if (the_token == Token.COMMA) {
dimension++;
goto again;
}
return false;
}
bool parse_less_than ()
{
start:
int the_token = token ();
switch (the_token) {
case Token.IDENTIFIER:
case Token.OBJECT:
case Token.STRING:
case Token.BOOL:
case Token.DECIMAL:
case Token.FLOAT:
case Token.DOUBLE:
case Token.SBYTE:
case Token.BYTE:
case Token.SHORT:
case Token.USHORT:
case Token.INT:
case Token.UINT:
case Token.LONG:
case Token.ULONG:
case Token.CHAR:
case Token.VOID:
break;
default:
return false;
}
again:
the_token = token ();
if (the_token == Token.OP_GENERICS_GT)
return true;
else if ((the_token == Token.COMMA) || (the_token == Token.DOT))
goto start;
else if (the_token == Token.OP_GENERICS_LT) {
if (!parse_less_than ())
return false;
goto again;
} else if (the_token == Token.OPEN_BRACKET) {
rank_specifiers:
the_token = token ();
if (the_token == Token.CLOSE_BRACKET)
goto again;
else if (the_token == Token.COMMA)
goto rank_specifiers;
return false;
}
return false;
}
bool parsing_less_than = false;
int parsing_generic_less_than = 0;
int is_punct (char c, ref bool doread)
{
@@ -545,71 +447,6 @@ namespace Mono.CSharp
return Token.INTERR;
}
if (c == '<') {
if (parsing_generic_less_than++ > 0)
return Token.OP_GENERICS_LT;
int old = reader.Position;
if (handle_typeof) {
int dimension;
if (parse_generic_dimension (out dimension)) {
val = dimension;
return Token.GENERIC_DIMENSION;
}
reader.Position = old;
putback_char = -1;
}
// Save current position and parse next token.
old = reader.Position;
bool is_generic_lt = parse_less_than ();
reader.Position = old;
putback_char = -1;
if (is_generic_lt) {
parsing_generic_less_than++;
return Token.OP_GENERICS_LT;
} else
parsing_generic_less_than = 0;
d = peekChar ();
if (d == '<'){
getChar ();
d = peekChar ();
if (d == '='){
doread = true;
return Token.OP_SHIFT_LEFT_ASSIGN;
}
return Token.OP_SHIFT_LEFT;
} else if (d == '='){
doread = true;
return Token.OP_LE;
}
return Token.OP_LT;
} else if (c == '>') {
if (parsing_generic_less_than > 0) {
parsing_generic_less_than--;
return Token.OP_GENERICS_GT;
}
d = peekChar ();
if (d == '>'){
getChar ();
d = peekChar ();
if (d == '='){
doread = true;
return Token.OP_SHIFT_RIGHT_ASSIGN;
}
return Token.OP_SHIFT_RIGHT;
} else if (d == '='){
doread = true;
return Token.OP_GE;
}
return Token.OP_GT;
}
d = peekChar ();
if (c == '+'){
@@ -705,6 +542,39 @@ namespace Mono.CSharp
return Token.CARRET;
}
if (c == '<'){
if (d == '<'){
getChar ();
d = peekChar ();
if (d == '='){
doread = true;
return Token.OP_SHIFT_LEFT_ASSIGN;
}
return Token.OP_SHIFT_LEFT;
} else if (d == '='){
doread = true;
return Token.OP_LE;
}
return Token.OP_LT;
}
if (c == '>'){
if (d == '>'){
getChar ();
d = peekChar ();
if (d == '='){
doread = true;
return Token.OP_SHIFT_RIGHT_ASSIGN;
}
return Token.OP_SHIFT_RIGHT;
} else if (d == '='){
doread = true;
return Token.OP_GE;
}
return Token.OP_GT;
}
return Token.ERROR;
}
@@ -799,12 +669,15 @@ namespace Mono.CSharp
break;
case 'l':
if (!is_unsigned && (RootContext.WarningLevel >= 4)){
if (!is_unsigned){
//
// if we have not seen anything in between
// report this error
//
Report.Warning (78, Location, "The 'l' suffix is easily confused with the digit '1' (use 'L' for clarity)");
Report.Warning (
78, Location,
"the 'l' suffix is easily confused with digit `1'," +
" use 'L' for clarity");
}
goto case 'L';
@@ -887,11 +760,6 @@ namespace Mono.CSharp
val = 0ul;
return Token.LITERAL_INTEGER;
}
catch (FormatException) {
Report.Error (1013, Location, "Invalid number");
val = 0ul;
return Token.LITERAL_INTEGER;
}
}
int adjust_real (int t)
@@ -1240,19 +1108,7 @@ namespace Mono.CSharp
public int token ()
{
current_token = xtoken ();
if (current_token != Token.DEFAULT)
return current_token;
int c = consume_whitespace ();
if (c == -1)
current_token = Token.ERROR;
else if (c == '(')
current_token = Token.DEFAULT_OPEN_PARENS;
else
putback (c);
return current_token;
return current_token;
}
static StringBuilder static_cmd_arg = new System.Text.StringBuilder ();
@@ -1268,15 +1124,16 @@ namespace Mono.CSharp
// skip over white space
while ((c = getChar ()) != -1 && (c != '\n') && ((c == '\r') || (c == ' ') || (c == '\t')))
;
while ((c != -1) && (c != '\n') && (c != ' ') && (c != '\t') && (c != '\r')){
if (is_identifier_part_character ((char) c)){
if (is_identifier_part_character ((char) c)){
static_cmd_arg.Append ((char) c);
c = getChar ();
} else {
putback (c);
break;
}
} else {
putback (c);
break;
}
}
cmd = static_cmd_arg.ToString ();
@@ -1335,7 +1192,7 @@ namespace Mono.CSharp
//
return true;
}
try {
int pos;
@@ -1398,60 +1255,6 @@ namespace Mono.CSharp
}
}
/// <summary>
/// Handles #pragma directive
/// </summary>
void PreProcessPragma (string arg)
{
const string disable = "warning disable";
const string restore = "warning restore";
if (arg == disable) {
Report.RegisterWarningRegion (Location).WarningDisable (line);
return;
}
if (arg == restore) {
Report.RegisterWarningRegion (Location).WarningEnable (line);
return;
}
if (arg.StartsWith (disable)) {
int[] codes = ParseNumbers (arg.Substring (disable.Length));
foreach (int code in codes) {
if (code != 0)
Report.RegisterWarningRegion (Location).WarningDisable (Location, code);
}
return;
}
if (arg.StartsWith (restore)) {
int[] codes = ParseNumbers (arg.Substring (restore.Length));
foreach (int code in codes) {
Report.RegisterWarningRegion (Location).WarningEnable (Location, code);
}
return;
}
return;
}
int[] ParseNumbers (string text)
{
string[] string_array = text.Split (',');
int[] values = new int [string_array.Length];
int index = 0;
foreach (string string_code in string_array) {
try {
values[index++] = int.Parse (string_code, System.Globalization.CultureInfo.InvariantCulture);
}
catch (FormatException) {
Report.Warning (1692, Location, "Invalid number");
}
}
return values;
}
bool eval_val (string s)
{
if (s == "true")
@@ -1655,20 +1458,16 @@ namespace Mono.CSharp
//
switch (cmd){
case "pragma":
if (RootContext.Version == LanguageVersion.ISO_1) {
Report.FeatureIsNotStandardized (Location, "#pragma");
return caller_is_taking;
}
PreProcessPragma (arg);
return caller_is_taking;
if (RootContext.V2)
return true;
break;
case "line":
if (!PreProcessLine (arg))
Report.Error (
1576, Location,
"Argument to #line directive is missing or invalid");
return caller_is_taking;
return true;
case "region":
region_directive = true;
@@ -1828,7 +1627,7 @@ namespace Mono.CSharp
return true;
case "warning":
Report.Warning (1030, Location, "#warning: '{0}'", arg);
Report.Warning (1030, Location, "#warning: '" + arg + "'");
return true;
}
@@ -1875,36 +1674,6 @@ namespace Mono.CSharp
return Token.EOF;
}
private int consume_identifier (int s)
{
int res = consume_identifier (s, false);
if (res == Token.PARTIAL) {
// Save current position and parse next token.
int old = reader.Position;
int old_putback = putback_char;
putback_char = -1;
int next_token = token ();
bool ok = (next_token == Token.CLASS) ||
(next_token == Token.STRUCT) ||
(next_token == Token.INTERFACE);
reader.Position = old;
putback_char = old_putback;
if (ok)
return res;
else {
val = "partial";
return Token.IDENTIFIER;
}
}
return res;
}
private int consume_identifier (int s, bool quoted)
{
int pos = 1;
@@ -1932,10 +1701,10 @@ namespace Mono.CSharp
// Optimization: avoids doing the keyword lookup
// on uppercase letters and _
//
if (!quoted && (s >= 'a' || s == '_')){
if (s >= 'a'){
int keyword = GetKeyword (id_builder, pos);
if (keyword != -1)
return keyword;
if (keyword != -1 && !quoted)
return keyword;
}
//
@@ -1961,8 +1730,8 @@ namespace Mono.CSharp
return Token.IDENTIFIER;
}
int consume_whitespace ()
public int xtoken ()
{
int t;
bool doread = false;
@@ -2032,7 +1801,22 @@ namespace Mono.CSharp
goto is_punct_label;
}
if (is_identifier_start_character ((char)c)){
tokens_seen = true;
return consume_identifier (c, false);
}
is_punct_label:
if ((t = is_punct ((char)c, ref doread)) != Token.ERROR){
tokens_seen = true;
if (doread){
getChar ();
col++;
}
return t;
}
// white space
if (c == '\n'){
line++;
@@ -2043,6 +1827,19 @@ namespace Mono.CSharp
continue;
}
if (c >= '0' && c <= '9'){
tokens_seen = true;
return is_number (c);
}
if (c == '.'){
tokens_seen = true;
int peek = peekChar ();
if (peek >= '0' && peek <= '9')
return is_number (c);
return Token.DOT;
}
/* For now, ignore pre-processor commands */
// FIXME: In C# the '#' is not limited to appear
// on the first column.
@@ -2079,115 +1876,72 @@ namespace Mono.CSharp
Report.Error (1027, Location, "#endif/#endregion expected");
continue;
}
return c;
}
return -1;
}
public int xtoken ()
{
int t;
bool doread = false;
int c;
val = null;
// optimization: eliminate col and implement #directive semantic correctly.
c = consume_whitespace ();
if (c == -1)
return Token.EOF;
if (is_identifier_start_character ((char)c)){
tokens_seen = true;
return consume_identifier (c);
}
is_punct_label:
if ((t = is_punct ((char)c, ref doread)) != Token.ERROR){
tokens_seen = true;
if (doread){
getChar ();
col++;
}
return t;
}
if (c >= '0' && c <= '9'){
tokens_seen = true;
return is_number (c);
}
if (c == '.'){
tokens_seen = true;
int peek = peekChar ();
if (peek >= '0' && peek <= '9')
return is_number (c);
return Token.DOT;
}
if (c == '"')
return consume_string (false);
if (c == '\''){
c = getChar ();
tokens_seen = true;
if (c == '\''){
error_details = "Empty character literal";
Report.Error (1011, Location, error_details);
return Token.ERROR;
}
c = escape (c);
if (c == -1)
return Token.ERROR;
val = new System.Char ();
val = (char) c;
c = getChar ();
if (c != '\''){
error_details = "Too many characters in character literal";
Report.Error (1012, Location, error_details);
// Try to recover, read until newline or next "'"
while ((c = getChar ()) != -1){
if (c == '\n' || c == '\''){
line++;
ref_line++;
col = 0;
break;
} else
col++;
}
return Token.ERROR;
}
return Token.LITERAL_CHARACTER;
}
if (c == '@') {
c = getChar ();
if (c == '"') {
if (c == '"')
return consume_string (false);
if (c == '\''){
c = getChar ();
tokens_seen = true;
return consume_string (true);
} else if (is_identifier_start_character ((char) c)){
return consume_identifier (c, true);
} else {
Report.Error (1033, Location, "'@' must be followed by string constant or identifier");
if (c == '\''){
error_details = "Empty character literal";
Report.Error (1011, Location, error_details);
return Token.ERROR;
}
c = escape (c);
if (c == -1)
return Token.ERROR;
val = new System.Char ();
val = (char) c;
c = getChar ();
if (c != '\''){
error_details = "Too many characters in character literal";
Report.Error (1012, Location, error_details);
// Try to recover, read until newline or next "'"
while ((c = getChar ()) != -1){
if (c == '\n' || c == '\''){
line++;
ref_line++;
col = 0;
break;
} else
col++;
}
return Token.ERROR;
}
return Token.LITERAL_CHARACTER;
}
if (c == '@') {
c = getChar ();
if (c == '"') {
tokens_seen = true;
return consume_string (true);
} else if (is_identifier_start_character ((char) c)){
return consume_identifier (c, true);
} else {
Report.Error (1033, Location, "'@' must be followed by string constant or identifier");
}
}
}
if (c == '#') {
error_details = "Preprocessor directives must appear as the first non-whitespace " +
"character on a line.";
if (c == '#') {
error_details = "Preprocessor directives must appear as the first non-whitespace " +
"character on a line.";
Report.Error (1040, Location, error_details);
Report.Error (1040, Location, error_details);
return Token.ERROR;
}
error_details = ((char)c).ToString ();
return Token.ERROR;
}
error_details = ((char)c).ToString ();
return Token.ERROR;
return Token.EOF;
}
public void cleanup ()
File diff suppressed because it is too large. Load diff
+106 -160
View File
@@ -49,7 +49,7 @@ namespace Mono.CSharp {
Modifiers.PRIVATE;
public Delegate (NamespaceEntry ns, TypeContainer parent, Expression type,
int mod_flags, MemberName name, Parameters param_list,
int mod_flags, string name, Parameters param_list,
Attributes attrs, Location l)
: base (ns, parent, name, attrs, l)
@@ -63,7 +63,7 @@ namespace Mono.CSharp {
public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
{
if (a.Target == AttributeTargets.ReturnValue) {
if (a.Target == "return") {
if (return_attributes == null)
return_attributes = new ReturnParameter (InvokeBuilder, Location);
@@ -79,12 +79,6 @@ namespace Mono.CSharp {
if (TypeBuilder != null)
return TypeBuilder;
if (IsGeneric) {
foreach (TypeParameter type_param in TypeParameters)
if (!type_param.Resolve (this))
return null;
}
TypeAttributes attr = Modifiers.TypeAttr (ModFlags, IsTopLevel) |
TypeAttributes.Class | TypeAttributes.Sealed;
@@ -106,30 +100,6 @@ namespace Mono.CSharp {
TypeManager.AddDelegateType (Name, TypeBuilder, this);
if (IsGeneric) {
CurrentType = new ConstructedType (
Name, TypeParameters, Location);
EmitContext ec = new EmitContext (
this, this, Location, null, null, ModFlags, false);
string[] param_names = new string [TypeParameters.Length];
for (int i = 0; i < TypeParameters.Length; i++)
param_names [i] = TypeParameters [i].Name;
GenericTypeParameterBuilder[] gen_params;
gen_params = TypeBuilder.DefineGenericParameters (param_names);
for (int i = 0; i < gen_params.Length; i++)
TypeParameters [i].Define (gen_params [i]);
foreach (TypeParameter type_param in TypeParameters) {
if (!type_param.DefineType (ec))
return null;
}
}
return TypeBuilder;
}
@@ -138,18 +108,13 @@ namespace Mono.CSharp {
return true;
}
public override bool Define ()
public override bool Define (TypeContainer container)
{
MethodAttributes mattr;
int i;
EmitContext ec = new EmitContext (this, this, Location, null,
null, ModFlags, false);
if (IsGeneric) {
foreach (TypeParameter type_param in TypeParameters)
type_param.DefineType (ec);
}
// FIXME: POSSIBLY make this static, as it is always constant
//
Type [] const_arg_types = new Type [2];
@@ -202,14 +167,14 @@ namespace Mono.CSharp {
// Check accessibility
foreach (Type partype in param_types){
if (!Parent.AsAccessible (partype, ModFlags)) {
if (!container.AsAccessible (partype, ModFlags)) {
Report.Error (59, Location,
"Inconsistent accessibility: parameter type `" +
TypeManager.CSharpName (partype) + "` is less " +
"accessible than delegate `" + Name + "'");
return false;
}
if (partype.IsPointer && !UnsafeOK (Parent))
if (partype.IsPointer && !UnsafeOK (container))
return false;
}
@@ -221,7 +186,7 @@ namespace Mono.CSharp {
if (ret_type == null)
return false;
if (!Parent.AsAccessible (ret_type, ModFlags)) {
if (!container.AsAccessible (ret_type, ModFlags)) {
Report.Error (58, Location,
"Inconsistent accessibility: return type `" +
TypeManager.CSharpName (ret_type) + "` is less " +
@@ -229,7 +194,7 @@ namespace Mono.CSharp {
return false;
}
if (ret_type.IsPointer && !UnsafeOK (Parent))
if (ret_type.IsPointer && !UnsafeOK (container))
return false;
//
@@ -272,7 +237,7 @@ namespace Mono.CSharp {
InvokeBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
TypeManager.RegisterMethod (InvokeBuilder,
new InternalParameters (Parent, Parameters),
new InternalParameters (container, Parameters),
param_types);
//
@@ -339,7 +304,7 @@ namespace Mono.CSharp {
async_parameters.ComputeAndDefineParameterTypes (this);
TypeManager.RegisterMethod (BeginInvokeBuilder,
new InternalParameters (Parent, async_parameters),
new InternalParameters (container, async_parameters),
async_param_types);
//
@@ -384,25 +349,24 @@ namespace Mono.CSharp {
TypeManager.RegisterMethod (
EndInvokeBuilder,
new InternalParameters (Parent, end_parameters),
new InternalParameters (container, end_parameters),
end_param_types);
return true;
}
public override void Emit ()
public override void Emit (TypeContainer tc)
{
if (OptAttributes != null) {
EmitContext ec = new EmitContext (
Parent, this, Location, null, null, ModFlags, false);
EmitContext ec = new EmitContext (tc, this, Location, null, null, ModFlags, false);
Parameters.LabelParameters (ec, InvokeBuilder, Location);
OptAttributes.Emit (ec, this);
}
base.Emit ();
base.Emit (tc);
}
public override string[] ValidAttributeTargets {
protected override string[] ValidAttributeTargets {
get {
return attribute_targets;
}
@@ -418,7 +382,7 @@ namespace Mono.CSharp {
AttributeTester.AreParametersCompliant (Parameters.FixedParameters, Location);
if (!AttributeTester.IsClsCompliant (ReturnType.Type)) {
Report.Error (3002, Location, "Return type of '{0}' is not CLS-compliant", GetSignatureForError ());
Report.Error_T (3002, Location, GetSignatureForError ());
}
return true;
}
@@ -430,6 +394,10 @@ namespace Mono.CSharp {
public static MethodBase VerifyMethod (EmitContext ec, Type delegate_type, MethodBase mb,
Location loc)
{
ParameterData pd = Invocation.GetParameterData (mb);
int pd_count = pd.Count;
Expression ml = Expression.MemberLookup (
ec, delegate_type, "Invoke", loc);
@@ -442,13 +410,6 @@ namespace Mono.CSharp {
ParameterData invoke_pd = Invocation.GetParameterData (invoke_mb);
if (!((MethodGroupExpr) ml).HasTypeArguments &&
!Invocation.InferTypeArguments (ec, invoke_pd, ref mb))
return null;
ParameterData pd = Invocation.GetParameterData (mb);
int pd_count = pd.Count;
if (invoke_pd.Count != pd_count)
return null;
@@ -473,8 +434,10 @@ namespace Mono.CSharp {
// Verifies whether the invocation arguments are compatible with the
// delegate's target method
// </summary>
public static bool VerifyApplicability (EmitContext ec, Type delegate_type,
ArrayList args, Location loc)
public static bool VerifyApplicability (EmitContext ec,
Type delegate_type,
ArrayList args,
Location loc)
{
int arg_count;
@@ -523,13 +486,9 @@ namespace Mono.CSharp {
bool ans = false;
if (arg_count == pd_count)
ans = Invocation.VerifyArgumentsCompat (
ec, args, arg_count, mb, false,
delegate_type, false, loc);
ans = Invocation.VerifyArgumentsCompat (ec, args, arg_count, mb, false, delegate_type, loc);
if (!ans && params_method)
ans = Invocation.VerifyArgumentsCompat (
ec, args, arg_count, mb, true,
delegate_type, false, loc);
ans = Invocation.VerifyArgumentsCompat (ec, args, arg_count, mb, true, delegate_type, loc);
return ans;
}
@@ -665,16 +624,7 @@ namespace Mono.CSharp {
public override AttributeTargets AttributeTargets {
get {
return AttributeTargets.Delegate;
}
}
protected override void VerifyObsoleteAttribute()
{
CheckUsageOfObsoleteAttribute (ret_type);
foreach (Type type in param_types) {
CheckUsageOfObsoleteAttribute (type);
return AttributeTargets.Delegate | AttributeTargets.ReturnValue;
}
}
}
@@ -685,20 +635,18 @@ namespace Mono.CSharp {
public abstract class DelegateCreation : Expression {
protected MethodBase constructor_method;
protected MethodBase delegate_method;
protected MethodGroupExpr method_group;
protected Expression delegate_instance_expression;
protected Expression delegate_instance_expr;
public DelegateCreation () {}
public static void Error_NoMatchingMethodForDelegate (EmitContext ec, MethodGroupExpr mg, Type type, Location loc)
{
string method_desc;
MethodBase candidate = mg.Methods [0];
if (mg.Methods.Length > 1)
method_desc = candidate.Name;
method_desc = mg.Methods [0].Name;
else
method_desc = Invocation.FullMethodDesc (candidate);
method_desc = Invocation.FullMethodDesc (mg.Methods [0]);
Expression invoke_method = Expression.MemberLookup (
ec, type, "Invoke", MemberTypes.Method,
@@ -706,27 +654,20 @@ namespace Mono.CSharp {
MethodBase method = ((MethodGroupExpr) invoke_method).Methods [0];
ParameterData param = Invocation.GetParameterData (method);
string delegate_desc = Delegate.FullDelegateDesc (type, method, param);
if (!mg.HasTypeArguments &&
!Invocation.InferTypeArguments (ec, param, ref candidate))
Report.Error (411, loc, "The type arguments for " +
"method `{0}' cannot be infered from " +
"the usage. Try specifying the type " +
"arguments explicitly.", method_desc);
else
Report.Error (123, loc, "Method '{0}' does not " +
"match delegate '{1}'", method_desc,
delegate_desc);
Report.Error (123, loc, "Method '" + method_desc + "' does not " +
"match delegate '" + delegate_desc + "'");
}
public override void Emit (EmitContext ec)
{
if (delegate_instance_expression == null || delegate_method.IsStatic)
if (delegate_instance_expr == null ||
delegate_method.IsStatic)
ec.ig.Emit (OpCodes.Ldnull);
else
delegate_instance_expression.Emit (ec);
delegate_instance_expr.Emit (ec);
if (delegate_method.IsVirtual && !method_group.IsBase) {
if (delegate_method.IsVirtual) {
ec.ig.Emit (OpCodes.Dup);
ec.ig.Emit (OpCodes.Ldvirtftn, (MethodInfo) delegate_method);
} else
@@ -750,63 +691,52 @@ namespace Mono.CSharp {
protected Expression ResolveMethodGroupExpr (EmitContext ec, MethodGroupExpr mg)
{
foreach (MethodInfo mi in mg.Methods){
delegate_method = Delegate.VerifyMethod (
ec, type, mi, loc);
if (delegate_method != null)
break;
}
if (delegate_method == null) {
Error_NoMatchingMethodForDelegate (ec, mg, type, loc);
return null;
}
//
// Check safe/unsafe of the delegate
//
if (!ec.InUnsafe){
ParameterData param = Invocation.GetParameterData (delegate_method);
int count = param.Count;
for (int i = 0; i < count; i++){
if (param.ParameterType (i).IsPointer){
Expression.UnsafeError (loc);
return null;
}
foreach (MethodInfo mi in mg.Methods){
delegate_method = Delegate.VerifyMethod (ec, type, mi, loc);
if (delegate_method != null)
break;
}
if (delegate_method == null) {
Error_NoMatchingMethodForDelegate (ec, mg, type, loc);
return null;
}
//
// Check safe/unsafe of the delegate
//
if (!ec.InUnsafe){
ParameterData param = Invocation.GetParameterData (delegate_method);
int count = param.Count;
for (int i = 0; i < count; i++){
if (param.ParameterType (i).IsPointer){
Expression.UnsafeError (loc);
return null;
}
}
//TODO: implement caching when performance will be low
IMethodData md = TypeManager.GetMethod (delegate_method);
if (md == null) {
if (System.Attribute.GetCustomAttribute (delegate_method, TypeManager.conditional_attribute_type) != null) {
Report.Error (1618, loc, "Cannot create delegate with '{0}' because it has a Conditional attribute", TypeManager.CSharpSignature (delegate_method));
}
} else {
if (md.OptAttributes != null && md.OptAttributes.Search (TypeManager.conditional_attribute_type, ec) != null) {
Report.Error (1618, loc, "Cannot create delegate with '{0}' because it has a Conditional attribute", TypeManager.CSharpSignature (delegate_method));
}
}
if (mg.InstanceExpression != null)
delegate_instance_expression = mg.InstanceExpression.Resolve (ec);
else if (ec.IsStatic) {
if (!delegate_method.IsStatic) {
Report.Error (120, loc,
"An object reference is required for the non-static method " +
delegate_method.Name);
return null;
}
delegate_instance_expression = null;
} else
delegate_instance_expression = ec.GetThis (loc);
if (delegate_instance_expression != null && delegate_instance_expression.Type.IsValueType)
delegate_instance_expression = new BoxedCast (mg.InstanceExpression);
method_group = mg;
delegate_instance_expr = mg.InstanceExpression.Resolve (ec);
else {
if (ec.IsStatic){
if (!delegate_method.IsStatic){
Report.Error (120, loc,
"An object reference is required for the non-static method " +
delegate_method.Name);
return null;
}
delegate_instance_expr = null;
} else
delegate_instance_expr = ec.GetThis (loc);
}
if (delegate_instance_expr != null)
if (delegate_instance_expr.Type.IsValueType)
delegate_instance_expr = new BoxedCast (delegate_instance_expr);
eclass = ExprClass.Value;
return this;
}
@@ -867,6 +797,15 @@ namespace Mono.CSharp {
Argument a = (Argument) Arguments [0];
Expression invoke_method = Expression.MemberLookup (
ec, type, "Invoke", MemberTypes.Method,
Expression.AllBindingFlags, loc);
if (invoke_method == null) {
Report.Error (-200, loc, "Internal error ! Could not find Invoke method!");
return null;
}
if (!a.ResolveMethodGroup (ec, loc))
return null;
@@ -879,33 +818,40 @@ namespace Mono.CSharp {
Type e_type = e.Type;
if (!TypeManager.IsDelegateType (e_type)) {
e.Error_UnexpectedKind ("method", loc);
return null;
}
method_group = Expression.MemberLookup (
ec, type, "Invoke", MemberTypes.Method,
Expression.AllBindingFlags, loc) as MethodGroupExpr;
if (method_group == null) {
Report.Error (-200, loc, "Internal error ! Could not find Invoke method!");
e.Error_UnexpectedKind ("method");
return null;
}
// This is what MS' compiler reports. We could always choose
// to be more verbose and actually give delegate-level specifics
if (!Delegate.VerifyDelegate (ec, type, e_type, loc)) {
Report.Error (29, loc, "Cannot implicitly convert type '" + e_type + "' " +
"to type '" + type + "'");
return null;
}
delegate_instance_expression = e;
delegate_method = method_group.Methods [0];
delegate_instance_expr = e;
delegate_method = ((MethodGroupExpr) invoke_method).Methods [0];
eclass = ExprClass.Value;
return this;
}
public override void Emit (EmitContext ec)
{
if (delegate_instance_expr == null || delegate_method.IsStatic)
ec.ig.Emit (OpCodes.Ldnull);
else
delegate_instance_expr.Emit (ec);
if (delegate_method.IsVirtual) {
ec.ig.Emit (OpCodes.Dup);
ec.ig.Emit (OpCodes.Ldvirtftn, (MethodInfo) delegate_method);
} else
ec.ig.Emit (OpCodes.Ldftn, (MethodInfo) delegate_method);
ec.ig.Emit (OpCodes.Newobj, (ConstructorInfo) constructor_method);
}
}
public class DelegateInvocation : ExpressionStatement {
+34 -70
View File
@@ -14,10 +14,11 @@ namespace Mono.CSharp
using System.Reflection;
using System.Reflection.Emit;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using Mono.Languages;
public enum Target {
Library, Exe, Module, WinExe
@@ -79,7 +80,7 @@ namespace Mono.CSharp
static ArrayList embedded_resources;
static string win32ResourceFile;
static string win32IconFile;
//
// An array of the defines from the command line
//
@@ -105,6 +106,12 @@ namespace Mono.CSharp
//
static bool using_default_encoder = true;
//
// The system version we are using, if not specified on the commandline we
// will use the same version as corlib for looking for libraries in the GAC.
//
static string sys_version;
public static void ShowTime (string msg)
{
if (!timestamps)
@@ -176,7 +183,7 @@ namespace Mono.CSharp
SeekableStreamReader reader = new SeekableStreamReader (input, encoding, using_default_encoder);
parser = new CSharpParser (reader, file, defines);
parser.yacc_verbose_flag = yacc_verbose;
parser.yacc_verbose = yacc_verbose;
try {
parser.parse ();
} catch (Exception ex) {
@@ -185,7 +192,7 @@ namespace Mono.CSharp
input.Close ();
}
}
static void OtherFlags ()
{
Console.WriteLine (
@@ -205,7 +212,6 @@ namespace Mono.CSharp
"Mono C# compiler, (C) 2001 - 2003 Ximian, Inc.\n" +
"mcs [options] source-files\n" +
" --about About the Mono C# compiler\n" +
" -addmodule:MODULE Adds the module to the generated assembly\n" +
" -checked[+|-] Set default context to checked\n" +
" -codepage:ID Sets code page to the one in ID\n" +
" (number, `utf8' or `reset')\n" +
@@ -217,7 +223,6 @@ namespace Mono.CSharp
" -g Generate debugging information\n" +
" -keycontainer:NAME The key pair container used to strongname the assembly\n" +
" -keyfile:FILE The strongname key file used to strongname the assembly\n" +
" -langversion:TEXT Specifies language version modes: ISO-1 or Default" + Environment.NewLine +
" -lib:PATH1,PATH2 Adds the paths to the assembly link path\n" +
" -main:class Specified the class that contains the entry point\n" +
" -noconfig[+|-] Disables implicit references to assemblies\n" +
@@ -240,7 +245,7 @@ namespace Mono.CSharp
" -resource:FILE[,ID] Embed FILE as a resource\n" +
" -win32res:FILE Specifies Win32 resource file (.res)\n" +
" -win32icon:FILE Use this icon for the output\n" +
" @file Read response file for more options\n\n" +
" @file Read response file for more options\n\n" +
"Options can be of the form -option or /option");
}
@@ -258,7 +263,7 @@ namespace Mono.CSharp
"For more information on Mono, visit the project Web site\n" +
" http://www.go-mono.com\n\n" +
"The compiler was written by Miguel de Icaza, Ravi Pratap, Martin Baulig and Marek Safar");
"The compiler was written by Miguel de Icaza, Ravi Pratap and Martin Baulig");
Environment.Exit (0);
}
@@ -266,7 +271,6 @@ namespace Mono.CSharp
public static int Main (string[] args)
{
RootContext.Version = LanguageVersion.Default;
bool ok = MainDriver (args);
if (ok && Report.Errors == 0) {
@@ -638,7 +642,7 @@ namespace Mono.CSharp
static void SetupV2 ()
{
RootContext.Version = LanguageVersion.Default;
RootContext.V2 = true;
defines.Add ("__V2__");
}
@@ -690,7 +694,7 @@ namespace Mono.CSharp
Usage ();
Environment.Exit (0);
return true;
case "--define":
if ((i + 1) >= args.Length){
Usage ();
@@ -993,7 +997,7 @@ namespace Mono.CSharp
resources.Add (value);
return true;
case "/pkg": {
string packages;
@@ -1040,26 +1044,18 @@ namespace Mono.CSharp
case "/res":
case "/resource":
if (value == ""){
Report.Error (5, "-resource requires an argument");
Report.Error (5, arg + " requires an argument");
Environment.Exit (1);
}
if (embedded_resources == null)
embedded_resources = new ArrayList ();
if (embedded_resources.Contains (value)) {
Report.Error (1508, String.Format ("The resource identifier '{0}' has already been used in this assembly.", value));
}
else if (value.IndexOf (',') != -1 && embedded_resources.Contains (value.Split (',')[1])) {
Report.Error (1508, String.Format ("The resource identifier '{0}' has already been used in this assembly.", value));
}
else {
embedded_resources.Add (value);
}
return true;
case "/recurse":
if (value == ""){
Report.Error (5, "-recurse requires an argument");
Report.Error (5, "/recurse requires an argument");
Environment.Exit (1);
}
CompileFiles (value, true);
@@ -1068,7 +1064,7 @@ namespace Mono.CSharp
case "/r":
case "/reference": {
if (value == ""){
Report.Error (5, "-reference requires an argument");
Report.Error (5, arg + " requires an argument");
Environment.Exit (1);
}
@@ -1267,24 +1263,9 @@ namespace Mono.CSharp
case "/v2":
case "/2":
Console.WriteLine ("The compiler option -2 is obsolete. Please use /langversion instead");
SetupV2 ();
return true;
case "/langversion":
switch (value.ToLower (CultureInfo.InvariantCulture)) {
case "iso-1":
RootContext.Version = LanguageVersion.ISO_1;
return true;
case "default":
SetupV2 ();
return true;
}
Report.Error (1617, "Invalid option '{0}' for /langversion; must be ISO-1 or Default", value);
Environment.Exit (1);
return false;
case "/codepage":
int cp = -1;
@@ -1315,7 +1296,7 @@ namespace Mono.CSharp
//Environment.Exit (1);
return false;
}
static string [] AddArgs (string [] args, string [] extra_args)
{
string [] new_args;
@@ -1342,8 +1323,6 @@ namespace Mono.CSharp
int i;
bool parsing_options = true;
Console.WriteLine ("ALPHA SOFTWARE: Mono C# Compiler {0} for Generics",
Assembly.GetExecutingAssembly ().GetName ().Version.ToString ());
try {
encoding = Encoding.GetEncoding (28591);
} catch {
@@ -1369,7 +1348,7 @@ namespace Mono.CSharp
string arg = args [i];
if (arg == "")
continue;
if (arg.StartsWith ("@")){
string [] extra_args;
string response_file = arg.Substring (1);
@@ -1426,15 +1405,15 @@ namespace Mono.CSharp
if (tokenize)
return true;
//
// If we are an exe, require a source file for the entry point
//
if (RootContext.Target == Target.Exe || RootContext.Target == Target.WinExe){
if (first_source == null){
Report.Error (2008, "No files to compile were specified");
return false;
}
if (first_source == null){
Report.Error (2008, "No files to compile were specified");
return false;
}
}
@@ -1442,8 +1421,8 @@ namespace Mono.CSharp
// If there is nothing to put in the assembly, and we are not a library
//
if (first_source == null && embedded_resources == null && resources == null){
Report.Error (2008, "No files to compile were specified");
return false;
Report.Error (2008, "No files to compile were specified");
return false;
}
if (Report.Errors > 0)
@@ -1451,7 +1430,7 @@ namespace Mono.CSharp
if (parse_only)
return true;
Tokenizer.Cleanup ();
//
@@ -1552,6 +1531,7 @@ namespace Mono.CSharp
ShowTime ("Populate tree");
if (!RootContext.StdLib)
RootContext.BootCorlib_PopulateCoreTypes ();
RootContext.PopulateTypes ();
RootContext.DefineTypes ();
@@ -1568,11 +1548,8 @@ namespace Mono.CSharp
if (RootContext.VerifyClsCompliance) {
CodeGen.Assembly.ResolveClsCompliance ();
if (CodeGen.Assembly.IsClsCompliant) {
AttributeTester.VerifyModulesClsCompliance ();
TypeManager.LoadAllImportedTypes ();
AttributeTester.VerifyTopLevelNameClsCompliance ();
}
}
//
@@ -1595,7 +1572,7 @@ namespace Mono.CSharp
RootContext.CloseTypes ();
PEFileKinds k = PEFileKinds.ConsoleApplication;
switch (RootContext.Target) {
case Target.Library:
case Target.Module:
@@ -1610,25 +1587,12 @@ namespace Mono.CSharp
MethodInfo ep = RootContext.EntryPoint;
if (ep == null) {
if (RootContext.MainClass != null) {
object main_cont = RootContext.Tree.Decls [RootContext.MainClass];
if (main_cont == null) {
Report.Error (1555, output_file, "Could not find '{0}' specified for Main method", RootContext.MainClass);
return false;
}
if (!(main_cont is ClassOrStruct)) {
Report.Error (1556, output_file, "'{0}' specified for Main method must be a valid class or struct", RootContext.MainClass);
return false;
}
}
if (Report.Errors == 0)
Report.Error (5001, "Program " + output_file +
" does not have an entry point defined");
return false;
}
CodeGen.Assembly.Builder.SetEntryPoint (ep, k);
} else if (RootContext.MainClass != null) {
Report.Error (2017, "Can not specify -main: when building module or library");
@@ -1721,7 +1685,7 @@ namespace Mono.CSharp
Timer.ShowTimers ();
if (Report.ExpectedError != 0){
if (Report.ExpectedError != 0) {
if (Report.Errors == 0) {
Console.WriteLine ("Failed to report expected error " + Report.ExpectedError + ".\n" +
"No other errors reported.");
@@ -1731,7 +1695,7 @@ namespace Mono.CSharp
Console.WriteLine ("Failed to report expected error " + Report.ExpectedError + ".\n" +
"However, other errors were reported.");
Environment.Exit (1);
Environment.Exit (1);
}
File diff suppressed because it is too large. Load diff
+72 -78
View File
@@ -17,20 +17,21 @@ using System.Globalization;
namespace Mono.CSharp {
class EnumMember: MemberCore {
class EnumMember: Attributable {
string name;
Enum parent;
Location loc;
static string[] attribute_targets = new string [] { "field" };
Enum parent_enum;
public FieldBuilder builder;
internal readonly Expression Type;
public EnumMember (Enum parent_enum, Expression expr, string name,
Location loc, Attributes attrs):
base (null, new MemberName (name), attrs, loc)
public EnumMember (string name, Enum parent, Location loc, Attributes attrs):
base (attrs)
{
this.parent_enum = parent_enum;
this.ModFlags = parent_enum.ModFlags;
this.Type = expr;
this.name = name;
this.parent = parent;
this.loc = loc;
}
public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
@@ -41,7 +42,7 @@ namespace Mono.CSharp {
builder.SetMarshal (marshal);
return;
}
Report.Warning (-24, a.Location, "The Microsoft Runtime cannot set this marshal info. Please use the Mono runtime instead.");
Report.Warning_T (-24, a.Location);
return;
}
@@ -54,49 +55,30 @@ namespace Mono.CSharp {
}
}
public override bool IsClsCompliaceRequired(DeclSpace ds)
{
return parent.IsClsCompliaceRequired (ds);
}
public void DefineMember (TypeBuilder tb)
{
FieldAttributes attr = FieldAttributes.Public | FieldAttributes.Static
| FieldAttributes.Literal;
builder = tb.DefineField (Name, tb, attr);
}
public override bool Define ()
{
throw new NotImplementedException ();
builder = tb.DefineField (name, tb, attr);
}
public void Emit (EmitContext ec)
{
if (OptAttributes != null)
OptAttributes.Emit (ec, this);
Emit ();
}
public override string GetSignatureForError()
{
return String.Concat (parent_enum.GetSignatureForError (), '.', base.GetSignatureForError ());
}
public override string[] ValidAttributeTargets {
protected override string[] ValidAttributeTargets {
get {
return attribute_targets;
}
}
protected override bool VerifyClsCompliance(DeclSpace ds)
{
// Because parent is TypeContainer and we have only DeclSpace parent.
// Parameter replacing is required
return base.VerifyClsCompliance (parent_enum);
}
// There is no base type
protected override void VerifyObsoleteAttribute()
{
}
}
/// <summary>
@@ -110,6 +92,7 @@ namespace Mono.CSharp {
public Type UnderlyingType;
Hashtable member_to_location;
Hashtable member_to_attributes;
//
// This is for members that have been defined
@@ -122,6 +105,9 @@ namespace Mono.CSharp {
Hashtable in_transit;
ArrayList field_builders;
Hashtable name_to_member;
public const int AllowedModifiers =
Modifiers.NEW |
@@ -130,8 +116,8 @@ namespace Mono.CSharp {
Modifiers.INTERNAL |
Modifiers.PRIVATE;
public Enum (NamespaceEntry ns, TypeContainer parent, Expression type,
int mod_flags, MemberName name, Attributes attrs, Location l)
public Enum (NamespaceEntry ns, TypeContainer parent, Expression type, int mod_flags,
string name, Attributes attrs, Location l)
: base (ns, parent, name, attrs, l)
{
this.BaseType = type;
@@ -143,27 +129,38 @@ namespace Mono.CSharp {
member_to_value = new Hashtable ();
in_transit = new Hashtable ();
field_builders = new ArrayList ();
name_to_member = new Hashtable ();
}
/// <summary>
/// Adds @name to the enumeration space, with @expr
/// being its definition.
/// </summary>
public void AddEnumMember (string name, Expression expr, Location loc, Attributes opt_attrs)
public AdditionResult AddEnumMember (string name, Expression expr, Location loc,
Attributes opt_attrs)
{
if (defined_names.Contains (name))
return AdditionResult.NameExists;
if (name == "value__") {
Report.Error (76, loc, "An item in an enumeration can't have an identifier `value__'");
return;
return AdditionResult.Error;
}
EnumMember em = new EnumMember (this, expr, name, loc, opt_attrs);
if (!AddToContainer (em, false, name, ""))
return;
DefineName (name, expr);
// TODO: can be almost deleted
ordered_enums.Add (name);
member_to_location.Add (name, loc);
if (member_to_attributes == null)
member_to_attributes = new Hashtable ();
member_to_attributes.Add (name, opt_attrs);
name_to_member.Add (name, new EnumMember (name, this, loc, opt_attrs));
return AdditionResult.Success;
}
//
@@ -582,7 +579,7 @@ namespace Mono.CSharp {
}
}
EnumMember em = (EnumMember) defined_names [name];
EnumMember em = name_to_member [name] as EnumMember;
em.DefineMember (TypeBuilder);
bool fail;
@@ -607,7 +604,7 @@ namespace Mono.CSharp {
return true;
}
public override bool Define ()
public override bool Define (TypeContainer parent)
{
//
// If there was an error during DefineEnum, return
@@ -642,7 +639,7 @@ namespace Mono.CSharp {
return false;
}
EnumMember em = (EnumMember) defined_names [name];
EnumMember em = name_to_member [name] as EnumMember;
em.DefineMember (TypeBuilder);
FieldBuilder fb = em.builder;
@@ -670,52 +667,53 @@ namespace Mono.CSharp {
default_value = GetNextDefaultValue (default_value);
}
return true;
}
public override void Emit ()
public override void Emit (TypeContainer tc)
{
EmitContext ec = new EmitContext (
Parent, this, Location, null, null, ModFlags, false);
EmitContext ec = new EmitContext (tc, this, Location, null, null, ModFlags, false);
if (OptAttributes != null) {
OptAttributes.Emit (ec, this);
}
foreach (EnumMember em in defined_names.Values) {
foreach (EnumMember em in name_to_member.Values) {
em.Emit (ec);
}
base.Emit ();
base.Emit (tc);
}
void VerifyClsName ()
{
Hashtable ht = new Hashtable ();
foreach (string name in ordered_enums) {
string locase = name.ToLower (System.Globalization.CultureInfo.InvariantCulture);
if (!ht.Contains (locase)) {
ht.Add (locase, defined_names [name]);
continue;
}
MemberCore conflict = (MemberCore)ht [locase];
Report.SymbolRelatedToPreviousError (conflict);
conflict = GetDefinition (name);
Report.Error (3005, conflict.Location, "Identifier '{0}' differing only in case is not CLS-compliant", conflict.GetSignatureForError ());
}
}
protected override bool IsIdentifierClsCompliant (DeclSpace ds)
{
if (!base.IsIdentifierClsCompliant (ds))
return false;
for (int i = 1; i < ordered_enums.Count; ++i) {
string checked_name = ordered_enums [i] as string;
for (int ii = 0; ii < ordered_enums.Count; ++ii) {
if (ii == i)
continue;
string enumerator_name = ordered_enums [ii] as string;
if (String.Compare (checked_name, enumerator_name, true, CultureInfo.InvariantCulture) == 0) {
Report.SymbolRelatedToPreviousError ((Location)member_to_location [enumerator_name], enumerator_name);
Report.Error_T (3005, (Location)member_to_location [checked_name], GetEnumeratorName (checked_name));
break;
}
}
}
return true;
}
protected override bool VerifyClsCompliance (DeclSpace ds)
{
if (!base.VerifyClsCompliance (ds))
return false;
VerifyClsName ();
if (!AttributeTester.IsClsCompliant (UnderlyingType)) {
Report.Error (3009, Location, "'{0}': base type '{1}' is not CLS-compliant", GetSignatureForError (), TypeManager.CSharpName (UnderlyingType));
Report.Error_T (3009, Location, GetSignatureForError (), TypeManager.CSharpName (UnderlyingType));
}
return true;
@@ -767,7 +765,7 @@ namespace Mono.CSharp {
// indexer
public Expression this [string name] {
get {
return ((EnumMember) defined_names [name]).Type;
return (Expression) defined_names [name];
}
}
@@ -777,9 +775,5 @@ namespace Mono.CSharp {
}
}
protected override void VerifyObsoleteAttribute()
{
// UnderlyingType is never obsolete
}
}
}
File renamed without changes.
File diff suppressed because it is too large. Load diff
@@ -258,7 +258,7 @@ namespace Mono.CSharp
(throws == FlowReturns.Never) &&
(barrier == FlowReturns.Never))
return FlowReturns.Always;
else
else
return FlowReturns.Sometimes;
}
}
@@ -334,11 +334,6 @@ namespace Mono.CSharp
barrier = FlowReturns.Always;
}
public void ResetBarrier ()
{
barrier = FlowReturns.Never;
}
static string ShortName (FlowReturns returns)
{
switch (returns) {
@@ -364,7 +359,7 @@ namespace Mono.CSharp
{
switch (type) {
case BranchingType.Exception:
throw new InvalidOperationException ();
return new FlowBranchingException (parent, block, loc);
case BranchingType.Switch:
return new FlowBranchingBlock (parent, type, SiblingType.SwitchSection, block, loc);
@@ -490,7 +485,7 @@ namespace Mono.CSharp
if (parent != null) {
if (num_locals > 0)
locals = new MyBitVector (parent.locals, CountLocals);
locals = new MyBitVector (parent.locals, CountLocals);
if (num_params > 0)
parameters = new MyBitVector (parent.parameters, num_params);
@@ -498,7 +493,7 @@ namespace Mono.CSharp
reachability = parent.Reachability.Clone ();
} else {
if (num_locals > 0)
locals = new MyBitVector (null, CountLocals);
locals = new MyBitVector (null, CountLocals);
if (num_params > 0)
parameters = new MyBitVector (null, num_params);
@@ -540,7 +535,7 @@ namespace Mono.CSharp
CountParameters, CountLocals);
if (retval.locals != null)
retval.locals = locals.Clone ();
retval.locals = locals.Clone ();
if (parameters != null)
retval.parameters = parameters.Clone ();
@@ -629,7 +624,7 @@ namespace Mono.CSharp
{
UsageVector result = branching.Merge ();
Report.Debug (2, " MERGING CHILD", this, branching, IsDirty,
Report.Debug (2, " MERGING CHILD", this, IsDirty,
result.ParameterVector, result.LocalVector,
result.Reachability, reachability, Type);
@@ -647,25 +642,21 @@ namespace Mono.CSharp
// then we do always return (or stay in the
// loop forever).
new_r.SetReturns ();
}
}
new_r.SetBarrier ();
} else {
if (new_r.Returns == FlowReturns.Always) {
// We're either finite or we may leave the loop.
new_r.SetReturnsSometimes ();
}
}
if (new_r.Throws == FlowReturns.Always) {
// We're either finite or we may leave the loop.
new_r.SetThrowsSometimes ();
}
}
} else if (branching.Type == BranchingType.Switch) {
if (new_r.MayBreak || new_r.MayReturn)
new_r.ResetBarrier ();
}
} else if (branching.Type == BranchingType.Switch)
new_r.ResetBreaks ();
}
//
// We've now either reached the point after the branching or we will
@@ -679,9 +670,9 @@ namespace Mono.CSharp
if ((Type == SiblingType.SwitchSection) && !new_r.IsUnreachable) {
Report.Error (163, Location,
"Control cannot fall through from one " +
"case label to another");
"case label to another");
return result;
}
}
if (locals != null && result.LocalVector != null)
locals.Or (result.LocalVector);
@@ -697,7 +688,7 @@ namespace Mono.CSharp
IsDirty = true;
return result;
}
}
protected void MergeFinally (FlowBranching branching, UsageVector f_origins,
MyBitVector f_params)
@@ -749,31 +740,29 @@ namespace Mono.CSharp
reachability = Reachability.Never ();
if (o_vectors == null) {
reachability.SetBarrier ();
if (o_vectors == null)
return;
}
bool first = true;
for (UsageVector vector = o_vectors; vector != null;
vector = vector.Next) {
Report.Debug (1, " MERGING JUMP ORIGIN", vector);
Report.Debug (1, " MERGING JUMP ORIGIN", vector);
if (first) {
if (locals != null && vector.Locals != null)
locals.Or (vector.locals);
locals.Or (vector.locals);
if (parameters != null)
parameters.Or (vector.parameters);
first = false;
} else {
if (locals != null && vector.Locals != null)
locals.And (vector.locals);
if (parameters != null)
parameters.And (vector.parameters);
}
locals.And (vector.locals);
if (parameters != null)
parameters.And (vector.parameters);
}
Reachability.And (ref reachability, vector.Reachability, true);
}
@@ -791,7 +780,7 @@ namespace Mono.CSharp
reachability = Reachability.Never ();
for (UsageVector vector = f_origins; vector != null; vector = vector.Next) {
Report.Debug (1, " MERGING FINALLY ORIGIN", vector);
Report.Debug (1, " MERGING FINALLY ORIGIN", vector);
if (parameters != null)
parameters.And (vector.parameters);
@@ -889,7 +878,7 @@ namespace Mono.CSharp
public MyBitVector Locals {
get {
if (locals != null)
return locals.Clone ();
return locals.Clone ();
else
return null;
}
@@ -1026,7 +1015,7 @@ namespace Mono.CSharp
}
protected UsageVector Merge (UsageVector sibling_list)
{
{
if (sibling_list.Next == null)
return sibling_list;
@@ -1040,13 +1029,13 @@ namespace Mono.CSharp
for (UsageVector child = sibling_list; child != null; child = child.Next) {
bool do_break = (Type != BranchingType.Switch) &&
(Type != BranchingType.Loop);
Report.Debug (2, " MERGING SIBLING ", child,
child.ParameterVector, child.LocalVector,
reachability, child.Reachability, do_break);
Reachability.And (ref reachability, child.Reachability, do_break);
// A local variable is initialized after a flow branching if it
// has been initialized in all its branches which do neither
// always return or always throw an exception.
@@ -1236,12 +1225,6 @@ namespace Mono.CSharp
throw new NotSupportedException ();
}
public virtual void StealFinallyClauses (ref ArrayList list)
{
if (Parent != null)
Parent.StealFinallyClauses (ref list);
}
public bool IsAssigned (VariableInfo vi)
{
return CurrentUsageVector.IsAssigned (vi);
@@ -1333,7 +1316,7 @@ namespace Mono.CSharp
UsageVector vector = CurrentUsageVector.Clone ();
vector.Next = origin_vectors;
origin_vectors = vector;
}
}
CurrentUsageVector.MergeJumpOrigins (origin_vectors);
}
@@ -1371,22 +1354,15 @@ namespace Mono.CSharp
public class FlowBranchingException : FlowBranching
{
ExceptionStatement stmt;
UsageVector current_vector;
UsageVector catch_vectors;
UsageVector finally_vector;
UsageVector finally_origins;
bool emit_finally;
bool in_try;
public FlowBranchingException (FlowBranching parent,
ExceptionStatement stmt)
: base (parent, BranchingType.Exception, SiblingType.Try,
null, stmt.loc)
{
this.stmt = stmt;
this.emit_finally = true;
}
public FlowBranchingException (FlowBranching parent, Block block, Location loc)
: base (parent, BranchingType.Exception, SiblingType.Try, block, loc)
{ }
protected override void AddSibling (UsageVector sibling)
{
@@ -1439,19 +1415,6 @@ namespace Mono.CSharp
finally_origins = vector;
}
public override void StealFinallyClauses (ref ArrayList list)
{
if (list == null)
list = new ArrayList ();
list.Add (stmt);
emit_finally = false;
base.StealFinallyClauses (ref list);
}
public bool EmitFinally {
get { return emit_finally; }
}
public override LabeledStatement LookupLabel (string name, Location loc)
{
if (current_vector.Block == null)
@@ -1698,10 +1661,6 @@ namespace Mono.CSharp
Fields = new FieldInfo [Count];
public_fields.CopyTo (Fields, 0);
non_public_fields.CopyTo (Fields, CountPublic);
} else if (type is GenericTypeParameterBuilder) {
CountPublic = CountNonPublic = Count = 0;
Fields = new FieldInfo [0];
} else {
FieldInfo[] public_fields = type.GetFields (
BindingFlags.Instance|BindingFlags.Public);
@@ -2031,14 +1990,14 @@ namespace Mono.CSharp
if ((mod & Parameter.Modifier.OUT) == 0)
continue;
// Dont allocate till we find an out var.
if (map == null)
map = new VariableInfo [Count];
map [i] = new VariableInfo (ip.ParameterName (i),
TypeManager.GetElementType (ip.ParameterType (i)), i, Length);
Length += map [i].Length;
}
}
@@ -2281,7 +2240,7 @@ namespace Mono.CSharp
{
if (vector != null)
return;
vector = new BitArray (Count, false);
if (InheritsFrom != null)
Vector = InheritsFrom.Vector;
File renamed without changes.
File renamed without changes.
+56
View File
@@ -0,0 +1,56 @@
//
// generic.cs: Support classes for generics
//
// Author:
// Miguel de Icaza ([email protected])
//
// (C) 2003 Ximian, Inc.
//
using System;
using System.Collections;
namespace Mono.CSharp {
//
// Tracks the constraints for a type parameter
//
class Constraints {
string type_parameter;
ArrayList constraints;
//
// type_parameter is the identifier, constraints is an arraylist of
// Expressions (with types) or `true' for the constructor constraint.
//
public Constraints (string type_parameter, ArrayList constraints)
{
this.type_parameter = type_parameter;
this.constraints = constraints;
}
}
//
// This type represents a generic type parameter reference.
//
// These expressions are born in a fully resolved state.
//
public class TypeParameterExpr : TypeExpr {
string type_parameter;
public TypeParameterExpr (string type_parameter, Location l)
: base (typeof (object), l)
{
this.type_parameter = type_parameter;
}
public override string ToString ()
{
return "TypeParameter[" + type_parameter + "]";
}
public void Error_CannotUseAsUnmanagedType (Location loc)
{
Report.Error (-203, loc, "Can not use type parameter as unamanged type");
}
}
}
+61
View File
@@ -0,0 +1,61 @@
//
// GenericParser.cs: The Base Parser for the Mono compilers
//
// Author: A Rafael D Teixeira ([email protected])
//
// Licensed under the terms of the GNU GPL
//
// Copyright (C) 2001 Ximian, Inc.
//
using System;
using System.Text;
namespace Mono.Languages
{
using System.Collections;
/// <summary>
/// Base class to support multiple Jay generated parsers
/// </summary>
public abstract class GenericParser
{
// Name of the file we are parsing
public string name;
// Input stream to parse from.
public System.IO.Stream input;
public abstract void parse ();
public virtual string[] extensions()
{
string [] list = { ".cs" };
return list;
}
public GenericParser()
{
//
// DO NOTHING: Derived classes should do their iniatilization here duties
//
}
protected bool yacc_verbose_flag = false;
public bool yacc_verbose
{
set
{
yacc_verbose_flag = value;
}
get
{
return yacc_verbose_flag;
}
}
}
}
+694
View File
@@ -0,0 +1,694 @@
//
// iterators.cs: Support for implementing iterators
//
// Author:
// Miguel de Icaza ([email protected])
//
// (C) 2003 Ximian, Inc.
//
// TODO:
// Flow analysis for Yield.
// Emit calls to parent object constructor.
//
// Generics note:
// Current should be defined to return T, and IEnumerator.Current returns object
//
using System;
using System.Collections;
using System.Reflection;
using System.Reflection.Emit;
namespace Mono.CSharp {
public interface IIteratorContainer {
//
// Invoked if a yield statement is found in the body
//
void SetYields ();
}
public class Yield : Statement {
public Expression expr;
bool in_exc;
public Yield (Expression expr, Location l)
{
this.expr = expr;
loc = l;
}
public static bool CheckContext (EmitContext ec, Location loc)
{
if (ec.CurrentBranching.InFinally (true)){
Report.Error (-208, loc, "yield statement can not appear in finally clause");
return false;
}
if (ec.CurrentBranching.InCatch ()){
Report.Error (-209, loc, "yield statement can not appear in the catch clause");
return false;
}
if (ec.InAnonymousMethod){
Report.Error (-209, loc, "yield statement can not appear inside an anonymoud method");
return false;
}
//
// FIXME: Missing check for Yield inside try block that contains catch clauses
//
return true;
}
public override bool Resolve (EmitContext ec)
{
expr = expr.Resolve (ec);
if (expr == null)
return false;
if (!CheckContext (ec, loc))
return false;
in_exc = ec.CurrentBranching.InTryOrCatch (false);
Type iterator_type = IteratorHandler.Current.IteratorType;
if (expr.Type != iterator_type){
expr = Convert.ImplicitConversionRequired (ec, expr, iterator_type, loc);
if (expr == null)
return false;
}
return true;
}
protected override void DoEmit (EmitContext ec)
{
IteratorHandler.Current.MarkYield (ec, expr, in_exc);
}
}
public class YieldBreak : Statement {
public YieldBreak (Location l)
{
loc = l;
}
public override bool Resolve (EmitContext ec)
{
if (!Yield.CheckContext (ec, loc))
return false;
ec.CurrentBranching.CurrentUsageVector.Goto ();
return true;
}
protected override void DoEmit (EmitContext ec)
{
IteratorHandler.Current.EmitYieldBreak (ec.ig, true);
}
}
public class IteratorHandler {
//
// Points to the current iterator handler, will be probed by
// Yield and YieldBreak to get their context information
//
public static IteratorHandler Current;
//
// The typebuilder to the proxy class we create
//
TypeBuilder enumerator_proxy_class;
TypeBuilder enumerable_proxy_class;
//
// The type of this iterator, object by default.
//
public Type IteratorType;
//
// The members we create on the proxy class
//
MethodBuilder move_next_method;
MethodBuilder reset_method;
MethodBuilder get_current_method;
MethodBuilder dispose_method;
MethodBuilder getenumerator_method;
PropertyBuilder current_property;
ConstructorBuilder enumerator_proxy_constructor;
ConstructorBuilder enumerable_proxy_constructor;
//
// The PC for the state machine.
//
FieldBuilder pc_field;
//
// The value computed for Current
//
FieldBuilder current_field;
//
// Used to reference fields on the container class (instance methods)
//
public FieldBuilder this_field;
public FieldBuilder enumerable_this_field;
//
// References the parameters
//
public FieldBuilder [] parameter_fields;
FieldBuilder [] enumerable_parameter_fields;
//
// The state as we generate the iterator
//
ArrayList resume_labels = new ArrayList ();
int pc;
//
// Context from the original method
//
string name;
TypeContainer container;
Type return_type;
Type [] param_types;
InternalParameters parameters;
Block original_block;
Location loc;
int modifiers;
static int proxy_count;
public void EmitYieldBreak (ILGenerator ig, bool add_return)
{
ig.Emit (OpCodes.Ldarg_0);
IntConstant.EmitInt (ig, -1);
ig.Emit (OpCodes.Stfld, pc_field);
if (add_return){
ig.Emit (OpCodes.Ldc_I4_0);
ig.Emit (OpCodes.Ret);
}
}
void EmitThrowInvalidOp (ILGenerator ig)
{
ig.Emit (OpCodes.Newobj, TypeManager.invalid_operation_ctor);
ig.Emit (OpCodes.Throw);
}
void Create_MoveNext ()
{
move_next_method = enumerator_proxy_class.DefineMethod (
"System.IEnumerator.MoveNext",
MethodAttributes.HideBySig | MethodAttributes.NewSlot |
MethodAttributes.Virtual,
CallingConventions.HasThis, TypeManager.bool_type, TypeManager.NoTypes);
enumerator_proxy_class.DefineMethodOverride (move_next_method, TypeManager.bool_movenext_void);
ILGenerator ig = move_next_method.GetILGenerator ();
EmitContext ec = new EmitContext (
container, loc, ig,
TypeManager.void_type, modifiers);
Label dispatcher = ig.DefineLabel ();
ig.Emit (OpCodes.Br, dispatcher);
Label entry_point = ig.DefineLabel ();
ig.MarkLabel (entry_point);
resume_labels.Add (entry_point);
Current = this;
SymbolWriter sw = CodeGen.SymbolWriter;
if ((sw != null) && !Location.IsNull (loc) && !Location.IsNull (original_block.EndLocation)) {
sw.OpenMethod (container, move_next_method, loc, original_block.EndLocation);
ec.EmitTopBlock (original_block, parameters, loc);
sw.CloseMethod ();
} else {
ec.EmitTopBlock (original_block, parameters, loc);
}
Current = null;
EmitYieldBreak (ig, true);
//
// FIXME: Split the switch in blocks that can be consumed by switch.
//
ig.MarkLabel (dispatcher);
Label [] labels = new Label [resume_labels.Count];
resume_labels.CopyTo (labels);
ig.Emit (OpCodes.Ldarg_0);
ig.Emit (OpCodes.Ldfld, pc_field);
ig.Emit (OpCodes.Switch, labels);
ig.Emit (OpCodes.Ldc_I4_0);
ig.Emit (OpCodes.Ret);
}
//
// Invoked when a local variable declaration needs to be mapped to
// a field in our proxy class
//
// Prefixes registered:
// v_ for EmitContext.MapVariable
// s_ for Storage
//
public FieldBuilder MapVariable (string pfx, string name, Type t)
{
return enumerator_proxy_class.DefineField (pfx + name, t, FieldAttributes.Public);
}
void Create_Reset ()
{
reset_method = enumerator_proxy_class.DefineMethod (
"System.IEnumerator.Reset",
MethodAttributes.HideBySig | MethodAttributes.NewSlot |
MethodAttributes.Virtual,
CallingConventions.HasThis, TypeManager.void_type, TypeManager.NoTypes);
enumerator_proxy_class.DefineMethodOverride (reset_method, TypeManager.void_reset_void);
ILGenerator ig = reset_method.GetILGenerator ();
EmitThrowInvalidOp (ig);
}
void Create_Current ()
{
get_current_method = enumerator_proxy_class.DefineMethod (
"System.IEnumerator.get_Current",
MethodAttributes.HideBySig | MethodAttributes.SpecialName |
MethodAttributes.NewSlot | MethodAttributes.Virtual,
CallingConventions.HasThis, TypeManager.object_type, TypeManager.NoTypes);
enumerator_proxy_class.DefineMethodOverride (get_current_method, TypeManager.object_getcurrent_void);
current_property = enumerator_proxy_class.DefineProperty (
"Current",
PropertyAttributes.RTSpecialName | PropertyAttributes.SpecialName,
TypeManager.object_type, null);
current_property.SetGetMethod (get_current_method);
ILGenerator ig = get_current_method.GetILGenerator ();
ig.Emit (OpCodes.Ldarg_0);
ig.Emit (OpCodes.Ldfld, pc_field);
ig.Emit (OpCodes.Ldc_I4_0);
Label return_current = ig.DefineLabel ();
ig.Emit (OpCodes.Bgt, return_current);
EmitThrowInvalidOp (ig);
ig.MarkLabel (return_current);
ig.Emit (OpCodes.Ldarg_0);
ig.Emit (OpCodes.Ldfld, current_field);
ig.Emit (OpCodes.Ret);
}
void Create_Dispose ()
{
dispose_method = enumerator_proxy_class.DefineMethod (
"System.IDisposable.Dispose",
MethodAttributes.HideBySig | MethodAttributes.SpecialName |
MethodAttributes.NewSlot | MethodAttributes.Virtual,
CallingConventions.HasThis, TypeManager.void_type, TypeManager.NoTypes);
enumerator_proxy_class.DefineMethodOverride (dispose_method, TypeManager.void_dispose_void);
ILGenerator ig = dispose_method.GetILGenerator ();
EmitYieldBreak (ig, false);
ig.Emit (OpCodes.Ret);
}
void Create_GetEnumerator ()
{
getenumerator_method = enumerable_proxy_class.DefineMethod (
"IEnumerable.GetEnumerator",
MethodAttributes.HideBySig | MethodAttributes.SpecialName |
MethodAttributes.NewSlot | MethodAttributes.Virtual,
CallingConventions.HasThis, TypeManager.ienumerator_type, TypeManager.NoTypes);
enumerable_proxy_class.DefineMethodOverride (getenumerator_method, TypeManager.ienumerable_getenumerator_void);
ILGenerator ig = getenumerator_method.GetILGenerator ();
ig.Emit (OpCodes.Newobj, (ConstructorInfo) enumerator_proxy_constructor);
if (enumerable_this_field != null || parameters.Count > 0){
LocalBuilder obj = ig.DeclareLocal (enumerator_proxy_class);
ig.Emit (OpCodes.Stloc, obj);
if (enumerable_this_field != null){
ig.Emit (OpCodes.Ldloc, obj);
ig.Emit (OpCodes.Ldarg_0);
ig.Emit (OpCodes.Ldfld, enumerable_this_field);
ig.Emit (OpCodes.Stfld, this_field);
}
for (int i = 0; i < parameters.Count; i++){
ig.Emit (OpCodes.Ldloc, obj);
ig.Emit (OpCodes.Ldarg_0);
ig.Emit (OpCodes.Ldfld, enumerable_parameter_fields [i]);
ig.Emit (OpCodes.Stfld, parameter_fields [i]);
}
ig.Emit (OpCodes.Ldloc, obj);
}
ig.Emit (OpCodes.Ret);
}
//
// Called back from Yield
//
public void MarkYield (EmitContext ec, Expression expr, bool in_exc)
{
ILGenerator ig = ec.ig;
// Store the new current
ig.Emit (OpCodes.Ldarg_0);
expr.Emit (ec);
ig.Emit (OpCodes.Stfld, current_field);
// increment pc
pc++;
ig.Emit (OpCodes.Ldarg_0);
IntConstant.EmitInt (ig, pc);
ig.Emit (OpCodes.Stfld, pc_field);
// Return ok
ig.Emit (OpCodes.Ldc_I4_1);
// Find out how to "leave"
if (in_exc || !ec.IsLastStatement){
Type old = ec.ReturnType;
ec.ReturnType = TypeManager.int32_type;
ig.Emit (OpCodes.Stloc, ec.TemporaryReturn ());
ec.ReturnType = old;
}
if (in_exc){
ec.NeedReturnLabel ();
ig.Emit (OpCodes.Leave, ec.ReturnLabel);
} else if (ec.IsLastStatement){
ig.Emit (OpCodes.Ret);
} else {
ec.NeedReturnLabel ();
ig.Emit (OpCodes.Br, ec.ReturnLabel);
}
Label resume_point = ig.DefineLabel ();
ig.MarkLabel (resume_point);
resume_labels.Add (resume_point);
}
//
// Creates the IEnumerator Proxy class
//
void MakeEnumeratorProxy ()
{
TypeExpr [] proxy_base_interfaces = new TypeExpr [2];
proxy_base_interfaces [0] = new TypeExpression (TypeManager.ienumerator_type, loc);
proxy_base_interfaces [1] = new TypeExpression (TypeManager.idisposable_type, loc);
Type [] proxy_base_itypes = new Type [2];
proxy_base_itypes [0] = TypeManager.ienumerator_type;
proxy_base_itypes [1] = TypeManager.idisposable_type;
TypeBuilder container_builder = container.TypeBuilder;
//
// Create the class
//
enumerator_proxy_class = container_builder.DefineNestedType (
"<Enumerator:" + name + ":" + (proxy_count++) + ">",
TypeAttributes.AutoLayout | TypeAttributes.Class |TypeAttributes.NestedPrivate,
TypeManager.object_type, proxy_base_itypes);
TypeManager.RegisterBuilder (enumerator_proxy_class, proxy_base_interfaces);
//
// Define our fields
//
pc_field = enumerator_proxy_class.DefineField ("PC", TypeManager.int32_type, FieldAttributes.Assembly);
current_field = enumerator_proxy_class.DefineField ("current", IteratorType, FieldAttributes.Assembly);
if ((modifiers & Modifiers.STATIC) == 0)
this_field = enumerator_proxy_class.DefineField ("THIS", container.TypeBuilder, FieldAttributes.Assembly);
parameter_fields = new FieldBuilder [parameters.Count];
for (int i = 0; i < parameters.Count; i++){
parameter_fields [i] = enumerator_proxy_class.DefineField (
String.Format ("tor{0}_{1}", i, parameters.ParameterName (i)),
parameters.ParameterType (i), FieldAttributes.Assembly);
}
//
// Define a constructor
//
enumerator_proxy_constructor = enumerator_proxy_class.DefineConstructor (
MethodAttributes.Public | MethodAttributes.HideBySig |
MethodAttributes.SpecialName | MethodAttributes.RTSpecialName,
CallingConventions.HasThis, TypeManager.NoTypes);
InternalParameters parameter_info = new InternalParameters (
TypeManager.NoTypes, Parameters.EmptyReadOnlyParameters);
TypeManager.RegisterMethod (enumerator_proxy_constructor, parameter_info, TypeManager.NoTypes);
//
// Our constructor
//
ILGenerator ig = enumerator_proxy_constructor.GetILGenerator ();
ig.Emit (OpCodes.Ldarg_0);
ig.Emit (OpCodes.Call, TypeManager.object_ctor);
ig.Emit (OpCodes.Ret);
}
//
// Creates the IEnumerable proxy class
//
void MakeEnumerableProxy ()
{
TypeBuilder container_builder = container.TypeBuilder;
Type [] proxy_base_interfaces = new Type [1];
proxy_base_interfaces [0] = TypeManager.ienumerable_type;
//
// Creates the Enumerable proxy class.
//
enumerable_proxy_class = container_builder.DefineNestedType (
"<Enumerable:" + name + ":" + (proxy_count++)+ ">",
TypeAttributes.AutoLayout | TypeAttributes.Class |TypeAttributes.NestedPublic,
TypeManager.object_type, proxy_base_interfaces);
//
// Constructor
//
if ((modifiers & Modifiers.STATIC) == 0){
enumerable_this_field = enumerable_proxy_class.DefineField (
"THIS", container.TypeBuilder, FieldAttributes.Assembly);
}
enumerable_parameter_fields = new FieldBuilder [parameters.Count];
for (int i = 0; i < parameters.Count; i++){
enumerable_parameter_fields [i] = enumerable_proxy_class.DefineField (
String.Format ("able{0}_{1}", i, parameters.ParameterName (i)),
parameters.ParameterType (i), FieldAttributes.Assembly);
}
enumerable_proxy_constructor = enumerable_proxy_class.DefineConstructor (
MethodAttributes.Public | MethodAttributes.HideBySig |
MethodAttributes.SpecialName | MethodAttributes.RTSpecialName,
CallingConventions.HasThis, TypeManager.NoTypes);
InternalParameters parameter_info = new InternalParameters (
TypeManager.NoTypes, Parameters.EmptyReadOnlyParameters);
TypeManager.RegisterMethod (enumerable_proxy_constructor, parameter_info, TypeManager.NoTypes);
ILGenerator ig = enumerable_proxy_constructor.GetILGenerator ();
ig.Emit (OpCodes.Ldarg_0);
ig.Emit (OpCodes.Call, TypeManager.object_ctor);
ig.Emit (OpCodes.Ret);
}
//
// Populates the Enumerator Proxy class
//
void PopulateProxy ()
{
RootContext.RegisterHelperClass (enumerator_proxy_class);
Create_MoveNext ();
Create_Reset ();
Create_Current ();
Create_Dispose ();
if (IsIEnumerable (return_type)){
Create_GetEnumerator ();
RootContext.RegisterHelperClass (enumerable_proxy_class);
}
}
//
// This is invoked by the EmitCode hook
//
void SetupIterator ()
{
PopulateProxy ();
}
//
// Our constructor
//
public IteratorHandler (string name, TypeContainer container, Type return_type, Type [] param_types,
InternalParameters parameters, int modifiers, Location loc)
{
this.name = name;
this.container = container;
this.return_type = return_type;
this.param_types = param_types;
this.parameters = parameters;
this.modifiers = modifiers;
this.loc = loc;
IteratorType = TypeManager.object_type;
RootContext.EmitCodeHook += new RootContext.Hook (SetupIterator);
}
//
// This class is just an expression that evaluates to a type, and the
// type is our internal proxy class. Used in the generated new body
// of the original method
//
class NewInnerType : Expression {
IteratorHandler handler;
public NewInnerType (IteratorHandler handler, Location l)
{
this.handler = handler;
eclass = ExprClass.Value;
loc = l;
}
public override Expression DoResolve (EmitContext ec)
{
// Create the proxy class type.
handler.MakeEnumeratorProxy ();
if (IsIEnumerable (handler.return_type))
handler.MakeEnumerableProxy ();
type = handler.return_type;
return this;
}
public override Expression ResolveAsTypeStep (EmitContext ec)
{
return DoResolve (ec);
}
public override void Emit (EmitContext ec)
{
ILGenerator ig = ec.ig;
FieldBuilder this_field = null;
bool is_ienumerable = IsIEnumerable (handler.return_type);
Type temp_type;
if (is_ienumerable){
temp_type = handler.enumerable_proxy_class;
ig.Emit (OpCodes.Newobj, (ConstructorInfo) handler.enumerable_proxy_constructor);
this_field = handler.enumerable_this_field;
} else {
temp_type = handler.enumerator_proxy_class;
ig.Emit (OpCodes.Newobj, (ConstructorInfo) handler.enumerator_proxy_constructor);
this_field = handler.this_field;
}
if (this_field == null && handler.parameters.Count == 0)
return;
LocalBuilder temp = ec.GetTemporaryLocal (temp_type);
ig.Emit (OpCodes.Stloc, temp);
//
// Initialize This
//
int first = 0;
if (this_field != null){
ig.Emit (OpCodes.Ldloc, temp);
ig.Emit (OpCodes.Ldarg_0);
if (handler.container is Struct)
ig.Emit (OpCodes.Ldobj, handler.container.TypeBuilder);
ig.Emit (OpCodes.Stfld, this_field);
first = 1;
}
for (int i = 0; i < handler.parameters.Count; i++){
ig.Emit (OpCodes.Ldloc, temp);
ParameterReference.EmitLdArg (ig, i + first);
if (is_ienumerable)
ig.Emit (OpCodes.Stfld, handler.enumerable_parameter_fields [i]);
else
ig.Emit (OpCodes.Stfld, handler.parameter_fields [i]);
}
//
// Initialize fields
//
ig.Emit (OpCodes.Ldloc, temp);
ec.FreeTemporaryLocal (temp, handler.container.TypeBuilder);
}
}
//
// This return statement tricks return into not flagging an error for being
// used in a Yields method
//
class NoCheckReturn : Return {
public NoCheckReturn (Expression expr, Location loc) : base (expr, loc)
{
}
public override bool Resolve (EmitContext ec)
{
ec.InIterator = false;
bool ret_val = base.Resolve (ec);
ec.InIterator = true;
return ret_val;
}
}
static bool IsIEnumerable (Type t)
{
return t == TypeManager.ienumerable_type || TypeManager.ImplementsInterface (t, TypeManager.ienumerable_type);
}
static bool IsIEnumerator (Type t)
{
return t == TypeManager.ienumerator_type || TypeManager.ImplementsInterface (t, TypeManager.ienumerator_type);
}
//
// Returns the new block for the method, or null on failure
//
public Block Setup (Block block)
{
if (!(IsIEnumerator (return_type) || IsIEnumerable (return_type))){
Report.Error (
-205, loc, String.Format (
"The method `{0}' contains a yield statement, but has an invalid return type for an iterator `{1}'",
name, TypeManager.CSharpName (return_type)));
return null;
}
for (int i = 0; i < parameters.Count; i++){
Parameter.Modifier mod = parameters.ParameterModifier (i);
if ((mod & (Parameter.Modifier.REF | Parameter.Modifier.OUT)) != 0){
Report.Error (-207, loc, String.Format (
"Parameter {0} of `{1}' is {2} and not allowed for an iterator method",
i+1, name, parameters.ParameterDesc (i)));
return null;
}
}
original_block = block;
Block b = new Block (null);
// return new InnerClass ()
b.AddStatement (new NoCheckReturn (new NewInnerType (this, loc), loc));
return b;
}
}
}
+2 -20
View File
@@ -22,18 +22,6 @@ using System;
using System.Reflection;
using System.Reflection.Emit;
//
// I put System.Null just so we do not have to special case it on
// TypeManager.CSharpName
//
namespace System {
//
// Represents the Null Type, just used as a placeholder for the type in NullLiteral
//
public class Null {
}
}
namespace Mono.CSharp {
public class NullLiteral : Constant {
@@ -61,7 +49,7 @@ namespace Mono.CSharp {
public override Expression DoResolve (EmitContext ec)
{
type = typeof (System.Null);
type = TypeManager.object_type;
return this;
}
@@ -70,12 +58,6 @@ namespace Mono.CSharp {
ec.ig.Emit (OpCodes.Ldnull);
}
public override bool IsNegative {
get {
return false;
}
}
public override bool IsZeroInteger {
get { return true; }
}
@@ -91,7 +73,7 @@ namespace Mono.CSharp {
{
Null = new NullPointer ();
}
private NullPointer ()
{
type = TypeManager.object_type;
+14 -20
View File
@@ -10,7 +10,7 @@
using System;
using System.IO;
using System.Collections;
using Mono.CompilerServices.SymbolWriter;
using System.Diagnostics.SymbolStore;
namespace Mono.CSharp {
/// <summary>
@@ -20,11 +20,11 @@ namespace Mono.CSharp {
/// This is intentionally a class and not a struct since we need
/// to pass this by reference.
/// </remarks>
public sealed class SourceFile : ISourceFile {
public sealed class SourceFile {
public readonly string Name;
public readonly string Path;
public readonly int Index;
public SourceFileEntry SourceFileEntry;
public ISymbolDocumentWriter SymbolDocument;
public bool HasLineDirective;
public SourceFile (string name, string path, int index)
@@ -33,16 +33,6 @@ namespace Mono.CSharp {
this.Name = name;
this.Path = path;
}
SourceFileEntry ISourceFile.Entry {
get { return SourceFileEntry; }
}
public override string ToString ()
{
return String.Format ("SourceFile ({0}:{1}:{2}:{3})",
Name, Path, Index, SourceFileEntry);
}
}
/// <summary>
@@ -84,7 +74,9 @@ namespace Mono.CSharp {
string path = Path.GetFullPath (name);
if (source_files.Contains (path)){
Report.Warning (2002, name, "Source file '{0}' specified multiple times");
Report.Warning (
2002,
"Source file `" + name + "' specified multiple times");
return;
}
@@ -150,14 +142,15 @@ namespace Mono.CSharp {
}
// <remarks>
// If we're compiling with debugging support, this is called between parsing
// and code generation to register all the source files with the
// symbol writer.
// If we're compiling with debugging support, this is called between parsing and
// code generation to register all the source files with the symbol writer. //
// </remarks>
static public void DefineSymbolDocuments (SymbolWriter symwriter)
{
foreach (SourceFile file in source_list) {
file.SourceFileEntry = symwriter.DefineDocument (file.Path);
if (file.HasLineDirective)
continue;
file.SymbolDocument = symwriter.DefineDocument (file.Path);
}
}
@@ -220,12 +213,13 @@ namespace Mono.CSharp {
// to the location's source file.
//
// If we don't have a symbol writer, this property is always null.
public SourceFile SourceFile {
public ISymbolDocumentWriter SymbolDocument {
get {
int index = token & source_mask;
if (index == 0)
return null;
return (SourceFile) source_list [index - 1];
SourceFile file = (SourceFile) source_list [index - 1];
return file.SymbolDocument;
}
}
}
@@ -1,7 +1,4 @@
<configuration>
<startup>
<supportedRuntime version="v1.1.4322"/>
</startup>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
+34
View File
@@ -0,0 +1,34 @@
AssemblyInfo.cs
anonymous.cs
assign.cs
attribute.cs
driver.cs
cs-tokenizer.cs
cfold.cs
class.cs
codegen.cs
const.cs
constant.cs
convert.cs
decl.cs
delegate.cs
enum.cs
ecore.cs
expression.cs
flowanalysis.cs
genericparser.cs
iterators.cs
literal.cs
location.cs
modifiers.cs
namespace.cs
parameter.cs
pending.cs
report.cs
rootcontext.cs
statement.cs
support.cs
typemanager.cs
symbolwriter.cs
tree.cs
CryptoConvert.cs
@@ -31,7 +31,6 @@ namespace Mono.CSharp {
// We use this internally to flag that the method contains an iterator
//
public const int METHOD_YIELDS = 0x8000;
public const int METHOD_GENERIC = 0x10000;
public const int Accessibility =
PUBLIC | PROTECTED | INTERNAL | PRIVATE;
@@ -113,7 +112,7 @@ namespace Mono.CSharp {
// If we do not have static constructors, static methods
// can be invoked without initializing the type.
if (!caller.UserDefinedStaticConstructor &&
(caller.Kind != Kind.Interface))
!(caller is Interface))
t |= TypeAttributes.BeforeFieldInit;
return t;
+57 -103
View File
@@ -14,7 +14,7 @@ namespace Mono.CSharp {
/// <summary>
/// Keeps track of the namespaces defined in the C# code.
/// </summary>
public class Namespace : IAlias {
public class Namespace {
static ArrayList all_namespaces = new ArrayList ();
static Hashtable namespaces_map = new Hashtable ();
@@ -88,9 +88,9 @@ namespace Mono.CSharp {
return Root.GetNamespace (name, create);
}
public IAlias Lookup (DeclSpace ds, string name, Location loc)
public object Lookup (DeclSpace ds, string name)
{
IAlias o = Lookup (name);
object o = Lookup (name);
Type t;
DeclSpace tdecl = o as DeclSpace;
@@ -98,18 +98,21 @@ namespace Mono.CSharp {
t = tdecl.DefineType ();
if ((ds == null) || ds.CheckAccessLevel (t))
return new TypeExpression (t, loc);
return t;
}
Namespace ns = GetNamespace (name, false);
if (ns != null)
return ns;
t = TypeManager.LookupType (DeclSpace.MakeFQN (fullname, name));
//
// The type is not a nested type here
//
t = TypeManager.LookupTypeDirect (DeclSpace.MakeFQN (fullname, name));
if ((t == null) || ((ds != null) && !ds.CheckAccessLevel (t)))
return null;
return new TypeExpression (t, loc);
return t;
}
public void AddNamespaceEntry (NamespaceEntry entry)
@@ -117,14 +120,14 @@ namespace Mono.CSharp {
entries.Add (entry);
}
public void DefineName (string name, IAlias o)
public void DefineName (string name, object o)
{
defined_names.Add (name, o);
}
public IAlias Lookup (string name)
public object Lookup (string name)
{
return (IAlias) defined_names [name];
return defined_names [name];
}
static public ArrayList UserDefinedNamespaces {
@@ -179,16 +182,6 @@ namespace Mono.CSharp {
else
return String.Format ("Namespace ({0})", Name);
}
bool IAlias.IsType {
get { return false; }
}
TypeExpr IAlias.Type {
get {
throw new InvalidOperationException ();
}
}
}
public class NamespaceEntry
@@ -241,11 +234,11 @@ namespace Mono.CSharp {
public class AliasEntry {
public readonly string Name;
public readonly MemberName Alias;
public readonly Expression Alias;
public readonly NamespaceEntry NamespaceEntry;
public readonly Location Location;
public AliasEntry (NamespaceEntry entry, string name, MemberName alias, Location loc)
public AliasEntry (NamespaceEntry entry, string name, Expression alias, Location loc)
{
Name = name;
Alias = alias;
@@ -253,43 +246,23 @@ namespace Mono.CSharp {
Location = loc;
}
IAlias resolved;
object resolved;
public IAlias Resolve ()
public object Resolve ()
{
if (resolved != null)
return resolved;
//
// GENERICS: Cope with the expression and not with the string
// this will fail with `using A = Stack<int>'
//
string alias = Alias.GetTypeName ();
// According to section 16.3.1, the namespace-or-type-name is resolved
// as if the immediately containing namespace body has no using-directives.
resolved = NamespaceEntry.Lookup (
null, alias, Alias.CountTypeArguments, true, false, Location);
NamespaceEntry curr_ns = NamespaceEntry.Parent;
NamespaceEntry curr_ns = NamespaceEntry;
string alias = Alias.ToString ();
while ((curr_ns != null) && (resolved == null)) {
resolved = curr_ns.Lookup (
null, alias, Alias.CountTypeArguments,
false, false, Location);
resolved = curr_ns.Lookup (null, alias, false, Location);
if (resolved == null)
curr_ns = curr_ns.Parent;
}
if (resolved == null)
return null;
if (resolved.IsType)
resolved = new TypeAliasExpression (
resolved.Type, Alias.TypeArguments, Location);
return resolved;
}
}
@@ -344,7 +317,7 @@ namespace Mono.CSharp {
}
}
public void DefineName (string name, IAlias o)
public void DefineName (string name, object o)
{
ns.DefineName (name, o);
}
@@ -365,12 +338,11 @@ namespace Mono.CSharp {
if (using_clauses == null)
using_clauses = new ArrayList ();
if (RootContext.WarningLevel >= 3) {
foreach (UsingEntry old_entry in using_clauses){
if (old_entry.Name == ns){
Report.Warning (105, loc, "The using directive for '{0}' appeared previously in this namespace", ns);
return;
}
foreach (UsingEntry old_entry in using_clauses){
if (old_entry.Name == ns){
Report.Warning (105, loc, "The using directive for '" + ns +
"' appeared previously in this namespace");
return;
}
}
@@ -378,23 +350,18 @@ namespace Mono.CSharp {
using_clauses.Add (ue);
}
public void UsingAlias (string name, MemberName alias, Location loc)
public void UsingAlias (string alias, Expression namespace_or_type, Location loc)
{
if (DeclarationFound){
Report.Error (1529, loc, "A using clause must precede all other namespace elements");
return;
}
if (aliases == null)
aliases = new Hashtable ();
if (aliases.Contains (name)){
Report.Error (1537, loc, "The using alias `" + name +
if (aliases.Contains (alias)){
Report.Error (1537, loc, "The using alias `" + alias +
"' appeared previously in this namespace");
return;
}
aliases [name] = new AliasEntry (this, name, alias, loc);
aliases [alias] = new AliasEntry (this, alias, namespace_or_type, loc);
}
protected AliasEntry GetAliasEntry (string alias)
@@ -409,20 +376,25 @@ namespace Mono.CSharp {
return entry;
}
public IAlias LookupAlias (string alias)
public string LookupAlias (string alias)
{
AliasEntry entry = GetAliasEntry (alias);
if (entry == null)
return null;
return entry.Resolve ();
object resolved = entry.Resolve ();
if (resolved == null)
return null;
else if (resolved is Namespace)
return ((Namespace) resolved).Name;
else
return ((Type) resolved).FullName;
}
public IAlias Lookup (DeclSpace ds, string name, int num_type_params,
bool ignore_using, bool silent, Location loc)
public object Lookup (DeclSpace ds, string name, bool silent, Location loc)
{
IAlias o;
object o;
Namespace ns;
//
@@ -433,41 +405,36 @@ namespace Mono.CSharp {
string first = name.Substring (0, pos);
string last = name.Substring (pos + 1);
o = Lookup (ds, first, 0, ignore_using, silent, loc);
o = Lookup (ds, first, silent, loc);
if (o == null)
return null;
ns = o as Namespace;
if (ns != null) {
o = ns.Lookup (ds, last, loc);
return o;
}
if (ns != null)
return ns.Lookup (ds, last);
Type nested = TypeManager.LookupType (o.Name + "." + last);
Type nested = TypeManager.LookupType ((((Type) o).Name + "." + last));
if ((nested == null) || ((ds != null) && !ds.CheckAccessLevel (nested)))
return null;
return new TypeExpression (nested, loc);
return nested;
}
//
// Check whether it's a namespace.
//
o = NS.Lookup (ds, name, loc);
o = NS.Lookup (ds, name);
if (o != null)
return o;
if (ignore_using)
return null;
//
// Check aliases.
//
AliasEntry entry = GetAliasEntry (name);
if (entry != null) {
IAlias alias = entry.Resolve ();
if (alias != null)
return alias;
o = entry.Resolve ();
if (o != null)
return o;
}
if (name.IndexOf ('.') > 0)
@@ -476,13 +443,13 @@ namespace Mono.CSharp {
//
// Check using entries.
//
IAlias t = null, match = null;
Type t = null, match = null;
foreach (Namespace using_ns in GetUsingTable ()) {
match = using_ns.Lookup (ds, name, loc);
if ((match != null) && match.IsType){
match = using_ns.Lookup (ds, name) as Type;
if (match != null){
if (t != null) {
if (!silent)
DeclSpace.Error_AmbiguousTypeReference (loc, name, t.Name, match.Name);
DeclSpace.Error_AmbiguousTypeReference (loc, name, t, match);
return null;
} else {
t = match;
@@ -535,11 +502,7 @@ namespace Mono.CSharp {
}
int parent_id = parent != null ? parent.symfile_id : 0;
if (file.SourceFileEntry == null)
return;
symfile_id = symwriter.DefineNamespace (
ns.Name, file.SourceFileEntry, using_list, parent_id);
symfile_id = symwriter.DefineNamespace (ns.Name, file, using_list, parent_id);
}
public int SymbolFileID {
@@ -604,10 +567,6 @@ namespace Mono.CSharp {
/// </summary>
public void VerifyUsing ()
{
TypeContainer dummy = new RootTypes ();
EmitContext ec = new EmitContext (
dummy, Location.Null, null, null, 0, false);
if (using_clauses != null){
foreach (UsingEntry ue in using_clauses){
if (ue.Resolve () != null)
@@ -619,17 +578,12 @@ namespace Mono.CSharp {
if (aliases != null){
foreach (DictionaryEntry de in aliases){
AliasEntry entry = (AliasEntry) de.Value;
IAlias alias = entry.Resolve ();
if (alias != null) {
if (alias.IsType)
alias.Type.ResolveType (ec);
AliasEntry alias = (AliasEntry) de.Value;
if (alias.Resolve () != null)
continue;
}
error246 (entry.Location, entry.Alias.ToString ());
error246 (alias.Location, alias.Alias.ToString ());
}
}
}
File renamed without changes.
+15 -55
View File
@@ -35,8 +35,8 @@ namespace Mono.CSharp {
if (marshal != null) {
builder.SetMarshal (marshal);
return;
}
Report.Warning (-24, a.Location, "The Microsoft Runtime cannot set this marshal info. Please use the Mono runtime instead.");
}
Report.Warning_T (-24, a.Location);
return;
}
@@ -46,7 +46,7 @@ namespace Mono.CSharp {
public override bool IsClsCompliaceRequired(DeclSpace ds)
{
return false;
}
}
}
/// <summary>
@@ -60,7 +60,7 @@ namespace Mono.CSharp {
builder = mb.DefineParameter (0, ParameterAttributes.None, "");
}
catch (ArgumentOutOfRangeException) {
Report.Warning (-28, location, "The Microsoft .NET Runtime 1.x does not permit setting custom attributes on the return type");
Report.Warning_T (-28, location);
}
}
@@ -82,7 +82,7 @@ namespace Mono.CSharp {
/// <summary>
/// Is never called
/// </summary>
public override string[] ValidAttributeTargets {
protected override string[] ValidAttributeTargets {
get {
return null;
}
@@ -90,11 +90,11 @@ namespace Mono.CSharp {
}
/// <summary>
/// Class for applying custom attributes on the implicit parameter type
/// of the 'set' method in properties, and the 'add' and 'remove' methods in events.
/// Class for applying custom attributes on the implicit parameter type
/// of the 'set' method in properties, and the 'add' and 'remove' methods in events.
/// </summary>
public class ImplicitParameter: ParameterBase {
public ImplicitParameter (MethodBuilder mb):
public class ImplicitParameter: ParameterBase {
public ImplicitParameter (MethodBuilder mb):
base (null)
{
builder = mb.DefineParameter (1, ParameterAttributes.None, "");
@@ -109,11 +109,11 @@ namespace Mono.CSharp {
/// <summary>
/// Is never called
/// </summary>
public override string[] ValidAttributeTargets {
protected override string[] ValidAttributeTargets {
get {
return null;
}
}
}
}
@@ -130,8 +130,7 @@ namespace Mono.CSharp {
OUT = 2,
PARAMS = 4,
// This is a flag which says that it's either REF or OUT.
ISBYREF = 8,
ARGLIST = 16
ISBYREF = 8
}
static string[] attribute_targets = new string [] { "param" };
@@ -139,7 +138,6 @@ namespace Mono.CSharp {
public readonly Expression TypeName;
public readonly Modifier ModFlags;
public readonly string Name;
GenericConstraints constraints;
Type parameter_type;
public Parameter (Expression type, string name, Modifier mod, Attributes attrs)
@@ -150,34 +148,12 @@ namespace Mono.CSharp {
TypeName = type;
}
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
{
if (a.Type == TypeManager.param_array_type) {
Report.Error (674, a.Location, "Do not use 'System.ParamArrayAttribute'. Use the 'params' keyword instead");
return;
}
base.ApplyAttributeBuilder (a, cb);
}
// <summary>
// Resolve is used in method definitions
// </summary>
public bool Resolve (DeclSpace ds, Location l)
{
TypeExpr texpr = ds.ResolveTypeExpr (TypeName, false, l);
if (texpr == null)
return false;
TypeParameterExpr tparam = texpr as TypeParameterExpr;
if (tparam != null)
constraints = tparam.TypeParameter.Constraints;
parameter_type = ds.ResolveType (texpr, l);
if (parameter_type.IsAbstract && parameter_type.IsSealed) {
Report.Error (721, l, "'{0}': static types cannot be used as parameters", GetSignatureForError ());
return false;
}
parameter_type = ds.ResolveType (TypeName, false, l);
if (parameter_type == TypeManager.void_type){
Report.Error (1536, l, "`void' parameter is not permitted");
@@ -209,12 +185,6 @@ namespace Mono.CSharp {
return parameter_type;
}
}
public GenericConstraints GenericConstraints {
get {
return constraints;
}
}
public ParameterAttributes Attributes {
get {
@@ -287,7 +257,7 @@ namespace Mono.CSharp {
}
}
public override string[] ValidAttributeTargets {
protected override string[] ValidAttributeTargets {
get {
return attribute_targets;
}
@@ -300,7 +270,6 @@ namespace Mono.CSharp {
public class Parameters {
public Parameter [] FixedParameters;
public readonly Parameter ArrayParameter;
public readonly bool HasArglist;
string signature;
Type [] types;
Location loc;
@@ -314,13 +283,6 @@ namespace Mono.CSharp {
loc = l;
}
public Parameters (Parameter [] fixed_parameters, bool has_arglist, Location l)
{
FixedParameters = fixed_parameters;
HasArglist = has_arglist;
loc = l;
}
/// <summary>
/// This is used to reuse a set of empty parameters, because they
/// are common
@@ -600,9 +562,7 @@ namespace Mono.CSharp {
public CallingConventions GetCallingConvention ()
{
if (HasArglist)
return CallingConventions.VarArgs;
else
// For now this is the only correc thing to do
return CallingConventions.Standard;
}
File renamed without changes.
File renamed without changes.
+12 -10
View File
@@ -150,14 +150,14 @@ namespace Mono.CSharp {
Type t = missing.Type;
if (t is TypeBuilder){
TypeContainer iface;
Interface iface;
iface = TypeManager.LookupInterface (t);
mi = iface.GetMethods ();
} else
mi = t.GetMethods ();
int count = mi.Length;
pending_implementations [i].type = t;
pending_implementations [i].optional = missing.Optional;
@@ -229,7 +229,7 @@ namespace Mono.CSharp {
//
// Completely broken. So we do it ourselves!
//
Type [] impl = TypeManager.GetExplicitInterfaces (type_builder);
TypeExpr [] impl = TypeManager.GetExplicitInterfaces (type_builder);
if (impl == null || impl.Length == 0)
return EmptyMissingInterfacesInfo;
@@ -237,17 +237,19 @@ namespace Mono.CSharp {
MissingInterfacesInfo [] ret = new MissingInterfacesInfo [impl.Length];
for (int i = 0; i < impl.Length; i++)
ret [i] = new MissingInterfacesInfo (impl [i]);
ret [i] = new MissingInterfacesInfo (impl [i].Type);
// we really should not get here because Object doesnt implement any
// interfaces. But it could implement something internal, so we have
// to handle that case.
if (type_builder.BaseType == null)
return ret;
Type [] parent_impls = TypeManager.GetInterfaces (type_builder.BaseType);
TypeExpr [] parent_impls = TypeManager.GetInterfaces (type_builder.BaseType);
foreach (Type t in parent_impls) {
foreach (TypeExpr te in parent_impls) {
Type t = te.Type;
for (int i = 0; i < ret.Length; i ++) {
if (t == ret [i].Type) {
ret [i].Optional = true;
@@ -382,7 +384,7 @@ namespace Mono.CSharp {
} else if ((need_proxy == null) && (name != m.Name))
continue;
if (!TypeManager.IsEqual (ret_type, m.ReturnType)){
if (ret_type != m.ReturnType){
if (!((ret_type == null && m.ReturnType == TypeManager.void_type) ||
(m.ReturnType == null && ret_type == TypeManager.void_type)))
continue;
@@ -396,9 +398,9 @@ namespace Mono.CSharp {
int j, top = args.Length;
bool fail = false;
for (j = 0; j < top; j++){
if (!TypeManager.IsEqual (tm.args [i][j], args[j])){
if (tm.args [i][j] != args[j]){
fail = true;
break;
}
+238 -324
View File
@@ -60,151 +60,77 @@ namespace Mono.CSharp {
//
static Hashtable warning_ignore_table;
static Hashtable warning_regions_table;
/// <summary>
/// List of symbols related to reported error/warning. You have to fill it before error/warning is reported.
/// </summary>
static StringCollection related_symbols = new StringCollection ();
abstract class AbstractMessage {
static void Check (int code)
{
if (code == expected_error) {
Environment.Exit (0);
}
}
public abstract bool IsWarning { get; }
public abstract string MessageType { get; }
public virtual void Print (int code, string location, string text)
{
if (code < 0)
code = 8000-code;
StringBuilder msg = new StringBuilder ();
if (location.Length != 0) {
msg.Append (location);
msg.Append (' ');
}
msg.AppendFormat ("{0} CS{1:0000}: {2}", MessageType, code, text);
Console.WriteLine (msg.ToString ());
foreach (string s in related_symbols) {
Console.WriteLine (String.Concat (s, MessageType, ')'));
}
related_symbols.Clear ();
if (Stacktrace)
Console.WriteLine (FriendlyStackTrace (new StackTrace (true)));
if (Fatal) {
if (!IsWarning || WarningsAreErrors)
throw new Exception (text);
}
Check (code);
}
public virtual void Print (int code, Location location, string text)
{
if (location.Equals (Location.Null)) {
Print (code, "", text);
return;
}
Print (code, String.Format ("{0}({1})", location.Name, location.Row), text);
}
}
sealed class WarningMessage: AbstractMessage {
Location loc = Location.Null;
readonly int Level;
public WarningMessage ():
this (-1) {}
public WarningMessage (int level)
{
struct WarningData {
public WarningData (int level, string text) {
Level = level;
Message = text;
}
public override bool IsWarning {
get { return true; }
}
bool IsEnabled (int code)
public bool IsEnabled ()
{
if (RootContext.WarningLevel < Level)
return false;
if (warning_ignore_table != null) {
if (warning_ignore_table.Contains (code)) {
return false;
}
}
if (warning_regions_table == null || loc.Equals (Location.Null))
return true;
WarningRegions regions = (WarningRegions)warning_regions_table [loc.Name];
return regions.IsWarningEnabled (code, loc.Row);
return RootContext.WarningLevel >= Level;
}
public override void Print(int code, string location, string text)
public string Format (params object[] args)
{
if (!IsEnabled (code)) {
related_symbols.Clear ();
return;
}
if (WarningsAreErrors) {
new ErrorMessage ().Print (code, location, text);
return;
}
Warnings++;
base.Print (code, location, text);
return String.Format (Message, args);
}
public override void Print(int code, Location location, string text)
{
loc = location;
base.Print (code, location, text);
}
public override string MessageType {
get {
return "warning";
}
}
readonly string Message;
readonly int Level;
}
sealed class ErrorMessage: AbstractMessage {
public override void Print(int code, string location, string text)
{
Errors++;
base.Print (code, location, text);
}
public override bool IsWarning {
get { return false; }
}
public override string MessageType {
get {
return "error";
}
}
}
public static void FeatureIsNotStandardized (Location loc, string feature)
static string GetErrorMsg (int error_no)
{
Report.Error (1644, loc, "Feature '{0}' cannot be used because it is not part of the standardized ISO C# language specification", feature);
switch (error_no) {
case 0122: return "'{0}' is inaccessible due to its protection level";
case 0619: return "'{0}' is obsolete: '{1}'";
case 0657: return "'{0}' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are '{1}'";
case 3001: return "Argument type '{0}' is not CLS-compliant";
case 3002: return "Return type of '{0}' is not CLS-compliant";
case 3003: return "Type of '{0}' is not CLS-compliant";
case 3005: return "Identifier '{0}' differing only in case is not CLS-compliant";
case 3006: return "Overloaded method '{0}' differing only in ref or out, or in array rank, is not CLS-compliant";
case 3008: return "Identifier '{0}' is not CLS-compliant";
case 3009: return "'{0}': base type '{1}' is not CLS-compliant";
case 3010: return "'{0}': CLS-compliant interfaces must have only CLS-compliant members";
case 3011: return "'{0}': only CLS-compliant members can be abstract";
case 3013: return "Added modules must be marked with the CLSCompliant attribute to match the assembly";
case 3014: return "'{0}' cannot be marked as CLS-compliant because the assembly does not have a CLSCompliant attribute";
case 3015: return "'{0}' has no accessible constructors which use only CLS-compliant types";
case 3016: return "Arrays as attribute arguments are not CLS-compliant";
}
throw new InternalErrorException (String.Format ("Missing error '{0}' text", error_no));
}
static WarningData GetWarningMsg (int warn_no)
{
switch (warn_no) {
case -24: return new WarningData (1, "The Microsoft Runtime cannot set this marshal info. Please use the Mono runtime instead.");
case -28: return new WarningData (1, "The Microsoft .NET Runtime 1.x does not permit setting custom attributes on the return type");
case 0612: return new WarningData (1, "'{0}' is obsolete");
case 0618: return new WarningData (2, "'{0}' is obsolete: '{1}'");
case 0672: return new WarningData (1, "Member '{0}' overrides obsolete member. Add the Obsolete attribute to '{0}'");
case 3012: return new WarningData (1, "You must specify the CLSCompliant attribute on the assembly, not the module, to enable CLS compliance checking");
case 3019: return new WarningData (2, "CLS compliance checking will not be performed on '{0}' because it is private or internal");
}
throw new InternalErrorException (String.Format ("Wrong warning number '{0}'", warn_no));
}
static void Check (int code)
{
if (code == expected_error){
if (Fatal)
throw new Exception ();
Environment.Exit (0);
}
}
public static string FriendlyStackTrace (Exception e)
@@ -247,34 +173,16 @@ namespace Mono.CSharp {
return sb.ToString ();
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// IF YOU ADD A NEW WARNING YOU HAVE TO DUPLICATE ITS ID HERE
public static bool IsValidWarning (int code)
{
int[] all_warnings = new int[] { 28, 67, 78, 105, 108, 109, 114, 192, 168, 169, 183, 184, 219, 251, 612, 618, 626, 628, 642, 649,
659, 660, 661, 672, 1030, 1522, 1616, 1691, 1692, 1901, 2002, 2023, 3012, 3019, 8024, 8028
};
foreach (int i in all_warnings) {
if (i == code)
return true;
}
return false;
}
[Obsolete ("Use SymbolRelatedToPreviousError for better error description")]
static public void LocationOfPreviousError (Location loc)
{
Console.WriteLine (String.Format ("{0}({1}) (Location of symbol related to previous error)", loc.Name, loc.Row));
}
static public void RuntimeMissingSupport (string feature)
{
Report.Error (-88, "Your .NET Runtime does not support '{0}'. Please use the latest Mono runtime instead.", feature);
}
}
/// <summary>
/// In most error cases is very useful to have information about symbol that caused the error.
/// Call this method before you call Report.Error when it makes sense.
/// In most error cases is very useful to have information about symbol that caused the error.
/// Call this method before you call Report.Error when it makes sense.
/// </summary>
static public void SymbolRelatedToPreviousError (Location loc, string symbol)
{
@@ -283,91 +191,181 @@ namespace Mono.CSharp {
static public void SymbolRelatedToPreviousError (MemberInfo mi)
{
TypeContainer temp_ds = TypeManager.LookupGenericTypeContainer (mi.DeclaringType);
DeclSpace temp_ds = TypeManager.LookupDeclSpace (mi.DeclaringType);
if (temp_ds == null) {
SymbolRelatedToPreviousError (mi.DeclaringType.Assembly.Location, TypeManager.GetFullNameSignature (mi));
} else {
MethodBase mb = mi as MethodBase;
if (mb != null) {
while (mb.Mono_IsInflatedMethod)
mb = mb.GetGenericMethodDefinition ();
IMethodData md = TypeManager.GetMethod (mb);
SymbolRelatedToPreviousError (md.Location, md.GetSignatureForError (temp_ds));
return;
}
string name = String.Concat (temp_ds.Name, ".", mi.Name);
MemberCore mc = temp_ds.GetDefinition (name);
SymbolRelatedToPreviousError (mc);
MemberCore mc = temp_ds.GetDefinition (name) as MemberCore;
SymbolRelatedToPreviousError (mc.Location, mc.GetSignatureForError ());
}
}
static public void SymbolRelatedToPreviousError (MemberCore mc)
{
SymbolRelatedToPreviousError (mc.Location, mc.GetSignatureForError ());
}
static public void SymbolRelatedToPreviousError (Type type)
{
DeclSpace temp_ds = TypeManager.LookupDeclSpace (type);
if (temp_ds == null)
SymbolRelatedToPreviousError (type.Assembly.Location, TypeManager.CSharpName (type));
else
SymbolRelatedToPreviousError (temp_ds.Location, TypeManager.CSharpName (type));
SymbolRelatedToPreviousError (type.Assembly.Location, TypeManager.CSharpName (type));
}
static void SymbolRelatedToPreviousError (string loc, string symbol)
{
related_symbols.Add (String.Format ("{0}: '{1}' (name of symbol related to previous ", loc, symbol));
related_symbols.Add (String.Format ("{0}: ('{1}' name of symbol related to previous error)", loc, symbol));
}
public static WarningRegions RegisterWarningRegion (Location location)
static public void RealError (string msg)
{
if (warning_regions_table == null)
warning_regions_table = new Hashtable ();
Errors++;
Console.WriteLine (msg);
WarningRegions regions = (WarningRegions)warning_regions_table [location.Name];
if (regions == null) {
regions = new WarningRegions ();
warning_regions_table.Add (location.Name, regions);
}
return regions;
foreach (string s in related_symbols)
Console.WriteLine (s);
related_symbols.Clear ();
if (Stacktrace)
Console.WriteLine (FriendlyStackTrace (new StackTrace (true)));
if (Fatal)
throw new Exception (msg);
}
static public void Warning (int code, int level, Location loc, string format, params object[] args)
{
WarningMessage w = new WarningMessage (level);
w.Print (code, loc, String.Format (format, args));
}
static public void Warning (int code, Location loc, string format, params object[] args)
/// <summary>
/// Method reports warning message. Only one reason why exist Warning and Report methods is beter code readability.
/// </summary>
static public void Warning_T (int code, Location loc, params object[] args)
{
WarningMessage w = new WarningMessage ();
w.Print (code, loc, String.Format (format, args));
}
WarningData warning = GetWarningMsg (code);
if (warning.IsEnabled ())
Warning (code, loc, warning.Format (args));
static public void Warning (int code, string format, params object[] args)
{
Warning (code, Location.Null, String.Format (format, args));
related_symbols.Clear ();
}
/// <summary>
/// Did you test your WarningLevel, that you use this method
/// Reports error message.
/// </summary>
static public void Error_T (int code, Location loc, params object[] args)
{
Error_T (code, String.Format ("{0}({1})", loc.Name, loc.Row), args);
}
static public void Error_T (int code, string location, params object[] args)
{
string errorText = String.Format (GetErrorMsg (code), args);
PrintError (code, location, errorText);
}
static void PrintError (int code, string l, string text)
{
if (code < 0)
code = 8000-code;
string msg = String.Format ("{0} error CS{1:0000}: {2}", l, code, text);
RealError (msg);
Check (code);
}
static public void Error (int code, Location l, string text)
{
if (code < 0)
code = 8000-code;
string msg = String.Format (
"{0}({1}) error CS{2:0000}: {3}", l.Name, l.Row, code, text);
// "{0}({1}) error CS{2}: {3}", l.Name, l.Row, code, text);
RealError (msg);
Check (code);
}
static public void Warning (int code, Location l, string text)
{
if (code < 0)
code = 8000-code;
if (warning_ignore_table != null){
if (warning_ignore_table.Contains (code)) {
related_symbols.Clear ();
return;
}
}
if (WarningsAreErrors)
Error (code, l, text);
else {
string row;
if (Location.IsNull (l))
row = "";
else
row = l.Row.ToString ();
Console.WriteLine (String.Format (
"{0}({1}) warning CS{2:0000}: {3}",
// "{0}({1}) warning CS{2}: {3}",
l.Name, row, code, text));
Warnings++;
foreach (string s in related_symbols)
Console.WriteLine (s);
related_symbols.Clear ();
Check (code);
if (Stacktrace)
Console.WriteLine (new StackTrace ().ToString ());
}
}
static public void Warning (int code, string text)
{
Warning (code, Location.Null, text);
}
static public void Error (int code, string format, params object[] args)
static public void Warning (int code, int level, string text)
{
Error (code, Location.Null, String.Format (format, args));
if (RootContext.WarningLevel >= level)
Warning (code, Location.Null, text);
}
static public void Warning (int code, int level, Location l, string text)
{
if (RootContext.WarningLevel >= level)
Warning (code, l, text);
}
static public void Error (int code, string text)
{
if (code < 0)
code = 8000-code;
string msg = String.Format ("error CS{0:0000}: {1}", code, text);
// string msg = String.Format ("error CS{0}: {1}", code, text);
RealError (msg);
Check (code);
}
static public void Error (int code, Location loc, string format, params object[] args)
{
ErrorMessage e = new ErrorMessage ();
e.Print (code, loc, String.Format (format, args));
Error (code, loc, String.Format (format, args));
}
static public void Warning (int code, Location loc, string format, params object[] args)
{
Warning (code, loc, String.Format (format, args));
}
static public void Warning (int code, string format, params object[] args)
{
Warning (code, String.Format (format, args));
}
static public void Message (Message m)
{
if (m is ErrorMessage)
Error (m.code, m.text);
else
Warning (m.code, m.text);
}
static public void SetIgnoreWarning (int code)
@@ -378,14 +376,14 @@ namespace Mono.CSharp {
warning_ignore_table [code] = true;
}
static public int ExpectedError {
set {
expected_error = value;
}
get {
return expected_error;
}
}
static public int ExpectedError {
set {
expected_error = value;
}
get {
return expected_error;
}
}
public static int DebugFlags = 0;
@@ -445,6 +443,38 @@ namespace Mono.CSharp {
}
}
public class Message {
public int code;
public string text;
public Message (int code, string text)
{
this.code = code;
this.text = text;
}
}
public class WarningMessage : Message {
public WarningMessage (int code, string text) : base (code, text)
{
}
}
public class ErrorMessage : Message {
public ErrorMessage (int code, string text) : base (code, text)
{
}
//
// For compatibility reasons with old code.
//
public static void report_error (string error)
{
Console.Write ("ERROR: ");
Console.WriteLine (error);
}
}
public enum TimerType {
FindMembers = 0,
TcFindMembers = 1,
@@ -542,120 +572,4 @@ namespace Mono.CSharp {
{
}
}
/// <summary>
/// Handles #pragma warning
/// </summary>
public class WarningRegions {
abstract class PragmaCmd
{
public int Line;
protected PragmaCmd (int line)
{
Line = line;
}
public abstract bool IsEnabled (int code, bool previous);
}
class Disable: PragmaCmd
{
int code;
public Disable (int line, int code)
: base (line)
{
this.code = code;
}
public override bool IsEnabled (int code, bool previous)
{
return this.code == code ? false : previous;
}
}
class DisableAll: PragmaCmd
{
public DisableAll (int line)
: base (line) {}
public override bool IsEnabled(int code, bool previous)
{
return false;
}
}
class Enable: PragmaCmd
{
int code;
public Enable (int line, int code)
: base (line)
{
this.code = code;
}
public override bool IsEnabled(int code, bool previous)
{
return this.code == code ? true : previous;
}
}
class EnableAll: PragmaCmd
{
public EnableAll (int line)
: base (line) {}
public override bool IsEnabled(int code, bool previous)
{
return true;
}
}
ArrayList regions = new ArrayList ();
public void WarningDisable (int line)
{
regions.Add (new DisableAll (line));
}
public void WarningDisable (Location location, int code)
{
if (CheckWarningCode (code, location))
regions.Add (new Disable (location.Row, code));
}
public void WarningEnable (int line)
{
regions.Add (new EnableAll (line));
}
public void WarningEnable (Location location, int code)
{
if (CheckWarningCode (code, location))
regions.Add (new Enable (location.Row, code));
}
public bool IsWarningEnabled (int code, int src_line)
{
bool result = true;
foreach (PragmaCmd pragma in regions) {
if (src_line < pragma.Line)
break;
result = pragma.IsEnabled (code, result);
}
return result;
}
bool CheckWarningCode (int code, Location loc)
{
if (Report.IsValidWarning (code))
return true;
Report.Warning (1691, 1, loc, "'{0}' is not a valid warning number", code);
return false;
}
}
}
@@ -16,12 +16,6 @@ using System.Diagnostics;
namespace Mono.CSharp {
public enum LanguageVersion
{
Default = 0,
ISO_1 = 1
}
public class RootContext {
//
@@ -52,6 +46,7 @@ namespace Mono.CSharp {
// override).
//
static ArrayList type_container_resolve_order;
static ArrayList interface_resolve_order;
static ArrayList attribute_types;
//
@@ -63,13 +58,16 @@ namespace Mono.CSharp {
static TypeBuilder impl_details_class;
public static int WarningLevel = 2;
public static Target Target = Target.Exe;
public static string TargetExt = ".exe";
public static bool VerifyClsCompliance = true;
public static LanguageVersion Version = LanguageVersion.Default;
//
// If set, enable C# version 2 features
//
public static bool V2 = true;
//
// We keep strongname related info here because
@@ -85,9 +83,10 @@ namespace Mono.CSharp {
static RootContext ()
{
tree = new Tree ();
interface_resolve_order = new ArrayList ();
type_container_resolve_order = new ArrayList ();
}
public static bool NeedsEntryPoint {
get {
return RootContext.Target == Target.Exe || RootContext.Target == Target.WinExe;
@@ -102,6 +101,11 @@ namespace Mono.CSharp {
static public string MainClass;
public static void RegisterOrder (Interface iface)
{
interface_resolve_order.Add (iface);
}
public static void RegisterOrder (TypeContainer tc)
{
type_container_resolve_order.Add (tc);
@@ -306,13 +310,7 @@ namespace Mono.CSharp {
"System.Runtime.Serialization.ISerializable",
"System.Reflection.IReflect",
"System.Reflection.ICustomAttributeProvider",
//
// Generic types
//
"System.Collections.Generic.IEnumerator`1",
"System.Collections.Generic.IEnumerable`1"
"System.Reflection.ICustomAttributeProvider"
};
foreach (string iname in interfaces_first_stage)
@@ -342,7 +340,6 @@ namespace Mono.CSharp {
"System.Char", "System.Boolean",
"System.Decimal", "System.Void",
"System.RuntimeFieldHandle",
"System.RuntimeArgumentHandle",
"System.RuntimeTypeHandle",
"System.IntPtr",
"System.TypedReference",
@@ -359,7 +356,6 @@ namespace Mono.CSharp {
"System.Reflection.MemberInfo",
"System.Type",
"System.Exception",
"System.Activator",
//
// These are not really important in the order, but they
@@ -373,7 +369,6 @@ namespace Mono.CSharp {
"System.Runtime.InteropServices.DllImportAttribute",
"System.Runtime.CompilerServices.MethodImplAttribute",
"System.Runtime.InteropServices.MarshalAsAttribute",
"System.Runtime.CompilerServices.NewConstraintAttribute",
"System.Diagnostics.ConditionalAttribute",
"System.ObsoleteAttribute",
"System.ParamArrayAttribute",
@@ -384,7 +379,6 @@ namespace Mono.CSharp {
"System.Runtime.InteropServices.StructLayoutAttribute",
"System.Runtime.InteropServices.FieldOffsetAttribute",
"System.InvalidOperationException",
"System.NotSupportedException",
"System.MarshalByRefObject"
};
@@ -423,6 +417,9 @@ namespace Mono.CSharp {
foreach (TypeContainer tc in attribute_types)
tc.CloseType ();
foreach (Interface iface in interface_resolve_order)
iface.CloseType ();
//
// We do this in two passes, first we close the structs,
// then the classes, because it seems the code needs it this
@@ -430,13 +427,13 @@ namespace Mono.CSharp {
// make sure that we define the structs in order as well.
//
foreach (TypeContainer tc in type_container_resolve_order){
if (tc.Kind == Kind.Struct && tc.Parent == tree.Types){
if (tc is Struct && tc.Parent == tree.Types){
tc.CloseType ();
}
}
foreach (TypeContainer tc in type_container_resolve_order){
if (!(tc.Kind == Kind.Struct && tc.Parent == tree.Types))
if (!(tc is Struct && tc.Parent == tree.Types))
tc.CloseType ();
}
@@ -454,9 +451,10 @@ namespace Mono.CSharp {
}
attribute_types = null;
interface_resolve_order = null;
type_container_resolve_order = null;
helper_classes = null;
//tree = null;
tree = null;
TypeManager.CleanUp ();
}
@@ -486,33 +484,26 @@ namespace Mono.CSharp {
return ns.Substring (0, i);
}
static TypeExpr NamespaceLookup (DeclSpace ds, string name,
int num_type_args, bool silent, Location loc)
static Type NamespaceLookup (DeclSpace ds, string name, bool silent,
Location loc)
{
//
// Try in the current namespace and all its implicit parents
//
for (NamespaceEntry ns = ds.NamespaceEntry; ns != null; ns = ns.ImplicitParent) {
IAlias result = ns.Lookup (ds, name, num_type_args, false, silent, loc);
object result = ns.Lookup (ds, name, silent, loc);
if (result == null)
continue;
if (!result.IsType)
return null;
if (result is Type)
return (Type) result;
return result.Type;
return null;
}
return null;
}
static public TypeExpr LookupType (DeclSpace ds, string name, bool silent,
Location loc)
{
return LookupType (ds, name, silent, 0, loc);
}
//
// Public function used to locate types, this can only
// be used after the ResolveTree function has been invoked.
@@ -521,15 +512,12 @@ namespace Mono.CSharp {
//
// Come to think of it, this should be a DeclSpace
//
static public TypeExpr LookupType (DeclSpace ds, string name, bool silent,
int num_type_params, Location loc)
static public Type LookupType (DeclSpace ds, string name, bool silent, Location loc)
{
TypeExpr t;
Type t;
if (ds.Cache.Contains (name)){
t = (TypeExpr) ds.Cache [name];
if (t != null)
return t;
if (ds.Cache.Contains (name)) {
t = (Type) ds.Cache [name];
} else {
//
// For the case the type we are looking for is nested within this one
@@ -537,15 +525,30 @@ namespace Mono.CSharp {
//
DeclSpace containing_ds = ds;
while (containing_ds != null){
// if the member cache has been created, lets use it.
// the member cache is MUCH faster.
if (containing_ds.MemberCache != null) {
t = containing_ds.MemberCache.FindNestedType (name);
if (t == null) {
containing_ds = containing_ds.Parent;
continue;
}
ds.Cache [name] = t;
return t;
}
// no member cache. Do it the hard way -- reflection
Type current_type = containing_ds.TypeBuilder;
while (current_type != null) {
while (current_type != null &&
current_type != TypeManager.object_type) {
//
// nested class
//
Type type = TypeManager.LookupType (current_type.FullName + "." + name);
if (type != null){
t = new TypeExpression (type, loc);
t = TypeManager.LookupType (current_type.FullName + "." + name);
if (t != null){
ds.Cache [name] = t;
return t;
}
@@ -556,28 +559,40 @@ namespace Mono.CSharp {
containing_ds = containing_ds.Parent;
}
t = NamespaceLookup (ds, name, num_type_params, silent, loc);
if (t != null){
t = NamespaceLookup (ds, name, silent, loc);
if (!silent)
ds.Cache [name] = t;
return t;
}
}
if (!silent)
if (t == null && !silent)
Report.Error (246, loc, "Cannot find type `"+name+"'");
return null;
return t;
}
// <summary>
// This is the silent version of LookupType, you can use this
// to `probe' for a type
// </summary>
static public TypeExpr LookupType (TypeContainer tc, string name, Location loc)
static public Type LookupType (TypeContainer tc, string name, Location loc)
{
return LookupType (tc, name, true, loc);
}
static public bool IsNamespace (string name)
{
Namespace ns;
if (tree.Namespaces != null){
ns = (Namespace) tree.Namespaces [name];
if (ns != null)
return true;
}
return false;
}
static void Report1530 (Location loc)
{
Report.Error (1530, loc, "Keyword new not allowed for namespace elements");
@@ -588,7 +603,7 @@ namespace Mono.CSharp {
DeclSpace ds = (DeclSpace) root.GetDefinition (name);
ds.DefineMembers (root);
ds.Define ();
ds.Define (root);
}
static public void BootCorlib_PopulateCoreTypes ()
@@ -613,6 +628,15 @@ namespace Mono.CSharp {
if (attribute_types != null)
foreach (TypeContainer tc in attribute_types)
tc.DefineMembers (root);
if (interface_resolve_order != null){
foreach (Interface iface in interface_resolve_order)
if ((iface.ModFlags & Modifiers.NEW) == 0)
iface.DefineMembers (root);
else
Report1530 (iface.Location);
}
if (type_container_resolve_order != null){
if (RootContext.StdLib){
@@ -679,7 +703,14 @@ namespace Mono.CSharp {
if (attribute_types != null)
foreach (TypeContainer tc in attribute_types)
tc.Define ();
tc.Define (root);
if (interface_resolve_order != null){
foreach (Interface iface in interface_resolve_order)
if ((iface.ModFlags & Modifiers.NEW) == 0)
iface.Define (root);
}
if (type_container_resolve_order != null){
foreach (TypeContainer tc in type_container_resolve_order) {
@@ -692,7 +723,7 @@ namespace Mono.CSharp {
continue;
if ((tc.ModFlags & Modifiers.NEW) == 0)
tc.Define ();
tc.Define (root);
}
}
@@ -700,14 +731,14 @@ namespace Mono.CSharp {
if (delegates != null){
foreach (Delegate d in delegates)
if ((d.ModFlags & Modifiers.NEW) == 0)
d.Define ();
d.Define (root);
}
ArrayList enums = root.Enums;
if (enums != null){
foreach (Enum en in enums)
if ((en.ModFlags & Modifiers.NEW) == 0)
en.Define ();
en.Define (root);
}
}
@@ -715,24 +746,32 @@ namespace Mono.CSharp {
{
if (attribute_types != null)
foreach (TypeContainer tc in attribute_types)
tc.EmitType ();
tc.Emit ();
CodeGen.Assembly.Emit (Tree.Types);
CodeGen.Module.Emit (Tree.Types);
if (Tree.Types.Enums != null) {
foreach (Enum e in Tree.Types.Enums)
e.Emit ();
e.Emit (Tree.Types);
}
if (interface_resolve_order != null) {
foreach (Interface iface in interface_resolve_order)
iface.Emit (Tree.Types);
}
if (type_container_resolve_order != null) {
foreach (TypeContainer tc in type_container_resolve_order)
tc.EmitType ();
tc.EmitConstants ();
foreach (TypeContainer tc in type_container_resolve_order)
tc.Emit ();
}
if (Tree.Types.Delegates != null) {
foreach (Delegate d in Tree.Types.Delegates)
d.Emit ();
d.Emit (Tree.Types);
}
//
// Run any hooks after all the types have been defined.
File diff suppressed because it is too large. Load diff
File renamed without changes.
+43 -140
View File
@@ -20,8 +20,6 @@ namespace Mono.CSharp {
public interface ParameterData {
Type ParameterType (int pos);
GenericConstraints GenericConstraints (int pos);
bool HasArrayParameter { get; }
int Count { get; }
string ParameterName (int pos);
string ParameterDesc (int pos);
@@ -30,55 +28,32 @@ namespace Mono.CSharp {
public class ReflectionParameters : ParameterData {
ParameterInfo [] pi;
Type[] type_params;
bool last_arg_is_params = false;
bool is_varargs = false;
ParameterData gpd;
public ReflectionParameters (MethodBase mb)
public ReflectionParameters (ParameterInfo [] pi)
{
object [] attrs;
ParameterInfo [] pi = mb.GetParameters ();
is_varargs = (mb.CallingConvention & CallingConventions.VarArgs) != 0;
this.pi = pi;
int count = pi.Length-1;
if (count < 0)
return;
if (count >= 0) {
attrs = pi [count].GetCustomAttributes (TypeManager.param_array_type, true);
if (mb.Mono_IsInflatedMethod) {
MethodInfo generic = mb.GetGenericMethodDefinition ();
gpd = Invocation.GetParameterData (generic);
if (attrs == null)
return;
if (attrs.Length == 0)
return;
last_arg_is_params = gpd.HasArrayParameter;
return;
last_arg_is_params = true;
}
if (mb.IsGenericMethodDefinition)
type_params = mb.GetGenericArguments ();
attrs = pi [count].GetCustomAttributes (TypeManager.param_array_type, true);
if (attrs == null)
return;
if (attrs.Length == 0)
return;
last_arg_is_params = true;
}
public bool HasArrayParameter {
get { return last_arg_is_params; }
}
public Type ParameterType (int pos)
{
if (last_arg_is_params && pos >= pi.Length - 1)
return pi [pi.Length - 1].ParameterType;
else if (is_varargs && pos >= pi.Length)
return TypeManager.runtime_argument_handle_type;
else {
Type t = pi [pos].ParameterType;
@@ -86,32 +61,16 @@ namespace Mono.CSharp {
}
}
public GenericConstraints GenericConstraints (int pos)
{
if (gpd != null)
return gpd.GenericConstraints (pos);
if (type_params == null)
return null;
return new ReflectionConstraints (type_params [pos]);
}
public string ParameterName (int pos)
{
if (last_arg_is_params && pos >= pi.Length - 1)
return pi [pi.Length - 1].Name;
else if (is_varargs && pos >= pi.Length)
return "__arglist";
else
return pi [pos].Name;
}
public string ParameterDesc (int pos)
{
if (is_varargs && pos >= pi.Length)
return "";
StringBuilder sb = new StringBuilder ();
if (pi [pos].IsIn)
@@ -139,10 +98,9 @@ namespace Mono.CSharp {
{
int len = pi.Length;
if (last_arg_is_params && pos >= pi.Length - 1)
if (pos >= len - 1)
if (last_arg_is_params)
return Parameter.Modifier.PARAMS;
else if (is_varargs && pos >= pi.Length)
return Parameter.Modifier.ARGLIST;
Type t = pi [pos].ParameterType;
if (t.IsByRef){
@@ -157,18 +115,16 @@ namespace Mono.CSharp {
public int Count {
get {
return is_varargs ? pi.Length + 1 : pi.Length;
return pi.Length;
}
}
}
public class InternalParameters : ParameterData {
Type [] param_types;
bool has_varargs;
int count;
public readonly Parameters Parameters;
public readonly TypeParameter[] TypeParameters;
public InternalParameters (Type [] param_types, Parameters parameters)
{
@@ -179,29 +135,15 @@ namespace Mono.CSharp {
public InternalParameters (DeclSpace ds, Parameters parameters)
: this (parameters.GetParameterInfo (ds), parameters)
{
has_varargs = parameters.HasArglist;
if (param_types == null)
count = 0;
else
count = param_types.Length;
}
public InternalParameters (DeclSpace ds, Parameters parameters,
TypeParameter [] type_params)
: this (ds, parameters)
{
this.TypeParameters = type_params;
}
public int Count {
get {
return has_varargs ? count + 1 : count;
}
}
if (param_types == null)
return 0;
public bool HasArrayParameter {
get { return Parameters.ArrayParameter != null; }
return param_types.Length;
}
}
Parameter GetParameter (int pos)
@@ -218,36 +160,20 @@ namespace Mono.CSharp {
public Type ParameterType (int pos)
{
if (has_varargs && pos >= count)
return TypeManager.runtime_argument_handle_type;
if (param_types == null)
return null;
return GetParameter (pos).ExternalType ();
}
public GenericConstraints GenericConstraints (int pos)
{
if (TypeParameters == null)
return null;
return TypeParameters [pos].Constraints;
}
public string ParameterName (int pos)
{
if (has_varargs && pos >= count)
return "__arglist";
return GetParameter (pos).Name;
}
public string ParameterDesc (int pos)
{
if (has_varargs && pos >= count)
return "__arglist";
string tmp = String.Empty;
Parameter p = GetParameter (pos);
@@ -269,9 +195,6 @@ namespace Mono.CSharp {
public Parameter.Modifier ParameterModifier (int pos)
{
if (has_varargs && pos >= count)
return Parameter.Modifier.ARGLIST;
Parameter.Modifier mod = GetParameter (pos).ModFlags;
if ((mod & (Parameter.Modifier.REF | Parameter.Modifier.OUT)) != 0)
@@ -282,49 +205,6 @@ namespace Mono.CSharp {
}
public class ReflectionConstraints : GenericConstraints
{
GenericParameterAttributes attrs;
Type base_type;
Type class_constraint;
Type[] iface_constraints;
public ReflectionConstraints (Type t)
{
Type[] constraints = t.GetGenericParameterConstraints ();
if ((constraints.Length > 0) && !constraints [0].IsInterface) {
class_constraint = constraints [0];
iface_constraints = new Type [constraints.Length - 1];
Array.Copy (constraints, 1, iface_constraints, 0, constraints.Length - 1);
} else
iface_constraints = constraints;
attrs = t.GenericParameterAttributes;
if (HasValueTypeConstraint)
base_type = TypeManager.value_type;
else if (class_constraint != null)
base_type = class_constraint;
else
base_type = TypeManager.object_type;
}
public override GenericParameterAttributes Attributes {
get { return attrs; }
}
public override Type ClassConstraint {
get { return class_constraint; }
}
public override Type EffectiveBaseClass {
get { return base_type; }
}
public override Type[] InterfaceConstraints {
get { return iface_constraints; }
}
}
class PtrHashtable : Hashtable {
sealed class PtrComparer : IComparer {
private PtrComparer () {}
@@ -389,6 +269,29 @@ namespace Mono.CSharp {
}
}
//
// Compares member infos based on their name and
// also allows one argument to be a string
//
class MemberInfoCompare : IComparer {
public int Compare (object a, object b)
{
if (a == null || b == null){
Console.WriteLine ("Invalid information passed");
throw new Exception ();
}
if (a is string)
return String.Compare ((string) a, ((MemberInfo)b).Name, false, CultureInfo.InvariantCulture);
if (b is string)
return String.Compare (((MemberInfo)a).Name, (string) b, false, CultureInfo.InvariantCulture);
return String.Compare (((MemberInfo)a).Name, ((MemberInfo)b).Name, false, CultureInfo.InvariantCulture);
}
}
struct Pair {
public object First;
public object Second;
+89
View File
@@ -0,0 +1,89 @@
//
// symbolwriter.cs: The symbol writer
//
// Author:
// Martin Baulig ([email protected])
//
// (C) 2003 Ximian, Inc.
//
using System;
using System.Collections;
using System.Reflection;
using System.Reflection.Emit;
using System.Diagnostics.SymbolStore;
namespace Mono.CSharp {
public class SymbolWriter {
ISymbolWriter symwriter;
MethodInfo define_namespace;
MethodInfo open_method;
protected SymbolWriter (ISymbolWriter symwriter)
{
this.symwriter = symwriter;
}
bool Initialize ()
{
Type type = symwriter.GetType ();
define_namespace = type.GetMethod ("DefineNamespace", new Type[] {
typeof (string), typeof (ISymbolDocumentWriter),
typeof (string []), typeof (int) });
if (define_namespace == null)
return false;
open_method = type.GetMethod ("OpenMethod", new Type[] {
typeof (ISymbolDocumentWriter), typeof (int), typeof (int),
typeof (int), typeof (int), typeof (MethodBase), typeof (int) });
if (open_method == null)
return false;
Location.DefineSymbolDocuments (this);
Namespace.DefineNamespaces (this);
return true;
}
public ISymbolDocumentWriter DefineDocument (string path)
{
return symwriter.DefineDocument (
path, SymLanguageType.CSharp, SymLanguageVendor.Microsoft,
SymDocumentType.Text);
}
public int DefineNamespace (string name, SourceFile file, string[] using_list, int parent)
{
if (file.SymbolDocument == null)
return 0;
return (int) define_namespace.Invoke (symwriter, new object[] {
name, file.SymbolDocument, using_list, parent });
}
public void OpenMethod (TypeContainer parent, MethodBase method, Location start, Location end)
{
int ns_id = parent.NamespaceEntry.SymbolFileID;
open_method.Invoke (symwriter, new object[] {
start.SymbolDocument, start.Row, 0, end.Row, 0, method, ns_id });
}
public void CloseMethod ()
{
symwriter.CloseMethod ();
}
public static SymbolWriter GetSymbolWriter (ModuleBuilder module)
{
ISymbolWriter symwriter = module.GetSymWriter ();
if (symwriter == null)
return null;
SymbolWriter writer = new SymbolWriter (symwriter);
if (!writer.Initialize ())
return null;
return writer;
}
}
}
+33 -32
View File
@@ -33,6 +33,11 @@ namespace Mono.CSharp
public class Tree {
TypeContainer root_types;
// <summary>
// Keeps track of namespaces defined in the source code
// </summary>
Hashtable namespaces;
// <summary>
// Keeps track of all the types definied (classes, structs, ifaces, enums)
// </summary>
@@ -40,31 +45,19 @@ namespace Mono.CSharp
public Tree ()
{
root_types = new RootTypes ();
root_types = new TypeContainer ();
decls = new Hashtable ();
namespaces = new Hashtable ();
}
DoubleHash decl_ns_name = new DoubleHash ();
public void RecordDecl (string name, DeclSpace ds)
{
DeclSpace other = (DeclSpace) decls [name];
if (other != null){
PartialContainer other_pc = other as PartialContainer;
if ((ds is TypeContainer) && (other_pc != null)) {
Report.Error (
260, ds.Location, "Missing partial modifier " +
"on declaration of type `{0}'; another " +
"partial implementation of this type exists",
name);
Report.LocationOfPreviousError (other.Location);
return;
}
Report.SymbolRelatedToPreviousError (
other.Location, other.GetSignatureForError ());
if (decls.Contains (name)){
DeclSpace other = (DeclSpace) decls [name];
Report.SymbolRelatedToPreviousError (other.Location, other.GetSignatureForError ());
Report.Error (
101, ds.Location,
@@ -92,6 +85,26 @@ namespace Mono.CSharp
return (DeclSpace) res;
}
public NamespaceEntry RecordNamespace (NamespaceEntry parent, SourceFile file, string name, Location loc)
{
NamespaceEntry ns = new NamespaceEntry (parent, file, name, loc);
if (namespaces.Contains (file)){
Hashtable ns_ns = (Hashtable) namespaces [file];
if (ns_ns.Contains (ns.FullName))
return (NamespaceEntry) ns_ns [ns.FullName];
ns_ns.Add (ns.FullName, ns);
} else {
Hashtable new_table = new Hashtable ();
namespaces [file] = new_table;
new_table.Add (ns.FullName, ns);
}
return ns;
}
//
// FIXME: Why are we using Types?
//
@@ -106,23 +119,11 @@ namespace Mono.CSharp
return decls;
}
}
}
public class RootTypes : TypeContainer
{
public RootTypes ()
: base (null, null, MemberName.Null, null, Kind.Root,
new Location (-1))
{ }
public override void Register ()
{
throw new InvalidOperationException ();
public Hashtable Namespaces {
get {
return namespaces;
}
public override PendingImplementation GetPendingImplementations ()
{
throw new InvalidOperationException ();
}
}
}
File diff suppressed because it is too large. Load diff
Loaded 100 of 472 files, more files were not shown because too many files have changed in this diff. Show more