diff options
380 files changed, 33347 insertions, 5782 deletions
diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 00000000000..907d24aede5 --- /dev/null +++ b/.cvsignore @@ -0,0 +1,11 @@ +config.h +Makefile +config.cache +stamp-h.in +config.status +aclocal.m4 +configure +stamp-h +libtool +Makefile.in +config.log @@ -1 +1,2 @@ Miguel de Icaza (miguel@ximian.com) +Paolo Molaro (lupus@ximian.com) diff --git a/ChangeLog b/ChangeLog index 1a76f446632..c180c74aa66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2001-07-15 Joe Shaw <joe@ximian.com> + + * configure.in: Don't create doc/Makefile as there's nothing there + to make. + + * Makefile.am: Don't build the doc directory because there's no + Makefile.am there. + + * autogen.sh: Call aclocal with the $ACLOCAL_FLAGS env var. + +2001-07-15 Miguel de Icaza <miguel@ximian.com> + + * doc/class-library (A): Updated FAQ with question on error 1595. + +2001-07-14 Miguel de Icaza <miguel@ximian.com> + + * doc/index: + +Wed Jul 11 00:36:36 CEST 2001 Paolo Molaro <lupus@ximian.com> + + * status/*: scripts and data to create statistics about the + class library status. + +2001-07-09 Alex Graveley <alex@ximian.com> + + * doc/makefile (clean): Add clean target. + * doc/web/makefile (clean): Ditto. + +2001-07-09 Alex Graveley <alex@ximian.com> + + * doc/makefile (all-docs): Fix typo. + 2001-05-30 Miguel de Icaza <miguel@ximian.com> * NEWS: diff --git a/Makefile.am b/Makefile.am index 7a0d4a47da8..fc581a79c21 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1 +1 @@ -SUBDIRS = mono +SUBDIRS = mono doc @@ -1,3 +1,13 @@ +2001-07-12 Miguel de Icaza <miguel@ximian.com> + + New XSLT file from Sergey Chaban for CIL opcodes + + Paolo got the beginning of an interpreter in. + + Further work on the dissasembler. + + Fix various parts of the metadata library + 2001-05-30 Miguel de Icaza <miguel@ximian.com> Project started @@ -1,3 +1,8 @@ This is MonoNet. Ximian's portable implementation of .NET + + +---------- + +To edit the go-mono website, see doc/README. diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 00000000000..0b11f883c53 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,6 @@ +libtoolize --automake +automake -a +autoheader +aclocal $ACLOCAL_FLAGS +autoconf +./configure $* diff --git a/config.h.in b/config.h.in deleted file mode 100644 index f871c4edf55..00000000000 --- a/config.h.in +++ /dev/null @@ -1,11 +0,0 @@ -/* config.h.in. Generated automatically from configure.in by autoheader. */ - -/* Define if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Name of package */ -#undef PACKAGE - -/* Version number of package */ -#undef VERSION - diff --git a/configure.in b/configure.in index b146447d4d7..fcfe6492389 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ AC_INIT(README) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(mononet, 0.1) +AM_INIT_AUTOMAKE(mono, 0.4) AM_MAINTAINER_MODE AC_PROG_CC @@ -31,4 +31,7 @@ Makefile mono/Makefile mono/metadata/Makefile mono/dis/Makefile -])
\ No newline at end of file +mono/cil/Makefile +mono/interpreter/Makefile +doc/Makefile +]) diff --git a/doc/.cvsignore b/doc/.cvsignore new file mode 100644 index 00000000000..79a25824094 --- /dev/null +++ b/doc/.cvsignore @@ -0,0 +1,3 @@ +Makefile.in +Makefile +all-docs diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 00000000000..dd2e2d85e2c --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,19 @@ +WEB_FILES= \ + c-sharp class-library contact contributing documentation download \ + faq gcc-frontend ideas index passport rationale resources \ + roadmap runtime status team testing thanks tools + +OTHERS= pending resources-pending todo + +EXTRA_DIST = $(WEB_FILES) README $(OTHERS) + +all-docs: $(WEB_FILES) + cat rationale roadmap c-sharp tools class-library \ + runtime documentation download faq contributing \ + resources status > all-docs + +webit: + (cd web; make && make push) + +push-notes: + scp release-notes/mono* www@www:/web/cvsmodules/mono/archive diff --git a/doc/README b/doc/README new file mode 100644 index 00000000000..333d133943f --- /dev/null +++ b/doc/README @@ -0,0 +1,17 @@ +To edit the website appearance: + +cd doc/web +edit template.html.in +make + +To edit website content: + +cd doc (this directory) +edit files carefully +cd web +make + +To publish changes: + +cd web +make push diff --git a/doc/c-sharp b/doc/c-sharp new file mode 100644 index 00000000000..c37fe559200 --- /dev/null +++ b/doc/c-sharp @@ -0,0 +1,151 @@ +* MCS: The Ximian C# compiler + + MCS began as an experiment to learn the features of C# by + writing a large C# program. MCS is currently able to parse C# + programs and create an internal tree representation of the + program. MCS can parse itself. + + Work is progressing quickly on various fronts in the C# + compiler. Recently I started using the System.Reflection API + to load system type definitions and avoid self-population of + types in the compiler and dropped my internal Type + representation in favor of using the CLI's System.Type. + +** Phases of the compiler + + The compiler has a number of phases: + + <ul> + * Lexical analyzer: hand-coded lexical analyzer that + provides tokens to the parser. + + * The Parser: the parser is implemented using Jay (A + Berkeley Yacc port to Java, that I ported to C#). + The parser does minimal work and syntax checking, + and only constructs a parsed tree. + + Each language element gets its own class. The code + convention is to use an uppercase name for the + language element. So a C# class and its associated + information is kept in a "Class" class, a "struct" + in a "Struct" class and so on. Statements derive + from the "Statement" class, and Expressions from the + Expr class. + + * Parent class resolution: before the actual code + generation, we need to resolve the parents and + interfaces for interface, classe and struct + definitions. + + * Semantic analysis: since C# can not resolve in a + top-down pass what identifiers actually mean, we + have to postpone this decision until the above steps + are finished. + + * Code generation: nothing done so far, but I do not + expect this to be hard, as I will just use + System.Reflection.Emit to generate the code. + + </ul> + +<a name="tasks"> +** Current pending tasks + + Simple tasks: + + <ul> + * Array declarations are currently being ignored, + + * PInvoke declarations are not supported. + + * Pre-processing is not supported. + + * Attribute declarations and passing currently ignored. + + * Compiler does not pass around line/col information from tokenizer for error reporting. + + * Jay does not work correctly with `error' + productions, making parser errors hard to point. It + would be best to port the Bison-To-Java compiler to + become Bison-to-C# compiler (bjepson@oreilly.com + might have more information) + </ul> + + Critical tasks: + + <ul> + * Resolve "base" classes and "base" interfaces for + classes, structs and interfaces. + + Once this is done, we can actually do the semantic + analysis, because otherwise we do not know who our + parents are. + </ul> + + Interesting tasks: + + <ul> + * Finishing the JB port from Java to C#. If you are + interested in working on this, please contact Brian + Jepson (bjepson at oreilly d-o-t com). + + More on JB at: <a href="http://www.cs.colorado.edu/~dennis/software/jb.html"> + http://www.cs.colorado.edu/~dennis/software/jb.html</a> + + JB will allow us to move from the Berkeley Yacc + based Jay to a Bison-based compiler (better error + reporting and recovery). + </ul> + +** Questions and Answers + +Q: Why not write a C# front-end for GCC? + +A: I wanted to learn about C#, and this was an exercise in this + task. The resulting compiler is highly object-oriented, which has + lead to a very nice, easy to follow and simple implementation of + the compiler. + + I found that the design of this compiler is very similar to + Guavac's implementation. + + Targeting the CIL/MSIL byte codes would require to re-architecting + GCC, as GCC is mostly designed to be used for register machines. + + The GCC Java engine that generates Java byte codes cheats: it does + not use the GCC backend; it has a special backend just for Java, so + you can not really generate Java bytecodes from the other languages + supported by GCC. + +Q: If your C# compiler is written in C#, how do you plan on getting + this working on a non-Microsoft environment. + + We will do this through an implementation of the CLI Virtual + Execution System for Unix (our JIT engine). + +Q: Do you use Bison? + +A: No, currently I am using Jay which is a port of Berkeley Yacc to + Java that I later ported to C#. This means that error recovery is + not as nice as I would like to, and for some reason error + productions are not being caught. + + In the future I want to port one of the Bison/Java ports to C# for + the parser. + +Q: How do I compile it? + +A: Compiling MCS currently requires you to run my port of <a + href="http://primates.ximian.com/~miguel/code/jay.cs.tar.gz">Jay to + C#</a> on a Unix system to generate the parser, and then you need + to use Microsoft's .NET csc.exe compiler to compile the compiler. + + You only need to compile the compiler compiler (C code), the + samples are Java samples that I did not port, and you do not need + them. + + It might be simple to port Jay.cs to Windows, but I have not tried + this. + +You might also want to look at the <a href="faq.html#gcc">GCC</a> +section on the main FAQ diff --git a/doc/class-library b/doc/class-library new file mode 100644 index 00000000000..a2ce00d655b --- /dev/null +++ b/doc/class-library @@ -0,0 +1,174 @@ +* The Class Library + + The Class Library should be compatible with Microsoft's .NET + implementation. + + Please see the <a href="class-status.html">Class Status</a> + page for a status of who is working on which classes. + + We will write as much code as possible in C#. We may need to + interface with code written in C to gain access to the + functionality of libraries like libart, Gtk+, and libc. + +** Contributing + + We welcome contributions to the the Class Library. To get + started, check the status page for information about which + APIs are being worked on, and how to get in touch with + individual maintainers. + + If you want to work on a class, first check the <a + href="download.html">Classes Distribution</a> to see if it is + not implemented yet, if not, check the <a + href="class-status.html">Class Status</a> to see if someone is + already working on it, and maybe contact them. + + If nobody is working on it, mail <a + href="mailto:mono-list@ximian.com">mono-list@ximian.com</a> + with the class you want to implement and CC <a + href="mailto:miguel@ximian.com">miguel@ximian.com</a> + +** Layout + + The Class Library resides in the `mcs' module in the directoy + `class'. + + Each directory in the directory represents the assembly where + the code belongs to, and inside each directory we divide the + code based on the namespace they implement. + + There are two cases when we should consider portability: when + we are dealing with a couple of classes only that differ from + system to system (Consider System.Net and System.IO for Win32 + and Unix). In those cases we will just place the files for + example on <t>corlib/System/System.IO/Unix-Console.cs</t> and + <t>corlib/System/System.IO/Win32-Console.cs</t>. + + For classes that might differ more (for example, the + implementation of Windows.Forms), we might have different + directories altogether: <t>System.Windows.Forms/Win32</t>, + <t>System.Windows.Forms/Gtk+</t> and + <t>System.Windows.Forms/Cocoa</t>. + +** Using existing components from GNOME. + + Our current plan is to implement the GUI tools on top of + Gtk+. The only obstacle here is that applications from Windows + might expect to be able to pull the HWND property from the + widgets and use PInvoke to call Windows functions. + +** Class Library and Win32 dependencies. + + There are a few spots where the Win32 foundation is exposed to + the class library (for example, the HDC and HWND properties in + the GDI+). Casual inspection suggests that these can be + safely mapped to Gdk's GC and GdkWindow pointers without + breaking anything. + + The only drawback is that support for PInvoke of Win32 code + won't be available. An alternate solution would be to use + portions of Wine, or even to use Wine as our toolkit. + +*** Initial GDI+ and WinForms implementation + + The initial implementation will use Gtk+ as the underlying + toolkit. Since GTK+ has already been ported to many windowing + systems other than X (including frame buffer, Win32, and BeOS) + its use should cover most applications for most users. + +*** Database access + + We will implement ADO.NET functionality by reusing <a + href="http://www.gnome-db.org">GNOME-DB</a>. This is an ideal + choice, since GNOME-DB was implemented precisely to provide an + ADO-like system for GNOME. + +*** Component Integration + + We will provide a new namespace to use GNOME specific features + as well as a namespace to host Bonobo interfaces and classes + in Mono. + +** Licensing + + The class library will be licensed under the terms of the GNU + LGPL. Some people have pointed out that the plain LGPL is + troublesome for embedded use of the Mono class libraries. So + we are considering to use the GPL with a special exception + (like the <a + href="http://www.gnu.org/software/classpath/classpath.html">GNU + Classpath</a> project did. + + The exception to the GPL would be: + + <i>The library is distributed under the terms of the GNU General + Public License with the following exception: + + If you link this library against your own program, then you do not + need to release the source code for that program. However, any + changes that you make to the library itself, or to any native + methods upon which the library relies, must be re-distributed in + accordance with the terms of the GPL.</i> + + If you are going to contribute, please keep in mind that we + might require you to agree that Ximian might adjust the + license to enable the use of the class libraries on embedded + systems or to develop proprietary applications using Mono. + + We suggest that you assign the copyright of your work to the + GNOME Foundation or the Free Software Foundation to simplify + defending the code in case it is used inappropiately. + +** Class Library testing + + We need to write regression tests that will verify + the correctness of the class library, compiler, and JIT + engine. + +** Coding conventions + + Please follow the conventions on the ECMA specification (On + the Annex Partition) for your coding your libraries. + + Use 8 space tabs for writing your code (hopefully we can keep + this consistent). If you are modifying someone else's code, try + to keep the coding style similar. + + For a rationale on 8 space tabs, read Linus Torvald's Coding + Style guidelines in the Linux kernel source for a rationale. + +*** Missing implementation bits + + If you implement a class and you are missing implementation bits, + please put in the code the word "TODO" and a description of what + is missing to be implemented. + +*** Tagging buggy code + + If there is a bug in your implementation tag the problem by using + the word "FIXME" in the code, together with a description of the + problem. + + Do not use XXX or obscure descriptions, because otherwise people + will not be able to understand what you mean. + +*** Tagging Lame specs + + Sometimes the specification will be lame (consider Version.ToString (fieldCount) + where there is no way of knowing how many fields are available, making the API + not only stupid, but leading to unreliable code). + + In those cases, use the keyword "LAMESPEC". + +** FAQ + +Frequently asked questions about the class library: + +Q: I am writing a new class that overrides one of the system classes, + and I am getting a 1595 warning from the compiler. Should we use a + different namespace? + +A: There is a quick solution to the problem, you can pass the command + line argument /nowarn:1595 and this will effectively let you use + your implementation of the code, while overriding the ones from the + system assemblies.
\ No newline at end of file diff --git a/doc/class-status b/doc/class-status new file mode 100644 index 00000000000..5e26c2d1e63 --- /dev/null +++ b/doc/class-status @@ -0,0 +1,27 @@ +* Status of the various pieces of the class library + + You can browse the status of the class library and see who has + registered to work on what parts of the system. These list + work-in-progress components currently. + + <ul> + * Per <a href="class-status/per-assembly.html">Assembly</a> + + * Per <a href="class-status/per-completion.html">Completion</a> + + * Per <a href="class-status/per-maintainer.html">Maintainer</a> + + * Per <a href="class-status/per-unimplemented.html">Unimplemented</a> + </ul> + + A better mechanism will soon be in place, I just did this + really quickly, as we already got one duplicated implementation. + + You can also download the XML <a + href="class-status/maintainers.xml">maintainers</a> file that + contains the actual maintainers list. + + I am sure we can generate better reports, if you are + interested in contributing, let <a + href="mailto:miguel@ximian.com">me</a> know. + diff --git a/doc/contact b/doc/contact new file mode 100644 index 00000000000..f5e1b98c115 --- /dev/null +++ b/doc/contact @@ -0,0 +1,16 @@ +* Contacting the Mono team. + + You can contact the Mono Team by sending e-mail to `<a + href="mailto:mono-hackers@ximian.com">mailto:mono-hackers@ximian.com</a>'. + + You can contact the general forum of discussion by sending + e-mail to <a href="mailto:mono-list@ximian.com">mono-list@ximian.com</a> + + You can contact me (Miguel de Icaza) by sending e-mail to <a + href="mailto:miguel@ximian.com">miguel@ximian.com</a>. My web + page is <a + href="http://primates.ximian.com/~miguel">http://primates.ximian.com/~miguel"</a> + + You can also <a + href="http://www.ximian.com/about/contact.php3">reach Ximian.</a> + diff --git a/doc/contributing b/doc/contributing new file mode 100644 index 00000000000..7e64a96ab21 --- /dev/null +++ b/doc/contributing @@ -0,0 +1,53 @@ +* Contributing to the Mono project + + There are many ways in which you can help in the Mono project: + + <ul> + * <b>Programmers:</b> You can work on a free + implementation of the <a + href="class-library.html">class libraries</a>, the + <a href="runtime.html">runtime engine</a>, <a + href="tools.html">the tools</a>, the <a + href="testing.html">testing framework</a> + + * <b>Writers:</b> You can help us with writing <a + href="documentation.html">documentation</a>. + </ul> + + Those are just broad things that need to be worked on, but + something that would help tremendously would be to help with + small duties in the project that need to be addressed. + +** Small tasks + + A few smaller tasks are here, dropped in no particular order: + <ul> + * <b>MCS compilation process:</b> Currently MCS does + not build with a single `make' command. This should + be fixed (this being part of the `Joel Test' that + software has to pass). + + * <b>Mono/doc and web site:</b> They need to be + packaged up in the official `distribution' + + * <b>Enthusiasts: </b> + </ul> + +* Special note + + If you have looked at Microsoft's implementation of .NET or + their shared source code, you may not be able to contribute + to Mono. Details will follow when we know more about this. + + In general be careful when you are implementing free software + and you have access to proprietary code. We need to make sure + that we are not using someone else's copyrighted code + accidentally. + + Please do not use the <b>ildasm</b> program to disassemble + proprietary code when you are planning to reimplement a class + for Mono. If you have done this, we might not be able to use + your code. + + Please stick to published documentation for implementing any + classes. diff --git a/doc/documentation b/doc/documentation new file mode 100644 index 00000000000..166e0e8ccfe --- /dev/null +++ b/doc/documentation @@ -0,0 +1,50 @@ +* Documentation + + Although most of the concepts from Microsoft.NET can + be applied to the completed Mono platform, we do need to + have a complete set of free documentation written specifically + for Mono. + + The documentation license we have chosen is the GNU Free + Documentation License (FDL), the standard for most documents + in the free software world. + + We need documentation on a number of topics: + + <ul> + + * The development tools (compilers, assembler tools, + language reference, design time features). + + * Frequently Asked Question compilations. + + * HOWTO documents. + + * The Class Libraries + + * Tutorials on Mono and the specifics of running it. + + * A guide to Mono as compared to the Microsoft.NET + Framework SDK + + </ul> + +** Class Library documentation + + When contributing to the Class Library effort, please use the + inline XML documentation tags to document your classes so we + can automatically generate the documentation from the class + libraries. + + If you provide examples, please do not embed them into the + source code, as that will make the source code harder to read + and maintain. Instead, put examples for your code into a + subdirectory of the class libraries. Make your sample + code a full standalone application that people can compile. + Ideally the Mono documentation browser will let you edit, modify + and run the sample programs. + + + + + diff --git a/doc/download b/doc/download new file mode 100644 index 00000000000..27a82064593 --- /dev/null +++ b/doc/download @@ -0,0 +1,52 @@ +* Software Availability + + The Virtual Execution System is available in package `mono'. + Currently this contains a metadata library and the + disassembler. Please reffer to our <a + href="runtime.html">Runtime</a> description for more details + on this part of the project. + + The code for the C# compiler as well as the language error + test suite and the class library are in the `mcs' package, we + will move this later into `mono' itself. + + The mcs compiler requires the `jay' parser generator, this is + available in module `jay'. + +** Sources + + Currently we will be providing CVS snapshots every day, until + we make the first tarball release. + + <ul> + <a name="july-15"> + <b>July 15th, 2001</b> + <ul> + * <a href="archive/mcs-15-Jul-2001.tar.gz">mcs-15-Jul-2001.tar.gz</a>: CVS snapshot. + * <a href="archive/mono-0.4.tar.gz">mono-0.4.tar.gz</a>: Packaged Source Code. + * <a href="archive/mono-0.4">Release Notes</a> + </ul> + + <a name="july-14"> + <b>July 14th, 2001</b> + <ul> + * <a href="archive/jay.cs.tar.gz">archive/jay.cs.tar.gz</a>: Sources to Jay. + * <a href="archive/mcs-12-Jul-2001.tar.gz">mcs-12-Jul-2001.tar.gz</a>: CVS snapshot. + * <a href="archive/mono-0.3.tar.gz">mono-0.3.tar.gz</a>: Packaged Source Code. + </ul> + + <a name="july-8"> + <b>July 8th, 2001</b> + + <ul> + * <a href="archive/jay.cs.tar.gz">archive/jay.cs.tar.gz</a>: Sources. + * <a href="archive/mcs-08-Jul-2001.tar.gz">mcs-08-Jul-2001.tar.gz</a>: CVS Snapshot + * <a href="archive/mono-08-Jul-2001.tar.gz">mono-08-Jul-2001.tar.gz</a>: CVS Snapshot + </ul> + </ul> + +** CVS + + We are trying to figure out where to put our CVS repository. + We are debating between the GNOME CVS or SourceForge. Watch + this spot. diff --git a/doc/faq b/doc/faq new file mode 100644 index 00000000000..8f9f8f199f4 --- /dev/null +++ b/doc/faq @@ -0,0 +1,609 @@ +** Basics + +Q: Is Mono the same as Microsoft's .NET initiative? + +A: It is not. + + .NET is a company-wide initiative at Microsoft that + encompasses many different areas. The .NET development framework, + Passport, Biztalk, new server products, and anything that is + remotely connected to .NET gets the ".NET-stamping" treatment. + Some components of Microsoft's .NET initiative have been announced + and some others are in the works. + + Mono is a project to implement several technologies developed by + Microsoft that have now been submitted to the ECMA Standards Body. + +Q: What technologies are included in Mono? + +A: Mono contains a number of components useful for building new + software: + + <ul> + * A Common Language Infrastructure (CLI) virtual + machine that contains a class loader, Just-in-time + compiler, and a garbage collecting runtime. + + * A class library that can work with any language + which works on the CLR. + + * A compiler for the C# language. In the future we + might work on other compilers that target the Common + Language Runtime. + + Windows has compilers that target the + virtual machine from + <a href="http://msdn.microsoft.com/net/thirdparty/default.asp#lang">a + number of languages:</a> Managed C++, Java Script, + Eiffel, Component Pascal, APL, Cobol, Oberon, Perl, + Python, Scheme, Smalltalk, Standard ML, Haskell, + Mercury and Oberon. + </ul> + + The CLR and the Common Type System (CTS) enables applications and + libraries to be written in a number of languages. Classes and + methods created in one language can be used from a different + language. + + This means for example that if you define a class to do algebraic + manipulation in C#, that class can be reused from any other + language that supports the CLI. You could create a class in C#, + subclass it in C++ and instantiate it in an Eiffel program. + + A single object system, threading system, class libraries, and + garbage collection system can be shared across all these languages. + +Q: Where can I find the specification for these technologies? + +A: You can find the work-in-progress documentation from the T3G ECMA + group here: + + <a href="http://www.dotnetexperts.com">http://www.dotnetexperts.com</a> + +Q: Will you implement the .NET Framework SDK class libraries? + +A: Yes, we will be implementing the APIs of the .NET Framework SDK + class libraries. + +Q: What does Mono stand for? + +A: Mono is the word for `Monkey' in Spanish. We like monkeys. + +Q: When will you ship it? + +A: We do not know when the code will be shipped. The more + contributions we get to the project, the sooner it will ship. + + A rough estimate is that we might be able to run our C# compiler on + Linux by the end of the year. That means running the Windows + Executable generated by a Microsoft .NET compiler on the Linux + platform. + + We expect that doing GUI applications will require more work on the + class libraries. That could take another six months. + +Q: How can I contribute? + +A: Check the <a href="contributing.html">contributing</a> section. + +Q: You guys should innovate instead of copying. + +A: In this particular case, we see a clear advantage in the platform + and we are interested in using the features of the CLI on open source systems. + + We have decided that we should spend our limited resources towards + implementing an existing specification instead of designing and + implementing our own. + + Designing and implementing our own would be possible, but it doesn't make + sense to do that just because the specification comes from a + proprietary vendor. + +** Ximian + +Q: Why is Ximian working on .NET? + +A: We are interested in providing the best tools for programmers to + develop applications for Free Operating Systems. + + For more information, read the project <a + href="rationale.html">rationale</a> page. + +Q: Will Ximian be able to take on a project of this size? + +A: Ximian will not be able to taken on the whole project on its own. + Mono will be a free software/open source community project, that is + the only way we can hope to implement something of this size. You + can <a href="contributing.html">contribute</a> to this effort. + +Q: What pieces will Ximian be working on? + +A: We will focus on building a development and execution + environment. + + The idea is to get Mono to a state of that would allow + third parties to actually be able to use it real-world development. + +Q: Why does Ximian even care? + +A: We like the features that the CLI and its related technologies + bring to the table. An exciting addition to the developer toolkit. + The goal of Mono is to bring this technology to non-Windows + platforms (although we hope Mono will also run on Windows, for + debugging and comparative purposes). + + +** Licensing + +Q: Will I be able to write proprietary applications that run with + Mono? + +A: Yes. We will make sure that the licensing will allow developers to + create proprietary applications. + +Q: What license is Mono on? + +A: The C# Compiler is released under the terms of the GPL. The class + libraries will be under the LGPL or the GPL with a special + exception. The runtime libraries are under the LGPL. + + Here is the exception for the class libraries: + + The library is distributed under the terms of the GNU General + Public License with the following exception: + + If you link this library against your own program, then you do not + need to release the source code for that program. However, any + changes that you make to the library itself, or to any native + methods upon which the library relies, must be re-distributed in + accordance with the terms of the GPL. + + This is similar in spirit to <a + href="http://www.gnu.org/software/classpath/classpath.html">GNU + Classpath.</a> + +Q: Will you accept code under the XXX License? + +A: If the XXX License is compatible with the license we use in that + specific piece of code, then yes. If you want to use the BSD license, make + sure you use the BSD license without the advertisement clause (The + `Ousterhout License'). + +** Mono and .NET + +Q: If applications use Mono, does that mean that I have to pay a service fee? + +A: No. Mono is not related to Microsoft's initiative of + software-as-a-service. + +Q: If you implement .NET, will I depend on Microsoft Passport to run my software? + +A: No. The .NET Framework is a runtime infrastructure and collection + of class libraries. Passport may be required to access certain web + services written for that framework, but only if the programmer + chooses Passport as the authentication mechanism. + +Q: Is .NET just a bunch of marketing slogans? + +A: Although the `.NET initiative' is still quite nebulous, The .NET Framework + has been available for some time. Mono is not an implementation of the .NET + initiative, just the development framework. + +Q: What is a 100% .NET application? + +A: A `100% .NET application' is one that only uses the APIs defined + under the System namespace and does not use PInvoke. These + applications would in theory run unmodified on Windows, Linux, + HP-UX, Solaris, MacOS X and others. + +Q: But Microsoft will release a port of the real thing under the + `Shared Source' license, why bother with anything else? + +A: The Shared Source implementation will not be usable for commercial + purposes. We are working towards an implementation that will grant + a number of rights to recipients: use for any purpose, + redistribution, modification, and redistribution of modifications. + + This is what we call <a + href="http://www.gnu.org/philosophy/free-sw.html">Free Software</a> + +** Passport + +Q: Is this a free implementation of Passport? + +A: No. Passport is part of Microsoft's Hailstorm initiative. Mono + is just a runtime, a compiler and a set of class libraries. + +Q: Will the System.Web.Security.PassportIdentity class, mean + that my software will depend on Passport? + +A: No. That just means that applications might use that API to + contact a Passport site. + + As long as your application does not use Passport, you will not + need Passport. + + It might even be possible to implement that class with + a set of dummy functions, or use an alternate Passport implementation. + + We do not know at this time whether the Passport protocol is + documented and whether we will be able to talk to + passport.com + +Q: What is your opinion? + +A: You can read my personal <a href="passport.html">opinion on + passport</a>. + +** Mono and Windows + +Q: Will Mono allow me to run Microsoft Office on Linux? + +A: No, it will not. Microsoft Office is a Windows application. To + run Windows applications on Intel Unix systems refer to <a + href="http://www.winehq.com">the Wine Project</a> + +** GNOME + +Q: How is this related to GNOME? + +A: In a number of ways: + + * Mono will use existing + components that have been developed for GNOME when it makes + sense. For example on X systems, we will use Gtk+ and + Libart to implement Winforms and the Drawing2D API. + + For database access, we will use LibGDA (not really + depending on GNOME, but related to). + + * This project was born out of the need of providing improved + tools for the GNOME community. + + * We would like to add support to our CLR implementation to + deal with GObjects (in GNOME 1.x, they are called + GtkObjects), and allow Mono developers to provide GObjects + or use and extend existing GObjects. + +Q: Has the GNOME Foundation or the GNOME team adopted Mono? + +A: Mono is too new to be adopted by those groups. We hope that the + tools that we will provide will be adopted by free software + programmers including the GNOME Foundation members and the GNOME + project generally. + +Q: Should GNOME programmers switch over to Mono? + +A: Mono will not be ready even within the next six months, and a + complete implementation is probably one year away. + + We encourage GNOME developers to continue using the existing tools, + libraries and components. Improvements made to GNOME will have an + impact on Mono, as they will provide the "backend" for various + classes. + +Q: Will Mono include compatibility with Bonobo components? + +A: Yes, we will provide a set of classes for implementing and using + Bonobo components from within Mono. + +** Mono and the Web + +Q: Is Mono a way of running Java applets? + +A: No. + +** Web Services + +Q: Is Mono just a new way of writing Web Services? + +A: No. + +Q: If this implements the SDK classes, will I be able to write and + execute .NET Web Services with this? + +A: Yes, you will. + + When the project is finished, you will be able to use the same + technologies that are available through the .NET Framework SDK on + Windows to write Web Services. + +Q: What about Soup? + +A: Soup is a library for GNOME applications to create SOAP server and + SOAP clients. You can browse the source code for soup using <a + href="http://cvs.gnome.org/bonsai">GNOME's Bonsai</a> + +Q: Can I use CORBA? + +A: Yes. The CLI contains enough information about a class that + exposing it to other RPC systems (like CORBA) is really simple, and + does not even require support from an object. + + We will be implementing CORBA interoperation as an extension to the + Mono classes so that we can integrate with Bonobo, just like + Microsoft provides COM interoperation classes and support + mechanisms. + +Q: Can I serialize my objects to other things other than XML? + +A: Yes, although the serializing tools have not yet been planned, and +you would probably have to implement them yourself. + +** Development Tools + +Q: Will it be possible to use the CLI features without using bytecodes + or the JIT? + +A: Yes. The CLI engine will be made available as a shared library. + The garbage collection engine, the threading abstraction, the + object system, the dynamic type code system and the JIT will be + available for C developers to integreate with their applications if + they wish to do so. + +Q: Will you have new development tools? + +A: Hopefully Free Software enthusiasts will contribute tools to + improve the developer environment. These tools could be developed + initially using Microsoft implementation of the CLI and then + executed later with Mono. + +** Mono and Java + +Q: What about using Java? After all there are many languages that + target the Java VM. + +A: You can get very good tools for doing Java development on free + systems right now. <a href="http://www.redhat.com">Red Hat</a> has + contributed a <a href="http://gcc.gnu.org">GCC</a> <a + href="http://gcc.gnu.org/java">frontend for Java</a> that can take + Java sources or Java byte codes and generate native executables; <a + href="http://www.transvirtual.com">Transvirtual</a> has implemented + <a href="http://www.kaffe.org">Kaffe</a> a JIT engine for Java; + Intel also has a Java VM called <a + href="http://www.intel.com/research/mrl/orp">ORP</a>. + + The JVM is not designed to be a general purpose virtual machine. + The Common Intermediate Language (CIL), on the other hand, is + designed to be a target for a + wide variety of programming languages, and has a set of rules + designed to be optimal for JITers. + + +Q: What kind of rules make the Common Intermediate Language useful for + JITers? + +A: The main rule is that the stack in the CLI is not a general purpose + stack. You are not allowed to use it for other purposes than + computing values and passing arguments to functions or return + values. + + At any given call or return instruction, the types on the stack + have to be the same independently of the flow of execution of your + code. + +Q: I heard that the CIL is ideal for JITing and not efficient for + interpreters, is this the case? + +A: The CIL is better suited to be JITed than JVM byte codes, but you + can interpret them as trivially as you can interpret JVM byte + codes. + +** Extending Mono + +Q: Would you allow other classes other than those in the + specification? + +A: Yes. The Microsoft class collection is very big, but it is by no + means complete. It would be nice to have a port of `Camel' (the + Mail API used by Evolution inspired by Java Mail) for Mono + applications. + + You might also want to look into implementing CORBA for Mono. Not + only because it would be useful, but because it sounds like a fun + thing to do, given the fact that the CLI is such a type rich + system. + + For more information on extending Mono, see our <a + href="ideas.html">ideas</a> page. + +** Mono and portability + +Q: Will Mono only work on Linux? + +A: Currently, we are doing our work on Linux-based systems and + Windows. We do not expect many Linux-isms in the code, so it + should be easy to port Mono to other UNIX variants. + +Q: What about Mono on non X-based systems? + +A: Our main intention at Ximian is to be able to develop GNOME + applications with Mono, but if you are interested in providing a + port of the Winform classes to other platforms (frame buffer or + MacOS X for example), we would gladly integrate them, as long + they are under a Free Software License. + +** Reusing existing Code + +Q: What projects will you reuse or build upon? + +A: We want to get Mono in the hands of programmers soon. We are + interested in reusing existing open source software. + +Q: What about Intel's research JIT framework, ORP? + +A: At this time, we are investigating whether we can use elements of + ORP for Mono. ORP is a research JIT engine that has a clear + defined API that splits the JIT from the GC system and the actual + byte code implementation. It is a research product. + +Q: What about using GNU Lightning? + +A: We are also researching <a + href="http://www.gnu.org/software/lightning/lightning.html">GNU + Lightning</a>. + +** Ximian and Microsoft + +Q: Didn't Miguel de Icaza say that `Unix Sucks'? + +A: Yes, he did, as a catch phrase in his opening remark on the Ottawa + Linux Symposium. His talk focused on various ways to improve Unix. + + There is a paper describing some ways to improve Unix at: + + <a href="http://primates.ximian.com/~miguel/bongo-bong.html"> + http://primates.ximian.com/~miguel/bongo-bong.html</a> + +Q: Didn't Ximian's Miguel work for Microsoft? + +A: Actually, Nat Friedman (Ximian's co-founder) did work as an + intern for Microsoft for one summer but Miguel did not. + +Q: Did Nat and Miguel meet at Microsoft? + +A: They met online on the Linux IRC network; They met in person for + the first time in 1997. + +** Mono and Microsoft + +Q: How can you expect Mono to compete with Microsoft, wont this + require an effort too large? + +A: You are right. Mono will never become a reality without the help + of other contributors. Ximian is a small company that can not + finish Mono alone. We will be working with members of the + community to deliver the product. + +Q: Is Microsoft and Corel involved in the Mono implementation? + +A: No, they are not. + +Q: Are you writing Mono from the ECMA specs? + +A: yes, we are writing them from the ECMA specs and the published + materials in print about .NET + +** Acronyms + +Q: What is the difference between CLR (Common Language Runtime) and + CLI (Common Language Infrastructure)? + +A: CLI is the specification of an execution system. The Microsoft + implementation of this specification is named CLR. + + Unless we come up with our own acronym, we could just call ours + also CLR, just because it would do exactly the same thing the + Microsoft implementation does. + +<a name="gcc"> +** Mono and GCC + +Q: Should someone work on a GCC front-end to C#? + +A: I would love if someone does, and we would love to help anyone that + takes on that task, but we do not have the time or expertise to + build a C# compiler with the GCC engine. I find it a lot more fun + personally to work on C# on a C# compiler, which has an intrinsic + beauty. + +Q: Should someone make a GCC backend that will generate CIL images? + +A: I would love to see a backend to GCC that generates CIL images. It + would provide a ton of free compilers that would generate CIL + code. This is something that people would want to look into + anyways for Windows interoperation in the future. + +Q: What about making a front-end to GCC that takes CIL images and + generates native code? + +A: I would love to see this, specially since GCC supports this same + feature for Java Byte Codes. You could use the metadata library + from Mono to read the byte codes (ie, this would be your + "front-end") and generate the trees that get passed to the + optimizer. + + Ideally our implementation of the CLI will be available as a shared + library that could be linked with your application as its runtime + support. + +Q: But would this work around the GPL in the GCC compiler and allow + people to work on non-free front-ends? + +A: People can already do this by targeting the JVM byte codes (there + are about 130 compilers for various languages that target the JVM). + +Q: Why are you writing a JIT engine instead of a front-end to GCC? + +A: The JIT engine and runtime engine will be able to execute CIL + executables generated on Windows. + +** Mono and GNU + +Q: Is Mono part of the GNU project? + +A: Mono is a Ximian project, that is also part of the GNU project. + +** Mono and Portability + +Q: Will Mono work on other variants of Unix? + +A: Yes. We do not expect to add any gratuitous incompatibilities. + +Q: Will Mono run on Windows? + +A: Hopefully yes. Currently some parts of Mono only run on Windows + (the C# compiler is a .NET executable) and other parts have only + been compiled on Linux, but work on Windows with Cygwin. + +Q: Will Mono depend on GNOME? + +A: It will depend only if you are using a particular assembly (for + example, for doing GUI applications). If you are just interested + in Mono for implementing a `Hello World Enterprise P2P Web + Service', you will not need any GNOME component. + +** Performance + +Q: How fast will be Mono? + +A: We can not predict the future, but a conservative estimate is that + it would be at least `as fast as other JIT engines'. + + Now, wishfully thinking I hope that we will ship various JITs with + Mono just like Microsoft has done. A fast JITer when maximum + performance is not needed, but fast load times are important; And + an optimizing JITer that would be slower at generating code but + produce more optimal output. + + The CIL has some advantages over the Java byte code: it is really + an intermediate representation and there are a number of + restrictions on how you can emit CIL code that simplify creating + better JIT engines. + + For example, on the CIL the stack is not really an abstraction + available for the code generator to use at will: it is just a way + of creating a postfix representation of the parsed tree. At any + given call point or return point, the contents of the stack are + expected to contain the same object types independently of how the + instructions was reached. + +** Assorted questions + +Q: You say that the CLI allows multiple languages to execute on the + same environment. Isn't this the purpose of CORBA? + +A: CORBA can be used for this purpose, but think of CORBA mostly as a + inter-process (local machine or remote machine) communication + system. + + Think of the CLI to be targeted to interoperation of languages in + the same process, and CORBA as being a nifty addition for + out-of-process. + + Sure, we have used CORBA for in-proc components, but the lack of an + ABI for in-proc components does not translate into a good framework + for in-proc systems + + + diff --git a/doc/gcc-frontend b/doc/gcc-frontend new file mode 100644 index 00000000000..2b15346db69 --- /dev/null +++ b/doc/gcc-frontend @@ -0,0 +1,9 @@ +* The GCC front-end + + The GCC front-end will accept input in a binary file with + codes in the Common Intermediate Language (CIL), and generate + native code. + + This will allow pre-compilation and full optimization to take + place before a program is executed. + diff --git a/doc/ideas b/doc/ideas new file mode 100644 index 00000000000..acc584d95cf --- /dev/null +++ b/doc/ideas @@ -0,0 +1,40 @@ +* Ideas + + Here are a few ideas of tools, classes and projects that you + could start. More are forthcoming. + +<a name="classes"> +** Classes + + <ul> + * Implement a JXTA protocol implementation: + <a href="http://www.jxta.org">http://www.jxta.org</a> + + * Implement a Mail API, similar to Camel or JavaMail (Camel has + significant architecture features that are required on a real + mailer). + + You can check the current C + <a href="http://cvs.gnome.org/bonsai/rview.cgi?dir=evolution%2Fcamel"> + Camel implementation</a>. + + * Interfacing to Multimedia systems. You might want + to look into the Quicktime API. I know <a + href="mailto:vladimir@ximian.com">Vladimir</a> has + researched the problem before + </ul> + +<a name="projects"> +** Projects + + <ul> + * Implement an xmlStorageSystem for the CLI: + <a href="http://www.soapware.org/xmlStorageSystem"> + http://www.soapware.org/xmlStorageSystem</a> + + * Build a CORBA interoperability engine for the CLR. + You do not need to do all of the work, just talking + the protocol will get us a long way (<a + href="http://www.omg.org">The OMG site</a> has the CORBA specs). + + </ul> diff --git a/doc/index b/doc/index new file mode 100644 index 00000000000..db1035e01bf --- /dev/null +++ b/doc/index @@ -0,0 +1,45 @@ +** Jul 15, 2001 + + Another release of Mono is out, check the <a + href="archive/mono-0.4">Mono 0.4 Release Notes</a>. Get it <a + href="download.html#july-15">here</a>. + +** Jul 14, 2001 + + A <a + href="http://mail.ximian.com/archives/public/mono-list/2001-July/000399.html">new + release</a> of the + runtime, compiler and classes has been made. Get it <a href="download.html#july-14">here</a> + +** Jul 12, 2001 + + I keep getting questions about my opinion on Passport, even when + Mono has <b>nothing</b> to do with it. I finally <a + href="passport.html">wrote something.</a> + +** Jul 9, 2001 + + Today <a href="http://www.ximian.com">Ximian</a> announced the + launch of the Mono + project, an effort to create a free software + (sometimes called open source) implementation of the .NET + Development Framework. + + If you have questions about the + project, please read our list of <a + href="faq.html">Frequently Asked Questions</a>. + + You might also want to <a href="download.html">Download the + source</a> for our work so far. + + You might want to <a + href="resources.html#mailing">subscribe</a> to our mono-list + and mono-announce-list + + You can contact the team at: <a + href="mailto:mono-list@ximian.com">mono-list@ximian.com</a> + +** O'Reilly + + Brian posted a story on <a + href="http://www.oreillynet.com/dotnet">O'Reilly Network .NET</a> diff --git a/doc/passport b/doc/passport new file mode 100644 index 00000000000..facf3ee01b0 --- /dev/null +++ b/doc/passport @@ -0,0 +1,231 @@ +* Microsoft Hailstorm and Passport + + Microsoft Passport is a centralized database hosted by + Microsoft that enhances the consumer experience with the Web + by providing a single logon system that they can use across a + number of participant web sites. + + As you might know by now from our extensive <a + href="faq.html">FAQ</a>, the Mono project has nothing to do + with Microsoft Hailstorm or <a + href="http://www.passport.com">Microsoft Passport.</a> + + Still a lot of people have asked us our opinion on them. + +** Passport + + Passport is important not because of it being breaktrough + technologically speaking, but because the company is in a + position to drive most people toward being suscribers of it. + + At the time of this writing passport is required to use the + free mail service <a href="http://www.hotmail.com">Hotmail</a> + to get customized support for the <a + href="http://www.msn.com">MSN portal</a>, <a + href="http://msdn.microsoft.com">Microsoft Developers + Network</a> and according to the original announcement from + Microsoft <a href="http://www.americanexpress.com">American + Express</a> and <a href="http://www.ebay.com">EBay</a> will be + adopting it. + + There is already a <a + href="http://www.passport.com/Directory/Default.asp?PPDir=C&lc=1033">Large + list</a> of participating sites. + + There are many current users of it and Microsoft will be + driving more users towards Passport as it <a + href="http://news.cnet.com/news/0-1003-200-6343275.html">integrates + it</a> in their upcoming release of Windows. + + Microsoft has also <a + href="http://www.passport.com/Business/JoinPassportNetwork.asp?lc=1033">developed + a toolkit</a> to enable current web merchants to integrate + their services with passport. + + To the end user, there is a clear benefit: they only have to + log into a single network and not remember multiple passwords + across sites on the internet. Companies that adopt passport + will have a competition advantage over those that dont. + Microsoft lists a list of <a + href="http://www.passport.com/Business/Default.asp?lc=1033">benefits</a> + to companies. + + +** The problems of Passport + + There are a number of concerns that different groups have over + Passport. Sometimes I have some, sometimes I do not. But + overall, consumers and businesses can have better solutions. + + <ul> + * <b>Single Point of Failure:</b> As more services and + components depend on remote servers, functionality can + grind to a halt if there is a failure on the + centralized Passport system. + + Such a failure was predicted, and we recently <a + href="http://news.cnet.com/news/0-1005-200-6473003.html">witnessed</a> + got a lot of people worried. + + The outgage lasted for seven days. Think what this + could do to your business. + + * <b>Trust:</b> Not everyone trusts Microsoft to keep + their information confidential. Concerns are not only + at the corporate level policy, but also the fact that + the source code for Microsoft products is not + available, means that trojans or worms could be built + into the products by malicious engineers. This is not + unheard of, as the <a + href="http://slashdot.org/articles/00/04/14/0619206.shtml">Microsoft + Internet Server</a> had a trojan horse built into that + allowed anyone that knew about this to control any + server running IIS. + + * <b>Security:</b> With a centralized system like + Passport, imagine the repercussions of a malicious + hacker gaining access to the Passport database. + Personal information and credit card information about + almost everyone using a computer could be stored there. + + Hackers have already <a + href="http://slashdot.org/articles/00/10/27/1147248.shtml">broken + into Microsoft</a> in the past. And the company was + unable to figure out for how long their systems had been hacked. + </ul> + + Microsoft might or might not realize this. The idea behind + Passport is indeed a good one (I can start to get rid of my + file that keeps track of the 30 logins and passwords or so + that I use across the various services on the net myself). + +** Alternatives to Microsoft Passport + + An alternative to Microsoft Passport needs to take the above + problems into consideration. Any solution of the form `We + will just have a competing offering' will not work. + + The system thus has to be: + + <ul> + * <b>Distributed:</b> The entire authentication + system should not create an internet `blackout' in the + case of failure. + + * <b>Allow for multiple registrars:</b> Users should + be able to choose a registrar (their banks, local + phone company, service provider, Swiss bank, or any + other entity they trust. + + * <b>Mandate good security measures:</b> As a + principle, only Open Source software should be used + for servers in the registrar, and they should conform + to a standard set of tools and software that can be + examined by third parties. + </ul> + + An implementation of this protocol could use the DNS or a + DNS-like setup to distribute the information of users with the + possibility of replicating and caching public information + about the user. + + For instant messaging (another pieces of the Hailstorm bit), + you want to use a non-centralized system like Sun's <a + href="http://www.jxta.org">JXTA</a>. Some people mailed me to + mention Jabber as a messaging platform. + + It could also just use the user e-mail address as the `key' to + choose the registrar (msn.com, hotmail.com -> passport.com; + aol.com -> aol.passport.com; you get the idea). + + The <a + href="http://www.soapware.org/xmlStorageSystem">xmlStorage</a> + idea from <a href="http://www.scripting.com">Dave Winer</a> + could be used to store the information. + + A toolkit for various popular web servers could be provided, + authenticated and should be open sourced (for those of you who + think that a binary program would give more security and would + prevent people from tampering: you are wrong. You can always + use a proxy system that "behaves" like the binary, and passes + information back and forth from the real program, and snoops + in-transit information). + + Good cryptographers need to be involved in this problem to + figure out the details and the possible insecure pieces of a + proposal like this. + +** Implementation: In short + + To keep it short: <b>DNS, JXTA, xmlStorage.</b> + + +** Deploying it + + The implementation of such a system should be a pretty + straightforward tasks once security cryptographers have + designed such a beast. + + The major problems are: + + <ul> + * <b>People might just not care:</b> In a poll to US + citizens a couple of decades ago, it was found that + most people did not care about the rights they were + given by the Bill of Rights, which lead to a number of + laws to be passed in the US that eliminated most of + the rights people had. + + * <b>The industry will move way too slow:</b> + Microsoft's implementation is out in the open now: it + is being deployed, and soon it will be insinuated to + many, many users. The industry needs to get together + soon if they care about this issue. + + By the time the industry reacts, it might be too + late. + </ul> + +** Passport and Mono + + The .NET class libraries includes a Passport class that + applications might use to authenticate with Passport. Since + we do not have information at this point on the exact protocol + of Passport, it is not even feasible to implement it. + + If at some point the information is disclosed, it could be + implemented. + + If a competing system to Passport existed, we could probably + hide all the authentication information to use a number of + different passport-like systems. + + If a user does not want to use Passport at all, he could + always turn it off (or completely remove the class from the + library). After all, this is free software. + + Currently, we are too far from the point where this is a real + issue. + +** Disclaimer + + This is just a group of personal thoughts of mine that I have + placed here because I get asked this question a lot lately. + The views of this page are not a statement from my employer + (Ximian, Inc). + + This is not part of Mono. We are not trying to deal with this + problem. + + Nat Friedman (Ximian's co-founder) has his own ideas on how a + competing system to Passport could be designed, but I will let + <a href="http://www.nat.org/gym">him</a> post his own story. + +** Other Alternatives + + Some people have pointed out <a + href="http://www.xns.org">XNS</a> + +Send comments to me: Miguel de Icaza (<a + href="mailto:miguel@ximian.com">miguel@ximian.com</a>) + diff --git a/doc/pending b/doc/pending new file mode 100644 index 00000000000..e243a10dedf --- /dev/null +++ b/doc/pending @@ -0,0 +1,14 @@ +** Microsoft and GNU and Linux. + +Q: Does this mean that Microsoft is better than Linux? + +A: Many of us are working on <a + href="http://www.gnu.org/philosophy/free-sw.html">free software<a> + and want to have an <a href="http://www.opensource.org">open + source</a> environment that we can change, modify, improve, learn + from, and share with others. Some of us also think that this will + lead on the long run to better software: more efficient, faster, + more robust and more. + + We are willing to take good ideas from any source they come from. + diff --git a/doc/rationale b/doc/rationale new file mode 100644 index 00000000000..1027d292286 --- /dev/null +++ b/doc/rationale @@ -0,0 +1,173 @@ + +* The Mono Project + +** Background. + + The GNOME project goal was to bring missing technologies to + Unix and make it competitive in the current market place for + desktop applications. We also realized early on that language + independence was important, and that is why GNOME APIs were + coded using a standard that allowed the APIs to be easily + wrapped for other languages. Our APIs are available to most + programming languages on Unix (Perl, Python, Scheme, C++, + Objective-C, Ada). + + Later on we decided to use better methods for encapsulating + our APIs, and we started to use CORBA to define interfaces to + components. We complemented it with policy and a set of + standard GNOME interfaces for easily creating reusable, + language independent components, controls and compound + documents. This technology is known as <a + href="http://www.ximian.com/tech/bonobo.php3">Bonobo</a>. + Interfaces to Bonobo exist for C, Perl, Python, and + Java. + + CORBA is good when you define coarse interfaces, and most + Bonobo interfaces are coarse. The only problem is that + Bonobo/CORBA interfaces are not good for small interfaces. + For example, an XML parsing Bonobo/CORBA component would be + inefficient compared to a C API. + +** Another explanation + + I recently explained our motivations to Dave Winer, and he posted + it <a + href="http://scriptingnews.userland.com/stories/storyReader$1275">here</a> + +** Microsoft's .NET + + The Microsoft .NET initiative is confusing because it is a + company wide effort that ranges from development tools to end + user applications. .NET is a branding formative that + has been applied to: + + <ul> + * The .NET development platform, a new platform for + writing software. + + * Web services. + + * Microsoft Server Applications. + + * New tools that use the new development platform. + + * Hailstorm, the Passport centralized single-signon + system that is being integrated into Windows XP. + + </ul> + + Mono is an implementation of the .NET development platform. + +** The Common Language Infrastructure platform. + + Microsoft has created a new development platform. The + highlights of this new development platform are: + + <ul> + * A runtime environment that provides garbage + collection, threading and a virtual machine + specification (The Virtual Execution System, VES) + + * A comprehensive class library. + + * A new language, C#. Very similar to Java, C# + allows programmers to use all the features available + on the .NET runtime. + + * A language specification that compilers can + follow if they want to generate classes and code + that can interoperate with other programming + languages (The Common Language Specification: CLS) + </ul> + + The Common Language Infrastructure platform is similar to the + goals we had in GNOME of giving language independence to + programmers. It is more mature, documented, larger in scope, + and has a consistent design. + + Any API that is written using a CLS provider language can be + used by any language that is a CLS consumer. Compilers + generate code in a format called Common Intermediate Language + (CIL) which is an intermediate representation of a compiled + program and is easy to compile to native code or compiled + using Just-in-Time (JIT) engines. The restrictions placed by + the runtime on the CIL byte codes ensures that it is possible + to do a good job at optimizing the code in a JIT compiler. + + There is not really a lot of innovation in this platform: we + have seen all of these concepts before, and we are all + familiar with how these things work. + + What makes the Common Language Infrastructure development + platform interesting is that it is a good mix of technologies + that have been nicely integrated. + + The .NET development platform is essentially a new foundation + for program development that gives Microsoft a room to grow + for the coming years. + +** ECMA standards. + + Microsoft has submitted the + specifications of C#, the runtime, the metadata and the + other various bits of the .NET development platform to the + <a href="http://www.ecma.ch">ECMA</a> for standarization. + + You can get a copy of the specifications submitted to ECMA + from: <a href="http://www.dotnetexperts.com/ecma">http://www.dotnetexperts.com/ecma</a> + +** Mono: an Open Source Common Language Infrastructure implementation. + + Ximian has begun work on Mono, a project that aims to bring + the Common Language Infrastructure platform to free systems. + + When the GNU project was launched, they picked the best + operating system that was available out there, and they + began to clone it: Unix. + + The .NET development platform is a very rich, powerful, and + well designed platform that would help improve the free + software development platform. Just like the GNU project + began to clone Unix sixteen years ago, we will be cloning the + .NET development platform because it is a great platform to + build on. + +** What makes up Mono? + + There are various pieces that will make up Mono: + + <ul> + * A C# compiler. + + * The Virtual Execution System: that will have the + Just-in-Time compiler, garbage collector, loader, + threading engine. + + A byte code interpreter will be provided for quickly + porting Mono to new systems and debugging the JIT + purposes, but it is not intended to be the ideal + execution environment. + + * An implemenation of the .NET class library. + + * Visual development tools. + + * A CIL GCC frontend. + </ul> + +** Why use GNOME components? + + GNOME is an umbrella project that consists of infrastructural + components (GUI toolkit, XML libraries, CORBA implementation, + printing architecture, imaging system), a desktop environment, + and productivity applications. + + The GNOME infrastructural components can be used to quickly + implement various pieces of the class libraries without reinventing + the wheel, and since all those components are licensed under + the terms of the GNU LGPL it is a perfect fit. + + Libart will be used to implement the Drawing.2D API; Gtk+ and + the GNOME libraries will be used to implement the WinForms + API and of course Glib and libxml will be used in various + places.
\ No newline at end of file diff --git a/doc/release-notes/mono-0.3 b/doc/release-notes/mono-0.3 new file mode 100644 index 00000000000..4976037b957 --- /dev/null +++ b/doc/release-notes/mono-0.3 @@ -0,0 +1,46 @@ +To: mono-list@ximian.com, mono-announce-list@ximian.com +Subject: July 12 snapshots. +FCC: ~/Mail/outbox.txt +X-Windows: Sometimes you fill a vacuum and it still sucks. +--text follows this line-- + +Hey! + + July 12 snapshots of class libraries, the compiler and the mono +runtime are available. + +New on this release: + + * Runtime (module: mono) + + The beginning of a simple interpreter that Paolo started + workign on (can run really simple .NET programs). + + Disassembler copes with more elements of the binary format and + more tokens are decoded. Paolo is working now on moving some + of these to the metadata library. + + More tables are dumped. + + * Class libraries (module: mcs/class) + + Many new more classes are in from Joe, Vladimir, Jeff, Sean + and yours truly. + + Sean fixed the build process, and it is now possible to + compile with a single command the assemblies. We will be + revisiting this mechanism in the future to compile per-OS + assemblies (ie, Unix, Windows, MacOS, etc). + + * Compiler (module mcs/mcs) + + Not much done this week, just a few fixes here and there, and + more work to make it easy to compiler. + + * Documentation (module: mono/doc) + + All the changes to the web site are there for your browsing + pleasure. We still need to integrate the status system in + there. + +Miguel. diff --git a/doc/release-notes/mono-0.4 b/doc/release-notes/mono-0.4 new file mode 100644 index 00000000000..1d7e1cea5f1 --- /dev/null +++ b/doc/release-notes/mono-0.4 @@ -0,0 +1,43 @@ +To: mono-list@ximian.com +Subject: Sunday snapshot available. +Gcc: mail.2001-07 +--text follows this line-- + +Hey guys, + + I promise I will not be doing these so often once we have the CVS +server up. In the meantime: + + * MCS + + Sean got the classes to compile in a single go. You + will need CygWin (www.cygwin.org) to compile though + (GNU make and stuff is required). + + System.Xml.XmlReader contribution from Jason + (WOOHHOO!!). It also contains a nice test-suite for + his functions, and in his new code bit, his + implementation is faster than Microsoft's + + We now ship `jay' as part of the distribution to allow + you to compile the compiler with the same `make' + command. Small fixes to the parser as well were + introduced. + + * Mono 0.4 + + Paolo's interpreter supports call instructions and has + the test suite program that he posted about. + + + All documentation ships now in the mono-0.4.tar.gz + +Notes: + + As usual, MCS is targeted to be compiled on a Windows machine + (you will need Cygwin). + + Mono is targeted to be compiled on a Unix machine or a Windows + machine running Cygwin. + +Miguel.
\ No newline at end of file diff --git a/doc/resources b/doc/resources new file mode 100644 index 00000000000..7ef28be7c12 --- /dev/null +++ b/doc/resources @@ -0,0 +1,109 @@ + +* Resources + + There are a number of resources available for those of you who + want to contribute to the Mono project. Here are a few links. + + If you want to send suggestions for links, address them to <a + mailto="web-mono@ximian.com">web-mono@ximian.com</a>. + +** ECMA Documentation. + + You can get the documentation for the ECMA specs from a number of sites: + <ul> + * <a href="http://msdn.microsoft.com/net/ecma">At MSDN</a> + * <a href="http://www.dotnetexperts.com">Dot Net Experts</a> + * <a href="http://developer.intel.com/software/idap/ecma">Intel</a> + * <a href="http://lightning.csse.monash.edu.au/.net/CLI">Monash University</a> + </ul> + + These contain specifications for the assembler, the metadata, + byte codes supported by the CLI virtual machine, the C# + language and the core class libraries. + + For details on the .NET class libraries, you can + visit the Microsoft's Developer Network: + + <ul> + * <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/cpref_start.asp">.NET Framework Class Library</a> + </ul> + + You can also get this information if you install the Beta2 + release of the .NET Framework. + +<a name="mailing"> +** Mailing Lists + + There are a number of mailing lists for Mono + + <ul> + + * <b><a + href="http://mail.ximian.com/mailman/listinfo/mono-list">mono-list:</a></b> + The general Mono discussion list. + * <b><a + href="http://mail.ximian.com/mailman/listinfo/mono-announce-list">mono-announce-list:</a></b> + Announcements of Mono developments. + * <b><a + href="http://mail.ximian.com/mailman/listinfo/mono-docs-list">mono-docs-list:</a></b> + Discussion on the documentation of Mono. + * <b><a + href="http://discuss.develop.com/dotnet.html">Dotnet mailing + list at Develop.com:</a></b> The guys at Develop Mentor run + this general purpose mailing list. + </ul> + +** Discussion Groups. + + <ul> + + * <a href="http://www.oreillynet.com">O'Reilly + Network</a> has a <a + href="http://www.oreillynet.com/dotnet">section devoted to + .NET</a> + * <a + href="http://msdn.microsoft.com/newsgroups">MSDN</a> also + lists various newsgroups related to .NET</ul> + </ul> + +** Other .NET related projects + + There are a number of related projects to Mono: + + <ul> + * <a + href="http://www.icsharpcode.net/OpenSource/SD/default.asp">Sharp + Develop:</a> an IDE for the C# language written in C#. + + * <a + href="http://www.southern-storm.com.au/portable_net.html">Portable.NET:</a> + + * <a href="http://nunit.sourceforge.net">NUnit:</a> A + testing framework for .NET classes. + + * <a href="http://www.kaffe.org">Kaffe:</a> A popular + Free Software JIT engine for Java. + + * <a href="http://www.intel.com/research/mrl/orp">ORP:</a> A research +JIT/VM/GC system from Intel. + </ul> + +** GNOME Documentation + + Documnetation on GNOME, and the GNOME APIs is available from + the <a href="http://developer.gnome.org">developer</a> site at + GNOME: + + <ul> + * <a href="http://developer.gnome.org/doc/API/">GNOME + API documentation</a> + + * <a href="http://developer.gnome.org/doc/books">GNOME + Online books</a> + + * <A + href="http://developer.gnome.org/arch/">Architecture Overview</a> + </ul> + + +
\ No newline at end of file diff --git a/doc/resources-pending b/doc/resources-pending new file mode 100644 index 00000000000..fd9b9073d64 --- /dev/null +++ b/doc/resources-pending @@ -0,0 +1,30 @@ +** MacOS Documentation + +** Assembly Language Manuals online + Intel + MIPS + SPARC + +** Microsoft + msdn.microsoft.com/net + Research.microsoft.com + +** Related Technologies + + <ul> + + * The CLI allows people to create Web Services using the SOAP + protocol. SOAP is based on XML, XML schemas an the HTTP + protocol. + <ul> + * XML specification. + * XML Namespaces. + * XML Schemas. + * SOAP Specification. + </ul> + </ul> + +** Compiler Information + GCC + GCC Sample front-end tutorial + diff --git a/doc/roadmap b/doc/roadmap new file mode 100644 index 00000000000..6cdfa1366a8 --- /dev/null +++ b/doc/roadmap @@ -0,0 +1,12 @@ +* Roadmap + + We are working on the following three projects at Ximian: + + The C# Compiler (mcs/mcs) + + A .NET compatible Class Library (mcs/class) + + The JIT/interpreter (mono) + + +
\ No newline at end of file diff --git a/doc/runtime b/doc/runtime new file mode 100644 index 00000000000..82bc0a74fa8 --- /dev/null +++ b/doc/runtime @@ -0,0 +1,133 @@ + The MonoNet runtime + + The MonoNet runtime will implement the JIT engine (and a byte + code interpreter for quickly porting to new systems), the + class loader, the garbage collector, threading system and + metadata access libraries. + + Currently the runtime contains the beginning of an image + loader and metadata access entry points. Since Beta2 has been + now released, it is possible to resume work using the ECMA + specs and testing with Beta2-generated executables. + + The runtime core will be implemented in C, in a library + "libMonoVES.so". + +** Executing MSIL/CIL images + + The code will load an executable and map the references to + external assemblies to our own version of the assemblies on + GNU/Linux. + + Our roadmap looks like this, this has been updated as of + <b>Jul 15, 2001</b>: + + <ul> + + * Milestone 1: Fully read and parse all CIL byte-codes + and metadata tokens (ie, a disassembler). + + * Milestone 2: Complete an interpreter for CIL byte + codes. This interpreter can be used temporarly to + run CIL byte code on a system where no JIT is + available. + + * Milestone 3: Define an <i>lburg</i> instruction + selector for the JITer for Intel. Although slower + at JITing than a streaming JITer, it generates + better code. The same grammar can later be used for + the stream jitter. + + * Milestone 4: Implement JITer. + + * Milestone 5: Port of the JITer to non IA32 systems. + </ul> + + A setup similar to the Kaffe JIT engine can be used to + layout the code to support non-IA32 architectures. Our work + will be focused on getting a IA32 version running first. + + The JIT engine should work on Linux and Win32, although you + will need to install the CygWin32 development tools to get a + Unix-like compilation environment. + +** JIT Engine (<b>updated, Jul 14th, 2001</b>) + + We will be using a code-generator generator approach for our + JITer. Given the properties of CIL byte codes, we can take + full advantage of a real instruction selector for our code + generator. + + There are a couple of books that deal with this technique: "A + Retargetable C Compiler" and "Advanced Compiler Design and + Implementation" are good references. You can also get a + technical description of <a + href="http://research.microsoft.com/copyright/accept.asp?path=http://www.research.microsoft.com/~drh/pubs/iburg.pdf&pub=ACM">lbrug</a> + + Previously we had looked at a number of JIT engines and tools, + but they would not take full advantage of the CIL properties: + + <ul> + * <a + href="http://www.intel.com/research/mrl/orp/">ORP</a> + + * <a + href="http://www.gnu.org/software/lightning/">GNU + Lightning</a> + + * href="http://www.eecs.harvard.edu/~nr/toolkit/">NJ Machine + Toolkit</a>.). + + * VCODE. + </ul> + +** Garbage Collection + + We have decided to implement a generational tracing garbage + collector, which is very similar to the one being used by + .NET. For an introduction to the garbage collection system + used by Microsoft's CLR implementation, you can read this book + on <a + href="http://www.amazon.com/exec/obidos/ASIN/0471941484/o/qid=992556433/sr=2-1/ref=aps_sr_b_1_1/103-5866388-0492603">Garbage + Collection.</a> + + Although using a conservative garbage collector like Bohem's + would work, all the type information is available at runtime, + so we can actually implement a better collector than a + conservative collector. + + <ul> + * Garbage collection list and FAQ:<br> + <a href="http://www.iecc.com/gclist/">http://www.iecc.com/gclist/</a> + + * The Microsoft .NET Garbage Collection Implementation:<br> + <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI.asp</a> + <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI.asp</a> + </ul> + +** Useful links + + Paolo Molaro found a few interesting links: + + <ul> + + * On compilation of stack-based languages:<br> + <a href="http://www.complang.tuwien.ac.at/projects/rafts.html"> + http://www.complang.tuwien.ac.at/projects/rafts.html</a> + + * A paper on fast JIT compilation of a stack-based language:<br> + <a href="http://www.research.microsoft.com/~cwfraser/pldi99codegen.pdf"> + http://www.research.microsoft.com/~cwfraser/pldi99codegen.pdf</a> + + * Vmgen generates much of the code for efficient virtual machine (VM) + interpreters from simple descriptions of the VM instructions:<br> + <a href="http://www.complang.tuwien.ac.at/anton/vmgen/"> + http://www.complang.tuwien.ac.at/anton/vmgen</a> + </ul> + +** PInvoke + + PInvoke will be supported, and will be used to wrap Unix API + calls, these in turn are required for reusing some of the + GNOME libraries that will reduce the work we have to do to + deliver a complete class library. diff --git a/doc/status b/doc/status new file mode 100644 index 00000000000..274fb3a24f6 --- /dev/null +++ b/doc/status @@ -0,0 +1,44 @@ +* Project Status + + + Pieces of Mono that have been implemented: + + <ul> + * C# compiler: The C# parser can now generate parse + trees. Next up: semantic analysis, compiler lever optimizations + and code generation. + + * Metadata library: Can currently parse and load + information from .NET modules (executables and DLL + files). It has a few bugs outstanding (table + dimension computation is incorrect). + + Parsing of Exception tables is missing. + + It lacks Token to (Table, Index) mapping, but this + should be trivial to write. + + * Disassembler: Can disassemble .NET modules. Still + lacking exception handling as well as useful debugging + tools (hex dumping, token dumping). + + * Class Libraries: Only a few classes have been + implemented. + </ul> + + Tasks on the critical path: + + <ul> + * Method and Field resolution. + + * Bytecode interpreter: Not implemented yet. + + * Simple JIT: Not implemented yet. + + * Garbage collection engine. + </ul> + + + + + diff --git a/doc/team b/doc/team new file mode 100644 index 00000000000..eff7bc9d3d5 --- /dev/null +++ b/doc/team @@ -0,0 +1,2 @@ +* The MonoNet Team + diff --git a/doc/testing b/doc/testing new file mode 100644 index 00000000000..febabf6550e --- /dev/null +++ b/doc/testing @@ -0,0 +1,21 @@ +* Testing + + All classes in Mono libraries should have comprehensive unit test + suites to go with them. Unit testing is a software engineering + methodology that makes it easier to build correct code. Every + method in every class should have a set of tests to verify + that they work correctly. Mono also needs a testing framework + to make it easy to write and run lots of tests. + + Try <a href="http://nunit.sourceforge.net">NUnit</a> + + Why do unit testing? It becomes simple to run automated tests + for the whole library. Unit tests are a safety net - you can + change part of the code and verify that you haven't broken + anything. Ideally, tests are written before the actual library + code itself. And every time a bug is discovered, a test should + be written to demonstrate the bug and its fix. Then, if + you ever reintroduce the bug, you will know immediately. For + more info, read <a + href="http://nunit.sourceforge.net/doc/testinfected/testing.html"> + JUnit Test Infected: Programmers Love Writing Tests</a>. diff --git a/doc/thanks b/doc/thanks new file mode 100644 index 00000000000..5f2df36f9cd --- /dev/null +++ b/doc/thanks @@ -0,0 +1,6 @@ +* Thanks + + We would like to thank Tim O'Reilly, Brian Jepson and Nathan + Torkington for their help. + + Dave Winer for provided interesting comments and a to read. diff --git a/doc/todo b/doc/todo new file mode 100644 index 00000000000..abae8cdfb40 --- /dev/null +++ b/doc/todo @@ -0,0 +1 @@ +Discuss with write new JIT
\ No newline at end of file diff --git a/doc/tools b/doc/tools new file mode 100644 index 00000000000..1a7065d58aa --- /dev/null +++ b/doc/tools @@ -0,0 +1,25 @@ +* Tools + + We need a number of tools to make people productive using a + Mono-based solution. Some of these tools can be developed on + Windows before Mono is fully finished. + +** Debugger + + We will need a debugging API to debug CLI applications and + then a debugger component that can be used in an IDE + environment. + +** Integrated Development Environment + + There is already a project to create a C# development + environment (SharpDevelop). People could work with the + SharpDevelop hackers to produce a unified development environment. + +** Help Browser + + We need a good help browser that can be used to browse all the + Mono documentation. + + + diff --git a/doc/web/.cvsignore b/doc/web/.cvsignore new file mode 100644 index 00000000000..a023a6f9c7c --- /dev/null +++ b/doc/web/.cvsignore @@ -0,0 +1,2 @@ +*.src +*.html diff --git a/doc/web/commands b/doc/web/commands new file mode 100644 index 00000000000..4184a72fecb --- /dev/null +++ b/doc/web/commands @@ -0,0 +1,17 @@ +0,Home,index.html,index.src +1,FAQ,faq.html,faq.src +0,Mono,rationale.html,rationale.src +1,Runtime,runtime.html,runtime.src +1,Classes,class-library.html,class-library.src +2,Class Status,class-status.html,class-status.src +1,C# Compiler,c-sharp.html,c-sharp.src +1,Status,status.html,status.src +0,Contributing,contributing.html,contributing.src +1,Documentation,documentation.html,documentation.src +1,Test Suite,testing.html,testing.src +1,Tools,tools.html,tools.src +0,Download,download.html,download.src +0,Resources,resources.html,resources.src +1,Ideas,ideas.html,ideas.src +1,Passport,passport.html,passport.src +0,Contact,contact.html,contact.src diff --git a/doc/web/htmlify b/doc/web/htmlify new file mode 100644 index 00000000000..d0e163eaab5 --- /dev/null +++ b/doc/web/htmlify @@ -0,0 +1,24 @@ +#!/usr/bin/perl +$q = 1; + +while (<>){ + chop; + if (/^\* (.*)$/){ + print "<h1>$1</h1>\n"; + } elsif (/^\*\* (.*)$/) { + print "<h2>$1</h2>\n"; + } elsif (/^\*\*\* (.*)$/) { + print "<h3>$1</h3>\n"; + } elsif (/^$/) { + print "<p>\n"; + } elsif (/^\t\t\* (.*)$/) { + print "<li>$1\n"; + } elsif (/^Q: (.*)$/){ + print "<p><a name=\"q$q\"><b>Question $q:</b> $1\n"; + $q++; + } elsif (/^A: (.*)$/){ + print "$1\n"; + } else { + print "$_\n"; + } +} diff --git a/doc/web/images/bgsquares.gif b/doc/web/images/bgsquares.gif Binary files differnew file mode 100644 index 00000000000..864bcd44038 --- /dev/null +++ b/doc/web/images/bgsquares.gif diff --git a/doc/web/images/bgsquares.png b/doc/web/images/bgsquares.png Binary files differnew file mode 100644 index 00000000000..54de2ad1e6d --- /dev/null +++ b/doc/web/images/bgsquares.png diff --git a/doc/web/images/bgsquares.xcf.gz b/doc/web/images/bgsquares.xcf.gz Binary files differnew file mode 100644 index 00000000000..200b5805615 --- /dev/null +++ b/doc/web/images/bgsquares.xcf.gz diff --git a/doc/web/images/mono.gif b/doc/web/images/mono.gif Binary files differnew file mode 100644 index 00000000000..5ce7a218ac7 --- /dev/null +++ b/doc/web/images/mono.gif diff --git a/doc/web/images/mono.png b/doc/web/images/mono.png Binary files differnew file mode 100644 index 00000000000..a19e38acedd --- /dev/null +++ b/doc/web/images/mono.png diff --git a/doc/web/images/pixel.gif b/doc/web/images/pixel.gif Binary files differnew file mode 100644 index 00000000000..a4f37d7e02e --- /dev/null +++ b/doc/web/images/pixel.gif diff --git a/doc/web/images/pixel.png b/doc/web/images/pixel.png Binary files differnew file mode 100644 index 00000000000..d8f33a2a3e4 --- /dev/null +++ b/doc/web/images/pixel.png diff --git a/doc/web/makefile b/doc/web/makefile new file mode 100644 index 00000000000..1e549a40c3a --- /dev/null +++ b/doc/web/makefile @@ -0,0 +1,39 @@ +SOURCES= \ + ../contributing \ + ../class-library \ + ../class-status \ + ../contact \ + ../c-sharp \ + ../documentation \ + ../download \ + ../faq \ + ../gcc-frontend \ + ../index \ + ../ideas \ + ../passport \ + ../rationale \ + ../resources \ + ../roadmap \ + ../runtime \ + ../status \ + ../testing \ + ../tools + +all: + -mkdir site + for i in $(SOURCES); do \ + perl htmlify $$i > `basename $$i`.src; \ + done; + + perl process.pl commands template.html.in . + +clean: + for i in $(SOURCES); do \ + rm -f `basename $$i`.src `basename $$i`.html; \ + done; + +push: + scp *.html www@www.ximian.com:/web/cvsmodules/mono + +push2: + scp *.html primates:public_html/xxx diff --git a/doc/web/process.pl b/doc/web/process.pl new file mode 100755 index 00000000000..157ae9bb08f --- /dev/null +++ b/doc/web/process.pl @@ -0,0 +1,73 @@ +#!/usr/bin/perl +# +# Author: +# Sean MacIsaac +# + +use strict; + +my $full_expand = 1; +my @template; +my $n; + +if ($#ARGV != 2) { + print "process.pl command_file template_file directory_prefix\n"; + exit (); +} + +my $menu = ""; + +open COMMANDS, $ARGV[0] || die "Can not open $ARGV[0]"; +while (<COMMANDS>) { + chop; + my @command = split /,/; + if ($command[0] != -1) { + $menu .= "\t\t"; + if ($command[0] == 0){ + $menu .= "<tr><td valign=\"top\" class=\"navi\"><a class=\"navi\""; + } else { + $menu .= "<tr><td valign=\"top\" class=\"subnavi\">  <a class=\"subnavi\""; + } + $menu .= "HREF=\"$command[2]\">$command[1]</A></td></tr>\n\n"; + } +} +close COMMANDS; + +open TEMPLATE, $ARGV[1] || die "Can not open $ARGV[1]"; +while (<TEMPLATE>) { + push @template, $_; +} +close TEMPLATE; + +open COMMANDS, $ARGV[0] || die "Can not open $ARGV[0]"; +while (<COMMANDS>) { + chop; + my @command = split /,/; + + $n = $ARGV[2] . "/" . $command[2]; + open OUTPUT, ">" . $n || die "Can not create $n"; + + my $content = ""; + open INPUT, $command[3] || die "Can not open $command[3]"; + while (<INPUT>) { + $content .= $_; + } + close INPUT; + + my $line; + my $temp; + my $tit; + my $title; + + $tit = $command[1]; + foreach $line (@template) { + $temp = $line; + $title = "$tit / Mono"; + $temp =~ s/#TITLE#/$title/; + $temp =~ s/#CONTENT#/$content/; + $temp =~ s/#MENU#/$menu/; + print OUTPUT $temp; + } + + close OUTPUT; +} diff --git a/doc/web/template.html.in b/doc/web/template.html.in new file mode 100644 index 00000000000..7b3e5986494 --- /dev/null +++ b/doc/web/template.html.in @@ -0,0 +1,78 @@ +<html> +<head> +<title>#TITLE#</title> +<style type="text/css"> +<!-- + body { font-family: "trebuchet ms", lucida, verdana, helvetica; + background-image: url("images/bgsquares.gif"); + background-attachment: fixed; } + body, td, table { font-family: "trebuchet ms", lucida, verdana, helvetica; + font-size: 12px; } + + .navi { font-size: 14px; background: #444444; } + .subnavi { font-size: 12px; } + .footnote { font-size: 10px; color: #aaaaaa; } + + a.navi { color: #ffffff; text-decoration: none; font-weight: bold; } + a.navi:visited { color: #cccccc; } + a.navi:hover { color: #ee9900; text-decoration: underline; } + + a.subnavi { color: #ffffff; text-decoration: none; font-weight: bold; } + a.subnavi:visited { color: #cccccc; } + a.subnavi:hover { color: #ee9900; text-decoration: underline; } + +// --> +</style> +</head> +<body bgcolor="#555555" text="#000000"> + +<table cellpadding="0" cellspacing="0" border="0" width="100%"> + <tr> + <td><img src="images/pixel.gif"></td><!-- left border --> + <td colspan="4"> + <a href="/"><img src="images/mono.gif" border="0"></a></td> + <td><img src="images/pixel.gif"></td><!-- right border --> + </tr> + <tr> + <td><img src="images/pixel.gif" width="1" height="1"></td> + <td colspan="3" bgcolor="black"><img src="images/pixel.gif" height="2"></td> + <td bgcolor="black"><img src="images/pixel.gif" width="1"></td> + <td><img src="images/pixel.gif"></td> + </tr> + <tr> + <td width="100"><img src="images/pixel.gif"></td> + <td valign="top"> + <table cellpadding="2" valign="top" cellspacing="0" border="0"> + #MENU# + </table> + </td> + <td bgcolor="black" width="1"><img src="images/pixel.gif" width="1"></td> + <td bgcolor="white"> + <table cellpadding="16"> + <tr><td> + #CONTENT# + </td></tr> + </table> + </td> + <td bgcolor="black"><img src="images/pixel.gif" width="1"></td> + <td width="100"><img src="images/pixel.gif"></td> + </tr> + <tr> + <td colspan="2"> + <img src="images/pixel.gif"></td> + <td colspan="2" bgcolor="black"><img src="images/pixel.gif" height="1"></td> + <td bgcolor="black"><img src="images/pixel.gif" width="1"></td> + <td><img src="images/pixel.gif"></td> + </tr> + + <td colspan="2"></td> + <td colspan="2" align="center"> + <a class="footnote" href="mailto: webmaster@go-mono.com">webmaster@go-mono.com</a> + </td> + <td colspan="2"></td> + </tr> +</tr> +</table> + +</body> +</html> diff --git a/mcs/AUTHORS b/mcs/AUTHORS index b3d640ef755..15758203656 100755 --- a/mcs/AUTHORS +++ b/mcs/AUTHORS @@ -1 +1,9 @@ -Miguel de Icaza (miguel@ximian.com)
\ No newline at end of file +C# Compiler: + Miguel de Icaza (miguel@ximian.com) + +Class Libraries: + Jeff Stedfast (fejj@ximian.com) + Joe Shaw (joe@ximian.com) + Miguel de Icaza (miguel@ximian.com) + Sean MacIsaac (macisaac@ximian.com) + Vladimir Vukicevic (vladimir@ximian.com) diff --git a/mcs/class/README b/mcs/class/README new file mode 100644 index 00000000000..d64070d314e --- /dev/null +++ b/mcs/class/README @@ -0,0 +1,34 @@ +The class libraries are grouped together in the assemblies they belong. + +Each directory here represents an assembly, and inside each directory we +divide the code based on the namespace they implement. + +* Missing implementation bits + + If you implement a class and you are missing implementation bits, + please put in the code the word "TODO" and a description of what + is missing to be implemented. + +* Tagging buggy code + + If there is a bug in your implementation tag the problem by using + the word "FIXME" in the code, together with a description of the + problem. + + Do not use XXX or obscure descriptions, because otherwise people + will not be able to understand what you mean. + +* Tagging Lame specs + + Sometimes the specification will be lame (consider Version.ToString (fieldCount) + where there is no way of knowing how many fields are available, making the API + not only stupid, but leading to unreliable code). + + In those cases, use the keyword "LAMESPEC". + +* Coding consideration + + Use 8 space tabs for writing your code (hopefully we can keep + this consistent). If you are modifying someone else's code, try + to keep the coding style similar. + diff --git a/mcs/class/System.Data/makefile b/mcs/class/System.Data/makefile new file mode 100644 index 00000000000..0309fce6107 --- /dev/null +++ b/mcs/class/System.Data/makefile @@ -0,0 +1,4 @@ +all: windows + +windows: + $(csc) /target:library /out:System.Data.dll /nowarn:1595 /recurse:*.cs diff --git a/mcs/class/System.Drawing/makefile b/mcs/class/System.Drawing/makefile new file mode 100644 index 00000000000..6ce10de0043 --- /dev/null +++ b/mcs/class/System.Drawing/makefile @@ -0,0 +1,4 @@ +all: windows + +windows: + $(csc) /target:library /out:System.Drawing.dll /nowarn:1595 /recurse:*.cs diff --git a/mcs/class/System.Management/makefile b/mcs/class/System.Management/makefile new file mode 100644 index 00000000000..c7e57cf750a --- /dev/null +++ b/mcs/class/System.Management/makefile @@ -0,0 +1,4 @@ +all: windows + +windows: + $(csc) /target:library /out:System.Management.dll /nowarn:1595 /recurse:*.cs diff --git a/mcs/class/System.XML/System.Xml/Driver.cs b/mcs/class/System.XML/System.Xml/Driver.cs new file mode 100644 index 00000000000..4bbbf035ca1 --- /dev/null +++ b/mcs/class/System.XML/System.Xml/Driver.cs @@ -0,0 +1,40 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// Driver.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+using System;
+using System.Xml;
+
+public class Driver
+{
+ public static void Main(string[] args)
+ {
+ XmlReader xmlReader = null;
+
+ if (args.Length < 1)
+ {
+ xmlReader = new XmlTextReader(Console.In);
+ }
+ else
+ {
+ xmlReader = new XmlTextReader(args[0]);
+ }
+
+ while (xmlReader.Read())
+ {
+ Console.WriteLine("NodeType = {0}", xmlReader.NodeType);
+ Console.WriteLine(" Name = {0}", xmlReader.Name);
+ Console.WriteLine(" IsEmptyElement = {0}", xmlReader.IsEmptyElement);
+ Console.WriteLine(" HasAttributes = {0}", xmlReader.HasAttributes);
+ Console.WriteLine(" AttributeCount = {0}", xmlReader.AttributeCount);
+ Console.WriteLine(" HasValue = {0}", xmlReader.HasValue);
+ Console.WriteLine(" Value = {0}", xmlReader.Value);
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/ReadState.cs b/mcs/class/System.XML/System.Xml/ReadState.cs new file mode 100644 index 00000000000..373488ef51b --- /dev/null +++ b/mcs/class/System.XML/System.Xml/ReadState.cs @@ -0,0 +1,21 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.ReadState.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+namespace System.Xml
+{
+ public enum ReadState
+ {
+ Closed,
+ EndOfFile,
+ Error,
+ Initial,
+ Interactive
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/Test.cs b/mcs/class/System.XML/System.Xml/Test.cs new file mode 100644 index 00000000000..8b1c1240cf3 --- /dev/null +++ b/mcs/class/System.XML/System.Xml/Test.cs @@ -0,0 +1,817 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.Test.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+using System;
+using System.Diagnostics;
+using System.IO;
+
+using NUnit.Framework;
+
+namespace System.Xml
+{
+ public class Test : TestCase
+ {
+ public Test(string name) : base(name) { }
+
+ private void AssertStartDocument(XmlReader xmlReader)
+ {
+ Assert(xmlReader.ReadState == ReadState.Initial);
+ Assert(xmlReader.NodeType == XmlNodeType.None);
+ Assert(!xmlReader.EOF);
+ }
+
+ private void AssertNode(
+ XmlReader xmlReader,
+ XmlNodeType nodeType,
+ bool isEmptyElement,
+ string name,
+ string value,
+ int attributeCount)
+ {
+ Assert(xmlReader.Read());
+ Assert(xmlReader.ReadState == ReadState.Interactive);
+ Assert(!xmlReader.EOF);
+
+ Assert(xmlReader.NodeType == nodeType);
+ Assert(xmlReader.IsEmptyElement == isEmptyElement);
+ Assert(xmlReader.Name == name);
+ Assert(xmlReader.HasValue == (value != String.Empty));
+ Assert(xmlReader.Value == value);
+ Assert(xmlReader.HasAttributes == (attributeCount > 0));
+ Assert(xmlReader.AttributeCount == attributeCount);
+ }
+
+ private void AssertAttribute(
+ XmlReader xmlReader,
+ string name,
+ string value)
+ {
+ Assert(xmlReader[name] == value);
+ Assert(xmlReader.GetAttribute(name) == value);
+ }
+
+ private void AssertEndDocument(XmlReader xmlReader)
+ {
+ Assert(!xmlReader.Read());
+ Assert(xmlReader.NodeType == XmlNodeType.None);
+ Assert(xmlReader.ReadState == ReadState.EndOfFile);
+ Assert(xmlReader.EOF);
+
+ xmlReader.Close();
+ Assert(xmlReader.ReadState == ReadState.Closed);
+ }
+
+ public void TestEmptyElement()
+ {
+ string xml = "<foo/>";
+ XmlReader xmlReader =
+ new XmlTextReader(new StringReader(xml));
+
+ AssertStartDocument(xmlReader);
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ true, // isEmptyElement
+ "foo", // name
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument(xmlReader);
+ }
+
+ public void TestEmptyElementWithWhitespace()
+ {
+ string xml = "<foo />";
+ XmlReader xmlReader =
+ new XmlTextReader(new StringReader(xml));
+
+ AssertStartDocument(xmlReader);
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ true, // isEmptyElement
+ "foo", // name
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument(xmlReader);
+ }
+
+ public void TestEmptyElementWithStartAndEndTag()
+ {
+ string xml = "<foo></foo>";
+ XmlReader xmlReader =
+ new XmlTextReader(new StringReader(xml));
+
+ AssertStartDocument(xmlReader);
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument(xmlReader);
+ }
+
+ public void TestEmptyElementWithStartAndEndTagWithWhitespace()
+ {
+ string xml = "<foo ></foo >";
+ XmlReader xmlReader =
+ new XmlTextReader(new StringReader(xml));
+
+ AssertStartDocument(xmlReader);
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument(xmlReader);
+ }
+
+ public void TestNestedEmptyTag()
+ {
+ string xml = "<foo><bar/></foo>";
+ XmlReader xmlReader =
+ new XmlTextReader(new StringReader(xml));
+
+ AssertStartDocument(xmlReader);
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ true, // isEmptyElement
+ "bar", // name
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument(xmlReader);
+ }
+
+ public void TestNestedText()
+ {
+ string xml = "<foo>bar</foo>";
+ XmlReader xmlReader =
+ new XmlTextReader(new StringReader(xml));
+
+ AssertStartDocument(xmlReader);
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.Text, // nodeType
+ false, // isEmptyElement
+ String.Empty, // name
+ "bar", // value
+ 0 // attributeCount
+ );
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument(xmlReader);
+ }
+
+ public void TestEmptyElementWithAttribute()
+ {
+ string xml = @"<foo bar=""baz""/>";
+ XmlReader xmlReader =
+ new XmlTextReader(new StringReader(xml));
+
+ AssertStartDocument(xmlReader);
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ true, // isEmptyElement
+ "foo", // name
+ String.Empty, // value
+ 1 // attributeCount
+ );
+
+ AssertAttribute(
+ xmlReader, // xmlReader
+ "bar", // name
+ "baz" // value
+ );
+
+ AssertEndDocument(xmlReader);
+ }
+
+ public void TestStartAndEndTagWithAttribute()
+ {
+ string xml = @"<foo bar='baz'></foo>";
+ XmlReader xmlReader =
+ new XmlTextReader(new StringReader(xml));
+
+ AssertStartDocument(xmlReader);
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // value
+ 1 // attributeCount
+ );
+
+ AssertAttribute(
+ xmlReader, // xmlReader
+ "bar", // name
+ "baz" // value
+ );
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.EndElement, // nodeType
+ false, // isEmptyElement
+ "foo", // name
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument(xmlReader);
+ }
+
+ public void TestEmptyElementWithTwoAttributes()
+ {
+ string xml = @"<foo bar=""baz"" quux='quuux'/>";
+ XmlReader xmlReader =
+ new XmlTextReader(new StringReader(xml));
+
+ AssertStartDocument(xmlReader);
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ true, // isEmptyElement
+ "foo", // name
+ String.Empty, // value
+ 2 // attributeCount
+ );
+
+ AssertAttribute(
+ xmlReader, // xmlReader
+ "bar", // name
+ "baz" // value
+ );
+
+ AssertAttribute(
+ xmlReader, // xmlReader
+ "quux", // name
+ "quuux" // value
+ );
+
+ AssertEndDocument(xmlReader);
+ }
+
+ public void TestProcessingInstructionBeforeDocumentElement()
+ {
+ string xml = "<?foo bar?><baz/>";
+ XmlReader xmlReader =
+ new XmlTextReader(new StringReader(xml));
+
+ AssertStartDocument(xmlReader);
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.ProcessingInstruction, // nodeType
+ false, // isEmptyElement
+ "foo", // name
+ "bar", // value
+ 0 // attributeCount
+ );
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ true, // isEmptyElement
+ "baz", // name
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument(xmlReader);
+ }
+
+ public void TestCommentBeforeDocumentElement()
+ {
+ string xml = "<!--foo--><bar/>";
+ XmlReader xmlReader =
+ new XmlTextReader(new StringReader(xml));
+
+ AssertStartDocument(xmlReader);
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.Comment, // nodeType
+ false, // isEmptyElement
+ String.Empty, // name
+ "foo", // value
+ 0 // attributeCount
+ );
+
+ AssertNode(
+ xmlReader, // xmlReader
+ XmlNodeType.Element, // nodeType
+ true, // isEmptyElement
+ "bar", // name
+ String.Empty, // value
+ 0 // attributeCount
+ );
+
+ AssertEndDocument(xmlReader);
+ }
+
+// The following is #if'ed out because it's specific to the Mono
+// implementation and won't compile when testing Microsoft's code.
+// Feel free to turn it on if you want to test Mono's name tables.
+
+#if false
+
+ public void TestIsFirstNameChar()
+ {
+ for (int ch = 0; ch <= 0xFFFF; ++ch)
+ {
+ Assert(
+ XmlChar.IsFirstNameChar(ch) ==
+ IsFirstNameChar(ch));
+ }
+ }
+
+ public void TestIsNameChar()
+ {
+ for (int ch = 0; ch <= 0xFFFF; ++ch)
+ {
+ Assert(
+ XmlChar.IsNameChar(ch) ==
+ IsNameChar(ch));
+ }
+ }
+
+ private static bool IsFirstNameChar(int ch)
+ {
+ return
+ IsLetter(ch) ||
+ (ch == '_') ||
+ (ch == ':');
+ }
+
+ private static bool IsNameChar(int ch)
+ {
+ return
+ IsLetter(ch) ||
+ IsDigit(ch) ||
+ (ch == '.') ||
+ (ch == '-') ||
+ (ch == '_') ||
+ (ch == ':') ||
+ IsCombiningChar(ch) ||
+ IsExtender(ch);
+ }
+
+ private static bool IsLetter(int ch)
+ {
+ return
+ IsBaseChar(ch) ||
+ IsIdeographic(ch);
+ }
+
+ private static bool IsBaseChar(int ch)
+ {
+ return
+ (ch >= 0x0041 && ch <= 0x005A) ||
+ (ch >= 0x0061 && ch <= 0x007A) ||
+ (ch >= 0x00C0 && ch <= 0x00D6) ||
+ (ch >= 0x00D8 && ch <= 0x00F6) ||
+ (ch >= 0x00F8 && ch <= 0x00FF) ||
+ (ch >= 0x0100 && ch <= 0x0131) ||
+ (ch >= 0x0134 && ch <= 0x013E) ||
+ (ch >= 0x0141 && ch <= 0x0148) ||
+ (ch >= 0x014A && ch <= 0x017E) ||
+ (ch >= 0x0180 && ch <= 0x01C3) ||
+ (ch >= 0x01CD && ch <= 0x01F0) ||
+ (ch >= 0x01F4 && ch <= 0x01F5) ||
+ (ch >= 0x01FA && ch <= 0x0217) ||
+ (ch >= 0x0250 && ch <= 0x02A8) ||
+ (ch >= 0x02BB && ch <= 0x02C1) ||
+ (ch == 0x0386) ||
+ (ch >= 0x0388 && ch <= 0x038A) ||
+ (ch == 0x038C) ||
+ (ch >= 0x038E && ch <= 0x03A1) ||
+ (ch >= 0x03A3 && ch <= 0x03CE) ||
+ (ch >= 0x03D0 && ch <= 0x03D6) ||
+ (ch == 0x03DA) ||
+ (ch == 0x03DC) ||
+ (ch == 0x03DE) ||
+ (ch == 0x03E0) ||
+ (ch >= 0x03E2 && ch <= 0x03F3) ||
+ (ch >= 0x0401 && ch <= 0x040C) ||
+ (ch >= 0x040E && ch <= 0x044F) ||
+ (ch >= 0x0451 && ch <= 0x045C) ||
+ (ch >= 0x045E && ch <= 0x0481) ||
+ (ch >= 0x0490 && ch <= 0x04C4) ||
+ (ch >= 0x04C7 && ch <= 0x04C8) ||
+ (ch >= 0x04CB && ch <= 0x04CC) ||
+ (ch >= 0x04D0 && ch <= 0x04EB) ||
+ (ch >= 0x04EE && ch <= 0x04F5) ||
+ (ch >= 0x04F8 && ch <= 0x04F9) ||
+ (ch >= 0x0531 && ch <= 0x0556) ||
+ (ch == 0x0559) ||
+ (ch >= 0x0561 && ch <= 0x0586) ||
+ (ch >= 0x05D0 && ch <= 0x05EA) ||
+ (ch >= 0x05F0 && ch <= 0x05F2) ||
+ (ch >= 0x0621 && ch <= 0x063A) ||
+ (ch >= 0x0641 && ch <= 0x064A) ||
+ (ch >= 0x0671 && ch <= 0x06B7) ||
+ (ch >= 0x06BA && ch <= 0x06BE) ||
+ (ch >= 0x06C0 && ch <= 0x06CE) ||
+ (ch >= 0x06D0 && ch <= 0x06D3) ||
+ (ch == 0x06D5) ||
+ (ch >= 0x06E5 && ch <= 0x06E6) ||
+ (ch >= 0x0905 && ch <= 0x0939) ||
+ (ch == 0x093D) ||
+ (ch >= 0x0958 && ch <= 0x0961) ||
+ (ch >= 0x0985 && ch <= 0x098C) ||
+ (ch >= 0x098F && ch <= 0x0990) ||
+ (ch >= 0x0993 && ch <= 0x09A8) ||
+ (ch >= 0x09AA && ch <= 0x09B0) ||
+ (ch == 0x09B2) ||
+ (ch >= 0x09B6 && ch <= 0x09B9) ||
+ (ch >= 0x09DC && ch <= 0x09DD) ||
+ (ch >= 0x09DF && ch <= 0x09E1) ||
+ (ch >= 0x09F0 && ch <= 0x09F1) ||
+ (ch >= 0x0A05 && ch <= 0x0A0A) ||
+ (ch >= 0x0A0F && ch <= 0x0A10) ||
+ (ch >= 0x0A13 && ch <= 0x0A28) ||
+ (ch >= 0x0A2A && ch <= 0x0A30) ||
+ (ch >= 0x0A32 && ch <= 0x0A33) ||
+ (ch >= 0x0A35 && ch <= 0x0A36) ||
+ (ch >= 0x0A38 && ch <= 0x0A39) ||
+ (ch >= 0x0A59 && ch <= 0x0A5C) ||
+ (ch == 0x0A5E) ||
+ (ch >= 0x0A72 && ch <= 0x0A74) ||
+ (ch >= 0x0A85 && ch <= 0x0A8B) ||
+ (ch == 0x0A8D) ||
+ (ch >= 0x0A8F && ch <= 0x0A91) ||
+ (ch >= 0x0A93 && ch <= 0x0AA8) ||
+ (ch >= 0x0AAA && ch <= 0x0AB0) ||
+ (ch >= 0x0AB2 && ch <= 0x0AB3) ||
+ (ch >= 0x0AB5 && ch <= 0x0AB9) ||
+ (ch == 0x0ABD) ||
+ (ch == 0x0AE0) ||
+ (ch >= 0x0B05 && ch <= 0x0B0C) ||
+ (ch >= 0x0B0F && ch <= 0x0B10) ||
+ (ch >= 0x0B13 && ch <= 0x0B28) ||
+ (ch >= 0x0B2A && ch <= 0x0B30) ||
+ (ch >= 0x0B32 && ch <= 0x0B33) ||
+ (ch >= 0x0B36 && ch <= 0x0B39) ||
+ (ch == 0x0B3D) ||
+ (ch >= 0x0B5C && ch <= 0x0B5D) ||
+ (ch >= 0x0B5F && ch <= 0x0B61) ||
+ (ch >= 0x0B85 && ch <= 0x0B8A) ||
+ (ch >= 0x0B8E && ch <= 0x0B90) ||
+ (ch >= 0x0B92 && ch <= 0x0B95) ||
+ (ch >= 0x0B99 && ch <= 0x0B9A) ||
+ (ch == 0x0B9C) ||
+ (ch >= 0x0B9E && ch <= 0x0B9F) ||
+ (ch >= 0x0BA3 && ch <= 0x0BA4) ||
+ (ch >= 0x0BA8 && ch <= 0x0BAA) ||
+ (ch >= 0x0BAE && ch <= 0x0BB5) ||
+ (ch >= 0x0BB7 && ch <= 0x0BB9) ||
+ (ch >= 0x0C05 && ch <= 0x0C0C) ||
+ (ch >= 0x0C0E && ch <= 0x0C10) ||
+ (ch >= 0x0C12 && ch <= 0x0C28) ||
+ (ch >= 0x0C2A && ch <= 0x0C33) ||
+ (ch >= 0x0C35 && ch <= 0x0C39) ||
+ (ch >= 0x0C60 && ch <= 0x0C61) ||
+ (ch >= 0x0C85 && ch <= 0x0C8C) ||
+ (ch >= 0x0C8E && ch <= 0x0C90) ||
+ (ch >= 0x0C92 && ch <= 0x0CA8) ||
+ (ch >= 0x0CAA && ch <= 0x0CB3) ||
+ (ch >= 0x0CB5 && ch <= 0x0CB9) ||
+ (ch == 0x0CDE) ||
+ (ch >= 0x0CE0 && ch <= 0x0CE1) ||
+ (ch >= 0x0D05 && ch <= 0x0D0C) ||
+ (ch >= 0x0D0E && ch <= 0x0D10) ||
+ (ch >= 0x0D12 && ch <= 0x0D28) ||
+ (ch >= 0x0D2A && ch <= 0x0D39) ||
+ (ch >= 0x0D60 && ch <= 0x0D61) ||
+ (ch >= 0x0E01 && ch <= 0x0E2E) ||
+ (ch == 0x0E30) ||
+ (ch >= 0x0E32 && ch <= 0x0E33) ||
+ (ch >= 0x0E40 && ch <= 0x0E45) ||
+ (ch >= 0x0E81 && ch <= 0x0E82) ||
+ (ch == 0x0E84) ||
+ (ch >= 0x0E87 && ch <= 0x0E88) ||
+ (ch == 0x0E8A) ||
+ (ch == 0x0E8D) ||
+ (ch >= 0x0E94 && ch <= 0x0E97) ||
+ (ch >= 0x0E99 && ch <= 0x0E9F) ||
+ (ch >= 0x0EA1 && ch <= 0x0EA3) ||
+ (ch == 0x0EA5) ||
+ (ch == 0x0EA7) ||
+ (ch >= 0x0EAA && ch <= 0x0EAB) ||
+ (ch >= 0x0EAD && ch <= 0x0EAE) ||
+ (ch == 0x0EB0) ||
+ (ch >= 0x0EB2 && ch <= 0x0EB3) ||
+ (ch == 0x0EBD) ||
+ (ch >= 0x0EC0 && ch <= 0x0EC4) ||
+ (ch >= 0x0F40 && ch <= 0x0F47) ||
+ (ch >= 0x0F49 && ch <= 0x0F69) ||
+ (ch >= 0x10A0 && ch <= 0x10C5) ||
+ (ch >= 0x10D0 && ch <= 0x10F6) ||
+ (ch == 0x1100) ||
+ (ch >= 0x1102 && ch <= 0x1103) ||
+ (ch >= 0x1105 && ch <= 0x1107) ||
+ (ch == 0x1109) ||
+ (ch >= 0x110B && ch <= 0x110C) ||
+ (ch >= 0x110E && ch <= 0x1112) ||
+ (ch == 0x113C) ||
+ (ch == 0x113E) ||
+ (ch == 0x1140) ||
+ (ch == 0x114C) ||
+ (ch == 0x114E) ||
+ (ch == 0x1150) ||
+ (ch >= 0x1154 && ch <= 0x1155) ||
+ (ch == 0x1159) ||
+ (ch >= 0x115F && ch <= 0x1161) ||
+ (ch == 0x1163) ||
+ (ch == 0x1165) ||
+ (ch == 0x1167) ||
+ (ch == 0x1169) ||
+ (ch >= 0x116D && ch <= 0x116E) ||
+ (ch >= 0x1172 && ch <= 0x1173) ||
+ (ch == 0x1175) ||
+ (ch == 0x119E) ||
+ (ch == 0x11A8) ||
+ (ch == 0x11AB) ||
+ (ch >= 0x11AE && ch <= 0x11AF) ||
+ (ch >= 0x11B7 && ch <= 0x11B8) ||
+ (ch == 0x11BA) ||
+ (ch >= 0x11BC && ch <= 0x11C2) ||
+ (ch == 0x11EB) ||
+ (ch == 0x11F0) ||
+ (ch == 0x11F9) ||
+ (ch >= 0x1E00 && ch <= 0x1E9B) ||
+ (ch >= 0x1EA0 && ch <= 0x1EF9) ||
+ (ch >= 0x1F00 && ch <= 0x1F15) ||
+ (ch >= 0x1F18 && ch <= 0x1F1D) ||
+ (ch >= 0x1F20 && ch <= 0x1F45) ||
+ (ch >= 0x1F48 && ch <= 0x1F4D) ||
+ (ch >= 0x1F50 && ch <= 0x1F57) ||
+ (ch == 0x1F59) ||
+ (ch == 0x1F5B) ||
+ (ch == 0x1F5D) ||
+ (ch >= 0x1F5F && ch <= 0x1F7D) ||
+ (ch >= 0x1F80 && ch <= 0x1FB4) ||
+ (ch >= 0x1FB6 && ch <= 0x1FBC) ||
+ (ch == 0x1FBE) ||
+ (ch >= 0x1FC2 && ch <= 0x1FC4) ||
+ (ch >= 0x1FC6 && ch <= 0x1FCC) ||
+ (ch >= 0x1FD0 && ch <= 0x1FD3) ||
+ (ch >= 0x1FD6 && ch <= 0x1FDB) ||
+ (ch >= 0x1FE0 && ch <= 0x1FEC) ||
+ (ch >= 0x1FF2 && ch <= 0x1FF4) ||
+ (ch >= 0x1FF6 && ch <= 0x1FFC) ||
+ (ch == 0x2126) ||
+ (ch >= 0x212A && ch <= 0x212B) ||
+ (ch == 0x212E) ||
+ (ch >= 0x2180 && ch <= 0x2182) ||
+ (ch >= 0x3041 && ch <= 0x3094) ||
+ (ch >= 0x30A1 && ch <= 0x30FA) ||
+ (ch >= 0x3105 && ch <= 0x312C) ||
+ (ch >= 0xAC00 && ch <= 0xD7A3);
+ }
+
+ private static bool IsIdeographic(int ch)
+ {
+ return
+ (ch >= 0x4E00 && ch <= 0x9FA5) ||
+ (ch == 0x3007) ||
+ (ch >= 0x3021 && ch <= 0x3029);
+ }
+
+ private static bool IsDigit(int ch)
+ {
+ return
+ (ch >= 0x0030 && ch <= 0x0039) ||
+ (ch >= 0x0660 && ch <= 0x0669) ||
+ (ch >= 0x06F0 && ch <= 0x06F9) ||
+ (ch >= 0x0966 && ch <= 0x096F) ||
+ (ch >= 0x09E6 && ch <= 0x09EF) ||
+ (ch >= 0x0A66 && ch <= 0x0A6F) ||
+ (ch >= 0x0AE6 && ch <= 0x0AEF) ||
+ (ch >= 0x0B66 && ch <= 0x0B6F) ||
+ (ch >= 0x0BE7 && ch <= 0x0BEF) ||
+ (ch >= 0x0C66 && ch <= 0x0C6F) ||
+ (ch >= 0x0CE6 && ch <= 0x0CEF) ||
+ (ch >= 0x0D66 && ch <= 0x0D6F) ||
+ (ch >= 0x0E50 && ch <= 0x0E59) ||
+ (ch >= 0x0ED0 && ch <= 0x0ED9) ||
+ (ch >= 0x0F20 && ch <= 0x0F29);
+ }
+
+ private static bool IsCombiningChar(int ch)
+ {
+ return
+ (ch >= 0x0300 && ch <= 0x0345) ||
+ (ch >= 0x0360 && ch <= 0x0361) ||
+ (ch >= 0x0483 && ch <= 0x0486) ||
+ (ch >= 0x0591 && ch <= 0x05A1) ||
+ (ch >= 0x05A3 && ch <= 0x05B9) ||
+ (ch >= 0x05BB && ch <= 0x05BD) ||
+ (ch == 0x05BF) ||
+ (ch >= 0x05C1 && ch <= 0x05C2) ||
+ (ch == 0x05C4) ||
+ (ch >= 0x064B && ch <= 0x0652) ||
+ (ch == 0x0670) ||
+ (ch >= 0x06D6 && ch <= 0x06DC) ||
+ (ch >= 0x06DD && ch <= 0x06DF) ||
+ (ch >= 0x06E0 && ch <= 0x06E4) ||
+ (ch >= 0x06E7 && ch <= 0x06E8) ||
+ (ch >= 0x06EA && ch <= 0x06ED) ||
+ (ch >= 0x0901 && ch <= 0x0903) ||
+ (ch == 0x093C) ||
+ (ch >= 0x093E && ch <= 0x094C) ||
+ (ch == 0x094D) ||
+ (ch >= 0x0951 && ch <= 0x0954) ||
+ (ch >= 0x0962 && ch <= 0x0963) ||
+ (ch >= 0x0981 && ch <= 0x0983) ||
+ (ch == 0x09BC) ||
+ (ch == 0x09BE) ||
+ (ch == 0x09BF) ||
+ (ch >= 0x09C0 && ch <= 0x09C4) ||
+ (ch >= 0x09C7 && ch <= 0x09C8) ||
+ (ch >= 0x09CB && ch <= 0x09CD) ||
+ (ch == 0x09D7) ||
+ (ch >= 0x09E2 && ch <= 0x09E3) ||
+ (ch == 0x0A02) ||
+ (ch == 0x0A3C) ||
+ (ch == 0x0A3E) ||
+ (ch == 0x0A3F) ||
+ (ch >= 0x0A40 && ch <= 0x0A42) ||
+ (ch >= 0x0A47 && ch <= 0x0A48) ||
+ (ch >= 0x0A4B && ch <= 0x0A4D) ||
+ (ch >= 0x0A70 && ch <= 0x0A71) ||
+ (ch >= 0x0A81 && ch <= 0x0A83) ||
+ (ch == 0x0ABC) ||
+ (ch >= 0x0ABE && ch <= 0x0AC5) ||
+ (ch >= 0x0AC7 && ch <= 0x0AC9) ||
+ (ch >= 0x0ACB && ch <= 0x0ACD) ||
+ (ch >= 0x0B01 && ch <= 0x0B03) ||
+ (ch == 0x0B3C) ||
+ (ch >= 0x0B3E && ch <= 0x0B43) ||
+ (ch >= 0x0B47 && ch <= 0x0B48) ||
+ (ch >= 0x0B4B && ch <= 0x0B4D) ||
+ (ch >= 0x0B56 && ch <= 0x0B57) ||
+ (ch >= 0x0B82 && ch <= 0x0B83) ||
+ (ch >= 0x0BBE && ch <= 0x0BC2) ||
+ (ch >= 0x0BC6 && ch <= 0x0BC8) ||
+ (ch >= 0x0BCA && ch <= 0x0BCD) ||
+ (ch == 0x0BD7) ||
+ (ch >= 0x0C01 && ch <= 0x0C03) ||
+ (ch >= 0x0C3E && ch <= 0x0C44) ||
+ (ch >= 0x0C46 && ch <= 0x0C48) ||
+ (ch >= 0x0C4A && ch <= 0x0C4D) ||
+ (ch >= 0x0C55 && ch <= 0x0C56) ||
+ (ch >= 0x0C82 && ch <= 0x0C83) ||
+ (ch >= 0x0CBE && ch <= 0x0CC4) ||
+ (ch >= 0x0CC6 && ch <= 0x0CC8) ||
+ (ch >= 0x0CCA && ch <= 0x0CCD) ||
+ (ch >= 0x0CD5 && ch <= 0x0CD6) ||
+ (ch >= 0x0D02 && ch <= 0x0D03) ||
+ (ch >= 0x0D3E && ch <= 0x0D43) ||
+ (ch >= 0x0D46 && ch <= 0x0D48) ||
+ (ch >= 0x0D4A && ch <= 0x0D4D) ||
+ (ch == 0x0D57) ||
+ (ch == 0x0E31) ||
+ (ch >= 0x0E34 && ch <= 0x0E3A) ||
+ (ch >= 0x0E47 && ch <= 0x0E4E) ||
+ (ch == 0x0EB1) ||
+ (ch >= 0x0EB4 && ch <= 0x0EB9) ||
+ (ch >= 0x0EBB && ch <= 0x0EBC) ||
+ (ch >= 0x0EC8 && ch <= 0x0ECD) ||
+ (ch >= 0x0F18 && ch <= 0x0F19) ||
+ (ch == 0x0F35) ||
+ (ch == 0x0F37) ||
+ (ch == 0x0F39) ||
+ (ch == 0x0F3E) ||
+ (ch == 0x0F3F) ||
+ (ch >= 0x0F71 && ch <= 0x0F84) ||
+ (ch >= 0x0F86 && ch <= 0x0F8B) ||
+ (ch >= 0x0F90 && ch <= 0x0F95) ||
+ (ch == 0x0F97) ||
+ (ch >= 0x0F99 && ch <= 0x0FAD) ||
+ (ch >= 0x0FB1 && ch <= 0x0FB7) ||
+ (ch == 0x0FB9) ||
+ (ch >= 0x20D0 && ch <= 0x20DC) ||
+ (ch == 0x20E1) ||
+ (ch >= 0x302A && ch <= 0x302F) ||
+ (ch == 0x3099) ||
+ (ch == 0x309A);
+ }
+
+ private static bool IsExtender(int ch)
+ {
+ return
+ (ch == 0x00B7) ||
+ (ch == 0x02D0) ||
+ (ch == 0x02D1) ||
+ (ch == 0x0387) ||
+ (ch == 0x0640) ||
+ (ch == 0x0E46) ||
+ (ch == 0x0EC6) ||
+ (ch == 0x3005) ||
+ (ch >= 0x3031 && ch <= 0x3035) ||
+ (ch >= 0x309D && ch <= 0x309E) ||
+ (ch >= 0x30FC && ch <= 0x30FE);
+ }
+
+#endif
+
+ public void TestIsName()
+ {
+ Assert(XmlReader.IsName("foo"));
+ Assert(!XmlReader.IsName("1foo"));
+ Assert(!XmlReader.IsName(" foo"));
+ }
+
+ public void TestIsNameToken()
+ {
+ Assert(XmlReader.IsNameToken("foo"));
+ Assert(XmlReader.IsNameToken("1foo"));
+ Assert(!XmlReader.IsNameToken(" foo"));
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlChar.cs b/mcs/class/System.XML/System.Xml/XmlChar.cs new file mode 100644 index 00000000000..0a76ae07898 --- /dev/null +++ b/mcs/class/System.XML/System.Xml/XmlChar.cs @@ -0,0 +1,202 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlChar.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+using System;
+
+namespace System.Xml
+{
+ internal class XmlChar
+ {
+ internal static bool IsWhitespace(int ch)
+ {
+ return ch == 0x20 || ch == 0x9 || ch == 0xD || ch == 0xA;
+ }
+
+ internal static bool IsFirstNameChar(int ch)
+ {
+ bool result = false;
+
+ if (ch >= 0 && ch <= 0xFFFF)
+ {
+ result = (nameBitmap[(firstNamePages[ch >> 8] << 3) + ((ch & 0xFF) >> 5)] & (1 << (ch & 0x1F))) != 0;
+ }
+
+ return result;
+ }
+
+ internal static bool IsNameChar(int ch)
+ {
+ bool result = false;
+
+ if (ch >= 0 && ch <= 0xFFFF)
+ {
+ result = (nameBitmap[(namePages[ch >> 8] << 3) + ((ch & 0xFF) >> 5)] & (1 << (ch & 0x1F))) != 0;
+ }
+
+ return result;
+ }
+
+ private static byte[] firstNamePages =
+ {
+ 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00,
+ 0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
+ 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+
+ private static byte[] namePages =
+ {
+ 0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00,
+ 0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
+ 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
+ 0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+
+ private static uint[] nameBitmap =
+ {
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+ 0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE,
+ 0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
+ 0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF,
+ 0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
+ 0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
+ 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
+ 0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
+ 0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
+ 0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF,
+ 0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000,
+ 0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
+ 0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003,
+ 0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003,
+ 0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
+ 0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001,
+ 0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003,
+ 0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
+ 0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003,
+ 0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003,
+ 0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000,
+ 0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
+ 0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF,
+ 0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB,
+ 0x40000000, 0xF580C900, 0x00000007, 0x02010800,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+ 0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF,
+ 0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
+ 0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
+ 0x00000000, 0x00004C40, 0x00000000, 0x00000000,
+ 0x00000007, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF,
+ 0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF,
+ 0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+ 0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+ 0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000,
+ 0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
+ 0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF,
+ 0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
+ 0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003,
+ 0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
+ 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
+ 0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
+ 0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
+ 0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
+ 0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF,
+ 0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF,
+ 0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
+ 0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF,
+ 0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0,
+ 0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
+ 0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3,
+ 0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80,
+ 0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
+ 0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3,
+ 0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000,
+ 0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000,
+ 0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
+ 0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
+ 0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
+ 0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF
+ };
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNameTable.cs b/mcs/class/System.XML/System.Xml/XmlNameTable.cs new file mode 100644 index 00000000000..4f0df67af64 --- /dev/null +++ b/mcs/class/System.XML/System.Xml/XmlNameTable.cs @@ -0,0 +1,20 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlNameTable.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+namespace System.Xml
+{
+ public abstract class XmlNameTable
+ {
+ public abstract string Add(string name);
+ public abstract string Add(char[] buffer, int offset, int length);
+ public abstract string Get(string name);
+ public abstract string Get(char[] buffer, int offset, int length);
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs b/mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs new file mode 100644 index 00000000000..2c9a4a0c738 --- /dev/null +++ b/mcs/class/System.XML/System.Xml/XmlNamespaceManager.cs @@ -0,0 +1,22 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlNamespaceManager.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+using System.Collections;
+
+namespace System.Xml
+{
+ public class XmlNamespaceManager : IEnumerable
+ {
+ public IEnumerator GetEnumerator()
+ {
+ return null;
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlNodeType.cs b/mcs/class/System.XML/System.Xml/XmlNodeType.cs new file mode 100644 index 00000000000..a01c34ee65b --- /dev/null +++ b/mcs/class/System.XML/System.Xml/XmlNodeType.cs @@ -0,0 +1,34 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlNodeType.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+namespace System.Xml
+{
+ public enum XmlNodeType
+ {
+ Attribute,
+ CDATA,
+ Comment,
+ Document,
+ DocumentFragment,
+ DocumentType,
+ Element,
+ EndElement,
+ EndEntity,
+ Entity,
+ EntityReference,
+ None,
+ Notation,
+ ProcessingInstruction,
+ SignifigantWhitespace,
+ Text,
+ Whitespace,
+ XmlDeclaration
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlParserContext.cs b/mcs/class/System.XML/System.Xml/XmlParserContext.cs new file mode 100644 index 00000000000..a88f579c077 --- /dev/null +++ b/mcs/class/System.XML/System.Xml/XmlParserContext.cs @@ -0,0 +1,127 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlParserContext.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+namespace System.Xml
+{
+ public class XmlParserContext
+ {
+ // constructors
+
+ public XmlParserContext(
+ XmlNameTable nameTable,
+ XmlNamespaceManager namespaceManager,
+ string xmlLang,
+ XmlSpace xmlSpace) :
+
+ this(
+ nameTable,
+ namespaceManager,
+ null,
+ null,
+ null,
+ null,
+ null,
+ xmlLang,
+ xmlSpace
+ )
+ {
+ }
+
+ public XmlParserContext(
+ XmlNameTable nameTable,
+ XmlNamespaceManager namespaceManager,
+ string docTypeName,
+ string publicID,
+ string systemID,
+ string internalSubset,
+ string baseURI,
+ string xmlLang,
+ XmlSpace xmlSpace)
+ {
+ this.nameTable = nameTable;
+ this.namespaceManager = namespaceManager;
+ this.docTypeName = docTypeName;
+ this.publicID = publicID;
+ this.systemID = systemID;
+ this.internalSubset = internalSubset;
+ this.baseURI = baseURI;
+ this.xmlLang = xmlLang;
+ this.xmlSpace = xmlSpace;
+ }
+
+ // properties
+
+ public string BaseURI
+ {
+ get { return baseURI; }
+ set { baseURI = value; }
+ }
+
+ public string DocTypeName
+ {
+ get { return docTypeName; }
+ set { docTypeName = value; }
+ }
+
+ public string InternalSubset
+ {
+ get { return internalSubset; }
+ set { internalSubset = value; }
+ }
+
+ public XmlNamespaceManager NamespaceManager
+ {
+ get { return namespaceManager; }
+ set { namespaceManager = value; }
+ }
+
+ public XmlNameTable NameTable
+ {
+ get { return nameTable; }
+ set { nameTable = nameTable; }
+ }
+
+ public string PublicId
+ {
+ get { return publicID; }
+ set { publicID = value; }
+ }
+
+ public string SystemId
+ {
+ get { return systemID; }
+ set { systemID = value; }
+ }
+
+ public string XmlLang
+ {
+ get { return xmlLang; }
+ set { xmlLang = value; }
+ }
+
+ public XmlSpace XmlSpace
+ {
+ get { return xmlSpace; }
+ set { xmlSpace = value; }
+ }
+
+ // privates
+
+ private string baseURI;
+ private string docTypeName;
+ private string internalSubset;
+ private XmlNamespaceManager namespaceManager;
+ private XmlNameTable nameTable;
+ private string publicID;
+ private string systemID;
+ private string xmlLang;
+ private XmlSpace xmlSpace;
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlReader.cs b/mcs/class/System.XML/System.Xml/XmlReader.cs new file mode 100644 index 00000000000..e386b819593 --- /dev/null +++ b/mcs/class/System.XML/System.Xml/XmlReader.cs @@ -0,0 +1,238 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlReader.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+namespace System.Xml
+{
+ public abstract class XmlReader
+ {
+ // properties
+
+ public abstract int AttributeCount { get; }
+
+ public abstract string BaseURI { get; }
+
+ public virtual bool CanResolveEntity
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public abstract int Depth { get; }
+
+ public abstract bool EOF { get; }
+
+ public virtual bool HasAttributes
+ {
+ get
+ {
+ return AttributeCount > 0;
+ }
+ }
+
+ public abstract bool HasValue { get; }
+
+ public abstract bool IsDefault { get; }
+
+ public abstract bool IsEmptyElement { get; }
+
+ public abstract string this[int i] { get; }
+
+ public abstract string this[string name] { get; }
+
+ public abstract string this[
+ string localName,
+ string namespaceName]
+ { get; }
+
+ public abstract string LocalName { get; }
+
+ public abstract string Name { get; }
+
+ public abstract string NamespaceURI { get; }
+
+ public abstract XmlNameTable NameTable { get; }
+
+ public abstract XmlNodeType NodeType { get; }
+
+ public abstract string Prefix { get; }
+
+ public abstract char QuoteChar { get; }
+
+ public abstract ReadState ReadState { get; }
+
+ public abstract string Value { get; }
+
+ public abstract string XmlLang { get; }
+
+ public abstract XmlSpace XmlSpace { get; }
+
+ // methods
+
+ public abstract void Close();
+
+ public abstract string GetAttribute(int i);
+
+ public abstract string GetAttribute(string name);
+
+ public abstract string GetAttribute(
+ string localName,
+ string namespaceName);
+
+ public static bool IsName(string s)
+ {
+ bool result = false;
+
+ if (s != null && s.Length > 0)
+ {
+ char[] chars = s.ToCharArray();
+
+ if (XmlChar.IsFirstNameChar(chars[0]))
+ {
+ int i = 1;
+ int n = chars.Length;
+
+ while (i < n && XmlChar.IsNameChar(chars[i]))
+ {
+ ++i;
+ }
+
+ result = i == n;
+ }
+ }
+
+ return result;
+ }
+
+ public static bool IsNameToken(string s)
+ {
+ bool result = false;
+
+ if (s != null && s.Length > 0)
+ {
+ char[] chars = s.ToCharArray();
+
+ int i = 0;
+ int n = chars.Length;
+
+ while (i < n && XmlChar.IsNameChar(chars[i]))
+ {
+ ++i;
+ }
+
+ result = i == n;
+ }
+
+ return result;
+ }
+
+ public virtual bool IsStartElement()
+ {
+ // TODO: implement me.
+ return false;
+ }
+
+ public virtual bool IsStartElement(string name)
+ {
+ // TODO: implement me.
+ return false;
+ }
+
+ public virtual bool IsStartElement(
+ string localName,
+ string namespaceName)
+ {
+ // TODO: implement me.
+ return false;
+ }
+
+ public abstract string LookupNamespace(string prefix);
+
+ public abstract void MoveToAttribute(int i);
+
+ public abstract bool MoveToAttribute(string name);
+
+ public abstract bool MoveToAttribute(
+ string localName,
+ string namespaceName);
+
+ public virtual XmlNodeType MoveToContent()
+ {
+ // TODO: implement me.
+ return XmlNodeType.None;
+ }
+
+ public abstract bool MoveToElement();
+
+ public abstract bool MoveToFirstAttribute();
+
+ public abstract bool MoveToNextAttribute();
+
+ public abstract bool Read();
+
+ public abstract bool ReadAttributeValue();
+
+ public virtual string ReadElementString()
+ {
+ // TODO: implement me.
+ return null;
+ }
+
+ public virtual string ReadElementString(string name)
+ {
+ // TODO: implement me.
+ return null;
+ }
+
+ public virtual string ReadElementString(
+ string localName,
+ string namespaceName)
+ {
+ // TODO: implement me.
+ return null;
+ }
+
+ public virtual void ReadEndElement()
+ {
+ // TODO: implement me.
+ }
+
+ public abstract string ReadInnerXml();
+
+ public abstract string ReadOuterXml();
+
+ public virtual void ReadStartElement()
+ {
+ // TODO: implement me.
+ }
+
+ public virtual void ReadStartElement(string name)
+ {
+ // TODO: implement me.
+ }
+
+ public virtual void ReadStartElement(
+ string localName,
+ string namespaceName)
+ {
+ // TODO: implement me.
+ }
+
+ public abstract string ReadString();
+
+ public abstract void ResolveEntity();
+
+ public virtual void Skip()
+ {
+ // TODO: implement me.
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlSpace.cs b/mcs/class/System.XML/System.Xml/XmlSpace.cs new file mode 100644 index 00000000000..18f753ce584 --- /dev/null +++ b/mcs/class/System.XML/System.Xml/XmlSpace.cs @@ -0,0 +1,19 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlSpace.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+namespace System.Xml
+{
+ public enum XmlSpace
+ {
+ Default,
+ None,
+ Preserve
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/XmlTextReader.cs b/mcs/class/System.XML/System.Xml/XmlTextReader.cs new file mode 100644 index 00000000000..cc736ed5870 --- /dev/null +++ b/mcs/class/System.XML/System.Xml/XmlTextReader.cs @@ -0,0 +1,797 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlTextReader.cs
+//
+// Author:
+// Jason Diamond (jason@injektilo.org)
+//
+// (C) 2001 Jason Diamond http://injektilo.org/
+//
+
+// FIXME:
+// This can only parse basic XML: elements, attributes, processing
+// instructions, and comments are OK but there's no support for
+// entity/character references or namespaces yet.
+//
+// It barfs on DOCTYPE declarations and CDATA sections.
+//
+// There's also no checking being done for either well-formedness
+// or validity.
+//
+// ParserContext and NameTables aren't being used yet.
+//
+// The XmlTextReader-specific properties and methods have yet to
+// be added or implemented.
+//
+// Some thought needs to be given to performance. There's too many
+// strings and string builders being allocated.
+//
+// None of the MoveTo methods have been implemented yet.
+//
+// LineNumber and LinePosition aren't being tracked.
+//
+// xml:space, xml:lang, and xml:base aren't being tracked.
+//
+// Depth isn't being tracked.
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Net;
+using System.Text;
+
+namespace System.Xml
+{
+ public class XmlTextReader : XmlReader
+ {
+ // constructors
+
+ protected XmlTextReader()
+ {
+ Init();
+ }
+
+ public XmlTextReader(Stream input)
+ {
+ Init();
+ reader = new StreamReader(
+ input,
+ Encoding.UTF8,
+ true);
+ }
+
+ public XmlTextReader(string url)
+ {
+ Init();
+ WebClient client = new WebClient();
+ reader = new StreamReader(
+ client.OpenRead(url),
+ Encoding.UTF8,
+ true);
+ }
+
+ public XmlTextReader(TextReader input)
+ {
+ Init();
+ reader = input;
+ }
+
+ public XmlTextReader(Stream input, XmlNameTable nameTable)
+ {
+ // TODO: implement me.
+ throw new NotImplementedException();
+ }
+
+ public XmlTextReader(string baseURI, Stream input)
+ {
+ // TODO: implement me.
+ throw new NotImplementedException();
+ }
+
+ public XmlTextReader(string baseURI, TextReader input)
+ {
+ // TODO: implement me.
+ throw new NotImplementedException();
+ }
+
+ public XmlTextReader(string url, XmlNameTable nameTable)
+ {
+ // TODO: implement me.
+ throw new NotImplementedException();
+ }
+
+ public XmlTextReader(
+ TextReader input,
+ XmlNameTable nameTable)
+ {
+ // TODO: implement me.
+ throw new NotImplementedException();
+ }
+
+ public XmlTextReader(
+ Stream inputFragment,
+ XmlNodeType fragmentType,
+ XmlParserContext context)
+ {
+ // TODO: implement me.
+ throw new NotImplementedException();
+ }
+
+ public XmlTextReader(
+ string baseURI,
+ Stream input,
+ XmlNameTable nameTable)
+ {
+ // TODO: implement me.
+ throw new NotImplementedException();
+ }
+
+ public XmlTextReader(
+ string baseURI,
+ TextReader input,
+ XmlNameTable nameTable)
+ {
+ // TODO: implement me.
+ throw new NotImplementedException();
+ }
+
+ public XmlTextReader(
+ string fragment,
+ XmlNodeType fragmentType,
+ XmlParserContext context)
+ {
+ // TODO: implement me.
+ throw new NotImplementedException();
+ }
+
+ // properties
+
+ public override int AttributeCount
+ {
+ get
+ {
+ return attributes.Count;
+ }
+ }
+
+ public override string BaseURI
+ {
+ get
+ {
+ // TODO: implement me.
+ return null;
+ }
+ }
+
+ public override bool CanResolveEntity
+ {
+ get
+ {
+ // TODO: implement me.
+ return false;
+ }
+ }
+
+ public override int Depth
+ {
+ get
+ {
+ // TODO: implement me.
+ return 0;
+ }
+ }
+
+ public override bool EOF
+ {
+ get
+ {
+ return
+ readState == ReadState.EndOfFile ||
+ readState == ReadState.Closed;
+ }
+ }
+
+ public override bool HasValue
+ {
+ get
+ {
+ return value != String.Empty;
+ }
+ }
+
+ public override bool IsDefault
+ {
+ get
+ {
+ // TODO: implement me.
+ return false;
+ }
+ }
+
+ public override bool IsEmptyElement
+ {
+ get
+ {
+ return isEmptyElement;
+ }
+ }
+
+ public override string this[int i]
+ {
+ get
+ {
+ return GetAttribute(i);
+ }
+ }
+
+ public override string this[string name]
+ {
+ get
+ {
+ return GetAttribute(name);
+ }
+ }
+
+ public override string this[
+ string localName,
+ string namespaceName]
+ {
+ get
+ {
+ return GetAttribute(localName, namespaceName);
+ }
+ }
+
+ public override string LocalName
+ {
+ get
+ {
+ // TODO: implement me.
+ return null;
+ }
+ }
+
+ public override string Name
+ {
+ get
+ {
+ return name;
+ }
+ }
+
+ public override string NamespaceURI
+ {
+ get
+ {
+ // TODO: implement me.
+ return null;
+ }
+ }
+
+ public override XmlNameTable NameTable
+ {
+ get
+ {
+ // TODO: implement me.
+ return null;
+ }
+ }
+
+ public override XmlNodeType NodeType
+ {
+ get
+ {
+ return nodeType;
+ }
+ }
+
+ public override string Prefix
+ {
+ get
+ {
+ // TODO: implement me.
+ return null;
+ }
+ }
+
+ public override char QuoteChar
+ {
+ get
+ {
+ // TODO: implement me.
+ return '"';
+ }
+ }
+
+ public override ReadState ReadState
+ {
+ get
+ {
+ return readState;
+ }
+ }
+
+ public override string Value
+ {
+ get
+ {
+ return value;
+ }
+ }
+
+ public override string XmlLang
+ {
+ get
+ {
+ // TODO: implement me.
+ return null;
+ }
+ }
+
+ public override XmlSpace XmlSpace
+ {
+ get
+ {
+ // TODO: implement me.
+ return XmlSpace.Default;
+ }
+ }
+
+ // methods
+
+ public override void Close()
+ {
+ readState = ReadState.Closed;
+ }
+
+ public override string GetAttribute(int i)
+ {
+ // TODO: implement me.
+ return null;
+ }
+
+ public override string GetAttribute(string name)
+ {
+ return (string)attributes[name];
+ }
+
+ public override string GetAttribute(
+ string localName,
+ string namespaceName)
+ {
+ // TODO: implement me.
+ return null;
+ }
+
+ public override string LookupNamespace(string prefix)
+ {
+ // TODO: implement me.
+ return null;
+ }
+
+ public override void MoveToAttribute(int i)
+ {
+ // TODO: implement me.
+ }
+
+ public override bool MoveToAttribute(string name)
+ {
+ // TODO: implement me.
+ return false;
+ }
+
+ public override bool MoveToAttribute(
+ string localName,
+ string namespaceName)
+ {
+ // TODO: implement me.
+ return false;
+ }
+
+ public override bool MoveToElement()
+ {
+ // TODO: implement me.
+ return false;
+ }
+
+ public override bool MoveToFirstAttribute()
+ {
+ // TODO: implement me.
+ return false;
+ }
+
+ public override bool MoveToNextAttribute()
+ {
+ // TODO: implement me.
+ return false;
+ }
+
+ public override bool Read()
+ {
+ bool more = false;
+
+ readState = ReadState.Interactive;
+
+ more = ReadContent();
+
+ return more;
+ }
+
+ public override bool ReadAttributeValue()
+ {
+ // TODO: implement me.
+ return false;
+ }
+
+ public override string ReadInnerXml()
+ {
+ // TODO: implement me.
+ return null;
+ }
+
+ public override string ReadOuterXml()
+ {
+ // TODO: implement me.
+ return null;
+ }
+
+ public override string ReadString()
+ {
+ // TODO: implement me.
+ return null;
+ }
+
+ public override void ResolveEntity()
+ {
+ // TODO: implement me.
+ }
+
+ // privates
+
+ private TextReader reader;
+ private ReadState readState;
+
+ private XmlNodeType nodeType;
+ private string name;
+ private bool isEmptyElement;
+ private string value;
+ private Hashtable attributes;
+
+ private void Init()
+ {
+ readState = ReadState.Initial;
+
+ nodeType = XmlNodeType.None;
+ name = String.Empty;
+ isEmptyElement = false;
+ value = String.Empty;
+ attributes = new Hashtable();
+ }
+
+ // Use this method rather than setting the properties
+ // directly so that all the necessary properties can
+ // be changed in harmony with each other. Maybe the
+ // fields should be in a seperate class to help enforce
+ // this.
+ private void SetProperties(
+ XmlNodeType nodeType,
+ string name,
+ bool isEmptyElement,
+ string value,
+ bool clearAttributes)
+ {
+ this.nodeType = nodeType;
+ this.name = name;
+ this.isEmptyElement = isEmptyElement;
+ this.value = value;
+
+ if (clearAttributes)
+ {
+ ClearAttributes();
+ }
+ }
+
+ private void AddAttribute(string name, string value)
+ {
+ attributes.Add(name, value);
+ }
+
+ private void ClearAttributes()
+ {
+ attributes.Clear();
+ }
+
+ // This should really keep track of some state so
+ // that it's not possible to have more than one document
+ // element or text outside of the document element.
+ private bool ReadContent()
+ {
+ bool more = false;
+
+ switch (reader.Peek())
+ {
+ case '<':
+ reader.Read();
+ ReadTag();
+ more = true;
+ break;
+ case -1:
+ readState = ReadState.EndOfFile;
+ SetProperties(
+ XmlNodeType.None, // nodeType
+ String.Empty, // name
+ false, // isEmptyElement
+ String.Empty, // value
+ true // clearAttributes
+ );
+ more = false;
+ break;
+ default:
+ ReadText();
+ more = true;
+ break;
+ }
+
+ return more;
+ }
+
+ // The leading '<' has already been consumed.
+ private void ReadTag()
+ {
+ switch (reader.Peek())
+ {
+ case '/':
+ reader.Read();
+ ReadEndTag();
+ break;
+ case '?':
+ reader.Read();
+ ReadProcessingInstruction();
+ break;
+ case '!':
+ reader.Read();
+ ReadComment();
+ break;
+ default:
+ ReadStartTag();
+ break;
+ }
+ }
+
+ // The leading '<' has already been consumed.
+ private void ReadStartTag()
+ {
+ string name = ReadName();
+ SkipWhitespace();
+
+ bool isEmptyElement = false;
+
+ ClearAttributes();
+
+ if (XmlChar.IsFirstNameChar(reader.Peek()))
+ {
+ ReadAttributes();
+ }
+
+ if (reader.Peek() == '/')
+ {
+ reader.Read();
+ isEmptyElement = true;
+ }
+
+ Expect('>');
+
+ SetProperties(
+ XmlNodeType.Element, // nodeType
+ name, // name
+ isEmptyElement, // isEmptyElement
+ String.Empty, // value
+ false // clearAttributes
+ );
+ }
+
+ // The reader is positioned on the first character
+ // of the element's name.
+ private void ReadEndTag()
+ {
+ string name = ReadName();
+ SkipWhitespace();
+ Expect('>');
+
+ SetProperties(
+ XmlNodeType.EndElement, // nodeType
+ name, // name
+ false, // isEmptyElement
+ String.Empty, // value
+ true // clearAttributes
+ );
+ }
+
+ // The reader is positioned on the first character
+ // of the text.
+ private void ReadText()
+ {
+ StringBuilder text = new StringBuilder();
+ text.Append((char)reader.Read());
+
+ while (reader.Peek() != '<' && reader.Peek() != -1)
+ {
+ text.Append((char)reader.Read());
+ }
+
+ SetProperties(
+ XmlNodeType.Text, // nodeType
+ String.Empty, // name
+ false, // isEmptyElement
+ text.ToString(), // value
+ true // clearAttributes
+ );
+ }
+
+ // The reader is positioned on the first character of
+ // the attribute name.
+ private void ReadAttributes()
+ {
+ do
+ {
+ string name = ReadName();
+ SkipWhitespace();
+ Expect('=');
+ SkipWhitespace();
+ string value = ReadAttribute();
+ SkipWhitespace();
+
+ AddAttribute(name, value);
+ }
+ while (reader.Peek() != '/' && reader.Peek() != '>' && reader.Peek() != -1);
+ }
+
+ // The reader is positioned on the quote character.
+ private string ReadAttribute()
+ {
+ int quoteChar = reader.Read();
+
+ if (quoteChar != '\'' && quoteChar != '\"')
+ {
+ throw new Exception("an attribute value was not quoted");
+ }
+
+ StringBuilder valueBuilder = new StringBuilder();
+
+ while (reader.Peek() != quoteChar)
+ {
+ int ch = reader.Read();
+
+ switch (ch)
+ {
+ case '<':
+ throw new Exception("attribute values cannot contain '<'");
+ case -1:
+ throw new Exception("unexpected end of file in an attribute value");
+ }
+
+ valueBuilder.Append((char)ch);
+ }
+
+ reader.Read();
+
+ return valueBuilder.ToString();
+ }
+
+ // The reader is positioned on the first character
+ // of the target.
+ private void ReadProcessingInstruction()
+ {
+ string target = ReadName();
+ SkipWhitespace();
+
+ StringBuilder valueBuilder = new StringBuilder();
+
+ while (reader.Peek() != -1)
+ {
+ int ch = reader.Read();
+
+ if (ch == '?' && reader.Peek() == '>')
+ {
+ reader.Read();
+ break;
+ }
+
+ valueBuilder.Append((char)ch);
+ }
+
+ SetProperties(
+ XmlNodeType.ProcessingInstruction, // nodeType
+ target, // name
+ false, // isEmptyElement
+ valueBuilder.ToString(), // value
+ true // clearAttributes
+ );
+ }
+
+ // The reader is positioned on the first character after
+ // the leading '<!'.
+ private void ReadComment()
+ {
+ Expect('-');
+ Expect('-');
+
+ StringBuilder valueBuilder = new StringBuilder();
+
+ while (reader.Peek() != -1)
+ {
+ int ch = reader.Read();
+
+ if (ch == '-' && reader.Peek() == '-')
+ {
+ reader.Read();
+
+ if (reader.Peek() != '>')
+ {
+ throw new Exception("comments cannot contain '--'");
+ }
+
+ reader.Read();
+ break;
+ }
+
+ valueBuilder.Append((char)ch);
+ }
+
+ SetProperties(
+ XmlNodeType.Comment, // nodeType
+ String.Empty, // name
+ false, // isEmptyElement
+ valueBuilder.ToString(), // value
+ true // clearAttributes
+ );
+ }
+
+ // The reader is positioned on the first character
+ // of the name.
+ private string ReadName()
+ {
+ if (!XmlChar.IsFirstNameChar(reader.Peek()))
+ {
+ throw new Exception("a name did not start with a legal character");
+ }
+
+ StringBuilder nameBuilder = new StringBuilder();
+
+ nameBuilder.Append((char)reader.Read());
+
+ while (XmlChar.IsNameChar(reader.Peek()))
+ {
+ nameBuilder.Append((char)reader.Read());
+ }
+
+ return nameBuilder.ToString();
+ }
+
+ // Read the next character and compare it against the
+ // specified character.
+ private void Expect(int expected)
+ {
+ int ch = reader.Read();
+
+ if (ch != expected)
+ {
+ throw new Exception(String.Format(
+ "expected '{0}' ({1:X}) but found '{2}' ({3:X})",
+ (char)expected,
+ expected,
+ (char)ch,
+ ch));
+ }
+ }
+
+ // Does not consume the first non-whitespace character.
+ private void SkipWhitespace()
+ {
+ while (XmlChar.IsWhitespace(reader.Peek()))
+ {
+ reader.Read();
+ }
+ }
+ }
+}
diff --git a/mcs/class/System.XML/System.Xml/common.src b/mcs/class/System.XML/System.Xml/common.src new file mode 100644 index 00000000000..8315e7ca50b --- /dev/null +++ b/mcs/class/System.XML/System.Xml/common.src @@ -0,0 +1,8 @@ +XmlChar.cs +XmlNameTable.cs +XmlNamespaceManager.cs +XmlNodeType.cs +XmlParserContext.cs +XmlReader.cs +XmlSpace.cs +XmlTextReader.cs diff --git a/mcs/class/System.XML/makefile b/mcs/class/System.XML/makefile new file mode 100644 index 00000000000..781ecffcbaf --- /dev/null +++ b/mcs/class/System.XML/makefile @@ -0,0 +1,14 @@ +all: + @echo "You must use 'make windows' or 'make unix'." + @echo "'make unix' is broken for now." + +windows: make-list + $(CSC) /target:library /out:System.XML.dll /nowarn:1595 @list + +unix: + @echo "'make unix' is broken for now." + +make-list: + cat $$i/common.src $$i/windows.src | sed "s/^/$$i\\\\/"; + +test: $(PLATFORM)
\ No newline at end of file diff --git a/mcs/class/System/.cvsignore b/mcs/class/System/.cvsignore new file mode 100644 index 00000000000..c5f30212276 --- /dev/null +++ b/mcs/class/System/.cvsignore @@ -0,0 +1,2 @@ +System.dll +list diff --git a/mcs/class/System/System.CodeDom.Compiler/ChangeLog b/mcs/class/System/System.CodeDom.Compiler/ChangeLog new file mode 100755 index 00000000000..8462e3c2fc2 --- /dev/null +++ b/mcs/class/System/System.CodeDom.Compiler/ChangeLog @@ -0,0 +1,5 @@ +2001-07-15 Sean MacIsaac <macisaac@ximian.com> + + * CodeGenerator.cs: moved using statement out of namespace + declaration. + diff --git a/mcs/class/System/System.CodeDom.Compiler/CodeGenerator.cs b/mcs/class/System/System.CodeDom.Compiler/CodeGenerator.cs new file mode 100755 index 00000000000..00525b3bcd2 --- /dev/null +++ b/mcs/class/System/System.CodeDom.Compiler/CodeGenerator.cs @@ -0,0 +1,237 @@ +// +// System.CodeDom.Compiler CodeGenerator class +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +using System.CodeDom; +using System.Reflection; +using System.IO; + +namespace System.CodeDom.Compiler { + + public abstract class CodeGenerator : ICodeGenerator { + protected TextWriter output; + + protected virtual void ContinueOnNewLine (string st) + { + } + + CodeGenerator () + { + indent = 8; + } + + // + // Code Generation methods + // + protected abstract void GenerateArrayCreateExpression (CodeArrayCreateExpression e); + protected abstract void GenerateAssignStatement (CodeAssignStatement s); + protected abstract void GenerateAttachEventStatement (CodeAttachEventStatement s); + protected abstract void GenerateBaseReferenceExpression (CodeBaseReferenceExpression e); + protected abstract void GenerateBinaryOperatorExpression (CodeBinaryOperatorExpression x); + protected abstract void GenerateCastExpression (CodeCastExpression x); + protected abstract void GenerateClasses (CodeNamespace x); + protected abstract void GenerateCommentStatement (CodeCommentStatement x); + protected abstract void GenerateConstructor (CodeConstructor x, CodeTypeDeclaration c); + protected abstract void GenerateDelegateCreateExpression (CodeDelegateCreateExpression x); + protected abstract void GenerateDelegateInvokeExpression (CodeDelegateInvokeExpression x); + protected abstract void GenerateEvent (CodeMemberEvent x, CodeTypeDeclaration c); + protected abstract void GenerateExpression (CodeExpression x); + protected abstract void GenerateField (CodeMemberField x); + protected abstract void GenerateFieldReferenceExpression (CodeFieldReferenceExpression x); + protected abstract void GenerateIndexerExpression (CodeIndexerExpression x); + protected abstract void GenerateLinePragmaStart (CodeLinePragma x); + protected abstract void GenerateLinePragmaEnd (CodeLinePragma x); + protected abstract void GenerateMethod (CodeMemberMethod m, CodeTypeDeclaration c); + protected abstract void GenerateMethodInvokeExpression (CodeMethodInvokeExpression x); + protected abstract void GenerateMethodReturnStatement (CodeMethodReturnStatement x); + protected abstract void GenerateNamespace (CodeNamespace x); + protected abstract void GenerateNamespaceStart (CodeNamespace x); + protected abstract void GenerateNamespaceEnd (CodeNamespace x); + protected abstract void GenerateNamespaceImport (CodeNamespaceImport i); + protected abstract void GenerateNamespaceImports (CodeNamespace i); + protected abstract void GenerateObjectCreateExpression (CodeObjectCreateExpression x); + protected abstract void GenerateParameterDeclarationExpression (CodeParameterDeclarationExpression x); + protected abstract void GeneratePrimitiveExpression (CodePrimitiveExpression x); + protected abstract void GenerateProperty (CodeMemberProperty e, CodeTypeDeclaration c); + protected abstract void GeneratePropertyReferenceExpression (CodePropertyReferenceExpression x); + protected abstract void GenerateStatement (CodeStatement x); + protected abstract void GenerateStatementCollection (CodeStatementCollection x); + protected abstract void GenerateThisReferenceExpression (CodeThisReferenceExpression x); + protected abstract void GenerateThrowExceptionStatement (CodeThrowExceptionStatement x); + protected abstract void GenerateTryCatchFinallyStatement (CodeTryCatchFinallyStatement x); + protected abstract void GenerateTypeOfExpression (CodeTypeOfExpression x); + protected abstract void GenerateTypeReferenceExpression (CodeTypeReferenceExpression x); + protected abstract void GenerateVariableDeclarationStatement (CodeVariableDeclarationStatement x); + + // + // Other members + // + protected abstract string GetNullToken (); + + public abstract bool IsValidIdentifier (string value); + + public static bool IsValidLanguateIndependentIdentifier (string value) + { + /* FIXME: implement */ + return true; + } + + // + // Output functions + // + protected virtual void OutputAttributeArgument (CodeAttributeArgument arg) + { + } + + protected virtual void OutputDirection (FieldDirection dir) + { + } + + protected virtual void OutputExpressionList (CodeExpressionCollection c) + { + } + + protected virtual void OutputExpressionLIst (CodeExpressionCollection c, bool useNewlines) + { + } + + protected virtual void OutputFieldScopeModifier (MemberAttributes attrs) + { + } + + protected virtual void OutputIdentifier (string ident) + { + } + + protected virtual void OutputMemberAccessModifier (MemberAttributes attrs) + { + } + + protected virtual void OutputMemberScopeModifier (MemberAttributes attrs) + { + } + + protected virtual void OutputOperator (CodeBinaryOperatorType op) + { + } + + protected virtual void OutputParameters (CodeParameterDeclarationExpressionCollection pars) + { + } + + protected virtual void OutputType (string typeRef) + { + } + + protected virtual void OutputTypeAttributes (TypeAttributes attrs) + { + } + + protected virtual void OutputTypeNamePair (string typeRef, string name) + { + } + + + protected abstract string QuoteLiteralString (string value); + + public virtual void ValidateIdentifier (string value) + { + } + + // + // Properties + // + protected string currentClassName; + protected string CurrentClassName { + get { + return currentClassName; + } + } + + protected CodeTypeMember codeClassMember; + protected CodeTypeMember CurrentMember { + get { + return codeClassMember; + } + } + + protected string CurrentMemberName { + get { + return codeClassMember.Name; + } + } + + int indent; + protected int Indent { + get { + return indent; + } + + set { + indent = value; + } + } + + // + // This concept seems broken, I should not really be using + // a flag, I should be "probing" what is being generated. + // at least the Start/End + // functions should not be abstract, or abstract could + // have an implementation piece? + // + public bool isCurrentClass; + protected bool IsCurrentClass { + get { + return isCurrentClass; + } + } + + public bool isCurrentDelegate; + protected bool IsCurrentDelegate { + get { + return isCurrentDelegate; + } + } + public bool isCurrentEnum; + protected bool IsCurrentEnum { + get { + return isCurrentEnum; + } + } + public bool isCurrentInterface; + protected bool IsCurrentInterface { + get { + return isCurrentInterface; + } + } + + public bool isCurrentStruct; + protected bool IsCurrentStruct { + get { + return isCurrentStruct; + } + } + + protected TextWriter Output { + get { + return output; + } + + set { + output = value; + } + } + + public abstract void GenerateCodeFromExpression (TextWriter output, CodeExpression expression); + + public abstract void GenerateCodeFromNamespace (TextWriter output, CodeExpression expression); + + public abstract void GenerateCodeFromStatement (TextWriter output, CodeStatement expression); + + } +} diff --git a/mcs/class/System/System.CodeDom.Compiler/ICodeGenerator.cs b/mcs/class/System/System.CodeDom.Compiler/ICodeGenerator.cs new file mode 100755 index 00000000000..3cdbb32c7f6 --- /dev/null +++ b/mcs/class/System/System.CodeDom.Compiler/ICodeGenerator.cs @@ -0,0 +1,30 @@ +// +// System.CodeDom.Compiler ICodeGenerator Interface +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom.Compiler { + using System.CodeDom; + using System.IO; + + public interface ICodeGenerator { + + + // <summary> + // Generates code for @expression on @output + // </summary> + void GenerateCodeFromExpression (TextWriter output, CodeExpression expression); + + void GenerateCodeFromNamespace (TextWriter output, CodeExpression expression); + + void GenerateCodeFromStatement (TextWriter output, CodeStatement expression); + + bool IsValidIdentifier (string value); + + void ValidateIdentifier (string value); + } +} diff --git a/mcs/class/System/System.CodeDom.Compiler/common.src b/mcs/class/System/System.CodeDom.Compiler/common.src new file mode 100755 index 00000000000..d4a8e2b560f --- /dev/null +++ b/mcs/class/System/System.CodeDom.Compiler/common.src @@ -0,0 +1,2 @@ +ICodeGenerator.cs +CodeGenerator.cs diff --git a/mcs/class/System/System.CodeDom.Compiler/unix.src b/mcs/class/System/System.CodeDom.Compiler/unix.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/System/System.CodeDom.Compiler/unix.src diff --git a/mcs/class/System/System.CodeDom.Compiler/windows.src b/mcs/class/System/System.CodeDom.Compiler/windows.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/System/System.CodeDom.Compiler/windows.src diff --git a/mcs/class/System/System.CodeDom/ChangeLog b/mcs/class/System/System.CodeDom/ChangeLog new file mode 100644 index 00000000000..102e74825e3 --- /dev/null +++ b/mcs/class/System/System.CodeDom/ChangeLog @@ -0,0 +1,19 @@ +2001-07-15 Sean MacIsaac <macisaac@ximian.com> + + * MemberAttributes.cs: Added so rest of classes would compile. + + * FieldDirection.cs: Added so rest of classes would compile. + + * CodeTypeMember.cs: Added so rest of classes would compile. + + * CodeTypeDeclaration.cs: Added so rest of classes would compile. + + * CodeObject.cs: Added so rest of classes would compile. + + * CodeBinaryOperatorType.cs: Added so rest of classes would compile. + +2001-07-12 Sean MacIsaac <macisaac@ximian.com> + + * All files implementing IList: Added IsFixedSize property. + + * All files: Changed CodeDOM to CodeDom. diff --git a/mcs/class/System/System.CodeDom/Code-X-Collection.cs b/mcs/class/System/System.CodeDom/Code-X-Collection.cs new file mode 100755 index 00000000000..8e4731656b4 --- /dev/null +++ b/mcs/class/System/System.CodeDom/Code-X-Collection.cs @@ -0,0 +1,159 @@ +// +// System.CodeDOM Code@CONTAINEE@Collection Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDOM { + + using System.Collections; + + public class Code@CONTAINEE@Collection : IList, ICollection, IEnumerable { + + ArrayList @arrayname@; + + // + // Constructors + // + public Code@CONTAINEE@Collection () + { + @arrayname@ = new ArrayList (); + } + + // + // Properties + // + public int Count { + get { + return @arrayname@.Count; + } + } + + // + // Methods + // + public void Add (Code@CONTAINEE@ value) + { + @arrayname@.Add (value); + } + + public void AddRange (Code@CONTAINEE@ [] values) + { + foreach (Code@CONTAINEE@ ca in values) + @arrayname@.Add (ca); + + } + + public void Clear () + { + @arrayname@.Clear (); + } + + private class Enumerator : IEnumerator { + private Code@CONTAINEE@Collection collection; + private int currentIndex = -1; + + internal Enumerator (Code@CONTAINEE@Collection collection) + { + this.collection = collection; + } + + public object Current { + get { + if (currentIndex == collection.Count) + throw new InvalidOperationException (); + return collection [currentIndex]; + } + } + + public bool MoveNext () + { + if (currentIndex > collection.Count) + throw new InvalidOperationException (); + return ++currentIndex < collection.Count; + } + + public void Reset () + { + currentIndex = -1; + } + } + + public IEnumerator GetEnumerator () + { + return new Code@CONTAINEE@Collection.Enumerator (this); + } + + // + // IList method implementations + // + public int Add (object value) + { + return @arrayname@.Add (value); + } + + public bool Contains (Object value) + { + return @arrayname@.Contains (value); + } + + public int IndexOf (Object value) + { + return @arrayname@.IndexOf (value); + } + + public void Insert (int index, Object value) + { + @arrayname@ [index] = value; + } + + public object this[int index] { + get { + return @arrayname@ [index]; + } + + set { + @arrayname@ [index] = value; + } + } + + public void Remove (object value) + { + @arrayname@.Remove (value); + } + + public void RemoveAt (int index) + { + @arrayname@.RemoveAt (index); + } + + // + // ICollection method implementations + // + public void CopyTo (Array array, int index) + { + @arrayname@.CopyTo (array, index); + } + + public object SyncRoot { + get { + return @arrayname@.SyncRoot; + } + } + + public bool IsReadOnly { + get { + return false; + } + } + + public bool IsSynchronized { + get { + return @arrayname@.IsSynchronized; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeArrayCreateExpression.cs b/mcs/class/System/System.CodeDom/CodeArrayCreateExpression.cs new file mode 100755 index 00000000000..17a4a455db3 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeArrayCreateExpression.cs @@ -0,0 +1,89 @@ +// +// System.CodeDom CodeArrayCreateExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// +namespace System.CodeDom { + + public class CodeArrayCreateExpression : CodeExpression { + string createType; + CodeExpressionCollection initializers; + CodeExpression sizeExpression; + int size; + + // + // Constructors + // + public CodeArrayCreateExpression () + { + + } + + public CodeArrayCreateExpression (string createType, CodeExpression size) + { + this.createType = createType; + this.sizeExpression = size; + } + + public CodeArrayCreateExpression (string createType, int size) + { + this.createType = createType; + this.size = size; + } + + public CodeArrayCreateExpression (string createType, CodeExpression [] initializers) + { + this.createType = createType; + this.initializers = new CodeExpressionCollection (); + + this.initializers.AddRange (initializers); + } + + // + // Properties + // + public CodeExpression SizeExpression { + get { + return sizeExpression; + } + + set { + sizeExpression = value; + } + } + + public int Size { + get { + return size; + } + + set { + size = value; + } + } + + public CodeExpressionCollection Initializers { + get { + return initializers; + } + + set { + initializers = value; + } + } + + public string CreateType { + get { + return createType; + } + + set { + createType = value; + } + } + } +} + diff --git a/mcs/class/System/System.CodeDom/CodeAssignStatement.cs b/mcs/class/System/System.CodeDom/CodeAssignStatement.cs new file mode 100755 index 00000000000..0e1bb9750ad --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeAssignStatement.cs @@ -0,0 +1,52 @@ +// +// System.CodeDom CodeArrayCreateExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeAssignStatement : CodeStatement { + + CodeExpression left, right; + + // + // Constructors + // + public CodeAssignStatement () + { + } + + public CodeAssignStatement (CodeExpression left, CodeExpression right) + { + this.left = left; + this.right = right; + } + + // + // Properties + // + public CodeExpression Left { + get { + return left; + } + + set { + left = value; + } + } + + public CodeExpression Right { + get { + return right; + } + + set { + right = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeAttachEventStatement.cs b/mcs/class/System/System.CodeDom/CodeAttachEventStatement.cs new file mode 100755 index 00000000000..d85a61d8ea9 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeAttachEventStatement.cs @@ -0,0 +1,62 @@ +// +// System.CodeDom CodeAttachEventStatement Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// +namespace System.CodeDom { + + public class CodeAttachEventStatement : CodeStatement { + CodeExpression targetObject; + string eventName; + CodeExpression newListener; + + public CodeAttachEventStatement () + { + } + + public CodeAttachEventStatement (CodeExpression targetObject, + string eventName, + CodeExpression newListener) + { + this.targetObject = targetObject; + this.eventName = eventName; + this.newListener = newListener; + } + + // + // Properties + // + public string EventName { + get { + return eventName; + } + + set { + eventName = value; + } + } + + public CodeExpression NewListener { + get { + return newListener; + } + + set { + newListener = value; + } + } + + public CodeExpression TargetObject { + get { + return targetObject; + } + + set { + targetObject = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeAttributeArgument.cs b/mcs/class/System/System.CodeDom/CodeAttributeArgument.cs new file mode 100755 index 00000000000..50fa7efcd6e --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeAttributeArgument.cs @@ -0,0 +1,60 @@ +// +// System.CodeDom CodeAttributeArgument Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeAttributeArgument { + string name; + CodeExpression val; + + // + // Constructors + // + public CodeAttributeArgument () + { + } + + public CodeAttributeArgument (CodeExpression value) + { + } + + public CodeAttributeArgument (string name, CodeExpression val) + { + this.name = name; + this.val = val; + } + + // + // Properties + // + + public string Name { + get { + return name; + } + + set { + name = value; + } + } + + public CodeExpression Value { + get { + return val; + } + + set { + val = value; + } + } + + + } + +} diff --git a/mcs/class/System/System.CodeDom/CodeAttributeArgumentCollection.cs b/mcs/class/System/System.CodeDom/CodeAttributeArgumentCollection.cs new file mode 100755 index 00000000000..d318732320a --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeAttributeArgumentCollection.cs @@ -0,0 +1,166 @@ +// +// System.CodeDom CodeAttributeArgumentCollection Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + using System.Collections; + + public class CodeAttributeArgumentCollection : IList, ICollection, IEnumerable { + + ArrayList attributeArgs; + + // + // Constructors + // + public CodeAttributeArgumentCollection () + { + attributeArgs = new ArrayList (); + } + + // + // Properties + // + public int Count { + get { + return attributeArgs.Count; + } + } + + public bool IsFixedSize { + get { + return true; + } + } + + // + // Methods + // + + public void Add (CodeAttributeArgument value) + { + attributeArgs.Add (value); + } + + public void AddRange (CodeAttributeArgument [] values) + { + foreach (CodeAttributeArgument ca in values) + attributeArgs.Add (ca); + + } + + public void Clear () + { + attributeArgs.Clear (); + } + + private class Enumerator : IEnumerator { + private CodeAttributeArgumentCollection collection; + private int currentIndex = -1; + + internal Enumerator (CodeAttributeArgumentCollection collection) + { + this.collection = collection; + } + + public object Current { + get { + if (currentIndex == collection.Count) + throw new InvalidOperationException (); + return collection [currentIndex]; + } + } + + public bool MoveNext () + { + if (currentIndex > collection.Count) + throw new InvalidOperationException (); + return ++currentIndex < collection.Count; + } + + public void Reset () + { + currentIndex = -1; + } + } + + public IEnumerator GetEnumerator () + { + return new CodeAttributeArgumentCollection.Enumerator (this); + } + + // + // IList method implementations + // + public int Add (object value) + { + return attributeArgs.Add (value); + } + + public bool Contains (Object value) + { + return attributeArgs.Contains (value); + } + + public int IndexOf (Object value) + { + return attributeArgs.IndexOf (value); + } + + public void Insert (int index, Object value) + { + attributeArgs [index] = value; + } + + public object this[int index] { + get { + return attributeArgs [index]; + } + + set { + attributeArgs [index] = value; + } + } + + public void Remove (object value) + { + attributeArgs.Remove (value); + } + + public void RemoveAt (int index) + { + attributeArgs.RemoveAt (index); + } + + // + // ICollection method implementations + // + public void CopyTo (Array array, int index) + { + attributeArgs.CopyTo (array, index); + } + + public object SyncRoot { + get { + return attributeArgs.SyncRoot; + } + } + + public bool IsReadOnly { + get { + return false; + } + } + + public bool IsSynchronized { + get { + return attributeArgs.IsSynchronized; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeAttributeBlock.cs b/mcs/class/System/System.CodeDom/CodeAttributeBlock.cs new file mode 100755 index 00000000000..16ed71265ba --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeAttributeBlock.cs @@ -0,0 +1,42 @@ +// +// System.CodeDom CodeAttributeBlock Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeAttributeBlock { + + CodeAttributeDeclarationCollection attributes; + + // + // Constructors + // + public CodeAttributeBlock () + { + } + + public CodeAttributeBlock (CodeAttributeDeclaration [] attributes) + { + this.attributes = new CodeAttributeDeclarationCollection (); + this.attributes.AddRange (attributes); + } + + // + // Prpoperties + // + public CodeAttributeDeclarationCollection Attributes { + get { + return attributes; + } + + set { + attributes = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeAttributeDeclaration.cs b/mcs/class/System/System.CodeDom/CodeAttributeDeclaration.cs new file mode 100755 index 00000000000..8c9105ce236 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeAttributeDeclaration.cs @@ -0,0 +1,60 @@ +// +// System.CodeDom CodeAttributeDeclaration Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeAttributeDeclaration { + + string name; + CodeAttributeArgumentCollection arguments; + + // + // Constructors + // + public CodeAttributeDeclaration () + { + } + + public CodeAttributeDeclaration (string name) + { + this.name = name; + } + + public CodeAttributeDeclaration (string name, CodeAttributeArgument [] arguments) + { + this.name = name; + this.arguments = new CodeAttributeArgumentCollection (); + this.arguments.AddRange (arguments); + } + + // + // Properties + // + public CodeAttributeArgumentCollection Arguments { + get { + return arguments; + } + + set { + arguments = value; + } + } + + public string Name { + get { + return name; + } + + set { + name = value; + } + } + } +} + diff --git a/mcs/class/System/System.CodeDom/CodeAttributeDeclarationCollection.cs b/mcs/class/System/System.CodeDom/CodeAttributeDeclarationCollection.cs new file mode 100755 index 00000000000..48aa3b48965 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeAttributeDeclarationCollection.cs @@ -0,0 +1,165 @@ +// +// System.CodeDom CodeAttributeDeclarationCollection Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + using System.Collections; + + public class CodeAttributeDeclarationCollection : IList, ICollection, IEnumerable { + + ArrayList attributeDecls; + + // + // Constructors + // + public CodeAttributeDeclarationCollection () + { + attributeDecls = new ArrayList (); + } + + // + // Properties + // + public int Count { + get { + return attributeDecls.Count; + } + } + + public bool IsFixedSize { + get { + return true; + } + } + + // + // Methods + // + public void Add (CodeAttributeDeclaration value) + { + attributeDecls.Add (value); + } + + public void AddRange (CodeAttributeDeclaration [] values) + { + foreach (CodeAttributeDeclaration ca in values) + attributeDecls.Add (ca); + + } + + public void Clear () + { + attributeDecls.Clear (); + } + + private class Enumerator : IEnumerator { + private CodeAttributeDeclarationCollection collection; + private int currentIndex = -1; + + internal Enumerator (CodeAttributeDeclarationCollection collection) + { + this.collection = collection; + } + + public object Current { + get { + if (currentIndex == collection.Count) + throw new InvalidOperationException (); + return collection [currentIndex]; + } + } + + public bool MoveNext () + { + if (currentIndex > collection.Count) + throw new InvalidOperationException (); + return ++currentIndex < collection.Count; + } + + public void Reset () + { + currentIndex = -1; + } + } + + public IEnumerator GetEnumerator () + { + return new CodeAttributeDeclarationCollection.Enumerator (this); + } + + // + // IList method implementations + // + public int Add (object value) + { + return attributeDecls.Add (value); + } + + public bool Contains (Object value) + { + return attributeDecls.Contains (value); + } + + public int IndexOf (Object value) + { + return attributeDecls.IndexOf (value); + } + + public void Insert (int index, Object value) + { + attributeDecls [index] = value; + } + + public object this[int index] { + get { + return attributeDecls [index]; + } + + set { + attributeDecls [index] = value; + } + } + + public void Remove (object value) + { + attributeDecls.Remove (value); + } + + public void RemoveAt (int index) + { + attributeDecls.RemoveAt (index); + } + + // + // ICollection method implementations + // + public void CopyTo (Array array, int index) + { + attributeDecls.CopyTo (array, index); + } + + public object SyncRoot { + get { + return attributeDecls.SyncRoot; + } + } + + public bool IsReadOnly { + get { + return false; + } + } + + public bool IsSynchronized { + get { + return attributeDecls.IsSynchronized; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeBaseReferenceExpression.cs b/mcs/class/System/System.CodeDom/CodeBaseReferenceExpression.cs new file mode 100755 index 00000000000..dee01e013af --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeBaseReferenceExpression.cs @@ -0,0 +1,15 @@ +// +// System.CodeDom CodeBaseReferenceExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeBaseReferenceExpression : CodeExpression { + public CodeBaseReferenceExpression () {} + } +} diff --git a/mcs/class/System/System.CodeDom/CodeBinaryOperatorExpression.cs b/mcs/class/System/System.CodeDom/CodeBinaryOperatorExpression.cs new file mode 100755 index 00000000000..775b29bf90f --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeBinaryOperatorExpression.cs @@ -0,0 +1,88 @@ +// +// System.CodeDom CodeBinaryOperatorExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeBinaryOperatorExpression : CodeExpression { + + CodeExpression left, right; + CodeBinaryOperatorType oper; + + public enum CodeBinaryOperatorType { + Add, + Substract, + Multiply, + Divide, + Modulus, + Assign, + IdentityInequality, + IdentityEquality, + ValueEquality, + BitwiseOr, + BitwiseAnd, + BooleanOr, + BooleanAnd, + LessThan, + LessThanOrEqual, + GreatherThan, + GreatherThanOrEqual, + } + + // + // Constructors + // + public CodeBinaryOperatorExpression () + { + } + + + public CodeBinaryOperatorExpression (CodeExpression left, + CodeBinaryOperatorType oper, + CodeExpression right) + { + this.left = left; + this.oper = oper; + this.right = right; + } + + // + // Properties + // + public CodeExpression Left { + get { + return left; + } + + set { + left = value; + } + } + + public CodeExpression Right { + get { + return right; + } + + set { + right = value; + } + } + + public CodeBinaryOperatorType Operator { + get { + return oper; + } + + set { + oper = value; + } + } + } +} + diff --git a/mcs/class/System/System.CodeDom/CodeBinaryOperatorType.cs b/mcs/class/System/System.CodeDom/CodeBinaryOperatorType.cs new file mode 100755 index 00000000000..eb2d31a02d4 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeBinaryOperatorType.cs @@ -0,0 +1,30 @@ +// +// System.CodeDom CodeBinaryOperatorType Enum implementation +// +// Author: +// Sean MacIsaac (macisaac@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + public enum CodeBinaryOperatorType { + Add, + Assign, + BitwiseAnd, + BitwiseOr, + BooleanAnd, + BooleanOr, + Divide, + GreaterThan, + GreaterThanOrEqual, + IdentityEquality, + IdentityInequality, + LessThan, + LessThanOrEqual, + Modulus, + Multiply, + Subtract, + ValueEquality + } +} diff --git a/mcs/class/System/System.CodeDom/CodeCastExpression.cs b/mcs/class/System/System.CodeDom/CodeCastExpression.cs new file mode 100755 index 00000000000..3c3bef51042 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeCastExpression.cs @@ -0,0 +1,52 @@ +// +// System.CodeDom CodeCastExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeCastExpression : CodeExpression { + string targetType; + CodeExpression expression; + + // + // Constructors + // + public CodeCastExpression () + { + } + + public CodeCastExpression (string targetType, CodeExpression expression) + { + this.targetType = targetType; + this.expression = expression; + } + + // + // Properties + // + public CodeExpression Expression { + get { + return expression; + } + + set { + expression = value; + } + } + + public string TargetType { + get { + return targetType; + } + + set { + targetType = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeCatchClause.cs b/mcs/class/System/System.CodeDom/CodeCatchClause.cs new file mode 100755 index 00000000000..4af7a18f4a2 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeCatchClause.cs @@ -0,0 +1,46 @@ +// +// System.CodeDom CodeCatchClaus Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeCatchClause { + + CodeParameterDeclarationExpression condition; + CodeStatementCollection statements; + + public CodeCatchClause () + { + this.statements = new CodeStatementCollection (); + } + + public CodeCatchClause (CodeParameterDeclarationExpression condition, + CodeStatement [] statements) + { + this.condition = condition; + this.statements = new CodeStatementCollection (); + this.statements.AddRange (statements); + } + + public CodeStatementCollection Statements { + get { + return statements; + } + } + + public CodeParameterDeclarationExpression Condition { + get { + return condition; + } + + set { + condition = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeCatchClauseCollection.cs b/mcs/class/System/System.CodeDom/CodeCatchClauseCollection.cs new file mode 100755 index 00000000000..7b4a284bac5 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeCatchClauseCollection.cs @@ -0,0 +1,165 @@ +// +// System.CodeDom CodeCatchClauseCollection Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + using System.Collections; + + public class CodeCatchClauseCollection : IList, ICollection, IEnumerable { + + ArrayList catchClauses; + + // + // Constructors + // + public CodeCatchClauseCollection () + { + catchClauses = new ArrayList (); + } + + // + // Properties + // + public int Count { + get { + return catchClauses.Count; + } + } + + public bool IsFixedSize { + get { + return true; + } + } + + // + // Methods + // + public void Add (CodeCatchClause value) + { + catchClauses.Add (value); + } + + public void AddRange (CodeCatchClause [] values) + { + foreach (CodeCatchClause ca in values) + catchClauses.Add (ca); + + } + + public void Clear () + { + catchClauses.Clear (); + } + + private class Enumerator : IEnumerator { + private CodeCatchClauseCollection collection; + private int currentIndex = -1; + + internal Enumerator (CodeCatchClauseCollection collection) + { + this.collection = collection; + } + + public object Current { + get { + if (currentIndex == collection.Count) + throw new InvalidOperationException (); + return collection [currentIndex]; + } + } + + public bool MoveNext () + { + if (currentIndex > collection.Count) + throw new InvalidOperationException (); + return ++currentIndex < collection.Count; + } + + public void Reset () + { + currentIndex = -1; + } + } + + public IEnumerator GetEnumerator () + { + return new CodeCatchClauseCollection.Enumerator (this); + } + + // + // IList method implementations + // + public int Add (object value) + { + return catchClauses.Add (value); + } + + public bool Contains (Object value) + { + return catchClauses.Contains (value); + } + + public int IndexOf (Object value) + { + return catchClauses.IndexOf (value); + } + + public void Insert (int index, Object value) + { + catchClauses [index] = value; + } + + public object this[int index] { + get { + return catchClauses [index]; + } + + set { + catchClauses [index] = value; + } + } + + public void Remove (object value) + { + catchClauses.Remove (value); + } + + public void RemoveAt (int index) + { + catchClauses.RemoveAt (index); + } + + // + // ICollection method implementations + // + public void CopyTo (Array array, int index) + { + catchClauses.CopyTo (array, index); + } + + public object SyncRoot { + get { + return catchClauses.SyncRoot; + } + } + + public bool IsReadOnly { + get { + return false; + } + } + + public bool IsSynchronized { + get { + return catchClauses.IsSynchronized; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeClass.cs b/mcs/class/System/System.CodeDom/CodeClass.cs new file mode 100755 index 00000000000..146cfb474ea --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeClass.cs @@ -0,0 +1,107 @@ +// +// System.CodeDom CodeClass Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +using System.Collections.Specialized; + +namespace System.CodeDom { + using System.Reflection; + using System.Collections; + + public class CodeClass : CodeClassMember { + CodeClassMemberCollection members; + TypeAttributes attrs; + StringCollection baseTypes; + bool isClass, isEnum, isInterface, isStruct; + + string name; + + // + // Constructors + // + public CodeClass () + { + } + + public CodeClass (string name) + { + this.name = name; + } + + // + // Properties + // + public TypeAttributes attributes { + get { + return attrs; + } + + set { + attrs = value; + } + } + + public StringCollection BaseTypes { + get { + return baseTypes; + } + + set { + baseTypes = value; + } + } + + public bool IsClass { + get { + return isClass; + } + + set { + isClass = value; + } + } + public bool IsEnum { + get { + return isEnum; + } + + set { + isEnum = value; + } + } + + public bool IsInterface { + get { + return isInterface; + } + + set { + isInterface = value; + } + } + public bool IsStruct { + get { + return isStruct; + } + + set { + isStruct = value; + } + } + + public CodeClassMemberCollection Members { + get { + return members; + } + + set { + members = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeClassCollection.cs b/mcs/class/System/System.CodeDom/CodeClassCollection.cs new file mode 100755 index 00000000000..d38055a32b8 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeClassCollection.cs @@ -0,0 +1,165 @@ +// +// System.CodeDom CodeClassCollection Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + using System.Collections; + + public class CodeClassCollection : IList, ICollection, IEnumerable { + + ArrayList classes; + + // + // Constructors + // + public CodeClassCollection () + { + classes = new ArrayList (); + } + + // + // Properties + // + public int Count { + get { + return classes.Count; + } + } + + public bool IsFixedSize { + get { + return true; + } + } + + // + // Methods + // + public void Add (CodeClass value) + { + classes.Add (value); + } + + public void AddRange (CodeClass [] values) + { + foreach (CodeClass ca in values) + classes.Add (ca); + + } + + public void Clear () + { + classes.Clear (); + } + + private class Enumerator : IEnumerator { + private CodeClassCollection collection; + private int currentIndex = -1; + + internal Enumerator (CodeClassCollection collection) + { + this.collection = collection; + } + + public object Current { + get { + if (currentIndex == collection.Count) + throw new InvalidOperationException (); + return collection [currentIndex]; + } + } + + public bool MoveNext () + { + if (currentIndex > collection.Count) + throw new InvalidOperationException (); + return ++currentIndex < collection.Count; + } + + public void Reset () + { + currentIndex = -1; + } + } + + public IEnumerator GetEnumerator () + { + return new CodeClassCollection.Enumerator (this); + } + + // + // IList method implementations + // + public int Add (object value) + { + return classes.Add (value); + } + + public bool Contains (Object value) + { + return classes.Contains (value); + } + + public int IndexOf (Object value) + { + return classes.IndexOf (value); + } + + public void Insert (int index, Object value) + { + classes [index] = value; + } + + public object this[int index] { + get { + return classes [index]; + } + + set { + classes [index] = value; + } + } + + public void Remove (object value) + { + classes.Remove (value); + } + + public void RemoveAt (int index) + { + classes.RemoveAt (index); + } + + // + // ICollection method implementations + // + public void CopyTo (Array array, int index) + { + classes.CopyTo (array, index); + } + + public object SyncRoot { + get { + return classes.SyncRoot; + } + } + + public bool IsReadOnly { + get { + return false; + } + } + + public bool IsSynchronized { + get { + return classes.IsSynchronized; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeClassConstructor.cs b/mcs/class/System/System.CodeDom/CodeClassConstructor.cs new file mode 100755 index 00000000000..a778cf5d82d --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeClassConstructor.cs @@ -0,0 +1,17 @@ +// +// System.CodeDom CodeClassConstructor Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + public class CodeClassConstructor : CodeMemberMethod { + + public CodeClassConstructor () + { + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeClassDelegate.cs b/mcs/class/System/System.CodeDom/CodeClassDelegate.cs new file mode 100755 index 00000000000..cf4be20b3fe --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeClassDelegate.cs @@ -0,0 +1,52 @@ +// +// System.CodeDom CodeClassDelegate Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeClassDelegate : CodeClass { + CodeParameterDeclarationExpressionCollection parameters; + string returnType; + string name; + + // + // Constructors + // + public CodeClassDelegate () + { + } + + public CodeClassDelegate (string name) + { + this.name = name; + } + + // + // Properties + // + public CodeParameterDeclarationExpressionCollection Parameters { + get { + return parameters; + } + + set { + parameters = value; + } + } + + public string ReturnType { + get { + return returnType; + } + + set { + returnType = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeClassMember.cs b/mcs/class/System/System.CodeDom/CodeClassMember.cs new file mode 100755 index 00000000000..51d8b0476a7 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeClassMember.cs @@ -0,0 +1,80 @@ +// +// System.CodeDom CodeClassMember Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeClassMember : CodeStatement { + MemberAttributes attributes; + CodeAttributeBlock customAttributes; + + string name; + + // + // Yeah, this is a strange way of defining this + // + public enum MemberAttributes { + Abstract = 0x0001, + Final = 0x0002, + Override = 0x0004, + Const = 0x0005, + Assembly = 0x1000, + AccessMask = 0xf000, + FamANDAssem = 0x2000, + Family = 0x3000, + FamORAssem = 0x4000, + New = 0x0010, + Private = 0x5000, + Public = 0x6000, + ScopeMask = 0x000f, + Static = 0x0003, + VTableMask = 0x00f0 + } + + // + // Constructors + // + public CodeClassMember () + { + } + + // + // Properties + // + + public MemberAttributes Attributes { + get { + return attributes; + } + + set { + attributes = value; + } + } + + public CodeAttributeBlock CustomAttributes { + get { + return customAttributes; + } + + set { + customAttributes = value; + } + } + + public string Name { + get { + return name; + } + + set { + name = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeClassMemberCollection.cs b/mcs/class/System/System.CodeDom/CodeClassMemberCollection.cs new file mode 100755 index 00000000000..f081ad3a45b --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeClassMemberCollection.cs @@ -0,0 +1,165 @@ +// +// System.CodeDom CodeClassMemberCollection Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + using System.Collections; + + public class CodeClassMemberCollection : IList, ICollection, IEnumerable { + + ArrayList classMembers; + + // + // Constructors + // + public CodeClassMemberCollection () + { + classMembers = new ArrayList (); + } + + // + // Properties + // + public int Count { + get { + return classMembers.Count; + } + } + + public bool IsFixedSize { + get { + return true; + } + } + + // + // Methods + // + public void Add (CodeClassMember value) + { + classMembers.Add (value); + } + + public void AddRange (CodeClassMember [] values) + { + foreach (CodeClassMember ca in values) + classMembers.Add (ca); + + } + + public void Clear () + { + classMembers.Clear (); + } + + private class Enumerator : IEnumerator { + private CodeClassMemberCollection collection; + private int currentIndex = -1; + + internal Enumerator (CodeClassMemberCollection collection) + { + this.collection = collection; + } + + public object Current { + get { + if (currentIndex == collection.Count) + throw new InvalidOperationException (); + return collection [currentIndex]; + } + } + + public bool MoveNext () + { + if (currentIndex > collection.Count) + throw new InvalidOperationException (); + return ++currentIndex < collection.Count; + } + + public void Reset () + { + currentIndex = -1; + } + } + + public IEnumerator GetEnumerator () + { + return new CodeClassMemberCollection.Enumerator (this); + } + + // + // IList method implementations + // + public int Add (object value) + { + return classMembers.Add (value); + } + + public bool Contains (Object value) + { + return classMembers.Contains (value); + } + + public int IndexOf (Object value) + { + return classMembers.IndexOf (value); + } + + public void Insert (int index, Object value) + { + classMembers [index] = value; + } + + public object this[int index] { + get { + return classMembers [index]; + } + + set { + classMembers [index] = value; + } + } + + public void Remove (object value) + { + classMembers.Remove (value); + } + + public void RemoveAt (int index) + { + classMembers.RemoveAt (index); + } + + // + // ICollection method implementations + // + public void CopyTo (Array array, int index) + { + classMembers.CopyTo (array, index); + } + + public object SyncRoot { + get { + return classMembers.SyncRoot; + } + } + + public bool IsReadOnly { + get { + return false; + } + } + + public bool IsSynchronized { + get { + return classMembers.IsSynchronized; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeCommentStatement.cs b/mcs/class/System/System.CodeDom/CodeCommentStatement.cs new file mode 100755 index 00000000000..9dba6528a70 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeCommentStatement.cs @@ -0,0 +1,39 @@ +// +// System.CodeDom CodeCommentStatement Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeCommentStatement : CodeStatement { + string text; + + // + // Constructors + // + public CodeCommentStatement () + { + } + + public CodeCommentStatement (string text) + { + this.text = text; + } + + string Text { + get { + return text; + } + + set { + text = value; + } + } + } +} + + diff --git a/mcs/class/System/System.CodeDom/CodeConstructor.cs b/mcs/class/System/System.CodeDom/CodeConstructor.cs new file mode 100755 index 00000000000..0d6a707ac15 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeConstructor.cs @@ -0,0 +1,43 @@ +// +// System.CodeDom CodeConstructor Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeConstructor : CodeMemberMethod { + CodeExpressionCollection baseConstructorArgs; + CodeExpressionCollection chainedConstructorArgs; + + // + // Constructors + // + public CodeConstructor () + { + } + + public CodeExpressionCollection BaseConstructorArgs { + get { + return baseConstructorArgs; + } + + set { + baseConstructorArgs = value; + } + } + + public CodeExpressionCollection ChainedConstructorArgs { + get { + return chainedConstructorArgs; + } + + set { + chainedConstructorArgs = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeDelegateCreateExpression.cs b/mcs/class/System/System.CodeDom/CodeDelegateCreateExpression.cs new file mode 100755 index 00000000000..1be84cc27ad --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeDelegateCreateExpression.cs @@ -0,0 +1,66 @@ +// +// System.CodeDom CodeDelegateCreateExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeDelegateCreateExpression : CodeExpression { + string delegateType, methodName; + CodeExpression targetObject; + + // + // Constructors + // + public CodeDelegateCreateExpression (string delegateType, + CodeExpression targetObject, + string methodName) + { + this.delegateType = delegateType; + this.targetObject = targetObject; + this.methodName = methodName; + } + + public CodeDelegateCreateExpression () + { + } + + // + // Properties + // + + string DelegateType { + get { + return delegateType; + } + + set { + delegateType = value; + } + } + + string MethodName { + get { + return methodName; + } + + set { + methodName = value; + } + } + + CodeExpression TargetObject { + get { + return targetObject; + } + + set { + targetObject = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeDelegateInvokeExpression.cs b/mcs/class/System/System.CodeDom/CodeDelegateInvokeExpression.cs new file mode 100755 index 00000000000..9b918c4cd0b --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeDelegateInvokeExpression.cs @@ -0,0 +1,59 @@ +// +// System.CodeDom CodeDelegateInvokeExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeDelegateInvokeExpression : CodeExpression { + CodeExpressionCollection parameters; + CodeExpression targetObject; + + // + // Constructors + // + public CodeDelegateInvokeExpression () + { + } + + public CodeDelegateInvokeExpression (CodeExpression targetObject, + CodeExpression [] parameters) + { + this.targetObject = targetObject; + this.parameters = new CodeExpressionCollection (); + this.parameters.AddRange (parameters); + } + + public CodeDelegateInvokeExpression (CodeExpression targetObject) + { + this.targetObject = targetObject; + } + + // + // Properties + // + public CodeExpression TargetObject { + get { + return targetObject; + } + + set { + targetObject = value; + } + } + + public CodeExpressionCollection Parameters { + get { + return parameters; + } + + set { + parameters = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeDelegateInvokeStatement.cs b/mcs/class/System/System.CodeDom/CodeDelegateInvokeStatement.cs new file mode 100755 index 00000000000..299e107a8ed --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeDelegateInvokeStatement.cs @@ -0,0 +1,55 @@ +// +// System.CodeDom CodeDelegateInvokeStatement Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeDelegateInvokeStatement : CodeStatement { + CodeStatementCollection parameters; + CodeStatement targetObject; + CodeDelegateInvokeExpression delegateInvoke; + + // + // Constructors + // + public CodeDelegateInvokeStatement () + { + } + + public CodeDelegateInvokeStatement (CodeStatement targetObject) + { + this.targetObject = targetObject; + } + + public CodeDelegateInvokeStatement (CodeDelegateInvokeExpression delegateInvoke) + { + this.delegateInvoke = delegateInvoke; + } + + public CodeDelegateInvokeStatement (CodeStatement targetObject, + CodeStatement [] parameters) + { + this.targetObject = targetObject; + this.parameters = new CodeStatementCollection (); + this.parameters.AddRange (parameters); + } + + // + // Properties + // + public CodeDelegateInvokeExpression DelegateInvoke { + get { + return delegateInvoke; + } + + set { + delegateInvoke = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeDetachEventStatement.cs b/mcs/class/System/System.CodeDom/CodeDetachEventStatement.cs new file mode 100755 index 00000000000..5998b73cf2d --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeDetachEventStatement.cs @@ -0,0 +1,62 @@ +// +// System.CodeDom CodeDetachEventStatement Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeDetachEventStatement : CodeStatement { + string eventName; + CodeExpression targetObject, newListener; + + // + // Constructors + // + public CodeDetachEventStatement () + { + } + + public CodeDetachEventStatement (CodeExpression targetObject, + string eventName, + CodeExpression newListener) + { + this.targetObject = targetObject; + this.eventName = eventName; + this.newListener = newListener; + } + + public string EventName { + get { + return eventName; + } + + set { + eventName = value; + } + } + + public CodeExpression TargetObject { + get { + return targetObject; + } + + set { + targetObject = value; + } + } + + public CodeExpression NewListener { + get { + return newListener; + } + + set { + newListener = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeExpression.cs b/mcs/class/System/System.CodeDom/CodeExpression.cs new file mode 100755 index 00000000000..f140c9d0d5e --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeExpression.cs @@ -0,0 +1,35 @@ +// +// System.CodeDom CodeExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeExpression { + object userData; + + // + // Constructors + // + public CodeExpression () + { + } + + // + // Properties + // + public object UserData { + get { + return userData; + } + + set { + userData = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeExpressionCollection.cs b/mcs/class/System/System.CodeDom/CodeExpressionCollection.cs new file mode 100755 index 00000000000..10622c3b0e4 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeExpressionCollection.cs @@ -0,0 +1,165 @@ +// +// System.CodeDom CodeExpressionCollection Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + using System.Collections; + + public class CodeExpressionCollection : IList, ICollection, IEnumerable { + + ArrayList expressions; + + // + // Constructors + // + public CodeExpressionCollection () + { + expressions = new ArrayList (); + } + + // + // Properties + // + public int Count { + get { + return expressions.Count; + } + } + + public bool IsFixedSize { + get { + return true; + } + } + + // + // Methods + // + public void Add (CodeExpression value) + { + expressions.Add (value); + } + + public void AddRange (CodeExpression [] values) + { + foreach (CodeExpression ca in values) + expressions.Add (ca); + + } + + public void Clear () + { + expressions.Clear (); + } + + private class Enumerator : IEnumerator { + private CodeExpressionCollection collection; + private int currentIndex = -1; + + internal Enumerator (CodeExpressionCollection collection) + { + this.collection = collection; + } + + public object Current { + get { + if (currentIndex == collection.Count) + throw new InvalidOperationException (); + return collection [currentIndex]; + } + } + + public bool MoveNext () + { + if (currentIndex > collection.Count) + throw new InvalidOperationException (); + return ++currentIndex < collection.Count; + } + + public void Reset () + { + currentIndex = -1; + } + } + + public IEnumerator GetEnumerator () + { + return new CodeExpressionCollection.Enumerator (this); + } + + // + // IList method implementations + // + public int Add (object value) + { + return expressions.Add (value); + } + + public bool Contains (Object value) + { + return expressions.Contains (value); + } + + public int IndexOf (Object value) + { + return expressions.IndexOf (value); + } + + public void Insert (int index, Object value) + { + expressions [index] = value; + } + + public object this[int index] { + get { + return expressions [index]; + } + + set { + expressions [index] = value; + } + } + + public void Remove (object value) + { + expressions.Remove (value); + } + + public void RemoveAt (int index) + { + expressions.RemoveAt (index); + } + + // + // ICollection method implementations + // + public void CopyTo (Array array, int index) + { + expressions.CopyTo (array, index); + } + + public object SyncRoot { + get { + return expressions.SyncRoot; + } + } + + public bool IsReadOnly { + get { + return false; + } + } + + public bool IsSynchronized { + get { + return expressions.IsSynchronized; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeFieldReferenceExpression.cs b/mcs/class/System/System.CodeDom/CodeFieldReferenceExpression.cs new file mode 100755 index 00000000000..66581e84f22 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeFieldReferenceExpression.cs @@ -0,0 +1,71 @@ +// +// System.CodeDom CodeFieldReferenceExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeFieldReferenceExpression : CodeExpression { + CodeExpression targetObject; + string fieldName; + FieldDirection direction; + + public enum FieldDirection { + In, + Out, + Ref + } + + // + // Constructors + // + public CodeFieldReferenceExpression () + { + } + + public CodeFieldReferenceExpression (CodeExpression targetObject, + string fieldName) + { + this.targetObject = targetObject; + this.fieldName = fieldName; + } + + // + // Properties + // + public FieldDirection Direction { + get { + return direction; + } + + set { + direction = value; + } + } + + public string FieldName { + get { + return fieldName; + } + + set { + fieldName = value; + } + } + + public CodeExpression TargetObject { + get { + return targetObject; + } + + set { + targetObject = value; + } + } + + } +} diff --git a/mcs/class/System/System.CodeDom/CodeForLoopStatement.cs b/mcs/class/System/System.CodeDom/CodeForLoopStatement.cs new file mode 100755 index 00000000000..c0b0a46ea53 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeForLoopStatement.cs @@ -0,0 +1,78 @@ +// +// System.CodeDom CodeForLoopStatement Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeForLoopStatement : CodeExpression { + CodeStatement initStatement, incrementStatement; + CodeExpression testExpression; + CodeStatementCollection statements; + + // + // Constructors + // + public CodeForLoopStatement () + { + statements = new CodeStatementCollection (); + } + + public CodeForLoopStatement (CodeStatement initStatement, + CodeExpression testExpression, + CodeStatement incrementStatement, + CodeStatement [] statements) + { + this.initStatement = initStatement; + this.testExpression = testExpression; + this.incrementStatement = incrementStatement; + this.statements = new CodeStatementCollection (); + this.statements.AddRange (statements); + } + + // + // Properties + // + + public CodeStatement InitStatement { + get { + return initStatement; + } + + set { + initStatement = value; + } + } + + public CodeStatement IncrementStatement { + get { + return incrementStatement; + } + + set { + incrementStatement = value; + } + } + + public CodeStatementCollection Statements { + get { + return statements; + } + } + + public CodeExpression TestExpression { + get { + return testExpression; + } + + set { + testExpression = value; + } + } + } +} + diff --git a/mcs/class/System/System.CodeDom/CodeIfStatement.cs b/mcs/class/System/System.CodeDom/CodeIfStatement.cs new file mode 100755 index 00000000000..4ca158416b6 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeIfStatement.cs @@ -0,0 +1,73 @@ +// +// System.CodeDom CodeIfStatement Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeIfStatement : CodeStatement { + + CodeExpression condition; + CodeStatementCollection trueStatements; + CodeStatementCollection falseStatements; + + // + // Constructors + // + public CodeIfStatement () + { + trueStatements = new CodeStatementCollection (); + falseStatements = new CodeStatementCollection (); + } + + public CodeIfStatement (CodeExpression condition, CodeStatement [] trueStatements) + { + this.condition = condition; + this.trueStatements = new CodeStatementCollection (); + this.trueStatements.AddRange (trueStatements); + this.falseStatements = new CodeStatementCollection (); + } + + public CodeIfStatement (CodeExpression condition, + CodeStatement [] trueStatements, + CodeStatement [] falseStatements) + { + this.condition = condition; + + this.trueStatements = new CodeStatementCollection (); + this.trueStatements.AddRange (trueStatements); + + this.falseStatements = new CodeStatementCollection (); + this.falseStatements.AddRange (falseStatements); + } + + // + // Properties + // + public CodeExpression Condition { + get { + return condition; + } + + set { + condition = value; + } + } + + public CodeStatementCollection FalseStatements { + get { + return falseStatements; + } + } + + public CodeStatementCollection TrueStatements { + get { + return trueStatements; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeIndexerExpression.cs b/mcs/class/System/System.CodeDom/CodeIndexerExpression.cs new file mode 100755 index 00000000000..8dbc95b44a2 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeIndexerExpression.cs @@ -0,0 +1,34 @@ +// +// System.CodeDom CodeFieldReferenceExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeIndexerExpression : CodeExpression { + CodeExpression targetObject; + CodeExpression index; + + // + // Constructors + // + public CodeIndexerExpression () + { + } + + public CodeIndexerExpression (CodeExpression targetObject, CodeExpression index) + { + this.index = index; + this.targetObject = targetObject; + } + + // + // Properties + // + } +} + diff --git a/mcs/class/System/System.CodeDom/CodeLinePragma.cs b/mcs/class/System/System.CodeDom/CodeLinePragma.cs new file mode 100755 index 00000000000..d83a9f6c8c5 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeLinePragma.cs @@ -0,0 +1,50 @@ +// +// System.CodeDom CodeLinePragma Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// +using System; + +namespace System.CodeDom { + + // <summary> + // Use objects of this class to keep track of locations where + // statements are defined + // </summary> + public class CodeLinePragma { + string fileName; + int lineNumber; + + public CodeLinePragma (string fileName, int lineNumber) + { + this.fileName = fileName; + this.lineNumber = lineNumber; + } + + // + // Properties + // + public string FileName { + get { + return fileName; + } + + set { + fileName = value; + } + } + + public int LineNumber { + get { + return lineNumber; + } + + set { + lineNumber = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeLiteralClassMember.cs b/mcs/class/System/System.CodeDom/CodeLiteralClassMember.cs new file mode 100755 index 00000000000..0733b786a7f --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeLiteralClassMember.cs @@ -0,0 +1,40 @@ +// +// System.CodeDom CodeLiteralClassMember Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeLiteralClassMember : CodeClassMember { + string text; + + // + // Constructors + // + public CodeLiteralClassMember () + { + } + + public CodeLiteralClassMember (string text) + { + this.text = text; + } + + // + // Properties + // + string Text { + get { + return text; + } + + set { + text = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeLiteralExpression.cs b/mcs/class/System/System.CodeDom/CodeLiteralExpression.cs new file mode 100755 index 00000000000..36ca6908b2c --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeLiteralExpression.cs @@ -0,0 +1,40 @@ +// +// System.CodeDom CodeLiteralExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeLiteralExpression : CodeExpression { + string val; + + // + // Constructors + // + public CodeLiteralExpression () + { + } + + public CodeLiteralExpression (string value) + { + val = value; + } + + // + // Properties + // + string Value { + get { + return val; + } + + set { + val = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeLiteralNamespace.cs b/mcs/class/System/System.CodeDom/CodeLiteralNamespace.cs new file mode 100755 index 00000000000..7cbf4c46b9e --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeLiteralNamespace.cs @@ -0,0 +1,48 @@ +// +// System.CodeDom CodeLiteralNamespace Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeLiteralNamespace : CodeNamespace { + CodeLinePragma linePragma; + string value; + + // + // Constructors + // + public CodeLiteralNamespace (string value) + { + this.value = value; + } + + // + // Properties + // + string Value { + get { + return value; + } + + set { + this.value = value; + } + } + + CodeLinePragma LinePragma { + get { + return linePragma; + } + + set { + linePragma = value; + } + } + } +} + diff --git a/mcs/class/System/System.CodeDom/CodeLiteralStatement.cs b/mcs/class/System/System.CodeDom/CodeLiteralStatement.cs new file mode 100755 index 00000000000..63e1fec6bbb --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeLiteralStatement.cs @@ -0,0 +1,36 @@ +// +// System.CodeDom CodeLiteralStatement Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeLiteralStatement : CodeStatement { + string value; + + // + // Constructors + // + public CodeLiteralStatement (string value) + { + this.value = value; + } + + // + // Properties + // + string Value { + get { + return value; + } + + set { + this.value = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeMemberEvent.cs b/mcs/class/System/System.CodeDom/CodeMemberEvent.cs new file mode 100755 index 00000000000..46f1fee42d9 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeMemberEvent.cs @@ -0,0 +1,50 @@ +// +// System.CodeDom CodeMemberEvent Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeMemberEvent : CodeClassMember { + string implementsType, type; + bool privateImplements; + + public CodeMemberEvent () + { + } + + public string ImplementsType { + get { + return implementsType; + } + + set { + implementsType = value; + } + } + + public bool PrivateImplements { + get { + return privateImplements; + } + + set { + privateImplements = value; + } + } + + public string Type { + get { + return type; + } + + set { + type = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeMemberField.cs b/mcs/class/System/System.CodeDom/CodeMemberField.cs new file mode 100755 index 00000000000..ac8b1d3ab79 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeMemberField.cs @@ -0,0 +1,49 @@ +// +// System.CodeDom CodeMemberField Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeMemberField : CodeClassMember { + CodeExpression initExpression; + string type, name; + + public CodeMemberField () + { + } + + public CodeMemberField (string type, string name) + { + this.type = type; + this.name = name; + } + + // + // Properties + // + public CodeExpression InitExpression { + get { + return initExpression; + } + + set { + initExpression = value; + } + } + + public string Type { + get { + return type; + } + + set { + type = name; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeMemberMethod.cs b/mcs/class/System/System.CodeDom/CodeMemberMethod.cs new file mode 100755 index 00000000000..aa417a2aeee --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeMemberMethod.cs @@ -0,0 +1,73 @@ +// +// System.CodeDom CodeMemberMethod Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeMemberMethod : CodeClassMember { + CodeParameterDeclarationExpressionCollection parameters; + CodeStatementCollection statements; + string implementsType; + string returnType; + bool privateImplements; + + public CodeMemberMethod () + { + } + + public string ImplementsType { + get { + return implementsType; + } + + set { + implementsType = value; + } + } + + public bool PrivateImplements { + get { + return privateImplements; + } + + set { + privateImplements = value; + } + } + + public string ReturnType { + get { + return returnType; + } + + set { + returnType = value; + } + } + + public CodeParameterDeclarationExpressionCollection Parameters { + get { + return parameters; + } + + set { + parameters = value; + } + } + + public CodeStatementCollection Statements { + get { + return statements; + } + + set { + statements = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeMemberProperty.cs b/mcs/class/System/System.CodeDom/CodeMemberProperty.cs new file mode 100755 index 00000000000..8889de098a0 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeMemberProperty.cs @@ -0,0 +1,108 @@ +// +// System.CodeDom CodeMemberProperty Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeMemberProperty : CodeClassMember { + CodeParameterDeclarationExpressionCollection parameters; + CodeStatementCollection getStatements, setStatements; + bool hasGet, hasSet; + string implementsType, type; + bool privateImplements; + + public CodeMemberProperty () + { + } + + // + // Properties + // + + public string ImplementsType { + get { + return implementsType; + } + + set { + implementsType = value; + } + } + + public bool PrivateImplements { + get { + return privateImplements; + } + + set { + privateImplements = value; + } + } + + public CodeParameterDeclarationExpressionCollection Parameters { + get { + return parameters; + } + + set { + parameters = value; + } + } + + public CodeStatementCollection SetStatements { + get { + return setStatements; + } + + set { + setStatements = value; + } + } + + public CodeStatementCollection GetStatements { + get { + return getStatements; + } + + set { + getStatements = value; + } + } + + public string Type { + get { + return type; + } + + set { + type = value; + } + } + + public bool HasGet { + get { + return hasGet; + } + + set { + hasGet = value; + } + } + + public bool HasSet { + get { + return hasSet; + } + + set { + hasSet = value; + } + } + } +} + diff --git a/mcs/class/System/System.CodeDom/CodeMethodInvokeExpression.cs b/mcs/class/System/System.CodeDom/CodeMethodInvokeExpression.cs new file mode 100755 index 00000000000..cb51ff9b5d4 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeMethodInvokeExpression.cs @@ -0,0 +1,68 @@ +// +// System.CodeDom CodeMethodInvokeExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeMethodInvokeExpression : CodeExpression { + string methodName; + CodeExpression targetObject; + CodeExpressionCollection parameters; + + // + // Constructors + // + public CodeMethodInvokeExpression () {} + + public CodeMethodInvokeExpression (CodeExpression targetObject, string methodName) + { + this.targetObject = targetObject; + this.methodName = methodName; + } + + public CodeMethodInvokeExpression (CodeExpression targetObject, + string methodName, + CodeExpression [] parameters) + { + this.targetObject = targetObject; + this.methodName = methodName; + this.parameters = new CodeExpressionCollection (); + this.parameters.AddRange (parameters); + } + + public string MethodName { + get { + return methodName; + } + + set { + methodName = value; + } + } + + public CodeExpressionCollection Parameters { + get { + return parameters; + } + + set { + parameters = value; + } + } + + public CodeExpression TargetObject { + get { + return targetObject; + } + + set { + targetObject = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeMethodInvokeStatement.cs b/mcs/class/System/System.CodeDom/CodeMethodInvokeStatement.cs new file mode 100755 index 00000000000..519e4164ad5 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeMethodInvokeStatement.cs @@ -0,0 +1,84 @@ +// +// System.CodeDom CodeMethodInvokeStatement Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeMethodInvokeStatement : CodeStatement { + string methodName; + CodeExpression targetObject; + CodeExpressionCollection parameters; + CodeMethodInvokeExpression methodInvoke; + + // + // Constructors + // + public CodeMethodInvokeStatement () {} + + public CodeMethodInvokeStatement (CodeMethodInvokeExpression methodInvoke) + { + this.methodInvoke = methodInvoke; + } + + public CodeMethodInvokeStatement (CodeExpression targetObject, string methodName) + { + this.targetObject = targetObject; + this.methodName = methodName; + } + + public CodeMethodInvokeStatement (CodeExpression targetObject, + string methodName, + CodeExpression [] parameters) + { + this.targetObject = targetObject; + this.methodName = methodName; + this.parameters = new CodeExpressionCollection (); + this.parameters.AddRange (parameters); + } + + public string MethodName { + get { + return methodName; + } + + set { + methodName = value; + } + } + + public CodeExpressionCollection Parameters { + get { + return parameters; + } + + set { + parameters = value; + } + } + + public CodeExpression TargetObject { + get { + return targetObject; + } + + set { + targetObject = value; + } + } + + public CodeMethodInvokeExpression MethodInvoke { + get { + return methodInvoke; + } + + set { + methodInvoke = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeMethodReturnStatement.cs b/mcs/class/System/System.CodeDom/CodeMethodReturnStatement.cs new file mode 100755 index 00000000000..02d51b42410 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeMethodReturnStatement.cs @@ -0,0 +1,12 @@ +// +// System.CodeDom CodeMethodReturnStatement class implementation +// +// Author: +// Sean MacIsaac (macisaac@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +public class CodeMethodReturnStatement : CodeStatement { + +} diff --git a/mcs/class/System/System.CodeDom/CodeNamespace.cs b/mcs/class/System/System.CodeDom/CodeNamespace.cs new file mode 100755 index 00000000000..0794653cfd8 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeNamespace.cs @@ -0,0 +1,92 @@ +// +// System.CodeDom CodeNamespace Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeNamespace { + CodeClassCollection classes; + CodeNamespaceImportCollection imports; + bool allowLateBound, requireVariableDeclaration; + string name; + object userData; + + public CodeNamespace () + { + } + + public CodeNamespace (string name) + { + this.name = name; + } + + // + // Properties + // + + public bool AllowLateBound { + get { + return allowLateBound; + } + + set { + allowLateBound = value; + } + } + + public CodeClassCollection Classes { + get { + return classes; + } + + set { + classes = value; + } + } + + public CodeNamespaceImportCollection Imports { + get { + return imports; + } + + set { + imports = value; + } + } + + public string Name { + get { + return name; + } + + set { + name = value; + } + } + + public bool RequireVariableDeclaration { + get { + return requireVariableDeclaration; + } + + set { + requireVariableDeclaration = value; + } + } + + public object UserData { + get { + return userData; + } + + set { + userData = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeNamespaceImport.cs b/mcs/class/System/System.CodeDom/CodeNamespaceImport.cs new file mode 100755 index 00000000000..d13767c588e --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeNamespaceImport.cs @@ -0,0 +1,36 @@ +// +// System.CodeDom CodeNamespaceImport Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeNamespaceImport : CodeStatement { + string nameSpace; + + public CodeNamespaceImport () {} + + public CodeNamespaceImport (string nameSpace) + { + this.nameSpace = nameSpace; + } + + // + // Properties + // + + public string Namespace { + get { + return nameSpace; + } + + set { + nameSpace = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeNamespaceImportCollection.cs b/mcs/class/System/System.CodeDom/CodeNamespaceImportCollection.cs new file mode 100755 index 00000000000..d65ee247c4d --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeNamespaceImportCollection.cs @@ -0,0 +1,165 @@ +// +// System.CodeDom CodeNamespaceImportCollection Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + using System.Collections; + + public class CodeNamespaceImportCollection : IList, ICollection, IEnumerable { + + ArrayList namespaceImports; + + // + // Constructors + // + public CodeNamespaceImportCollection () + { + namespaceImports = new ArrayList (); + } + + // + // Properties + // + public int Count { + get { + return namespaceImports.Count; + } + } + + public bool IsFixedSize { + get { + return true; + } + } + + // + // Methods + // + public void Add (CodeNamespaceImport value) + { + namespaceImports.Add (value); + } + + public void AddRange (CodeNamespaceImport [] values) + { + foreach (CodeNamespaceImport ca in values) + namespaceImports.Add (ca); + + } + + public void Clear () + { + namespaceImports.Clear (); + } + + private class Enumerator : IEnumerator { + private CodeNamespaceImportCollection collection; + private int currentIndex = -1; + + internal Enumerator (CodeNamespaceImportCollection collection) + { + this.collection = collection; + } + + public object Current { + get { + if (currentIndex == collection.Count) + throw new InvalidOperationException (); + return collection [currentIndex]; + } + } + + public bool MoveNext () + { + if (currentIndex > collection.Count) + throw new InvalidOperationException (); + return ++currentIndex < collection.Count; + } + + public void Reset () + { + currentIndex = -1; + } + } + + public IEnumerator GetEnumerator () + { + return new CodeNamespaceImportCollection.Enumerator (this); + } + + // + // IList method implementations + // + public int Add (object value) + { + return namespaceImports.Add (value); + } + + public bool Contains (Object value) + { + return namespaceImports.Contains (value); + } + + public int IndexOf (Object value) + { + return namespaceImports.IndexOf (value); + } + + public void Insert (int index, Object value) + { + namespaceImports [index] = value; + } + + public object this[int index] { + get { + return namespaceImports [index]; + } + + set { + namespaceImports [index] = value; + } + } + + public void Remove (object value) + { + namespaceImports.Remove (value); + } + + public void RemoveAt (int index) + { + namespaceImports.RemoveAt (index); + } + + // + // ICollection method implementations + // + public void CopyTo (Array array, int index) + { + namespaceImports.CopyTo (array, index); + } + + public object SyncRoot { + get { + return namespaceImports.SyncRoot; + } + } + + public bool IsReadOnly { + get { + return false; + } + } + + public bool IsSynchronized { + get { + return namespaceImports.IsSynchronized; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeObject.cs b/mcs/class/System/System.CodeDom/CodeObject.cs new file mode 100755 index 00000000000..b2c38638f96 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeObject.cs @@ -0,0 +1,12 @@ +// +// System.CodeDom CodeObject class implementation +// +// Author: +// Sean MacIsaac (macisaac@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +public class CodeObject { + +} diff --git a/mcs/class/System/System.CodeDom/CodeObjectCreateExpression.cs b/mcs/class/System/System.CodeDom/CodeObjectCreateExpression.cs new file mode 100755 index 00000000000..421d2aa29de --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeObjectCreateExpression.cs @@ -0,0 +1,54 @@ +// +// System.CodeDom CodeObjectCreateExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeObjectCreateExpression : CodeExpression { + string createType; + CodeExpressionCollection parameters; + + public CodeObjectCreateExpression () {} + + public CodeObjectCreateExpression (string createType) + { + this.createType = createType; + } + + public CodeObjectCreateExpression (string createType, CodeExpression [] parameters) + { + this.createType = createType; + this.parameters = new CodeExpressionCollection (); + this.parameters.AddRange (parameters); + } + + // + // Properties + // + public string CreateType { + get { + return createType; + } + + set { + createType = value; + } + } + + public CodeExpressionCollection Parameters { + get { + return parameters; + } + + set { + parameters = value; + } + } + + } +} diff --git a/mcs/class/System/System.CodeDom/CodeParameterDeclarationExpression.cs b/mcs/class/System/System.CodeDom/CodeParameterDeclarationExpression.cs new file mode 100755 index 00000000000..93f4b0ee7b0 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeParameterDeclarationExpression.cs @@ -0,0 +1,68 @@ +// +// System.CodeDom CodeParameterDeclarationExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeParameterDeclarationExpression : CodeExpression { + FieldDirection direction; + CodeAttributeBlock customAttributes; + string type, name; + + public CodeParameterDeclarationExpression () + { + } + + public CodeParameterDeclarationExpression (string type, string name) + { + this.type = type; + this.name = name; + } + + public string Type { + get { + return type; + } + + set { + type = value; + } + } + + public string Name { + get { + return name; + } + + set { + name = value; + } + } + + public CodeAttributeBlock CustomAttributes { + get { + return customAttributes; + } + + set { + customAttributes = value; + } + } + + public FieldDirection Direction { + get { + return direction; + } + + set { + direction = value; + } + } + } +} + diff --git a/mcs/class/System/System.CodeDom/CodeParameterDeclarationExpressionCollection.cs b/mcs/class/System/System.CodeDom/CodeParameterDeclarationExpressionCollection.cs new file mode 100755 index 00000000000..970e9ec78e7 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeParameterDeclarationExpressionCollection.cs @@ -0,0 +1,165 @@ +// +// System.CodeDom CodeParameterDeclarationExpressionCollection Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + using System.Collections; + + public class CodeParameterDeclarationExpressionCollection : IList, ICollection, IEnumerable { + + ArrayList parameterDeclExprs; + + // + // Constructors + // + public CodeParameterDeclarationExpressionCollection () + { + parameterDeclExprs = new ArrayList (); + } + + // + // Properties + // + public int Count { + get { + return parameterDeclExprs.Count; + } + } + + public bool IsFixedSize { + get { + return true; + } + } + + // + // Methods + // + public void Add (CodeParameterDeclarationExpression value) + { + parameterDeclExprs.Add (value); + } + + public void AddRange (CodeParameterDeclarationExpression [] values) + { + foreach (CodeParameterDeclarationExpression ca in values) + parameterDeclExprs.Add (ca); + + } + + public void Clear () + { + parameterDeclExprs.Clear (); + } + + private class Enumerator : IEnumerator { + private CodeParameterDeclarationExpressionCollection collection; + private int currentIndex = -1; + + internal Enumerator (CodeParameterDeclarationExpressionCollection collection) + { + this.collection = collection; + } + + public object Current { + get { + if (currentIndex == collection.Count) + throw new InvalidOperationException (); + return collection [currentIndex]; + } + } + + public bool MoveNext () + { + if (currentIndex > collection.Count) + throw new InvalidOperationException (); + return ++currentIndex < collection.Count; + } + + public void Reset () + { + currentIndex = -1; + } + } + + public IEnumerator GetEnumerator () + { + return new CodeParameterDeclarationExpressionCollection.Enumerator (this); + } + + // + // IList method implementations + // + public int Add (object value) + { + return parameterDeclExprs.Add (value); + } + + public bool Contains (Object value) + { + return parameterDeclExprs.Contains (value); + } + + public int IndexOf (Object value) + { + return parameterDeclExprs.IndexOf (value); + } + + public void Insert (int index, Object value) + { + parameterDeclExprs [index] = value; + } + + public object this[int index] { + get { + return parameterDeclExprs [index]; + } + + set { + parameterDeclExprs [index] = value; + } + } + + public void Remove (object value) + { + parameterDeclExprs.Remove (value); + } + + public void RemoveAt (int index) + { + parameterDeclExprs.RemoveAt (index); + } + + // + // ICollection method implementations + // + public void CopyTo (Array array, int index) + { + parameterDeclExprs.CopyTo (array, index); + } + + public object SyncRoot { + get { + return parameterDeclExprs.SyncRoot; + } + } + + public bool IsReadOnly { + get { + return false; + } + } + + public bool IsSynchronized { + get { + return parameterDeclExprs.IsSynchronized; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodePrimitiveExpression.cs b/mcs/class/System/System.CodeDom/CodePrimitiveExpression.cs new file mode 100755 index 00000000000..98d64e3ae0a --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodePrimitiveExpression.cs @@ -0,0 +1,33 @@ +// +// System.CodeDom CodePrimitiveExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodePrimitiveExpression : CodeExpression { + object value; + + public CodePrimitiveExpression () {} + + public CodePrimitiveExpression (Object value) + { + this.value = value; + } + + public object Value { + get { + return value; + } + + set { + this.value = value; + } + } + } +} + diff --git a/mcs/class/System/System.CodeDom/CodePropertyReferenceExpression.cs b/mcs/class/System/System.CodeDom/CodePropertyReferenceExpression.cs new file mode 100755 index 00000000000..13f4471ce0c --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodePropertyReferenceExpression.cs @@ -0,0 +1,59 @@ +// +// System.CodeDom CodePropertyReferenceExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodePropertyReferenceExpression : CodeExpression { + CodeExpressionCollection parameters; + CodeExpression targetObject; + string propertyName; + + public CodePropertyReferenceExpression () {} + + public CodePropertyReferenceExpression (CodeExpression targetObject, + string propertyName) + { + this.targetObject = targetObject; + this.propertyName = propertyName; + } + + // + // Properties + // + public CodeExpressionCollection Parameter { + get { + return parameters; + } + + set { + parameters = value; + } + } + + public string PropertyName { + get { + return propertyName; + } + + set { + propertyName = value; + } + } + + public CodeExpression TargetObject { + get { + return targetObject; + } + + set { + targetObject = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeStatement.cs b/mcs/class/System/System.CodeDom/CodeStatement.cs new file mode 100755 index 00000000000..400a4854b4d --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeStatement.cs @@ -0,0 +1,12 @@ +// +// System.CodeDom CodeStatement class implementation +// +// Author: +// Sean MacIsaac (macisaac@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +public class CodeStatement : CodeObject { + +} diff --git a/mcs/class/System/System.CodeDom/CodeStatementCollection.cs b/mcs/class/System/System.CodeDom/CodeStatementCollection.cs new file mode 100755 index 00000000000..6a70aeafd2a --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeStatementCollection.cs @@ -0,0 +1,165 @@ +// +// System.CodeDom CodeStatementCollection Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + using System.Collections; + + public class CodeStatementCollection : IList, ICollection, IEnumerable { + + ArrayList statements; + + // + // Constructors + // + public CodeStatementCollection () + { + statements = new ArrayList (); + } + + // + // Properties + // + public int Count { + get { + return statements.Count; + } + } + + public bool IsFixedSize { + get { + return true; + } + } + + // + // Methods + // + public void Add (CodeStatement value) + { + statements.Add (value); + } + + public void AddRange (CodeStatement [] values) + { + foreach (CodeStatement ca in values) + statements.Add (ca); + + } + + public void Clear () + { + statements.Clear (); + } + + private class Enumerator : IEnumerator { + private CodeStatementCollection collection; + private int currentIndex = -1; + + internal Enumerator (CodeStatementCollection collection) + { + this.collection = collection; + } + + public object Current { + get { + if (currentIndex == collection.Count) + throw new InvalidOperationException (); + return collection [currentIndex]; + } + } + + public bool MoveNext () + { + if (currentIndex > collection.Count) + throw new InvalidOperationException (); + return ++currentIndex < collection.Count; + } + + public void Reset () + { + currentIndex = -1; + } + } + + public IEnumerator GetEnumerator () + { + return new CodeStatementCollection.Enumerator (this); + } + + // + // IList method implementations + // + public int Add (object value) + { + return statements.Add (value); + } + + public bool Contains (Object value) + { + return statements.Contains (value); + } + + public int IndexOf (Object value) + { + return statements.IndexOf (value); + } + + public void Insert (int index, Object value) + { + statements [index] = value; + } + + public object this[int index] { + get { + return statements [index]; + } + + set { + statements [index] = value; + } + } + + public void Remove (object value) + { + statements.Remove (value); + } + + public void RemoveAt (int index) + { + statements.RemoveAt (index); + } + + // + // ICollection method implementations + // + public void CopyTo (Array array, int index) + { + statements.CopyTo (array, index); + } + + public object SyncRoot { + get { + return statements.SyncRoot; + } + } + + public bool IsReadOnly { + get { + return false; + } + } + + public bool IsSynchronized { + get { + return statements.IsSynchronized; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeThisReferenceExpression.cs b/mcs/class/System/System.CodeDom/CodeThisReferenceExpression.cs new file mode 100755 index 00000000000..4084e04f7b2 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeThisReferenceExpression.cs @@ -0,0 +1,16 @@ +// +// System.CodeDom CodeParameterDeclarationExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeThisReferenceExpression : CodeExpression { + public CodeThisReferenceExpression () { } + } +} + diff --git a/mcs/class/System/System.CodeDom/CodeThrowExceptionStatement.cs b/mcs/class/System/System.CodeDom/CodeThrowExceptionStatement.cs new file mode 100755 index 00000000000..4b3071515be --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeThrowExceptionStatement.cs @@ -0,0 +1,31 @@ +// +// System.CodeDom CodeThrowExceptionStatement Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeThrowExceptionStatement : CodeStatement { + CodeExpression toThrow; + + public CodeThrowExceptionStatement () {} + public CodeThrowExceptionStatement (CodeExpression toThrow) + { + this.toThrow = toThrow; + } + + public CodeExpression ToThrow { + get { + return toThrow; + } + + set { + toThrow = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeTryCatchFinallyStatement.cs b/mcs/class/System/System.CodeDom/CodeTryCatchFinallyStatement.cs new file mode 100755 index 00000000000..2ad078a9d4e --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeTryCatchFinallyStatement.cs @@ -0,0 +1,70 @@ +// +// System.CodeDom CodeTryCatchFinallyStatement Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeTryCatchFinallyStatement : CodeStatement { + CodeStatementCollection tryStatements, finallyStatements; + CodeCatchClauseCollection catchClauses; + + public CodeTryCatchFinallyStatement () {} + + public CodeTryCatchFinallyStatement (CodeStatement [] tryStatements, + CodeCatchClause [] catchClauses) + { + this.tryStatements = new CodeStatementCollection (); + this.catchClauses = new CodeCatchClauseCollection (); + + this.tryStatements.AddRange (tryStatements); + this.catchClauses.AddRange (catchClauses); + } + + public CodeTryCatchFinallyStatement (CodeStatement [] tryStatements, + CodeCatchClause [] catchClauses, + CodeStatement [] finallyStatements) + { + this.tryStatements = new CodeStatementCollection (); + this.catchClauses = new CodeCatchClauseCollection (); + this.finallyStatements = new CodeStatementCollection (); + + this.tryStatements.AddRange (tryStatements); + this.catchClauses.AddRange (catchClauses); + this.finallyStatements.AddRange (finallyStatements); + } + + public CodeStatementCollection FinallyStatements{ + get { + return finallyStatements; + } + + set { + finallyStatements = value; + } + } + + public CodeStatementCollection TryStatements { + get { + return tryStatements; + } + + set { + tryStatements = value; + } + } + public CodeCatchClauseCollection CatchClauses { + get { + return catchClauses; + } + + set { + catchClauses = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeTypeDeclaration.cs b/mcs/class/System/System.CodeDom/CodeTypeDeclaration.cs new file mode 100755 index 00000000000..acbe14bda67 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeTypeDeclaration.cs @@ -0,0 +1,11 @@ +// +// System.CodeDom CodeTypeDeclaration Class implementation +// +// Author: +// Sean MacIsaac (macisaac@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +public class CodeTypeDeclaration : CodeTypeMember { +} diff --git a/mcs/class/System/System.CodeDom/CodeTypeMember.cs b/mcs/class/System/System.CodeDom/CodeTypeMember.cs new file mode 100755 index 00000000000..5bcbb09b5de --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeTypeMember.cs @@ -0,0 +1,21 @@ +// +// System.CodeDom CodeTypeMember Class implementation +// +// Author: +// Sean MacIsaac (macisaac@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +public class CodeTypeMember : CodeObject { + private string name; + + public string Name { + get { + return name; + } + set { + name = value; + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeTypeOfExpression.cs b/mcs/class/System/System.CodeDom/CodeTypeOfExpression.cs new file mode 100755 index 00000000000..3a496f95923 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeTypeOfExpression.cs @@ -0,0 +1,32 @@ +// +// System.CodeDom CodeTypeOfExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeTypeOfExpression : CodeExpression { + string type; + + public CodeTypeOfExpression () {} + + public CodeTypeOfExpression (string type) + { + this.type = type; + } + + public string Type { + get { + return type; + } + + set { + type = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeTypeReferenceExpression.cs b/mcs/class/System/System.CodeDom/CodeTypeReferenceExpression.cs new file mode 100755 index 00000000000..8fcbc04ef77 --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeTypeReferenceExpression.cs @@ -0,0 +1,32 @@ +// +// System.CodeDom CodeTypeReferenceExpression Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeTypeReferenceExpression : CodeExpression { + string type; + + public CodeTypeReferenceExpression () {} + + public CodeTypeReferenceExpression (string type) + { + this.type = type; + } + + public string Type { + get { + return type; + } + + set { + type = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/CodeVariableDeclarationStatement.cs b/mcs/class/System/System.CodeDom/CodeVariableDeclarationStatement.cs new file mode 100755 index 00000000000..faff810835f --- /dev/null +++ b/mcs/class/System/System.CodeDom/CodeVariableDeclarationStatement.cs @@ -0,0 +1,62 @@ +// +// System.CodeDom CodeVariableDeclarationStatement Class implementation +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + + public class CodeVariableDeclarationStatement : CodeStatement { + CodeExpression initExpression; + string type, name; + + public CodeVariableDeclarationStatement () {} + + public CodeVariableDeclarationStatement (string type, string name) + { + this.type = type; + this.name = name; + } + + public CodeVariableDeclarationStatement (string type, string name, + CodeExpression initExpression) + { + this.type = type; + this.name = name; + this.initExpression = initExpression; + } + + public CodeExpression InitExpression { + get { + return initExpression; + } + + set { + initExpression = value; + } + } + + public string Name { + get { + return name; + } + + set { + name = value; + } + } + + public string Type { + get { + return type; + } + + set { + type = value; + } + } + } +} diff --git a/mcs/class/System/System.CodeDom/FieldDirection.cs b/mcs/class/System/System.CodeDom/FieldDirection.cs new file mode 100755 index 00000000000..669bf377c4a --- /dev/null +++ b/mcs/class/System/System.CodeDom/FieldDirection.cs @@ -0,0 +1,14 @@ +// +// System.CodeDom FieldDirection Enum implementation +// +// Author: +// Sean MacIsaac (macisaac@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + public enum FieldDirection { + In, Out, Ref + } +} diff --git a/mcs/class/System/System.CodeDom/MemberAttributes.cs b/mcs/class/System/System.CodeDom/MemberAttributes.cs new file mode 100755 index 00000000000..d851f92f5d6 --- /dev/null +++ b/mcs/class/System/System.CodeDom/MemberAttributes.cs @@ -0,0 +1,29 @@ +// +// System.CodeDom MemberAttributes Enum implementation +// +// Author: +// Sean MacIsaac (macisaac@ximian.com) +// +// (C) 2001 Ximian, Inc. +// + +namespace System.CodeDom { + public enum MemberAttributes { + Abstract, + AccessMask, + Assembly, + Const, + Family, + FamilyAndAssembly, + FamilyOrAssembly, + Final, + New, + Overloaded, + Override, + Private, + Public, + ScopeMask, + Static, + VTableMask + } +} diff --git a/mcs/class/System/System.CodeDom/common.src b/mcs/class/System/System.CodeDom/common.src new file mode 100755 index 00000000000..2818230866c --- /dev/null +++ b/mcs/class/System/System.CodeDom/common.src @@ -0,0 +1,65 @@ +CodeArrayCreateExpression.cs +CodeAssignStatement.cs +CodeAttachEventStatement.cs +CodeAttributeArgument.cs +CodeAttributeArgumentCollection.cs +CodeAttributeBlock.cs +CodeAttributeDeclaration.cs +CodeAttributeDeclarationCollection.cs +CodeBaseReferenceExpression.cs +CodeBinaryOperatorExpression.cs +CodeBinaryOperatorType.cs +CodeCastExpression.cs +CodeCatchClause.cs +CodeCatchClauseCollection.cs +CodeClass.cs +CodeClassCollection.cs +CodeClassConstructor.cs +CodeClassDelegate.cs +CodeClassMember.cs +CodeClassMemberCollection.cs +CodeCommentStatement.cs +CodeConstructor.cs +CodeDelegateCreateExpression.cs +CodeDelegateInvokeExpression.cs +CodeDelegateInvokeStatement.cs +CodeDetachEventStatement.cs +CodeExpression.cs +CodeExpressionCollection.cs +CodeFieldReferenceExpression.cs +CodeForLoopStatement.cs +CodeIfStatement.cs +CodeIndexerExpression.cs +CodeLinePragma.cs +CodeLiteralClassMember.cs +CodeLiteralExpression.cs +CodeLiteralNamespace.cs +CodeLiteralStatement.cs +CodeMemberEvent.cs +CodeMemberField.cs +CodeMemberMethod.cs +CodeMemberProperty.cs +CodeMethodInvokeExpression.cs +CodeMethodInvokeStatement.cs +CodeMethodReturnStatement.cs +CodeNamespace.cs +CodeNamespaceImport.cs +CodeNamespaceImportCollection.cs +CodeObject.cs +CodeObjectCreateExpression.cs +CodeParameterDeclarationExpression.cs +CodeParameterDeclarationExpressionCollection.cs +CodePrimitiveExpression.cs +CodePropertyReferenceExpression.cs +CodeStatement.cs +CodeStatementCollection.cs +CodeThisReferenceExpression.cs +CodeThrowExceptionStatement.cs +CodeTryCatchFinallyStatement.cs +CodeTypeDeclaration.cs +CodeTypeMember.cs +CodeTypeOfExpression.cs +CodeTypeReferenceExpression.cs +CodeVariableDeclarationStatement.cs +FieldDirection.cs +MemberAttributes.cs diff --git a/mcs/class/System/System.CodeDom/unix.src b/mcs/class/System/System.CodeDom/unix.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/System/System.CodeDom/unix.src diff --git a/mcs/class/System/System.CodeDom/windows.src b/mcs/class/System/System.CodeDom/windows.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/System/System.CodeDom/windows.src diff --git a/mcs/class/System/System.Collections.Specialized/BitVector32.cs b/mcs/class/System/System.Collections.Specialized/BitVector32.cs new file mode 100644 index 00000000000..e04a44d7234 --- /dev/null +++ b/mcs/class/System/System.Collections.Specialized/BitVector32.cs @@ -0,0 +1,67 @@ +// +// System.Collections.Specialized.BitVector32.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +namespace System.Collections.Specialized { + + public struct BitVector32 { + int value; + + public struct Section { + public short maxval; + } + + public static Section CreateSection (short maxval) + { + Section s = new Section(); + + // FIXME: Imeplemtn me + + return s; + } + + public static int CreateMask () + { + return 1; + } + + public static int CreateMask (int prev) + { + return prev << 1; + } + + public BitVector32 (BitVector32 source) + { + value = source.value; + } + + public BitVector32 (int init) + { + value = init; + } + + public override bool Equals (object o) + { + if (!(o is BitVector32)) + return false; + + return value == ((BitVector32) o).value; + } + + public override int GetHashCode () + { + return 0; + } + + public int Data { + get { + return value; + } + } + } +} diff --git a/mcs/class/System/System.Collections.Specialized/ChangeLog b/mcs/class/System/System.Collections.Specialized/ChangeLog new file mode 100755 index 00000000000..887297683b5 --- /dev/null +++ b/mcs/class/System/System.Collections.Specialized/ChangeLog @@ -0,0 +1,4 @@ +2001-07-15 Sean MacIsaac <macisaac@ximian.com> + + * StringCollection.cs: Added so that CodeDom.* would compile. + diff --git a/mcs/class/System/System.Collections.Specialized/StringCollection.cs b/mcs/class/System/System.Collections.Specialized/StringCollection.cs new file mode 100755 index 00000000000..8a3b7c1da80 --- /dev/null +++ b/mcs/class/System/System.Collections.Specialized/StringCollection.cs @@ -0,0 +1,14 @@ +// +// System.Collections.Specialized.StringCollection.cs +// +// Author: +// Sean MacIsaac (macisaac@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +namespace System.Collections.Specialized { + + public class StringCollection { + } +} diff --git a/mcs/class/System/System.Collections.Specialized/common.src b/mcs/class/System/System.Collections.Specialized/common.src new file mode 100755 index 00000000000..e23906fc439 --- /dev/null +++ b/mcs/class/System/System.Collections.Specialized/common.src @@ -0,0 +1,2 @@ +BitVector32.cs +StringCollection.cs diff --git a/mcs/class/System/System.Collections.Specialized/unix.src b/mcs/class/System/System.Collections.Specialized/unix.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/System/System.Collections.Specialized/unix.src diff --git a/mcs/class/System/System.Collections.Specialized/windows.src b/mcs/class/System/System.Collections.Specialized/windows.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/System/System.Collections.Specialized/windows.src diff --git a/mcs/class/System/System.Net/AuthenticationManager.cs b/mcs/class/System/System.Net/AuthenticationManager.cs index d1c3e48b291..fd723a11005 100755 --- a/mcs/class/System/System.Net/AuthenticationManager.cs +++ b/mcs/class/System/System.Net/AuthenticationManager.cs @@ -7,6 +7,8 @@ // (C) Ximian, Inc. http://www.ximian.com // +using System.Collections; + namespace System.Net { public class AuthenticationManager { @@ -15,41 +17,34 @@ namespace System.Net { public static IEnumerator RegisteredModules { get { - if (!modules) + if (modules == null) modules = new ArrayList (); - return modules; + return modules as IEnumerator; } } public static Authorization PreAuthenticate (WebRequest request, - ICredentialLookup credentials) + ICredentials credentials) { // FIXME: implement + return null; } public static void Register (IAuthenticationModule authenticationModule) { - if (!modules) + if (modules == null) modules = new ArrayList (); modules.Add (authenticationModule); } - public static Authorization Respond (WebHeaders ResponseHeaders, - WebRequest Request, - ICredentialLookup credentials) - { - // FIXME: implement - return null; - } - public static void Unregister (IAuthenticationModule authenticationModule) { // FIXME: implement } - pubilc static void Unregister (string authenticationScheme) + public static void Unregister (string authenticationScheme) { // FIXME: implement } diff --git a/mcs/class/System/System.Net/Authorization.cs b/mcs/class/System/System.Net/Authorization.cs index e3866b0119e..60e8c889f22 100755 --- a/mcs/class/System/System.Net/Authorization.cs +++ b/mcs/class/System/System.Net/Authorization.cs @@ -27,7 +27,7 @@ namespace System.Net { public bool Complete { get { - return finished; + return complete; } } diff --git a/mcs/class/System/System.Net/ChangeLog b/mcs/class/System/System.Net/ChangeLog new file mode 100644 index 00000000000..241bc2a2fbb --- /dev/null +++ b/mcs/class/System/System.Net/ChangeLog @@ -0,0 +1,13 @@ +2001-07-12 Sean MacIsaac <macisaac@ximian.com> + + * Authorization.cs: Fixed compiler error. + + * IAuthenticationModule.cs: Changes for Beta2. + + * IPAddress.cs: Internal storage changed to be uint not int. + + * IPEndPoint.cs: Fixed compiler error. + + * EndPoint.cs: Fixed compiler error. + + * AuthenticationManager.cs: Fixed typo. diff --git a/mcs/class/System/System.Net/EndPoint.cs b/mcs/class/System/System.Net/EndPoint.cs index d35cad86757..9078f4d1bdc 100755 --- a/mcs/class/System/System.Net/EndPoint.cs +++ b/mcs/class/System/System.Net/EndPoint.cs @@ -12,18 +12,21 @@ namespace System.Net { public class EndPoint { public virtual EndPoint Create (SocketAddress address) { + return null; } public virtual SocketAddress Serialize () { + return null; } protected EndPoint () { } - public int AddressFamily { - virtual get { + public virtual int AddressFamily { + get { + return 0; } } diff --git a/mcs/class/System/System.Net/IAuthenticationModule.cs b/mcs/class/System/System.Net/IAuthenticationModule.cs index 089cdd9d930..15119f74da3 100755 --- a/mcs/class/System/System.Net/IAuthenticationModule.cs +++ b/mcs/class/System/System.Net/IAuthenticationModule.cs @@ -23,8 +23,8 @@ namespace System.Net { bool CanRespond (string challenge); - Authorization PreAuthenticate (WebRequest request, ICredentialLookup credentials); + Authorization PreAuthenticate (WebRequest request, ICredentials credentials); - Authorization Respond (string challenge, WebRequest request, ICredentialLookup credentials); + Authorization Respond (string challenge, WebRequest request, ICredentials credentials); } } diff --git a/mcs/class/System/System.Net/IPAdress.cs b/mcs/class/System/System.Net/IPAdress.cs index fc4e2d8e79f..5255744a013 100755 --- a/mcs/class/System/System.Net/IPAdress.cs +++ b/mcs/class/System/System.Net/IPAdress.cs @@ -13,17 +13,17 @@ namespace System.Net { // Encapsulates an IP Address. // </remarks> public class IPAddress { - public int Address; + public uint address; - public const int InaddrAny = 0; - public const int InaddrBroadcast = 0xffffffff; - public const int InaddrLoopback = 0x7f000001; - public const int InaddrNone = 0xffffffff; + public const uint InaddrAny = 0; + public const uint InaddrBroadcast = 0xffffffff; + public const uint InaddrLoopback = 0x7f000001; + public const uint InaddrNone = 0xffffffff; // <summary> // Constructor from a 32-bit constant. // </summary> - public IPAddress (int address) + public IPAddress (uint address) { this.address = address; } @@ -33,13 +33,14 @@ namespace System.Net { // </summary> public IPAddress (string ip) { - string ips = ip.Split ("."); - int i, a = 0; + string[] ips = ip.Split (new char[] {'.'}); + int i; + uint a = 0; - for (i = 0; i < ips.Count; i++) - a = (a << 8) | (ips [i].ToInt16 ()); + for (i = 0; i < ips.Length; i++) + a = (a << 8) | (UInt16.Parse(ips [i])); - Address = a; + address = a; } // <summary> @@ -49,7 +50,7 @@ namespace System.Net { // <returns></returns> public static bool IsLoopback (IPAddress addr) { - return addr.Address == InaddrLoopback; + return addr.address == InaddrLoopback; } // <summary> @@ -58,13 +59,13 @@ namespace System.Net { // </summary> public override string ToString () { - System.Net.IPAddress.ToString (Address); + return ToString (address); } // <summary> // Returns this object rendered in a quad-dotted notation // </summary> - public static string ToString (int addr) + public static string ToString (uint addr) { return (addr >> 24).ToString () + "." + ((addr >> 16) & 0xff).ToString () + "." + @@ -75,13 +76,18 @@ namespace System.Net { // <returns> // Whether both objects are equal. // </returns> - public override bool Equal (object other) + public override bool Equals (object other) { - if (typeof (other) is System.Net.IPAddress){ - return Address == ((System.Net.IPAddress) other).Address; + if (other is System.Net.IPAddress){ + return address == ((System.Net.IPAddress) other).address; } return false; } + + public override int GetHashCode () + { + return (int)address; + } } } diff --git a/mcs/class/System/System.Net/IPEndPoint.cs b/mcs/class/System/System.Net/IPEndPoint.cs index 3d3809faade..e4d2bcf1582 100755 --- a/mcs/class/System/System.Net/IPEndPoint.cs +++ b/mcs/class/System/System.Net/IPEndPoint.cs @@ -15,7 +15,15 @@ namespace System.Net { public const int MaxPort = 65535; public const int MinPort = 0; - public short Port; + private int port; + public int Port { + get { + return port; + } + set { + port = value; + } + } public IPEndPoint (IPAddress address, int port) { @@ -23,15 +31,16 @@ namespace System.Net { Port = port; } - public IPEndPoint (int iaddr, int port) + public IPEndPoint (long iaddr, int port) { - IPAddress address = new IPAddress (iaddr); + IPAddress address = new IPAddress ((uint)iaddr); - IPEndPoint (address, port); + Address = address; + this.port = port; } - public int AddressFamily { - override get { + public override int AddressFamily { + get { return 2; } } diff --git a/mcs/class/System/System.Net/common.src b/mcs/class/System/System.Net/common.src new file mode 100755 index 00000000000..1922ba79405 --- /dev/null +++ b/mcs/class/System/System.Net/common.src @@ -0,0 +1,8 @@ +AuthenticationManager.cs +Authorization.cs +EndPoint.cs +IAuthenticationModule.cs +ICredentialLookup.cs +IPAdress.cs +IPEndPoint.cs +SocketAddress.cs diff --git a/mcs/class/System/System.Net/unix.src b/mcs/class/System/System.Net/unix.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/System/System.Net/unix.src diff --git a/mcs/class/System/System.Net/windows.src b/mcs/class/System/System.Net/windows.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/System/System.Net/windows.src diff --git a/mcs/class/System/makefile b/mcs/class/System/makefile new file mode 100644 index 00000000000..86155e20bad --- /dev/null +++ b/mcs/class/System/makefile @@ -0,0 +1,16 @@ +DIRS=System.CodeDom System.CodeDom.Compiler System.Collections.Specialized + +all: + @echo "You must use 'make windows' or 'make unix'." + @echo "'make unix' is broken for now." + +windows: make-list + $(CSC) /target:library /out:System.dll /nowarn:1595 @list + +unix: + @echo "'make unix' is broken for now." + +make-list: + for i in $(DIRS); do \ + cat $$i/common.src $$i/windows.src | sed "s/^/$$i\\\\/"; \ + done > list diff --git a/mcs/class/corlib/.cvsignore b/mcs/class/corlib/.cvsignore new file mode 100644 index 00000000000..1e0fc1e7eb0 --- /dev/null +++ b/mcs/class/corlib/.cvsignore @@ -0,0 +1,2 @@ +corlib.dll +list diff --git a/mcs/class/corlib/System.Collections/ArrayList.cs b/mcs/class/corlib/System.Collections/ArrayList.cs new file mode 100644 index 00000000000..26243e5c3ef --- /dev/null +++ b/mcs/class/corlib/System.Collections/ArrayList.cs @@ -0,0 +1,462 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- +// +// System.Collections.ArrayList +// +// Author: +// Vladimir Vukicevic (vladimir@pobox.com) +// +// (C) 2001 Vladimir Vukicevic +// + +using System; + +namespace System.Collections { + + public class ArrayList : IList, ICollection, IEnumerable, ICloneable { + // constructors + + public ArrayList () { + dataArray = new object[capacity]; + } + + public ArrayList (ICollection c) { + } + + public ArrayList (int capacity) { + dataArray = new object[capacity]; + this.capacity = capacity; + } + + private ArrayList (object[] dataArray, int count, int capacity, + bool fixedSize, bool readOnly, bool synchronized) + { + this.dataArray = dataArray; + this.count = count; + this.capacity = capacity; + this.fixedSize = fixedSize; + this.readOnly = readOnly; + this.synchronized = synchronized; + } + + public static ArrayList ReadOnly (ArrayList list) { + throw new NotImplementedException ("System.Collections.ArrayList.ReadOnly"); + } + + public static ArrayList ReadOnly (IList list) { + throw new NotImplementedException ("System.Collections.ArrayList.ReadOnly"); + } + + public static ArrayList Synchronized (ArrayList list) { + throw new NotImplementedException ("System.Collections.ArrayList.Synchronized"); + } + + public static ArrayList Synchronized (IList list) { + throw new NotImplementedException ("System.Collections.ArrayList.Synchronized"); + } + + public static ArrayList FixedSize (ArrayList list) { + throw new NotImplementedException ("System.Collections.ArrayList.FixedSize"); + } + + public static ArrayList FixedSize (IList list) { + throw new NotImplementedException ("System.Collections.ArrayList.FixedSize"); + } + + public static ArrayList Repeat (object value, int count) { + ArrayList al = new ArrayList (count); + for (int i = 0; i < count; i++) { + al.dataArray[i] = value; + } + al.count = count; + + return al; + } + + public static ArrayList Adapter (IList list) { + throw new NotImplementedException ("System.Collections.ArrayList.Adapter"); + } + + // properties + + private bool fixedSize = false; + private bool readOnly = false; + private bool synchronized = false; + + private int count = 0; + private int capacity = 16; + + private object[] dataArray; + + private void copyDataArray (object[] outArray) { + for (int i = 0; i < count; i++) { + outArray[i] = dataArray[i]; + } + } + + private void setSize (int newSize) { + if (newSize == capacity) { + return; + } + + // note that this assumes that we've already sanity-checked + // the new size + object[] newDataArray = new object[newSize]; + copyDataArray (newDataArray); + dataArray = newDataArray; + + capacity = newSize; + } + + // note that this DOES NOT update count + private void shiftElements (int startIndex, int numshift) { + if (numshift == 0) { + return; + } + + if (count + numshift > capacity) { + setSize (capacity * 2); + shiftElements (startIndex, numshift); + } else { + if (numshift > 0) { + int numelts = count - startIndex; + for (int i = numelts-1; i >= 0; i--) { + dataArray[startIndex + numshift + i] = dataArray[startIndex + i]; + } + + for (int i = startIndex; i < startIndex + numshift; i++) { + dataArray[i] = null; + } + } else { + int numelts = count - startIndex + numshift; + for (int i = startIndex; i < numelts; i++) { + dataArray[i] = dataArray[i - numshift]; + } + for (int i = count + numshift; i < count; i++) { + dataArray[i] = null; + } + } + } + } + + public virtual int Capacity { + get { + return capacity; + } + + set { + if (readOnly) { + throw new NotSupportedException + ("Collection is read-only."); + } + + if (value < count) { + throw new ArgumentOutOfRangeException + ("ArrayList Capacity being set to less than Count"); + } + + if (fixedSize && value != capacity) { + throw new NotSupportedException + ("Collection is fixed size."); + } + + setSize (value); + } + } + + public virtual int Count { + get { + return count; + } + } + + public virtual bool IsFixedSize { + get { + return fixedSize; + } + } + + public virtual bool IsReadOnly { + get { + return readOnly; + } + } + + public virtual bool IsSynchronized { + get { + return synchronized; + } + } + + public virtual object this[int index] { + get { + if (index < 0) { + throw new ArgumentOutOfRangeException ("index < 0"); + } + + if (index >= count) { + throw new ArgumentOutOfRangeException ("index out of range"); + } + + return dataArray[index]; + } + set { + if (index < 0) { + throw new ArgumentOutOfRangeException ("index < 0"); + } + // FIXME -- should setting an index implicitly extend the array? + // the docs aren't clear -- I'm assuming not, since the exception + // is listed for both get and set + if (index >= count) { + throw new ArgumentOutOfRangeException ("index out of range"); + } + + if (readOnly) { + throw new NotSupportedException ("Collection is read-only."); + } + + dataArray[index] = value; + } + } + + public virtual object SyncRoot { + get { + throw new NotImplementedException ("System.Collections.ArrayList.SyncRoot.get"); + } + } + + + // methods + + public virtual int Add (object value) { + if (readOnly) { + throw new NotSupportedException ("Collection is read-only."); + } + + if (count + 1 >= capacity) { + setSize (capacity * 2); + } + + dataArray[count++] = value; + return count-1; + } + + public virtual void AddRange (ICollection c) { + throw new NotImplementedException ("System.Collections.ArrayList.AddRange"); + } + + public virtual int BinarySearch (object value) { + throw new NotImplementedException ("System.Collections.ArrayList.BinarySearch"); + } + + public virtual int BinarySearch (object value, IComparer comparer) { + throw new NotImplementedException ("System.Collections.ArrayList.BinarySearch"); + } + + public virtual int BinarySearch (int index, int count, + object value, IComparer comparer) { + throw new NotImplementedException ("System.Collections.ArrayList.BinarySearch"); + } + + public virtual void Clear () { + count = 0; + setSize(capacity); + } + + public virtual object Clone () { + return new ArrayList (dataArray, count, capacity, + fixedSize, readOnly, synchronized); + } + + public virtual bool Contains (object item) { + for (int i = 0; i < count; i++) { + if (Object.Equals (dataArray[i], item)) { + return true; + } + } + + return false; + } + + public virtual void CopyTo (Array array) { + } + + public virtual void CopyTo (Array array, int arrayIndex) { + } + + public virtual void CopyTo (int index, Array array, + int arrayIndex, int count) { + } + + public virtual IEnumerator GetEnumerator () { + return null; + } + + public virtual IEnumerator GetEnumerator (int index, int count) { + return null; + } + + public virtual ArrayList GetRange (int index, int count) { + return null; + } + + public virtual int IndexOf (object value) { + return IndexOf (value, 0, count); + } + + public virtual int IndexOf (object value, int startIndex) { + return IndexOf (value, startIndex, count - startIndex); + } + + public virtual int IndexOf (object value, int startIndex, int count) { + if (startIndex < 0 || startIndex + count > this.count || count < 0) { + throw new ArgumentOutOfRangeException ("IndexOf arguments out of range"); + } + for (int i = startIndex; i < (startIndex + count); i++) { + if (Object.Equals (dataArray[i], value)) { + return i; + } + } + + return -1; + } + + public virtual void Insert (int index, object value) { + if (readOnly) { + throw new NotSupportedException + ("Collection is read-only."); + } + + if (fixedSize) { + throw new NotSupportedException + ("Collection is fixed size."); + } + + if (index < 0 || index >= count) { + throw new ArgumentOutOfRangeException ("index < 0 or index >= count"); + } + + shiftElements (index, 1); + dataArray[index] = value; + count++; + } + + public virtual void InsertRange (int index, ICollection c) { + } + + public virtual int LastIndexOf (object value) { + return LastIndexOf (value, 0, count); + } + + public virtual int LastIndexOf (object value, int startIndex) { + return LastIndexOf (value, startIndex, count - startIndex); + } + + public virtual int LastIndexOf (object value, int StartIndex, + int count) + { + for (int i = count - 1; i >= 0; i--) { + if (Object.Equals (dataArray[i], value)) { + return i; + } + } + + return -1; + } + + public virtual void Remove (object obj) { + int objIndex = IndexOf (obj); + + if (objIndex == -1) { + // shouldn't an exception be thrown here?? + // the MS docs don't indicate one, and testing + // with the MS .net framework doesn't indicate one + return; + } + + RemoveRange (objIndex, 1); + } + + public virtual void RemoveAt (int index) { + RemoveRange (index, 1); + } + + public virtual void RemoveRange (int index, int count) { + if (readOnly) { + throw new NotSupportedException + ("Collection is read-only."); + } + + if (fixedSize) { + throw new NotSupportedException + ("Collection is fixed size."); + } + + if (index < 0 || index >= this.count || index + count > this.count) { + throw new ArgumentOutOfRangeException + ("index/count out of range"); + } + + shiftElements (index, - count); + this.count -= count; + } + + public virtual void Reverse () { + Reverse (0, count); + } + + public virtual void Reverse (int index, int count) { + if (readOnly) { + throw new NotSupportedException + ("Collection is read-only."); + } + + if (index < 0 || index + count > this.count) { + throw new ArgumentOutOfRangeException + ("index/count out of range"); + } + + Array.Reverse (dataArray, index, count); + } + + public virtual void SetRange (int index, ICollection c) { + } + + public virtual void Sort () { + Sort (0, count, null); + } + + public virtual void Sort (IComparer comparer) { + Sort (0, count, comparer); + } + + public virtual void Sort (int index, int count, IComparer comparer) { + if (readOnly) { + throw new NotSupportedException + ("Collection is read-only."); + } + + if (index < 0 || index + count > this.count) { + throw new ArgumentOutOfRangeException + ("index/count out of range"); + } + + Array.Sort (dataArray, index, count, comparer); + } + + public virtual object[] ToArray() { + object[] outArray = new object[count]; + Array.Copy (dataArray, outArray, count); + return outArray; + } + + public virtual Array ToArray (Type type) { + Array outArray = Array.CreateInstance (type, count); + Array.Copy (dataArray, outArray, count); + return outArray; + } + + public virtual void TrimToSize () { + // FIXME: implement this + } + } +} diff --git a/mcs/class/corlib/System.Collections/ChangeLog b/mcs/class/corlib/System.Collections/ChangeLog new file mode 100644 index 00000000000..ea1f782ef3f --- /dev/null +++ b/mcs/class/corlib/System.Collections/ChangeLog @@ -0,0 +1,16 @@ +2001-07-15 Sean MacIsaac <macisaac@ximian.com> + + * IDictionary.cs: Clear was clear. + +2001-07-13 Miguel de Icaza <miguel@ximian.com> + + * All files: Renamespace things to System. + +2001-07-05 Vladimir Vukicevic <vladimir@ximian.com> + + * ArrayList.cs: initial checkin and implementation + + * ICollection.cs, IComprarer.cs, IDictionary.cs, + IDictionaryEnumerator.cs, IEnumerable.cs, IHashCodeProvider.cs, + IList.cs: initial checkin + diff --git a/mcs/class/corlib/System.Collections/ICollection.cs b/mcs/class/corlib/System.Collections/ICollection.cs new file mode 100644 index 00000000000..2189931cae8 --- /dev/null +++ b/mcs/class/corlib/System.Collections/ICollection.cs @@ -0,0 +1,24 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- +// +// System.Collections.ICollection +// +// Author: +// Vladimir Vukicevic (vladimir@pobox.com) +// +// (C) 2001 Vladimir Vukicevic +// + +using System; + +namespace System.Collections { + + public interface ICollection : IEnumerable { + int Count { get; } + + bool IsSynchronized { get; } + + object SyncRoot { get; } + + void CopyTo (Array array, int index); + } +} diff --git a/mcs/class/corlib/System.Collections/IComparer.cs b/mcs/class/corlib/System.Collections/IComparer.cs new file mode 100644 index 00000000000..3d1ee2ef609 --- /dev/null +++ b/mcs/class/corlib/System.Collections/IComparer.cs @@ -0,0 +1,19 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- +// +// System.Collections.IComparer +// +// Author: +// Vladimir Vukicevic (vladimir@pobox.com) +// +// (C) 2001 Vladimir Vukicevic +// + +using System; + +namespace System.Collections { + + public interface IComparer { + int Compare (object x, object y); + } + +} diff --git a/mcs/class/corlib/System.Collections/IDictionary.cs b/mcs/class/corlib/System.Collections/IDictionary.cs new file mode 100644 index 00000000000..ad4f433c149 --- /dev/null +++ b/mcs/class/corlib/System.Collections/IDictionary.cs @@ -0,0 +1,40 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- +// +// System.Collections.IDictionary +// +// Author: +// Vladimir Vukicevic (vladimir@pobox.com) +// +// (C) 2001 Vladimir Vukicevic +// + +using System; + +namespace System.Collections { + + public interface IDictionary { + // properties + + bool IsFixedSize { get; } + + bool IsReadOnly { get; } + + object this[object key] { get; set; } + + ICollection Keys { get; } + + ICollection Values { get; } + + // methods + + void Add (object key, object value); + + void Clear (); + + bool Contains (object key); + + IDictionaryEnumerator GetEnumerator (); + + void Remove (object key); + } +} diff --git a/mcs/class/corlib/System.Collections/IDictionaryEnumerator.cs b/mcs/class/corlib/System.Collections/IDictionaryEnumerator.cs new file mode 100644 index 00000000000..fb1998d55f0 --- /dev/null +++ b/mcs/class/corlib/System.Collections/IDictionaryEnumerator.cs @@ -0,0 +1,20 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- +// +// System.Collections.IDictionaryEnumerator +// +// Author: +// Vladimir Vukicevic (vladimir@pobox.com) +// +// (C) 2001 Vladimir Vukicevic +// + +using System; + +namespace System.Collections { + + public interface IDictionaryEnumerator : IEnumerator { + DictionaryEntry Entry { get; } + object Key { get; } + object Value { get; } + } +} diff --git a/mcs/class/corlib/System.Collections/IEnumerable.cs b/mcs/class/corlib/System.Collections/IEnumerable.cs new file mode 100644 index 00000000000..de0a57475dc --- /dev/null +++ b/mcs/class/corlib/System.Collections/IEnumerable.cs @@ -0,0 +1,18 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- +// +// System.Collections.IEnumerable +// +// Author: +// Vladimir Vukicevic (vladimir@pobox.com) +// +// (C) 2001 Vladimir Vukicevic +// + +using System; + +namespace System.Collections { + + public interface IEnumerable { + IEnumerator GetEnumerator(); + } +} diff --git a/mcs/class/corlib/System.Collections/IEnumerator.cs b/mcs/class/corlib/System.Collections/IEnumerator.cs new file mode 100644 index 00000000000..06d250c8b7e --- /dev/null +++ b/mcs/class/corlib/System.Collections/IEnumerator.cs @@ -0,0 +1,22 @@ +// +// System.Collections.IEnumerator +// +// Author: +// Vladimir Vukicevic (vladimir@pobox.com) +// +// (C) 2001 Vladimir Vukicevic +// + +using System; + +namespace System.Collections { + + public interface IEnumerator { + object Current { get; } + + bool MoveNext (); + + void Reset (); + } + +} diff --git a/mcs/class/corlib/System.Collections/IHashCodeProvider.cs b/mcs/class/corlib/System.Collections/IHashCodeProvider.cs new file mode 100644 index 00000000000..1cacfc103bd --- /dev/null +++ b/mcs/class/corlib/System.Collections/IHashCodeProvider.cs @@ -0,0 +1,18 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- +// +// System.Collections.IDictionary +// +// Author: +// Vladimir Vukicevic (vladimir@pobox.com) +// +// (C) 2001 Vladimir Vukicevic +// + +using System; + +namespace System.Collections { + + public interface IHashCodeProvider { + int GetHashCode (object obj); + } +} diff --git a/mcs/class/corlib/System.Collections/IList.cs b/mcs/class/corlib/System.Collections/IList.cs new file mode 100644 index 00000000000..e039a8358c3 --- /dev/null +++ b/mcs/class/corlib/System.Collections/IList.cs @@ -0,0 +1,40 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- +// +// System.Collections.IList +// +// Author: +// Vladimir Vukicevic (vladimir@pobox.com) +// +// (C) 2001 Vladimir Vukicevic +// + +using System; + +namespace System.Collections { + + public interface IList : ICollection, IEnumerable { + // properties + + bool IsFixedSize { get; } + + bool IsReadOnly { get; } + + object this[int index] { get; set; } + + // methods + + int Add (object value); + + void Clear (); + + bool Contains (object value); + + int IndexOf (object value); + + void Insert (int index, object value); + + void Remove (object value); + + void RemoveAt (int index); + } +} diff --git a/mcs/class/corlib/System.Collections/common.src b/mcs/class/corlib/System.Collections/common.src new file mode 100755 index 00000000000..c172ff49540 --- /dev/null +++ b/mcs/class/corlib/System.Collections/common.src @@ -0,0 +1,9 @@ +ArrayList.cs +ICollection.cs +IComparer.cs +IDictionary.cs +IDictionaryEnumerator.cs +IEnumerable.cs +IEnumerator.cs +IHashCodeProvider.cs +IList.cs diff --git a/mcs/class/corlib/System.Collections/unix.src b/mcs/class/corlib/System.Collections/unix.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/corlib/System.Collections/unix.src diff --git a/mcs/class/corlib/System.Collections/windows.src b/mcs/class/corlib/System.Collections/windows.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/corlib/System.Collections/windows.src diff --git a/mcs/class/corlib/System.Globalization/Calendar.cs b/mcs/class/corlib/System.Globalization/Calendar.cs new file mode 100644 index 00000000000..f29d1c3e303 --- /dev/null +++ b/mcs/class/corlib/System.Globalization/Calendar.cs @@ -0,0 +1,58 @@ +// +// System.Globalization.Calendar.cs +// +// Nick made it. (nick@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com/ +// + +namespace System.Globalization +{ + public abstract class Calendar + { + protected Calendar (); + + public const int CurrentEra; + + public abstract int[] Eras {get;} + public virtual int TwoDigitYearMax {get; set;} + + public virtual DateTime AddDays ( DateTime time, int days ); + public virtual DateTime AddHours ( DateTime time, int hours ); + public virtual DateTime AddMilliseconds ( DateTime time, double milliseconds ); + public virtual DateTime AddMinutes ( DateTime time, int minutes ); + public virtual DateTime AddMonths ( DateTime time, int months ); + public virtual DateTime AddSeconds ( DateTime time, int seconds ); + public virtual DateTime AddWeeks ( DateTime time, int weeks ); + public virtual DateTime AddYears ( DateTime time, int years ); + + + public abstract int GetDayOfMonth ( DateTime time ); + public abstract DayOfWeek GetDayOfWeek ( DateTime time ); + public abstract GetDayOfYear ( DateTime time ); + public virtual int GetDaysInMonth ( int year, int month ); + public abstract int GetDaysInMonth ( int year, int month, int era ); + public virtual int GetDaysInYear ( int year ); + public abstract int GetDaysInYear ( int year, int era ); + public abstract int GetEra ( DateTime time ); + public virtual int GetHour ( DateTime time ); + public virtual double GetMilliseconds ( DateTime time ); + public virtual int GetMinute ( DateTime time ); + public abstract int GetMonth ( DateTime time ); + public virtual int GetMonthsInYear ( int year ); + public abstract int GetMonthsInYear ( int year, int era ); + public virtual int GetSecond ( DateTime time ); + public virtual int GetWeekOfYear ( DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek ); + public abstract int GetYear ( DateTime time ); + public virtual bool IsLeapDay ( int year, int month, int day ); + public abstract bool IsLeapDay ( int year, int month, int day, int era ); + public virtual bool IsLeapMonth ( int year, int month ); + public abstract bool IsLeapMonth ( int year, int month, int era ); + public virtual bool IsLeapYear ( int year ); + public abstract bool IsLeapYear ( int year, int era ); + public virtual DateTime ToDateTime ( int year, int month, int day, int hour, int minute, int second, int millisecond ); + public abstract DateTime ToDateTime ( int year, int month, int date, int hour, int minute, int second, int millisecond, int era ); + public virtual int ToFourDigitYear ( int year ); + } +} + diff --git a/mcs/class/corlib/System.Globalization/ChangeLog b/mcs/class/corlib/System.Globalization/ChangeLog new file mode 100644 index 00000000000..7a7b647fcfd --- /dev/null +++ b/mcs/class/corlib/System.Globalization/ChangeLog @@ -0,0 +1,3 @@ +2001-07-06 Joe Shaw <joe@ximian.com> + + * UnicodeCategory.cs: Added. diff --git a/mcs/class/corlib/System.Globalization/UnicodeCategory.cs b/mcs/class/corlib/System.Globalization/UnicodeCategory.cs new file mode 100644 index 00000000000..2cedb95b02d --- /dev/null +++ b/mcs/class/corlib/System.Globalization/UnicodeCategory.cs @@ -0,0 +1,44 @@ +// +// System.Globalization.UnicodeCategory.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System.Globalization { + + public enum UnicodeCategory { + UppercaseLetter = 0, + LowercaseLetter = 1, + TitlecaseLetter = 2, + ModifierLetter = 3, + OtherLetter = 4, + NonSpacingMark = 5, + SpaceCombiningMark = 6, + EnclosingMark = 7, + DecimalDigitNumber = 8, + LetterNumber = 9, + OtherNumber = 10, + SpaceSeperator = 11, + LineSeperator = 12, + ParagraphSeperator = 13, + Control = 14, + Format = 15, + Surrogate = 16, + PrivateUse = 17, + ConnectorPunctuation = 18, + DashPunctuation = 19, + OpenPunctuation = 20, + ClosePunctuation = 21, + InitialQuotePunctuation = 22, + FinalQuotePunctuation = 23, + OtherPunctuation = 24, + MathSymbol = 25, + CurrencySymbol = 26, + ModifierSymbol = 27, + OtherSymbol = 28, + OtherNotAssigned = 29, + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System.Globalization/common.src b/mcs/class/corlib/System.Globalization/common.src new file mode 100755 index 00000000000..07bca57e0d3 --- /dev/null +++ b/mcs/class/corlib/System.Globalization/common.src @@ -0,0 +1 @@ +UnicodeCategory.cs diff --git a/mcs/class/corlib/System.Globalization/unix.src b/mcs/class/corlib/System.Globalization/unix.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/corlib/System.Globalization/unix.src diff --git a/mcs/class/corlib/System.Globalization/windows.src b/mcs/class/corlib/System.Globalization/windows.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/corlib/System.Globalization/windows.src diff --git a/mcs/class/corlib/System.Text/ASCIIEncoding.cs b/mcs/class/corlib/System.Text/ASCIIEncoding.cs new file mode 100755 index 00000000000..2bfe091a40c --- /dev/null +++ b/mcs/class/corlib/System.Text/ASCIIEncoding.cs @@ -0,0 +1,40 @@ +// +// System.Text.ASCIIEncoding.cs +// +// Author: +// Sean MacIsaac (macisaac@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + + +namespace System.Text { + + public class ASCIIEncoding : Encoding { + public override int GetByteCount(char[] chars, int index, int count) { + // FIXME + return 0; + } + + public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { + // FIXME + return 0; + } + + public override char[] GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) { + // FIXME + return null; + } + + public override int GetMaxByteCount(int charCount) { + // FIXME + return 0; + } + + public override int GetMaxCharCount(int byteCount) { + // FIXME + return 0; + } + } +} + diff --git a/mcs/class/corlib/System.Text/ChangeLog b/mcs/class/corlib/System.Text/ChangeLog new file mode 100755 index 00000000000..4f35ff849fa --- /dev/null +++ b/mcs/class/corlib/System.Text/ChangeLog @@ -0,0 +1,25 @@ +2001-07-12 Marcin Szczepanski <marcins@zipworld.com.au> + + * StringBuilder.cs: Implemented. + + The only methods left unimplemented are the AppendFormat( ... ) + ones just because it's probably better to wait until some of the + Format related classes are implemented. I've put that as a TODO + comment at the top and created the methods with a "nop" body. + +2001-06-26 Sean MacIsaac <macisaac@ximian.com> + + * UnicodeEncoding.cs: Members added so that a clean compile is + possible. + + * ASCIIEncoding.cs: Members added so that a clean compile is + possible. + + * UTF7Encoding.cs: Members added so that a clean compile is + possible. + + * UTF8Encoding.cs: Members added so that a clean compile is + possible. + + * Encoding.cs: All public members included. Most members + unimplemented. diff --git a/mcs/class/corlib/System.Text/Encoding.cs b/mcs/class/corlib/System.Text/Encoding.cs new file mode 100755 index 00000000000..178975441f3 --- /dev/null +++ b/mcs/class/corlib/System.Text/Encoding.cs @@ -0,0 +1,263 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- +// +// System.Text.Encoding.cs +// +// Author: +// Sean MacIsaac (macisaac@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + + +namespace System.Text { + + public abstract class Encoding { + + private static ASCIIEncoding asciiEncoding; + private static UnicodeEncoding bigEndianUnicode; + private static UnicodeEncoding unicodeEncoding; + private static UTF7Encoding utf7Encoding; + private static UTF8Encoding utf8Encoding; + + private int codepage; + protected string bodyName; + protected string encodingName; + protected string headerName; + + protected Encoding() { + } + + protected Encoding(int codepage) { + this.codepage = codepage; + } + + public static Encoding ASCII { + get { + if (asciiEncoding == null) + asciiEncoding = new ASCIIEncoding (); + return asciiEncoding; + } + } + + public static Encoding BigEndianUnicode { + get { + if (bigEndianUnicode == null) + bigEndianUnicode = new UnicodeEncoding (true, true); + return bigEndianUnicode; + } + } + + public virtual string BodyName { + get { + return bodyName; + } + } + + public virtual int CodePage { + get { + return codepage; + } + } + + public static Encoding Default { + get { + return ASCII; + } + } + + public virtual string EncodingName { + get { + return encodingName; + } + } + + public virtual string HeaderName { + get { + return headerName; + } + } + + public virtual bool IsBrowserDisplay { + get { + // FIXME + return false; + } + } + + public virtual bool IsBrowserSave { + get { + // FIXME + return false; + } + } + + public virtual bool IsMailNewsDisplay { + get { + // FIXME + return false; + } + } + + public virtual bool IsMailNewsSave { + get { + // FIXME + return false; + } + } + + public static Encoding Unicode { + get { + if (unicodeEncoding == null) { + unicodeEncoding = new UnicodeEncoding(); + } + return unicodeEncoding; + } + } + + public static Encoding UTF7 { + get { + if (utf7Encoding == null) { + utf7Encoding = new UTF7Encoding(); + } + return utf7Encoding; + } + } + + public static Encoding UTF8 { + get { + if (utf8Encoding == null) { + utf8Encoding = new UTF8Encoding(); + } + return utf8Encoding; + } + } + + public virtual string WebName { + get { + // FIXME + return ""; + } + } + + public virtual int WindowsCodePage { + get { + // FIXME + return 0; + } + } + + public static byte[] Convert(Encoding srcEncoding, Encoding dstEncoding, byte[] bytes) { + // FIXME + return null; + } + + public static byte[] Convert(Encoding srcEncoding, Encoding dstEncoding, byte[] bytes, int index, int count) { + // FIXME + return null; + } + + public override bool Equals(object value) { + // FIXME + return false; + } + + public virtual int GetByteCount(char[] chars) { + // FIXME + return 0; + } + + public virtual int GetByteCount(string s) { + // FIXME + return 0; + } + + public abstract int GetByteCount(char[] chars, int index, int count); + + public virtual byte[] GetBytes(char[] chars) { + // FIXME + return null; + } + + public virtual byte[] GetBytes(string s) { + // FIXME + return null; + } + + public virtual byte[] GetBytes(char[] chars, int index, int count) { + // FIXME + return null; + } + + public abstract int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex); + + public virtual byte[] GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex) { + // FIXME + return null; + } + + public virtual int GetCharCount(byte[] bytes) { + // FIXME + return 0; + } + + public virtual int GetCharCount(byte[] bytes, int index, int count) { + // FIXME + return 0; + } + + public virtual char[] GetChars(byte[] bytes) { + // FIXME + return null; + } + + public virtual char[] GetChars(byte[] bytes, int index, int count) { + // FIXME + return null; + } + + public abstract char[] GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex); + + public virtual Decoder GetDecoder() { + // FIXME + return null; + } + + public virtual Encoder GetEncoder() { + // FIXME + return null; + } + + public virtual Encoding GetEncoding(int codepage) { + // FIXME + return null; + } + + public virtual Encoding GetEncoding(string name) { + return null; + } + + public override int GetHashCode() { + // FIXME + return 0; + } + + public abstract int GetMaxByteCount(int charCount); + + public abstract int GetMaxCharCount(int byteCount); + + public virtual byte[] GetPreamble() { + // FIXME + return null; + } + + public virtual string GetString(byte[] bytes) { + // FIXME + return null; + } + + public virtual string GetString(byte[] bytes, int index, int count) { + // FIXME + return null; + } + } +} diff --git a/mcs/class/corlib/System.Text/StringBuilder.cs b/mcs/class/corlib/System.Text/StringBuilder.cs new file mode 100644 index 00000000000..ba6bebcf24b --- /dev/null +++ b/mcs/class/corlib/System.Text/StringBuilder.cs @@ -0,0 +1,564 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Text.StringBuilder
+//
+// Author: Marcin Szczepanski (marcins@zipworld.com.au)
+//
+// TODO: Implement the AppendFormat methods. Wasn't sure how
+// best to do this at this early stage, might want to see
+// how the String class and the IFormatProvide / IFormattable interfaces
+// pan out first.
+//
+// TODO: Make sure the coding complies to the ECMA draft, there's some
+// variable names that probably don't (like sString)
+//
+
+namespace System.Text {
+ public sealed class StringBuilder {
+
+ const int defaultCapacity = 16;
+
+ private int sCapacity;
+ private int sLength;
+ private char[] sString;
+
+ public StringBuilder() {
+
+ // The MS Implementation uses the default
+ // capacity for a StringBuilder. The spec
+ // says it's up to the implementer, but
+ // we'll do it the MS way just in case.
+
+ sString = new char[ defaultCapacity ];
+ sCapacity = defaultCapacity;
+ sLength = 0;
+ }
+
+ public StringBuilder( int capacity ) {
+ if( capacity < defaultCapacity ) {
+ // The spec says that the capacity
+ // has to be at least the default capacity
+ capacity = defaultCapacity;
+ }
+
+ sString = new char[capacity];
+ sCapacity = capacity;
+ sLength = 0;
+ }
+
+ public StringBuilder( string str ) {
+
+ if( str.Length < defaultCapacity ) {
+ char[] tString = str.ToCharArray();
+ sString = new char[ defaultCapacity ];
+ Array.Copy( tString, sString, str.Length );
+ sLength = str.Length;
+ sCapacity = defaultCapacity;
+ } else {
+ sString = str.ToCharArray();
+ sCapacity = sString.Length;
+ sLength = sString.Length;
+ }
+ }
+
+ public int Capacity {
+ get {
+ return sCapacity;
+ }
+
+ set {
+ if( value < sLength ) {
+ throw new ArgumentException( "Capacity must be > length" );
+ } else {
+ char[] tString = new char[value];
+ Array.Copy( sString, tString, sLength );
+ sString = tString;
+ sCapacity = sString.Length;
+ }
+ }
+ }
+
+
+ public int Length {
+ get {
+ return sLength;
+ }
+
+ set {
+ if( value < 0 || value > Int32.MaxValue) {
+ throw new ArgumentOutOfRangeException();
+ } else {
+ if( value < sLength ) {
+ // Truncate current string at value
+
+ // LAMESPEC: The spec is unclear as to what to do
+ // with the capacity when truncating the string.
+ //
+ // Don't change the capacity, as this is what
+ // the MS implementation does.
+
+ sLength = value;
+ } else {
+ // Expand the capacity to the new length and
+ // pad the string with spaces.
+
+ // LAMESPEC: The spec says to put the spaces on the
+ // left of the string however the MS implementation
+ // puts them on the right. We'll do that for
+ // compatibility (!)
+
+ char[] tString = new char[ value ];
+ int padLength = value - sLength;
+
+ string padding = new String( ' ', padLength );
+ Array.Copy( sString, tString, sLength );
+ Array.Copy( padding.ToCharArray(), 0, tString, sLength, padLength );
+ sString = tString;
+ sLength = sString.Length;
+ sCapacity = value;
+ }
+ }
+ }
+ }
+
+ public char this[ int index ] {
+ get {
+
+ if( index >= sLength || index < 0 ) {
+ throw new IndexOutOfRangeException();
+ }
+ return sString[ index ];
+ }
+
+ set {
+ if( index >= sLength || index < 0 ) {
+ throw new IndexOutOfRangeException();
+ }
+ sString[ index ] = value;
+ }
+ }
+
+ public override string ToString() {
+ return ToString(0, sLength);
+ }
+
+ public string ToString( int startIndex, int length ) {
+ if( startIndex < 0 || length < 0 || startIndex + length > sLength ) {
+ throw new ArgumentOutOfRangeException();
+ }
+
+ return new String( sString, startIndex, length );
+ }
+
+ public int EnsureCapacity( int capacity ) {
+ if( capacity < 0 ) {
+ throw new ArgumentOutOfRangeException(
+ "Capacity must be greater than 0." );
+ }
+
+ if( capacity <= sCapacity ) {
+ return sCapacity;
+ } else {
+ Capacity = capacity;
+ return sCapacity;
+ }
+ }
+
+ public bool Equals( StringBuilder sb ) {
+ if( this.ToString() == sb.ToString() ) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public StringBuilder Remove( int startIndex, int length ) {
+ if( startIndex < 0 || length < 0 || startIndex + length > sLength ) {
+ throw new ArgumentOutOfRangeException();
+ }
+
+ // Copy everything after the 'removed' part to the start
+ // of the removed part and truncate the sLength
+
+ Array.Copy( sString, startIndex + length, sString,
+ startIndex, length );
+
+ sLength -= length;
+ return this;
+ }
+
+ public StringBuilder Replace( char oldChar, char newChar ) {
+
+ return Replace( oldChar, newChar, 0, sLength);
+ }
+
+ public StringBuilder Replace( char oldChar, char newChar, int startIndex, int count ) {
+ if( startIndex + count > sLength || startIndex < 0 || count < 0 ) {
+ throw new ArgumentOutOfRangeException();
+ }
+
+ for( int replaceIterate = startIndex; replaceIterate < startIndex + count; replaceIterate++ ) {
+ if( this[replaceIterate] == oldChar ) {
+ this[replaceIterate] = newChar;
+ }
+ }
+
+ return this;
+ }
+
+ public StringBuilder Replace( string oldValue, string newValue ) {
+ return Replace( oldValue, newValue, 0, sLength );
+ }
+
+ public StringBuilder Replace( string oldValue, string newValue, int startIndex, int count ) {
+ string startString = this.ToString();
+ StringBuilder newStringB = new StringBuilder();
+ string newString;
+
+ if( oldValue == null ) {
+ throw new ArgumentNullException(
+ "The old value cannot be null.");
+ }
+
+ if( startIndex < 0 || count < 0 || startIndex + count > sLength ) {
+ throw new ArgumentOutOfRangeException();
+ }
+
+ if( oldValue.Length == 0 ) {
+ throw new ArgumentException(
+ "The old value cannot be zero length.");
+ }
+
+ int nextIndex = startIndex; // Where to start the next search
+ int lastIndex = nextIndex; // Where the last search finished
+
+ while( nextIndex != -1 ) {
+ nextIndex = startString.IndexOf( oldValue, lastIndex);
+ if( nextIndex != -1 ) {
+ // The MS implementation won't replace a substring
+ // if that substring goes over the "count"
+ // boundary, so we'll make sure the behaviour
+ // here is the same.
+
+ if( nextIndex + oldValue.Length < startIndex + count ) {
+
+ // Add everything to the left of the old
+ // string
+ newStringB.Append( startString.Substring( lastIndex, nextIndex - lastIndex ) );
+
+ // Add the replacement string
+ newStringB.Append( newValue );
+
+ // Set the next start point to the
+ // end of the last match
+ lastIndex = nextIndex + oldValue.Length;
+ } else {
+ // We're past the "count" we're supposed to replace within
+ nextIndex = -1;
+ newStringB.Append(
+ startString.Substring( lastIndex ) );
+ }
+
+ } else {
+ // Append everything left over
+ newStringB.Append( startString.Substring( lastIndex ) );
+ }
+ }
+
+ newString = newStringB.ToString();
+
+ EnsureCapacity( newString.Length );
+ sString = newString.ToCharArray();
+ sLength = newString.Length;
+ return this;
+ }
+
+
+ /* The Append Methods */
+
+ // TODO: Currently most of these methods convert the
+ // parameter to a CharArray (via a String) and then pass
+ // it to Append( char[] ). There might be a faster way
+ // of doing this, but it's probably adequate and anything else
+ // would make it too messy.
+ //
+ // As an example, a sample test run of appending a 100 character
+ // string to the StringBuilder, and loooping this 50,000 times
+ // results in an elapsed time of 2.4s using the MS StringBuilder
+ // and 2.7s using this StringBuilder. Note that this results
+ // in a 5 million character string. I believe MS uses a lot
+ // of "native" DLLs for the "meat" of the base classes.
+
+
+ public StringBuilder Append( char[] value ) {
+ if( sLength + value.Length > sCapacity ) {
+ // Need more capacity, double the capacity StringBuilder
+ // and make sure we have at least enough for the value
+ // if that's going to go over double.
+
+ Capacity = value.Length + ( sCapacity + sCapacity);
+ }
+
+ Array.Copy( value, 0, sString, sLength, value.Length );
+ sLength += value.Length;
+
+ return this;
+ }
+
+ public StringBuilder Append( string value ) {
+ if( value != null ) {
+ return Append( value.ToCharArray() );
+ } else {
+ return null;
+ }
+ }
+
+ public StringBuilder Append( bool value ) {
+ return Append( value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Append( byte value ) {
+ return Append( value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Append( int index, char value) {
+ char[] appendChar = new char[1];
+
+ appendChar[0] = value;
+ return Append( appendChar );
+ }
+
+
+ public StringBuilder Append( decimal value ) {
+ return Append( value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Append( double value ) {
+ return Append( value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Append( short value ) {
+ return Append( value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Append( int value ) {
+ return Append( value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Append( long value ) {
+ return Append( value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Append( object value ) {
+ return Append( value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Append( sbyte value ) {
+ return Append( value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Append( float value ) {
+ return Append( value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Append( ushort value ) {
+ return Append( value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Append( uint value ) {
+ return Append( value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Append( ulong value ) {
+ return Append( value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Append( char value, int repeatCount ) {
+ if( repeatCount < 0 ) {
+ throw new ArgumentOutOfRangeException();
+ }
+
+ return Append( new String( value, repeatCount) );
+ }
+
+ public StringBuilder Append( char[] value, int startIndex, int charCount ) {
+
+ if( (charCount < 0 || startIndex < 0) ||
+ ( charCount + startIndex > value.Length ) ) {
+ throw new ArgumentOutOfRangeException();
+ }
+
+ if( value == null ) {
+ if( !(startIndex == 0 && charCount == 0) ) {
+ throw new ArgumentNullException();
+ } else {
+ return this;
+ }
+ } else {
+ char[] appendChars = new char[ charCount ];
+
+ Array.Copy( value, startIndex, appendChars, 0, charCount );
+ return Append( appendChars );
+ }
+ }
+
+ public StringBuilder Append( string value, int startIndex, int count ) {
+ if( (count < 0 || startIndex < 0) ||
+ ( startIndex + count > value.Length ) ) {
+ throw new ArgumentOutOfRangeException();
+ }
+
+ return Append( value.Substring( startIndex, count ).ToCharArray() );
+ }
+
+ public StringBuilder AppendFormat( string format, object arg0 ) {
+ // TODO: Implement
+ return this;
+ }
+
+ public StringBuilder AppendFormat( string format, params object[] args ) {
+ // TODO: Implement
+ return this;
+ }
+
+ public StringBuilder AppendFormat( IFormatProvider provider, string format,
+ params object[] args ) {
+ // TODO: Implement
+ return this;
+ }
+
+ public StringBuilder AppendFormat( string format, object arg0, object arg1 ) {
+ // TODO: Implement;
+ return this;
+ }
+
+ public StringBuilder AppendFormat( string format, object arg0, object arg1, object arg2 ) {
+ // TODO Implement
+ return this;
+ }
+
+ /* The Insert Functions */
+
+ // Similarly to the Append functions, get everything down to a CharArray
+ // and insert that.
+
+ public StringBuilder Insert( int index, char[] value ) {
+ if( index > sLength || index < 0) {
+ throw new ArgumentOutOfRangeException();
+ }
+
+ if( value == null || value.Length == 0 ) {
+ return this;
+ } else {
+ // Check we have the capacity to insert this array
+ if( sCapacity < sLength + value.Length ) {
+ Capacity = value.Length + ( sCapacity + sCapacity );
+ }
+
+ // Move everything to the right of the insert point across
+ Array.Copy( sString, index, sString, index + value.Length, sLength - index);
+
+ // Copy in stuff from the insert buffer
+ Array.Copy( value, 0, sString, index, value.Length );
+
+ sLength += value.Length;
+ return this;
+ }
+ }
+
+ public StringBuilder Insert( int index, string value ) {
+ return Insert( index, value.ToCharArray() );
+ }
+
+ public StringBuilder Insert( int index, bool value ) {
+ return Insert( index, value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Insert( int index, byte value ) {
+ return Insert( index, value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Insert( int index, char value) {
+ char[] insertChar = new char[1];
+
+ insertChar[0] = value;
+ return Insert( index, insertChar );
+ }
+
+ public StringBuilder Insert( int index, decimal value ) {
+ return Insert( index, value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Insert( int index, double value ) {
+ return Insert( index, value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Insert( int index, short value ) {
+ return Insert( index, value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Insert( int index, int value ) {
+ return Insert( index, value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Insert( int index, long value ) {
+ return Insert( index, value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Insert( int index, object value ) {
+ return Insert( index, value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Insert( int index, sbyte value ) {
+ return Insert( index, value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Insert( int index, float value ) {
+ return Insert( index, value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Insert( int index, ushort value ) {
+ return Insert( index, value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Insert( int index, uint value ) {
+ return Insert( index, value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Insert( int index, ulong value ) {
+ return Insert( index, value.ToString().ToCharArray() );
+ }
+
+ public StringBuilder Insert( int index, string value, int count ) {
+ if ( count < 0 ) {
+ throw new ArgumentOutOfRangeException();
+ }
+
+ if( value != null ) {
+ if( value != "" ) {
+ for( int insertCount = 0; insertCount < count;
+ insertCount++ ) {
+ Insert( index, value.ToCharArray() );
+ }
+ }
+ }
+ return this;
+ }
+
+ public StringBuilder Insert( int index, char[] value, int startIndex,
+ int charCount ) {
+
+ if( value != null ) {
+ if( charCount < 0 || startIndex < 0 || startIndex + charCount > value.Length ) {
+ throw new ArgumentOutOfRangeException();
+ }
+
+ char[] insertChars = new char[ charCount ];
+ Array.Copy( value, startIndex, insertChars, 0, charCount );
+ return Insert( index, insertChars );
+ } else {
+ return this;
+ }
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Text/UTF7Encoding.cs b/mcs/class/corlib/System.Text/UTF7Encoding.cs new file mode 100755 index 00000000000..c21389b7e8a --- /dev/null +++ b/mcs/class/corlib/System.Text/UTF7Encoding.cs @@ -0,0 +1,40 @@ +// +// System.Text.UTF7Encoding.cs +// +// Author: +// Sean MacIsaac (macisaac@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + + +namespace System.Text { + + public class UTF7Encoding : Encoding { + public override int GetByteCount(char[] chars, int index, int count) { + // FIXME + return 0; + } + + public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { + // FIXME + return 0; + } + + public override char[] GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) { + // FIXME + return null; + } + + public override int GetMaxByteCount(int charCount) { + // FIXME + return 0; + } + + public override int GetMaxCharCount(int byteCount) { + // FIXME + return 0; + } + } +} + diff --git a/mcs/class/corlib/System.Text/UTF8Encoding.cs b/mcs/class/corlib/System.Text/UTF8Encoding.cs new file mode 100755 index 00000000000..eb7ddffaf7d --- /dev/null +++ b/mcs/class/corlib/System.Text/UTF8Encoding.cs @@ -0,0 +1,40 @@ +// +// System.Text.UTF8Encoding.cs +// +// Author: +// Sean MacIsaac (macisaac@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + + +namespace System.Text { + + public class UTF8Encoding : Encoding { + public override int GetByteCount(char[] chars, int index, int count) { + // FIXME + return 0; + } + + public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { + // FIXME + return 0; + } + + public override char[] GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) { + // FIXME + return null; + } + + public override int GetMaxByteCount(int charCount) { + // FIXME + return 0; + } + + public override int GetMaxCharCount(int byteCount) { + // FIXME + return 0; + } + } +} + diff --git a/mcs/class/corlib/System.Text/UnicodeEncoding.cs b/mcs/class/corlib/System.Text/UnicodeEncoding.cs new file mode 100755 index 00000000000..374c6e1963c --- /dev/null +++ b/mcs/class/corlib/System.Text/UnicodeEncoding.cs @@ -0,0 +1,46 @@ +// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- +// +// System.Text.UnicodeEncoding.cs +// +// Author: +// Sean MacIsaac (macisaac@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + + +namespace System.Text { + + public class UnicodeEncoding : Encoding { + public UnicodeEncoding() { + } + + public UnicodeEncoding(bool bigEndian, bool byteOrderMark) { + } + + public override int GetByteCount(char[] chars, int index, int count) { + // FIXME + return 0; + } + + public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { + // FIXME + return 0; + } + + public override char[] GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) { + // FIXME + return null; + } + + public override int GetMaxByteCount(int charCount) { + // FIXME + return 0; + } + + public override int GetMaxCharCount(int byteCount) { + // FIXME + return 0; + } + } +} diff --git a/mcs/class/corlib/System.Text/common.src b/mcs/class/corlib/System.Text/common.src new file mode 100755 index 00000000000..774b5bc098c --- /dev/null +++ b/mcs/class/corlib/System.Text/common.src @@ -0,0 +1,6 @@ +ASCIIEncoding.cs +Encoding.cs +StringBuilder.cs +UTF7Encoding.cs +UTF8Encoding.cs +UnicodeEncoding.cs diff --git a/mcs/class/corlib/System.Text/unix.src b/mcs/class/corlib/System.Text/unix.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/corlib/System.Text/unix.src diff --git a/mcs/class/corlib/System.Text/windows.src b/mcs/class/corlib/System.Text/windows.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/corlib/System.Text/windows.src diff --git a/mcs/class/corlib/System/ApplicationException.cs b/mcs/class/corlib/System/ApplicationException.cs new file mode 100644 index 00000000000..9bb597644aa --- /dev/null +++ b/mcs/class/corlib/System/ApplicationException.cs @@ -0,0 +1,29 @@ +// +// System.ApplicationException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class ApplicationException : Exception { + // Constructors + public ApplicationException () + : base ("An application exception has occurred.") + { + } + + public ApplicationException (string message) + : base (message) + { + } + + public ApplicationException (string message, Exception inner) + : base (message, inner) + { + } + } +} diff --git a/mcs/class/corlib/System/ArgumentException.cs b/mcs/class/corlib/System/ArgumentException.cs new file mode 100644 index 00000000000..c97c57cac12 --- /dev/null +++ b/mcs/class/corlib/System/ArgumentException.cs @@ -0,0 +1,50 @@ +// +// System.ArgumentException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class ArgumentException : SystemException { + private string param_name; + + // Constructors + public ArgumentException () + : base ("An invalid argument was specified.") + { + } + + public ArgumentException (string message) + : base (message) + { + } + + public ArgumentException (string message, Exception inner) + : base (message, inner) + { + } + + public ArgumentException (string message, string param_name) + : base (message) + { + this.param_name = param_name; + } + + public ArgumentException (string message, string param_name, Exception inner) + : base (message, inner) + { + this.param_name = param_name; + } + + // Properties + public virtual string ParamName { + get { + return param_name; + } + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/ArgumentNullException.cs b/mcs/class/corlib/System/ArgumentNullException.cs new file mode 100644 index 00000000000..d35a9648e63 --- /dev/null +++ b/mcs/class/corlib/System/ArgumentNullException.cs @@ -0,0 +1,29 @@ +// +// System.ArgumentNullException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class ArgumentNullException : ArgumentException { + // Constructors + public ArgumentNullException () + : base ("Argument cannot be null") + { + } + + public ArgumentNullException (string param_name) + : base ("Argument cannot be null", param_name) + { + } + + public ArgumentNullException (string param_name, string message) + : base (message, param_name) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/ArgumentOutOfRangeException.cs b/mcs/class/corlib/System/ArgumentOutOfRangeException.cs new file mode 100644 index 00000000000..26acf91cf46 --- /dev/null +++ b/mcs/class/corlib/System/ArgumentOutOfRangeException.cs @@ -0,0 +1,44 @@ +// +// System.ArgumentOutOfRangeException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class ArgumentOutOfRangeException : ArgumentException { + private object actual_value; + + // Constructors + public ArgumentOutOfRangeException () + : base ("Argument is out of range") + { + } + + public ArgumentOutOfRangeException (string param_name) + : base ("Argument is out of range", param_name) + { + } + + public ArgumentOutOfRangeException (string param_name, string message) + : base (message, param_name) + { + } + + public ArgumentOutOfRangeException (string param_name, object actual_value, string message) + : base (message, param_name) + { + this.actual_value = actual_value; + } + + // Properties + public virtual object ActualValue { + get { + return actual_value; + } + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/ArithmeticException.cs b/mcs/class/corlib/System/ArithmeticException.cs new file mode 100644 index 00000000000..cc5bfa92477 --- /dev/null +++ b/mcs/class/corlib/System/ArithmeticException.cs @@ -0,0 +1,29 @@ +// +// System.ArithmeticException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class ArithmeticException : SystemException { + // Constructors + public ArithmeticException () + : base ("The arithmetic operation is not allowed") + { + } + + public ArithmeticException (string message) + : base (message) + { + } + + public ArithmeticException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/Array.cs b/mcs/class/corlib/System/Array.cs new file mode 100644 index 00000000000..814d991c7e4 --- /dev/null +++ b/mcs/class/corlib/System/Array.cs @@ -0,0 +1,381 @@ +// +// System.Array.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +using System.Collections; +using System.Runtime.CompilerServices; + +namespace System
+{ + + public abstract class Array : ICloneable
+ { + public int lower_bound = 0; + protected int length; + protected int rank; + + // Properties + public int Length
+ { + get
+ { + return length; + } + } + + public int Rank
+ { + get
+ { + return rank; + } + } + + // Methods + public static int BinarySearch (Array array, object value) + { + return BinarySearch (array, array.lower_bound, array.length, value, null); + } + + public static int BinarySearch (Array array, object value, IComparer comparer) + { + return BinarySearch (array, array.lower_bound, array.length, value, comparer); + } + + public static int BinarySearch (Array array, int index, int length, object value) + { + return BinarySearch (array, index, length, value, null); + } + + public static int BinarySearch (Array array, int index, int length, object value, IComparer comparer) + { + if (array == null) + throw new ArgumentNullException (); + + if (array.Rank > 1) + throw new RankException (); + + if (index < array.lower_bound || length < 0) + throw new ArgumentOutOfRangeException (); + + if (index + length > array.lower_bound + array.Length) + throw new ArgumentException (); + + if (comparer == null && !(value is IComparable)) + throw new ArgumentException (); + + // FIXME: Throw an ArgumentException if comparer + // is null and value is not of the same type as the + // elements of array. + + for (int i = 0; i < length; i++)
+ { + int result; + + if (comparer == null && !(array.GetValue(index + i) is IComparable)) + throw new ArgumentException (); + + if (comparer == null) + result = (value as IComparable).CompareTo(array.GetValue(index + i)); + else + result = comparer.Compare(value, array.GetValue(index + i)); + + if (result == 0) + return index + i; + else if (result < 0) + return ~(index + i); + } + + return ~(index + length); + } + + public static void Clear (Array array, int index, int length) + { + if (array == null) + throw new ArgumentNullException (); + + if (index < array.lower_bound || length < 0 || + index + length > array.lower_bound + array.length) + throw new ArgumentOutOfRangeException (); + + for (int i = 0; i < length; i++)
+ { + if (array.GetValue(index + i) is bool) + array.SetValue(false, index + i); + else if (array.GetValue(index + i) is ValueType) + array.SetValue(0, index + i); + else + array.SetValue(null, index + i); + } + } + + public virtual object Clone () + { + // Array is abstract -- Array a = new Array(); + Array a = (Array)this.Clone(); + + for (int i = 0; i < this.length; i++)
+ { + int index = this.lower_bound + i; + + a.SetValue(this.GetValue(index), index); + } + + return a; + } + + public static void Copy (Array source, Array dest, int length) + { + Copy (source, source.lower_bound, dest, dest.lower_bound, length); + } + + public static void Copy (Array source, int source_idx, Array dest, int dest_idx, int length) + { + if (length < 0) + throw new ArgumentOutOfRangeException (); + + if (source == null || dest == null) + throw new ArgumentNullException (); + + if (source_idx < source.lower_bound || source_idx + length > source.lower_bound + source.Length || dest_idx < dest.lower_bound || dest_idx + length > dest.lower_bound + dest.Length) + throw new ArgumentException (); + + if (source.Rank != dest.Rank) + throw new RankException (); + + for (int i = 0; i < length; i++)
+ { + int index = source.lower_bound + i; + + dest.SetValue(source.GetValue(index), index); + } + } + + [MethodImplAttribute(MethodImplOptions.InternalCall)] + private extern object InternalGetValue (int index); + + public object GetValue (int index) + { + if (this.rank > 1) + throw new ArgumentException (); + + if (index < this.lower_bound || + index > this.lower_bound + this.length) + throw new ArgumentOutOfRangeException (); + + return InternalGetValue (index); + } + + [MethodImplAttribute(MethodImplOptions.InternalCall)] + private extern void InternalSetValue (object value, int index); + + public void SetValue (object value, int index) + { + if (this.rank > 1) + throw new ArgumentException (); + + if (index < this.lower_bound || + index > this.lower_bound + this.length) + throw new ArgumentOutOfRangeException (); + + InternalSetValue (value, index); + } + + public static int IndexOf (Array array, object value) + { + return IndexOf (array, value, 0, array.Length); + } + + public static int IndexOf (Array array, object value, int index) + { + return IndexOf (array, value, index, array.Length - index); + } + + public static int IndexOf (Array array, object value, int index, int length) + { + if (array == null) + throw new ArgumentNullException (); + + if (length < 0 || index < array.lower_bound || index > array.lower_bound + length) + throw new ArgumentOutOfRangeException (); + + for (int i = 0; i < length; i++)
+ { + if (array.GetValue(index + i) == value) + return index + i; + } + + return array.lower_bound - 1; + } + + public static int LastIndexOf (Array array, object value) + { + return LastIndexOf (array, value, 0, array.Length); + } + + public static int LastIndexOf (Array array, object value, int index) + { + return LastIndexOf (array, value, index, array.Length - index); + } + + public static int LastIndexOf (Array array, object value, int index, int length) + { + if (array == null) + throw new ArgumentNullException (); + + if (length < 0 || index < array.lower_bound || index > array.lower_bound + length) + throw new ArgumentOutOfRangeException (); + + for (int i = length - 1; i >= 0; i--)
+ { + if (array.GetValue(index + i) == value) + return index + i; + } + + return array.lower_bound - 1; + } + + public static void Reverse (Array array) + { + Reverse (array, array.lower_bound, array.Length); + } + + public static void Reverse (Array array, int index, int length) + { + if (array == null) + throw new ArgumentNullException (); + + if (array.Rank > 1) + throw new RankException (); + + if (index < array.lower_bound || length < 0) + throw new ArgumentOutOfRangeException (); + + if (index + length > array.lower_bound + array.Length) + throw new ArgumentException (); + + for (int i = 0; i < length/2; i++)
+ { + object tmp; + + tmp = array.GetValue(index + i); + array.SetValue(array.GetValue(index + length - i - 1), index + i); + array.SetValue(tmp, index + length - i - 1); + } + } + + public static void Sort (Array array) + { + Sort (array, null, array.lower_bound, array.Length, null); + } + + public static void Sort (Array keys, Array items) + { + Sort (keys, items, keys.lower_bound, keys.Length, null); + } + + public static void Sort (Array array, IComparer comparer) + { + Sort (array, null, array.lower_bound, array.Length, comparer); + } + + public static void Sort (Array array, int index, int length) + { + Sort (array, null, index, length, null); + } + + public static void Sort (Array keys, Array items, IComparer comparer) + { + Sort (keys, items, keys.lower_bound, keys.Length, comparer); + } + + public static void Sort (Array keys, Array items, int index, int length) + { + Sort (keys, items, index, length, null); + } + + public static void Sort (Array array, int index, int length, IComparer comparer) + { + Sort (array, null, index, length, comparer); + } + + public static void Sort (Array keys, Array items, int index, int length, IComparer comparer) + { + int low0 = index; + int high0 = index + length - 1; + + qsort (keys, items, index, index + length - 1, comparer); + } + + private static void qsort (Array keys, Array items, int low0, int high0, IComparer comparer) + { + int pivot; + int low = low0; + int high = high0; + + if (low >= high) + return; + + pivot = (low + high) / 2; + + if (compare(keys.GetValue(low), keys.GetValue(pivot), comparer) > 0) + swap(keys, items, low, pivot); + + if (compare(keys.GetValue(pivot), keys.GetValue(high), comparer) > 0) + swap(keys, items, pivot, high); + + while (low < high)
+ { + // Move the walls in + while (low < high && compare(keys.GetValue(low), keys.GetValue(pivot), comparer) < 0) + low++; + while (low < high && compare(keys.GetValue(pivot), keys.GetValue(high), comparer) < 0) + high--; + + if (low < high)
+ { + swap(keys, items, low, high); + low++; + high--; + } + } + + qsort (keys, items, low0, low - 1, comparer); + qsort (keys, items, high + 1, high0, comparer); + } + + private static void swap (Array keys, Array items, int i, int j) + { + object tmp; + + tmp = keys.GetValue(i); + keys.SetValue(keys.GetValue(j), i); + keys.SetValue(tmp, j); + + if (items != null)
+ { + tmp = items.GetValue(i); + items.SetValue(items.GetValue(j), i); + items.SetValue(tmp, j); + } + } + + private static int compare (object value1, object value2, IComparer comparer) + { + if (comparer == null) + return ((IComparable) value1).CompareTo(value2); + else + return comparer.Compare(value1, value2); + } + + public static Array CreateInstance(Type elementType, int length) + { + return null; + } + } +} diff --git a/mcs/class/corlib/System/ArrayTypeMismatchException.cs b/mcs/class/corlib/System/ArrayTypeMismatchException.cs new file mode 100644 index 00000000000..ecfc88a4cc8 --- /dev/null +++ b/mcs/class/corlib/System/ArrayTypeMismatchException.cs @@ -0,0 +1,29 @@ +// +// System.ArrayTypeMismatchException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class ArrayTypeMismatchException : SystemException { + // Constructors + public ArrayTypeMismatchException () + : base ("Source array type cannot be assigned to destination array type") + { + } + + public ArrayTypeMismatchException (string message) + : base (message) + { + } + + public ArrayTypeMismatchException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/ChangeLog b/mcs/class/corlib/System/ChangeLog new file mode 100644 index 00000000000..c6fb33e8605 --- /dev/null +++ b/mcs/class/corlib/System/ChangeLog @@ -0,0 +1,153 @@ +2001-07-15 Sean MacIsaac <macisaac@ximian.com> + + * String.cs: Spelling error of IComparable, object's + MemberwiseClone cannot be overridden. Made indexer valid for now, + but not sure what to do about this in the long run. Seems to be a + couple bugs in csc.exe having to do with multiple pointer defs in + the same statement, and returning subclasses of a class in the + return type of an interface function implementation. Also moved + operators inside of class definition. + +2001-07-14 Jeffrey Stedfast <fejj@ximian.com> + + * String.cs: A tom of compile fixes, although we still don't compile. + + * IConvertible.cs: The To*Int64() methods return *Int64's, not + *Int32's. Also, it's ToDateTime() not ToDateType(). + +2001-07-14 Jeffrey Stedfast <fejj@ximian.com> + + * String.cs: Apparently I needed to at least write stubs for the + IConvertible interfaces. *sigh* + +2001-07-14 Jeffrey Stedfast <fejj@ximian.com> + + * String.cs: Many logic/other fixes and better usage of the + features of c# + (tolower): New convenience method to help condense code. + (toupper): Another new helper method. + (Compare): Use the new helper methods. + (ToLower): use tolower(). + (ToUpper): use toupper(). + (LastIndexOfAny): Implemented. + (BoyerMoore): New private helper method that implements a modified + version of the Boyer-Moore search algorithm. Noothing uses it yet + as I'm not 100% sure it even works properly with unicode strings + not to mention it uses a huge lookup-table :-) + (Split): Implemented. + +2001-07-13 Jeffrey Stedfast <fejj@ximian.com> + + * TODO: Added things that need to be finished in System.String + + * String.cs: New source file implementing the System.String class + +2001-07-12 Sean MacIsaac <macisaac@ximian.com> + + * TypeCode.cs: UInt64 was UInt63. + + * Object.cs: Fixed a numer of compiler errors. + + * Array.cs: Fixed some compiler errors. + + * IComparable.cs: Fixed some compiler errors. + + * ICloneable.cs: Fixed some compiler errors. + + * IConvertible.cs: Fixed some compiler errors. + + * IFormattable.cs: Fixed a compiler error. + + * IFormatProvider.cs: Fixed a compiler error. + + * IDisposable.cs: Fixed a compiler error. + + * IFormatProvider.cs: Added public accesability type to + IFormatProvider. + + * Exception.cs: Added a using statement to remove compile time + error. + + * ApplicationException.cs: Removed a ; that was causing a compiler + error. + + * Int16.cs: Fixed some compiler errors. + + * Int32.cs: Fixed some compiler errors. + + * Int64.cs: Fixed some compiler errors. + + * SystemException.cs: Fixed a compiler error. + + * UInt16.cs: Fixed some compiler errors. + + * UInt32.cs: Fixed some compiler errors. + + * UInt64.cs: Fixed some compiler errors. + + * Void.cs: Fixed a compiler error. + +2001-07-12 Joe Shaw <joe@ximian.com> + + * Array.cs: Fix backwards parameters to Array.SetValue() + throughout. + (BinarySearch): Fix backward logic surrounding whether to call + value.CompareTo or comparer.Compare. + (LastIndexOf): Stop being stupid. I am so not used to strongly + bounded arrays... + (Sort): Implement a quicksort. + +2001-07-11 Joe Shaw <joe@ximian.com> + + * Array.cs: Change all instances of trying to access an array with + the index operator to calls to GetValue and SetValue, and add + InternalGetValue and InternalSetValue which are internal calls + into the runtime. Ew. + +2001-07-10 Joe Shaw <joe@ximian.com> + + * Array.cs: Implemented everything but Sort(). + +2001-07-09 Jeffrey Stedfast <fejj@ximian.com> + + * Object.cs (Object::Equals): Object variable name is `o'. + +2001-07-06 Joe Shaw <joe@ximian.com> + + * Int16.cs, Int32.cs, Int64.cs, UInt16.cs, UInt32.cs, UInt64.cs: + Implement the IComparable and IFormattable interfaces. Fix a typo + (publig -> public) + + * ApplicationException.cs, ArgumentException.cs, + ArgumentNullException.cs, ArgumentOutOfRangeException.cs, + ArtithmeticException.cs, ArrayTypeMismatchException.cs, + DivideByZeroException.cs, DuplicateWaitObjectException.cs, + ExecutionEngineException.cs, FormatException.cs, + IndexOutOfRangeException.cs, InvalidCastException.cs, + InvalidOperationException.cs, InvalidProgramException.cs, + MulticateNotSupportedException.cs, NotFiniteNumberException.cs, + NotSupportedException.cs, NullReferenceException.cs, + OutOfMemoryException.cs, OverflowException.cs, RankException.cs, + StackOverflowException.cs, SystemException.cs, + TypeInitializationException.cs: Added all of the exceptions + specified by the language spec. Mmmm... bloat. + +2001-07-06 Miguel de Icaza <miguel@ximian.com> + + * Int64.cs, Int32.cs: Put. Parsing and ToString missing. Should + do a generic routine all of these guys use. + + * Int16.cs: identified missing methods. + + * UInt16.cs, UInt32.cs, UInt64.cs: Add. + +2001-06-26 Miguel de Icaza <miguel@ximian.com> + + * TypeCode.cs: Implement + + * Void.cs: Implement. + + * TODO: Add file to keep track of pending tasks. + + * Object.cs, ValueType.cs: Implement. + diff --git a/mcs/class/corlib/System/DivideByZeroException.cs b/mcs/class/corlib/System/DivideByZeroException.cs new file mode 100644 index 00000000000..5b94f587222 --- /dev/null +++ b/mcs/class/corlib/System/DivideByZeroException.cs @@ -0,0 +1,29 @@ +// +// System.DivideByZeroException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class DivideByZeroException : ArithmeticException { + // Constructors + public DivideByZeroException () + : base ("Division by zero") + { + } + + public DivideByZeroException (string message) + : base (message) + { + } + + public DivideByZeroException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/DuplicateWaitObjectException.cs b/mcs/class/corlib/System/DuplicateWaitObjectException.cs new file mode 100644 index 00000000000..72ccc25483d --- /dev/null +++ b/mcs/class/corlib/System/DuplicateWaitObjectException.cs @@ -0,0 +1,29 @@ +// +// System.DuplicateWaitObjectException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class DuplicateWaitObjectException : ArgumentException { + // Constructors + public DuplicateWaitObjectException () + : base ("Duplicate objects in argument") + { + } + + public DuplicateWaitObjectException (string param_name) + : base ("Duplicate objects in argument", param_name) + { + } + + public DuplicateWaitObjectException (string param_name, string message) + : base (message, param_name) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/Exception.cs b/mcs/class/corlib/System/Exception.cs new file mode 100644 index 00000000000..00994103c41 --- /dev/null +++ b/mcs/class/corlib/System/Exception.cs @@ -0,0 +1,137 @@ +// +// System.Exception.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +using System.Runtime.Serialization; +using System.Reflection; + +namespace System { + + public class Exception : ISerializable { + Exception inner_exception; + string message; + string help_link; + string stack_trace = "TODO: implement stack traces"; + int hresult; + private string source; + + public Exception () + { + inner_exception = null; + message = ""; + } + + public Exception (string msg) + { + inner_exception = null; + message = msg; + } + + protected Exception (SerializationInfo info, StreamingContext sc) + { + if (info == null){ + throw new ArgumentNullException ("info"); + } + + // TODO: Implement the restoration of an Exception + // from a stream. + } + + public Exception (string msg, Exception e) + { + inner_exception = e; + message = msg; + } + + public Exception InnerException { + get { + return inner_exception; + } + } + + public string HelpLink { + get { + return help_link; + } + + set { + help_link = value; + } + } + + protected int HResult { + get { + return hresult; + } + + set { + hresult = value; + } + } + + public string Message { + get { + return message; + } + } + + public string Source { + get { + // TODO: if source is null, we must return + // the name of the assembly where the error + // originated. + return source; + } + + set { + source = value; + } + } + + public string StackTrace { + get { + return stack_trace; + } + } + + public MethodBase TargetSite { + get { + // TODO: Implement this. + return null; + } + } + + public virtual Exception GetBaseException () + { + Exception inner = inner_exception; + + while (inner != null){ + if (inner.InnerException != null) + inner = inner.InnerException; + else + return inner; + } + + return null; + } + + public virtual void GetObjectData (SerializationInfo info, StreamingContext context) + { + // TODO: implement me. + } + + public override string ToString () + { + return this.GetType ().FullName + "\n" + + message + + GetBaseException ().GetType ().FullName + + stack_trace; + } + } +} + diff --git a/mcs/class/corlib/System/ExecutionEngineException.cs b/mcs/class/corlib/System/ExecutionEngineException.cs new file mode 100644 index 00000000000..db1e2b555c7 --- /dev/null +++ b/mcs/class/corlib/System/ExecutionEngineException.cs @@ -0,0 +1,29 @@ +// +// System.ExecutionEngineException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public sealed class ExecutionEngineException : SystemException { + // Constructors + public ExecutionEngineException () + : base ("Internal error occurred") // Haha. Nice. + { + } + + public ExecutionEngineException (string message) + : base (message) + { + } + + public ExecutionEngineException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/FormatException.cs b/mcs/class/corlib/System/FormatException.cs new file mode 100644 index 00000000000..332d50e1b52 --- /dev/null +++ b/mcs/class/corlib/System/FormatException.cs @@ -0,0 +1,29 @@ +// +// System.FormatException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class FormatException : SystemException { + // Constructors + public FormatException () + : base ("Invalid format") + { + } + + public FormatException (string message) + : base (message) + { + } + + public FormatException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/ICloneable.cs b/mcs/class/corlib/System/ICloneable.cs new file mode 100644 index 00000000000..792550db1f5 --- /dev/null +++ b/mcs/class/corlib/System/ICloneable.cs @@ -0,0 +1,15 @@ +// +// System.ICloneable.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public interface ICloneable { + object Clone (); + } +} diff --git a/mcs/class/corlib/System/IComparable.cs b/mcs/class/corlib/System/IComparable.cs new file mode 100644 index 00000000000..bee64989f4f --- /dev/null +++ b/mcs/class/corlib/System/IComparable.cs @@ -0,0 +1,15 @@ +// +// System.CoreInterfaces.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public interface IComparable { + int CompareTo (object obj); + } +} diff --git a/mcs/class/corlib/System/IConvertible.cs b/mcs/class/corlib/System/IConvertible.cs new file mode 100644 index 00000000000..bfff8808b28 --- /dev/null +++ b/mcs/class/corlib/System/IConvertible.cs @@ -0,0 +1,33 @@ +// +// System.IConvertible.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public interface IConvertible { + + TypeCode GetTypeCode (); + + bool ToBoolean (IFormatProvider provider); + byte ToByte (IFormatProvider provider); + char ToChar (IFormatProvider provider); + DateTime ToDateTime (IFormatProvider provider); + Decimal ToDecimal (IFormatProvider provider); + Double ToDouble (IFormatProvider provider); + Int16 ToInt16 (IFormatProvider provider); + Int32 ToInt32 (IFormatProvider provider); + Int64 ToInt64 (IFormatProvider provider); + SByte ToSByte (IFormatProvider provider); + float ToSingle (IFormatProvider provider); + string ToString (IFormatProvider provider); + object ToType (Type conversionType, IFormatProvider provider); + UInt16 ToUInt16 (IFormatProvider provider); + UInt32 ToUInt32 (IFormatProvider provider); + UInt64 ToUInt64 (IFormatProvider provider); + } +} diff --git a/mcs/class/corlib/System/ICustomFormatter.cs b/mcs/class/corlib/System/ICustomFormatter.cs new file mode 100644 index 00000000000..a370647f37f --- /dev/null +++ b/mcs/class/corlib/System/ICustomFormatter.cs @@ -0,0 +1,15 @@ +// +// System.ICustomFormatter.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +namespace System { + + interface ICustomFormatter { + string Format (string format, object arg, IFormatProvider formatProvider); + } +} diff --git a/mcs/class/corlib/System/IDisposable.cs b/mcs/class/corlib/System/IDisposable.cs new file mode 100644 index 00000000000..6c3ca1b6367 --- /dev/null +++ b/mcs/class/corlib/System/IDisposable.cs @@ -0,0 +1,17 @@ +// +// System.IDisposable.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public interface IDisposable { + + void Dispose (); + + } +} diff --git a/mcs/class/corlib/System/IFormatProvider.cs b/mcs/class/corlib/System/IFormatProvider.cs new file mode 100644 index 00000000000..266c62d1295 --- /dev/null +++ b/mcs/class/corlib/System/IFormatProvider.cs @@ -0,0 +1,15 @@ +// +// System.IFormatProvider.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public interface IFormatProvider { + object GetFormat (Type format_type); + } +} diff --git a/mcs/class/corlib/System/IFormattable.cs b/mcs/class/corlib/System/IFormattable.cs new file mode 100644 index 00000000000..1769f4034c0 --- /dev/null +++ b/mcs/class/corlib/System/IFormattable.cs @@ -0,0 +1,15 @@ +// +// System.IFormattable.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public interface IFormattable { + string ToString (string format, IFormatProvider format_provider); + } +} diff --git a/mcs/class/corlib/System/IndexOutOfRangeException.cs b/mcs/class/corlib/System/IndexOutOfRangeException.cs new file mode 100644 index 00000000000..62a690bd6ac --- /dev/null +++ b/mcs/class/corlib/System/IndexOutOfRangeException.cs @@ -0,0 +1,29 @@ +// +// System.IndexOutOfRangeException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public sealed class IndexOutOfRangeException : SystemException { + // Constructors + public IndexOutOfRangeException () + : base ("Array index is out of range") + { + } + + public IndexOutOfRangeException (string message) + : base (message) + { + } + + public IndexOutOfRangeException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/Int16.cs b/mcs/class/corlib/System/Int16.cs new file mode 100644 index 00000000000..ae05006d17a --- /dev/null +++ b/mcs/class/corlib/System/Int16.cs @@ -0,0 +1,91 @@ +// +// System.Int16.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +using System.Globalization; + +namespace System { + + public struct Int16 : IComparable, IFormattable { + public const short MinValue = -32768; + public const short MaxValue = 32767; + + // VES needs to know about value. public is workaround + // so source will compile + public short value; + + public int CompareTo (object v) + { + if (!(v is System.Int16)) + throw new ArgumentException ("Value is not a System.Int16"); + + return value - ((short) v); + } + + public override bool Equals (object o) + { + if (!(o is System.Int16)) + return false; + + return ((short) o) == value; + } + + public override int GetHashCode () + { + return value; + } + + public TypeCode GetTypeCode () + { + return TypeCode.Int16; + } + + public static short Parse (string s) + { + // TODO: Implement me + return 0; + } + + public static short Parse (string s, IFormatProvider fp) + { + // TODO: Implement me + return 0; + } + + public static short Parse (string s, NumberStyles style, IFormatProvider fp) + { + // TODO: Implement me + return 0; + } + + public override string ToString () + { + // TODO: Implement me + + return ""; + } + + public string ToString (IFormatProvider fp) + { + // TODO: Implement me. + return ""; + } + + public string ToString (string format) + { + // TODO: Implement me. + return ""; + } + + public string ToString (string format, IFormatProvider fp) + { + // TODO: Implement me. + return ""; + } + } +} diff --git a/mcs/class/corlib/System/Int32.cs b/mcs/class/corlib/System/Int32.cs new file mode 100644 index 00000000000..57496ffa9b6 --- /dev/null +++ b/mcs/class/corlib/System/Int32.cs @@ -0,0 +1,89 @@ +// +// System.Int32.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +using System.Globalization; + +namespace System { + + public struct Int32 : IComparable, IFormattable { + public const int MinValue = -2147483648; + public const int MaxValue = 0x7fffffff; + + public int value; + + public int CompareTo (object v) + { + if (!(v is System.Int32)) + throw new ArgumentException ("Value is not a System.Int32"); + + return value - (int) v; + } + + public override bool Equals (object o) + { + if (!(o is System.Int32)) + return false; + + return ((int) o) == value; + } + + public override int GetHashCode () + { + return value; + } + + public TypeCode GetTypeCode () + { + return TypeCode.Int32; + } + + public static int Parse (string s) + { + // TODO: Implement me + return 0; + } + + public static int Parse (string s, IFormatProvider fp) + { + // TODO: Implement me + return 0; + } + + public static int Parse (string s, NumberStyles style, IFormatProvider fp) + { + // TODO: Implement me + return 0; + } + + public override string ToString () + { + // TODO: Implement me + + return ""; + } + + public string ToString (IFormatProvider fp) + { + // TODO: Implement me. + return ""; + } + + public string ToString (string format) + { + // TODO: Implement me. + return ""; + } + + public string ToString (string format, IFormatProvider fp) + { + // TODO: Implement me. + return ""; + } + } +} diff --git a/mcs/class/corlib/System/Int64.cs b/mcs/class/corlib/System/Int64.cs new file mode 100644 index 00000000000..4744b6d0817 --- /dev/null +++ b/mcs/class/corlib/System/Int64.cs @@ -0,0 +1,95 @@ +// +// System.Int64.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +using System.Globalization; + +namespace System { + + public struct Int64 : IComparable, IFormattable { + public const long MinValue = -9223372036854775808; + public const long MaxValue = 0x7fffffffffffffff; + + public long value; + + public int CompareTo (object v) + { + if (!(v is System.Int64)) + throw new ArgumentException ("Value is not a System.Int64"); + + if (value == (long) v) + return 0; + + if (value < (long) v) + return -1; + + return 1; + } + + public override bool Equals (object o) + { + if (!(o is System.Int64)) + return false; + + return ((long) o) == value; + } + + public override int GetHashCode () + { + return (int)(value & 0xffffffff) ^ (int)(value >> 32); + } + + public TypeCode GetTypeCode () + { + return TypeCode.Int64; + } + + public static long Parse (string s) + { + // TODO: Implement me + return 0; + } + + public static long Parse (string s, IFormatProvider fp) + { + // TODO: Implement me + return 0; + } + + public static long Parse (string s, NumberStyles style, IFormatProvider fp) + { + // TODO: Implement me + return 0; + } + + public override string ToString () + { + // TODO: Implement me + + return ""; + } + + public string ToString (IFormatProvider fp) + { + // TODO: Implement me. + return ""; + } + + public string ToString (string format) + { + // TODO: Implement me. + return ""; + } + + public string ToString (string format, IFormatProvider fp) + { + // TODO: Implement me. + return ""; + } + } +} diff --git a/mcs/class/corlib/System/InvalidCastException.cs b/mcs/class/corlib/System/InvalidCastException.cs new file mode 100644 index 00000000000..23989794e71 --- /dev/null +++ b/mcs/class/corlib/System/InvalidCastException.cs @@ -0,0 +1,29 @@ +// +// System.InvalidCastException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class InvalidCastException : SystemException { + // Constructors + public InvalidCastException () + : base ("Cannot cast from source type to destination type") + { + } + + public InvalidCastException (string message) + : base (message) + { + } + + public InvalidCastException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/InvalidOperationException.cs b/mcs/class/corlib/System/InvalidOperationException.cs new file mode 100644 index 00000000000..c57029a110b --- /dev/null +++ b/mcs/class/corlib/System/InvalidOperationException.cs @@ -0,0 +1,29 @@ +// +// System.InvalidOperationException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class InvalidOperationException : SystemException { + // Constructors + public InvalidOperationException () + : base ("The requested operation cannot be performed") + { + } + + public InvalidOperationException (string message) + : base (message) + { + } + + public InvalidOperationException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/InvalidProgramException.cs b/mcs/class/corlib/System/InvalidProgramException.cs new file mode 100644 index 00000000000..88150558cc5 --- /dev/null +++ b/mcs/class/corlib/System/InvalidProgramException.cs @@ -0,0 +1,29 @@ +// +// System.InvalidProgramException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public sealed class InvalidProgramException : SystemException { + // Constructors + public InvalidProgramException () + : base ("Metadata is incorrect") + { + } + + public InvalidProgramException (string message) + : base (message) + { + } + + public InvalidProgramException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/MulticastNotSupportedException.cs b/mcs/class/corlib/System/MulticastNotSupportedException.cs new file mode 100644 index 00000000000..02d2a7900c6 --- /dev/null +++ b/mcs/class/corlib/System/MulticastNotSupportedException.cs @@ -0,0 +1,29 @@ +// +// System.MulticastNotSupportedException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public sealed class MulticastNotSupportedException : SystemException { + // Constructors + public MulticastNotSupportedException () + : base ("This operation cannot be performed with the specified delagates") + { + } + + public MulticastNotSupportedException (string message) + : base (message) + { + } + + public MulticastNotSupportedException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/NotFiniteNumberException.cs b/mcs/class/corlib/System/NotFiniteNumberException.cs new file mode 100644 index 00000000000..f460a356033 --- /dev/null +++ b/mcs/class/corlib/System/NotFiniteNumberException.cs @@ -0,0 +1,49 @@ +// +// System.NotFiniteNumberException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class NotFiniteNumberException : ArithmeticException { + double offending_number; + + // Constructors + public NotFiniteNumberException () + : base ("The number encountered was not a finite quantity") + { + } + + public NotFiniteNumberException (double offending_number) + { + this.offending_number = offending_number; + } + + public NotFiniteNumberException (string message) + : base (message) + { + } + + public NotFiniteNumberException (string message, double offending_number) + { + this.offending_number = offending_number; + } + + public NotFiniteNumberException (string message, double offending_number, Exception inner) + : base (message, inner) + { + this.offending_number = offending_number; + } + + // Properties + public virtual double OffendingNumber { + get { + return offending_number; + } + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/NotSupportedException.cs b/mcs/class/corlib/System/NotSupportedException.cs new file mode 100644 index 00000000000..8a6078a9396 --- /dev/null +++ b/mcs/class/corlib/System/NotSupportedException.cs @@ -0,0 +1,29 @@ +// +// System.NotSupportedException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class NotSupportedException : SystemException { + // Constructors + public NotSupportedException () + : base ("Operation is not supported") + { + } + + public NotSupportedException (string message) + : base (message) + { + } + + public NotSupportedException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/NullReferenceException.cs b/mcs/class/corlib/System/NullReferenceException.cs new file mode 100644 index 00000000000..5f712bbb09d --- /dev/null +++ b/mcs/class/corlib/System/NullReferenceException.cs @@ -0,0 +1,29 @@ +// +// System.NullReferenceException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class NullReferenceException : SystemException { + // Constructors + public NullReferenceException () + : base ("A null value was found where an object instance was required") + { + } + + public NullReferenceException (string message) + : base (message) + { + } + + public NullReferenceException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/Object.cs b/mcs/class/corlib/System/Object.cs new file mode 100644 index 00000000000..375a6ccf09a --- /dev/null +++ b/mcs/class/corlib/System/Object.cs @@ -0,0 +1,111 @@ +// +// System.Object.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// +// This should probably be implemented in IL instead of C#, to +// use internalcalls to get its hands on the underlying Type +// of an object. +// + +namespace System { + + public class Object { + + // <summary> + // Compares this object to the specified object. + // Returns true if they are equal, false otherwise. + // </summary> + public virtual bool Equals (object o) + { + return this == o; + } + + // <summary> + // Compares two objects for equality + // </summary> + public static bool Equals (object a, object b) + { + if (a == null) { + if (b == null) + return true; + return false; + } else { + if (b == null) + return false; + return a.Equals (b); + } + } + + // <summary> + // Initializes a new instance of the object class. + // </summary> + public Object () + { + } + + // <summary> + // Object destructor. + // </summary> + ~Object () + { + } + + // <summary> + // Returns a hashcode for this object. Each derived + // class should return a hash code that makes sense + // for that particular implementation of the object. + // </summary> + public virtual int GetHashCode () + { + return 0; + } + + // <summary> + // Returns the Type associated with the object. + // </summary> + public Type GetType () + { + // TODO: This probably needs to be tied up + // with the Type system. Private communications + // channel? + // Type is abstract, so the following line won't cut it. + //return new Type (); + return null; + } + + // <summary> + // Shallow copy of the object. + // </summary> + protected object MemberWiseClone () + { + return null; + } + + // <summary> + // Returns a stringified representation of the object. + // This is not supposed to be used for user presentation, + // use Format() for that and IFormattable. + // + // ToString is mostly used for debugging purposes. + // </summary> + public virtual string ToString () + { + return GetType().FullName; + } + + // <summary> + // Tests whether a is equal to b. + // Can not figure out why this even exists + // </summary> + public static bool ReferenceEquals (object a, object b) + { + return (a == b); + } + + + } +} diff --git a/mcs/class/corlib/System/OutOfMemoryException.cs b/mcs/class/corlib/System/OutOfMemoryException.cs new file mode 100644 index 00000000000..597f68156c9 --- /dev/null +++ b/mcs/class/corlib/System/OutOfMemoryException.cs @@ -0,0 +1,29 @@ +// +// System.OutOfMemoryException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class OutOfMemoryException : SystemException { + // Constructors + public OutOfMemoryException () + : base ("There is insufficient memory to continue execution") + { + } + + public OutOfMemoryException (string message) + : base (message) + { + } + + public OutOfMemoryException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/OverflowException.cs b/mcs/class/corlib/System/OverflowException.cs new file mode 100644 index 00000000000..5bee3b461a5 --- /dev/null +++ b/mcs/class/corlib/System/OverflowException.cs @@ -0,0 +1,29 @@ +// +// System.OverflowExceptionException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class OverflowExceptionException : ArithmeticException { + // Constructors + public OverflowExceptionException () + : base ("Number overflow") + { + } + + public OverflowExceptionException (string message) + : base (message) + { + } + + public OverflowExceptionException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/RankException.cs b/mcs/class/corlib/System/RankException.cs new file mode 100644 index 00000000000..5eb3709d4ac --- /dev/null +++ b/mcs/class/corlib/System/RankException.cs @@ -0,0 +1,29 @@ +// +// System.RankException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class RankException : SystemException { + // Constructors + public RankException () + : base ("Two arrays must have the same number of dimensions") + { + } + + public RankException (string message) + : base (message) + { + } + + public RankException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/StackOverflowException.cs b/mcs/class/corlib/System/StackOverflowException.cs new file mode 100644 index 00000000000..f389346d6f8 --- /dev/null +++ b/mcs/class/corlib/System/StackOverflowException.cs @@ -0,0 +1,29 @@ +// +// System.StackOverflowException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class StackOverflowException : SystemException { + // Constructors + public StackOverflowException () + : base ("The requested operation caused a stack overflow") + { + } + + public StackOverflowException (string message) + : base (message) + { + } + + public StackOverflowException (string message, Exception inner) + : base (message, inner) + { + } + } +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/String.cs b/mcs/class/corlib/System/String.cs new file mode 100644 index 00000000000..1bb23294b98 --- /dev/null +++ b/mcs/class/corlib/System/String.cs @@ -0,0 +1,1628 @@ +// -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- +// +// System.String.cs +// +// Author: +// Jeffrey Stedfast (fejj@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +// FIXME: from what I gather from msdn, when a function is to return an empty string +// we should be returning this.Empty - some methods do this and others don't. + +// FIXME: I didn't realise until later that `string' has a .Length method and so +// I am missing some proper bounds-checking in some methods. Find these +// instances and throw the ArgumentOutOfBoundsException at the programmer. +// I like pelting programmers with ArgumentOutOfBoundsException's :-) + +// FIXME: The ToLower(), ToUpper(), and Compare(..., bool ignoreCase) methods +// need to be made unicode aware. + +// FIXME: when you have a char carr[], does carr.Length include the terminating null char? + +using System; +using System.Text; +using System.Collections; +using System.Globalization; + +namespace System { + + public sealed class String : IComparable, ICloneable, IConvertible, IEnumerable { + public static readonly string Empty = ""; + private char[] c_str; + private int length; + + // Constructors + unsafe public String (char *value) + { + int i; + + // FIXME: can I do value.Length here? + if (value == null) { + this.length = 0; + } else { + for (i = 0; *(value + i) != '\0'; i++); + this.length = i; + } + + this.c_str = new char [this.length + 1]; + for (i = 0; i < this.length; i++) + this.c_str[i] = *(value + i); + this.c_str[i] = '\0'; + } + + public String (char[] value) + { + int i; + + // FIXME: value.Length includes the terminating null char? + this.length = value != null ? strlen (value): 0; + this.c_str = new char [this.length + 1]; + for (i = 0; i < this.length; i++) + this.c_str[i] = value[i]; + this.c_str[i] = '\0'; + } + + unsafe public String (sbyte *value) + { + // FIXME: consider unicode? + int i; + + // FIXME: can I do value.Length here? */ + if (value == null) { + this.length = 0; + } else { + for (i = 0; *(value + i) != '\0'; i++); + this.length = i; + } + + this.c_str = new char [this.length + 1]; + for (i = 0; i < this.length; i++) + this.c_str[i] = (char) *(value + i); + this.c_str[i] = '\0'; + } + + public String (char c, int count) + { + int i; + + this.length = count; + this.c_str = new char [count + 1]; + for (i = 0; i < count; i++) + this.c_str[i] = c; + this.c_str[i] = '\0'; + } + + unsafe public String (char *value, int startIndex, int length) + { + int i; + + if (value == null && startIndex != 0 && length != 0) + throw new ArgumentNullException (); + + if (startIndex < 0 || length < 0) + throw new ArgumentOutOfRangeException (); + + this.length = length; + this.c_str = new char [length + 1]; + for (i = 0; i < length; i++) + this.c_str[i] = *(value + startIndex + i); + this.c_str[i] = '\0'; + } + + public String (char[] value, int startIndex, int length) + { + int i; + + if (value == null && startIndex != 0 && length != 0) + throw new ArgumentNullException (); + + if (startIndex < 0 || length < 0) + throw new ArgumentOutOfRangeException (); + + this.length = length; + this.c_str = new char [length + 1]; + for (i = 0; i < length; i++) + this.c_str[i] = value[startIndex + i]; + this.c_str[i] = '\0'; + } + + unsafe public String (sbyte *value, int startIndex, int length) + { + // FIXME: consider unicode? + int i; + + if (value == null && startIndex != 0 && length != 0) + throw new ArgumentNullException (); + + if (startIndex < 0 || length < 0) + throw new ArgumentOutOfRangeException (); + + this.length = length; + this.c_str = new char [length + 1]; + for (i = 0; i < length; i++) + this.c_str[i] = (char) *(value + startIndex + i); + this.c_str[i] = '\0'; + } + + unsafe public String (sbyte *value, int startIndex, int length, Encoding enc) + { + // FIXME: implement me + } + + ~String () + { + // FIXME: is there anything we need to do here? + /*base.Finalize ();*/ + } + + // Properties + public int Length { + get { + return this.length; + } + } + + // FIXME: is this correct syntax?? + public char this [int index] { + get { + if (index > this.length) + throw new ArgumentOutOfRangeException (); + + return this.c_str[index]; + } + } + + // Private helper methods + private static int strlen (char[] str) + { + // FIXME: if str.Length includes terminating null char, then return (str.Length - 1) + return str.Length; + } + + private static char tolower (char c) + { + // FIXME: make me unicode aware + return c >= 'A' && c <= 'Z' ? c + (char) 33 : c; + } + + private static char toupper (char c) + { + // FIXME: make me unicode aware + return c >= 'a' && c <= 'z' ? c - (char) 33 : c; + } + + private static char tolowerordinal (char c) + { + // FIXME: implement me + return c; + } + + private static bool is_lwsp (char c) + { + /* this comes from the msdn docs for String.Trim() */ + if ((c >= '\x9' && c <= '\xD') || c == '\x20' || c == '\xA0' || + (c >= '\x2000' && c <= '\x200B') || c == '\x3000' || c == '\xFEFF') + return true; + else + return false; + } + + unsafe private static int BoyerMoore (char[] haystack, char[] needle, int startIndex, int count) + { + /* (hopefully) Unicode-safe Boyer-Moore implementation */ + char[] skiptable = new char[65536]; /* our unicode-safe skip-table */ + char *he_ptr; + char *ne_ptr; /* end-of-string pointers */ + char *hc_ptr; + char *nc_ptr; /* compare pointers */ + char *h_ptr; + char *the_ptr; /* haystack pointers */ + uint h_len, n_len, n, i; + + if (haystack == null || needle == null) + throw new ArgumentNullException (); + + h_len = count; + n_len = strlen (needle); + + /* if the search buffer is shorter than the pattern buffer, we can't match */ + if (h_len < n_len) + return -1; + + /* return an instant match if the pattern is 0-length */ + if (n_len == 0) + return startIndex; + + /* set a pointer at the end of each string */ + ne_ptr = needle + nlen - 1; /* point to char before '\0' */ + he_ptr = haystack + startIndex + count; /* point to last valid char */ + + /* init the skip table with the pattern length */ + for (i = 0; i < 65536; i++) + skiptable[i] = n_len; + + /* set the skip value for the chars that *do* appear in the + * pattern buffer (needle) to the distance from the index to + * the end of the pattern buffer. */ + for (nc_ptr = needle; nc_ptr < ne_ptr; nc_ptr++) + skiptable[*nc_ptr] = ne_ptr - nc_ptr; + + h_ptr = haystack + startIndex; + while (h_len >= n_len) { + the_ptr = h_ptr + n_len - 1; /* set the temp haystack end pointer */ + hc_ptr = h_ptr + n_len - 1; /* set the haystack compare pointer */ + nc_ptr = ne_ptr; /* set the needle compare pointer */ + + /* work our way backwards until they don't match */ + for (i = 0; nc_ptr > needle; nc_ptr--, hc_ptr--, i++) + if (*nc_ptr != *hc_ptr) + break; + + if (*nc_ptr != *hc_ptr) { + n = skiptable[*hc_ptr]; + if (n == 0) + n = n_len; + if (n == n_len && i > 0) + if (*ne_ptr == *needle) + n--; + h_ptr += n; + h_len -= n; + } else + return h_ptr - haystack; + } + + return -1; + } + + // Methods + public object Clone () + { + // FIXME: implement me + return null; + } + + public static int Compare (string strA, string strB) + { + int i; + + /* Does this remind anyone of the nautilus string.h wrappers? ;-) */ + if (strA == null) { + if (strB == null) + return 0; + else + return -1; + } else if (strB == null) + return 1; + + for (i = 0; strA[i] == strB[i] && strA[i] != '\0'; i++); + + return ((int) (strA[i] - strB[i])); + } + + public static int Compare (string strA, string strB, bool ignoreCase) + { + int i; + + if (!ignoreCase) + return Compare (strA, strB); + + /* + * And here I thought Eazel developers were on crack... + * if a string is null it should pelt the programmer with + * ArgumentNullExceptions, damnit! + */ + if (strA == null) { + if (strB == null) + return 0; + else + return -1; + } else if (strB == null) + return 1; + + for (i = 0; strA[i] != '\0' && strB[i] != '\0'; i++) { + if (tolower (strA[i]) != tolower (strB[i])) + break; + } + + return ((int) (strA[i] - strB[i])); + } + + public static int Compare (string strA, string strB, bool ignoreCase, CultureInfo culture) + { + // FIXME: implement me + return 0; + } + + public static int Compare (string strA, int indexA, string strB, int indexB, int length) + { + int i; + + if (length < 0 || indexA < 0 || indexB < 0) + throw new ArgumentOutOfRangeException (); + + if (indexA > strA.Length || indexB > strB.Length) + throw new ArgumentOutOfRangeException (); + + /* And again with the ("" > null) logic... lord have mercy! */ + if (strA == null) { + if (strB == null) + return 0; + else + return -1; + } else if (strB == null) + return 1; + + for (i = 0; i < length - 1; i++) { + if (strA[indexA + i] != strB[indexB + i]) + break; + } + + return ((int) (strA[indexA + i] - strB[indexB + i])); + } + + public static int Compare (string strA, int indexA, string strB, int indexB, + int length, bool ignoreCase) + { + int i; + + if (!ignoreCase) + return Compare (strA, indexA, strB, indexB, length); + + if (length < 0 || indexA < 0 || indexB < 0) + throw new ArgumentOutOfRangeException (); + + if (indexA > strA.Length || indexB > strB.Length) + throw new ArgumentOutOfRangeException (); + + /* When will the hurting stop!?!? */ + if (strA == null) { + if (strB == null) + return 0; + else + return -1; + } else if (strB == null) + return 1; + + for (i = 0; i < length - 1; i++) { + if (tolower (strA[indexA + i]) != tolower (strB[indexB + i])) + break; + } + + return ((int) (strA[indexA + i] - strB[indexB + i])); + } + + public static int Compare (string strA, int indexA, string strB, int indexB, + int length, bool ignoreCase, CultureInfo culture) + { + if (culture == null) + throw new ArgumentNullException (); + + if (length < 0 || indexA < 0 || indexB < 0) + throw new ArgumentOutOfRangeException (); + + if (indexA > strA.Length || indexB > strB.Length) + throw new ArgumentOutOfRangeException (); + + /* I can't take it anymore! */ + if (strA == null) { + if (strB == null) + return 0; + else + return -1; + } else if (strB == null) + return 1; + // FIXME: implement me + return 0; + } + + public static int CompareOrdinal (string strA, string strB) + { + int i; + + /* Please God, make it stop! */ + if (strA == null) { + if (strB == null) + return 0; + else + return -1; + } else if (strB == null) + return 1; + + for (i = 0; strA[i] != '\0'; i++) { + char cA, cB; + + cA = tolowerordinal (strA[i]); + cB = tolowerordinal (strB[i]); + + if (cA != cB) + break; + } + + return ((int) (strA[i] - strB[i])); + } + + public static int CompareOrdinal (string strA, int indexA, string strB, int indexB, + int length) + { + int i; + + if (length < 0 || indexA < 0 || indexB < 0) + throw new ArgumentOutOfRangeException (); + + /* Nooooooooo!! */ + if (strA == null) { + if (strB == null) + return 0; + else + return -1; + } else if (strB == null) + return 1; + + for (i = 0; i < length; i++) { + char cA, cB; + + cA = tolowerordinal (strA[indexA + i]); + cB = tolowerordinal (strB[indexB + i]); + + if (cA != cB) + break; + } + + return ((int) (strA[indexA + i] - strB[indexB + i])); + } + + public int CompareTo (object obj) + { + return Compare (this, obj == null ? null : obj.ToString ()); + } + + public int CompareTo (string str) + { + return Compare (this, str); + } + + public static string Concat (object arg) + { + return Concat (this, arg ? arg.ToString () : String.Empty); + } + + public static string Concat (params object[] args) + { + string[] strings; + string str; + int len, i; + + if (args == null) + throw new ArgumentNullException (); + + strings = new string [args.Length]; + len = 0; + foreach (object arg in args) { + /* use Empty for each null argument */ + if (arg == null) + strings[i] = String.Empty; + else + strings[i] = arg.ToString (); + len += strings[i].Length; + } + + if (len == 0) + return String.Empty; + + str = new string [len + 1]; + i = 0; + for (int j = 0; j < strings.Length; j++) + for (int k = 0; k < strings[j].Length; k++) + str[i++] = strings[j][k]; + str[i] = '\0'; + + return str; + } + + public static string Concat (params string[] values) + { + int len, i; + string str; + + if (values == null) + throw new ArgumentNullException (); + + len = 0; + foreach (string value in values) + len += value ? value.Length : 0; + + if (len == 0) + return String.Empty; + + str = new string [len + 1]; + i = 0; + foreach (string value in values) { + if (value == null) + continue; + + for (int j = 0; j < value.Length; j++) + str[i++] = value[j]; + } + str[i] = '\0'; + + return str; + } + + public static string Concat (object arg0, object arg1) + { + string str0 = arg0 ? arg0.ToString () : String.Empty; + string str1 = arg1 ? arg1.ToString () : String.Empty; + + return Concat (str0, str1); + } + + public static string Concat (string str0, string str1) + { + string concat; + int i, j, len; + + if (str0 == null) + str0 = String.Empty; + if (str1 == null) + str1 == String.Empty; + + len = str0.Length + str1.Length; + if (len == 0) + return String.Empty; + + concat = new string [len + 1]; + for (i = 0; i < str0.Length; i++) + concat[i] = str0[i]; + for (j = 0 ; j < str1.Length; j++) + concat[i + j] = str1[j]; + concat[len] = '\0'; + + return concat; + } + + public static string Concat (object arg0, object arg1, object arg2) + { + string str0 = arg0 ? arg0.ToString () : String.Empty; + string str1 = arg1 ? arg1.ToString () : String.Empty; + string str2 = arg2 ? arg2.ToString () : String.Empty; + + return Concat (str0, str1, str2); + } + + public static string Concat (string str0, string str1, string str2) + { + string concat; + int i, j, k, len; + + if (str0 == null) + str0 = String.Empty; + if (str1 == null) + str1 = String.Empty; + if (str2 == null) + str2 = String.Empty; + + len = str0.Length + str1.Length + str2.Length; + if (len == 0) + return String.Empty; + + concat = new string [len + 1]; + for (i = 0; i < str0.Length; i++) + concat[i] = str0[i]; + for (j = 0; j < str1.Length; j++) + concat[i + j] = str1[j]; + for (k = 0; k < str2.Length; k++) + concat[i + j + k] = str2[k]; + concat[len] = '\0'; + + return concat; + } + + public static string Concat (string str0, string str1, string str2, string str3) + { + string concat; + int i, j, k, l, len; + + if (str0 == null) + str0 = String.Empty; + if (str1 == null) + str1 = String.Empty; + if (str2 == null) + str2 = String.Empty; + if (str3 == null) + str3 = String.Empty; + + len = str0.Length + str1.Length + str2.Length + str3.Length; + if (len == 0) + return String.Empty; + + concat = new string [len + 1]; + for (i = 0; i < str0.Length; i++) + concat[i] = str0[i]; + for (j = 0; j < str1.Length; j++) + concat[i + j] = str1[j]; + for (k = 0; k < str2.Length; k++) + concat[i + j + k] = str2[k]; + for (l = 0; l < str3.Length; l++) + concat[i + j + k + l] = str3[l]; + concat[len] = '\0'; + + return concat; + } + + public static string Copy (string str) + { + if (str == null) + throw new ArgumentNullException (); + + return new String (str); + } + + public void CopyTo (int sourceIndex, char[] destination, int destinationIndex, int count) + { + // LAMESPEC: should I null-terminate? + int i; + + if (destination == null) + throw new ArgumentNullException (); + + if (sourceIndex < 0 || destinationIndex < 0 || count < 0) + throw new ArgumentOutOfRangeException (); + + if (sourceIndex + count > this.length) + throw new ArgumentOutOfRangeException (); + + if (destinationIndex + count > destination.Length) + throw new ArgumentOutOfRangeException (); + + for (i = 0; i < count; i++) + destination[destinationIndex + i] = this.c_str[sourceIndex + i]; + } + + public bool EndsWith (string value) + { + bool endswith = true; + int start, i; + + if (value == null) + throw new ArgumentNullException (); + + start = this.length - value.Length; + if (start < 0) + return false; + + for (i = start; i < this.length && endswith; i++) + endswith = this.c_str[i] == value[i - start]; + + return endswith; + } + + public override bool Equals (object obj) + { + if (!(obj is String)) + return false; + + return this == (String) obj; + } + + public bool Equals (string value) + { + return this == value; + } + + public static bool Equals (string a, string b) + { + return a == b; + } + + public static string Format (string format, object arg0) + { + // FIXME: implement me + return null; + } + + public static string Format (string format, params object[] args) + { + // FIXME: implement me + return null; + } + + public static string Format (IFormatProvider provider, string format, params object[] args) + { + // FIXME: implement me + return null; + } + + public static string Format (string format, object arg0, object arg1) + { + // FIXME: implement me + return null; + } + + public static string Format (string format, object arg0, object arg1, object arg2) + { + // FIXME: implement me + return null; + } + + //public CharEnumerator GetEnumerator () + public IEnumerator GetEnumerator () + { + // FIXME: implement me + return null; + } + + public override int GetHashCode () + { + // FIXME: implement me + return 0; + } + + public new Type GetType () + { + // FIXME: implement me + return null; + } + + public TypeCode GetTypeCode () + { + // FIXME: implement me + return null; + } + + public int IndexOf (char value) + { + return IndexOf (value, 0, this.length); + } + + public int IndexOf (string value) + { + return IndexOf (value, 0, this.length); + } + + public int IndexOf (char value, int startIndex) + { + return IndexOf (value, startIndex, this.length - startIndex); + } + + public int IndexOf (string value, int startIndex) + { + return IndexOf (value, startIndex, this.length - startIndex); + } + + public int IndexOf (char value, int startIndex, int count) + { + int i; + + if (startIndex < 0 || count < 0 || startIndex + count > this.length) + throw new ArgumentOutOfRangeException (); + + for (i = startIndex; i - startIndex < count; i++) + if (this.c_str[i] == value) + return i; + + return -1; + } + + public int IndexOf (string value, int startIndex, int count) + { + // FIXME: Use a modified Boyer-Moore algorithm to work with unicode? + int i; + + if (value == null) + throw new ArgumentNullException (); + + if (startIndex < 0 || count < 0 || startIndex + count > this.length) + throw new ArgumentOutOfRangeException (); + + for (i = startIndex; i - startIndex < count; i++) { + if (this.c_str[i] == value[0]) { + bool equal = true; + int j, offset; + + offset = i - startIndex; + for (j = 1; equal && value[j] != '\0' && offset + j < count; j++) + equal = this.c_str[i + j] == value[j]; + + if (equal) + return i; + } + } + + return -1; + } + + public int IndexOfAny (char[] values) + { + return IndexOfAny (values, 0, this.length); + } + + public int IndexOfAny (char[] values, int startIndex) + { + return IndexOfAny (values, startIndex, this.length - startIndex); + } + + public int IndexOfAny (char[] values, int startIndex, int count) + { + if (values == null) + throw new ArgumentNullException (); + + if (startIndex < 0 || count < 0 || startIndex + count > this.length) + throw new ArgumentOutOfRangeException (); + + for (int i = startIndex; i < startIndex + count; i++) { + for (int j = 0; j < strlen (values); j++) { + if (this.c_str[i] == values[j]) + return i; + } + } + + return -1; + } + + public string Insert (int startIndex, string value) + { + string str; + int i, j; + + if (value == null) + throw new ArgumentNullException (); + + if (startIndex < 0 || startIndex > this.length) + throw new ArgumentOutOfRangeException (); + + str = new string [value.Length + this.length + 1]; + for (i = 0; i < startIndex; i++) + str[i] = this.c_str[i]; + for (j = 0; j < value.Length; j++) + str[i + j] = value[j]; + for ( ; i < this.length; i++) + str[i + j] = this.c_str[i]; + str[i + j] = '\0'; + + return str; + } + + public static string Intern (string str) + { + if (str == null) + throw new ArgumentNullException (); + // FIXME: implement me + return null; + } + + public static string IsInterned (string str) + { + if (str == null) + throw new ArgumentNullException (); + // FIXME: implement me + return null; + } + + public static string Join (string separator, string[] value) + { + return Join (separator, value, 0, value.Length); + } + + public static string Join (string separator, string[] value, int startIndex, int count) + { + // LAMESPEC: msdn doesn't specify what happens when separator is null + int len, i, j, used; + string str; + + if (separator == null || value == null) + throw new ArgumentNullException (); + + if (startIndex + count > value.Length) + throw new ArgumentOutOfRangeException (); + + len = 0; + for (i = startIndex, used = 0; used < count; i++, used++) { + if (i != startIndex) + len += separator.Length; + + len += value[i].Length; + } + + // We have no elements to join? + if (i == startIndex) + return String.Empty; + + str = new string [len + 1]; + for (i = 0; i < value[startIndex].Length; i++) + str[i] = value[startIndex][i]; + + used = 1; + for (j = startIndex + 1; used < count; j++, used++) { + int k; + + for (k = 0; k < separator.Length; k++) + str[i++] = separator[k]; + for (k = 0; k < value[j].Length; k++) + str[i++] = value[j][k]; + } + str[i] = '\0'; + + return str; + } + + public int LastIndexOf (char value) + { + for (int i = this.length; i >= 0; i--) { + if (this.c_str[i] == value) + return i; + } + + return -1; + } + + public int LastIndexOf (string value) + { + return LastIndexOf (value, this.length, this.length); + } + + public int LastIndexOf (char value, int startIndex) + { + if (startIndex < 0 || startIndex > this.length) + throw new ArgumentOutOfRangeException (); + + for (int i = startIndex; i >= 0; i--) { + if (this.c_str[i] == value) + return i; + } + + return -1; + } + + public int LastIndexOf (string value, int startIndex) + { + return LastIndexOf (value, startIndex, this.length); + } + + public int LastIndexOf (char value, int startIndex, int count) + { + if (startIndex < 0 || count < 0) + throw new ArgumentOutOfRangeException (); + + if (startIndex > this.length || startIndex - count < 0) + throw new ArgumentOutOfRangeException (); + + for (int i = startIndex; i >= startIndex - count; i--) { + if (this.c_str[i] == value) + return i; + } + + return -1; + } + + public int LastIndexOf (string value, int startIndex, int count) + { + // LAMESPEC: currently I'm using startIndex as the 0-position in the comparison, + // but maybe it's the end-position in MS's implementation? + // msdn is unclear on this point. I think this is correct though. + int i, len; + + if (value == null) + throw new ArgumentNullException (); + + if (startIndex < 0 || startIndex > this.length) + throw new ArgumentOutOfRangeException (); + + if (count < 0 || startIndex - count < 0) + throw new ArgumentOutOfRangeException (); + + if (value == String.Empty) + return startIndex; + + if (startIndex + value.Length > this.length) { + /* just a little optimization */ + int start; + + start = this.length - value.Length; + count -= startIndex - start; + startIndex = start; + } + + // FIXME: use a reversed-unicode-safe-Boyer-Moore? + len = value.Length; + for (i = startIndex; i >= startIndex - count; i--) { + if (this.c_str[i + len] == value[len]) { + bool equal = true; + int j; + + for (j = len - 1; equal && j >= 0; j--) + equal = this.c_str[i + j] == value[j]; + + if (equal) + return i; + } + } + + return -1; + } + + public int LastIndexOfAny (char[] values) + { + return LastIndexOfAny (values, this.length, this.length); + } + + public int LastIndexOfAny (char[] values, int startIndex) + { + return LastIndexOfAny (values, startIndex, startIndex); + } + + public int LastIndexOfAny (char[] values, int startIndex, int count) + { + int i; + + if (values == null) + throw new ArgumentNullException (); + + if (startIndex < 0 || count < 0 || startIndex - count < 0) + throw new ArgumentOutOfRangeException (); + + for (i = startIndex; i >= startIndex - count; i--) { + for (int j = 0; j < strlen (values); j++) { + if (this.c_str[i] == values[j]) + return i; + } + } + + return -1; + } + + public string PadLeft (int totalWidth) + { + return PadLeft (totalWidth, ' '); + } + + public string PadLeft (int totalWidth, char padChar) + { + string str; + int i, j; + + if (totalWidth < 0) + throw new ArgumentException (); + + str = new string [totalWidth > this.length ? totalWidth : this.length + 1]; + for (i = 0; i < totalWidth - this.length; i++) + str[i] = padChar; + + for (j = 0; j < this.length; i++, j++) + str[i] = this.c_str[j]; + + str[i] = '\0'; + + return str; + } + + public string PadRight (int totalWidth) + { + return PadRight (totalWidth, ' '); + } + + public string PadRight (int totalWidth, char padChar) + { + string str; + int i; + + if (totalWidth < 0) + throw new ArgumentException (); + + str = new string [totalWidth > this.length ? totalWidth : this.length + 1]; + for (i = 0; i < this.length; i++) + str[i] = this.c_str[i]; + + for ( ; j < str.Length; i++) + str[i] = padChar; + + str[i] = '\0'; + + return str; + } + + public string Remove (int startIndex, int count) + { + string str; + int i, j, len; + + if (startIndex < 0 || count < 0 || startIndex + count > this.length) + throw new ArgumentOutOfRangeException (); + + len = this.length - count; + if (len == 0) + return String.Empty; + + str = new string [len + 1]; + for (i = 0; i < startIndex; i++) + str[i] = this.c_str[i]; + for (j = i + count; j < this.length; j++) + str[i++] = this.c_str[j]; + str[i] = '\0'; + + return str; + } + + public string Replace (char oldChar, char newChar) + { + string str; + int i; + + str = new string [this.length + 1]; + for (i = 0; i < this.length; i++) { + if (this.c_str[i] == oldChar) + str[i] = newChar; + else + str[i] = this.c_str[i]; + } + str[i] = '\0'; + + return str; + } + + public string Replace (string oldValue, string newValue) + { + // LAMESPEC: msdn doesn't specify what to do if either args is null + int index, len, i, j; + string str; + + if (oldValue == null || newValue == null) + throw new ArgumentNullException (); + + // Use IndexOf in case I later rewrite it to use Boyer-Moore + index = IndexOf (oldValue, 0); + if (index == -1) { + // This is the easy one ;-) + return Substring (0, this.length); + } + + len = this.length - oldValue.Length + newValue.Length; + if (len == 0) + return String.Empty; + + str = new string [len + 1]; + for (i = 0; i < index; i++) + str[i] = this.c_str[i]; + for (j = 0; j < newValue.Length; j++) + str[i++] = newValue[j]; + for (j = index + oldValue.Length; j < this.length; j++) + str[i++] = this.c_str[j]; + str[i] = '\0'; + + return str; + } + + private int splitme (char[] separators, int startIndex) + { + /* this is basically a customized IndexOfAny() for the Split() methods */ + for (int i = startIndex; i < this.length; i++) { + if (separators != null) { + foreach (char sep in separators) { + if (this.c_str[i] == sep) + return i - startIndex; + } + } else if (is_lwsp (this.c_str[i])) { + return i - startIndex; + } + } + + return -1; + } + + public string[] Split (params char[] separator) + { + /** + * split: + * @separator: delimiting chars or null to split on whtspc + * + * Returns: 1. An array consisting of a single + * element (@this) if none of the delimiting + * chars appear in @this. 2. An array of + * substrings which are delimited by one of + * the separator chars. 3. An array of + * substrings separated by whitespace if + * @separator is null. The Empty string should + * be returned wherever 2 delimiting chars are + * adjacent. + **/ + // FIXME: would using a Queue be better? + string[] strings; + ArrayList list; + int index, len; + + list = new ArrayList (); + for (index = 0, len = 0; index < this.length; index += len + 1) { + len = splitme (separator, index); + len = len > -1 ? len : this.length - index; + if (len == 0) { + list.Add (String.Empty); + } else { + string str; + int i; + + str = new string [len + 1]; + for (i = 0; i < len; i++) + str[i] = this.c_str[index + i]; + str[i] = '\0'; + + list.Add (str); + } + } + + strings = new string [list.Count]; + if (list.Count == 1) { + /* special case for an array holding @this */ + strings[0] = this; + } else { + for (index = 0; index < list.Count; index++) + strings[index] = (string) list[index]; + } + + return strings; + } + + public string[] Split (char[] separator, int maxCount) + { + // FIXME: what to do if maxCount <= 0? + // FIXME: would using Queue be better than ArrayList? + string[] strings; + ArrayList list; + int index, len, used; + + used = 0; + list = new ArrayList (); + for (index = 0, len = 0; index < this.length && used < maxCount; index += len + 1) { + len = splitme (separator, index); + len = len > -1 ? len : this.length - index; + if (len == 0) { + list.Add (String.Empty); + } else { + string str; + int i; + + str = new string [len + 1]; + for (i = 0; i < len; i++) + str[i] = this.c_str[index + i]; + str[i] = '\0'; + + list.Add (str); + } + used++; + } + + /* fit the remaining chunk of the @this into it's own element */ + if (index != this.length) { + string str; + int i; + + str = new string [this.length - index + 1]; + for (i = index; i < this.length; i++) + str[i - index] = this.c_str[i]; + str[i - index] = '\0'; + + list.Add (str); + } + + strings = new string [list.Count]; + if (list.Count == 1) { + /* special case for an array holding @this */ + strings[0] = this; + } else { + for (index = 0; index < list.Count; index++) + strings[index] = (string) list[index]; + } + + return strings; + } + + public bool StartsWith (string value) + { + bool startswith = true; + int i; + + if (value == null) + throw new ArgumentNullException (); + + if (value.Length > this.length) + return false; + + for (i = 0; i < value.Length && startswith; i++) + startswith = startswith && value[i] == this.c_str[i]; + + return startswith; + } + + public string Substring (int startIndex) + { + string str; + int i, len; + + if (startIndex < 0 || startIndex > this.length) + throw new ArgumentOutOfRangeException (); + + len = this.length - startIndex; + if (len == 0) + return String.Empty; + + str = new string [len + 1]; + for (i = startIndex; i < this.length; i++) + str[i - startIndex] = this.c_str[i]; + str[i] = '\0'; + + return str; + } + + public string Substring (int startIndex, int length) + { + string str; + int i; + + if (startIndex < 0 || length < 0 || startIndex + length > this.length) + throw new ArgumentOutOfRangeException (); + + if (length == 0) + return String.Empty; + + str = new string [length + 1]; + for (i = startIndex; i < startIndex + length; i++) + str[i - startIndex] = this.c_str[i]; + str[i] = '\0'; + + return str; + } + + public bool ToBoolean (IFormatProvider provider) + { + // FIXME: implement me + return false; + } + + public byte ToByte (IFormatProvider provider) + { + // FIXME: implement me + return '\0'; + } + + public char ToChar (IFormatProvider provider) + { + // FIXME: implement me + return '\0'; + } + + public char[] ToCharArray () + { + return ToCharArray (0, this.length); + } + + public char[] ToCharArray (int startIndex, int length) + { + char[] chars; + int i, j; + + if (startIndex < 0 || length < 0 || startIndex + length > this.length) + throw new ArgumentOutOfRangeException (); + + chars = new char [length + 1]; + for (i = startIndex, i < length; i++) + chars[i - startIndex] = this.c_str[i]; + + chars[length] = '\0'; + + return chars; + } + + public DateTime ToDateTime (IFormatProvider provider) + { + // FIXME: implement me + return null; + } + + public decimal ToDecimal (IFormatProvider provider) + { + // FIXME: implement me + return 0.0D; + } + + public double ToDouble (IFormatProvider provider) + { + // FIXME: implement me + return 0.0; + } + + public short ToInt16 (IFormatProvider provider) + { + // FIXME: implement me + return 0; + } + + public int ToInt32 (IFormatProvider provider) + { + // FIXME: implement me + return 0; + } + + public long ToInt64 (IFormatProvider provider) + { + // FIXME: implement me + return 0; + } + + public string ToLower () + { + string str; + int i; + + str = new string [this.length + 1]; + for (i = 0; i < this.length; i++) + str[i] = tolower (this.c_str[i]); + str[i] = '\0'; + + return str; + } + + public string ToLower (CultureInfo culture) + { + // FIXME: implement me + return null; + } + + public sbyte ToSByte (IFormatProvider provider) + { + // FIXME: implement me + return 0; + } + + public float ToSingle (IFormatProvider provider) + { + // FIXME: implement me + return 0.0F; + } + + public override string ToString () + { + return Substring (0, this.length); + } + + public string ToString (IFormatProvider format) + { + // FIXME: implement me + return null; + } + + public object ToType (Type conversionType, IFormatProvider provider) + { + // FIXME: implement me + return null; + } + + public ushort ToUInt16 (IFormatProvider provider) + { + // FIXME: implement me + return 0; + } + + public uint ToUInt32 (IFormatProvider provider) + { + // FIXME: implement me + return 0; + } + + public ulong ToUInt64 (IFormatProvider provider) + { + // FIXME: implement me + return 0; + } + + public string ToUpper () + { + string str; + int i; + + str = new string [this.length + 1]; + for (i = 0; i < this.length; i++) + str[i] = toupper (this.c_str[i]); + str[i] = '\0'; + + return str; + } + + public string ToUpper (CultureInfo culture) + { + // FIXME: implement me + return null; + } + + public string Trim () + { + return Trim (null); + } + + public string Trim (params char[] trimChars) + { + int begin, end; + bool matches; + + matches = true; + for (begin = 0; matches && begin < this.length; begin++) { + if (trimChars != null) { + matches = false; + foreach (char c in trimChars) + matches = this.c_str[begin] == c; + } else { + matches = is_lwsp (this.c_str[begin]); + } + } + + matches = true; + for (end = this.length; end > begin; end--) { + if (trimChars != null) { + matches = false; + foreach (char c in trimChars) + matches = this.c_str[end] == c; + } else { + matches = is_lwsp (this.c_str[end]); + } + } + + if (begin == end) + return String.Empty; + + return Substring (begin, end - begin); + } + + public string TrimEnd (params char[] trimChars) + { + bool matches = true; + int end; + + for (end = this.length; end > 0; end--) { + if (trimChars != null) { + matches = false; + foreach (char c in trimChars) + matches = this.c_str[end] == c; + } else { + matches = is_lwsp (this.c_str[end]); + } + } + + if (end == 0) + return String.Empty; + + return Substring (0, end); + } + + public string TrimStart (params char[] trimChars) + { + bool matches = true; + int begin; + + for (begin = 0; matches && begin < this.length; begin++) { + if (trimChars != null) { + matches = false; + foreach (char c in trimChars) + matches = this.c_str[begin] == c; + } else { + matches = is_lwsp (this.c_str[begin]); + } + } + + if (begin == this.length) + return String.Empty; + + return Substring (begin, this.length - begin); + } + + // Operators + public static bool operator ==(string a, string b) + { + return a == b; + } + + public static bool operator !=(string a, string b) + { + return a != b; + } + } + +} diff --git a/mcs/class/corlib/System/SystemException.cs b/mcs/class/corlib/System/SystemException.cs new file mode 100644 index 00000000000..79fa92ca2ec --- /dev/null +++ b/mcs/class/corlib/System/SystemException.cs @@ -0,0 +1,29 @@ +// +// System.SystemException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class SystemException : Exception { + // Constructors + public SystemException () + : base ("A system exception has occurred.") + { + } + + public SystemException (string message) + : base (message) + { + } + + public SystemException (string message, Exception inner) + : base (message, inner) + { + } + } +} diff --git a/mcs/class/corlib/System/TODO b/mcs/class/corlib/System/TODO new file mode 100644 index 00000000000..065809deedb --- /dev/null +++ b/mcs/class/corlib/System/TODO @@ -0,0 +1,22 @@ +System.Object: + Need a mechanism for getting an object underlying type. + +System.ValueType: + Need to lock memory and "scan" the actual contents to compute + hash code and do comparissions. Should be simple to do with + C#, the problem is figuring out the size of the object. + +System.String: + Need to implement the Format() and CompareOrdinal() methods + as we all implement all of the methods that take into account + CultureInfo or Encoding stuff. + +System.Array: + It's not possible to test to see if the whole thing works, as + GetValue() and SetValue() make calls into the runtime. However, + I've tried my implementations of things like BinarySearch() and + Sort() on the MS-provided System.Array and they seem to work fine. + According to the spec, System.Array implements the IList interface. + The spec doesn't have the methods for those interfaces, however, + the class doesn't (yet) implement that interface and those methods + are not (yet) written. diff --git a/mcs/class/corlib/System/TypeCode.cs b/mcs/class/corlib/System/TypeCode.cs new file mode 100644 index 00000000000..a11a1054022 --- /dev/null +++ b/mcs/class/corlib/System/TypeCode.cs @@ -0,0 +1,32 @@ +// +// System.TypeCode.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public enum TypeCode { + Empty = 0, + Object = 1, + DBNull = 2, + Boolean = 3, + Char = 4, + SByte = 5, + Byte = 6, + Int16 = 7, + UInt16 = 8, + Int32 = 9, + UInt32 = 10, + Int64 = 11, + UInt64 = 12, + Single = 13, + Double = 14, + Decimal = 15, + DateTime = 16, + String = 18, + } +} diff --git a/mcs/class/corlib/System/TypeInitializationException.cs b/mcs/class/corlib/System/TypeInitializationException.cs new file mode 100644 index 00000000000..2adbb2f89e6 --- /dev/null +++ b/mcs/class/corlib/System/TypeInitializationException.cs @@ -0,0 +1,30 @@ +// +// System.TypeInitializationException.cs +// +// Author: +// Joe Shaw (joe@ximian.com) +// +// (C) 2001 Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class TypeInitializationException : SystemException { + string type_name; + + // Constructors + public TypeInitializationException (string type_name, Exception inner) + : base ("An exception was thrown by the type initializer for " + type_name, inner) + { + this.type_name = type_name; + } + + // Properties + public string TypeName { + get { + return type_name; + } + } + } + +}
\ No newline at end of file diff --git a/mcs/class/corlib/System/UInt16.cs b/mcs/class/corlib/System/UInt16.cs new file mode 100644 index 00000000000..b8c025d1797 --- /dev/null +++ b/mcs/class/corlib/System/UInt16.cs @@ -0,0 +1,89 @@ +// +// System.UInt16.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +using System.Globalization; + +namespace System { + + public struct UInt16 : IComparable, IFormattable { + public const ushort MinValue = 0; + public const ushort MaxValue = 0xffff; + + public ushort value; + + public int CompareTo (object v) + { + if (!(v is System.UInt16)) + throw new ArgumentException ("Value is not a System.UInt16"); + + return value - ((ushort) v); + } + + public override bool Equals (object o) + { + if (!(o is System.UInt16)) + return false; + + return ((ushort) o) == value; + } + + public override int GetHashCode () + { + return value; + } + + public TypeCode GetTypeCode () + { + return TypeCode.UInt16; + } + + public static ushort Parse (string s) + { + // TODO: Implement me + return 0; + } + + public static ushort Parse (string s, IFormatProvider fp) + { + // TODO: Implement me + return 0; + } + + public static ushort Parse (string s, NumberStyles style, IFormatProvider fp) + { + // TODO: Implement me + return 0; + } + + public override string ToString () + { + // TODO: Implement me + + return ""; + } + + public string ToString (IFormatProvider fp) + { + // TODO: Implement me. + return ""; + } + + public string ToString (string format) + { + // TODO: Implement me. + return ""; + } + + public string ToString (string format, IFormatProvider fp) + { + // TODO: Implement me. + return ""; + } + } +} diff --git a/mcs/class/corlib/System/UInt32.cs b/mcs/class/corlib/System/UInt32.cs new file mode 100644 index 00000000000..c65744d9def --- /dev/null +++ b/mcs/class/corlib/System/UInt32.cs @@ -0,0 +1,95 @@ +// +// System.UInt32.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +using System.Globalization; + +namespace System { + + public struct UInt32 : IComparable, IFormattable { + public const uint MinValue = 0; + public const uint MaxValue = 0xffffffff; + + public uint value; + + public int CompareTo (object v) + { + if (!(v is System.UInt32)) + throw new ArgumentException ("Value is not a System.UInt32"); + + if (value == (uint) v) + return 0; + + if (value < (uint) v) + return -1; + + return 1; + } + + public override bool Equals (object o) + { + if (!(o is System.UInt32)) + return false; + + return ((uint) o) == value; + } + + public override int GetHashCode () + { + return (int) value; + } + + public TypeCode GetTypeCode () + { + return TypeCode.UInt32; + } + + public static uint Parse (string s) + { + // TODO: Implement me + return 0; + } + + public static uint Parse (string s, IFormatProvider fp) + { + // TODO: Implement me + return 0; + } + + public static uint Parse (string s, NumberStyles style, IFormatProvider fp) + { + // TODO: Implement me + return 0; + } + + public override string ToString () + { + // TODO: Implement me + + return ""; + } + + public string ToString (IFormatProvider fp) + { + // TODO: Implement me. + return ""; + } + + public string ToString (string format) + { + // TODO: Implement me. + return ""; + } + + public string ToString (string format, IFormatProvider fp) + { + // TODO: Implement me. + return ""; + } + } +} diff --git a/mcs/class/corlib/System/UInt64.cs b/mcs/class/corlib/System/UInt64.cs new file mode 100644 index 00000000000..1008bbe684d --- /dev/null +++ b/mcs/class/corlib/System/UInt64.cs @@ -0,0 +1,95 @@ +// +// System.UInt64.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +using System.Globalization; + +namespace System { + + public struct UInt64 : IComparable, IFormattable { + public const ulong MinValue = 0; + public const ulong MaxValue = 0xffffffffffffffff; + + public ulong value; + + public int CompareTo (object v) + { + if (!(v is System.UInt64)) + throw new ArgumentException ("Value is not a System.UInt64"); + + if (value == (ulong) v) + return 0; + + if (value < (ulong) v) + return -1; + + return 1; + } + + public override bool Equals (object o) + { + if (!(o is System.UInt64)) + return false; + + return ((ulong) o) == value; + } + + public override int GetHashCode () + { + return (int)(value & 0xffffffff) ^ (int)(value >> 32); + } + + public TypeCode GetTypeCode () + { + return TypeCode.UInt64; + } + + public static ulong Parse (string s) + { + // TODO: Implement me + return 0; + } + + public static ulong Parse (string s, IFormatProvider fp) + { + // TODO: Implement me + return 0; + } + + public static ulong Parse (string s, NumberStyles style, IFormatProvider fp) + { + // TODO: Implement me + return 0; + } + + public override string ToString () + { + // TODO: Implement me + + return ""; + } + + public string ToString (IFormatProvider fp) + { + // TODO: Implement me. + return ""; + } + + public string ToString (string format) + { + // TODO: Implement me. + return ""; + } + + public string ToString (string format, IFormatProvider fp) + { + // TODO: Implement me. + return ""; + } + } +} diff --git a/mcs/class/corlib/System/ValueType.cs b/mcs/class/corlib/System/ValueType.cs new file mode 100644 index 00000000000..1781418e2d5 --- /dev/null +++ b/mcs/class/corlib/System/ValueType.cs @@ -0,0 +1,66 @@ +// +// System.ValueType.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public abstract class ValueType { + + // <summary> + // ValueType constructor + // </summary> + protected ValueType () + { + } + + // <summary> + // True if this instance and o represent the same type + // and have the same value. + // </summary> + public override bool Equals (object o) + { + if (o == null){ + throw new ArgumentNullException ("Null argument to Equals"); + } + + if (o.GetType() != this.GetType()) + return false; + + // TODO: + // Now implement bit compare here. + + // TODO: Implement me! + return false; + } + + // <summary> + // Gets a hashcode for this value type using the + // bits in the structure + // </summary> + public override int GetHashCode () + { + if (this == null) + return 0; + + // TODO: compute a hashcode based on the actual + // contents. + + return 0; + } + + // <summary> + // Stringified representation of this ValueType. + // Must be overriden for better results, by default + // it just returns the Type name. + // </summary> + public override string ToString () + { + return GetType().FullName; + } + } +} diff --git a/mcs/class/corlib/System/Version.cs b/mcs/class/corlib/System/Version.cs new file mode 100644 index 00000000000..e3919fa682e --- /dev/null +++ b/mcs/class/corlib/System/Version.cs @@ -0,0 +1,200 @@ +// +// System.Version.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public class Version : ICloneable, IComparable { + int major, minor, build, revision; + + const int MAXINT = int.MaxValue; + + public Version (string version) + { + int n; + string [] vals = version.Split (new Char [] {'.'}); + + n = vals.Length; + if (n > 0) + major = int.Parse (vals [0]); + if (n > 1) + minor = int.Parse (vals [1]); + if (n > 2) + build = int.Parse (vals [2]); + if (n > 3) + build = int.Parse (vals [3]); + } + + public Version (int major, int minor) + { + this.major = major; + this.minor = minor; + this.build = MAXINT; + this.revision = MAXINT; + } + + public Version (int major, int minor, int build) + { + this.major = major; + this.minor = minor; + this.build = build; + this.revision = MAXINT; + } + + public Version (int major, int minor, int build, int revision) + { + this.major = major; + this.minor = minor; + this.build = build; + this.revision = revision; + } + + public int Build { + get { + return build; + } + } + + public int Major { + get { + return major; + } + } + + public int Minor { + get { + return minor; + } + } + + public int Revision { + get { + return revision; + } + } + + public object Clone () + { + return new Version (major, minor, build, revision); + } + + public int CompareTo (object version) + { + Version v; + + if (version == null) + throw new ArgumentNullException ("version"); + if (! (version is Version)) + throw new ArgumentException ("version"); + + v = version as Version; + + if (this.major > v.major) + return 1; + else if (this.major < v.major) + return -1; + + if (this.minor > v.minor) + return 1; + else if (this.minor < this.minor) + return -1; + + if (this.build > v.build) + return 1; + else if (this.build < this.build) + return -1; + + // FIXME: Compare revision or build first? + if (this.revision > v.revision) + return 1; + else if (this.revision < v.revision) + return -1; + + return 0; + } + + public override bool Equals (object obj) + { + Version x; + + if (obj == null) + throw new ArgumentNullException ("obj"); + if (!(obj is Version)) + return false; + + x = (Version) obj; + + if ((x.major == major) && + (x.minor == minor) && + (x.build == build) && + (x.revision == revision)) + return true; + return false; + } + + // <summary> + // This is sort of lame: the documentation claims that the + // return value is a 32-bit integer, but "int" can be 64 + // on Alphas for example. + // </summary> + public override int GetHashCode () + { + return (revision << 24) | (build << 16) | (minor << 8) | major; + } + + // <summary> + // Returns a stringified representation of the version, format: + // major.minor[.build[.revision]] + // </summary> + public override string ToString () + { + string mm = major.ToString () + "." + minor.ToString (); + + if (build != MAXINT) + mm = mm + "." + build.ToString (); + if (revision != MAXINT) + mm = mm + "." + revision.ToString (); + + return mm; + } + + // <summary> + // LAME: This API is lame, since there is no way of knowing + // how many fields a Version object has, it is unfair to throw + // an ArgumentException, but this is what the spec claims. + // + // ie, Version a = new Version (1, 2); a.ToString (3) should + // throw the expcetion. + // </summary> + public string ToString (int fields) + { + if (fields == 0) + return ""; + if (fields == 1) + return major.ToString (); + if (fields == 2) + return major.ToString () + "." + minor.ToString (); + if (fields == 3){ + if (build == MAXINT) + throw new ArgumentException ("fields is larger than the number of components defined in this instance"); + return major.ToString () + "." + minor.ToString () + "." + + build.ToString (); + } + if (fields == 4){ + if (build == MAXINT || revision == MAXINT) + throw new ArgumentException ("fields is larger than the number of components defined in this instance"); + return major.ToString () + "." + minor.ToString () + "." + + build.ToString () + "." + revision.ToString (); + } + throw new ArgumentException ("Invalid fields parameter: " + fields.ToString()); + } + } +} + + + diff --git a/mcs/class/corlib/System/Void.cs b/mcs/class/corlib/System/Void.cs new file mode 100644 index 00000000000..1ad4e1c5b2c --- /dev/null +++ b/mcs/class/corlib/System/Void.cs @@ -0,0 +1,14 @@ +// +// System.Void.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +namespace System { + + public struct Void { + } +} diff --git a/mcs/class/corlib/System/common.src b/mcs/class/corlib/System/common.src new file mode 100755 index 00000000000..44888aab810 --- /dev/null +++ b/mcs/class/corlib/System/common.src @@ -0,0 +1,44 @@ +ApplicationException.cs +ArgumentException.cs +ArgumentNullException.cs +ArgumentOutOfRangeException.cs +ArithmeticException.cs +Array.cs +ArrayTypeMismatchException.cs +DivideByZeroException.cs +DuplicateWaitObjectException.cs +Exception.cs +ExecutionEngineException.cs +FormatException.cs +ICloneable.cs +IComparable.cs +IConvertible.cs +ICustomFormatter.cs +IDisposable.cs +IFormatProvider.cs +IFormattable.cs +IndexOutOfRangeException.cs +Int16.cs +Int32.cs +Int64.cs +InvalidCastException.cs +InvalidOperationException.cs +InvalidProgramException.cs +MulticastNotSupportedException.cs +NotFiniteNumberException.cs +NotSupportedException.cs +NullReferenceException.cs +Object.cs +OutOfMemoryException.cs +OverflowException.cs +RankException.cs +StackOverflowException.cs +SystemException.cs +TypeCode.cs +TypeInitializationException.cs +UInt16.cs +UInt32.cs +UInt64.cs +ValueType.cs +Version.cs +Void.cs diff --git a/mcs/class/corlib/System/unix.src b/mcs/class/corlib/System/unix.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/corlib/System/unix.src diff --git a/mcs/class/corlib/System/windows.src b/mcs/class/corlib/System/windows.src new file mode 100755 index 00000000000..e69de29bb2d --- /dev/null +++ b/mcs/class/corlib/System/windows.src diff --git a/mcs/class/corlib/makefile b/mcs/class/corlib/makefile new file mode 100644 index 00000000000..04cc700c837 --- /dev/null +++ b/mcs/class/corlib/makefile @@ -0,0 +1,16 @@ +DIRS=System System.Collections System.Globalization System.Net System.Text + +all: + @echo "You must use 'make windows' or 'make unix'." + @echo "'make unix' is broken for now." + +windows: make-list + $(CSC) /unsafe /target:library /out:corlib.dll /nowarn:1595 @list + +unix: + @echo "'make unix' is broken for now." + +make-list: + for i in $(DIRS); do \ + cat $$i/common.src $$i/windows.src | sed "s/^/$$i\\\\/"; \ + done > list diff --git a/mcs/class/makefile b/mcs/class/makefile new file mode 100644 index 00000000000..441961d3b6f --- /dev/null +++ b/mcs/class/makefile @@ -0,0 +1,14 @@ +DIRS=corlib System +CSC=//c/winnt/microsoft.net/framework/v1.0.2914/csc.exe + +all: + @echo "You must use 'make windows' or 'make unix'." + @echo "'make unix' is broken for now." + +windows: + for i in $(DIRS); do \ + (cd $$i; CSC=$(CSC) NUNIT_CONSOLE=NUnitConsole.exe PLATFORM=window make windows)\ + done; + +unix: + @echo "'make unix' is broken for now." diff --git a/mcs/class/notes/BitVecto32.txt b/mcs/class/notes/BitVecto32.txt new file mode 100644 index 00000000000..fad747dfe76 --- /dev/null +++ b/mcs/class/notes/BitVecto32.txt @@ -0,0 +1,6 @@ +* Why does CreateSection take a short for the range number? + + It would seem like it should be possible to have numbers between 0 + and UInt32.MaxValue in there. Why is the API limiting things to 16 + bits? + diff --git a/mcs/jay/.cvsignore b/mcs/jay/.cvsignore new file mode 100755 index 00000000000..75b36e0911d --- /dev/null +++ b/mcs/jay/.cvsignore @@ -0,0 +1,2 @@ +jay +jay.exe diff --git a/mcs/jay/ACKNOWLEDGEMENTS b/mcs/jay/ACKNOWLEDGEMENTS new file mode 100644 index 00000000000..b66bb250645 --- /dev/null +++ b/mcs/jay/ACKNOWLEDGEMENTS @@ -0,0 +1,25 @@ + Berkeley Yacc owes much to the unflagging efforts of Keith Bostic. +His badgering kept me working on it long after I was ready to quit. + + Berkeley Yacc is based on the excellent algorithm for computing LALR(1) +lookaheads developed by Tom Pennello and Frank DeRemer. The algorithm is +described in their almost impenetrable article in TOPLAS 4,4. + + Finally, much of the credit for the latest version must go to those +who pointed out deficiencies of my earlier releases. Among the most +prolific contributors were + + Benson I. Margulies + Dave Gentzel + Antoine Verheijen + Peter S. Housel + Dale Smith + Ozan Yigit + John Campbell + Bill Sommerfeld + Paul Hilfinger + Gary Bridgewater + Dave Bakken + Dan Lanciani + Richard Sargent + Parag Patel diff --git a/mcs/jay/ChangeLog b/mcs/jay/ChangeLog new file mode 100755 index 00000000000..20b2931583a --- /dev/null +++ b/mcs/jay/ChangeLog @@ -0,0 +1,9 @@ +2001-07-15 Sean MacIsaac <macisaac@ximian.com> + + * makefile: added windows and unix targets. + +2001-07-14 Sean MacIsaac <macisaac@ximian.com> + + * main.c: fixed error in command line flag -c if it was not first + option. + diff --git a/mcs/jay/NEW_FEATURES b/mcs/jay/NEW_FEATURES new file mode 100644 index 00000000000..b030c625b00 --- /dev/null +++ b/mcs/jay/NEW_FEATURES @@ -0,0 +1,46 @@ + The -r option has been implemented. The -r option tells Yacc to +put the read-only tables in y.tab.c and the code and variables in +y.code.c. Keith Bostic asked for this option so that :yyfix could be +eliminated. + + The -l and -t options have been implemented. The -l option tells +Yacc not to include #line directives in the code it produces. The -t +option causes debugging code to be included in the compiled parser. + + The code for error recovery has been changed to implement the same +algorithm as AT&T Yacc. There will still be differences in the way +error recovery works because AT&T Yacc uses more default reductions +than Berkeley Yacc. + + The environment variable TMPDIR determines the directory where +temporary files will be created. If TMPDIR is defined, temporary files +will be created in the directory whose pathname is the value of TMPDIR. +By default, temporary files are created in /tmp. + + The keywords are now case-insensitive. For example, %nonassoc, +%NONASSOC, %NonAssoc, and %nOnAsSoC are all equivalent. + + Commas and semicolons that are not part of C code are treated as +commentary. + + Line-end comments, as in BCPL, are permitted. Line-end comments +begin with // and end at the next end-of-line. Line-end comments are +permitted in C code; they are converted to C comments on output. + + The form of y.output files has been changed to look more like +those produced by AT&T Yacc. + + A new kind of declaration has been added. The form of the declaration +is + + %ident string + +where string is a sequence of characters begining with a double quote +and ending with either a double quote or the next end-of-line, whichever +comes first. The declaration will cause a #ident directive to be written +near the start of the output file. + + If a parser has been compiled with debugging code, that code can be +enabled by setting an environment variable. If the environment variable +YYDEBUG is set to 0, debugging output is suppressed. If it is set to 1, +debugging output is written to standard output. diff --git a/mcs/jay/NOTES b/mcs/jay/NOTES new file mode 100644 index 00000000000..9db3c96ce1b --- /dev/null +++ b/mcs/jay/NOTES @@ -0,0 +1,9 @@ +Berkeley Yacc reflects its origins. The reason so many routines +use exactly six register variables is that Berkeley Yacc was +developed on a VAX using PCC. PCC placed at most six variables +in registers. I went to considerable effort to find which six +variables most belonged in registers. Changes in machines and +compilers make that effort worthless, perhaps even harmful. + +The code contains many instances where address calculations are +performed in particular ways to optimize the code for the VAX. diff --git a/mcs/jay/README b/mcs/jay/README new file mode 100644 index 00000000000..b261173398e --- /dev/null +++ b/mcs/jay/README @@ -0,0 +1,10 @@ +This is a port of Jay to C#, the original Jay can be found here: + http://www.informatik.uni-osnabrueck.de/bernd/jay/ + +This is a temporary solution as we move to a Bison-generated parser +as it would provide better error recovery (and error productions +are broken in my port of Jay). + +The original README from Jay is in `README.jay' + +Miguel diff --git a/mcs/jay/README.jay b/mcs/jay/README.jay new file mode 100644 index 00000000000..94b7b72e6e4 --- /dev/null +++ b/mcs/jay/README.jay @@ -0,0 +1,55 @@ + This version of Berkeley Yacc was taken from the BSD-Lite CD and targeted +to Java by + + axel.schreiner@informatik.uni-osnabrueck.de + +Makefile -> makefile removed Berkeleyisms, call it jay +defs.h eliminate -dlpr options, %union, output_file, #ident + eliminate sekeleton.c references +error.c eliminate %union +main.c eliminate -dlpr options, %union, output_file +output.c eliminate -dlpr options, %union, output_file + fix #define, short, -t/yyDebug + respell YYERRCODE, YYTABLESIZE, YYFINAL, YYMAXTOKEN + output trailer last + switch to filter behaviour +reader.c eliminate output_file, #ident + #line -> // line, pass // + yyvsp[] -> yyVals[yyTop], yyval -> yyVal +skeleton.c -> skeleton Java skeleton +test removed +yacc.1 -> jay.1 adapted +yyfix.* removed + +Types: there is a significant difference. yacc uses %union to cast the value +stack and <tag> to select alternatives. This works for l- and r-values alike. +jay uses Object as the value stack and <tag> to set a class. l-values must not +be cast. $n should not be assigned to, but $$ usually is. $n is referenced, +but $$ usually is not. Consequently jay casts $n and $<tag>$ but not $<>n +and $$. This makes assignment to $n references to $$ kludgily possible. +As another kludge, to prevent 'untyped' messages and to avoid unnecessary +casts, casts to "Object" are not emitted. +------------------------------------------------------------------------------- + Berkeley Yacc is an LALR(1) parser generator. Berkeley Yacc has been made +as compatible as possible with AT&T Yacc. Berkeley Yacc can accept any input +specification that conforms to the AT&T Yacc documentation. Specifications +that take advantage of undocumented features of AT&T Yacc will probably be +rejected. + + Berkeley Yacc is distributed with no warranty whatever. The code is certain +to contain errors. Neither the author nor any contributor takes responsibility +for any consequences of its use. + + Berkeley Yacc is in the public domain. The data structures and algorithms +used in Berkeley Yacc are all either taken from documents available to the +general public or are inventions of the author. Anyone may freely distribute +source or binary forms of Berkeley Yacc whether unchanged or modified. +Distributers may charge whatever fees they can obtain for Berkeley Yacc. +Programs generated by Berkeley Yacc may be distributed freely. + + Please report bugs to + + robert.corbett@eng.Sun.COM + +Include a small example if possible. Please include the banner string from +skeleton.c with the bug report. Do not expect rapid responses. diff --git a/mcs/jay/closure.c b/mcs/jay/closure.c new file mode 100644 index 00000000000..5f63c5f32cd --- /dev/null +++ b/mcs/jay/closure.c @@ -0,0 +1,295 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)closure.c 5.3 (Berkeley) 5/24/93"; +#endif /* not lint */ + +#include "defs.h" + +short *itemset; +short *itemsetend; +unsigned *ruleset; + +static unsigned *first_derives; +static unsigned *EFF; + + +set_EFF() +{ + register unsigned *row; + register int symbol; + register short *sp; + register int rowsize; + register int i; + register int rule; + + rowsize = WORDSIZE(nvars); + EFF = NEW2(nvars * rowsize, unsigned); + + row = EFF; + for (i = start_symbol; i < nsyms; i++) + { + sp = derives[i]; + for (rule = *sp; rule > 0; rule = *++sp) + { + symbol = ritem[rrhs[rule]]; + if (ISVAR(symbol)) + { + symbol -= start_symbol; + SETBIT(row, symbol); + } + } + row += rowsize; + } + + reflexive_transitive_closure(EFF, nvars); + +#ifdef DEBUG + print_EFF(); +#endif +} + + +set_first_derives() +{ + register unsigned *rrow; + register unsigned *vrow; + register int j; + register unsigned k; + register unsigned cword; + register short *rp; + + int rule; + int i; + int rulesetsize; + int varsetsize; + + rulesetsize = WORDSIZE(nrules); + varsetsize = WORDSIZE(nvars); + first_derives = NEW2(nvars * rulesetsize, unsigned) - ntokens * rulesetsize; + + set_EFF(); + + rrow = first_derives + ntokens * rulesetsize; + for (i = start_symbol; i < nsyms; i++) + { + vrow = EFF + ((i - ntokens) * varsetsize); + k = BITS_PER_WORD; + for (j = start_symbol; j < nsyms; k++, j++) + { + if (k >= BITS_PER_WORD) + { + cword = *vrow++; + k = 0; + } + + if (cword & (1 << k)) + { + rp = derives[j]; + while ((rule = *rp++) >= 0) + { + SETBIT(rrow, rule); + } + } + } + + vrow += varsetsize; + rrow += rulesetsize; + } + +#ifdef DEBUG + print_first_derives(); +#endif + + FREE(EFF); +} + + +closure(nucleus, n) +short *nucleus; +int n; +{ + register int ruleno; + register unsigned word; + register unsigned i; + register short *csp; + register unsigned *dsp; + register unsigned *rsp; + register int rulesetsize; + + short *csend; + unsigned *rsend; + int symbol; + int itemno; + + rulesetsize = WORDSIZE(nrules); + rsp = ruleset; + rsend = ruleset + rulesetsize; + for (rsp = ruleset; rsp < rsend; rsp++) + *rsp = 0; + + csend = nucleus + n; + for (csp = nucleus; csp < csend; ++csp) + { + symbol = ritem[*csp]; + if (ISVAR(symbol)) + { + dsp = first_derives + symbol * rulesetsize; + rsp = ruleset; + while (rsp < rsend) + *rsp++ |= *dsp++; + } + } + + ruleno = 0; + itemsetend = itemset; + csp = nucleus; + for (rsp = ruleset; rsp < rsend; ++rsp) + { + word = *rsp; + if (word) + { + for (i = 0; i < BITS_PER_WORD; ++i) + { + if (word & (1 << i)) + { + itemno = rrhs[ruleno+i]; + while (csp < csend && *csp < itemno) + *itemsetend++ = *csp++; + *itemsetend++ = itemno; + while (csp < csend && *csp == itemno) + ++csp; + } + } + } + ruleno += BITS_PER_WORD; + } + + while (csp < csend) + *itemsetend++ = *csp++; + +#ifdef DEBUG + print_closure(n); +#endif +} + + + +finalize_closure() +{ + FREE(itemset); + FREE(ruleset); + FREE(first_derives + ntokens * WORDSIZE(nrules)); +} + + +#ifdef DEBUG + +print_closure(n) +int n; +{ + register short *isp; + + printf("\n\nn = %d\n\n", n); + for (isp = itemset; isp < itemsetend; isp++) + printf(" %d\n", *isp); +} + + +print_EFF() +{ + register int i, j; + register unsigned *rowp; + register unsigned word; + register unsigned k; + + printf("\n\nEpsilon Free Firsts\n"); + + for (i = start_symbol; i < nsyms; i++) + { + printf("\n%s", symbol_name[i]); + rowp = EFF + ((i - start_symbol) * WORDSIZE(nvars)); + word = *rowp++; + + k = BITS_PER_WORD; + for (j = 0; j < nvars; k++, j++) + { + if (k >= BITS_PER_WORD) + { + word = *rowp++; + k = 0; + } + + if (word & (1 << k)) + printf(" %s", symbol_name[start_symbol + j]); + } + } +} + + +print_first_derives() +{ + register int i; + register int j; + register unsigned *rp; + register unsigned cword; + register unsigned k; + + printf("\n\n\nFirst Derives\n"); + + for (i = start_symbol; i < nsyms; i++) + { + printf("\n%s derives\n", symbol_name[i]); + rp = first_derives + i * WORDSIZE(nrules); + k = BITS_PER_WORD; + for (j = 0; j <= nrules; k++, j++) + { + if (k >= BITS_PER_WORD) + { + cword = *rp++; + k = 0; + } + + if (cword & (1 << k)) + printf(" %d\n", j); + } + } + + fflush(stdout); +} + +#endif diff --git a/mcs/jay/defs.h b/mcs/jay/defs.h new file mode 100644 index 00000000000..ac1d63f53a3 --- /dev/null +++ b/mcs/jay/defs.h @@ -0,0 +1,308 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)defs.h 5.6 (Berkeley) 5/24/93 + */ + +#include <assert.h> +#include <ctype.h> +#include <stdio.h> + + +/* machine-dependent definitions */ +/* the following definitions are for the Tahoe */ +/* they might have to be changed for other machines */ + +/* MAXCHAR is the largest unsigned character value */ +/* MAXSHORT is the largest value of a C short */ +/* MINSHORT is the most negative value of a C short */ +/* MAXTABLE is the maximum table size */ +/* BITS_PER_WORD is the number of bits in a C unsigned */ +/* WORDSIZE computes the number of words needed to */ +/* store n bits */ +/* BIT returns the value of the n-th bit starting */ +/* from r (0-indexed) */ +/* SETBIT sets the n-th bit starting from r */ + +#define MAXCHAR 255 +#define MAXSHORT 32767 +#define MINSHORT -32768 +#define MAXTABLE 32500 +#define BITS_PER_WORD 32 +#define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD) +#define BIT(r, n) ((((r)[(n)>>5])>>((n)&31))&1) +#define SETBIT(r, n) ((r)[(n)>>5]|=((unsigned)1<<((n)&31))) + + +/* character names */ + +#define NUL '\0' /* the null character */ +#define NEWLINE '\n' /* line feed */ +#define SP ' ' /* space */ +#define BS '\b' /* backspace */ +#define HT '\t' /* horizontal tab */ +#define VT '\013' /* vertical tab */ +#define CR '\r' /* carriage return */ +#define FF '\f' /* form feed */ +#define QUOTE '\'' /* single quote */ +#define DOUBLE_QUOTE '\"' /* double quote */ +#define BACKSLASH '\\' /* backslash */ + + +/* defines for constructing filenames */ + +#define CODE_SUFFIX ".code.c" +#define DEFINES_SUFFIX ".tab.h" +#define OUTPUT_SUFFIX ".tab.c" +#define VERBOSE_SUFFIX ".output" + + +/* keyword codes */ + +#define TOKEN 0 +#define LEFT 1 +#define RIGHT 2 +#define NONASSOC 3 +#define MARK 4 +#define TEXT 5 +#define TYPE 6 +#define START 7 + + +/* symbol classes */ + +#define UNKNOWN 0 +#define TERM 1 +#define NONTERM 2 + + +/* the undefined value */ + +#define UNDEFINED (-1) + + +/* action codes */ + +#define SHIFT 1 +#define REDUCE 2 + + +/* character macros */ + +#define IS_IDENT(c) (isalnum(c) || (c) == '_' || (c) == '.' || (c) == '$') +#define IS_OCTAL(c) ((c) >= '0' && (c) <= '7') +#define NUMERIC_VALUE(c) ((c) - '0') + + +/* symbol macros */ + +#define ISTOKEN(s) ((s) < start_symbol) +#define ISVAR(s) ((s) >= start_symbol) + + +/* storage allocation macros */ + +#define CALLOC(k,n) (calloc((unsigned)(k),(unsigned)(n))) +#define FREE(x) (free((char*)(x))) +#define MALLOC(n) (malloc((unsigned)(n))) +#define NEW(t) ((t*)allocate(sizeof(t))) +#define NEW2(n,t) ((t*)allocate((unsigned)((n)*sizeof(t)))) +#define REALLOC(p,n) (realloc((char*)(p),(unsigned)(n))) + + +/* the structure of a symbol table entry */ + +typedef struct bucket bucket; +struct bucket +{ + struct bucket *link; + struct bucket *next; + char *name; + char *tag; + short value; + short index; + short prec; + char class; + char assoc; +}; + + +/* the structure of the LR(0) state machine */ + +typedef struct core core; +struct core +{ + struct core *next; + struct core *link; + short number; + short accessing_symbol; + short nitems; + short items[1]; +}; + + +/* the structure used to record shifts */ + +typedef struct shifts shifts; +struct shifts +{ + struct shifts *next; + short number; + short nshifts; + short shift[1]; +}; + + +/* the structure used to store reductions */ + +typedef struct reductions reductions; +struct reductions +{ + struct reductions *next; + short number; + short nreds; + short rules[1]; +}; + + +/* the structure used to represent parser actions */ + +typedef struct action action; +struct action +{ + struct action *next; + short symbol; + short number; + short prec; + char action_code; + char assoc; + char suppressed; +}; + + +/* global variables */ + +extern char tflag; +extern char vflag; + +extern char *myname; +extern char *cptr; +extern char *line; +extern int lineno; +extern int outline; + +extern char *action_file_name; +extern char *input_file_name; +extern char *prolog_file_name; +extern char *local_file_name; +extern char *verbose_file_name; + +extern FILE *action_file; +extern FILE *input_file; +extern FILE *prolog_file; +extern FILE *local_file; +extern FILE *verbose_file; + +extern int nitems; +extern int nrules; +extern int nsyms; +extern int ntokens; +extern int nvars; +extern int ntags; + +extern char *line_format; + +extern int start_symbol; +extern char **symbol_name; +extern short *symbol_value; +extern short *symbol_prec; +extern char *symbol_assoc; + +extern short *ritem; +extern short *rlhs; +extern short *rrhs; +extern short *rprec; +extern char *rassoc; + +extern short **derives; +extern char *nullable; + +extern bucket *first_symbol; +extern bucket *last_symbol; + +extern int nstates; +extern core *first_state; +extern shifts *first_shift; +extern reductions *first_reduction; +extern short *accessing_symbol; +extern core **state_table; +extern shifts **shift_table; +extern reductions **reduction_table; +extern unsigned *LA; +extern short *LAruleno; +extern short *lookaheads; +extern short *goto_map; +extern short *from_state; +extern short *to_state; + +extern action **parser; +extern int SRtotal; +extern int RRtotal; +extern short *SRconflicts; +extern short *RRconflicts; +extern short *defred; +extern short *rules_used; +extern short nunused; +extern short final_state; + +/* global functions */ + +extern char *allocate(); +extern bucket *lookup(); +extern bucket *make_bucket(); + + +/* system variables */ + +extern int errno; + + +/* system functions */ + +extern void free(); +extern char *calloc(); +extern char *malloc(); +extern char *realloc(); +extern char *strcpy(); diff --git a/mcs/jay/depend b/mcs/jay/depend new file mode 100644 index 00000000000..134445ffddd --- /dev/null +++ b/mcs/jay/depend @@ -0,0 +1,11 @@ +closure.o: closure.c defs.h +error.o: error.c defs.h +lalr.o: lalr.c defs.h +lr0.o: lr0.c defs.h +main.o: main.c defs.h +mkpar.o: mkpar.c defs.h +output.o: output.c defs.h +reader.o: reader.c defs.h +symtab.o: symtab.c defs.h +verbose.o: verbose.c defs.h +warshall.o: warshall.c defs.h diff --git a/mcs/jay/error.c b/mcs/jay/error.c new file mode 100644 index 00000000000..dd8bf291c20 --- /dev/null +++ b/mcs/jay/error.c @@ -0,0 +1,335 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)error.c 5.3 (Berkeley) 6/1/90"; +#endif /* not lint */ + +/* routines for printing error messages */ + +#include "defs.h" + + +fatal(msg) +char *msg; +{ + fprintf(stderr, "%s: f - %s\n", myname, msg); + done(2); +} + + +no_space() +{ + fprintf(stderr, "%s: f - out of space\n", myname); + done(2); +} + + +open_error(filename) +char *filename; +{ + fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename); + done(2); +} + + +unexpected_EOF() +{ + fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n", + myname, lineno, input_file_name); + done(1); +} + + +print_pos(st_line, st_cptr) +char *st_line; +char *st_cptr; +{ + register char *s; + + if (st_line == 0) return; + for (s = st_line; *s != '\n'; ++s) + { + if (isprint(*s) || *s == '\t') + putc(*s, stderr); + else + putc('?', stderr); + } + putc('\n', stderr); + for (s = st_line; s < st_cptr; ++s) + { + if (*s == '\t') + putc('\t', stderr); + else + putc(' ', stderr); + } + putc('^', stderr); + putc('\n', stderr); +} + + +syntax_error(st_lineno, st_line, st_cptr) +int st_lineno; +char *st_line; +char *st_cptr; +{ + fprintf(stderr, "%s: e - line %d of \"%s\", syntax error\n", + myname, st_lineno, input_file_name); + print_pos(st_line, st_cptr); + done(1); +} + + +unterminated_comment(c_lineno, c_line, c_cptr) +int c_lineno; +char *c_line; +char *c_cptr; +{ + fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n", + myname, c_lineno, input_file_name); + print_pos(c_line, c_cptr); + done(1); +} + + +unterminated_string(s_lineno, s_line, s_cptr) +int s_lineno; +char *s_line; +char *s_cptr; +{ + fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n", + myname, s_lineno, input_file_name); + print_pos(s_line, s_cptr); + done(1); +} + + +unterminated_text(t_lineno, t_line, t_cptr) +int t_lineno; +char *t_line; +char *t_cptr; +{ + fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n", + myname, t_lineno, input_file_name); + print_pos(t_line, t_cptr); + done(1); +} + + +illegal_tag(t_lineno, t_line, t_cptr) +int t_lineno; +char *t_line; +char *t_cptr; +{ + fprintf(stderr, "%s: e - line %d of \"%s\", illegal tag\n", + myname, t_lineno, input_file_name); + print_pos(t_line, t_cptr); + done(1); +} + + +illegal_character(c_cptr) +char *c_cptr; +{ + fprintf(stderr, "%s: e - line %d of \"%s\", illegal character\n", + myname, lineno, input_file_name); + print_pos(line, c_cptr); + done(1); +} + + +used_reserved(s) +char *s; +{ + fprintf(stderr, "%s: e - line %d of \"%s\", illegal use of reserved symbol \ +%s\n", myname, lineno, input_file_name, s); + done(1); +} + + +tokenized_start(s) +char *s; +{ + fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s cannot be \ +declared to be a token\n", myname, lineno, input_file_name, s); + done(1); +} + + +retyped_warning(s) +char *s; +{ + fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \ +redeclared\n", myname, lineno, input_file_name, s); +} + + +reprec_warning(s) +char *s; +{ + fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \ +redeclared\n", myname, lineno, input_file_name, s); +} + + +revalued_warning(s) +char *s; +{ + fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \ +redeclared\n", myname, lineno, input_file_name, s); +} + + +terminal_start(s) +char *s; +{ + fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \ +token\n", myname, lineno, input_file_name, s); + done(1); +} + + +restarted_warning() +{ + fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \ +redeclared\n", myname, lineno, input_file_name); +} + + +no_grammar() +{ + fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \ +specified\n", myname, lineno, input_file_name); + done(1); +} + + +terminal_lhs(s_lineno) +int s_lineno; +{ + fprintf(stderr, "%s: e - line %d of \"%s\", a token appears on the lhs \ +of a production\n", myname, s_lineno, input_file_name); + done(1); +} + + +prec_redeclared() +{ + fprintf(stderr, "%s: w - line %d of \"%s\", conflicting %%prec \ +specifiers\n", myname, lineno, input_file_name); +} + + +unterminated_action(a_lineno, a_line, a_cptr) +int a_lineno; +char *a_line; +char *a_cptr; +{ + fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n", + myname, a_lineno, input_file_name); + print_pos(a_line, a_cptr); + done(1); +} + + +dollar_warning(a_lineno, i) +int a_lineno; +int i; +{ + fprintf(stderr, "%s: w - line %d of \"%s\", $%d references beyond the \ +end of the current rule\n", myname, a_lineno, input_file_name, i); +} + + +dollar_error(a_lineno, a_line, a_cptr) +int a_lineno; +char *a_line; +char *a_cptr; +{ + fprintf(stderr, "%s: e - line %d of \"%s\", illegal $-name\n", + myname, a_lineno, input_file_name); + print_pos(a_line, a_cptr); + done(1); +} + + +untyped_lhs() +{ + fprintf(stderr, "%s: w - line %d of \"%s\", $$ is untyped\n", + myname, lineno, input_file_name); + /** done(1); */ +} + + +untyped_rhs(i, s) +int i; +char *s; +{ + fprintf(stderr, "%s: w - line %d of \"%s\", $%d (%s) is untyped\n", + myname, lineno, input_file_name, i, s); + /** done(1); */ +} + + +unknown_rhs(i) +int i; +{ + fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n", + myname, lineno, input_file_name, i); + done(1); +} + + +default_action_warning() +{ + fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \ +undefined value to $$\n", myname, lineno, input_file_name); +} + + +undefined_goal(s) +char *s; +{ + fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s); + done(1); +} + + +undefined_symbol_warning(s) +char *s; +{ + fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s); +} diff --git a/mcs/jay/jay.1 b/mcs/jay/jay.1 new file mode 100644 index 00000000000..85040fd5694 --- /dev/null +++ b/mcs/jay/jay.1 @@ -0,0 +1,120 @@ +.\" Copyright (c) 1989, 1990 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Robert Paul Corbett. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)yacc.1 5.8 (Berkeley) 5/24/93 +.\" +.TH JAY 1 "May 24, 1993 / July 8, 1998" +.UC 6 +.SH NAME +jay \- an LALR(1) parser generator for Java and C# +.SH SYNOPSIS +.B jay [ -tv ] [ -c ] [ -b +.I file_prefix +.B ] [ -V +.I yyValue +.B ] +.I filename +.B < +.I skeleton +.SH DESCRIPTION +.I Jay +reads the grammar specification in the file +.I filename +and generates an LR(1) parser for it. +The parsers consist of a set of LALR(1) parsing tables and a driver routine +from the file +.I skeleton +written in the Java programming language. +.I Jay +writes the parse tables and the driver routine to standard output. +.PP +The following options are available: +.RS +.TP +\fB-b \fIfile_prefix\fR +The +.B -b +option changes the prefix prepended to the output file names to +the string denoted by +.IR file_prefix. +The default prefix is the character +.IR y. +.TP +.B -c +The +.B -c +option makes jay generate C# code instead of the default Java. +.TP +.B -t +The +.B -t +option arranges for +debugging information to be incorporated in the compiled code. +.TP +.B -v +The +.B -v +option causes a human-readable description of the generated parser to +be written to the file +.IR y.output. +.RE +.PP +If the environment variable TMPDIR is set, the string denoted by +TMPDIR will be used as the name of the directory where the temporary +files are created. +.SH FILES +.IR skeleton +.br +.IR y.output +.br +.IR /tmp/yacc.aXXXXXX +.br +.IR /tmp/yacc.tXXXXXX +.br +.IR /tmp/yacc.uXXXXXX +.SH DIAGNOSTICS +If there are rules that are never reduced, the number of such rules is +reported on standard error. +If there are any LALR(1) conflicts, the number of conflicts is reported +on standard error. +.SH HISTORY +.I Jay +is derived from Berkeley +.I yacc . +Input conventions closely follow those of +.I yacc ; +for details, +consult the parser +.I skeleton +file and the commented example included with the sources. diff --git a/mcs/jay/lalr.c b/mcs/jay/lalr.c new file mode 100644 index 00000000000..bf9aec846b7 --- /dev/null +++ b/mcs/jay/lalr.c @@ -0,0 +1,678 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)lalr.c 5.3 (Berkeley) 6/1/90"; +#endif /* not lint */ + +#include "defs.h" + +typedef + struct shorts + { + struct shorts *next; + short value; + } + shorts; + +int tokensetsize; +short *lookaheads; +short *LAruleno; +unsigned *LA; +short *accessing_symbol; +core **state_table; +shifts **shift_table; +reductions **reduction_table; +short *goto_map; +short *from_state; +short *to_state; + +short **transpose(); + +static int infinity; +static int maxrhs; +static int ngotos; +static unsigned *F; +static short **includes; +static shorts **lookback; +static short **R; +static short *INDEX; +static short *VERTICES; +static int top; + + +lalr() +{ + tokensetsize = WORDSIZE(ntokens); + + set_state_table(); + set_accessing_symbol(); + set_shift_table(); + set_reduction_table(); + set_maxrhs(); + initialize_LA(); + set_goto_map(); + initialize_F(); + build_relations(); + compute_FOLLOWS(); + compute_lookaheads(); +} + + + +set_state_table() +{ + register core *sp; + + state_table = NEW2(nstates, core *); + for (sp = first_state; sp; sp = sp->next) + state_table[sp->number] = sp; +} + + + +set_accessing_symbol() +{ + register core *sp; + + accessing_symbol = NEW2(nstates, short); + for (sp = first_state; sp; sp = sp->next) + accessing_symbol[sp->number] = sp->accessing_symbol; +} + + + +set_shift_table() +{ + register shifts *sp; + + shift_table = NEW2(nstates, shifts *); + for (sp = first_shift; sp; sp = sp->next) + shift_table[sp->number] = sp; +} + + + +set_reduction_table() +{ + register reductions *rp; + + reduction_table = NEW2(nstates, reductions *); + for (rp = first_reduction; rp; rp = rp->next) + reduction_table[rp->number] = rp; +} + + + +set_maxrhs() +{ + register short *itemp; + register short *item_end; + register int length; + register int max; + + length = 0; + max = 0; + item_end = ritem + nitems; + for (itemp = ritem; itemp < item_end; itemp++) + { + if (*itemp >= 0) + { + length++; + } + else + { + if (length > max) max = length; + length = 0; + } + } + + maxrhs = max; +} + + + +initialize_LA() +{ + register int i, j, k; + register reductions *rp; + + lookaheads = NEW2(nstates + 1, short); + + k = 0; + for (i = 0; i < nstates; i++) + { + lookaheads[i] = k; + rp = reduction_table[i]; + if (rp) + k += rp->nreds; + } + lookaheads[nstates] = k; + + LA = NEW2(k * tokensetsize, unsigned); + LAruleno = NEW2(k, short); + lookback = NEW2(k, shorts *); + + k = 0; + for (i = 0; i < nstates; i++) + { + rp = reduction_table[i]; + if (rp) + { + for (j = 0; j < rp->nreds; j++) + { + LAruleno[k] = rp->rules[j]; + k++; + } + } + } +} + + +set_goto_map() +{ + register shifts *sp; + register int i; + register int symbol; + register int k; + register short *temp_map; + register int state2; + register int state1; + + goto_map = NEW2(nvars + 1, short) - ntokens; + temp_map = NEW2(nvars + 1, short) - ntokens; + + ngotos = 0; + for (sp = first_shift; sp; sp = sp->next) + { + for (i = sp->nshifts - 1; i >= 0; i--) + { + symbol = accessing_symbol[sp->shift[i]]; + + if (ISTOKEN(symbol)) break; + + if (ngotos == MAXSHORT) + fatal("too many gotos"); + + ngotos++; + goto_map[symbol]++; + } + } + + k = 0; + for (i = ntokens; i < nsyms; i++) + { + temp_map[i] = k; + k += goto_map[i]; + } + + for (i = ntokens; i < nsyms; i++) + goto_map[i] = temp_map[i]; + + goto_map[nsyms] = ngotos; + temp_map[nsyms] = ngotos; + + from_state = NEW2(ngotos, short); + to_state = NEW2(ngotos, short); + + for (sp = first_shift; sp; sp = sp->next) + { + state1 = sp->number; + for (i = sp->nshifts - 1; i >= 0; i--) + { + state2 = sp->shift[i]; + symbol = accessing_symbol[state2]; + + if (ISTOKEN(symbol)) break; + + k = temp_map[symbol]++; + from_state[k] = state1; + to_state[k] = state2; + } + } + + FREE(temp_map + ntokens); +} + + + +/* Map_goto maps a state/symbol pair into its numeric representation. */ + +int +map_goto(state, symbol) +int state; +int symbol; +{ + register int high; + register int low; + register int middle; + register int s; + + low = goto_map[symbol]; + high = goto_map[symbol + 1]; + + for (;;) + { + assert(low <= high); + middle = (low + high) >> 1; + s = from_state[middle]; + if (s == state) + return (middle); + else if (s < state) + low = middle + 1; + else + high = middle - 1; + } +} + + + +initialize_F() +{ + register int i; + register int j; + register int k; + register shifts *sp; + register short *edge; + register unsigned *rowp; + register short *rp; + register short **reads; + register int nedges; + register int stateno; + register int symbol; + register int nwords; + + nwords = ngotos * tokensetsize; + F = NEW2(nwords, unsigned); + + reads = NEW2(ngotos, short *); + edge = NEW2(ngotos + 1, short); + nedges = 0; + + rowp = F; + for (i = 0; i < ngotos; i++) + { + stateno = to_state[i]; + sp = shift_table[stateno]; + + if (sp) + { + k = sp->nshifts; + + for (j = 0; j < k; j++) + { + symbol = accessing_symbol[sp->shift[j]]; + if (ISVAR(symbol)) + break; + SETBIT(rowp, symbol); + } + + for (; j < k; j++) + { + symbol = accessing_symbol[sp->shift[j]]; + if (nullable[symbol]) + edge[nedges++] = map_goto(stateno, symbol); + } + + if (nedges) + { + reads[i] = rp = NEW2(nedges + 1, short); + + for (j = 0; j < nedges; j++) + rp[j] = edge[j]; + + rp[nedges] = -1; + nedges = 0; + } + } + + rowp += tokensetsize; + } + + SETBIT(F, 0); + digraph(reads); + + for (i = 0; i < ngotos; i++) + { + if (reads[i]) + FREE(reads[i]); + } + + FREE(reads); + FREE(edge); +} + + + +build_relations() +{ + register int i; + register int j; + register int k; + register short *rulep; + register short *rp; + register shifts *sp; + register int length; + register int nedges; + register int done; + register int state1; + register int stateno; + register int symbol1; + register int symbol2; + register short *shortp; + register short *edge; + register short *states; + register short **new_includes; + + includes = NEW2(ngotos, short *); + edge = NEW2(ngotos + 1, short); + states = NEW2(maxrhs + 1, short); + + for (i = 0; i < ngotos; i++) + { + nedges = 0; + state1 = from_state[i]; + symbol1 = accessing_symbol[to_state[i]]; + + for (rulep = derives[symbol1]; *rulep >= 0; rulep++) + { + length = 1; + states[0] = state1; + stateno = state1; + + for (rp = ritem + rrhs[*rulep]; *rp >= 0; rp++) + { + symbol2 = *rp; + sp = shift_table[stateno]; + k = sp->nshifts; + + for (j = 0; j < k; j++) + { + stateno = sp->shift[j]; + if (accessing_symbol[stateno] == symbol2) break; + } + + states[length++] = stateno; + } + + add_lookback_edge(stateno, *rulep, i); + + length--; + done = 0; + while (!done) + { + done = 1; + rp--; + if (ISVAR(*rp)) + { + stateno = states[--length]; + edge[nedges++] = map_goto(stateno, *rp); + if (nullable[*rp] && length > 0) done = 0; + } + } + } + + if (nedges) + { + includes[i] = shortp = NEW2(nedges + 1, short); + for (j = 0; j < nedges; j++) + shortp[j] = edge[j]; + shortp[nedges] = -1; + } + } + + new_includes = transpose(includes, ngotos); + + for (i = 0; i < ngotos; i++) + if (includes[i]) + FREE(includes[i]); + + FREE(includes); + + includes = new_includes; + + FREE(edge); + FREE(states); +} + + +add_lookback_edge(stateno, ruleno, gotono) +int stateno, ruleno, gotono; +{ + register int i, k; + register int found; + register shorts *sp; + + i = lookaheads[stateno]; + k = lookaheads[stateno + 1]; + found = 0; + while (!found && i < k) + { + if (LAruleno[i] == ruleno) + found = 1; + else + ++i; + } + assert(found); + + sp = NEW(shorts); + sp->next = lookback[i]; + sp->value = gotono; + lookback[i] = sp; +} + + + +short ** +transpose(R, n) +short **R; +int n; +{ + register short **new_R; + register short **temp_R; + register short *nedges; + register short *sp; + register int i; + register int k; + + nedges = NEW2(n, short); + + for (i = 0; i < n; i++) + { + sp = R[i]; + if (sp) + { + while (*sp >= 0) + nedges[*sp++]++; + } + } + + new_R = NEW2(n, short *); + temp_R = NEW2(n, short *); + + for (i = 0; i < n; i++) + { + k = nedges[i]; + if (k > 0) + { + sp = NEW2(k + 1, short); + new_R[i] = sp; + temp_R[i] = sp; + sp[k] = -1; + } + } + + FREE(nedges); + + for (i = 0; i < n; i++) + { + sp = R[i]; + if (sp) + { + while (*sp >= 0) + *temp_R[*sp++]++ = i; + } + } + + FREE(temp_R); + + return (new_R); +} + + + +compute_FOLLOWS() +{ + digraph(includes); +} + + +compute_lookaheads() +{ + register int i, n; + register unsigned *fp1, *fp2, *fp3; + register shorts *sp, *next; + register unsigned *rowp; + + rowp = LA; + n = lookaheads[nstates]; + for (i = 0; i < n; i++) + { + fp3 = rowp + tokensetsize; + for (sp = lookback[i]; sp; sp = sp->next) + { + fp1 = rowp; + fp2 = F + tokensetsize * sp->value; + while (fp1 < fp3) + *fp1++ |= *fp2++; + } + rowp = fp3; + } + + for (i = 0; i < n; i++) + for (sp = lookback[i]; sp; sp = next) + { + next = sp->next; + FREE(sp); + } + + FREE(lookback); + FREE(F); +} + + +digraph(relation) +short **relation; +{ + register int i; + + infinity = ngotos + 2; + INDEX = NEW2(ngotos + 1, short); + VERTICES = NEW2(ngotos + 1, short); + top = 0; + + R = relation; + + for (i = 0; i < ngotos; i++) + INDEX[i] = 0; + + for (i = 0; i < ngotos; i++) + { + if (INDEX[i] == 0 && R[i]) + traverse(i); + } + + FREE(INDEX); + FREE(VERTICES); +} + + + +traverse(i) +register int i; +{ + register unsigned *fp1; + register unsigned *fp2; + register unsigned *fp3; + register int j; + register short *rp; + + int height; + unsigned *base; + + VERTICES[++top] = i; + INDEX[i] = height = top; + + base = F + i * tokensetsize; + fp3 = base + tokensetsize; + + rp = R[i]; + if (rp) + { + while ((j = *rp++) >= 0) + { + if (INDEX[j] == 0) + traverse(j); + + if (INDEX[i] > INDEX[j]) + INDEX[i] = INDEX[j]; + + fp1 = base; + fp2 = F + j * tokensetsize; + + while (fp1 < fp3) + *fp1++ |= *fp2++; + } + } + + if (INDEX[i] == height) + { + for (;;) + { + j = VERTICES[top--]; + INDEX[j] = infinity; + + if (i == j) + break; + + fp1 = base; + fp2 = F + j * tokensetsize; + + while (fp1 < fp3) + *fp2++ = *fp1++; + } + } +} diff --git a/mcs/jay/lr0.c b/mcs/jay/lr0.c new file mode 100644 index 00000000000..43106ea6cf3 --- /dev/null +++ b/mcs/jay/lr0.c @@ -0,0 +1,637 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)lr0.c 5.3 (Berkeley) 1/20/91"; +#endif /* not lint */ + +#include "defs.h" + +extern short *itemset; +extern short *itemsetend; +extern unsigned *ruleset; + +int nstates; +core *first_state; +shifts *first_shift; +reductions *first_reduction; + +int get_state(); +core *new_state(); + +static core **state_set; +static core *this_state; +static core *last_state; +static shifts *last_shift; +static reductions *last_reduction; + +static int nshifts; +static short *shift_symbol; + +static short *redset; +static short *shiftset; + +static short **kernel_base; +static short **kernel_end; +static short *kernel_items; + + +allocate_itemsets() +{ + register short *itemp; + register short *item_end; + register int symbol; + register int i; + register int count; + register int max; + register short *symbol_count; + + count = 0; + symbol_count = NEW2(nsyms, short); + + item_end = ritem + nitems; + for (itemp = ritem; itemp < item_end; itemp++) + { + symbol = *itemp; + if (symbol >= 0) + { + count++; + symbol_count[symbol]++; + } + } + + kernel_base = NEW2(nsyms, short *); + kernel_items = NEW2(count, short); + + count = 0; + max = 0; + for (i = 0; i < nsyms; i++) + { + kernel_base[i] = kernel_items + count; + count += symbol_count[i]; + if (max < symbol_count[i]) + max = symbol_count[i]; + } + + shift_symbol = symbol_count; + kernel_end = NEW2(nsyms, short *); +} + + +allocate_storage() +{ + allocate_itemsets(); + shiftset = NEW2(nsyms, short); + redset = NEW2(nrules + 1, short); + state_set = NEW2(nitems, core *); +} + + +append_states() +{ + register int i; + register int j; + register int symbol; + +#ifdef TRACE + fprintf(stderr, "Entering append_states()\n"); +#endif + for (i = 1; i < nshifts; i++) + { + symbol = shift_symbol[i]; + j = i; + while (j > 0 && shift_symbol[j - 1] > symbol) + { + shift_symbol[j] = shift_symbol[j - 1]; + j--; + } + shift_symbol[j] = symbol; + } + + for (i = 0; i < nshifts; i++) + { + symbol = shift_symbol[i]; + shiftset[i] = get_state(symbol); + } +} + + +free_storage() +{ + FREE(shift_symbol); + FREE(redset); + FREE(shiftset); + FREE(kernel_base); + FREE(kernel_end); + FREE(kernel_items); + FREE(state_set); +} + + + +generate_states() +{ + allocate_storage(); + itemset = NEW2(nitems, short); + ruleset = NEW2(WORDSIZE(nrules), unsigned); + set_first_derives(); + initialize_states(); + + while (this_state) + { + closure(this_state->items, this_state->nitems); + save_reductions(); + new_itemsets(); + append_states(); + + if (nshifts > 0) + save_shifts(); + + this_state = this_state->next; + } + + finalize_closure(); + free_storage(); +} + + + +int +get_state(symbol) +int symbol; +{ + register int key; + register short *isp1; + register short *isp2; + register short *iend; + register core *sp; + register int found; + register int n; + +#ifdef TRACE + fprintf(stderr, "Entering get_state(%d)\n", symbol); +#endif + + isp1 = kernel_base[symbol]; + iend = kernel_end[symbol]; + n = iend - isp1; + + key = *isp1; + assert(0 <= key && key < nitems); + sp = state_set[key]; + if (sp) + { + found = 0; + while (!found) + { + if (sp->nitems == n) + { + found = 1; + isp1 = kernel_base[symbol]; + isp2 = sp->items; + + while (found && isp1 < iend) + { + if (*isp1++ != *isp2++) + found = 0; + } + } + + if (!found) + { + if (sp->link) + { + sp = sp->link; + } + else + { + sp = sp->link = new_state(symbol); + found = 1; + } + } + } + } + else + { + state_set[key] = sp = new_state(symbol); + } + + return (sp->number); +} + + + +initialize_states() +{ + register int i; + register short *start_derives; + register core *p; + + start_derives = derives[start_symbol]; + for (i = 0; start_derives[i] >= 0; ++i) + continue; + + p = (core *) MALLOC(sizeof(core) + i*sizeof(short)); + if (p == 0) no_space(); + + p->next = 0; + p->link = 0; + p->number = 0; + p->accessing_symbol = 0; + p->nitems = i; + + for (i = 0; start_derives[i] >= 0; ++i) + p->items[i] = rrhs[start_derives[i]]; + + first_state = last_state = this_state = p; + nstates = 1; +} + + +new_itemsets() +{ + register int i; + register int shiftcount; + register short *isp; + register short *ksp; + register int symbol; + + for (i = 0; i < nsyms; i++) + kernel_end[i] = 0; + + shiftcount = 0; + isp = itemset; + while (isp < itemsetend) + { + i = *isp++; + symbol = ritem[i]; + if (symbol > 0) + { + ksp = kernel_end[symbol]; + if (!ksp) + { + shift_symbol[shiftcount++] = symbol; + ksp = kernel_base[symbol]; + } + + *ksp++ = i + 1; + kernel_end[symbol] = ksp; + } + } + + nshifts = shiftcount; +} + + + +core * +new_state(symbol) +int symbol; +{ + register int n; + register core *p; + register short *isp1; + register short *isp2; + register short *iend; + +#ifdef TRACE + fprintf(stderr, "Entering new_state(%d)\n", symbol); +#endif + + if (nstates >= MAXSHORT) + fatal("too many states"); + + isp1 = kernel_base[symbol]; + iend = kernel_end[symbol]; + n = iend - isp1; + + p = (core *) allocate((unsigned) (sizeof(core) + (n - 1) * sizeof(short))); + p->accessing_symbol = symbol; + p->number = nstates; + p->nitems = n; + + isp2 = p->items; + while (isp1 < iend) + *isp2++ = *isp1++; + + last_state->next = p; + last_state = p; + + nstates++; + + return (p); +} + + +/* show_cores is used for debugging */ + +show_cores() +{ + core *p; + int i, j, k, n; + int itemno; + + k = 0; + for (p = first_state; p; ++k, p = p->next) + { + if (k) printf("\n"); + printf("state %d, number = %d, accessing symbol = %s\n", + k, p->number, symbol_name[p->accessing_symbol]); + n = p->nitems; + for (i = 0; i < n; ++i) + { + itemno = p->items[i]; + printf("%4d ", itemno); + j = itemno; + while (ritem[j] >= 0) ++j; + printf("%s :", symbol_name[rlhs[-ritem[j]]]); + j = rrhs[-ritem[j]]; + while (j < itemno) + printf(" %s", symbol_name[ritem[j++]]); + printf(" ."); + while (ritem[j] >= 0) + printf(" %s", symbol_name[ritem[j++]]); + printf("\n"); + fflush(stdout); + } + } +} + + +/* show_ritems is used for debugging */ + +show_ritems() +{ + int i; + + for (i = 0; i < nitems; ++i) + printf("ritem[%d] = %d\n", i, ritem[i]); +} + + +/* show_rrhs is used for debugging */ +show_rrhs() +{ + int i; + + for (i = 0; i < nrules; ++i) + printf("rrhs[%d] = %d\n", i, rrhs[i]); +} + + +/* show_shifts is used for debugging */ + +show_shifts() +{ + shifts *p; + int i, j, k; + + k = 0; + for (p = first_shift; p; ++k, p = p->next) + { + if (k) printf("\n"); + printf("shift %d, number = %d, nshifts = %d\n", k, p->number, + p->nshifts); + j = p->nshifts; + for (i = 0; i < j; ++i) + printf("\t%d\n", p->shift[i]); + } +} + + +save_shifts() +{ + register shifts *p; + register short *sp1; + register short *sp2; + register short *send; + + p = (shifts *) allocate((unsigned) (sizeof(shifts) + + (nshifts - 1) * sizeof(short))); + + p->number = this_state->number; + p->nshifts = nshifts; + + sp1 = shiftset; + sp2 = p->shift; + send = shiftset + nshifts; + + while (sp1 < send) + *sp2++ = *sp1++; + + if (last_shift) + { + last_shift->next = p; + last_shift = p; + } + else + { + first_shift = p; + last_shift = p; + } +} + + + +save_reductions() +{ + register short *isp; + register short *rp1; + register short *rp2; + register int item; + register int count; + register reductions *p; + register short *rend; + + count = 0; + for (isp = itemset; isp < itemsetend; isp++) + { + item = ritem[*isp]; + if (item < 0) + { + redset[count++] = -item; + } + } + + if (count) + { + p = (reductions *) allocate((unsigned) (sizeof(reductions) + + (count - 1) * sizeof(short))); + + p->number = this_state->number; + p->nreds = count; + + rp1 = redset; + rp2 = p->rules; + rend = rp1 + count; + + while (rp1 < rend) + *rp2++ = *rp1++; + + if (last_reduction) + { + last_reduction->next = p; + last_reduction = p; + } + else + { + first_reduction = p; + last_reduction = p; + } + } +} + + +set_derives() +{ + register int i, k; + register int lhs; + register short *rules; + + derives = NEW2(nsyms, short *); + rules = NEW2(nvars + nrules, short); + + k = 0; + for (lhs = start_symbol; lhs < nsyms; lhs++) + { + derives[lhs] = rules + k; + for (i = 0; i < nrules; i++) + { + if (rlhs[i] == lhs) + { + rules[k] = i; + k++; + } + } + rules[k] = -1; + k++; + } + +#ifdef DEBUG + print_derives(); +#endif +} + +free_derives() +{ + FREE(derives[start_symbol]); + FREE(derives); +} + +#ifdef DEBUG +print_derives() +{ + register int i; + register short *sp; + + printf("\nDERIVES\n\n"); + + for (i = start_symbol; i < nsyms; i++) + { + printf("%s derives ", symbol_name[i]); + for (sp = derives[i]; *sp >= 0; sp++) + { + printf(" %d", *sp); + } + putchar('\n'); + } + + putchar('\n'); +} +#endif + + +set_nullable() +{ + register int i, j; + register int empty; + int done; + + nullable = MALLOC(nsyms); + if (nullable == 0) no_space(); + + for (i = 0; i < nsyms; ++i) + nullable[i] = 0; + + done = 0; + while (!done) + { + done = 1; + for (i = 1; i < nitems; i++) + { + empty = 1; + while ((j = ritem[i]) >= 0) + { + if (!nullable[j]) + empty = 0; + ++i; + } + if (empty) + { + j = rlhs[-j]; + if (!nullable[j]) + { + nullable[j] = 1; + done = 0; + } + } + } + } + +#ifdef DEBUG + for (i = 0; i < nsyms; i++) + { + if (nullable[i]) + printf("%s is nullable\n", symbol_name[i]); + else + printf("%s is not nullable\n", symbol_name[i]); + } +#endif +} + + +free_nullable() +{ + FREE(nullable); +} + + +lr0() +{ + set_derives(); + set_nullable(); + generate_states(); +} diff --git a/mcs/jay/main.c b/mcs/jay/main.c new file mode 100644 index 00000000000..c6954eb9285 --- /dev/null +++ b/mcs/jay/main.c @@ -0,0 +1,341 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +char copyright[] = +"@(#) Copyright (c) 1989 The Regents of the University of California.\n\ + All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)main.c 5.5 (Berkeley) 5/24/93"; +#endif /* not lint */ + +#include <signal.h> +#include "defs.h" + +char tflag; +char vflag; +char csharp = 0; + +char *file_prefix = "y"; +char *myname = "yacc"; +char *temp_form = "yacc.XXXXXXX"; + +int lineno; +int outline; + +char *action_file_name; +char *input_file_name = ""; +char *prolog_file_name; +char *local_file_name; +char *verbose_file_name; + +FILE *action_file; /* a temp file, used to save actions associated */ + /* with rules until the parser is written */ +FILE *input_file; /* the input file */ +FILE *prolog_file; /* temp files, used to save text until all */ +FILE *local_file; /* symbols have been defined */ +FILE *verbose_file; /* y.output */ + +int nitems; +int nrules; +int nsyms; +int ntokens; +int nvars; + +int start_symbol; +char **symbol_name; +short *symbol_value; +short *symbol_prec; +char *symbol_assoc; + +short *ritem; +short *rlhs; +short *rrhs; +short *rprec; +char *rassoc; +short **derives; +char *nullable; + +extern char *mktemp(); +extern char *getenv(); + +done(k) +int k; +{ + if (action_file) { fclose(action_file); unlink(action_file_name); } + if (prolog_file) { fclose(prolog_file); unlink(prolog_file_name); } + if (local_file) { fclose(local_file); unlink(local_file_name); } + exit(k); +} + + +void +onintr(signo) + int signo; +{ + done(1); +} + + +set_signals() +{ +#ifdef SIGINT + if (signal(SIGINT, SIG_IGN) != SIG_IGN) + signal(SIGINT, onintr); +#endif +#ifdef SIGTERM + if (signal(SIGTERM, SIG_IGN) != SIG_IGN) + signal(SIGTERM, onintr); +#endif +#ifdef SIGHUP + if (signal(SIGHUP, SIG_IGN) != SIG_IGN) + signal(SIGHUP, onintr); +#endif +} + + +usage() +{ + fprintf(stderr, "usage: %s [-tvc] [-b file_prefix] filename\n", myname); + exit(1); +} + + +getargs(argc, argv) +int argc; +char *argv[]; +{ + register int i; + register char *s; + + if (argc > 0) myname = argv[0]; + for (i = 1; i < argc; ++i) + { + s = argv[i]; + if (*s != '-') break; + switch (*++s) + { + case '\0': + input_file = stdin; + if (i + 1 < argc) usage(); + return; + + case '-': + ++i; + goto no_more_options; + + case 'b': + if (*++s) + file_prefix = s; + else if (++i < argc) + file_prefix = argv[i]; + else + usage(); + continue; + + case 't': + tflag = 1; + break; + + case 'c': + csharp = 1; + line_format = "#line %d \"%s\"\n"; + break; + + case 'v': + vflag = 1; + break; + + default: + usage(); + } + + for (;;) + { + switch (*++s) + { + case '\0': + goto end_of_option; + + case 't': + tflag = 1; + break; + + case 'v': + vflag = 1; + break; + + case 'c': + csharp = 1; + break; + + default: + usage(); + } + } +end_of_option:; + } + +no_more_options:; + if (i + 1 != argc) usage(); + input_file_name = argv[i]; +} + + +char * +allocate(n) +unsigned n; +{ + register char *p; + + p = NULL; + if (n) + { + p = CALLOC(1, n); + if (!p) no_space(); + } + return (p); +} + + +create_file_names() +{ + int i, len; + char *tmpdir; + + tmpdir = getenv("TMPDIR"); + if (tmpdir == 0) tmpdir = "/tmp"; + + len = strlen(tmpdir); + i = len + 13; + if (len && tmpdir[len-1] != '/') + ++i; + + action_file_name = MALLOC(i); + if (action_file_name == 0) no_space(); + prolog_file_name = MALLOC(i); + if (prolog_file_name == 0) no_space(); + local_file_name = MALLOC(i); + if (local_file_name == 0) no_space(); + + strcpy(action_file_name, tmpdir); + strcpy(prolog_file_name, tmpdir); + strcpy(local_file_name, tmpdir); + + if (len && tmpdir[len - 1] != '/') + { + action_file_name[len] = '/'; + prolog_file_name[len] = '/'; + local_file_name[len] = '/'; + ++len; + } + + strcpy(action_file_name + len, temp_form); + strcpy(prolog_file_name + len, temp_form); + strcpy(local_file_name + len, temp_form); + + action_file_name[len + 5] = 'a'; + prolog_file_name[len + 5] = 'p'; + local_file_name[len + 5] = 'l'; + + mktemp(action_file_name); + mktemp(prolog_file_name); + mktemp(local_file_name); + + len = strlen(file_prefix); + + if (vflag) + { + verbose_file_name = MALLOC(len + 8); + if (verbose_file_name == 0) + no_space(); + strcpy(verbose_file_name, file_prefix); + strcpy(verbose_file_name + len, VERBOSE_SUFFIX); + } +} + + +open_files() +{ + create_file_names(); + + if (input_file == 0) + { + input_file = fopen(input_file_name, "r"); + if (input_file == 0) + open_error(input_file_name); + } + + action_file = fopen(action_file_name, "w"); + if (action_file == 0) + open_error(action_file_name); + + prolog_file = fopen(prolog_file_name, "w"); + if (prolog_file == 0) + open_error(prolog_file_name); + + local_file = fopen(local_file_name, "w"); + if (local_file == 0) + open_error(local_file_name); + + if (vflag) + { + verbose_file = fopen(verbose_file_name, "w"); + if (verbose_file == 0) + open_error(verbose_file_name); + } +} + + +int +main(argc, argv) +int argc; +char *argv[]; +{ + set_signals(); + getargs(argc, argv); + open_files(); + reader(); + lr0(); + lalr(); + make_parser(); + verbose(); + output(); + done(0); + /*NOTREACHED*/ +} diff --git a/mcs/jay/makefile b/mcs/jay/makefile new file mode 100644 index 00000000000..82cce87c559 --- /dev/null +++ b/mcs/jay/makefile @@ -0,0 +1,14 @@ +all = jay +c = closure.c error.c lalr.c lr0.c main.c mkpar.c output.c reader.c \ + symtab.c verbose.c warshall.c + +CFLAGS=#-g + +jay: $(c:.c=.o) ; $(CC) -o $@ $(CFLAGS) $(c:.c=.o) + +clean: + rm -f jay *.o + +windows: jay + +unix: jay diff --git a/mcs/jay/mkpar.c b/mcs/jay/mkpar.c new file mode 100644 index 00000000000..42ead14514d --- /dev/null +++ b/mcs/jay/mkpar.c @@ -0,0 +1,395 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)mkpar.c 5.3 (Berkeley) 1/20/91"; +#endif /* not lint */ + +#include "defs.h" + +action **parser; +int SRtotal; +int RRtotal; +short *SRconflicts; +short *RRconflicts; +short *defred; +short *rules_used; +short nunused; +short final_state; + +static int SRcount; +static int RRcount; + +extern action *parse_actions(); +extern action *get_shifts(); +extern action *add_reductions(); +extern action *add_reduce(); + + +make_parser() +{ + register int i; + + parser = NEW2(nstates, action *); + for (i = 0; i < nstates; i++) + parser[i] = parse_actions(i); + + find_final_state(); + remove_conflicts(); + unused_rules(); + if (SRtotal + RRtotal > 0) total_conflicts(); + defreds(); +} + + +action * +parse_actions(stateno) +register int stateno; +{ + register action *actions; + + actions = get_shifts(stateno); + actions = add_reductions(stateno, actions); + return (actions); +} + + +action * +get_shifts(stateno) +int stateno; +{ + register action *actions, *temp; + register shifts *sp; + register short *to_state; + register int i, k; + register int symbol; + + actions = 0; + sp = shift_table[stateno]; + if (sp) + { + to_state = sp->shift; + for (i = sp->nshifts - 1; i >= 0; i--) + { + k = to_state[i]; + symbol = accessing_symbol[k]; + if (ISTOKEN(symbol)) + { + temp = NEW(action); + temp->next = actions; + temp->symbol = symbol; + temp->number = k; + temp->prec = symbol_prec[symbol]; + temp->action_code = SHIFT; + temp->assoc = symbol_assoc[symbol]; + actions = temp; + } + } + } + return (actions); +} + +action * +add_reductions(stateno, actions) +int stateno; +register action *actions; +{ + register int i, j, m, n; + register int ruleno, tokensetsize; + register unsigned *rowp; + + tokensetsize = WORDSIZE(ntokens); + m = lookaheads[stateno]; + n = lookaheads[stateno + 1]; + for (i = m; i < n; i++) + { + ruleno = LAruleno[i]; + rowp = LA + i * tokensetsize; + for (j = ntokens - 1; j >= 0; j--) + { + if (BIT(rowp, j)) + actions = add_reduce(actions, ruleno, j); + } + } + return (actions); +} + + +action * +add_reduce(actions, ruleno, symbol) +register action *actions; +register int ruleno, symbol; +{ + register action *temp, *prev, *next; + + prev = 0; + for (next = actions; next && next->symbol < symbol; next = next->next) + prev = next; + + while (next && next->symbol == symbol && next->action_code == SHIFT) + { + prev = next; + next = next->next; + } + + while (next && next->symbol == symbol && + next->action_code == REDUCE && next->number < ruleno) + { + prev = next; + next = next->next; + } + + temp = NEW(action); + temp->next = next; + temp->symbol = symbol; + temp->number = ruleno; + temp->prec = rprec[ruleno]; + temp->action_code = REDUCE; + temp->assoc = rassoc[ruleno]; + + if (prev) + prev->next = temp; + else + actions = temp; + + return (actions); +} + + +find_final_state() +{ + register int goal, i; + register short *to_state; + register shifts *p; + + p = shift_table[0]; + to_state = p->shift; + goal = ritem[1]; + for (i = p->nshifts - 1; i >= 0; --i) + { + final_state = to_state[i]; + if (accessing_symbol[final_state] == goal) break; + } +} + + +unused_rules() +{ + register int i; + register action *p; + + rules_used = (short *) MALLOC(nrules*sizeof(short)); + if (rules_used == 0) no_space(); + + for (i = 0; i < nrules; ++i) + rules_used[i] = 0; + + for (i = 0; i < nstates; ++i) + { + for (p = parser[i]; p; p = p->next) + { + if (p->action_code == REDUCE && p->suppressed == 0) + rules_used[p->number] = 1; + } + } + + nunused = 0; + for (i = 3; i < nrules; ++i) + if (!rules_used[i]) ++nunused; + + if (nunused) + if (nunused == 1) + fprintf(stderr, "%s: 1 rule never reduced\n", myname); + else + fprintf(stderr, "%s: %d rules never reduced\n", myname, nunused); +} + + +remove_conflicts() +{ + register int i; + register int symbol; + register action *p, *pref; + + SRtotal = 0; + RRtotal = 0; + SRconflicts = NEW2(nstates, short); + RRconflicts = NEW2(nstates, short); + for (i = 0; i < nstates; i++) + { + SRcount = 0; + RRcount = 0; + symbol = -1; + for (p = parser[i]; p; p = p->next) + { + if (p->symbol != symbol) + { + pref = p; + symbol = p->symbol; + } + else if (i == final_state && symbol == 0) + { + SRcount++; + p->suppressed = 1; + } + else if (pref->action_code == SHIFT) + { + if (pref->prec > 0 && p->prec > 0) + { + if (pref->prec < p->prec) + { + pref->suppressed = 2; + pref = p; + } + else if (pref->prec > p->prec) + { + p->suppressed = 2; + } + else if (pref->assoc == LEFT) + { + pref->suppressed = 2; + pref = p; + } + else if (pref->assoc == RIGHT) + { + p->suppressed = 2; + } + else + { + pref->suppressed = 2; + p->suppressed = 2; + } + } + else + { + SRcount++; + p->suppressed = 1; + } + } + else + { + RRcount++; + p->suppressed = 1; + } + } + SRtotal += SRcount; + RRtotal += RRcount; + SRconflicts[i] = SRcount; + RRconflicts[i] = RRcount; + } +} + + +total_conflicts() +{ + fprintf(stderr, "%s: ", myname); + if (SRtotal == 1) + fprintf(stderr, "1 shift/reduce conflict"); + else if (SRtotal > 1) + fprintf(stderr, "%d shift/reduce conflicts", SRtotal); + + if (SRtotal && RRtotal) + fprintf(stderr, ", "); + + if (RRtotal == 1) + fprintf(stderr, "1 reduce/reduce conflict"); + else if (RRtotal > 1) + fprintf(stderr, "%d reduce/reduce conflicts", RRtotal); + + fprintf(stderr, ".\n"); +} + + +int +sole_reduction(stateno) +int stateno; +{ + register int count, ruleno; + register action *p; + + count = 0; + ruleno = 0; + for (p = parser[stateno]; p; p = p->next) + { + if (p->action_code == SHIFT && p->suppressed == 0) + return (0); + else if (p->action_code == REDUCE && p->suppressed == 0) + { + if (ruleno > 0 && p->number != ruleno) + return (0); + if (p->symbol != 1) + ++count; + ruleno = p->number; + } + } + + if (count == 0) + return (0); + return (ruleno); +} + + +defreds() +{ + register int i; + + defred = NEW2(nstates, short); + for (i = 0; i < nstates; i++) + defred[i] = sole_reduction(i); +} + +free_action_row(p) +register action *p; +{ + register action *q; + + while (p) + { + q = p->next; + FREE(p); + p = q; + } +} + +free_parser() +{ + register int i; + + for (i = 0; i < nstates; i++) + free_action_row(parser[i]); + + FREE(parser); +} diff --git a/mcs/jay/output.c b/mcs/jay/output.c new file mode 100644 index 00000000000..81e4755c9cd --- /dev/null +++ b/mcs/jay/output.c @@ -0,0 +1,1173 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)output.c 5.7 (Berkeley) 5/24/93"; +#endif /* not lint */ + +#include "defs.h" +#include <string.h> + +static int nvectors; +static int nentries; +static short **froms; +static short **tos; +static short *tally; +static short *width; +static short *state_count; +static short *order; +static short *base; +static short *pos; +static int maxtable; +static short *table; +static short *check; +static int lowzero; +static int high; +extern int csharp; + +output () { + int lno = 0; + char buf [128]; + + free_itemsets(); + free_shifts(); + free_reductions(); + + while (fgets(buf, sizeof buf, stdin) != NULL) { + char * cp; + ++ lno; + if (buf[strlen(buf)-1] != '\n') + fprintf(stderr, "jay: line %d is too long\n", lno), done(1); + switch (buf[0]) { + case '#': continue; + case 't': if (!tflag) fputs("//t", stdout); + case '.': break; + default: + cp = strtok(buf, " \t\r\n"); + if (cp) + if (strcmp(cp, "actions") == 0) output_semantic_actions(); + else if (strcmp(cp, "debug") == 0) output_debug(); + else if (strcmp(cp, "epilog") == 0) output_trailing_text(); + else if (strcmp(cp, "prolog") == 0) + output_stored_text(prolog_file, prolog_file_name); + else if (strcmp(cp, "local") == 0) + output_stored_text(local_file, local_file_name); + else if (strcmp(cp, "tables") == 0) + output_rule_data(), output_yydefred(), output_actions(); + else if (strcmp(cp, "tokens") == 0) + output_defines(strtok(NULL, "\r\n")); + else + fprintf(stderr, "jay: unknown call (%s) in line %d\n", cp, lno); + continue; + } + fputs(buf+1, stdout), ++ outline; + } + free_parser(); +} + +output_rule_data() +{ + register int i; + register int j; + + + printf(" %s static %s short [] yyLhs = {%16d,", + csharp ? "" : " protected", + csharp ? "" : " final", + symbol_value[start_symbol]); + + j = 10; + for (i = 3; i < nrules; i++) + { + if (j >= 10) + { + ++outline; + putchar('\n'); + j = 1; + } + else + ++j; + + printf("%5d,", symbol_value[rlhs[i]]); + } + outline += 2; + printf("\n };\n"); + + printf(" %s static %s short [] yyLen = {%12d,", + csharp ? "" : "protected", + csharp ? "" : "final", + 2); + + j = 10; + for (i = 3; i < nrules; i++) + { + if (j >= 10) + { + ++outline; + putchar('\n'); + j = 1; + } + else + j++; + + printf("%5d,", rrhs[i + 1] - rrhs[i] - 1); + } + outline += 2; + printf("\n };\n"); +} + + +output_yydefred() +{ + register int i, j; + + printf(" %s static %s short [] yyDefRed = {%13d,", + csharp ? "" : "protected", + csharp ? "" : "final", + (defred[0] ? defred[0] - 2 : 0)); + + j = 10; + for (i = 1; i < nstates; i++) + { + if (j < 10) + ++j; + else + { + ++outline; + putchar('\n'); + j = 1; + } + + printf("%5d,", (defred[i] ? defred[i] - 2 : 0)); + } + + outline += 2; + printf("\n };\n"); +} + + +output_actions() +{ + nvectors = 2*nstates + nvars; + + froms = NEW2(nvectors, short *); + tos = NEW2(nvectors, short *); + tally = NEW2(nvectors, short); + width = NEW2(nvectors, short); + + token_actions(); + FREE(lookaheads); + FREE(LA); + FREE(LAruleno); + FREE(accessing_symbol); + + goto_actions(); + FREE(goto_map + ntokens); + FREE(from_state); + FREE(to_state); + + sort_actions(); + pack_table(); + output_base(); + output_table(); + output_check(); +} + + +token_actions() +{ + register int i, j; + register int shiftcount, reducecount; + register int max, min; + register short *actionrow, *r, *s; + register action *p; + + actionrow = NEW2(2*ntokens, short); + for (i = 0; i < nstates; ++i) + { + if (parser[i]) + { + for (j = 0; j < 2*ntokens; ++j) + actionrow[j] = 0; + + shiftcount = 0; + reducecount = 0; + for (p = parser[i]; p; p = p->next) + { + if (p->suppressed == 0) + { + if (p->action_code == SHIFT) + { + ++shiftcount; + actionrow[p->symbol] = p->number; + } + else if (p->action_code == REDUCE && p->number != defred[i]) + { + ++reducecount; + actionrow[p->symbol + ntokens] = p->number; + } + } + } + + tally[i] = shiftcount; + tally[nstates+i] = reducecount; + width[i] = 0; + width[nstates+i] = 0; + if (shiftcount > 0) + { + froms[i] = r = NEW2(shiftcount, short); + tos[i] = s = NEW2(shiftcount, short); + min = MAXSHORT; + max = 0; + for (j = 0; j < ntokens; ++j) + { + if (actionrow[j]) + { + if (min > symbol_value[j]) + min = symbol_value[j]; + if (max < symbol_value[j]) + max = symbol_value[j]; + *r++ = symbol_value[j]; + *s++ = actionrow[j]; + } + } + width[i] = max - min + 1; + } + if (reducecount > 0) + { + froms[nstates+i] = r = NEW2(reducecount, short); + tos[nstates+i] = s = NEW2(reducecount, short); + min = MAXSHORT; + max = 0; + for (j = 0; j < ntokens; ++j) + { + if (actionrow[ntokens+j]) + { + if (min > symbol_value[j]) + min = symbol_value[j]; + if (max < symbol_value[j]) + max = symbol_value[j]; + *r++ = symbol_value[j]; + *s++ = actionrow[ntokens+j] - 2; + } + } + width[nstates+i] = max - min + 1; + } + } + } + FREE(actionrow); +} + +goto_actions() +{ + register int i, j, k; + + state_count = NEW2(nstates, short); + + k = default_goto(start_symbol + 1); + printf(" protected static %s short [] yyDgoto = {%14d,", csharp ? "" : "final", k); + save_column(start_symbol + 1, k); + + j = 10; + for (i = start_symbol + 2; i < nsyms; i++) + { + if (j >= 10) + { + ++outline; + putchar('\n'); + j = 1; + } + else + ++j; + + k = default_goto(i); + printf("%5d,", k); + save_column(i, k); + } + + outline += 2; + printf("\n };\n"); + FREE(state_count); +} + +int +default_goto(symbol) +int symbol; +{ + register int i; + register int m; + register int n; + register int default_state; + register int max; + + m = goto_map[symbol]; + n = goto_map[symbol + 1]; + + if (m == n) return (0); + + for (i = 0; i < nstates; i++) + state_count[i] = 0; + + for (i = m; i < n; i++) + state_count[to_state[i]]++; + + max = 0; + default_state = 0; + for (i = 0; i < nstates; i++) + { + if (state_count[i] > max) + { + max = state_count[i]; + default_state = i; + } + } + + return (default_state); +} + + + +save_column(symbol, default_state) +int symbol; +int default_state; +{ + register int i; + register int m; + register int n; + register short *sp; + register short *sp1; + register short *sp2; + register int count; + register int symno; + + m = goto_map[symbol]; + n = goto_map[symbol + 1]; + + count = 0; + for (i = m; i < n; i++) + { + if (to_state[i] != default_state) + ++count; + } + if (count == 0) return; + + symno = symbol_value[symbol] + 2*nstates; + + froms[symno] = sp1 = sp = NEW2(count, short); + tos[symno] = sp2 = NEW2(count, short); + + for (i = m; i < n; i++) + { + if (to_state[i] != default_state) + { + *sp1++ = from_state[i]; + *sp2++ = to_state[i]; + } + } + + tally[symno] = count; + width[symno] = sp1[-1] - sp[0] + 1; +} + +sort_actions() +{ + register int i; + register int j; + register int k; + register int t; + register int w; + + order = NEW2(nvectors, short); + nentries = 0; + + for (i = 0; i < nvectors; i++) + { + if (tally[i] > 0) + { + t = tally[i]; + w = width[i]; + j = nentries - 1; + + while (j >= 0 && (width[order[j]] < w)) + j--; + + while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t)) + j--; + + for (k = nentries - 1; k > j; k--) + order[k + 1] = order[k]; + + order[j + 1] = i; + nentries++; + } + } +} + + +pack_table() +{ + register int i; + register int place; + register int state; + + base = NEW2(nvectors, short); + pos = NEW2(nentries, short); + + maxtable = 1000; + table = NEW2(maxtable, short); + check = NEW2(maxtable, short); + + lowzero = 0; + high = 0; + + for (i = 0; i < maxtable; i++) + check[i] = -1; + + for (i = 0; i < nentries; i++) + { + state = matching_vector(i); + + if (state < 0) + place = pack_vector(i); + else + place = base[state]; + + pos[i] = place; + base[order[i]] = place; + } + + for (i = 0; i < nvectors; i++) + { + if (froms[i]) + FREE(froms[i]); + if (tos[i]) + FREE(tos[i]); + } + + FREE(froms); + FREE(tos); + FREE(pos); +} + + +/* The function matching_vector determines if the vector specified by */ +/* the input parameter matches a previously considered vector. The */ +/* test at the start of the function checks if the vector represents */ +/* a row of shifts over terminal symbols or a row of reductions, or a */ +/* column of shifts over a nonterminal symbol. Berkeley Yacc does not */ +/* check if a column of shifts over a nonterminal symbols matches a */ +/* previously considered vector. Because of the nature of LR parsing */ +/* tables, no two columns can match. Therefore, the only possible */ +/* match would be between a row and a column. Such matches are */ +/* unlikely. Therefore, to save time, no attempt is made to see if a */ +/* column matches a previously considered vector. */ +/* */ +/* Matching_vector is poorly designed. The test could easily be made */ +/* faster. Also, it depends on the vectors being in a specific */ +/* order. */ + +int +matching_vector(vector) +int vector; +{ + register int i; + register int j; + register int k; + register int t; + register int w; + register int match; + register int prev; + + i = order[vector]; + if (i >= 2*nstates) + return (-1); + + t = tally[i]; + w = width[i]; + + for (prev = vector - 1; prev >= 0; prev--) + { + j = order[prev]; + if (width[j] != w || tally[j] != t) + return (-1); + + match = 1; + for (k = 0; match && k < t; k++) + { + if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k]) + match = 0; + } + + if (match) + return (j); + } + + return (-1); +} + + + +int +pack_vector(vector) +int vector; +{ + register int i, j, k, l; + register int t; + register int loc; + register int ok; + register short *from; + register short *to; + int newmax; + + i = order[vector]; + t = tally[i]; + assert(t); + + from = froms[i]; + to = tos[i]; + + j = lowzero - from[0]; + for (k = 1; k < t; ++k) + if (lowzero - from[k] > j) + j = lowzero - from[k]; + for (;; ++j) + { + if (j == 0) + continue; + ok = 1; + for (k = 0; ok && k < t; k++) + { + loc = j + from[k]; + if (loc >= maxtable) + { + if (loc >= MAXTABLE) + fatal("maximum table size exceeded"); + + newmax = maxtable; + do { newmax += 200; } while (newmax <= loc); + table = (short *) REALLOC(table, newmax*sizeof(short)); + if (table == 0) no_space(); + check = (short *) REALLOC(check, newmax*sizeof(short)); + if (check == 0) no_space(); + for (l = maxtable; l < newmax; ++l) + { + table[l] = 0; + check[l] = -1; + } + maxtable = newmax; + } + + if (check[loc] != -1) + ok = 0; + } + for (k = 0; ok && k < vector; k++) + { + if (pos[k] == j) + ok = 0; + } + if (ok) + { + for (k = 0; k < t; k++) + { + loc = j + from[k]; + table[loc] = to[k]; + check[loc] = from[k]; + if (loc > high) high = loc; + } + + while (check[lowzero] != -1) + ++lowzero; + + return (j); + } + } +} + + + +output_base() +{ + register int i, j; + + printf(" protected static %s short [] yySindex = {%13d,", csharp?"":"final", base[0]); + + j = 10; + for (i = 1; i < nstates; i++) + { + if (j >= 10) + { + ++outline; + putchar('\n'); + j = 1; + } + else + ++j; + + printf("%5d,", base[i]); + } + + outline += 2; + printf("\n };\n protected static %s short [] yyRindex = {%13d,", + csharp ? "" : "final", + base[nstates]); + + j = 10; + for (i = nstates + 1; i < 2*nstates; i++) + { + if (j >= 10) + { + ++outline; + putchar('\n'); + j = 1; + } + else + ++j; + + printf("%5d,", base[i]); + } + + outline += 2; + printf("\n };\n protected static %s short [] yyGindex = {%13d,", + csharp ? "" : "final", + base[2*nstates]); + + j = 10; + for (i = 2*nstates + 1; i < nvectors - 1; i++) + { + if (j >= 10) + { + ++outline; + putchar('\n'); + j = 1; + } + else + ++j; + + printf("%5d,", base[i]); + } + + outline += 2; + printf("\n };\n"); + FREE(base); +} + + + +output_table() +{ + register int i; + register int j; + + printf(" protected static %s short [] yyTable = {%14d,", csharp ? "" : "final", table[0]); + + j = 10; + for (i = 1; i <= high; i++) + { + if (j >= 10) + { + ++outline; + putchar('\n'); + j = 1; + } + else + ++j; + + printf("%5d,", table[i]); + } + + outline += 2; + printf("\n };\n"); + FREE(table); +} + + + +output_check() +{ + register int i; + register int j; + + printf(" protected static %s short [] yyCheck = {%14d,", + csharp ? "" : "final", + check[0]); + + j = 10; + for (i = 1; i <= high; i++) + { + if (j >= 10) + { + ++outline; + putchar('\n'); + j = 1; + } + else + ++j; + + printf("%5d,", check[i]); + } + + outline += 2; + printf("\n };\n"); + FREE(check); +} + + +int +is_C_identifier(name) +char *name; +{ + register char *s; + register int c; + + s = name; + c = *s; + if (c == '"') + { + c = *++s; + if (!isalpha(c) && c != '_' && c != '$') + return (0); + while ((c = *++s) != '"') + { + if (!isalnum(c) && c != '_' && c != '$') + return (0); + } + return (1); + } + + if (!isalpha(c) && c != '_' && c != '$') + return (0); + while (c = *++s) + { + if (!isalnum(c) && c != '_' && c != '$') + return (0); + } + return (1); +} + + +output_defines(prefix) +char *prefix; +{ + register int c, i; + register char *s; + + for (i = 2; i < ntokens; ++i) + { + s = symbol_name[i]; + if (is_C_identifier(s)) + { + if (prefix) + printf(" %s ", prefix); + c = *s; + if (c == '"') + { + while ((c = *++s) != '"') + { + putchar(c); + } + } + else + { + do + { + putchar(c); + } + while (c = *++s); + } + ++outline; + printf(" = %d%s\n", symbol_value[i], csharp ? ";" : ";"); + } + } + + ++outline; + printf(" %s yyErrorCode = %d%s\n", prefix ? prefix : "", symbol_value[1], csharp ? ";" : ";"); +} + + +output_stored_text(file, name) +FILE *file; +char *name; +{ + register int c; + register FILE *in; + + fflush(file); + in = fopen(name, "r"); + if (in == NULL) + open_error(name); + if ((c = getc(in)) != EOF) { + if (c == '\n') + ++outline; + putchar(c); + while ((c = getc(in)) != EOF) + { + if (c == '\n') + ++outline; + putchar(c); + } + printf(line_format, ++outline + 1, "-"); + } + fclose(in); +} + + +output_debug() +{ + register int i, j, k, max; + char **symnam, *s; + char * prefix = tflag ? "" : "//t"; + + ++outline; + printf(" protected static %s int yyFinal = %d;\n", csharp ? "" : "final", final_state); + + ++outline; + printf("%s public static %s string [] yyRule = {\n", prefix, csharp ? "" : "final"); + for (i = 2; i < nrules; ++i) + { + printf("%s \"%s :", prefix, symbol_name[rlhs[i]]); + for (j = rrhs[i]; ritem[j] > 0; ++j) + { + s = symbol_name[ritem[j]]; + if (s[0] == '"') + { + printf(" \\\""); + while (*++s != '"') + { + if (*s == '\\') + { + if (s[1] == '\\') + printf("\\\\\\\\"); + else + printf("\\\\%c", s[1]); + ++s; + } + else + putchar(*s); + } + printf("\\\""); + } + else if (s[0] == '\'') + { + if (s[1] == '"') + printf(" '\\\"'"); + else if (s[1] == '\\') + { + if (s[2] == '\\') + printf(" '\\\\\\\\"); + else + printf(" '\\\\%c", s[2]); + s += 2; + while (*++s != '\'') + putchar(*s); + putchar('\''); + } + else + printf(" '%c'", s[1]); + } + else + printf(" %s", s); + } + ++outline; + printf("\",\n"); + } + ++ outline; + printf("%s };\n", prefix); + + max = 0; + for (i = 2; i < ntokens; ++i) + if (symbol_value[i] > max) + max = symbol_value[i]; + + /* need yyName for yyExpecting() */ + + printf(" protected static %s string [] yyName = {", csharp ? "" : "final"); + symnam = (char **) MALLOC((max+1)*sizeof(char *)); + if (symnam == 0) no_space(); + + /* Note that it is not necessary to initialize the element */ + /* symnam[max]. */ + for (i = 0; i < max; ++i) + symnam[i] = 0; + for (i = ntokens - 1; i >= 2; --i) + symnam[symbol_value[i]] = symbol_name[i]; + symnam[0] = "end-of-file"; + + j = 70; fputs(" ", stdout); + for (i = 0; i <= max; ++i) + { + if (s = symnam[i]) + { + if (s[0] == '"') + { + k = 7; + while (*++s != '"') + { + ++k; + if (*s == '\\') + { + k += 2; + if (*++s == '\\') + ++k; + } + } + j += k; + if (j > 70) + { + ++outline; + printf("\n "); + j = k; + } + printf("\"\\\""); + s = symnam[i]; + while (*++s != '"') + { + if (*s == '\\') + { + printf("\\\\"); + if (*++s == '\\') + printf("\\\\"); + else + putchar(*s); + } + else + putchar(*s); + } + printf("\\\"\","); + } + else if (s[0] == '\'') + { + if (s[1] == '"') + { + j += 7; + if (j > 70) + { + ++outline; + printf("\n "); + j = 7; + } + printf("\"'\\\"'\","); + } + else + { + k = 5; + while (*++s != '\'') + { + ++k; + if (*s == '\\') + { + k += 2; + if (*++s == '\\') + ++k; + } + } + j += k; + if (j > 70) + { + ++outline; + printf("\n "); + j = k; + } + printf("\"'"); + s = symnam[i]; + while (*++s != '\'') + { + if (*s == '\\') + { + printf("\\\\"); + if (*++s == '\\') + printf("\\\\"); + else + putchar(*s); + } + else + putchar(*s); + } + printf("'\","); + } + } + else + { + k = strlen(s) + 3; + j += k; + if (j > 70) + { + ++outline; + printf("\n "); + j = k; + } + putchar('"'); + do { putchar(*s); } while (*++s); + printf("\","); + } + } + else + { + j += 5; + if (j > 70) + { + ++outline; + printf("\n "); + j = 5; + } + printf("null,"); + } + } + outline += 2; + printf("\n };\n"); + FREE(symnam); +} + +output_trailing_text() +{ + register int c, last; + register FILE *in; + + if (line == 0) + return; + + in = input_file; + c = *cptr; + if (c == '\n') + { + ++lineno; + if ((c = getc(in)) == EOF) + return; + ++outline; + printf(line_format, lineno, input_file_name); + if (c == '\n') + ++outline; + putchar(c); + last = c; + } + else + { + ++outline; + printf(line_format, lineno, input_file_name); + do { putchar(c); } while ((c = *++cptr) != '\n'); + ++outline; + putchar('\n'); + last = '\n'; + } + + while ((c = getc(in)) != EOF) + { + if (c == '\n') + ++outline; + putchar(c); + last = c; + } + + if (last != '\n') + { + ++outline; + putchar('\n'); + } + printf(line_format, ++outline + 1, "-"); +} + + +output_semantic_actions() +{ + register int c, last; + + fclose(action_file); + action_file = fopen(action_file_name, "r"); + if (action_file == NULL) + open_error(action_file_name); + + if ((c = getc(action_file)) == EOF) + return; + + last = c; + if (c == '\n') + ++outline; + putchar(c); + while ((c = getc(action_file)) != EOF) + { + if (c == '\n') + ++outline; + putchar(c); + last = c; + } + + if (last != '\n') + { + ++outline; + putchar('\n'); + } + + printf(line_format, ++outline + 1, "-"); +} + + +free_itemsets() +{ + register core *cp, *next; + + FREE(state_table); + for (cp = first_state; cp; cp = next) + { + next = cp->next; + FREE(cp); + } +} + + +free_shifts() +{ + register shifts *sp, *next; + + FREE(shift_table); + for (sp = first_shift; sp; sp = next) + { + next = sp->next; + FREE(sp); + } +} + + + +free_reductions() +{ + register reductions *rp, *next; + + FREE(reduction_table); + for (rp = first_reduction; rp; rp = next) + { + next = rp->next; + FREE(rp); + } +} diff --git a/mcs/jay/reader.c b/mcs/jay/reader.c new file mode 100644 index 00000000000..f2cdd5af834 --- /dev/null +++ b/mcs/jay/reader.c @@ -0,0 +1,1627 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)reader.c 5.7 (Berkeley) 1/20/91"; +#endif /* not lint */ + +#include "defs.h" + +/* The line size must be a positive integer. One hundred was chosen */ +/* because few lines in Yacc input grammars exceed 100 characters. */ +/* Note that if a line exceeds LINESIZE characters, the line buffer */ +/* will be expanded to accomodate it. */ + +#define LINESIZE 100 + +char *cache; +int cinc, cache_size; + +int ntags, tagmax; +char **tag_table; + +char saw_eof; +char *cptr, *line; +int linesize; + +bucket *goal; +int prec; +int gensym; +char last_was_action; + +int maxitems; +bucket **pitem; + +int maxrules; +bucket **plhs; + +int name_pool_size; +char *name_pool; + +char *line_format = "\t\t\t\t\t// line %d \"%s\"\n"; + + +cachec(c) +int c; +{ + assert(cinc >= 0); + if (cinc >= cache_size) + { + cache_size += 256; + cache = REALLOC(cache, cache_size); + if (cache == 0) no_space(); + } + cache[cinc] = c; + ++cinc; +} + + +get_line() +{ + register FILE *f = input_file; + register int c; + register int i; + + if (saw_eof || (c = getc(f)) == EOF) + { + if (line) { FREE(line); line = 0; } + cptr = 0; + saw_eof = 1; + return; + } + + if (line == 0 || linesize != (LINESIZE + 1)) + { + if (line) FREE(line); + linesize = LINESIZE + 1; + line = MALLOC(linesize); + if (line == 0) no_space(); + } + + i = 0; + ++lineno; + for (;;) + { + line[i] = c; + if (c == '\n') { cptr = line; return; } + if (++i >= linesize) + { + linesize += LINESIZE; + line = REALLOC(line, linesize); + if (line == 0) no_space(); + } + c = getc(f); + if (c == EOF) + { + line[i] = '\n'; + saw_eof = 1; + cptr = line; + return; + } + } +} + + +char * +dup_line() +{ + register char *p, *s, *t; + + if (line == 0) return (0); + s = line; + while (*s != '\n') ++s; + p = MALLOC(s - line + 1); + if (p == 0) no_space(); + + s = line; + t = p; + while ((*t++ = *s++) != '\n') continue; + return (p); +} + + +skip_comment() +{ + register char *s; + + int st_lineno = lineno; + char *st_line = dup_line(); + char *st_cptr = st_line + (cptr - line); + + s = cptr + 2; + for (;;) + { + if (*s == '*' && s[1] == '/') + { + cptr = s + 2; + FREE(st_line); + return; + } + if (*s == '\n') + { + get_line(); + if (line == 0) + unterminated_comment(st_lineno, st_line, st_cptr); + s = cptr; + } + else + ++s; + } +} + + +int +nextc() +{ + register char *s; + + if (line == 0) + { + get_line(); + if (line == 0) + return (EOF); + } + + s = cptr; + for (;;) + { + switch (*s) + { + case '\n': + get_line(); + if (line == 0) return (EOF); + s = cptr; + break; + + case ' ': + case '\t': + case '\f': + case '\r': + case '\v': + case ',': + case ';': + ++s; + break; + + case '\\': + cptr = s; + return ('%'); + + case '/': + if (s[1] == '*') + { + cptr = s; + skip_comment(); + s = cptr; + break; + } + else if (s[1] == '/') + { + get_line(); + if (line == 0) return (EOF); + s = cptr; + break; + } + /* fall through */ + + default: + cptr = s; + return (*s); + } + } +} + + +int +keyword() +{ + register int c; + char *t_cptr = cptr; + + c = *++cptr; + if (isalpha(c)) + { + cinc = 0; + for (;;) + { + if (isalpha(c)) + { + if (isupper(c)) c = tolower(c); + cachec(c); + } + else if (isdigit(c) || c == '_' || c == '.' || c == '$') + cachec(c); + else + break; + c = *++cptr; + } + cachec(NUL); + + if (strcmp(cache, "token") == 0 || strcmp(cache, "term") == 0) + return (TOKEN); + if (strcmp(cache, "type") == 0) + return (TYPE); + if (strcmp(cache, "left") == 0) + return (LEFT); + if (strcmp(cache, "right") == 0) + return (RIGHT); + if (strcmp(cache, "nonassoc") == 0 || strcmp(cache, "binary") == 0) + return (NONASSOC); + if (strcmp(cache, "start") == 0) + return (START); + } + else + { + ++cptr; + if (c == '{') + return (TEXT); + if (c == '%' || c == '\\') + return (MARK); + if (c == '<') + return (LEFT); + if (c == '>') + return (RIGHT); + if (c == '0') + return (TOKEN); + if (c == '2') + return (NONASSOC); + } + syntax_error(lineno, line, t_cptr); + /*NOTREACHED*/ +} + + +copy_text(f) +FILE *f; +{ + register int c; + int quote; + int need_newline = 0; + int t_lineno = lineno; + char *t_line = dup_line(); + char *t_cptr = t_line + (cptr - line - 2); + + if (*cptr == '\n') + { + get_line(); + if (line == 0) + unterminated_text(t_lineno, t_line, t_cptr); + } + fprintf(f, line_format, lineno, input_file_name); + +loop: + c = *cptr++; + switch (c) + { + case '\n': + next_line: + putc('\n', f); + need_newline = 0; + get_line(); + if (line) goto loop; + unterminated_text(t_lineno, t_line, t_cptr); + + case '\'': + case '"': + { + int s_lineno = lineno; + char *s_line = dup_line(); + char *s_cptr = s_line + (cptr - line - 1); + + quote = c; + putc(c, f); + for (;;) + { + c = *cptr++; + putc(c, f); + if (c == quote) + { + need_newline = 1; + FREE(s_line); + goto loop; + } + if (c == '\n') + unterminated_string(s_lineno, s_line, s_cptr); + if (c == '\\') + { + c = *cptr++; + putc(c, f); + if (c == '\n') + { + get_line(); + if (line == 0) + unterminated_string(s_lineno, s_line, s_cptr); + } + } + } + } + + case '/': + putc(c, f); + need_newline = 1; + c = *cptr; + if (c == '/') + { + do putc(c, f); while ((c = *++cptr) != '\n'); + goto next_line; + } + if (c == '*') + { + int c_lineno = lineno; + char *c_line = dup_line(); + char *c_cptr = c_line + (cptr - line - 1); + + putc('*', f); + ++cptr; + for (;;) + { + c = *cptr++; + putc(c, f); + if (c == '*' && *cptr == '/') + { + putc('/', f); + ++cptr; + FREE(c_line); + goto loop; + } + if (c == '\n') + { + get_line(); + if (line == 0) + unterminated_comment(c_lineno, c_line, c_cptr); + } + } + } + need_newline = 1; + goto loop; + + case '%': + case '\\': + if (*cptr == '}') + { + if (need_newline) putc('\n', f); + ++cptr; + FREE(t_line); + return; + } + /* fall through */ + + default: + putc(c, f); + need_newline = 1; + goto loop; + } +} + +int +hexval(c) +int c; +{ + if (c >= '0' && c <= '9') + return (c - '0'); + if (c >= 'A' && c <= 'F') + return (c - 'A' + 10); + if (c >= 'a' && c <= 'f') + return (c - 'a' + 10); + return (-1); +} + + +bucket * +get_literal() +{ + register int c, quote; + register int i; + register int n; + register char *s; + register bucket *bp; + int s_lineno = lineno; + char *s_line = dup_line(); + char *s_cptr = s_line + (cptr - line); + + quote = *cptr++; + cinc = 0; + for (;;) + { + c = *cptr++; + if (c == quote) break; + if (c == '\n') unterminated_string(s_lineno, s_line, s_cptr); + if (c == '\\') + { + char *c_cptr = cptr - 1; + + c = *cptr++; + switch (c) + { + case '\n': + get_line(); + if (line == 0) unterminated_string(s_lineno, s_line, s_cptr); + continue; + + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + n = c - '0'; + c = *cptr; + if (IS_OCTAL(c)) + { + n = (n << 3) + (c - '0'); + c = *++cptr; + if (IS_OCTAL(c)) + { + n = (n << 3) + (c - '0'); + ++cptr; + } + } + if (n > MAXCHAR) illegal_character(c_cptr); + c = n; + break; + + case 'x': + c = *cptr++; + n = hexval(c); + if (n < 0 || n >= 16) + illegal_character(c_cptr); + for (;;) + { + c = *cptr; + i = hexval(c); + if (i < 0 || i >= 16) break; + ++cptr; + n = (n << 4) + i; + if (n > MAXCHAR) illegal_character(c_cptr); + } + c = n; + break; + + case 'a': c = 7; break; + case 'b': c = '\b'; break; + case 'f': c = '\f'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'v': c = '\v'; break; + } + } + cachec(c); + } + FREE(s_line); + + n = cinc; + s = MALLOC(n); + if (s == 0) no_space(); + + for (i = 0; i < n; ++i) + s[i] = cache[i]; + + cinc = 0; + if (n == 1) + cachec('\''); + else + cachec('"'); + + for (i = 0; i < n; ++i) + { + c = ((unsigned char *)s)[i]; + if (c == '\\' || c == cache[0]) + { + cachec('\\'); + cachec(c); + } + else if (isprint(c)) + cachec(c); + else + { + cachec('\\'); + switch (c) + { + case 7: cachec('a'); break; + case '\b': cachec('b'); break; + case '\f': cachec('f'); break; + case '\n': cachec('n'); break; + case '\r': cachec('r'); break; + case '\t': cachec('t'); break; + case '\v': cachec('v'); break; + default: + cachec(((c >> 6) & 7) + '0'); + cachec(((c >> 3) & 7) + '0'); + cachec((c & 7) + '0'); + break; + } + } + } + + if (n == 1) + cachec('\''); + else + cachec('"'); + + cachec(NUL); + bp = lookup(cache); + bp->class = TERM; + if (n == 1 && bp->value == UNDEFINED) + bp->value = *(unsigned char *)s; + FREE(s); + + return (bp); +} + + +int +is_reserved(name) +char *name; +{ + char *s; + + if (strcmp(name, ".") == 0 || + strcmp(name, "$accept") == 0 || + strcmp(name, "$end") == 0) + return (1); + + if (name[0] == '$' && name[1] == '$' && isdigit(name[2])) + { + s = name + 3; + while (isdigit(*s)) ++s; + if (*s == NUL) return (1); + } + + return (0); +} + + +bucket * +get_name() +{ + register int c; + + cinc = 0; + for (c = *cptr; IS_IDENT(c); c = *++cptr) + cachec(c); + cachec(NUL); + + if (is_reserved(cache)) used_reserved(cache); + + return (lookup(cache)); +} + + +int +get_number() +{ + register int c; + register int n; + + n = 0; + for (c = *cptr; isdigit(c); c = *++cptr) + n = 10*n + (c - '0'); + + return (n); +} + + +char * +get_tag(int emptyOk) +{ + register int c; + register int i; + register char *s; + int t_lineno = lineno; + char *t_line = dup_line(); + char *t_cptr = t_line + (cptr - line); + + ++cptr; + c = nextc(); + if (c == EOF) unexpected_EOF(); + if (emptyOk && c == '>') { + ++cptr; return 0; // 0 indicates empty tag if emptyOk + } + if (!isalpha(c) && c != '_' && c != '$') + illegal_tag(t_lineno, t_line, t_cptr); + + cinc = 0; + do { cachec(c); c = *++cptr; } while (IS_IDENT(c)); + cachec(NUL); + + c = nextc(); + if (c == EOF) unexpected_EOF(); + if (c != '>') + illegal_tag(t_lineno, t_line, t_cptr); + ++cptr; + + for (i = 0; i < ntags; ++i) + { + if (strcmp(cache, tag_table[i]) == 0) + return (tag_table[i]); + } + + if (ntags >= tagmax) + { + tagmax += 16; + tag_table = (char **) + (tag_table ? REALLOC(tag_table, tagmax*sizeof(char *)) + : MALLOC(tagmax*sizeof(char *))); + if (tag_table == 0) no_space(); + } + + s = MALLOC(cinc); + if (s == 0) no_space(); + strcpy(s, cache); + tag_table[ntags] = s; + ++ntags; + FREE(t_line); + return (s); +} + + +declare_tokens(assoc) +int assoc; +{ + register int c; + register bucket *bp; + int value; + char *tag = 0; + + if (assoc != TOKEN) ++prec; + + c = nextc(); + if (c == EOF) unexpected_EOF(); + if (c == '<') + { + tag = get_tag(0); + c = nextc(); + if (c == EOF) unexpected_EOF(); + } + + for (;;) + { + if (isalpha(c) || c == '_' || c == '.' || c == '$') + bp = get_name(); + else if (c == '\'' || c == '"') + bp = get_literal(); + else + return; + + if (bp == goal) tokenized_start(bp->name); + bp->class = TERM; + + if (tag) + { + if (bp->tag && tag != bp->tag) + retyped_warning(bp->name); + bp->tag = tag; + } + + if (assoc != TOKEN) + { + if (bp->prec && prec != bp->prec) + reprec_warning(bp->name); + bp->assoc = assoc; + bp->prec = prec; + } + + c = nextc(); + if (c == EOF) unexpected_EOF(); + value = UNDEFINED; + if (isdigit(c)) + { + value = get_number(); + if (bp->value != UNDEFINED && value != bp->value) + revalued_warning(bp->name); + bp->value = value; + c = nextc(); + if (c == EOF) unexpected_EOF(); + } + } +} + + +declare_types() +{ + register int c; + register bucket *bp; + char *tag; + + c = nextc(); + if (c == EOF) unexpected_EOF(); + if (c != '<') syntax_error(lineno, line, cptr); + tag = get_tag(0); + + for (;;) + { + c = nextc(); + if (isalpha(c) || c == '_' || c == '.' || c == '$') + bp = get_name(); + else if (c == '\'' || c == '"') + bp = get_literal(); + else + return; + + if (bp->tag && tag != bp->tag) + retyped_warning(bp->name); + bp->tag = tag; + } +} + + +declare_start() +{ + register int c; + register bucket *bp; + + c = nextc(); + if (c == EOF) unexpected_EOF(); + if (!isalpha(c) && c != '_' && c != '.' && c != '$') + syntax_error(lineno, line, cptr); + bp = get_name(); + if (bp->class == TERM) + terminal_start(bp->name); + if (goal && goal != bp) + restarted_warning(); + goal = bp; +} + + +read_declarations() +{ + register int c, k; + + cache_size = 256; + cache = MALLOC(cache_size); + if (cache == 0) no_space(); + + for (;;) + { + c = nextc(); + if (c == EOF) unexpected_EOF(); + if (c != '%') syntax_error(lineno, line, cptr); + switch (k = keyword()) + { + case MARK: + return; + + case TEXT: + copy_text(prolog_file); + break; + + case TOKEN: + case LEFT: + case RIGHT: + case NONASSOC: + declare_tokens(k); + break; + + case TYPE: + declare_types(); + break; + + case START: + declare_start(); + break; + } + } +} + + +initialize_grammar() +{ + nitems = 4; + maxitems = 300; + pitem = (bucket **) MALLOC(maxitems*sizeof(bucket *)); + if (pitem == 0) no_space(); + pitem[0] = 0; + pitem[1] = 0; + pitem[2] = 0; + pitem[3] = 0; + + nrules = 3; + maxrules = 100; + plhs = (bucket **) MALLOC(maxrules*sizeof(bucket *)); + if (plhs == 0) no_space(); + plhs[0] = 0; + plhs[1] = 0; + plhs[2] = 0; + rprec = (short *) MALLOC(maxrules*sizeof(short)); + if (rprec == 0) no_space(); + rprec[0] = 0; + rprec[1] = 0; + rprec[2] = 0; + rassoc = (char *) MALLOC(maxrules*sizeof(char)); + if (rassoc == 0) no_space(); + rassoc[0] = TOKEN; + rassoc[1] = TOKEN; + rassoc[2] = TOKEN; +} + + +expand_items() +{ + maxitems += 300; + pitem = (bucket **) REALLOC(pitem, maxitems*sizeof(bucket *)); + if (pitem == 0) no_space(); +} + + +expand_rules() +{ + maxrules += 100; + plhs = (bucket **) REALLOC(plhs, maxrules*sizeof(bucket *)); + if (plhs == 0) no_space(); + rprec = (short *) REALLOC(rprec, maxrules*sizeof(short)); + if (rprec == 0) no_space(); + rassoc = (char *) REALLOC(rassoc, maxrules*sizeof(char)); + if (rassoc == 0) no_space(); +} + + +advance_to_start() +{ + register int c; + register bucket *bp; + char *s_cptr; + int s_lineno; + + for (;;) + { + c = nextc(); + if (c != '%') break; + s_cptr = cptr; + switch (keyword()) + { + case MARK: + no_grammar(); + + case TEXT: + copy_text(local_file); + break; + + case START: + declare_start(); + break; + + default: + syntax_error(lineno, line, s_cptr); + } + } + + c = nextc(); + if (!isalpha(c) && c != '_' && c != '.' && c != '_') + syntax_error(lineno, line, cptr); + bp = get_name(); + if (goal == 0) + { + if (bp->class == TERM) + terminal_start(bp->name); + goal = bp; + } + + s_lineno = lineno; + c = nextc(); + if (c == EOF) unexpected_EOF(); + if (c != ':') syntax_error(lineno, line, cptr); + start_rule(bp, s_lineno); + ++cptr; +} + + +start_rule(bp, s_lineno) +register bucket *bp; +int s_lineno; +{ + if (bp->class == TERM) + terminal_lhs(s_lineno); + bp->class = NONTERM; + if (nrules >= maxrules) + expand_rules(); + plhs[nrules] = bp; + rprec[nrules] = UNDEFINED; + rassoc[nrules] = TOKEN; +} + + +end_rule() +{ + register int i; + + if (!last_was_action && plhs[nrules]->tag) + { + for (i = nitems - 1; pitem[i]; --i) continue; + if (pitem[i+1] == 0 || pitem[i+1]->tag != plhs[nrules]->tag) + default_action_warning(); /** if classes don't match exactly **/ + } /** bug: could be superclass... **/ + + last_was_action = 0; + if (nitems >= maxitems) expand_items(); + pitem[nitems] = 0; + ++nitems; + ++nrules; +} + + +insert_empty_rule() +{ + register bucket *bp, **bpp; + + assert(cache); + sprintf(cache, "$$%d", ++gensym); + bp = make_bucket(cache); + last_symbol->next = bp; + last_symbol = bp; + bp->tag = plhs[nrules]->tag; + bp->class = NONTERM; + + if ((nitems += 2) > maxitems) + expand_items(); + bpp = pitem + nitems - 1; + *bpp-- = bp; + while (bpp[0] = bpp[-1]) --bpp; + + if (++nrules >= maxrules) + expand_rules(); + plhs[nrules] = plhs[nrules-1]; + plhs[nrules-1] = bp; + rprec[nrules] = rprec[nrules-1]; + rprec[nrules-1] = 0; + rassoc[nrules] = rassoc[nrules-1]; + rassoc[nrules-1] = TOKEN; +} + + +add_symbol() +{ + register int c; + register bucket *bp; + int s_lineno = lineno; + + c = *cptr; + if (c == '\'' || c == '"') + bp = get_literal(); + else + bp = get_name(); + + c = nextc(); + if (c == ':') + { + end_rule(); + start_rule(bp, s_lineno); + ++cptr; + return; + } + + if (last_was_action) + insert_empty_rule(); + last_was_action = 0; + + if (++nitems > maxitems) + expand_items(); + pitem[nitems-1] = bp; +} + + +copy_action() +{ + register int c; + register int i, n; + int depth; + int quote; + char *tag; + register FILE *f = action_file; + int a_lineno = lineno; + char *a_line = dup_line(); + char *a_cptr = a_line + (cptr - line); + + if (last_was_action) + insert_empty_rule(); + last_was_action = 1; + + fprintf(f, "case %d:\n", nrules - 2); + fprintf(f, line_format, lineno, input_file_name); + putc(' ', f); putc(' ', f); + if (*cptr == '=') ++cptr; + + n = 0; + for (i = nitems - 1; pitem[i]; --i) ++n; + + depth = 0; +loop: + c = *cptr; + if (c == '$') + { + if (cptr[1] == '<') + { + int d_lineno = lineno; + char *d_line = dup_line(); + char *d_cptr = d_line + (cptr - line); + + ++cptr; + tag = get_tag(1); + c = *cptr; + if (c == '$') + { if (tag && strcmp(tag, "Object")) + fprintf(f, "((%s)yyVal)", tag); + else fprintf(f, "yyVal"); + ++cptr; + FREE(d_line); + goto loop; + } + else if (isdigit(c)) + { + i = get_number(); + if (i > n) dollar_warning(d_lineno, i); + if (tag && strcmp(tag, "Object")) + fprintf(f, "((%s)yyVals[%d+yyTop])", tag, i - n); + else fprintf(f, "yyVals[%d+yyTop]", i - n); + FREE(d_line); + goto loop; + } + else if (c == '-' && isdigit(cptr[1])) + { + ++cptr; + i = -get_number() - n; + if (tag && strcmp(tag, "Object")) + fprintf(f, "((%s)yyVals[%d+yyTop])", tag, i); + else fprintf(f, "yyVals[%d+yyTop]", tag, i); + FREE(d_line); + goto loop; + } + else + dollar_error(d_lineno, d_line, d_cptr); + } + else if (cptr[1] == '$') + { + if (ntags && plhs[nrules]->tag == 0) + untyped_lhs(); + fprintf(f, "yyVal"); + cptr += 2; + goto loop; + } + else if (isdigit(cptr[1])) + { + ++cptr; + i = get_number(); + if (ntags) + { + if (i <= 0 || i > n) + unknown_rhs(i); + tag = pitem[nitems + i - n - 1]->tag; + if (tag == 0) + untyped_rhs(i, pitem[nitems + i - n - 1]->name), + fprintf(f, "yyVals[%d+yyTop]", i - n); + else if (strcmp(tag, "Object")) + fprintf(f, "((%s)yyVals[%d+yyTop])", tag, i - n); + else + fprintf(f, "yyVals[%d+yyTop]", i - n); + } + else + { + if (i > n) + dollar_warning(lineno, i); + fprintf(f, "yyVals[%d+yyTop]", i - n); + } + goto loop; + } + else if (cptr[1] == '-') + { + cptr += 2; + i = get_number(); + if (ntags) + unknown_rhs(-i); + fprintf(f, "yyVals[%d+yyTop]", -i - n); + goto loop; + } + } + if (isalpha(c) || c == '_' || c == '$') + { + do + { + putc(c, f); + c = *++cptr; + } while (isalnum(c) || c == '_' || c == '$'); + goto loop; + } + putc(c, f); + ++cptr; + switch (c) + { + case '\n': + next_line: + get_line(); + if (line) goto loop; + unterminated_action(a_lineno, a_line, a_cptr); + + case ';': + if (depth > 0) goto loop; + fprintf(f, "\nbreak;\n"); + return; + + case '{': + ++depth; + goto loop; + + case '}': + if (--depth > 0) goto loop; + fprintf(f, "\n break;\n"); + return; + + case '\'': + case '"': + { + int s_lineno = lineno; + char *s_line = dup_line(); + char *s_cptr = s_line + (cptr - line - 1); + + quote = c; + for (;;) + { + c = *cptr++; + putc(c, f); + if (c == quote) + { + FREE(s_line); + goto loop; + } + if (c == '\n') + unterminated_string(s_lineno, s_line, s_cptr); + if (c == '\\') + { + c = *cptr++; + putc(c, f); + if (c == '\n') + { + get_line(); + if (line == 0) + unterminated_string(s_lineno, s_line, s_cptr); + } + } + } + } + + case '/': + c = *cptr; + if (c == '/') + { + putc('*', f); + while ((c = *++cptr) != '\n') + { + if (c == '*' && cptr[1] == '/') + fprintf(f, "* "); + else + putc(c, f); + } + fprintf(f, "*/\n"); + goto next_line; + } + if (c == '*') + { + int c_lineno = lineno; + char *c_line = dup_line(); + char *c_cptr = c_line + (cptr - line - 1); + + putc('*', f); + ++cptr; + for (;;) + { + c = *cptr++; + putc(c, f); + if (c == '*' && *cptr == '/') + { + putc('/', f); + ++cptr; + FREE(c_line); + goto loop; + } + if (c == '\n') + { + get_line(); + if (line == 0) + unterminated_comment(c_lineno, c_line, c_cptr); + } + } + } + goto loop; + + default: + goto loop; + } +} + + +int +mark_symbol() +{ + register int c; + register bucket *bp; + + c = cptr[1]; + if (c == '%' || c == '\\') + { + cptr += 2; + return (1); + } + + if (c == '=') + cptr += 2; + else if ((c == 'p' || c == 'P') && + ((c = cptr[2]) == 'r' || c == 'R') && + ((c = cptr[3]) == 'e' || c == 'E') && + ((c = cptr[4]) == 'c' || c == 'C') && + ((c = cptr[5], !IS_IDENT(c)))) + cptr += 5; + else + syntax_error(lineno, line, cptr); + + c = nextc(); + if (isalpha(c) || c == '_' || c == '.' || c == '$') + bp = get_name(); + else if (c == '\'' || c == '"') + bp = get_literal(); + else + { + syntax_error(lineno, line, cptr); + /*NOTREACHED*/ + } + + if (rprec[nrules] != UNDEFINED && bp->prec != rprec[nrules]) + prec_redeclared(); + + rprec[nrules] = bp->prec; + rassoc[nrules] = bp->assoc; + return (0); +} + + +read_grammar() +{ + register int c; + + initialize_grammar(); + advance_to_start(); + + for (;;) + { + c = nextc(); + if (c == EOF) break; + if (isalpha(c) || c == '_' || c == '.' || c == '$' || c == '\'' || + c == '"') + add_symbol(); + else if (c == '{' || c == '=') + copy_action(); + else if (c == '|') + { + end_rule(); + start_rule(plhs[nrules-1], 0); + ++cptr; + } + else if (c == '%') + { + if (mark_symbol()) break; + } + else + syntax_error(lineno, line, cptr); + } + end_rule(); +} + + +free_tags() +{ + register int i; + + if (tag_table == 0) return; + + for (i = 0; i < ntags; ++i) + { + assert(tag_table[i]); + FREE(tag_table[i]); + } + FREE(tag_table); +} + + +pack_names() +{ + register bucket *bp; + register char *p, *s, *t; + + name_pool_size = 13; /* 13 == sizeof("$end") + sizeof("$accept") */ + for (bp = first_symbol; bp; bp = bp->next) + name_pool_size += strlen(bp->name) + 1; + name_pool = MALLOC(name_pool_size); + if (name_pool == 0) no_space(); + + strcpy(name_pool, "$accept"); + strcpy(name_pool+8, "$end"); + t = name_pool + 13; + for (bp = first_symbol; bp; bp = bp->next) + { + p = t; + s = bp->name; + while (*t++ = *s++) continue; + FREE(bp->name); + bp->name = p; + } +} + + +check_symbols() +{ + register bucket *bp; + + if (goal->class == UNKNOWN) + undefined_goal(goal->name); + + for (bp = first_symbol; bp; bp = bp->next) + { + if (bp->class == UNKNOWN) + { + undefined_symbol_warning(bp->name); + bp->class = TERM; + } + } +} + + +pack_symbols() +{ + register bucket *bp; + register bucket **v; + register int i, j, k, n; + + nsyms = 2; + ntokens = 1; + for (bp = first_symbol; bp; bp = bp->next) + { + ++nsyms; + if (bp->class == TERM) ++ntokens; + } + start_symbol = ntokens; + nvars = nsyms - ntokens; + + symbol_name = (char **) MALLOC(nsyms*sizeof(char *)); + if (symbol_name == 0) no_space(); + symbol_value = (short *) MALLOC(nsyms*sizeof(short)); + if (symbol_value == 0) no_space(); + symbol_prec = (short *) MALLOC(nsyms*sizeof(short)); + if (symbol_prec == 0) no_space(); + symbol_assoc = MALLOC(nsyms); + if (symbol_assoc == 0) no_space(); + + v = (bucket **) MALLOC(nsyms*sizeof(bucket *)); + if (v == 0) no_space(); + + v[0] = 0; + v[start_symbol] = 0; + + i = 1; + j = start_symbol + 1; + for (bp = first_symbol; bp; bp = bp->next) + { + if (bp->class == TERM) + v[i++] = bp; + else + v[j++] = bp; + } + assert(i == ntokens && j == nsyms); + + for (i = 1; i < ntokens; ++i) + v[i]->index = i; + + goal->index = start_symbol + 1; + k = start_symbol + 2; + while (++i < nsyms) + if (v[i] != goal) + { + v[i]->index = k; + ++k; + } + + goal->value = 0; + k = 1; + for (i = start_symbol + 1; i < nsyms; ++i) + { + if (v[i] != goal) + { + v[i]->value = k; + ++k; + } + } + + k = 0; + for (i = 1; i < ntokens; ++i) + { + n = v[i]->value; + if (n > 256) + { + for (j = k++; j > 0 && symbol_value[j-1] > n; --j) + symbol_value[j] = symbol_value[j-1]; + symbol_value[j] = n; + } + } + + if (v[1]->value == UNDEFINED) + v[1]->value = 256; + + j = 0; + n = 257; + for (i = 2; i < ntokens; ++i) + { + if (v[i]->value == UNDEFINED) + { + while (j < k && n == symbol_value[j]) + { + while (++j < k && n == symbol_value[j]) continue; + ++n; + } + v[i]->value = n; + ++n; + } + } + + symbol_name[0] = name_pool + 8; + symbol_value[0] = 0; + symbol_prec[0] = 0; + symbol_assoc[0] = TOKEN; + for (i = 1; i < ntokens; ++i) + { + symbol_name[i] = v[i]->name; + symbol_value[i] = v[i]->value; + symbol_prec[i] = v[i]->prec; + symbol_assoc[i] = v[i]->assoc; + } + symbol_name[start_symbol] = name_pool; + symbol_value[start_symbol] = -1; + symbol_prec[start_symbol] = 0; + symbol_assoc[start_symbol] = TOKEN; + for (++i; i < nsyms; ++i) + { + k = v[i]->index; + symbol_name[k] = v[i]->name; + symbol_value[k] = v[i]->value; + symbol_prec[k] = v[i]->prec; + symbol_assoc[k] = v[i]->assoc; + } + + FREE(v); +} + + +pack_grammar() +{ + register int i, j; + int assoc, prec; + + ritem = (short *) MALLOC(nitems*sizeof(short)); + if (ritem == 0) no_space(); + rlhs = (short *) MALLOC(nrules*sizeof(short)); + if (rlhs == 0) no_space(); + rrhs = (short *) MALLOC((nrules+1)*sizeof(short)); + if (rrhs == 0) no_space(); + rprec = (short *) REALLOC(rprec, nrules*sizeof(short)); + if (rprec == 0) no_space(); + rassoc = REALLOC(rassoc, nrules); + if (rassoc == 0) no_space(); + + ritem[0] = -1; + ritem[1] = goal->index; + ritem[2] = 0; + ritem[3] = -2; + rlhs[0] = 0; + rlhs[1] = 0; + rlhs[2] = start_symbol; + rrhs[0] = 0; + rrhs[1] = 0; + rrhs[2] = 1; + + j = 4; + for (i = 3; i < nrules; ++i) + { + rlhs[i] = plhs[i]->index; + rrhs[i] = j; + assoc = TOKEN; + prec = 0; + while (pitem[j]) + { + ritem[j] = pitem[j]->index; + if (pitem[j]->class == TERM) + { + prec = pitem[j]->prec; + assoc = pitem[j]->assoc; + } + ++j; + } + ritem[j] = -i; + ++j; + if (rprec[i] == UNDEFINED) + { + rprec[i] = prec; + rassoc[i] = assoc; + } + } + rrhs[i] = j; + + FREE(plhs); + FREE(pitem); +} + + +print_grammar() +{ + register int i, j, k; + int spacing; + register FILE *f = verbose_file; + + if (!vflag) return; + + k = 1; + for (i = 2; i < nrules; ++i) + { + if (rlhs[i] != rlhs[i-1]) + { + if (i != 2) fprintf(f, "\n"); + fprintf(f, "%4d %s :", i - 2, symbol_name[rlhs[i]]); + spacing = strlen(symbol_name[rlhs[i]]) + 1; + } + else + { + fprintf(f, "%4d ", i - 2); + j = spacing; + while (--j >= 0) putc(' ', f); + putc('|', f); + } + + while (ritem[k] >= 0) + { + fprintf(f, " %s", symbol_name[ritem[k]]); + ++k; + } + ++k; + putc('\n', f); + } +} + + +reader() +{ + create_symbol_table(); + read_declarations(); + read_grammar(); + free_symbol_table(); + free_tags(); + pack_names(); + check_symbols(); + pack_symbols(); + pack_grammar(); + free_symbols(); + print_grammar(); +} diff --git a/mcs/jay/skeleton b/mcs/jay/skeleton new file mode 100644 index 00000000000..07135c082f2 --- /dev/null +++ b/mcs/jay/skeleton @@ -0,0 +1,268 @@ +# jay skeleton + +# character in column 1 determines outcome... +# # is a comment +# . is copied +# t is copied as //t if -t is set +# other lines are interpreted to call jay procedures + +.// created by jay 0.7 (c) 1998 Axel.Schreiner@informatik.uni-osnabrueck.de +. + prolog ## %{ ... %} prior to the first %% + +.// %token constants +. + tokens public static final int +. +. /** thrown for irrecoverable syntax errors and stack overflow. +. */ +. public static class yyException extends java.lang.Exception { +. public yyException (String message) { +. super(message); +. } +. } +. +. /** must be implemented by a scanner object to supply input to the parser. +. */ +. public interface yyInput { +. /** move on to next token. +. @return false if positioned beyond tokens. +. @throws IOException on input error. +. */ +. boolean advance () throws java.io.IOException; +. /** classifies current token. +. Should not be called if advance() returned false. +. @return current %token or single character. +. */ +. int token (); +. /** associated with current token. +. Should not be called if advance() returned false. +. @return value for token(). +. */ +. Object value (); +. } +. +. /** simplified error message. +. @see <a href="#yyerror(java.lang.String, java.lang.String[])">yyerror</a> +. */ +. public void yyerror (String message) { +. yyerror(message, null); +. } +. +. /** (syntax) error message. +. Can be overwritten to control message format. +. @param message text to be displayed. +. @param expected vector of acceptable tokens, if available. +. */ +. public void yyerror (String message, String[] expected) { +. if (expected != null && expected.length > 0) { +. System.err.print(message+", expecting"); +. for (int n = 0; n < expected.length; ++ n) +. System.err.print(" "+expected[n]); +. System.err.println(); +. } else +. System.err.println(message); +. } +. +. /** debugging support, requires the package jay.yydebug. +. Set to null to suppress debugging messages. +. */ +t protected jay.yydebug.yyDebug yydebug; +. + debug ## tables for debugging support +. +. /** index-checked interface to yyName[]. +. @param token single character or %token value. +. @return token name or [illegal] or [unknown]. +. */ +t public static final String yyname (int token) { +t if (token < 0 || token > yyName.length) return "[illegal]"; +t String name; +t if ((name = yyName[token]) != null) return name; +t return "[unknown]"; +t } +. +. /** computes list of expected tokens on error by tracing the tables. +. @param state for which to compute the list. +. @return list of token names. +. */ +. protected String[] yyExpecting (int state) { +. int token, n, len = 0; +. boolean[] ok = new boolean[yyName.length]; +. +. if ((n = yySindex[state]) != 0) +. for (token = n < 0 ? -n : 0; +. token < yyName.length && n+token < yyTable.length; ++ token) +. if (yyCheck[n+token] == token && !ok[token] && yyName[token] != null) { +. ++ len; +. ok[token] = true; +. } +. if ((n = yyRindex[state]) != 0) +. for (token = n < 0 ? -n : 0; +. token < yyName.length && n+token < yyTable.length; ++ token) +. if (yyCheck[n+token] == token && !ok[token] && yyName[token] != null) { +. ++ len; +. ok[token] = true; +. } +. +. String result[] = new String[len]; +. for (n = token = 0; n < len; ++ token) +. if (ok[token]) result[n++] = yyName[token]; +. return result; +. } +. +. /** the generated parser, with debugging messages. +. Maintains a state and a value stack, currently with fixed maximum size. +. @param yyLex scanner. +. @param yydebug debug message writer implementing yyDebug, or null. +. @return result of the last reduction, if any. +. @throws yyException on irrecoverable parse error. +. */ +. public Object yyparse (yyInput yyLex, Object yydebug) +. throws java.io.IOException, yyException { +t this.yydebug = (jay.yydebug.yyDebug)yydebug; +. return yyparse(yyLex); +. } +. +. /** initial size and increment of the state/value stack [default 256]. +. This is not final so that it can be overwritten outside of invocations +. of yyparse(). +. */ +. protected int yyMax; +. +. /** executed at the beginning of a reduce action. +. Used as $$ = yyDefault($1), prior to the user-specified action, if any. +. Can be overwritten to provide deep copy, etc. +. @param first value for $1, or null. +. @return first. +. */ +. protected Object yyDefault (Object first) { +. return first; +. } +. +. /** the generated parser. +. Maintains a state and a value stack, currently with fixed maximum size. +. @param yyLex scanner. +. @return result of the last reduction, if any. +. @throws yyException on irrecoverable parse error. +. */ +. public Object yyparse (yyInput yyLex) +. throws java.io.IOException, yyException { +. if (yyMax <= 0) yyMax = 256; // initial size +. int yyState = 0, yyStates[] = new int[yyMax]; // state stack +. Object yyVal = null, yyVals[] = new Object[yyMax]; // value stack +. int yyToken = -1; // current input +. int yyErrorFlag = 0; // #tks to shift +. + local ## %{ ... %} after the first %% + +. yyLoop: for (int yyTop = 0;; ++ yyTop) { +. if (yyTop >= yyStates.length) { // dynamically increase +. int[] i = new int[yyStates.length+yyMax]; +. System.arraycopy(yyStates, 0, i, 0, yyStates.length); +. yyStates = i; +. Object[] o = new Object[yyVals.length+yyMax]; +. System.arraycopy(yyVals, 0, o, 0, yyVals.length); +. yyVals = o; +. } +. yyStates[yyTop] = yyState; +. yyVals[yyTop] = yyVal; +t if (yydebug != null) yydebug.push(yyState, yyVal); +. +. yyDiscarded: for (;;) { // discarding a token does not change stack +. int yyN; +. if ((yyN = yyDefRed[yyState]) == 0) { // else [default] reduce (yyN) +. if (yyToken < 0) { +. yyToken = yyLex.advance() ? yyLex.token() : 0; +t if (yydebug != null) +t yydebug.lex(yyState, yyToken, yyname(yyToken), yyLex.value()); +. } +. if ((yyN = yySindex[yyState]) != 0 && (yyN += yyToken) >= 0 +. && yyN < yyTable.length && yyCheck[yyN] == yyToken) { +t if (yydebug != null) +t yydebug.shift(yyState, yyTable[yyN], yyErrorFlag-1); +. yyState = yyTable[yyN]; // shift to yyN +. yyVal = yyLex.value(); +. yyToken = -1; +. if (yyErrorFlag > 0) -- yyErrorFlag; +. continue yyLoop; +. } +. if ((yyN = yyRindex[yyState]) != 0 && (yyN += yyToken) >= 0 +. && yyN < yyTable.length && yyCheck[yyN] == yyToken) +. yyN = yyTable[yyN]; // reduce (yyN) +. else +. switch (yyErrorFlag) { +. +. case 0: +. yyerror("syntax error", yyExpecting(yyState)); +t if (yydebug != null) yydebug.error("syntax error"); +. +. case 1: case 2: +. yyErrorFlag = 3; +. do { +. if ((yyN = yySindex[yyStates[yyTop]]) != 0 +. && (yyN += yyErrorCode) >= 0 && yyN < yyTable.length +. && yyCheck[yyN] == yyErrorCode) { +t if (yydebug != null) +t yydebug.shift(yyStates[yyTop], yyTable[yyN], 3); +. yyState = yyTable[yyN]; +. yyVal = yyLex.value(); +. continue yyLoop; +. } +t if (yydebug != null) yydebug.pop(yyStates[yyTop]); +. } while (-- yyTop >= 0); +t if (yydebug != null) yydebug.reject(); +. throw new yyException("irrecoverable syntax error"); +. +. case 3: +. if (yyToken == 0) { +t if (yydebug != null) yydebug.reject(); +. throw new yyException("irrecoverable syntax error at end-of-file"); +. } +t if (yydebug != null) +t yydebug.discard(yyState, yyToken, yyname(yyToken), +t yyLex.value()); +. yyToken = -1; +. continue yyDiscarded; // leave stack alone +. } +. } +. int yyV = yyTop + 1-yyLen[yyN]; +t if (yydebug != null) +t yydebug.reduce(yyState, yyStates[yyV-1], yyN, yyRule[yyN], yyLen[yyN]); +. yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]); +. switch (yyN) { + + actions ## code from the actions within the grammar + +. } +. yyTop -= yyLen[yyN]; +. yyState = yyStates[yyTop]; +. int yyM = yyLhs[yyN]; +. if (yyState == 0 && yyM == 0) { +t if (yydebug != null) yydebug.shift(0, yyFinal); +. yyState = yyFinal; +. if (yyToken < 0) { +. yyToken = yyLex.advance() ? yyLex.token() : 0; +t if (yydebug != null) +t yydebug.lex(yyState, yyToken,yyname(yyToken), yyLex.value()); +. } +. if (yyToken == 0) { +t if (yydebug != null) yydebug.accept(yyVal); +. return yyVal; +. } +. continue yyLoop; +. } +. if ((yyN = yyGindex[yyM]) != 0 && (yyN += yyState) >= 0 +. && yyN < yyTable.length && yyCheck[yyN] == yyState) +. yyState = yyTable[yyN]; +. else +. yyState = yyDgoto[yyM]; +t if (yydebug != null) yydebug.shift(yyStates[yyTop], yyState); +. continue yyLoop; +. } +. } +. } +. + tables ## tables for rules, default reduction, and action calls +. + epilog ## text following second %% diff --git a/mcs/jay/skeleton.cs b/mcs/jay/skeleton.cs new file mode 100644 index 00000000000..9dd1186651f --- /dev/null +++ b/mcs/jay/skeleton.cs @@ -0,0 +1,351 @@ +# jay skeleton + +# character in column 1 determines outcome... +# # is a comment +# . is copied +# t is copied as //t if -t is set +# other lines are interpreted to call jay procedures + +.// created by jay 0.7 (c) 1998 Axel.Schreiner@informatik.uni-osnabrueck.de +. + prolog ## %{ ... %} prior to the first %% + +. +. /** simplified error message. +. @see <a href="#yyerror(java.lang.String, java.lang.String[])">yyerror</a> +. */ +. public void yyerror (string message) { +. yyerror(message, null); +. } +. +. /** (syntax) error message. +. Can be overwritten to control message format. +. @param message text to be displayed. +. @param expected vector of acceptable tokens, if available. +. */ +. public void yyerror (string message, string[] expected) { +. if ((expected != null) && (expected.Length > 0)) { +. System.Console.Write (message+", expecting"); +. for (int n = 0; n < expected.Length; ++ n) +. System.Console.Write (" "+expected[n]); +. System.Console.WriteLine (); +. } else +. System.Console.WriteLine (message); +. } +. +. /** debugging support, requires the package jay.yydebug. +. Set to null to suppress debugging messages. +. */ +t protected yydebug.yyDebug yydebug; +. + debug ## tables for debugging support +. +. /** index-checked interface to yyName[]. +. @param token single character or %token value. +. @return token name or [illegal] or [unknown]. +. */ +t public static string yyname (int token) { +t if ((token < 0) || (token > yyName.Length)) return "[illegal]"; +t string name; +t if ((name = yyName[token]) != null) return name; +t return "[unknown]"; +t } +. +. /** computes list of expected tokens on error by tracing the tables. +. @param state for which to compute the list. +. @return list of token names. +. */ +. protected string[] yyExpecting (int state) { +. int token, n, len = 0; +. bool[] ok = new bool[yyName.Length]; +. +. if ((n = yySindex[state]) != 0) +. for (token = n < 0 ? -n : 0; +. (token < yyName.Length) && (n+token < yyTable.Length); ++ token) +. if (yyCheck[n+token] == token && !ok[token] && yyName[token] != null) { +. ++ len; +. ok[token] = true; +. } +. if ((n = yyRindex[state]) != 0) +. for (token = n < 0 ? -n : 0; +. (token < yyName.Length) && (n+token < yyTable.Length); ++ token) +. if (yyCheck[n+token] == token && !ok[token] && yyName[token] != null) { +. ++ len; +. ok[token] = true; +. } +. +. string [] result = new string[len]; +. for (n = token = 0; n < len; ++ token) +. if (ok[token]) result[n++] = yyName[token]; +. return result; +. } +. +. /** the generated parser, with debugging messages. +. Maintains a state and a value stack, currently with fixed maximum size. +. @param yyLex scanner. +. @param yydebug debug message writer implementing yyDebug, or null. +. @return result of the last reduction, if any. +. @throws yyException on irrecoverable parse error. +. */ +. public Object yyparse (yyParser.yyInput yyLex, Object yydebug) +. { +t this.yydebug = (yydebug.yyDebug)yydebug; +. return yyparse(yyLex); +. } +. +. /** initial size and increment of the state/value stack [default 256]. +. This is not final so that it can be overwritten outside of invocations +. of yyparse(). +. */ +. protected int yyMax; +. +. /** executed at the beginning of a reduce action. +. Used as $$ = yyDefault($1), prior to the user-specified action, if any. +. Can be overwritten to provide deep copy, etc. +. @param first value for $1, or null. +. @return first. +. */ +. protected Object yyDefault (Object first) { +. return first; +. } +. +. /** the generated parser. +. Maintains a state and a value stack, currently with fixed maximum size. +. @param yyLex scanner. +. @return result of the last reduction, if any. +. @throws yyException on irrecoverable parse error. +. */ +. public Object yyparse (yyParser.yyInput yyLex) +. { +. if (yyMax <= 0) yyMax = 256; // initial size +. int yyState = 0; // state stack ptr +. int [] yyStates = new int[yyMax]; // state stack +. Object yyVal = null; // value stack ptr +. Object [] yyVals = new Object[yyMax]; // value stack +. int yyToken = -1; // current input +. int yyErrorFlag = 0; // #tks to shift +. + local ## %{ ... %} after the first %% + +. int yyTop = 0; +. goto skip; +. yyLoop: +. yyTop++; +. skip: +. for (;; ++ yyTop) { +. if (yyTop >= yyStates.Length) { // dynamically increase +. int[] i = new int[yyStates.Length+yyMax]; +. System.Array.Copy(yyStates, i, 0); +. yyStates = i; +. Object[] o = new Object[yyVals.Length+yyMax]; +. System.Array.Copy(yyVals, o, 0); +. yyVals = o; +. } +. yyStates[yyTop] = yyState; +. yyVals[yyTop] = yyVal; +t if (yydebug != null) yydebug.push(yyState, yyVal); +. +. yyDiscarded: for (;;) { // discarding a token does not change stack +. int yyN; +. if ((yyN = yyDefRed[yyState]) == 0) { // else [default] reduce (yyN) +. if (yyToken < 0) { +. yyToken = yyLex.advance() ? yyLex.token() : 0; +t if (yydebug != null) +t yydebug.lex(yyState, yyToken, yyname(yyToken), yyLex.value()); +. } +. if ((yyN = yySindex[yyState]) != 0 && ((yyN += yyToken) >= 0) +. && (yyN < yyTable.Length) && (yyCheck[yyN] == yyToken)) { +t if (yydebug != null) +t yydebug.shift(yyState, yyTable[yyN], yyErrorFlag-1); +. yyState = yyTable[yyN]; // shift to yyN +. yyVal = yyLex.value(); +. yyToken = -1; +. if (yyErrorFlag > 0) -- yyErrorFlag; +. goto yyLoop; +. } +. if ((yyN = yyRindex[yyState]) != 0 && (yyN += yyToken) >= 0 +. && yyN < yyTable.Length && yyCheck[yyN] == yyToken) +. yyN = yyTable[yyN]; // reduce (yyN) +. else +. switch (yyErrorFlag) { +. +. case 0: +. yyerror("syntax error", yyExpecting(yyState)); +t if (yydebug != null) yydebug.error("syntax error"); +. goto case 1; +. case 1: case 2: +. yyErrorFlag = 3; +. do { +. if ((yyN = yySindex[yyStates[yyTop]]) != 0 +. && (yyN += Token.yyErrorCode) >= 0 && yyN < yyTable.Length +. && yyCheck[yyN] == Token.yyErrorCode) { +t if (yydebug != null) +t yydebug.shift(yyStates[yyTop], yyTable[yyN], 3); +. yyState = yyTable[yyN]; +. yyVal = yyLex.value(); +. goto yyLoop; +. } +t if (yydebug != null) yydebug.pop(yyStates[yyTop]); +. } while (-- yyTop >= 0); +t if (yydebug != null) yydebug.reject(); +. throw new yyParser.yyException("irrecoverable syntax error"); +. +. case 3: +. if (yyToken == 0) { +t if (yydebug != null) yydebug.reject(); +. throw new yyParser.yyException("irrecoverable syntax error at end-of-file"); +. } +t if (yydebug != null) +t yydebug.discard(yyState, yyToken, yyname(yyToken), +t yyLex.value()); +. yyToken = -1; +. goto yyDiscarded; // leave stack alone +. } +. } +. int yyV = yyTop + 1-yyLen[yyN]; +t if (yydebug != null) +t yydebug.reduce(yyState, yyStates[yyV-1], yyN, yyRule[yyN], yyLen[yyN]); +. yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]); +. switch (yyN) { + + actions ## code from the actions within the grammar + +. } +. yyTop -= yyLen[yyN]; +. yyState = yyStates[yyTop]; +. int yyM = yyLhs[yyN]; +. if (yyState == 0 && yyM == 0) { +t if (yydebug != null) yydebug.shift(0, yyFinal); +. yyState = yyFinal; +. if (yyToken < 0) { +. yyToken = yyLex.advance() ? yyLex.token() : 0; +t if (yydebug != null) +t yydebug.lex(yyState, yyToken,yyname(yyToken), yyLex.value()); +. } +. if (yyToken == 0) { +t if (yydebug != null) yydebug.accept(yyVal); +. return yyVal; +. } +. goto yyLoop; +. } +. if (((yyN = yyGindex[yyM]) != 0) && ((yyN += yyState) >= 0) +. && (yyN < yyTable.Length) && (yyCheck[yyN] == yyState)) +. yyState = yyTable[yyN]; +. else +. yyState = yyDgoto[yyM]; +t if (yydebug != null) yydebug.shift(yyStates[yyTop], yyState); +. goto yyLoop; +. } +. } +. } +. + tables ## tables for rules, default reduction, and action calls +. + epilog ## text following second %% +.namespace yydebug { +. using System; +. public interface yyDebug { +. void push (int state, Object value); +. void lex (int state, int token, string name, Object value); +. void shift (int from, int to, int errorFlag); +. void pop (int state); +. void discard (int state, int token, string name, Object value); +. void reduce (int from, int to, int rule, string text, int len); +. void shift (int from, int to); +. void accept (Object value); +. void error (string message); +. void reject (); +. } +. +. class yyDebugSimple : yyDebug { +. void println (string s){ +. Console.WriteLine (s); +. } +. +. public void push (int state, Object value) { +. println ("push\tstate "+state+"\tvalue "+value); +. } +. +. public void lex (int state, int token, string name, Object value) { +. println("lex\tstate "+state+"\treading "+name+"\tvalue "+value); +. } +. +. public void shift (int from, int to, int errorFlag) { +. switch (errorFlag) { +. default: // normally +. println("shift\tfrom state "+from+" to "+to); +. break; +. case 0: case 1: case 2: // in error recovery +. println("shift\tfrom state "+from+" to "+to +. +"\t"+errorFlag+" left to recover"); +. break; +. case 3: // normally +. println("shift\tfrom state "+from+" to "+to+"\ton error"); +. break; +. } +. } +. +. public void pop (int state) { +. println("pop\tstate "+state+"\ton error"); +. } +. +. public void discard (int state, int token, string name, Object value) { +. println("discard\tstate "+state+"\ttoken "+name+"\tvalue "+value); +. } +. +. public void reduce (int from, int to, int rule, string text, int len) { +. println("reduce\tstate "+from+"\tuncover "+to +. +"\trule ("+rule+") "+text); +. } +. +. public void shift (int from, int to) { +. println("goto\tfrom state "+from+" to "+to); +. } +. +. public void accept (Object value) { +. println("accept\tvalue "+value); +. } +. +. public void error (string message) { +. println("error\t"+message); +. } +. +. public void reject () { +. println("reject"); +. } +. +. } +.} +.// %token constants +. class Token { + tokens public const int +. } +. namespace yyParser { +. using System; +. /** thrown for irrecoverable syntax errors and stack overflow. +. */ +. public class yyException : System.Exception { +. public yyException (string message) : base (message) { +. } +. } +. +. /** must be implemented by a scanner object to supply input to the parser. +. */ +. public interface yyInput { +. /** move on to next token. +. @return false if positioned beyond tokens. +. @throws IOException on input error. +. */ +. bool advance (); // throws java.io.IOException; +. /** classifies current token. +. Should not be called if advance() returned false. +. @return current %token or single character. +. */ +. int token (); +. /** associated with current token. +. Should not be called if advance() returned false. +. @return value for token(). +. */ +. Object value (); +. } +. } diff --git a/mcs/jay/symtab.c b/mcs/jay/symtab.c new file mode 100644 index 00000000000..0c5f55c535b --- /dev/null +++ b/mcs/jay/symtab.c @@ -0,0 +1,158 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)symtab.c 5.3 (Berkeley) 6/1/90"; +#endif /* not lint */ + +#include "defs.h" + +/* TABLE_SIZE is the number of entries in the symbol table. */ +/* TABLE_SIZE must be a power of two. */ + +#define TABLE_SIZE 1024 + + +bucket **symbol_table; +bucket *first_symbol; +bucket *last_symbol; + + +int +hash(name) +char *name; +{ + register char *s; + register int c, k; + + assert(name && *name); + s = name; + k = *s; + while (c = *++s) + k = (31*k + c) & (TABLE_SIZE - 1); + + return (k); +} + + +bucket * +make_bucket(name) +char *name; +{ + register bucket *bp; + + assert(name); + bp = (bucket *) MALLOC(sizeof(bucket)); + if (bp == 0) no_space(); + bp->link = 0; + bp->next = 0; + bp->name = MALLOC(strlen(name) + 1); + if (bp->name == 0) no_space(); + bp->tag = 0; + bp->value = UNDEFINED; + bp->index = 0; + bp->prec = 0; + bp-> class = UNKNOWN; + bp->assoc = TOKEN; + + if (bp->name == 0) no_space(); + strcpy(bp->name, name); + + return (bp); +} + + +bucket * +lookup(name) +char *name; +{ + register bucket *bp, **bpp; + + bpp = symbol_table + hash(name); + bp = *bpp; + + while (bp) + { + if (strcmp(name, bp->name) == 0) return (bp); + bpp = &bp->link; + bp = *bpp; + } + + *bpp = bp = make_bucket(name); + last_symbol->next = bp; + last_symbol = bp; + + return (bp); +} + + +create_symbol_table() +{ + register int i; + register bucket *bp; + + symbol_table = (bucket **) MALLOC(TABLE_SIZE*sizeof(bucket *)); + if (symbol_table == 0) no_space(); + for (i = 0; i < TABLE_SIZE; i++) + symbol_table[i] = 0; + + bp = make_bucket("error"); + bp->index = 1; + bp->class = TERM; + + first_symbol = bp; + last_symbol = bp; + symbol_table[hash("error")] = bp; +} + + +free_symbol_table() +{ + FREE(symbol_table); + symbol_table = 0; +} + + +free_symbols() +{ + register bucket *p, *q; + + for (p = first_symbol; p; p = q) + { + q = p->next; + FREE(p); + } +} diff --git a/mcs/jay/verbose.c b/mcs/jay/verbose.c new file mode 100644 index 00000000000..33ae265ee2e --- /dev/null +++ b/mcs/jay/verbose.c @@ -0,0 +1,366 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)verbose.c 5.3 (Berkeley) 1/20/91"; +#endif /* not lint */ + +#include "defs.h" + +static short *null_rules; + +verbose() +{ + register int i; + + if (!vflag) return; + + null_rules = (short *) MALLOC(nrules*sizeof(short)); + if (null_rules == 0) no_space(); + fprintf(verbose_file, "\f\n"); + for (i = 0; i < nstates; i++) + print_state(i); + FREE(null_rules); + + if (nunused) + log_unused(); + if (SRtotal || RRtotal) + log_conflicts(); + + fprintf(verbose_file, "\n\n%d terminals, %d nonterminals\n", ntokens, + nvars); + fprintf(verbose_file, "%d grammar rules, %d states\n", nrules - 2, nstates); +} + + +log_unused() +{ + register int i; + register short *p; + + fprintf(verbose_file, "\n\nRules never reduced:\n"); + for (i = 3; i < nrules; ++i) + { + if (!rules_used[i]) + { + fprintf(verbose_file, "\t%s :", symbol_name[rlhs[i]]); + for (p = ritem + rrhs[i]; *p >= 0; ++p) + fprintf(verbose_file, " %s", symbol_name[*p]); + fprintf(verbose_file, " (%d)\n", i - 2); + } + } +} + + +log_conflicts() +{ + register int i; + + fprintf(verbose_file, "\n\n"); + for (i = 0; i < nstates; i++) + { + if (SRconflicts[i] || RRconflicts[i]) + { + fprintf(verbose_file, "State %d contains ", i); + if (SRconflicts[i] == 1) + fprintf(verbose_file, "1 shift/reduce conflict"); + else if (SRconflicts[i] > 1) + fprintf(verbose_file, "%d shift/reduce conflicts", + SRconflicts[i]); + if (SRconflicts[i] && RRconflicts[i]) + fprintf(verbose_file, ", "); + if (RRconflicts[i] == 1) + fprintf(verbose_file, "1 reduce/reduce conflict"); + else if (RRconflicts[i] > 1) + fprintf(verbose_file, "%d reduce/reduce conflicts", + RRconflicts[i]); + fprintf(verbose_file, ".\n"); + } + } +} + + +print_state(state) +int state; +{ + if (state) + fprintf(verbose_file, "\n\n"); + if (SRconflicts[state] || RRconflicts[state]) + print_conflicts(state); + fprintf(verbose_file, "state %d\n", state); + print_core(state); + print_nulls(state); + print_actions(state); +} + + +print_conflicts(state) +int state; +{ + register int symbol, act, number; + register action *p; + + symbol = -1; + for (p = parser[state]; p; p = p->next) + { + if (p->suppressed == 2) + continue; + + if (p->symbol != symbol) + { + symbol = p->symbol; + number = p->number; + if (p->action_code == SHIFT) + act = SHIFT; + else + act = REDUCE; + } + else if (p->suppressed == 1) + { + if (state == final_state && symbol == 0) + { + fprintf(verbose_file, "%d: shift/reduce conflict \ +(accept, reduce %d) on $end\n", state, p->number - 2); + } + else + { + if (act == SHIFT) + { + fprintf(verbose_file, "%d: shift/reduce conflict \ +(shift %d, reduce %d) on %s\n", state, number, p->number - 2, + symbol_name[symbol]); + } + else + { + fprintf(verbose_file, "%d: reduce/reduce conflict \ +(reduce %d, reduce %d) on %s\n", state, number - 2, p->number - 2, + symbol_name[symbol]); + } + } + } + } +} + + +print_core(state) +int state; +{ + register int i; + register int k; + register int rule; + register core *statep; + register short *sp; + register short *sp1; + + statep = state_table[state]; + k = statep->nitems; + + for (i = 0; i < k; i++) + { + sp1 = sp = ritem + statep->items[i]; + + while (*sp >= 0) ++sp; + rule = -(*sp); + fprintf(verbose_file, "\t%s : ", symbol_name[rlhs[rule]]); + + for (sp = ritem + rrhs[rule]; sp < sp1; sp++) + fprintf(verbose_file, "%s ", symbol_name[*sp]); + + putc('.', verbose_file); + + while (*sp >= 0) + { + fprintf(verbose_file, " %s", symbol_name[*sp]); + sp++; + } + fprintf(verbose_file, " (%d)\n", -2 - *sp); + } +} + + +print_nulls(state) +int state; +{ + register action *p; + register int i, j, k, nnulls; + + nnulls = 0; + for (p = parser[state]; p; p = p->next) + { + if (p->action_code == REDUCE && + (p->suppressed == 0 || p->suppressed == 1)) + { + i = p->number; + if (rrhs[i] + 1 == rrhs[i+1]) + { + for (j = 0; j < nnulls && i > null_rules[j]; ++j) + continue; + + if (j == nnulls) + { + ++nnulls; + null_rules[j] = i; + } + else if (i != null_rules[j]) + { + ++nnulls; + for (k = nnulls - 1; k > j; --k) + null_rules[k] = null_rules[k-1]; + null_rules[j] = i; + } + } + } + } + + for (i = 0; i < nnulls; ++i) + { + j = null_rules[i]; + fprintf(verbose_file, "\t%s : . (%d)\n", symbol_name[rlhs[j]], + j - 2); + } + fprintf(verbose_file, "\n"); +} + + +print_actions(stateno) +int stateno; +{ + register action *p; + register shifts *sp; + register int as; + + if (stateno == final_state) + fprintf(verbose_file, "\t$end accept\n"); + + p = parser[stateno]; + if (p) + { + print_shifts(p); + print_reductions(p, defred[stateno]); + } + + sp = shift_table[stateno]; + if (sp && sp->nshifts > 0) + { + as = accessing_symbol[sp->shift[sp->nshifts - 1]]; + if (ISVAR(as)) + print_gotos(stateno); + } +} + + +print_shifts(p) +register action *p; +{ + register int count; + register action *q; + + count = 0; + for (q = p; q; q = q->next) + { + if (q->suppressed < 2 && q->action_code == SHIFT) + ++count; + } + + if (count > 0) + { + for (; p; p = p->next) + { + if (p->action_code == SHIFT && p->suppressed == 0) + fprintf(verbose_file, "\t%s shift %d\n", + symbol_name[p->symbol], p->number); + } + } +} + + +print_reductions(p, defred) +register action *p; +register int defred; +{ + register int k, anyreds; + register action *q; + + anyreds = 0; + for (q = p; q ; q = q->next) + { + if (q->action_code == REDUCE && q->suppressed < 2) + { + anyreds = 1; + break; + } + } + + if (anyreds == 0) + fprintf(verbose_file, "\t. error\n"); + else + { + for (; p; p = p->next) + { + if (p->action_code == REDUCE && p->number != defred) + { + k = p->number - 2; + if (p->suppressed == 0) + fprintf(verbose_file, "\t%s reduce %d\n", + symbol_name[p->symbol], k); + } + } + + if (defred > 0) + fprintf(verbose_file, "\t. reduce %d\n", defred - 2); + } +} + + +print_gotos(stateno) +int stateno; +{ + register int i, k; + register int as; + register short *to_state; + register shifts *sp; + + putc('\n', verbose_file); + sp = shift_table[stateno]; + to_state = sp->shift; + for (i = 0; i < sp->nshifts; ++i) + { + k = to_state[i]; + as = accessing_symbol[k]; + if (ISVAR(as)) + fprintf(verbose_file, "\t%s goto %d\n", symbol_name[as], k); + } +} diff --git a/mcs/jay/warshall.c b/mcs/jay/warshall.c new file mode 100644 index 00000000000..4672244e368 --- /dev/null +++ b/mcs/jay/warshall.c @@ -0,0 +1,122 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Paul Corbett. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static char sccsid[] = "@(#)warshall.c 5.4 (Berkeley) 5/24/93"; +#endif /* not lint */ + +#include "defs.h" + +transitive_closure(R, n) +unsigned *R; +int n; +{ + register int rowsize; + register unsigned i; + register unsigned *rowj; + register unsigned *rp; + register unsigned *rend; + register unsigned *ccol; + register unsigned *relend; + register unsigned *cword; + register unsigned *rowi; + + rowsize = WORDSIZE(n); + relend = R + n*rowsize; + + cword = R; + i = 0; + rowi = R; + while (rowi < relend) + { + ccol = cword; + rowj = R; + + while (rowj < relend) + { + if (*ccol & (1 << i)) + { + rp = rowi; + rend = rowj + rowsize; + while (rowj < rend) + *rowj++ |= *rp++; + } + else + { + rowj += rowsize; + } + + ccol += rowsize; + } + + if (++i >= BITS_PER_WORD) + { + i = 0; + cword++; + } + + rowi += rowsize; + } +} + +reflexive_transitive_closure(R, n) +unsigned *R; +int n; +{ + register int rowsize; + register unsigned i; + register unsigned *rp; + register unsigned *relend; + + transitive_closure(R, n); + + rowsize = WORDSIZE(n); + relend = R + n*rowsize; + + i = 0; + rp = R; + while (rp < relend) + { + *rp |= (1 << i); + if (++i >= BITS_PER_WORD) + { + i = 0; + rp++; + } + + rp += rowsize; + } +} diff --git a/mcs/makefile b/mcs/makefile new file mode 100755 index 00000000000..eb056939780 --- /dev/null +++ b/mcs/makefile @@ -0,0 +1,13 @@ +DIRS=jay mcs class + +all: + @echo "You must use 'make windows' or 'make unix'." + @echo "'make unix' is broken for now." + +windows: + for i in $(DIRS); do \ + (cd $$i; make windows) \ + done + +unix: + echo "'make unix' is broken for now." diff --git a/mcs/mcs/.cvsignore b/mcs/mcs/.cvsignore new file mode 100644 index 00000000000..2b426a690cb --- /dev/null +++ b/mcs/mcs/.cvsignore @@ -0,0 +1,4 @@ +compiler.pdb +compiler.exe +cs-parser.cs +y.output diff --git a/mcs/mcs/ChangeLog b/mcs/mcs/ChangeLog index 202a33903dc..ddcbc611432 100755 --- a/mcs/mcs/ChangeLog +++ b/mcs/mcs/ChangeLog @@ -1,3 +1,25 @@ +2001-07-14 Sean MacIsaac <macisaac@ximian.com> + + * makefile: Fixed up for easy making. + +2001-07-13 Simon Cozens <simon@simon-cozens.org> + + * cs-parser.jay (rank_specifier): Remove a conflict by reordering + the + + (unary_expression): Expand pre_increment_expression and + post_decrement_expression to reduce a shift/reduce. + +2001-07-11 Simon Cozens + + * cs-tokenizer.cs: Hex numbers should begin with a 0. + + Improve allow_keyword_as_indent name. + +2001-06-19 Miguel de Icaza <miguel@ximian.com> + + * Adjustments for Beta2. + 2001-06-13 Miguel de Icaza <miguel@ximian.com> * decl.cs: Added `Define' abstract method. diff --git a/mcs/mcs/cs-parser.cs b/mcs/mcs/cs-parser.cs deleted file mode 100755 index 90add9f4dd5..00000000000 --- a/mcs/mcs/cs-parser.cs +++ /dev/null @@ -1,5531 +0,0 @@ -// created by jay 0.7 (c) 1998 Axel.Schreiner@informatik.uni-osnabrueck.de - -#line 1 "cs-parser.jay" -
-//
-// cs-parser.jay: The Parser for the C# compiler
-//
-// Author: Miguel de Icaza (miguel@gnu.org)
-//
-// Licensed under the terms of the GNU GPL
-//
-// (C) 2001 Ximian, Inc (http://www.ximian.com)
-//
-// TODO:
-// (1) Get rid of the *Collections.cs, that is an idea I took from System.CodeDOM
-// And come to think of it, it is not that great, it duplicates a lot of code
-// for something which is not really needed. We still have piles of typecasts
-// anwyays (due to the nature of the stack being a collection of Objects).
-//
-// (2) Figure out why error productions dont work. `type-declaration' is a
-// great spot to put an `error' because you can reproduce it with this input:
-// "public X { }"
-//
-// (3) Move Modifier checking from each object into the parser itself, that will
-// get rid of the global "error" symbol that we use now to report errors.
-// We still need to pass a pointer to the tree.ErrorHandler, but that is a
-// separate problem
-//
-using System.Text;
-using CSC;
-using System;
-
-namespace CSC
-{
- using System.Collections;
- using Compiler;
- using CSC;
- using CIR;
-
- /// <summary>
- /// The C# Parser
- /// </summary>
- public class CSharpParser : Parser {
- static int global_errors;
-
- Namespace current_namespace;
- TypeContainer current_container;
-
- // <summary>
- // Current block is used to add statements as we find
- // them.
- // </summary>
-
- Block current_block;
-
- // <summary>
- // Current interface is used by the various declaration
- // productions in the interface declaration to "add"
- // the interfaces as we find them.
- // </summary>
- Interface current_interface;
-
- // <summary>
- // This is used by the unary_expression code to resolve
- // a name against a parameter.
- // </summary>
- Parameters current_local_parameters;
-
- // <summary>
- // Using during property parsing to describe the implicit
- // value parameter that is passed to the "set" accesor
- // method
- // </summary>
- ParameterCollection implicit_value_parameters;
-
- // <summary>
- // Here we keep track of type references.
- // </summary>
- TypeRefManager type_references;
-#line 81 "-" - - /** simplified error message. - @see <a href="#yyerror(java.lang.String, java.lang.String[])">yyerror</a> - */ - public void yyerror (string message) { - yyerror(message, null); - } - - /** (syntax) error message. - Can be overwritten to control message format. - @param message text to be displayed. - @param expected vector of acceptable tokens, if available. - */ - public void yyerror (string message, string[] expected) { - string res; - if ((expected != null) && (expected.Length > 0)) { - res = message+", expecting"; - for (int n = 0; n < expected.Length; ++ n) - res += " "+expected[n]; - } else - res = message; - throw new Exception (res); - } - - /** debugging support, requires the package jay.yydebug. - Set to null to suppress debugging messages. - */ - protected yydebug.yyDebug yydebug; - - protected static int yyFinal = 2; - public static string [] yyRule = { - "$accept : compilation_unit", - "compilation_unit : opt_using_directives opt_attributes opt_namespace_member_declarations EOF", - "using_directives : using_directive", - "using_directives : using_directives using_directive", - "using_directive : using_alias_directive", - "using_directive : using_namespace_directive", - "using_alias_directive : USING IDENTIFIER ASSIGN namespace_or_type_name SEMICOLON", - "using_namespace_directive : USING namespace_name SEMICOLON", - "namespace_declarations : namespace_declaration", - "namespace_declarations : namespace_declarations namespace_declaration", - "$$1 :", - "namespace_declaration : NAMESPACE qualified_identifier $$1 namespace_body opt_semicolon", - "opt_semicolon :", - "opt_semicolon : SEMICOLON", - "opt_comma :", - "opt_comma : COMMA", - "qualified_identifier : IDENTIFIER", - "qualified_identifier : qualified_identifier DOT IDENTIFIER", - "namespace_name : namespace_or_type_name", - "namespace_body : OPEN_BRACE opt_using_directives opt_namespace_member_declarations CLOSE_BRACE", - "opt_using_directives :", - "opt_using_directives : using_directives", - "opt_namespace_member_declarations :", - "opt_namespace_member_declarations : namespace_member_declarations", - "namespace_member_declarations : namespace_member_declaration", - "namespace_member_declarations : namespace_member_declarations namespace_member_declaration", - "namespace_member_declaration : type_declaration", - "namespace_member_declaration : namespace_declaration", - "type_declaration : class_declaration", - "type_declaration : struct_declaration", - "type_declaration : interface_declaration", - "type_declaration : enum_declaration", - "type_declaration : delegate_declaration", - "opt_attributes :", - "opt_attributes : attributes", - "attributes : attribute_sections", - "attribute_sections : attribute_section", - "attribute_sections : attribute_sections attribute_section", - "attribute_section : OPEN_BRACKET opt_attribute_target_specifier attribute_list CLOSE_BRACKET", - "opt_attribute_target_specifier :", - "opt_attribute_target_specifier : attribute_target_specifier", - "attribute_target_specifier : attribute_target COLON", - "attribute_target : IDENTIFIER", - "attribute_target : EVENT", - "attribute_target : RETURN", - "attribute_list : attribute", - "attribute_list : attribute_list COMMA attribute", - "attribute : attribute_name", - "attribute : opt_attribute_arguments", - "attribute_name : type_name", - "opt_attribute_arguments :", - "opt_attribute_arguments : OPEN_PARENS attribute_arguments CLOSE_PARENS", - "attribute_arguments : expression", - "attribute_arguments : attribute_arguments COMMA expression", - "opt_dimension_separators :", - "opt_dimension_separators : dimension_separators", - "dimension_separators : COMMA", - "dimension_separators : dimension_separators COMMA", - "class_body : OPEN_BRACE opt_class_member_declarations CLOSE_BRACE", - "opt_class_member_declarations :", - "opt_class_member_declarations : class_member_declarations", - "class_member_declarations : class_member_declaration", - "class_member_declarations : class_member_declarations class_member_declaration", - "class_member_declaration : constant_declaration", - "class_member_declaration : field_declaration", - "class_member_declaration : method_declaration", - "class_member_declaration : property_declaration", - "class_member_declaration : event_declaration", - "class_member_declaration : indexer_declaration", - "class_member_declaration : operator_declaration", - "class_member_declaration : constructor_declaration", - "class_member_declaration : destructor_declaration", - "class_member_declaration : type_declaration", - "$$2 :", - "struct_declaration : opt_attributes opt_modifiers STRUCT IDENTIFIER $$2 opt_struct_interfaces struct_body opt_semicolon", - "opt_struct_interfaces :", - "opt_struct_interfaces : struct_interfaces", - "struct_interfaces : struct_interface", - "struct_interfaces : struct_interfaces struct_interface", - "struct_interface : COLON type_list", - "struct_body : OPEN_BRACE opt_struct_member_declarations CLOSE_BRACE", - "opt_struct_member_declarations :", - "opt_struct_member_declarations : struct_member_declarations", - "struct_member_declarations : struct_member_declaration", - "struct_member_declarations : struct_member_declarations struct_member_declaration", - "struct_member_declaration : constant_declaration", - "struct_member_declaration : field_declaration", - "struct_member_declaration : method_declaration", - "struct_member_declaration : property_declaration", - "struct_member_declaration : event_declaration", - "struct_member_declaration : indexer_declaration", - "struct_member_declaration : operator_declaration", - "struct_member_declaration : constructor_declaration", - "struct_member_declaration : type_declaration", - "constant_declaration : opt_attributes opt_modifiers CONST type constant_declarators SEMICOLON", - "constant_declarators : constant_declarator", - "constant_declarators : constant_declarators COMMA constant_declarator", - "constant_declarator : IDENTIFIER ASSIGN constant_expression", - "field_declaration : opt_attributes opt_modifiers type variable_declarators SEMICOLON", - "variable_declarators : variable_declarator", - "variable_declarators : variable_declarators COMMA variable_declarator", - "variable_declarator : IDENTIFIER ASSIGN variable_initializer", - "variable_declarator : IDENTIFIER", - "variable_initializer : expression", - "variable_initializer : array_initializer", - "method_declaration : method_header method_body", - "method_header : opt_attributes opt_modifiers type member_name OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS", - "method_header : opt_attributes opt_modifiers VOID member_name OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS", - "method_body : block", - "method_body : SEMICOLON", - "opt_formal_parameter_list :", - "opt_formal_parameter_list : formal_parameter_list", - "formal_parameter_list : fixed_parameters", - "formal_parameter_list : fixed_parameters COMMA parameter_array", - "formal_parameter_list : parameter_array", - "fixed_parameters : fixed_parameter", - "fixed_parameters : fixed_parameters COMMA fixed_parameter", - "fixed_parameter : opt_attributes opt_parameter_modifier type IDENTIFIER", - "opt_parameter_modifier :", - "opt_parameter_modifier : parameter_modifier", - "parameter_modifier : REF", - "parameter_modifier : OUT", - "parameter_array : opt_attributes PARAMS type IDENTIFIER", - "member_name : IDENTIFIER", - "member_name : interface_type DOT IDENTIFIER", - "$$3 :", - "$$4 :", - "property_declaration : opt_attributes opt_modifiers type member_name OPEN_BRACE $$3 accessor_declarations $$4 CLOSE_BRACE", - "accessor_declarations : get_accessor_declaration opt_set_accessor_declaration", - "accessor_declarations : set_accessor_declaration opt_get_accessor_declaration", - "opt_get_accessor_declaration :", - "opt_get_accessor_declaration : get_accessor_declaration", - "opt_set_accessor_declaration :", - "opt_set_accessor_declaration : set_accessor_declaration", - "get_accessor_declaration : opt_attributes GET accessor_body", - "$$5 :", - "set_accessor_declaration : opt_attributes SET $$5 accessor_body", - "accessor_body : block", - "accessor_body : SEMICOLON", - "$$6 :", - "interface_declaration : opt_attributes opt_modifiers INTERFACE IDENTIFIER $$6 opt_interface_base interface_body", - "opt_interface_base :", - "opt_interface_base : interface_base", - "interface_base : COLON interface_type_list", - "interface_type_list : interface_type", - "interface_type_list : interface_type_list COMMA interface_type", - "interface_body : OPEN_BRACE opt_interface_member_declarations CLOSE_BRACE", - "opt_interface_member_declarations :", - "opt_interface_member_declarations : interface_member_declarations", - "interface_member_declarations : interface_member_declaration", - "interface_member_declarations : interface_member_declarations interface_member_declaration", - "interface_member_declaration : interface_method_declaration", - "interface_member_declaration : interface_property_declaration", - "interface_member_declaration : interface_event_declaration", - "interface_member_declaration : interface_indexer_declaration", - "opt_new :", - "opt_new : NEW", - "interface_method_declaration : opt_attributes opt_new type IDENTIFIER OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS SEMICOLON", - "interface_method_declaration : opt_attributes opt_new VOID IDENTIFIER OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS SEMICOLON", - "$$7 :", - "$$8 :", - "interface_property_declaration : opt_attributes opt_new type IDENTIFIER OPEN_BRACE $$7 interface_accesors $$8 CLOSE_BRACE", - "interface_accesors : opt_attributes GET SEMICOLON", - "interface_accesors : opt_attributes SET SEMICOLON", - "interface_accesors : opt_attributes GET SEMICOLON opt_attributes SET SEMICOLON", - "interface_accesors : opt_attributes SET SEMICOLON opt_attributes GET SEMICOLON", - "interface_event_declaration : opt_attributes opt_new EVENT type IDENTIFIER SEMICOLON", - "$$9 :", - "$$10 :", - "interface_indexer_declaration : opt_attributes opt_new type THIS OPEN_BRACKET formal_parameter_list CLOSE_BRACKET OPEN_BRACE $$9 interface_accesors $$10 CLOSE_BRACE", - "operator_declaration : opt_attributes opt_modifiers operator_declarator block", - "operator_declarator : type OPERATOR overloadable_operator OPEN_PARENS type IDENTIFIER CLOSE_PARENS", - "operator_declarator : type OPERATOR overloadable_operator OPEN_PARENS type IDENTIFIER COMMA type IDENTIFIER CLOSE_PARENS", - "operator_declarator : conversion_operator_declarator", - "overloadable_operator : BANG", - "overloadable_operator : TILDE", - "overloadable_operator : OP_INC", - "overloadable_operator : OP_DEC", - "overloadable_operator : TRUE", - "overloadable_operator : FALSE", - "overloadable_operator : PLUS", - "overloadable_operator : MINUS", - "overloadable_operator : STAR", - "overloadable_operator : DIV", - "overloadable_operator : PERCENT", - "overloadable_operator : BITWISE_AND", - "overloadable_operator : BITWISE_OR", - "overloadable_operator : CARRET", - "overloadable_operator : OP_SHIFT_LEFT", - "overloadable_operator : OP_SHIFT_RIGHT", - "overloadable_operator : OP_EQ", - "overloadable_operator : OP_NE", - "overloadable_operator : OP_GT", - "overloadable_operator : OP_LT", - "overloadable_operator : OP_GE", - "overloadable_operator : OP_LE", - "conversion_operator_declarator : IMPLICIT OPERATOR type OPEN_PARENS type IDENTIFIER CLOSE_PARENS", - "conversion_operator_declarator : EXPLICIT OPERATOR type OPEN_PARENS type IDENTIFIER CLOSE_PARENS", - "constructor_declaration : opt_attributes opt_modifiers constructor_declarator block", - "constructor_declarator : IDENTIFIER OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS opt_constructor_initializer", - "opt_constructor_initializer :", - "opt_constructor_initializer : constructor_initializer", - "constructor_initializer : COLON BASE OPEN_PARENS opt_argument_list CLOSE_PARENS", - "constructor_initializer : COLON THIS OPEN_PARENS opt_argument_list CLOSE_PARENS", - "destructor_declaration : opt_attributes TILDE IDENTIFIER OPEN_PARENS CLOSE_PARENS block", - "event_declaration : opt_attributes opt_modifiers EVENT type variable_declarators SEMICOLON", - "event_declaration : opt_attributes opt_modifiers EVENT type member_name OPEN_BRACE event_accesor_declarations CLOSE_BRACE SEMICOLON", - "event_accesor_declarations : add_accessor_declaration remove_accessor_declaration", - "event_accesor_declarations : remove_accessor_declaration add_accessor_declaration", - "add_accessor_declaration : opt_attributes ADD block", - "remove_accessor_declaration : opt_attributes REMOVE block", - "indexer_declaration : opt_attributes opt_modifiers indexer_declarator OPEN_BRACE accessor_declarations CLOSE_BRACE", - "indexer_declarator : type THIS OPEN_BRACKET formal_parameter_list CLOSE_BRACKET", - "indexer_declarator : type interface_type DOT THIS OPEN_BRACKET formal_parameter_list CLOSE_BRACKET", - "enum_declaration : opt_attributes opt_modifiers ENUM IDENTIFIER opt_enum_base enum_body opt_semicolon", - "opt_enum_base :", - "opt_enum_base : COLON integral_type", - "enum_body : OPEN_BRACE opt_enum_member_declarations CLOSE_BRACE", - "enum_body : OPEN_BRACE enum_member_declarations COMMA CLOSE_BRACE", - "opt_enum_member_declarations :", - "opt_enum_member_declarations : enum_member_declarations", - "enum_member_declarations : enum_member_declaration", - "enum_member_declarations : enum_member_declarations COMMA enum_member_declaration", - "enum_member_declaration : opt_attributes IDENTIFIER", - "enum_member_declaration : opt_attributes IDENTIFIER ASSIGN expression", - "delegate_declaration : opt_attributes opt_modifiers DELEGATE type IDENTIFIER OPEN_PARENS formal_parameter_list CLOSE_PARENS SEMICOLON", - "type_name : namespace_or_type_name", - "namespace_or_type_name : qualified_identifier", - "type : type_name", - "type : builtin_types", - "type : array_type", - "type_list : type", - "type_list : type_list type", - "builtin_types : OBJECT", - "builtin_types : STRING", - "builtin_types : BOOL", - "builtin_types : DECIMAL", - "builtin_types : FLOAT", - "builtin_types : DOUBLE", - "builtin_types : integral_type", - "integral_type : SBYTE", - "integral_type : BYTE", - "integral_type : SHORT", - "integral_type : USHORT", - "integral_type : INT", - "integral_type : UINT", - "integral_type : LONG", - "integral_type : ULONG", - "integral_type : CHAR", - "interface_type : type_name", - "array_type : type rank_specifiers", - "primary_expression : literal", - "primary_expression : qualified_identifier", - "primary_expression : parenthesized_expression", - "primary_expression : member_access", - "primary_expression : invocation_expression", - "primary_expression : element_access", - "primary_expression : this_access", - "primary_expression : base_access", - "primary_expression : post_increment_expression", - "primary_expression : post_decrement_expression", - "primary_expression : new_expression", - "primary_expression : typeof_expression", - "primary_expression : sizeof_expression", - "primary_expression : checked_expression", - "primary_expression : unchecked_expression", - "literal : boolean_literal", - "literal : integer_literal", - "literal : real_literal", - "literal : LITERAL_CHARACTER", - "literal : LITERAL_STRING", - "literal : NULL", - "real_literal : LITERAL_FLOAT", - "real_literal : LITERAL_DOUBLE", - "real_literal : LITERAL_DECIMAL", - "integer_literal : LITERAL_INTEGER", - "boolean_literal : TRUE", - "boolean_literal : FALSE", - "parenthesized_expression : OPEN_PARENS expression CLOSE_PARENS", - "member_access : primary_expression DOT IDENTIFIER", - "member_access : predefined_type DOT IDENTIFIER", - "predefined_type : builtin_types", - "invocation_expression : primary_expression OPEN_PARENS opt_argument_list CLOSE_PARENS", - "opt_argument_list :", - "opt_argument_list : argument_list", - "argument_list : argument", - "argument_list : argument_list COMMA argument", - "argument : expression", - "argument : REF variable_reference", - "argument : OUT variable_reference", - "variable_reference : expression", - "element_access : primary_expression OPEN_BRACKET expression_list CLOSE_BRACKET", - "expression_list : expression", - "expression_list : expression_list COMMA expression", - "this_access : THIS", - "base_access : BASE DOT IDENTIFIER", - "base_access : BASE OPEN_BRACKET expression_list CLOSE_BRACKET", - "post_increment_expression : primary_expression OP_INC", - "post_decrement_expression : primary_expression OP_DEC", - "new_expression : object_or_delegate_creation_expression", - "new_expression : array_creation_expression", - "object_or_delegate_creation_expression : NEW type OPEN_PARENS opt_argument_list CLOSE_PARENS", - "array_creation_expression : NEW type OPEN_BRACKET expression_list CLOSE_BRACKET opt_rank_specifier opt_array_initializer", - "opt_rank_specifier :", - "opt_rank_specifier : rank_specifiers", - "rank_specifiers : rank_specifier", - "rank_specifiers : rank_specifiers rank_specifier", - "rank_specifier : OPEN_BRACKET opt_dim_separators CLOSE_BRACKET", - "opt_dim_separators :", - "opt_dim_separators : dim_separators", - "dim_separators : COMMA", - "dim_separators : dim_separators COMMA", - "opt_array_initializer :", - "opt_array_initializer : array_initializer", - "array_initializer : OPEN_BRACE CLOSE_BRACE", - "array_initializer : OPEN_BRACE variable_initializer_list CLOSE_BRACE", - "array_initializer : OPEN_BRACE variable_initializer_list COMMA CLOSE_BRACE", - "variable_initializer_list : variable_initializer", - "variable_initializer_list : variable_initializer_list COMMA variable_initializer", - "typeof_expression : TYPEOF OPEN_PARENS type CLOSE_PARENS", - "sizeof_expression : SIZEOF OPEN_PARENS type CLOSE_PARENS", - "checked_expression : CHECKED OPEN_PARENS expression CLOSE_PARENS", - "unchecked_expression : UNCHECKED OPEN_PARENS expression CLOSE_PARENS", - "unary_expression : primary_expression", - "unary_expression : PLUS unary_expression", - "unary_expression : MINUS unary_expression", - "unary_expression : BANG unary_expression", - "unary_expression : TILDE unary_expression", - "unary_expression : STAR unary_expression", - "unary_expression : BITWISE_AND unary_expression", - "unary_expression : pre_increment_expression", - "unary_expression : pre_decrement_expression", - "unary_expression : cast_expression", - "pre_increment_expression : OP_INC unary_expression", - "pre_decrement_expression : OP_DEC unary_expression", - "cast_expression : OPEN_PARENS qualified_identifier CLOSE_PARENS unary_expression", - "cast_expression : OPEN_PARENS builtin_types CLOSE_PARENS unary_expression", - "multiplicative_expression : unary_expression", - "multiplicative_expression : multiplicative_expression STAR unary_expression", - "multiplicative_expression : multiplicative_expression DIV unary_expression", - "multiplicative_expression : multiplicative_expression PERCENT unary_expression", - "additive_expression : multiplicative_expression", - "additive_expression : additive_expression PLUS multiplicative_expression", - "additive_expression : additive_expression MINUS multiplicative_expression", - "shift_expression : additive_expression", - "shift_expression : shift_expression OP_SHIFT_LEFT additive_expression", - "shift_expression : shift_expression OP_SHIFT_RIGHT additive_expression", - "relational_expression : shift_expression", - "relational_expression : relational_expression OP_LT shift_expression", - "relational_expression : relational_expression OP_GT shift_expression", - "relational_expression : relational_expression OP_LE shift_expression", - "relational_expression : relational_expression OP_GE shift_expression", - "relational_expression : relational_expression IS type", - "relational_expression : relational_expression AS type", - "equality_expression : relational_expression", - "equality_expression : equality_expression OP_EQ relational_expression", - "equality_expression : equality_expression OP_NE relational_expression", - "and_expression : equality_expression", - "and_expression : and_expression BITWISE_AND equality_expression", - "exclusive_or_expression : and_expression", - "exclusive_or_expression : exclusive_or_expression CARRET and_expression", - "inclusive_or_expression : exclusive_or_expression", - "inclusive_or_expression : inclusive_or_expression BITWISE_OR exclusive_or_expression", - "conditional_and_expression : inclusive_or_expression", - "conditional_and_expression : conditional_and_expression OP_AND inclusive_or_expression", - "conditional_or_expression : conditional_and_expression", - "conditional_or_expression : conditional_or_expression OP_OR conditional_and_expression", - "conditional_expression : conditional_or_expression", - "conditional_expression : conditional_or_expression INTERR expression COLON expression", - "assignment_expression : unary_expression ASSIGN expression", - "assignment_expression : unary_expression OP_MULT_ASSIGN expression", - "assignment_expression : unary_expression OP_DIV_ASSIGN expression", - "assignment_expression : unary_expression OP_MOD_ASSIGN expression", - "assignment_expression : unary_expression OP_ADD_ASSIGN expression", - "assignment_expression : unary_expression OP_SUB_ASSIGN expression", - "assignment_expression : unary_expression OP_SHIFT_LEFT_ASSIGN expression", - "assignment_expression : unary_expression OP_SHIFT_RIGHT_ASSIGN expression", - "assignment_expression : unary_expression OP_AND_ASSIGN expression", - "assignment_expression : unary_expression OP_OR_ASSIGN expression", - "assignment_expression : unary_expression OP_XOR_ASSIGN expression", - "expression : conditional_expression", - "expression : assignment_expression", - "constant_expression : expression", - "boolean_expression : expression", - "$$11 :", - "class_declaration : opt_attributes opt_modifiers CLASS IDENTIFIER $$11 opt_class_base class_body opt_semicolon", - "opt_modifiers :", - "opt_modifiers : modifiers", - "modifiers : modifier", - "modifiers : modifiers modifier", - "modifier : NEW", - "modifier : PUBLIC", - "modifier : PROTECTED", - "modifier : INTERNAL", - "modifier : PRIVATE", - "modifier : ABSTRACT", - "modifier : SEALED", - "modifier : STATIC", - "modifier : READONLY", - "modifier : VIRTUAL", - "modifier : OVERRIDE", - "modifier : EXTERN", - "opt_class_base :", - "opt_class_base : class_base", - "class_base : COLON type_list", - "$$12 :", - "block : OPEN_BRACE $$12 opt_statement_list CLOSE_BRACE", - "opt_statement_list :", - "opt_statement_list : statement_list", - "statement_list : statement", - "statement_list : statement_list statement", - "statement : declaration_statement", - "statement : embedded_statement", - "statement : labeled_statement", - "embedded_statement : block", - "embedded_statement : empty_statement", - "embedded_statement : expression_statement", - "embedded_statement : selection_statement", - "embedded_statement : iteration_statement", - "embedded_statement : jump_statement", - "embedded_statement : try_statement", - "embedded_statement : checked_statement", - "embedded_statement : unchecked_statement", - "embedded_statement : lock_statement", - "embedded_statement : using_statement", - "empty_statement : SEMICOLON", - "labeled_statement : IDENTIFIER COLON statement", - "declaration_statement : local_variable_declaration SEMICOLON", - "declaration_statement : local_constant_declaration SEMICOLON", - "local_variable_type : primary_expression type_suffixes", - "local_variable_type : builtin_types type_suffixes", - "local_variable_type : VOID type_suffixes", - "type_suffixes :", - "type_suffixes : type_suffix_list", - "type_suffix_list : type_suffix", - "type_suffix_list : type_suffix_list type_suffix", - "type_suffix : OPEN_BRACKET opt_dim_separators CLOSE_BRACKET", - "local_variable_declaration : local_variable_type variable_declarators", - "local_constant_declaration : CONST type constant_declarator", - "expression_statement : statement_expression SEMICOLON", - "statement_expression : invocation_expression", - "statement_expression : object_creation_expression", - "statement_expression : assignment_expression", - "statement_expression : post_increment_expression", - "statement_expression : post_decrement_expression", - "statement_expression : pre_increment_expression", - "statement_expression : pre_decrement_expression", - "object_creation_expression : object_or_delegate_creation_expression", - "selection_statement : if_statement", - "selection_statement : switch_statement", - "if_statement : IF OPEN_PARENS boolean_expression CLOSE_PARENS embedded_statement", - "if_statement : IF OPEN_PARENS boolean_expression CLOSE_PARENS embedded_statement ELSE embedded_statement", - "switch_statement : SWITCH OPEN_PARENS expression CLOSE_PARENS switch_block", - "switch_block : OPEN_BRACE opt_switch_sections CLOSE_BRACE", - "opt_switch_sections :", - "opt_switch_sections : switch_sections", - "switch_sections : switch_section", - "switch_sections : switch_sections switch_section", - "$$13 :", - "switch_section : switch_labels $$13 statement_list", - "switch_labels : switch_label", - "switch_labels : switch_labels switch_label", - "switch_label : CASE constant_expression COLON", - "switch_label : DEFAULT COLON", - "iteration_statement : while_statement", - "iteration_statement : do_statement", - "iteration_statement : for_statement", - "iteration_statement : foreach_statement", - "while_statement : WHILE OPEN_PARENS boolean_expression CLOSE_PARENS embedded_statement", - "do_statement : DO embedded_statement WHILE OPEN_PARENS boolean_expression CLOSE_PARENS SEMICOLON", - "for_statement : FOR OPEN_PARENS opt_for_initializer SEMICOLON opt_for_condition SEMICOLON opt_for_iterator CLOSE_PARENS embedded_statement", - "opt_for_initializer :", - "opt_for_initializer : for_initializer", - "for_initializer : local_variable_declaration", - "for_initializer : statement_expression_list", - "opt_for_condition :", - "opt_for_condition : boolean_expression", - "opt_for_iterator :", - "opt_for_iterator : for_iterator", - "for_iterator : statement_expression_list", - "statement_expression_list : statement_expression", - "statement_expression_list : statement_expression_list COMMA statement_expression", - "foreach_statement : FOREACH OPEN_PARENS type IDENTIFIER IN expression CLOSE_PARENS embedded_statement", - "jump_statement : break_statement", - "jump_statement : continue_statement", - "jump_statement : goto_statement", - "jump_statement : return_statement", - "jump_statement : throw_statement", - "break_statement : BREAK SEMICOLON", - "continue_statement : CONTINUE SEMICOLON", - "goto_statement : GOTO IDENTIFIER SEMICOLON", - "goto_statement : GOTO CASE constant_expression SEMICOLON", - "goto_statement : GOTO DEFAULT SEMICOLON", - "return_statement : RETURN opt_expression SEMICOLON", - "throw_statement : THROW opt_expression SEMICOLON", - "opt_expression :", - "opt_expression : expression", - "try_statement : TRY block catch_clauses", - "try_statement : TRY block finalize_clause", - "try_statement : TRY block catch_clauses finalize_clause", - "catch_clauses : specific_catch_clauses opt_general_catch_clause", - "catch_clauses : opt_specific_catch_clauses general_catch_clause", - "opt_general_catch_clause :", - "opt_general_catch_clause : general_catch_clause", - "opt_specific_catch_clauses :", - "opt_specific_catch_clauses : specific_catch_clauses", - "specific_catch_clauses : specific_catch_clause", - "specific_catch_clauses : specific_catch_clauses specific_catch_clause", - "specific_catch_clause : CATCH OPEN_PARENS type opt_identifier CLOSE_PARENS block", - "opt_identifier :", - "opt_identifier : IDENTIFIER", - "general_catch_clause : CATCH block", - "finalize_clause : FINALLY block", - "checked_statement : CHECKED block", - "unchecked_statement : UNCHECKED block", - "lock_statement : LOCK OPEN_PARENS expression CLOSE_PARENS embedded_statement", - "using_statement : USING OPEN_PARENS resource_acquisition CLOSE_PARENS embedded_statement", - "resource_acquisition : local_variable_declaration expression", - }; - protected static string [] yyName = { - "end-of-file",null,null,null,null,null,null,null,null,null,null,null, - null,null,null,null,null,null,null,null,null,null,null,null,null,null, - null,null,null,null,null,null,null,"'!'",null,null,null,"'%'","'&'", - null,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",null,null,null, - null,null,null,null,null,null,null,"':'","';'","'<'","'='","'>'", - "'?'",null,null,null,null,null,null,null,null,null,null,null,null, - null,null,null,null,null,null,null,null,null,null,null,null,null,null, - null,"'['",null,"']'","'^'",null,null,null,null,null,null,null,null, - null,null,null,null,null,null,null,null,null,null,null,null,null,null, - null,null,null,null,null,null,"'{'","'|'","'}'","'~'",null,null,null, - null,null,null,null,null,null,null,null,null,null,null,null,null,null, - null,null,null,null,null,null,null,null,null,null,null,null,null,null, - null,null,null,null,null,null,null,null,null,null,null,null,null,null, - null,null,null,null,null,null,null,null,null,null,null,null,null,null, - null,null,null,null,null,null,null,null,null,null,null,null,null,null, - null,null,null,null,null,null,null,null,null,null,null,null,null,null, - null,null,null,null,null,null,null,null,null,null,null,null,null,null, - null,null,null,null,null,null,null,null,null,null,null,null,null,null, - null,null,null,null,null,null,null,null,null,null,null,null,null,null, - null,"EOF","NONE","ERROR","ABSTRACT","AS","ADD","BASE","BOOL","BREAK", - "BYTE","CASE","CATCH","CHAR","CHECKED","CLASS","CONST","CONTINUE", - "DECIMAL","DEFAULT","DELEGATE","DO","DOUBLE","ELSE","ENUM","EVENT", - "EXPLICIT","EXTERN","FALSE","FINALLY","FIXED","FLOAT","FOR","FOREACH", - "GOTO","IF","IMPLICIT","IN","INT","INTERFACE","INTERNAL","IS","LOCK", - "LONG","NAMESPACE","NEW","NULL","OBJECT","OPERATOR","OUT","OVERRIDE", - "PARAMS","PRIVATE","PROTECTED","PUBLIC","READONLY","REF","RETURN", - "REMOVE","SBYTE","SEALED","SHORT","SIZEOF","STATIC","STRING","STRUCT", - "SWITCH","THIS","THROW","TRUE","TRY","TYPEOF","UINT","ULONG", - "UNCHECKED","UNSAFE","USHORT","USING","VIRTUAL","VOID","WHILE","GET", - "\"get\"","SET","\"set\"","OPEN_BRACE","CLOSE_BRACE","OPEN_BRACKET", - "CLOSE_BRACKET","OPEN_PARENS","CLOSE_PARENS","DOT","COMMA","COLON", - "SEMICOLON","TILDE","PLUS","MINUS","BANG","ASSIGN","OP_LT","OP_GT", - "BITWISE_AND","BITWISE_OR","STAR","PERCENT","DIV","CARRET","INTERR", - "OP_INC","\"++\"","OP_DEC","\"--\"","OP_SHIFT_LEFT","\"<<\"", - "OP_SHIFT_RIGHT","\">>\"","OP_LE","\"<=\"","OP_GE","\">=\"","OP_EQ", - "\"==\"","OP_NE","\"!=\"","OP_AND","\"&&\"","OP_OR","\"||\"", - "OP_MULT_ASSIGN","\"*=\"","OP_DIV_ASSIGN","\"/=\"","OP_MOD_ASSIGN", - "\"%=\"","OP_ADD_ASSIGN","\"+=\"","OP_SUB_ASSIGN","\"-=\"", - "OP_SHIFT_LEFT_ASSIGN","\"<<=\"","OP_SHIFT_RIGHT_ASSIGN","\">>=\"", - "OP_AND_ASSIGN","\"&=\"","OP_XOR_ASSIGN","\"^=\"","OP_OR_ASSIGN", - "\"|=\"","OP_PTR","\"->\"","LITERAL_INTEGER","\"int literal\"", - "LITERAL_FLOAT","\"float literal\"","LITERAL_DOUBLE", - "\"double literal\"","LITERAL_DECIMAL","\"decimal literal\"", - "LITERAL_CHARACTER","\"character literal\"","LITERAL_STRING", - "\"string literal\"","IDENTIFIER", - }; - - /** index-checked interface to yyName[]. - @param token single character or %token value. - @return token name or [illegal] or [unknown]. - */ - public static string yyname (int token) { - if ((token < 0) || (token > yyName.Length)) return "[illegal]"; - string name; - if ((name = yyName[token]) != null) return name; - return "[unknown]"; - } - - /** computes list of expected tokens on error by tracing the tables. - @param state for which to compute the list. - @return list of token names. - */ - protected string[] yyExpecting (int state) { - int token, n, len = 0; - bool[] ok = new bool[yyName.Length]; - - if ((n = yySindex[state]) != 0) - for (token = n < 0 ? -n : 0; - (token < yyName.Length) && (n+token < yyTable.Length); ++ token) - if (yyCheck[n+token] == token && !ok[token] && yyName[token] != null) { - ++ len; - ok[token] = true; - } - if ((n = yyRindex[state]) != 0) - for (token = n < 0 ? -n : 0; - (token < yyName.Length) && (n+token < yyTable.Length); ++ token) - if (yyCheck[n+token] == token && !ok[token] && yyName[token] != null) { - ++ len; - ok[token] = true; - } - - string [] result = new string[len]; - for (n = token = 0; n < len; ++ token) - if (ok[token]) result[n++] = yyName[token]; - return result; - } - - /** the generated parser, with debugging messages. - Maintains a state and a value stack, currently with fixed maximum size. - @param yyLex scanner. - @param yydebug debug message writer implementing yyDebug, or null. - @return result of the last reduction, if any. - @throws yyException on irrecoverable parse error. - */ - public Object yyparse (yyParser.yyInput yyLex, Object yydebug) - { - this.yydebug = (yydebug.yyDebug)yydebug; - return yyparse(yyLex); - } - - /** initial size and increment of the state/value stack [default 256]. - This is not final so that it can be overwritten outside of invocations - of yyparse(). - */ - protected int yyMax; - - /** executed at the beginning of a reduce action. - Used as $$ = yyDefault($1), prior to the user-specified action, if any. - Can be overwritten to provide deep copy, etc. - @param first value for $1, or null. - @return first. - */ - protected Object yyDefault (Object first) { - return first; - } - - /** the generated parser. - Maintains a state and a value stack, currently with fixed maximum size. - @param yyLex scanner. - @return result of the last reduction, if any. - @throws yyException on irrecoverable parse error. - */ - public Object yyparse (yyParser.yyInput yyLex) - { - if (yyMax <= 0) yyMax = 256; // initial size - int yyState = 0; // state stack ptr - int [] yyStates = new int[yyMax]; // state stack - Object yyVal = null; // value stack ptr - Object [] yyVals = new Object[yyMax]; // value stack - int yyToken = -1; // current input - int yyErrorFlag = 0; // #tks to shift - - int yyTop = 0; - goto skip; - yyLoop: - yyTop++; - skip: - for (;; ++ yyTop) { - if (yyTop >= yyStates.Length) { // dynamically increase - int[] i = new int[yyStates.Length+yyMax]; - System.Array.Copy(yyStates, i, 0); - yyStates = i; - Object[] o = new Object[yyVals.Length+yyMax]; - System.Array.Copy(yyVals, o, 0); - yyVals = o; - } - yyStates[yyTop] = yyState; - yyVals[yyTop] = yyVal; - if (yydebug != null) yydebug.push(yyState, yyVal); - - yyDiscarded: for (;;) { // discarding a token does not change stack - int yyN; - if ((yyN = yyDefRed[yyState]) == 0) { // else [default] reduce (yyN) - if (yyToken < 0) { - yyToken = yyLex.advance() ? yyLex.token() : 0; - if (yydebug != null) - yydebug.lex(yyState, yyToken, yyname(yyToken), yyLex.value()); - } - if ((yyN = yySindex[yyState]) != 0 && ((yyN += yyToken) >= 0) - && (yyN < yyTable.Length) && (yyCheck[yyN] == yyToken)) { - if (yydebug != null) - yydebug.shift(yyState, yyTable[yyN], yyErrorFlag-1); - yyState = yyTable[yyN]; // shift to yyN - yyVal = yyLex.value(); - yyToken = -1; - if (yyErrorFlag > 0) -- yyErrorFlag; - goto yyLoop; - } - if ((yyN = yyRindex[yyState]) != 0 && (yyN += yyToken) >= 0 - && yyN < yyTable.Length && yyCheck[yyN] == yyToken) - yyN = yyTable[yyN]; // reduce (yyN) - else - switch (yyErrorFlag) { - - case 0: - yyerror("syntax error", yyExpecting(yyState)); - if (yydebug != null) yydebug.error("syntax error"); - goto case 1; - case 1: case 2: - yyErrorFlag = 3; - do { - if ((yyN = yySindex[yyStates[yyTop]]) != 0 - && (yyN += Token.yyErrorCode) >= 0 && yyN < yyTable.Length - && yyCheck[yyN] == Token.yyErrorCode) { - if (yydebug != null) - yydebug.shift(yyStates[yyTop], yyTable[yyN], 3); - yyState = yyTable[yyN]; - yyVal = yyLex.value(); - goto yyLoop; - } - if (yydebug != null) yydebug.pop(yyStates[yyTop]); - } while (-- yyTop >= 0); - if (yydebug != null) yydebug.reject(); - throw new yyParser.yyException("irrecoverable syntax error"); - - case 3: - if (yyToken == 0) { - if (yydebug != null) yydebug.reject(); - throw new yyParser.yyException("irrecoverable syntax error at end-of-file"); - } - if (yydebug != null) - yydebug.discard(yyState, yyToken, yyname(yyToken), - yyLex.value()); - yyToken = -1; - goto yyDiscarded; // leave stack alone - } - } - int yyV = yyTop + 1-yyLen[yyN]; - if (yydebug != null) - yydebug.reduce(yyState, yyStates[yyV-1], yyN, yyRule[yyN], yyLen[yyN]); - yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]); - switch (yyN) { -case 1: -#line 240 "cs-parser.jay" - {
- /* At some point check that using only comes *before* any namespaces
*/ - } - break; -case 6: -#line 257 "cs-parser.jay" - {
- } - break; -case 7: -#line 263 "cs-parser.jay" - {
- current_namespace.Using ((string) yyVals[-1+yyTop]);
- } - break; -case 10: -#line 274 "cs-parser.jay" - {
- current_namespace = new Namespace (current_namespace, (string) yyVals[0+yyTop]);
- } - break; -case 11: -#line 278 "cs-parser.jay" - {
- current_namespace = current_namespace.Parent;
- } - break; -case 17: -#line 295 "cs-parser.jay" - {
- yyVal = ((yyVals[-2+yyTop]).ToString ()) + "." + (yyVals[0+yyTop].ToString ()); } - break; -case 19: -#line 308 "cs-parser.jay" - {
- } - break; -case 26: -#line 329 "cs-parser.jay" - {
- int mod_flags = 0;
- string name = "";
-
- if (yyVals[0+yyTop] is Class){
- Class c = (Class) yyVals[0+yyTop];
- mod_flags = c.ModFlags;
- name = c.Name;
- } else if (yyVals[0+yyTop] is Struct){
- Struct s = (Struct) yyVals[0+yyTop];
- mod_flags = s.ModFlags;
- name = s.Name;
- } else
- break;
-
- /*
*/ - /* We remove this error until we can
*/ - /*if ((mod_flags & (Modifiers.PRIVATE|Modifiers.PROTECTED)) != 0){
*/ - /* error (1527, "Namespace elements cant be explicitly " +
*/ - /* "declared private or protected in `" + name + "'");
*/ - /*}
*/ - } - break; -case 42: -#line 396 "cs-parser.jay" - {
- /* if (Collection.Contains ($$))... FIXME
*/ - note ("Allows: assembly, field, method, module, param, property, type");
- } - break; -case 49: -#line 415 "cs-parser.jay" - { /* reserved attribute name or identifier: 17.4 */ } - break; -case 73: -#line 471 "cs-parser.jay" - {
- Struct new_struct;
- string full_struct_name = MakeName ((string) yyVals[0+yyTop]);
-
- new_struct = new Struct (current_container, full_struct_name, (int) yyVals[-2+yyTop]);
- current_container = new_struct;
- current_container.Namespace = current_namespace;
- } - break; -case 74: -#line 482 "cs-parser.jay" - {
- Struct new_struct = (Struct) current_container;
-
- current_container = current_container.Parent;
- CheckDef (current_container.AddStruct (new_struct), new_struct.Name);
- yyVal = new_struct;
- } - break; -case 94: -#line 538 "cs-parser.jay" - {
- Modifiers.Check (Constant.AllowedModifiers, (int) yyVals[-4+yyTop], Modifiers.PRIVATE);
-
- foreach (DictionaryEntry constant in (ArrayList) yyVals[-1+yyTop]){
- Constant c = new Constant (
- (TypeRef) yyVals[-2+yyTop], (string) constant.Key,
- (Expression) constant.Value);
-
- CheckDef (current_container.AddConstant (c), c.Name);
- }
- } - break; -case 95: -#line 553 "cs-parser.jay" - {
- ArrayList constants = new ArrayList ();
- constants.Add (yyVals[0+yyTop]);
- yyVal = constants;
- } - break; -case 96: -#line 559 "cs-parser.jay" - {
- ArrayList constants = (ArrayList) yyVals[-2+yyTop];
-
- constants.Add (yyVals[0+yyTop]);
- } - break; -case 97: -#line 567 "cs-parser.jay" - {
- yyVal = new DictionaryEntry (yyVals[-2+yyTop], yyVals[0+yyTop]);
- } - break; -case 98: -#line 578 "cs-parser.jay" - {
- TypeRef typeref = (TypeRef) yyVals[-2+yyTop];
- int mod = (int) yyVals[-3+yyTop];
-
- foreach (VariableDeclaration var in (ArrayList) yyVals[-1+yyTop]){
- Field field = new Field (typeref, mod, var.identifier,
- var.expression_or_array_initializer);
-
- CheckDef (current_container.AddField (field), field.Name);
- }
- } - break; -case 99: -#line 594 "cs-parser.jay" - {
- ArrayList decl = new ArrayList ();
- yyVal = decl;
- decl.Add (yyVals[0+yyTop]);
- } - break; -case 100: -#line 600 "cs-parser.jay" - {
- ArrayList decls = (ArrayList) yyVals[-2+yyTop];
- decls.Add (yyVals[0+yyTop]);
- yyVal = yyVals[-2+yyTop];
- } - break; -case 101: -#line 609 "cs-parser.jay" - {
- yyVal = new VariableDeclaration ((string) yyVals[-2+yyTop], yyVals[0+yyTop]);
- } - break; -case 102: -#line 613 "cs-parser.jay" - {
- yyVal = new VariableDeclaration ((string) yyVals[0+yyTop], null);
- } - break; -case 105: -#line 626 "cs-parser.jay" - {
- Method method = (Method) yyVals[-1+yyTop];
-
- method.Block = (Block) yyVals[0+yyTop];
- CheckDef (current_container.AddMethod (method), method.Name);
-
- current_local_parameters = null;
- } - break; -case 106: -#line 642 "cs-parser.jay" - {
- Method method = new Method ((TypeRef) yyVals[-4+yyTop], (int) yyVals[-5+yyTop], (string) yyVals[-3+yyTop], (Parameters) yyVals[-1+yyTop]);
-
- current_local_parameters = (Parameters) yyVals[-1+yyTop];
-
- yyVal = method;
- } - break; -case 107: -#line 654 "cs-parser.jay" - {
- Method method = new Method (type ("void"), (int) yyVals[-5+yyTop], (string) yyVals[-3+yyTop], (Parameters) yyVals[-1+yyTop]);
-
- current_local_parameters = (Parameters) yyVals[-1+yyTop];
- yyVal = method;
- } - break; -case 109: -#line 664 "cs-parser.jay" - { yyVal = null; } - break; -case 110: -#line 668 "cs-parser.jay" - { yyVal = new Parameters (null, null); } - break; -case 112: -#line 674 "cs-parser.jay" - {
- yyVal = new Parameters ((ParameterCollection) yyVals[0+yyTop], null);
- } - break; -case 113: -#line 678 "cs-parser.jay" - {
- yyVal = new Parameters ((ParameterCollection) yyVals[-2+yyTop], (Parameter) yyVals[0+yyTop]);
- } - break; -case 114: -#line 682 "cs-parser.jay" - {
- yyVal = new Parameters (null, (Parameter) yyVals[0+yyTop]);
- } - break; -case 115: -#line 689 "cs-parser.jay" - {
- ParameterCollection pars = new ParameterCollection ();
- pars.Add ((Parameter) yyVals[0+yyTop]);
- yyVal = pars;
- } - break; -case 116: -#line 695 "cs-parser.jay" - {
- ParameterCollection pars = (ParameterCollection) yyVals[-2+yyTop];
- pars.Add ((Parameter) yyVals[0+yyTop]);
- yyVal = yyVals[-2+yyTop];
- } - break; -case 117: -#line 707 "cs-parser.jay" - {
- yyVal = new Parameter ((TypeRef) yyVals[-1+yyTop], (string) yyVals[0+yyTop], (Parameter.Modifier) yyVals[-2+yyTop]);
- } - break; -case 118: -#line 713 "cs-parser.jay" - { yyVal = Parameter.Modifier.NONE; } - break; -case 120: -#line 718 "cs-parser.jay" - { yyVal = Parameter.Modifier.REF; } - break; -case 121: -#line 719 "cs-parser.jay" - { yyVal = Parameter.Modifier.OUT; } - break; -case 122: -#line 724 "cs-parser.jay" - {
- yyVal = new Parameter ((TypeRef) yyVals[-1+yyTop], (string) yyVals[0+yyTop], Parameter.Modifier.PARAMS);
- note ("type must be a single-dimension array type");
- } - break; -case 123: -#line 731 "cs-parser.jay" - { yyVal = yyVals[0+yyTop].ToString (); } - break; -case 124: -#line 732 "cs-parser.jay" - { yyVal = yyVals[-2+yyTop].ToString () + "." + yyVals[0+yyTop].ToString (); } - break; -case 125: -#line 740 "cs-parser.jay" - {
- Parameter implicit_value_parameter;
- implicit_value_parameter = new Parameter ((TypeRef) yyVals[-2+yyTop], "value", Parameter.Modifier.NONE);
-
- lexer.properties = true;
-
- implicit_value_parameters = new ParameterCollection ();
- implicit_value_parameters.Add (implicit_value_parameter);
- } - break; -case 126: -#line 750 "cs-parser.jay" - {
- lexer.properties = false;
- } - break; -case 127: -#line 754 "cs-parser.jay" - {
- Property prop;
- DictionaryEntry pair = (DictionaryEntry) yyVals[-2+yyTop];
- Block get_block = null;
- Block set_block = null;
-
- if (pair.Key != null)
- get_block = (Block) pair.Key;
- if (pair.Value != null)
- set_block = (Block) pair.Value;
-
- prop = new Property ((TypeRef) yyVals[-6+yyTop], (string) yyVals[-5+yyTop], (int) yyVals[-7+yyTop], get_block, set_block);
-
- CheckDef (current_container.AddProperty (prop), prop.Name);
- implicit_value_parameters = null;
- } - break; -case 128: -#line 774 "cs-parser.jay" - {
- yyVal = new DictionaryEntry (yyVals[-1+yyTop], yyVals[0+yyTop]);
- } - break; -case 129: -#line 778 "cs-parser.jay" - {
- yyVal = new DictionaryEntry (yyVals[0+yyTop], yyVals[-1+yyTop]);
- } - break; -case 130: -#line 784 "cs-parser.jay" - { yyVal = null; } - break; -case 132: -#line 789 "cs-parser.jay" - { yyVal = null; } - break; -case 134: -#line 795 "cs-parser.jay" - {
- yyVal = yyVals[0+yyTop];
- } - break; -case 135: -#line 802 "cs-parser.jay" - {
- current_local_parameters = new Parameters (implicit_value_parameters, null);
- } - break; -case 136: -#line 806 "cs-parser.jay" - {
- yyVal = yyVals[0+yyTop];
- current_local_parameters = null;
- } - break; -case 138: -#line 814 "cs-parser.jay" - { yyVal = new Block (null); } - break; -case 139: -#line 821 "cs-parser.jay" - {
- Interface new_interface;
- string full_interface_name = MakeName ((string) yyVals[0+yyTop]);
-
- new_interface = new Interface (current_container, full_interface_name, (int) yyVals[-2+yyTop]);
- if (current_interface != null)
- error (-2, "Internal compiler error: interface inside interface");
- current_interface = new_interface;
- } - break; -case 140: -#line 832 "cs-parser.jay" - {
- Interface new_interface = (Interface) current_interface;
-
- if (yyVals[-1+yyTop] != null)
- new_interface.Bases = (ArrayList) yyVals[-1+yyTop];
-
- current_interface = null;
- CheckDef (current_container.AddInterface (new_interface), new_interface.Name);
- } - break; -case 141: -#line 844 "cs-parser.jay" - { yyVal = null; } - break; -case 143: -#line 849 "cs-parser.jay" - { yyVal = yyVals[0+yyTop]; } - break; -case 144: -#line 854 "cs-parser.jay" - {
- ArrayList interfaces = new ArrayList ();
-
- interfaces.Add (yyVals[0+yyTop]);
- } - break; -case 145: -#line 860 "cs-parser.jay" - {
- ArrayList interfaces = (ArrayList) yyVals[-2+yyTop];
- interfaces.Add (yyVals[0+yyTop]);
- yyVal = interfaces;
- } - break; -case 151: -#line 885 "cs-parser.jay" - {
- InterfaceMethod m = (InterfaceMethod) yyVals[0+yyTop];
-
- CheckDef (current_interface.AddMethod (m), m.Name);
- } - break; -case 152: -#line 891 "cs-parser.jay" - {
- InterfaceProperty p = (InterfaceProperty) yyVals[0+yyTop];
-
- CheckDef (current_interface.AddProperty (p), p.Name);
- } - break; -case 153: -#line 897 "cs-parser.jay" - {
- InterfaceEvent e = (InterfaceEvent) yyVals[0+yyTop];
-
- CheckDef (current_interface.AddEvent (e), e.Name);
- } - break; -case 154: -#line 903 "cs-parser.jay" - {
- InterfaceIndexer i = (InterfaceIndexer) yyVals[0+yyTop];
-
- CheckDef (current_interface.AddIndexer (i), "indexer");
- } - break; -case 155: -#line 911 "cs-parser.jay" - { yyVal = false; } - break; -case 156: -#line 912 "cs-parser.jay" - { yyVal = true; } - break; -case 157: -#line 919 "cs-parser.jay" - {
- yyVal = new InterfaceMethod ((TypeRef) yyVals[-5+yyTop], (string) yyVals[-4+yyTop], (bool) yyVals[-6+yyTop], (Parameters) yyVals[-2+yyTop]);
- } - break; -case 158: -#line 925 "cs-parser.jay" - {
- yyVal = new InterfaceMethod (type ("void"), (string) yyVals[-4+yyTop], (bool) yyVals[-6+yyTop], (Parameters) yyVals[-2+yyTop]);
- } - break; -case 159: -#line 935 "cs-parser.jay" - { lexer.properties = true; } - break; -case 160: -#line 937 "cs-parser.jay" - { lexer.properties = false; } - break; -case 161: -#line 939 "cs-parser.jay" - {
- int gs = (int) yyVals[-2+yyTop];
-
- yyVal = new InterfaceProperty ((TypeRef) yyVals[-6+yyTop], (string) yyVals[-5+yyTop], (bool) yyVals[-7+yyTop],
- (gs & 1) == 1, (gs & 2) == 2);
- } - break; -case 162: -#line 948 "cs-parser.jay" - { yyVal = 1; } - break; -case 163: -#line 949 "cs-parser.jay" - { yyVal = 2; } - break; -case 164: -#line 951 "cs-parser.jay" - { yyVal = 3; } - break; -case 165: -#line 953 "cs-parser.jay" - { yyVal = 3; } - break; -case 166: -#line 958 "cs-parser.jay" - {
- yyVal = new InterfaceEvent ((TypeRef) yyVals[-2+yyTop], (string) yyVals[-1+yyTop], (bool) yyVals[-4+yyTop]);
- } - break; -case 167: -#line 967 "cs-parser.jay" - { lexer.properties = true; } - break; -case 168: -#line 969 "cs-parser.jay" - { lexer.properties = false; } - break; -case 169: -#line 971 "cs-parser.jay" - {
- int a_flags = (int) yyVals[-2+yyTop];
-
- bool do_get = (a_flags & 1) == 1;
- bool do_set = (a_flags & 2) == 2;
-
- yyVal = new InterfaceIndexer ((TypeRef) yyVals[-9+yyTop], (Parameters) yyVals[-6+yyTop], do_get, do_set, (bool) yyVals[-10+yyTop]);
- } - break; -case 170: -#line 983 "cs-parser.jay" - {
- /* FIXME: validate that opt_modifiers is exactly: PUBLIC and STATIC
*/ - } - break; -case 171: -#line 991 "cs-parser.jay" - {
- /* FIXME: since reduce/reduce on this
*/ - /* rule, validate overloadable_operator is unary
*/ - } - break; -case 172: -#line 1000 "cs-parser.jay" - {
- /* FIXME: because of the reduce/reduce on PLUS and MINUS
*/ - /* validate overloadable_operator is binary
*/ - } - break; -case 198: -#line 1045 "cs-parser.jay" - {
- Constructor c = (Constructor) yyVals[-1+yyTop];
- c.Block = (Block) yyVals[0+yyTop];
- c.ModFlags = (int) yyVals[-2+yyTop];
-
- if ((c.ModFlags & Modifiers.STATIC) != 0){
- if ((c.ModFlags & Modifiers.Accessibility) != 0){
- error (515, "Access modifiers are not allowed on static constructors");
- }
- }
- CheckDef (current_container.AddConstructor (c), c.Name);
-
- current_local_parameters = null;
- } - break; -case 199: -#line 1065 "cs-parser.jay" - {
- ConstructorInitializer i = null;
-
- if (yyVals[0+yyTop] != null)
- i = (ConstructorInitializer) yyVals[0+yyTop];
-
- yyVal = new Constructor ((string) yyVals[-4+yyTop], (Parameters) yyVals[-2+yyTop], i);
-
- current_local_parameters = (Parameters) yyVals[-2+yyTop];
- } - break; -case 200: -#line 1078 "cs-parser.jay" - { yyVal = null; } - break; -case 202: -#line 1084 "cs-parser.jay" - {
- yyVal = new ConstructorBaseInitializer ((ArrayList) yyVals[-1+yyTop]);
- } - break; -case 203: -#line 1088 "cs-parser.jay" - {
- yyVal = new ConstructorThisInitializer ((ArrayList) yyVals[-1+yyTop]);
- } - break; -case 204: -#line 1095 "cs-parser.jay" - {
- Method d = new Method (type ("void"), 0, "Finalize", new Parameters (null, null));
-
- d.Block = (Block) yyVals[0+yyTop];
- CheckDef (current_container.AddMethod (d), d.Name);
- } - break; -case 205: -#line 1107 "cs-parser.jay" - { note ("validate that the flags only contain new public protected internal private static virtual sealed override abstract"); } - break; -case 206: -#line 1112 "cs-parser.jay" - { note ("validate that the flags only contain new public protected internal private static virtual sealed override abstract"); } - break; -case 211: -#line 1131 "cs-parser.jay" - {
- /* The signature is computed from the signature of the indexer. Look
*/ - /* at section 3.6 on the spec
*/ - note ("verify modifiers are NEW PUBLIC PROTECTED INTERNAL PRIVATE VIRTUAL SEALED OVERRIDE ABSTRACT");
- } - break; -case 214: -#line 1150 "cs-parser.jay" - {
- string name = (string) yyVals[-3+yyTop];
- Enum e = new Enum ((TypeRef) yyVals[-2+yyTop], (int) yyVals[-5+yyTop], name);
-
- foreach (VariableDeclaration ev in (ArrayList) yyVals[-1+yyTop]){
- CheckDef (
- e.AddEnum (
- ev.identifier,
- (Expression) ev.expression_or_array_initializer),
- ev.identifier);
- }
-
- CheckDef (current_container.AddEnum (e), name);
- } - break; -case 215: -#line 1167 "cs-parser.jay" - { yyVal = type ("System.Int32"); } - break; -case 216: -#line 1168 "cs-parser.jay" - { yyVal = yyVals[0+yyTop]; } - break; -case 217: -#line 1173 "cs-parser.jay" - {
- yyVal = yyVals[-1+yyTop];
- } - break; -case 218: -#line 1177 "cs-parser.jay" - {
- yyVal = yyVals[-2+yyTop];
- } - break; -case 219: -#line 1183 "cs-parser.jay" - { yyVal = new ArrayList (); } - break; -case 220: -#line 1184 "cs-parser.jay" - { yyVal = yyVals[0+yyTop]; } - break; -case 221: -#line 1189 "cs-parser.jay" - {
- ArrayList l = new ArrayList ();
-
- l.Add (yyVals[0+yyTop]);
- yyVal = l;
- } - break; -case 222: -#line 1196 "cs-parser.jay" - {
- ArrayList l = (ArrayList) yyVals[-2+yyTop];
-
- l.Add (yyVals[0+yyTop]);
-
- yyVal = l;
- } - break; -case 223: -#line 1207 "cs-parser.jay" - {
- yyVal = new VariableDeclaration ((string) yyVals[0+yyTop], null);
- } - break; -case 224: -#line 1211 "cs-parser.jay" - {
- yyVal = new VariableDeclaration ((string) yyVals[-2+yyTop], yyVals[0+yyTop]);
- } - break; -case 225: -#line 1224 "cs-parser.jay" - { note ("validate that modifiers only contains NEW PUBLIC PROTECTED INTERNAL PRIVATE"); } - break; -case 228: -#line 1242 "cs-parser.jay" - { /* class_type */
- /*
- This does interfaces, delegates, struct_types, class_types,
- parent classes, and more! 4.2
- */
- yyVal = type ((string) yyVals[0+yyTop]);
- } - break; -case 231: -#line 1255 "cs-parser.jay" - {
- ArrayList types = new ArrayList ();
-
- types.Add (yyVals[0+yyTop]);
- yyVal = types;
- } - break; -case 232: -#line 1262 "cs-parser.jay" - {
- ArrayList types = new ArrayList ();
- types.Add (yyVals[0+yyTop]);
- yyVal = types;
- } - break; -case 233: -#line 1274 "cs-parser.jay" - { yyVal = type ("System.Object"); } - break; -case 234: -#line 1275 "cs-parser.jay" - { yyVal = type ("System.String"); } - break; -case 235: -#line 1276 "cs-parser.jay" - { yyVal = type ("System.Boolean"); } - break; -case 236: -#line 1277 "cs-parser.jay" - { yyVal = type ("System.Decimal"); } - break; -case 237: -#line 1278 "cs-parser.jay" - { yyVal = type ("System.Single"); } - break; -case 238: -#line 1279 "cs-parser.jay" - { yyVal = type ("System.Double"); } - break; -case 240: -#line 1284 "cs-parser.jay" - { yyVal = type ("System.SByte"); } - break; -case 241: -#line 1285 "cs-parser.jay" - { yyVal = type ("System.Byte"); } - break; -case 242: -#line 1286 "cs-parser.jay" - { yyVal = type ("System.Int16"); } - break; -case 243: -#line 1287 "cs-parser.jay" - { yyVal = type ("System.UInt16"); } - break; -case 244: -#line 1288 "cs-parser.jay" - { yyVal = type ("System.Int32"); } - break; -case 245: -#line 1289 "cs-parser.jay" - { yyVal = type ("System.UInt32"); } - break; -case 246: -#line 1290 "cs-parser.jay" - { yyVal = type ("System.Int64"); } - break; -case 247: -#line 1291 "cs-parser.jay" - { yyVal = type ("System.UInt64"); } - break; -case 248: -#line 1292 "cs-parser.jay" - { yyVal = type ("System.Char"); } - break; -case 250: -#line 1301 "cs-parser.jay" - {
- yyVal = yyVals[-1+yyTop];
- /* FIXME: We need to create a type for the nested thing.
*/ - } - break; -case 251: -#line 1312 "cs-parser.jay" - {
- /* 7.5.1: Literals
*/ -
- } - break; -case 252: -#line 1318 "cs-parser.jay" - {
- string name = (string) yyVals[0+yyTop];
-
- yyVal = null;
- if (name.IndexOf ('.') == -1){
- /*
*/ - /* we need to check against current_block not being null
*/ - /* as `expression' is allowed in argument_lists, which
*/ - /* do not exist inside a block.
*/ - /*
*/ - if (current_block != null){
- if (current_block.IsVariableDefined (name))
- yyVal = new LocalVariableReference (current_block, name);
- }
- if ((yyVal == null) && (current_local_parameters != null)){
- Parameter par = current_local_parameters.GetParameterByName (name);
- if (par != null)
- yyVal = new ParameterReference (current_local_parameters, name);
- }
- }
- if (yyVal == null)
- yyVal = new SimpleName (name);
- } - break; -case 269: -#line 1360 "cs-parser.jay" - { yyVal = new CharLiteral ((char) lexer.Value); } - break; -case 270: -#line 1361 "cs-parser.jay" - { yyVal = new StringLiteral ((string) lexer.Value); } - break; -case 271: -#line 1362 "cs-parser.jay" - { yyVal = new NullLiteral (); } - break; -case 272: -#line 1366 "cs-parser.jay" - { yyVal = new FloatLiteral ((float) lexer.Value); } - break; -case 273: -#line 1367 "cs-parser.jay" - { yyVal = new DoubleLiteral ((double) lexer.Value); } - break; -case 274: -#line 1368 "cs-parser.jay" - { yyVal = new DecimalLiteral ((decimal) lexer.Value); } - break; -case 275: -#line 1372 "cs-parser.jay" - { yyVal = new IntLiteral ((Int32) lexer.Value); } - break; -case 276: -#line 1376 "cs-parser.jay" - { yyVal = new BoolLiteral (true); } - break; -case 277: -#line 1377 "cs-parser.jay" - { yyVal = new BoolLiteral (false); } - break; -case 278: -#line 1382 "cs-parser.jay" - { yyVal = yyVals[-1+yyTop]; } - break; -case 279: -#line 1387 "cs-parser.jay" - {
- yyVal = new MemberAccess ((Expression) yyVals[-2+yyTop], (string) yyVals[0+yyTop]);
- } - break; -case 280: -#line 1391 "cs-parser.jay" - {
- yyVal = new BuiltinTypeAccess ((TypeRef) yyVals[-2+yyTop], (string) yyVals[0+yyTop]);
- } - break; -case 282: -#line 1402 "cs-parser.jay" - {
- /* FIXME:
*/ - /* if $1 is MethodGroup
*/ - /* $$ = new Call ($1, $3);
*/ - /* else
*/ - /* $$ = new DelegateCall ($1, $3);
*/ - if (yyVals[-3+yyTop] == null)
- error (1, "THIS IS CRAZY");
-
- yyVal = new Invocation ((Expression) yyVals[-3+yyTop], (ArrayList) yyVals[-1+yyTop]);
- } - break; -case 283: -#line 1416 "cs-parser.jay" - { yyVal = new ArrayList (); } - break; -case 285: -#line 1422 "cs-parser.jay" - {
- ArrayList list = new ArrayList ();
- list.Add (yyVals[0+yyTop]);
- yyVal = list;
- } - break; -case 286: -#line 1428 "cs-parser.jay" - {
- ArrayList list = (ArrayList) yyVals[-2+yyTop];
- list.Add (yyVals[0+yyTop]);
- yyVal = list;
- } - break; -case 287: -#line 1437 "cs-parser.jay" - {
- yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Expression);
- } - break; -case 288: -#line 1441 "cs-parser.jay" - {
- yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Ref);
- } - break; -case 289: -#line 1445 "cs-parser.jay" - {
- yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Out);
- } - break; -case 290: -#line 1451 "cs-parser.jay" - { note ("section 5.4"); yyVal = yyVals[0+yyTop]; } - break; -case 294: -#line 1466 "cs-parser.jay" - {
- yyVal = new This ();
- } - break; -case 297: -#line 1480 "cs-parser.jay" - {
- yyVal = new Unary (Unary.Operator.PostIncrement, (Expression) yyVals[-1+yyTop]);
- } - break; -case 298: -#line 1487 "cs-parser.jay" - {
- yyVal = new Unary (Unary.Operator.PostDecrement, (Expression) yyVals[-1+yyTop]);
- } - break; -case 301: -#line 1499 "cs-parser.jay" - {
- yyVal = new New ((TypeRef) yyVals[-3+yyTop], (ArrayList) yyVals[-1+yyTop]);
- } - break; -case 319: -#line 1559 "cs-parser.jay" - {
- yyVal = new TypeOf ((TypeRef) yyVals[-1+yyTop]);
- } - break; -case 320: -#line 1565 "cs-parser.jay" - {
- yyVal = new SizeOf ((TypeRef) yyVals[-1+yyTop]);
-
- note ("Verify type is unmanaged");
- note ("if (5.8) builtin, yield constant expression");
- } - break; -case 324: -#line 1583 "cs-parser.jay" - {
- yyVal = new Unary (Unary.Operator.Plus, (Expression) yyVals[0+yyTop]);
- } - break; -case 325: -#line 1587 "cs-parser.jay" - {
- yyVal = new Unary (Unary.Operator.Minus, (Expression) yyVals[0+yyTop]);
- } - break; -case 326: -#line 1591 "cs-parser.jay" - {
- yyVal = new Unary (Unary.Operator.Negate, (Expression) yyVals[0+yyTop]);
- } - break; -case 327: -#line 1595 "cs-parser.jay" - {
- yyVal = new Unary (Unary.Operator.BitComplement, (Expression) yyVals[0+yyTop]);
- } - break; -case 328: -#line 1599 "cs-parser.jay" - {
- yyVal = new Unary (Unary.Operator.Indirection, (Expression) yyVals[0+yyTop]);
- } - break; -case 329: -#line 1603 "cs-parser.jay" - {
- yyVal = new Unary (Unary.Operator.AddressOf, (Expression) yyVals[0+yyTop]);
- } - break; -case 333: -#line 1618 "cs-parser.jay" - {
- yyVal = new Unary (Unary.Operator.PreIncrement, (Expression) yyVals[0+yyTop]);
- } - break; -case 334: -#line 1625 "cs-parser.jay" - {
- yyVal = new Unary (Unary.Operator.PreDecrement, (Expression) yyVals[0+yyTop]);
- } - break; -case 335: -#line 1635 "cs-parser.jay" - {
- yyVal = new Cast (type ((string) yyVals[-2+yyTop]), (Expression) yyVals[0+yyTop]);
- } - break; -case 336: -#line 1639 "cs-parser.jay" - {
- yyVal = new Cast ((TypeRef) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 338: -#line 1647 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.Multiply,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 339: -#line 1652 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.Divide,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 340: -#line 1657 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.Modulo,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 342: -#line 1666 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.Add,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 343: -#line 1671 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.Substract,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 345: -#line 1680 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.ShiftLeft,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 346: -#line 1685 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.ShiftRight,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 348: -#line 1694 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.LessThan,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 349: -#line 1699 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.GreatherThan,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 350: -#line 1704 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.LessOrEqual,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 351: -#line 1709 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.GreatherOrEqual,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 352: -#line 1714 "cs-parser.jay" - {
- yyVal = new Probe (Probe.Operator.Is,
- (Expression) yyVals[-2+yyTop], (TypeRef) yyVals[0+yyTop]);
- } - break; -case 353: -#line 1719 "cs-parser.jay" - {
- yyVal = new Probe (Probe.Operator.As,
- (Expression) yyVals[-2+yyTop], (TypeRef) yyVals[0+yyTop]);
- } - break; -case 355: -#line 1728 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.Equal,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 356: -#line 1733 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.NotEqual,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 358: -#line 1742 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.BitwiseAnd,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 360: -#line 1751 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.ExclusiveOr,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 362: -#line 1760 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.BitwiseOr,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 364: -#line 1769 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.LogicalAnd,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 366: -#line 1778 "cs-parser.jay" - {
- yyVal = new Binary (Binary.Operator.LogicalOr,
- (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 368: -#line 1787 "cs-parser.jay" - {
- yyVal = new Conditional ((Expression) yyVals[-4+yyTop], (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 369: -#line 1794 "cs-parser.jay" - {
- yyVal = new Assign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
- } - break; -case 370: -#line 1798 "cs-parser.jay" - {
- yyVal = new Assign ((Expression) yyVals[-2+yyTop],
- new Binary (Binary.Operator.Multiply,
- (Expression) yyVals[-2+yyTop],
- (Expression) yyVals[0+yyTop]));
- } - break; -case 371: -#line 1805 "cs-parser.jay" - {
- yyVal = new Assign ((Expression) yyVals[-2+yyTop],
- new Binary (Binary.Operator.Divide,
- (Expression) yyVals[-2+yyTop],
- (Expression) yyVals[0+yyTop]));
- } - break; -case 372: -#line 1812 "cs-parser.jay" - {
- yyVal = new Assign ((Expression) yyVals[-2+yyTop],
- new Binary (Binary.Operator.Modulo,
- (Expression) yyVals[-2+yyTop],
- (Expression) yyVals[0+yyTop]));
- } - break; -case 373: -#line 1819 "cs-parser.jay" - {
- yyVal = new Assign ((Expression) yyVals[-2+yyTop],
- new Binary (Binary.Operator.Add,
- (Expression) yyVals[-2+yyTop],
- (Expression) yyVals[0+yyTop]));
- } - break; -case 374: -#line 1826 "cs-parser.jay" - {
- yyVal = new Assign ((Expression) yyVals[-2+yyTop],
- new Binary (Binary.Operator.Substract,
- (Expression) yyVals[-2+yyTop],
- (Expression) yyVals[0+yyTop]));
- } - break; -case 375: -#line 1833 "cs-parser.jay" - {
- yyVal = new Assign ((Expression) yyVals[-2+yyTop],
- new Binary (Binary.Operator.ShiftLeft,
- (Expression) yyVals[-2+yyTop],
- (Expression) yyVals[0+yyTop]));
- } - break; -case 376: -#line 1840 "cs-parser.jay" - {
- yyVal = new Assign ((Expression) yyVals[-2+yyTop],
- new Binary (Binary.Operator.ShiftRight,
- (Expression) yyVals[-2+yyTop],
- (Expression) yyVals[0+yyTop]));
- } - break; -case 377: -#line 1847 "cs-parser.jay" - {
- yyVal = new Assign ((Expression) yyVals[-2+yyTop],
- new Binary (Binary.Operator.BitwiseAnd,
- (Expression) yyVals[-2+yyTop],
- (Expression) yyVals[0+yyTop]));
- } - break; -case 378: -#line 1854 "cs-parser.jay" - {
- yyVal = new Assign ((Expression) yyVals[-2+yyTop],
- new Binary (Binary.Operator.BitwiseOr,
- (Expression) yyVals[-2+yyTop],
- (Expression) yyVals[0+yyTop]));
- } - break; -case 379: -#line 1861 "cs-parser.jay" - {
- yyVal = new Assign ((Expression) yyVals[-2+yyTop],
- new Binary (Binary.Operator.ExclusiveOr,
- (Expression) yyVals[-2+yyTop],
- (Expression) yyVals[0+yyTop]));
- } - break; -case 383: -#line 1879 "cs-parser.jay" - { CheckBoolean ((Expression) yyVals[0+yyTop]); yyVal = yyVals[0+yyTop]; } - break; -case 384: -#line 1889 "cs-parser.jay" - {
- Class new_class;
- string full_class_name = MakeName ((string) yyVals[0+yyTop]);
-
- new_class = new Class (current_container, full_class_name, (int) yyVals[-2+yyTop]);
- current_container = new_class;
- current_container.Namespace = current_namespace;
- } - break; -case 385: -#line 1900 "cs-parser.jay" - {
- Class new_class = (Class) current_container;
-
- if (yyVals[-2+yyTop] != null)
- new_class.Bases = (ArrayList) yyVals[-2+yyTop];
-
- current_container = current_container.Parent;
- CheckDef (current_container.AddClass (new_class), new_class.Name);
-
- yyVal = new_class;
- } - break; -case 386: -#line 1914 "cs-parser.jay" - { yyVal = (int) 0; } - break; -case 389: -#line 1920 "cs-parser.jay" - {
- int m1 = (int) yyVals[-1+yyTop];
- int m2 = (int) yyVals[0+yyTop];
-
- if ((m1 & m2) != 0)
- error (1002, "Duplicate modifier: `" + Modifiers.Name (m2) + "'");
-
- yyVal = (int) (m1 | m2);
- } - break; -case 390: -#line 1932 "cs-parser.jay" - { yyVal = Modifiers.NEW; } - break; -case 391: -#line 1933 "cs-parser.jay" - { yyVal = Modifiers.PUBLIC; } - break; -case 392: -#line 1934 "cs-parser.jay" - { yyVal = Modifiers.PROTECTED; } - break; -case 393: -#line 1935 "cs-parser.jay" - { yyVal = Modifiers.INTERNAL; } - break; -case 394: -#line 1936 "cs-parser.jay" - { yyVal = Modifiers.PRIVATE; } - break; -case 395: -#line 1937 "cs-parser.jay" - { yyVal = Modifiers.ABSTRACT; } - break; -case 396: -#line 1938 "cs-parser.jay" - { yyVal = Modifiers.SEALED; } - break; -case 397: -#line 1939 "cs-parser.jay" - { yyVal = Modifiers.STATIC; } - break; -case 398: -#line 1940 "cs-parser.jay" - { yyVal = Modifiers.READONLY; } - break; -case 399: -#line 1941 "cs-parser.jay" - { yyVal = Modifiers.VIRTUAL; } - break; -case 400: -#line 1942 "cs-parser.jay" - { yyVal = Modifiers.OVERRIDE; } - break; -case 401: -#line 1943 "cs-parser.jay" - { yyVal = Modifiers.EXTERN; } - break; -case 402: -#line 1947 "cs-parser.jay" - { yyVal = null; } - break; -case 403: -#line 1948 "cs-parser.jay" - { yyVal = yyVals[0+yyTop]; } - break; -case 404: -#line 1952 "cs-parser.jay" - { yyVal = yyVals[0+yyTop]; } - break; -case 405: -#line 1970 "cs-parser.jay" - {
- current_block = new Block (current_block);
- } - break; -case 406: -#line 1974 "cs-parser.jay" - {
- while (current_block.Implicit)
- current_block = current_block.Parent;
- yyVal = current_block;
- current_block = current_block.Parent;
- } - break; -case 411: -#line 1994 "cs-parser.jay" - {
- if ((Block) yyVals[0+yyTop] != current_block){
- current_block.AddStatement ((Statement) yyVals[0+yyTop]);
- current_block = (Block) yyVals[0+yyTop];
- }
- } - break; -case 412: -#line 2001 "cs-parser.jay" - {
- current_block.AddStatement ((Statement) yyVals[0+yyTop]);
- } - break; -case 413: -#line 2005 "cs-parser.jay" - {
- current_block.AddStatement ((Statement) yyVals[0+yyTop]);
- } - break; -case 425: -#line 2026 "cs-parser.jay" - {
- yyVal = new EmptyStatement ();
- } - break; -case 426: -#line 2033 "cs-parser.jay" - {
- string lab = (String) yyVals[-2+yyTop];
- Block block;
-
- block = new Block (current_block, lab);
- block.AddStatement ((Statement) yyVals[0+yyTop]);
- yyVal = block;
-
- if (!current_block.AddLabel (lab, block)){
- error (140, "The label '" + lab + "' is a duplicate");
- yyVal = yyVals[0+yyTop];
- }
- } - break; -case 429: -#line 2061 "cs-parser.jay" - {
- /* FIXME: Do something smart here regarding the composition of the type.
*/ - /*
*/ -
- /* Ok, the above "primary_expression" is there to get rid of
*/ - /* both reduce/reduce and shift/reduces in the grammar, it should
*/ - /* really just be "type_name". If you use type_name, a reduce/reduce
*/ - /* creeps up. If you use qualified_identifier (which is all we need
*/ - /* really) two shift/reduces appear.
*/ - /*
*/ - /* So, instead we do a super trick: we just allow ($1) to be a
*/ - /* SimpleName Expression.
*/ - /*
*/ - if (((Expression) yyVals[-1+yyTop]) is SimpleName)
- yyVal = type (((SimpleName) yyVals[-1+yyTop]).Name);
- else {
- error (-1, "Invalid Type definition");
- yyVal = type ("object");
- }
- } - break; -case 430: -#line 2082 "cs-parser.jay" - {
- /* FIXME: Do something smart with the type here.
*/ - yyVal = yyVals[-1+yyTop];
- } - break; -case 431: -#line 2087 "cs-parser.jay" - {
- yyVal = type ("VOID SOMETHING TYPE");
- } - break; -case 437: -#line 2109 "cs-parser.jay" - {
- yyVal = declare_local_variables ((TypeRef) yyVals[-1+yyTop], (ArrayList) yyVals[0+yyTop]);
- } - break; -case 439: -#line 2121 "cs-parser.jay" - {
- yyVal = yyVals[-1+yyTop];
- } - break; -case 440: -#line 2131 "cs-parser.jay" - { yyVal = new StatementExpression ((Expression) yyVals[0+yyTop]); } - break; -case 441: -#line 2132 "cs-parser.jay" - { yyVal = new StatementExpression ((Expression) yyVals[0+yyTop]); } - break; -case 442: -#line 2133 "cs-parser.jay" - { yyVal = new StatementExpression ((Expression) yyVals[0+yyTop]); } - break; -case 443: -#line 2134 "cs-parser.jay" - { yyVal = new StatementExpression ((Expression) yyVals[0+yyTop]); } - break; -case 444: -#line 2135 "cs-parser.jay" - { yyVal = new StatementExpression ((Expression) yyVals[0+yyTop]); } - break; -case 445: -#line 2136 "cs-parser.jay" - { yyVal = new StatementExpression ((Expression) yyVals[0+yyTop]); } - break; -case 446: -#line 2137 "cs-parser.jay" - { yyVal = new StatementExpression ((Expression) yyVals[0+yyTop]); } - break; -case 447: -#line 2142 "cs-parser.jay" - { note ("complain if this is a delegate maybe?"); } - break; -case 450: -#line 2153 "cs-parser.jay" - {
- yyVal = new If ((Expression) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop]);
- } - break; -case 451: -#line 2158 "cs-parser.jay" - {
- yyVal = new If ((Expression) yyVals[-4+yyTop], (Statement) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop]);
- } - break; -case 452: -#line 2166 "cs-parser.jay" - {
- yyVal = new Switch ((Expression) yyVals[-2+yyTop], (ArrayList) yyVals[0+yyTop]);
- } - break; -case 453: -#line 2175 "cs-parser.jay" - {
- yyVal = yyVals[-1+yyTop];
- } - break; -case 454: -#line 2181 "cs-parser.jay" - { yyVal = new ArrayList (); } - break; -case 456: -#line 2187 "cs-parser.jay" - {
- ArrayList sections = new ArrayList ();
-
- sections.Add (yyVals[0+yyTop]);
- yyVal = sections;
- } - break; -case 457: -#line 2194 "cs-parser.jay" - {
- ArrayList sections = (ArrayList) yyVals[-1+yyTop];
-
- sections.Add (yyVals[0+yyTop]);
- yyVal = sections;
- } - break; -case 458: -#line 2204 "cs-parser.jay" - {
- current_block = new Block (current_block);
- } - break; -case 459: -#line 2208 "cs-parser.jay" - {
- while (current_block.Implicit)
- current_block = current_block.Parent;
- yyVal = new SwitchSection ((ArrayList) yyVals[-2+yyTop], current_block);
- current_block = current_block.Parent;
- } - break; -case 460: -#line 2218 "cs-parser.jay" - {
- ArrayList labels = new ArrayList ();
-
- labels.Add (yyVals[0+yyTop]);
- yyVal = labels;
- } - break; -case 461: -#line 2225 "cs-parser.jay" - {
- ArrayList labels = (ArrayList) (yyVals[-1+yyTop]);
- labels.Add (yyVals[0+yyTop]);
-
- yyVal = labels;
- } - break; -case 462: -#line 2234 "cs-parser.jay" - { yyVal = new SwitchLabel ((Expression) yyVals[-1+yyTop]); } - break; -case 463: -#line 2235 "cs-parser.jay" - { yyVal = new SwitchLabel (null); } - break; -case 468: -#line 2247 "cs-parser.jay" - {
- yyVal = new While ((Expression) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop]);
- } - break; -case 469: -#line 2255 "cs-parser.jay" - {
- yyVal = new Do ((Statement) yyVals[-5+yyTop], (Expression) yyVals[-2+yyTop]);
- } - break; -case 470: -#line 2266 "cs-parser.jay" - {
- yyVal = new For ((Statement) yyVals[-6+yyTop], (Expression) yyVals[-4+yyTop], (Statement) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop]);
- } - break; -case 471: -#line 2272 "cs-parser.jay" - { yyVal = new EmptyStatement (); } - break; -case 475: -#line 2282 "cs-parser.jay" - { yyVal = new BoolLiteral (true); } - break; -case 477: -#line 2287 "cs-parser.jay" - { yyVal = new EmptyStatement (); } - break; -case 480: -#line 2297 "cs-parser.jay" - {
- Block b = new Block (null, true);
-
- b.AddStatement ((Statement) yyVals[0+yyTop]);
- yyVal = b;
- } - break; -case 481: -#line 2304 "cs-parser.jay" - {
- Block b = (Block) yyVals[-2+yyTop];
-
- b.AddStatement ((Statement) yyVals[0+yyTop]);
- yyVal = yyVals[-2+yyTop];
- } - break; -case 482: -#line 2315 "cs-parser.jay" - {
- string temp_id = current_block.MakeInternalID ();
- Expression assign_e, ma;
- Statement getcurrent;
- Block foreach_block, child_block;
-
- foreach_block = new Block (current_block, true);
-
- foreach_block.AddVariable (type ("IEnumerator"), temp_id);
- foreach_block.AddVariable ((TypeRef) yyVals[-5+yyTop], (string) yyVals[-4+yyTop]);
- assign_e = new Assign (new LocalVariableReference (foreach_block, temp_id),
- new Invocation (
- new MemberAccess ((Expression) yyVals[-2+yyTop], "GetEnumerator"), null));
- current_block.AddStatement (new StatementExpression (assign_e));
- ma = new MemberAccess (new LocalVariableReference (foreach_block, temp_id), "MoveNext");
- child_block = new Block (current_block);
-
- getcurrent = new StatementExpression (
- new Assign (
- new LocalVariableReference (foreach_block, (string) yyVals[-4+yyTop]),
- new Cast (
- (TypeRef) yyVals[-5+yyTop],
- new MemberAccess (
- new LocalVariableReference (foreach_block, temp_id), "Current"))));
-
- child_block.AddStatement (getcurrent);
- child_block.AddStatement ((Statement) yyVals[0+yyTop]);
- foreach_block.AddStatement (new While (ma, (Statement) child_block));
-
- yyVal = foreach_block;
- } - break; -case 488: -#line 2358 "cs-parser.jay" - {
- yyVal = new Break ();
- } - break; -case 489: -#line 2365 "cs-parser.jay" - {
- yyVal = new Continue ();
- } - break; -case 490: -#line 2372 "cs-parser.jay" - {
- yyVal = new Goto ((string) yyVals[-1+yyTop]);
- } - break; -case 493: -#line 2381 "cs-parser.jay" - {
- yyVal = new Return ((Expression) yyVals[-1+yyTop]);
- } - break; -case 494: -#line 2388 "cs-parser.jay" - {
- yyVal = new Throw ((Expression) yyVals[-1+yyTop]);
- } - break; -case 497: -#line 2400 "cs-parser.jay" - {
- DictionaryEntry cc = (DictionaryEntry) yyVals[0+yyTop];
- ArrayList s = null;
-
- if (cc.Key != null)
- s = (ArrayList) cc.Key;
-
- yyVal = new Try ((Block) yyVals[-1+yyTop], s, (Catch) cc.Value, null);
- } - break; -case 498: -#line 2410 "cs-parser.jay" - {
- yyVal = new Try ((Block) yyVals[-1+yyTop], null, null, (Block) yyVals[0+yyTop]);
- } - break; -case 499: -#line 2414 "cs-parser.jay" - {
- DictionaryEntry cc = (DictionaryEntry) yyVals[-1+yyTop];
- ArrayList s = null;
-
- if (cc.Key != null)
- s = (ArrayList) cc.Key;
-
- yyVal = new Try ((Block) yyVals[-2+yyTop], s, (Catch) cc.Value, (Block) yyVals[0+yyTop]);
- } - break; -case 500: -#line 2427 "cs-parser.jay" - {
- DictionaryEntry pair = new DictionaryEntry ();
-
- pair.Key = yyVals[-1+yyTop];
- pair.Value = yyVals[0+yyTop];
-
- yyVal = pair;
- } - break; -case 501: -#line 2436 "cs-parser.jay" - {
- DictionaryEntry pair = new DictionaryEntry ();
- pair.Key = yyVals[-1+yyTop];
- pair.Value = yyVals[-1+yyTop];
-
- yyVal = pair;
- } - break; -case 502: -#line 2446 "cs-parser.jay" - { yyVal = null; } - break; -case 504: -#line 2451 "cs-parser.jay" - { yyVal = null; } - break; -case 506: -#line 2457 "cs-parser.jay" - {
- ArrayList l = new ArrayList ();
-
- l.Add (yyVals[0+yyTop]);
- yyVal = l;
- } - break; -case 507: -#line 2464 "cs-parser.jay" - {
- ArrayList l = (ArrayList) yyVals[-1+yyTop];
-
- l.Add (yyVals[0+yyTop]);
- yyVal = l;
- } - break; -case 508: -#line 2474 "cs-parser.jay" - {
- string id = null;
-
- if (yyVals[-2+yyTop] != null)
- id = (string) yyVals[-2+yyTop];
-
- yyVal = new Catch ((TypeRef) yyVals[-3+yyTop], id, (Block) yyVals[0+yyTop]);
- } - break; -case 509: -#line 2485 "cs-parser.jay" - { yyVal = null; } - break; -case 511: -#line 2491 "cs-parser.jay" - {
- yyVal = new Catch (null, null, (Block) yyVals[0+yyTop]);
- } - break; -case 512: -#line 2498 "cs-parser.jay" - {
- yyVal = yyVals[0+yyTop];
- } - break; -case 513: -#line 2505 "cs-parser.jay" - {
- yyVal = new Checked ((Block) yyVals[0+yyTop]);
- } - break; -case 514: -#line 2512 "cs-parser.jay" - {
- yyVal = new Unchecked ((Block) yyVals[0+yyTop]);
- } - break; -case 515: -#line 2519 "cs-parser.jay" - {
- yyVal = new Lock ((Expression) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop]);
- } - break; -#line 2673 "-" - } - yyTop -= yyLen[yyN]; - yyState = yyStates[yyTop]; - int yyM = yyLhs[yyN]; - if (yyState == 0 && yyM == 0) { - if (yydebug != null) yydebug.shift(0, yyFinal); - yyState = yyFinal; - if (yyToken < 0) { - yyToken = yyLex.advance() ? yyLex.token() : 0; - if (yydebug != null) - yydebug.lex(yyState, yyToken,yyname(yyToken), yyLex.value()); - } - if (yyToken == 0) { - if (yydebug != null) yydebug.accept(yyVal); - return yyVal; - } - goto yyLoop; - } - if (((yyN = yyGindex[yyM]) != 0) && ((yyN += yyState) >= 0) - && (yyN < yyTable.Length) && (yyCheck[yyN] == yyState)) - yyState = yyTable[yyN]; - else - yyState = yyDgoto[yyM]; - if (yydebug != null) yydebug.shift(yyStates[yyTop], yyState); - goto yyLoop; - } - } - } - - static short [] yyLhs = { -1, - 0, 4, 4, 5, 5, 6, 7, 10, 10, 14, - 11, 15, 15, 16, 16, 12, 12, 9, 13, 1, - 1, 3, 3, 17, 17, 18, 18, 19, 19, 19, - 19, 19, 2, 2, 25, 26, 26, 27, 28, 28, - 30, 31, 31, 31, 29, 29, 32, 32, 33, 34, - 34, 36, 36, 38, 38, 39, 39, 40, 41, 41, - 42, 42, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 55, 21, 54, 54, 57, 57, 58, 56, - 60, 60, 61, 61, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 44, 64, 64, 65, 45, 67, 67, - 68, 68, 69, 69, 46, 71, 71, 72, 72, 74, - 74, 76, 76, 76, 77, 77, 79, 80, 80, 81, - 81, 78, 73, 73, 84, 85, 47, 83, 83, 89, - 89, 87, 87, 86, 91, 88, 90, 90, 93, 22, - 92, 92, 95, 96, 96, 94, 97, 97, 98, 98, - 99, 99, 99, 99, 104, 104, 100, 100, 106, 107, - 101, 105, 105, 105, 105, 102, 108, 109, 103, 50, - 110, 110, 110, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 111, 112, 112, 51, 113, 114, - 114, 115, 115, 52, 48, 48, 117, 117, 118, 119, - 49, 120, 120, 23, 121, 121, 122, 122, 124, 124, - 125, 125, 126, 126, 24, 35, 8, 63, 63, 63, - 59, 59, 127, 127, 127, 127, 127, 127, 127, 123, - 123, 123, 123, 123, 123, 123, 123, 123, 82, 128, - 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, - 130, 130, 130, 130, 130, 131, 131, 131, 131, 131, - 131, 147, 147, 147, 146, 145, 145, 132, 133, 133, - 148, 134, 116, 116, 149, 149, 150, 150, 150, 151, - 135, 152, 152, 136, 137, 137, 138, 139, 140, 140, - 153, 154, 155, 155, 129, 129, 157, 158, 158, 159, - 159, 156, 156, 70, 70, 70, 160, 160, 141, 142, - 143, 144, 161, 161, 161, 161, 161, 161, 161, 161, - 161, 161, 162, 163, 164, 164, 165, 165, 165, 165, - 166, 166, 166, 167, 167, 167, 168, 168, 168, 168, - 168, 168, 168, 169, 169, 169, 170, 170, 171, 171, - 172, 172, 173, 173, 174, 174, 175, 175, 176, 176, - 176, 176, 176, 176, 176, 176, 176, 176, 176, 37, - 37, 66, 177, 179, 20, 53, 53, 180, 180, 181, - 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, - 181, 178, 178, 182, 184, 75, 183, 183, 185, 185, - 186, 186, 186, 188, 188, 188, 188, 188, 188, 188, - 188, 188, 188, 188, 190, 189, 187, 187, 202, 202, - 202, 203, 203, 204, 204, 205, 200, 201, 191, 206, - 206, 206, 206, 206, 206, 206, 207, 192, 192, 208, - 208, 209, 210, 211, 211, 212, 212, 215, 213, 214, - 214, 216, 216, 193, 193, 193, 193, 217, 218, 219, - 221, 221, 224, 224, 222, 222, 223, 223, 226, 225, - 225, 220, 194, 194, 194, 194, 194, 227, 228, 229, - 229, 229, 230, 231, 232, 232, 195, 195, 195, 233, - 233, 236, 236, 237, 237, 235, 235, 239, 240, 240, - 238, 234, 196, 197, 198, 199, 241, - }; - static short [] yyLen = { 2, - 4, 1, 2, 1, 1, 5, 3, 1, 2, 0, - 5, 0, 1, 0, 1, 1, 3, 1, 4, 0, - 1, 0, 1, 1, 2, 1, 1, 1, 1, 1, - 1, 1, 0, 1, 1, 1, 2, 4, 0, 1, - 2, 1, 1, 1, 1, 3, 1, 1, 1, 0, - 3, 1, 3, 0, 1, 1, 2, 3, 0, 1, - 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 0, 8, 0, 1, 1, 2, 2, 3, - 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 6, 1, 3, 3, 5, 1, 3, - 3, 1, 1, 1, 2, 7, 7, 1, 1, 0, - 1, 1, 3, 1, 1, 3, 4, 0, 1, 1, - 1, 4, 1, 3, 0, 0, 9, 2, 2, 0, - 1, 0, 1, 3, 0, 4, 1, 1, 0, 7, - 0, 1, 2, 1, 3, 3, 0, 1, 1, 2, - 1, 1, 1, 1, 0, 1, 8, 8, 0, 0, - 9, 3, 3, 6, 6, 6, 0, 0, 12, 4, - 7, 10, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 7, 7, 4, 5, 0, - 1, 5, 5, 6, 6, 9, 2, 2, 3, 3, - 6, 5, 7, 7, 0, 2, 3, 4, 0, 1, - 1, 3, 2, 4, 9, 1, 1, 1, 1, 1, - 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, - 1, 4, 0, 1, 1, 3, 1, 2, 2, 1, - 4, 1, 3, 1, 3, 4, 2, 2, 1, 1, - 5, 7, 0, 1, 1, 2, 3, 0, 1, 1, - 2, 0, 1, 2, 3, 4, 1, 3, 4, 4, - 4, 4, 1, 2, 2, 2, 2, 2, 2, 1, - 1, 1, 2, 2, 4, 4, 1, 3, 3, 3, - 1, 3, 3, 1, 3, 3, 1, 3, 3, 3, - 3, 3, 3, 1, 3, 3, 1, 3, 1, 3, - 1, 3, 1, 3, 1, 3, 1, 5, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, - 1, 1, 1, 0, 8, 0, 1, 1, 2, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, 1, 2, 0, 4, 0, 1, 1, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 2, 2, 2, 2, - 2, 0, 1, 1, 2, 3, 2, 3, 2, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, - 7, 5, 3, 0, 1, 1, 2, 0, 3, 1, - 2, 3, 2, 1, 1, 1, 1, 5, 7, 9, - 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, - 3, 8, 1, 1, 1, 1, 1, 2, 2, 3, - 4, 3, 3, 3, 0, 1, 3, 3, 4, 2, - 2, 0, 1, 0, 1, 1, 2, 6, 0, 1, - 2, 2, 2, 2, 5, 5, 2, - }; - static short [] yyDefRed = { 0, - 0, 0, 0, 0, 2, 4, 5, 0, 18, 0, - 0, 0, 0, 34, 0, 36, 3, 0, 7, 0, - 43, 44, 42, 0, 40, 0, 0, 0, 0, 27, - 0, 24, 26, 28, 29, 30, 31, 32, 37, 16, - 0, 17, 0, 226, 0, 45, 47, 48, 49, 41, - 0, 395, 401, 393, 390, 400, 394, 392, 391, 398, - 396, 397, 399, 0, 0, 388, 1, 25, 6, 0, - 235, 241, 248, 0, 236, 238, 277, 237, 244, 246, - 0, 271, 233, 240, 242, 0, 234, 294, 276, 0, - 245, 247, 0, 243, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 275, 272, 273, 274, 269, 270, 0, - 0, 52, 239, 281, 0, 251, 253, 254, 255, 256, - 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, - 267, 268, 0, 299, 300, 0, 330, 331, 332, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 380, - 381, 38, 0, 0, 0, 0, 0, 0, 0, 389, - 0, 0, 0, 228, 0, 229, 230, 0, 0, 0, - 0, 0, 0, 327, 324, 325, 326, 329, 328, 333, - 334, 51, 0, 0, 0, 0, 297, 298, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 46, 0, 0, 384, 0, 0, 139, 73, 292, - 0, 295, 0, 0, 0, 0, 305, 0, 0, 0, - 0, 278, 0, 53, 0, 0, 0, 287, 0, 0, - 285, 279, 280, 369, 370, 371, 372, 373, 374, 375, - 376, 377, 379, 378, 338, 340, 339, 337, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 13, 11, 0, - 0, 0, 0, 0, 0, 0, 296, 0, 321, 310, - 0, 0, 0, 0, 306, 320, 319, 322, 335, 336, - 291, 290, 289, 288, 282, 0, 0, 0, 0, 0, - 403, 0, 216, 0, 0, 0, 0, 142, 0, 0, - 0, 77, 293, 0, 307, 311, 301, 286, 368, 19, - 0, 0, 0, 0, 0, 0, 0, 114, 115, 0, - 0, 0, 221, 214, 249, 144, 0, 0, 140, 0, - 0, 0, 78, 0, 0, 0, 0, 72, 0, 0, - 61, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 0, 385, 121, 0, 120, 0, 119, 0, 0, 0, - 217, 0, 0, 0, 0, 0, 149, 151, 152, 153, - 154, 0, 93, 85, 86, 87, 88, 89, 90, 91, - 92, 0, 0, 83, 74, 0, 313, 302, 0, 0, - 58, 62, 405, 109, 105, 108, 0, 0, 225, 113, - 116, 0, 218, 222, 145, 156, 0, 146, 150, 80, - 84, 314, 103, 317, 104, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 173, 0, 0, 0, 122, - 117, 224, 0, 0, 0, 315, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 99, 0, 0, 170, 198, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 425, 0, 414, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 442, 0, 0, 409, - 411, 412, 413, 415, 416, 417, 418, 419, 420, 421, - 422, 423, 424, 0, 0, 0, 0, 441, 448, 449, - 464, 465, 466, 467, 483, 484, 485, 486, 487, 0, - 0, 0, 0, 316, 318, 0, 0, 0, 95, 0, - 0, 0, 0, 0, 0, 0, 111, 179, 178, 175, - 180, 181, 174, 193, 192, 185, 186, 182, 184, 183, - 187, 176, 177, 188, 189, 195, 194, 190, 191, 0, - 0, 0, 0, 98, 125, 0, 0, 0, 0, 0, - 0, 488, 513, 0, 489, 0, 0, 0, 0, 0, - 0, 0, 0, 496, 0, 0, 0, 0, 514, 0, - 0, 431, 0, 434, 0, 0, 430, 0, 429, 406, - 410, 427, 428, 0, 0, 439, 0, 0, 0, 159, - 0, 204, 0, 0, 94, 205, 0, 0, 0, 0, - 124, 0, 0, 0, 101, 100, 0, 0, 0, 0, - 135, 211, 0, 128, 133, 0, 131, 129, 438, 0, - 473, 480, 0, 472, 0, 0, 382, 0, 492, 490, - 383, 0, 0, 493, 0, 494, 0, 0, 0, 498, - 0, 0, 506, 0, 0, 0, 0, 0, 435, 0, - 426, 166, 0, 0, 0, 0, 97, 96, 0, 0, - 0, 0, 0, 0, 107, 0, 199, 201, 0, 212, - 126, 106, 0, 138, 137, 134, 0, 0, 0, 0, - 0, 491, 0, 0, 0, 0, 512, 499, 0, 500, - 503, 507, 0, 501, 517, 0, 436, 0, 0, 0, - 0, 160, 0, 0, 0, 0, 0, 207, 0, 208, - 0, 0, 0, 0, 0, 0, 0, 136, 0, 476, - 0, 481, 0, 0, 515, 0, 452, 0, 511, 516, - 468, 158, 167, 0, 0, 0, 157, 209, 210, 206, - 197, 196, 0, 0, 171, 0, 127, 213, 0, 0, - 0, 0, 0, 0, 0, 0, 456, 0, 460, 510, - 0, 0, 0, 0, 161, 0, 0, 0, 469, 0, - 0, 478, 0, 451, 0, 463, 453, 457, 0, 461, - 0, 168, 0, 0, 202, 203, 0, 0, 482, 462, - 0, 508, 0, 0, 0, 172, 470, 169, 164, 165, - }; - protected static short [] yyDgoto = { 2, - 3, 345, 29, 4, 5, 6, 7, 44, 10, 0, - 30, 110, 224, 154, 289, 0, 31, 32, 33, 34, - 35, 36, 37, 38, 14, 15, 16, 24, 45, 25, - 26, 46, 47, 48, 164, 111, 248, 0, 0, 344, - 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, - 379, 380, 420, 330, 296, 362, 331, 332, 341, 412, - 413, 414, 342, 558, 559, 678, 480, 481, 444, 445, - 381, 425, 474, 566, 507, 567, 347, 348, 349, 386, - 387, 475, 599, 657, 766, 600, 664, 601, 668, 726, - 727, 327, 295, 359, 328, 357, 395, 396, 397, 398, - 399, 400, 401, 437, 752, 705, 786, 812, 843, 455, - 590, 456, 457, 717, 718, 249, 710, 711, 712, 458, - 294, 325, 113, 351, 352, 353, 114, 167, 236, 115, - 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, - 126, 127, 128, 129, 130, 131, 132, 133, 250, 251, - 313, 245, 134, 135, 365, 418, 237, 302, 303, 446, - 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, - 146, 147, 148, 149, 150, 151, 682, 320, 290, 65, - 66, 321, 518, 459, 519, 520, 521, 522, 523, 524, - 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, - 535, 536, 629, 623, 624, 537, 538, 539, 540, 777, - 805, 806, 807, 808, 829, 809, 541, 542, 543, 544, - 673, 771, 820, 674, 675, 822, 545, 546, 547, 548, - 549, 615, 689, 690, 691, 740, 692, 741, 693, 811, - 697, - }; - protected static short [] yySindex = { -312, - -236, 0, -116, -312, 0, 0, 0, -97, 0, -56, - -15, -273, -90, 0, -116, 0, 0, -49, 0, -44, - 0, 0, 0, -328, 0, 69, -49, 4393, 166, 0, - -90, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 63, 0, 8029, 0, -58, 0, 0, 0, 0, 0, - -15, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 36, 4393, 0, 0, 0, 0, 19, - 0, 0, 0, 86, 0, 0, 0, 0, 0, 0, - 468, 0, 0, 0, 0, 90, 0, 0, 0, 95, - 0, 0, 98, 0, 8029, 8029, 8029, 8029, 8029, 8029, - 8029, 8029, 8029, 0, 0, 0, 0, 0, 0, -15, - 88, 0, 0, 0, 74, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 111, 0, 0, 429, 0, 0, 0, -9, - -51, 78, -155, 73, 112, 118, 126, 96, -295, 0, - 0, 0, -328, 158, 83, 468, 87, 91, 100, 0, - 8029, 101, 8029, 0, 116, 0, 0, 468, 468, 8029, - -293, 168, 171, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 8029, 8029, 6957, 102, 0, 0, 103, 8029, - 8029, 8029, 8029, 8029, 8029, 8029, 8029, 8029, 8029, 8029, - 8029, 8029, 8029, 8029, 8029, 8029, 8029, 468, 468, 8029, - 8029, 8029, 8029, 8029, 8029, 8029, 8029, 8029, 8029, 8029, - 8029, 0, -312, 173, 0, -310, 175, 0, 0, 0, - 33, 0, 179, 7493, 6957, 184, 0, -186, -87, 182, - 8029, 0, 8029, 0, 34, 8029, 8029, 0, 183, 185, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -9, -9, - -51, -51, 184, 184, 78, 78, 78, 78, -155, -155, - 73, 112, 118, 126, 193, 96, -90, 0, 0, 194, - 186, 187, 31, 190, 196, 199, 0, 8029, 0, 0, - 35, 200, 201, 204, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 6957, 8029, 210, 468, 213, - 0, -116, 0, -116, 173, -49, 216, 0, 468, 217, - 199, 0, 0, 184, 0, 0, 0, 0, 0, 0, - 468, 184, -116, 173, 38, 215, 218, 0, 0, 149, - 222, 221, 0, 0, 0, 0, 223, -116, 0, 468, - -116, 173, 0, 184, 224, 184, 4236, 0, 230, -116, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -299, 0, 0, 468, 0, 468, 0, 225, -116, 219, - 0, -19, -49, 275, 235, -116, 0, 0, 0, 0, - 0, 4393, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 236, -116, 0, 0, 7091, 0, 0, 162, 8233, - 0, 0, 0, 0, 0, 0, -305, -287, 0, 0, - 0, 8029, 0, 0, 0, 0, 8585, 0, 0, 0, - 0, 0, 0, 0, 0, -60, 234, 468, 468, 276, - 278, 164, 240, -208, 249, 0, 249, 251, 4633, 0, - 0, 0, 468, 174, -265, 0, 7225, 250, -276, -266, - 468, 468, 0, 254, 247, -116, 661, 252, 246, 119, - 0, 43, 255, 0, 0, -116, 256, 54, 468, 258, - 4947, 259, 266, -263, 267, 269, 8029, 272, 8029, 249, - 64, 274, 279, 280, 0, 277, 0, 279, 79, 0, - 0, 0, 0, 429, 0, 0, 0, 281, 4633, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 271, 282, 209, 285, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, -256, - 284, 288, 70, 0, 0, 249, 283, 125, 0, 134, - 286, 145, 146, -116, 227, 291, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 295, - -116, 7627, 209, 0, 0, -116, -308, 155, 299, -116, - -116, 0, 0, -276, 0, 311, 7761, 468, 8029, 300, - 301, 8029, 8029, 0, 305, 8029, 308, -241, 0, 8163, - 186, 0, 279, 0, 8029, 4633, 0, 7493, 0, 0, - 0, 0, 0, 246, 312, 0, 309, -116, -116, 0, - -116, 0, 8029, 243, 0, 0, -116, 468, 468, 317, - 0, 315, 468, 321, 0, 0, -116, 322, 329, -36, - 0, 0, 334, 0, 0, 339, 0, 0, 0, 336, - 0, 0, 332, 0, 331, -239, 0, 333, 0, 0, - 0, 338, 340, 0, 342, 0, 344, 249, 400, 0, - 422, 423, 0, 8029, 79, 8029, 348, 351, 0, 350, - 0, 0, 352, 353, -116, 359, 0, 0, -212, 364, - -116, -116, -238, -233, 0, -240, 0, 0, -231, 0, - 0, 0, -116, 0, 0, 0, -36, 8029, 8029, 8029, - 414, 0, 4947, 4947, 369, 468, 0, 0, 75, 0, - 0, 0, 249, 0, 0, 4947, 0, 4947, 361, 371, - 156, 0, 363, 249, 249, 367, 405, 0, 452, 0, - 377, 378, 380, 381, 152, 386, 385, 0, 384, 0, - 383, 0, 8029, 456, 0, -61, 0, -226, 0, 0, - 0, 0, 0, 388, 389, 394, 0, 0, 0, 0, - 0, 0, 6957, 6957, 0, 468, 0, 0, 391, 8029, - 397, 4947, 8029, 382, 403, -61, 0, -61, 0, 0, - 406, -116, -116, -116, 0, 407, 410, -194, 0, 413, - 331, 0, 4947, 0, 415, 0, 0, 0, 4633, 0, - 249, 0, 427, 412, 0, 0, 424, 4947, 0, 0, - 4633, 0, 430, 419, 426, 0, 0, 0, 0, 0, - }; - protected static short [] yyRindex = { 8996, - 0, 0, 9143, 8886, 0, 0, 0, -76, 0, 0, - 2129, 28, 9198, 0, 813, 0, 0, 0, 0, 0, - 0, 0, 0, 81, 0, 0, 0, 85, 0, 0, - 9051, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 433, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 8315, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1681, - 0, 0, 0, 0, 1838, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1995, 0, 0, 0, 2397, - 2799, 2933, 5081, 5483, 5751, 5885, 6287, 6555, 6823, 0, - 0, 0, 81, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8741, 0, 432, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 434, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 9073, 8941, 0, 0, 440, 0, 0, 0, - 0, 0, 0, 442, 434, 2263, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 443, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 2531, 2665, - 3067, 3201, 3335, 3469, 3603, 3737, 3871, 4005, 5215, 5349, - 5617, 6019, 6153, 6421, 0, 6689, 9126, 0, 0, 449, - 442, 0, 0, 0, 450, 451, 0, 0, 0, 0, - 0, 0, 454, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 8553, 0, -318, -235, 0, 0, 0, 0, 0, - 453, 0, 0, 1210, 0, 0, 0, 0, 0, 0, - 458, 8632, 889, -235, 8742, 0, 157, 0, 0, 0, - 0, 459, 0, 0, 0, 0, 461, 8426, 0, -80, - 1051, -235, 0, 1367, 1524, 8668, 8382, 0, 0, 970, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 8553, -29, - 0, 374, 0, 8720, 0, 8478, 0, 0, 0, 0, - 0, 8382, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1130, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -225, 0, 0, 0, 0, 0, 463, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 160, 0, 0, 8509, 0, 0, -12, 0, - 0, 0, 0, 0, 0, 172, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 445, 0, 445, 0, - 0, 0, 387, 0, 0, 9299, 0, -327, -108, 9155, - 9178, 9237, 9248, 0, 584, 1195, 0, 0, 465, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 8509, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 8553, 0, 0, 0, 0, 8509, 0, 0, 0, 2, - -150, 0, 0, 0, 0, 0, 462, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 442, 0, 402, 0, 0, 0, 0, 442, 0, 0, - 0, 0, 0, 7359, 7895, 0, 0, 8509, 8553, 0, - 8509, 0, 0, 0, 0, 0, -115, 0, 0, 0, - 0, 467, 0, 0, 0, 0, 172, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 473, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 4319, 0, - 4162, 0, 0, 0, 387, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 172, 0, 0, 0, 0, 0, - 499, 563, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 8553, 0, 0, 0, 0, 0, 481, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 4476, 0, 491, 0, 489, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 434, 434, 0, 0, 0, 0, 0, 490, - 0, 0, 0, 0, 0, 496, 0, 4790, 0, 0, - 0, 172, 48, 5, 0, 0, 0, 0, 0, 0, - 493, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -123, 0, 0, 0, 0, 0, 0, 0, 0, 0, - }; - protected static short [] yyGindex = { 0, - 618, -3, 555, 0, 839, 0, 0, 195, 0, 0, - 0, 8, 0, 0, -45, 0, 0, 814, -158, 0, - 0, 0, 0, 0, 0, 0, 834, 0, 0, 0, - 0, 698, 0, 0, -22, 0, -25, 0, 0, 0, - 0, 0, 482, -206, -161, -156, -153, -146, -135, -110, - -107, 0, 825, 0, 0, 0, 0, 523, 528, 0, - 0, 446, 229, 0, -454, -624, -415, 268, -453, 501, - 0, 0, -272, -501, -192, -319, 0, 475, 478, 0, - 0, -321, 212, 0, 0, 270, 0, 273, 0, 147, - 0, 0, 0, 0, 0, 0, 0, 0, 476, 0, - 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -234, 0, 163, 165, 0, - 0, 0, 586, 0, 0, 494, 67, 0, 549, -429, - 0, 0, 0, -193, 0, 0, 0, 17, 114, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 572, - 643, -10, 151, 0, 0, 0, -223, -306, 0, 0, - 27, 161, 208, 0, 198, 248, 253, 298, 676, 681, - 675, 682, 679, 0, 0, 263, -609, 0, 0, 0, - 837, 0, 0, 0, 76, -513, 0, -484, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, -558, - 0, 0, -134, 0, 287, -596, 0, 0, 0, 0, - 0, 0, 97, 0, 0, 104, 0, 0, 0, 0, - 0, 0, 0, 0, 106, 0, 0, 0, 0, 0, - 0, 416, 0, 228, 0, 0, 0, 226, 220, 0, - 0, - }; - protected static short [] yyTable = { 13, - 304, 49, 346, 609, 356, 631, 606, 21, 11, 28, - 672, 610, 305, 555, 659, 700, 43, 112, 707, 281, - 1, 12, 763, 219, 12, 11, 687, 28, 12, 509, - 12, 11, 291, 12, 51, 12, 12, 291, 12, 22, - 12, 423, 12, 688, 12, 12, 12, 12, 671, 754, - 424, 12, 241, 20, 560, 291, 12, 552, 12, 12, - 12, 696, 650, 12, 12, 12, 291, 12, 220, 172, - 12, 435, 12, 12, 12, 12, 291, 291, 16, 12, - 12, 12, 764, 12, 12, 12, 291, 221, 11, 509, - 40, 432, 12, 12, 658, 477, 12, 16, 12, 12, - 33, 755, 171, 291, 291, 208, 12, 12, 292, 291, - 651, 291, 701, 460, 478, 12, 291, 16, 769, 770, - 635, 16, 174, 175, 176, 177, 178, 179, 180, 181, - 49, 461, 483, 772, 291, 230, 703, 233, 655, 706, - 305, 209, 557, 459, 240, 23, 33, 166, 291, 669, - 231, 459, 479, 553, 404, 611, 291, 244, 230, 306, - 11, 173, 637, 11, 254, 255, 256, 257, 258, 259, - 260, 261, 262, 263, 264, 11, 11, 509, 825, 731, - 761, 482, 8, 12, 368, 762, 33, 765, 426, 708, - 695, 130, 810, 16, 285, 9, 509, 561, 33, 405, - 210, 211, 403, 672, 406, 803, 404, 407, 230, 27, - 479, 368, 41, 804, 408, 11, 11, 212, 459, 213, - 312, 312, 166, 301, 837, 409, 12, 265, 266, 267, - 268, 268, 268, 268, 166, 166, 268, 268, 268, 268, - 268, 268, 268, 268, 268, 268, 323, 268, 774, 775, - 410, 405, 12, 411, 403, 291, 406, 18, 307, 407, - 79, 780, 484, 781, 485, 510, 408, 309, 79, 310, - 16, 654, 333, 16, 166, 166, 323, 409, 323, 354, - 323, 466, 323, 28, 323, 152, 323, 467, 323, 153, - 323, 339, 323, 19, 323, 603, 72, 510, 382, 73, - 204, 205, 410, 355, 423, 411, 155, 618, 619, 165, - 432, 156, 223, 724, 698, 157, 415, 824, 223, 704, - 350, 698, 433, 12, 79, 510, 11, 631, 123, 80, - 158, 20, 123, 11, 16, 102, 11, 102, 839, 367, - 33, 33, 383, 132, 384, 84, 163, 85, 11, 385, - 201, 202, 203, 847, 394, 386, 159, 402, 91, 92, - 386, 161, 94, 642, 386, 162, 367, 11, 622, 40, - 355, 39, 39, 627, 42, 39, 297, 311, 334, 386, - 298, 298, 298, 595, 226, 166, 33, 596, 350, 162, - 443, 11, 394, 11, 423, 166, 238, 239, 163, 509, - 11, 269, 270, 767, 423, 386, 462, 166, 170, 402, - 640, 509, 69, 510, 641, 423, 184, 50, 185, 736, - 186, 628, 67, 185, 50, 186, 166, 11, 50, 355, - 163, 355, 510, 182, 168, 183, 273, 274, 187, 169, - 188, 443, 170, 187, 11, 188, 206, 355, 207, 214, - 166, 215, 166, 271, 272, 11, 11, 189, 234, 11, - 235, 11, 275, 276, 277, 278, 593, 725, 594, 216, - 11, 614, 644, 614, 645, 511, 219, 11, 11, 11, - 217, 593, 598, 646, 218, 514, 166, 291, 291, 648, - 649, 660, 784, 661, 785, 737, 11, 795, 223, 796, - 112, 225, 112, 166, 123, 227, 16, 511, 33, 228, - 33, 279, 280, 242, 166, 166, 243, 514, 229, 232, - 252, 253, 288, 293, 299, 508, 291, 308, 315, 166, - 324, 322, 316, 300, 725, 511, 510, 166, 166, 510, - 510, 317, 319, 335, 326, 514, 779, 329, 336, 337, - 779, 340, 510, 343, 510, 166, 358, 361, 816, 817, - 388, 788, 789, 391, 416, 389, 443, 390, 392, 366, - 393, 421, 512, 432, 429, 436, 438, 440, 468, 471, - 447, 472, 473, 677, 476, 508, 681, 683, 366, 423, - 685, 486, 551, 565, 591, 556, 663, 666, 564, 681, - 592, 597, 230, 607, 512, 602, 510, 605, 510, 513, - 608, 612, 427, 613, 428, 11, 616, 677, 620, 515, - 632, 621, 630, 511, 625, 626, 647, 634, 638, 510, - 639, 633, 512, 514, 636, 510, 652, 643, 842, 653, - 662, 513, 511, 709, 510, 651, 670, 510, 454, 679, - 680, 515, 514, 598, 684, 11, 11, 686, 702, 593, - 11, 557, 715, 716, 720, 465, 516, 722, 172, 513, - 745, 723, 661, 508, 166, 660, 469, 470, 730, 515, - 728, 729, 732, 733, 688, 734, 508, 735, 736, 739, - 743, 550, 508, 746, 747, 748, 750, 749, 516, 562, - 563, 751, 681, 681, 753, 756, 773, 757, 759, 776, - 782, 783, 787, 754, 166, 166, 790, 604, 755, 166, - 512, 517, 791, 792, 793, 794, 516, 797, 798, 799, - 826, 71, 800, 72, 802, 815, 73, 813, 814, 512, - 819, 75, 823, 11, 827, 76, 511, 801, 845, 511, - 511, 831, 835, 517, 78, 836, 514, 513, 838, 514, - 514, 79, 511, 840, 511, 844, 80, 515, 849, 846, - 83, 848, 514, 10, 514, 850, 513, 677, 281, 283, - 215, 517, 84, 190, 85, 308, 515, 87, 284, 402, - 141, 75, 33, 76, 495, 91, 92, 309, 404, 94, - 220, 143, 166, 11, 407, 432, 408, 200, 751, 833, - 834, 471, 33, 191, 516, 192, 511, 193, 511, 194, - 433, 195, 474, 196, 33, 197, 514, 198, 514, 199, - 475, 200, 454, 516, 509, 477, 676, 455, 479, 511, - 287, 318, 17, 512, 68, 511, 512, 512, 39, 514, - 222, 422, 64, 363, 511, 514, 360, 511, 441, 512, - 656, 512, 166, 430, 514, 417, 431, 514, 721, 517, - 667, 439, 665, 768, 760, 758, 713, 714, 323, 832, - 513, 719, 364, 513, 513, 434, 40, 338, 517, 314, - 515, 281, 283, 515, 515, 508, 513, 282, 513, 286, - 284, 160, 828, 0, 841, 821, 515, 508, 515, 699, - 742, 830, 0, 512, 617, 512, 738, 744, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 445, - 0, 445, 0, 445, 0, 0, 512, 516, 330, 0, - 516, 516, 512, 0, 568, 0, 0, 0, 0, 0, - 513, 512, 513, 516, 512, 516, 0, 0, 0, 0, - 515, 0, 515, 0, 778, 0, 0, 0, 330, 0, - 330, 0, 330, 513, 330, 0, 330, 0, 330, 513, - 330, 0, 330, 515, 330, 569, 330, 0, 513, 515, - 0, 513, 517, 0, 0, 517, 517, 0, 515, 0, - 0, 515, 0, 0, 0, 0, 0, 516, 517, 516, - 517, 570, 571, 572, 573, 0, 574, 575, 576, 577, - 578, 579, 580, 581, 818, 582, 0, 583, 0, 584, - 516, 585, 0, 586, 0, 587, 516, 588, 0, 589, - 0, 0, 0, 0, 0, 516, 0, 0, 516, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 517, 0, 517, 0, 0, 0, 0, 35, - 0, 0, 35, 0, 35, 0, 35, 0, 35, 0, - 0, 35, 0, 35, 35, 517, 35, 0, 35, 0, - 35, 517, 35, 35, 35, 35, 0, 0, 0, 35, - 517, 0, 0, 517, 35, 0, 35, 35, 35, 0, - 0, 35, 35, 35, 0, 35, 0, 35, 35, 35, - 35, 35, 35, 35, 35, 0, 35, 35, 35, 35, - 0, 35, 35, 35, 0, 0, 0, 0, 0, 0, - 35, 35, 0, 0, 35, 0, 35, 35, 33, 35, - 0, 35, 33, 0, 33, 0, 0, 33, 0, 33, - 33, 0, 33, 35, 33, 0, 33, 0, 33, 33, - 33, 33, 0, 0, 0, 33, 0, 0, 0, 0, - 33, 0, 33, 33, 33, 0, 0, 33, 0, 33, - 0, 33, 0, 0, 33, 0, 33, 33, 33, 33, - 0, 0, 0, 33, 33, 33, 0, 33, 33, 33, - 0, 0, 0, 0, 0, 0, 33, 33, 0, 0, - 33, 0, 33, 33, 0, 0, 0, 0, 0, 33, - 59, 35, 0, 33, 0, 33, 0, 0, 33, 33, - 33, 33, 0, 33, 0, 33, 0, 33, 0, 33, - 33, 33, 33, 0, 0, 0, 33, 0, 0, 0, - 0, 33, 0, 33, 33, 33, 0, 0, 33, 0, - 33, 0, 33, 0, 0, 33, 0, 33, 33, 33, - 33, 0, 0, 0, 33, 33, 33, 0, 33, 33, - 33, 0, 0, 0, 0, 0, 0, 33, 33, 0, - 0, 33, 0, 33, 33, 0, 0, 33, 0, 0, - 33, 60, 0, 0, 33, 0, 33, 0, 0, 33, - 33, 33, 33, 0, 33, 0, 33, 0, 33, 0, - 33, 33, 33, 33, 0, 0, 0, 33, 0, 0, - 0, 0, 33, 0, 33, 33, 33, 0, 0, 33, - 0, 33, 0, 33, 0, 0, 33, 0, 33, 33, - 33, 33, 0, 0, 0, 33, 33, 33, 0, 33, - 33, 33, 0, 0, 0, 0, 0, 0, 33, 33, - 0, 0, 33, 0, 33, 33, 0, 0, 33, 33, - 0, 0, 81, 33, 0, 33, 0, 0, 33, 0, - 33, 33, 0, 33, 0, 33, 0, 33, 0, 33, - 33, 33, 33, 0, 0, 0, 33, 0, 0, 0, - 0, 33, 0, 33, 33, 33, 0, 0, 33, 0, - 33, 0, 33, 0, 0, 33, 0, 33, 33, 33, - 33, 0, 0, 0, 33, 33, 33, 0, 33, 33, - 33, 0, 0, 0, 0, 0, 0, 33, 33, 0, - 0, 33, 0, 33, 33, 0, 0, 0, 0, 33, - 303, 82, 303, 303, 0, 303, 0, 0, 303, 303, - 0, 0, 0, 303, 0, 0, 0, 303, 0, 0, - 0, 0, 0, 303, 0, 0, 303, 0, 0, 0, - 0, 0, 0, 303, 0, 0, 303, 0, 303, 0, - 303, 303, 303, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 303, 0, 303, 303, 0, 303, - 0, 0, 303, 0, 303, 0, 303, 303, 303, 303, - 446, 303, 446, 0, 446, 0, 0, 0, 33, 331, - 303, 303, 0, 303, 303, 303, 303, 303, 303, 303, - 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, - 303, 303, 303, 303, 303, 0, 303, 0, 303, 331, - 303, 331, 303, 331, 303, 331, 303, 331, 303, 331, - 303, 331, 303, 331, 303, 331, 303, 331, 303, 0, - 303, 0, 303, 0, 303, 0, 303, 0, 303, 0, - 303, 0, 303, 0, 0, 0, 303, 0, 303, 0, - 303, 0, 303, 0, 303, 0, 303, 304, 303, 304, - 304, 0, 304, 0, 0, 304, 304, 0, 0, 0, - 304, 0, 0, 0, 304, 0, 0, 0, 0, 0, - 304, 0, 0, 304, 0, 0, 0, 0, 0, 0, - 304, 0, 0, 304, 0, 304, 0, 304, 304, 304, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 304, 0, 304, 304, 0, 304, 0, 0, 304, - 0, 304, 0, 304, 304, 304, 304, 0, 304, 0, - 0, 0, 0, 0, 0, 0, 0, 304, 304, 0, - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - 304, 304, 0, 304, 0, 304, 0, 304, 0, 304, - 0, 304, 0, 304, 0, 304, 0, 304, 0, 304, - 0, 304, 0, 304, 0, 304, 0, 304, 0, 304, - 0, 304, 0, 304, 0, 304, 0, 304, 0, 304, - 0, 0, 0, 304, 0, 304, 0, 304, 0, 304, - 0, 304, 0, 304, 312, 304, 312, 312, 0, 312, - 0, 0, 312, 312, 0, 0, 0, 312, 0, 0, - 0, 312, 0, 0, 0, 0, 0, 312, 0, 0, - 312, 0, 0, 0, 0, 0, 0, 312, 0, 0, - 312, 0, 312, 0, 312, 312, 312, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 312, 0, - 312, 312, 0, 312, 0, 0, 312, 0, 312, 0, - 312, 312, 312, 312, 0, 312, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 312, 312, 312, 312, 312, - 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, - 312, 312, 312, 312, 312, 312, 312, 312, 312, 0, - 312, 0, 312, 0, 312, 0, 312, 0, 312, 0, - 312, 0, 312, 0, 312, 0, 312, 0, 312, 0, - 312, 0, 312, 0, 312, 0, 312, 0, 312, 0, - 312, 0, 312, 0, 312, 0, 312, 0, 0, 0, - 312, 0, 312, 0, 312, 0, 312, 0, 312, 0, - 312, 252, 312, 252, 252, 0, 252, 0, 0, 252, - 252, 0, 0, 0, 252, 0, 0, 0, 252, 0, - 0, 0, 0, 0, 252, 0, 0, 252, 0, 0, - 0, 0, 0, 0, 252, 0, 0, 252, 0, 252, - 0, 252, 252, 252, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 252, 0, 252, 252, 0, - 252, 0, 0, 252, 0, 252, 0, 252, 252, 252, - 252, 0, 252, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 252, 252, 252, 252, 252, 0, 252, 252, - 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, - 252, 252, 252, 252, 252, 252, 0, 252, 0, 252, - 0, 252, 0, 252, 0, 252, 0, 252, 0, 252, - 0, 252, 0, 252, 0, 252, 0, 252, 0, 252, - 0, 252, 0, 252, 0, 252, 0, 252, 0, 252, - 0, 252, 0, 252, 0, 0, 0, 252, 0, 252, - 0, 252, 0, 252, 0, 252, 0, 252, 323, 252, - 323, 323, 0, 323, 0, 0, 323, 323, 0, 0, - 0, 323, 0, 0, 0, 323, 0, 0, 0, 0, - 0, 323, 0, 0, 323, 0, 0, 0, 0, 0, - 0, 323, 0, 0, 323, 0, 323, 0, 323, 323, - 323, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 323, 0, 323, 323, 0, 323, 0, 0, - 323, 0, 323, 0, 323, 323, 323, 323, 0, 323, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 323, - 0, 323, 0, 323, 0, 323, 323, 323, 323, 323, - 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, - 323, 323, 0, 0, 0, 0, 323, 0, 323, 0, - 323, 0, 323, 0, 323, 0, 323, 0, 323, 0, - 323, 0, 323, 0, 323, 0, 323, 0, 323, 0, - 323, 0, 323, 0, 323, 0, 323, 0, 323, 0, - 323, 0, 0, 0, 323, 0, 323, 0, 323, 0, - 323, 0, 323, 0, 323, 337, 323, 337, 337, 0, - 337, 0, 0, 337, 337, 0, 0, 0, 337, 0, - 0, 0, 337, 0, 0, 0, 0, 0, 337, 0, - 0, 337, 0, 0, 0, 0, 0, 0, 337, 0, - 0, 337, 0, 337, 0, 337, 337, 337, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 337, - 0, 337, 337, 0, 337, 0, 0, 337, 0, 337, - 0, 337, 337, 337, 337, 0, 337, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 337, 0, 337, 337, - 337, 0, 337, 337, 337, 337, 337, 337, 337, 0, - 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, - 0, 337, 0, 337, 0, 337, 0, 337, 0, 337, - 0, 337, 0, 337, 0, 337, 0, 337, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 227, - 0, 227, 227, 0, 227, 0, 0, 227, 227, 0, - 0, 337, 227, 337, 0, 337, 227, 337, 0, 337, - 0, 337, 227, 337, 0, 227, 0, 0, 0, 0, - 0, 0, 227, 0, 0, 227, 0, 227, 0, 227, - 227, 227, 227, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 227, 0, 227, 227, 0, 227, 0, - 0, 227, 0, 227, 0, 227, 227, 227, 227, 0, - 227, 0, 0, 0, 0, 0, 0, 0, 0, 227, - 227, 227, 227, 227, 227, 0, 227, 227, 227, 227, - 227, 227, 227, 0, 227, 227, 227, 227, 227, 0, - 0, 227, 227, 227, 0, 227, 0, 0, 0, 0, - 0, 227, 0, 227, 0, 227, 0, 227, 0, 227, - 0, 227, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 250, 0, 250, 250, 0, 250, 0, - 0, 250, 250, 0, 0, 227, 250, 227, 0, 227, - 250, 227, 0, 227, 0, 227, 250, 227, 0, 250, - 0, 0, 0, 0, 0, 0, 250, 0, 0, 250, - 0, 250, 0, 250, 250, 250, 250, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 250, 0, 250, - 250, 0, 250, 0, 0, 250, 0, 250, 0, 250, - 250, 250, 250, 0, 250, 0, 0, 0, 0, 0, - 0, 0, 0, 250, 250, 0, 250, 250, 250, 0, - 250, 250, 250, 250, 250, 250, 250, 0, 250, 250, - 250, 250, 250, 0, 0, 250, 250, 250, 0, 250, - 0, 0, 0, 0, 0, 250, 0, 250, 0, 250, - 0, 250, 0, 250, 0, 250, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 341, 0, 341, - 341, 0, 341, 0, 0, 341, 341, 0, 0, 250, - 341, 250, 0, 250, 341, 250, 0, 250, 0, 250, - 341, 250, 0, 341, 0, 0, 0, 0, 0, 0, - 341, 0, 0, 341, 0, 341, 0, 341, 341, 341, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 341, 0, 341, 341, 0, 341, 0, 0, 341, - 0, 341, 0, 341, 341, 341, 341, 0, 341, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 341, 0, - 341, 341, 341, 0, 341, 341, 341, 341, 341, 341, - 341, 0, 341, 341, 341, 341, 0, 0, 0, 341, - 341, 341, 0, 341, 0, 341, 0, 341, 0, 341, - 0, 341, 0, 341, 0, 341, 0, 341, 0, 341, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 342, 0, 342, 342, 0, 342, 0, 0, 342, - 342, 0, 0, 341, 342, 341, 0, 341, 342, 341, - 0, 341, 0, 341, 342, 341, 0, 342, 0, 0, - 0, 0, 0, 0, 342, 0, 0, 342, 0, 342, - 0, 342, 342, 342, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 342, 0, 342, 342, 0, - 342, 0, 0, 342, 0, 342, 0, 342, 342, 342, - 342, 0, 342, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 342, 0, 342, 342, 342, 0, 342, 342, - 342, 342, 342, 342, 342, 0, 342, 342, 342, 342, - 0, 0, 0, 342, 342, 342, 0, 342, 0, 342, - 0, 342, 0, 342, 0, 342, 0, 342, 0, 342, - 0, 342, 0, 342, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 343, 0, 343, 343, 0, - 343, 0, 0, 343, 343, 0, 0, 342, 343, 342, - 0, 342, 343, 342, 0, 342, 0, 342, 343, 342, - 0, 343, 0, 0, 0, 0, 0, 0, 343, 0, - 0, 343, 0, 343, 0, 343, 343, 343, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 343, - 0, 343, 343, 0, 343, 0, 0, 343, 0, 343, - 0, 343, 343, 343, 343, 0, 343, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 343, 0, 343, 343, - 343, 0, 343, 343, 343, 343, 343, 343, 343, 0, - 343, 343, 343, 343, 0, 0, 0, 343, 343, 343, - 0, 343, 0, 343, 0, 343, 0, 343, 0, 343, - 0, 343, 0, 343, 0, 343, 0, 343, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 344, - 0, 344, 344, 0, 344, 0, 0, 344, 344, 0, - 0, 343, 344, 343, 0, 343, 344, 343, 0, 343, - 0, 343, 344, 343, 0, 344, 0, 0, 0, 0, - 0, 0, 344, 0, 0, 344, 0, 344, 0, 344, - 344, 344, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 344, 0, 344, 344, 0, 344, 0, - 0, 344, 0, 344, 0, 344, 344, 344, 344, 0, - 344, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 344, 0, 344, 344, 344, 0, 344, 344, 344, 344, - 0, 0, 344, 0, 344, 344, 344, 344, 344, 0, - 0, 344, 344, 344, 0, 344, 0, 344, 0, 344, - 0, 344, 0, 344, 0, 344, 0, 344, 0, 344, - 0, 344, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 347, 0, 347, 347, 0, 347, 0, - 0, 347, 347, 0, 0, 344, 347, 344, 0, 344, - 347, 344, 0, 344, 0, 344, 347, 344, 0, 347, - 0, 0, 0, 0, 0, 0, 347, 0, 0, 347, - 0, 347, 0, 347, 347, 347, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 347, 0, 347, - 347, 0, 347, 0, 0, 347, 0, 347, 0, 347, - 347, 347, 347, 0, 347, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 347, 0, 347, 347, 347, 0, - 347, 347, 347, 347, 347, 347, 347, 0, 347, 347, - 347, 347, 347, 0, 0, 347, 347, 347, 0, 347, - 0, 0, 0, 0, 0, 347, 0, 347, 0, 347, - 0, 347, 0, 347, 0, 347, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 345, 0, 345, - 345, 0, 345, 0, 0, 345, 345, 0, 0, 347, - 345, 347, 0, 347, 345, 347, 0, 347, 0, 347, - 345, 347, 0, 345, 0, 0, 0, 0, 0, 0, - 345, 0, 0, 345, 0, 345, 0, 345, 345, 345, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 345, 0, 345, 345, 0, 345, 0, 0, 345, - 0, 345, 0, 345, 345, 345, 345, 0, 345, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 345, 0, - 345, 345, 345, 0, 345, 345, 345, 345, 0, 0, - 345, 0, 345, 345, 345, 345, 345, 0, 0, 345, - 345, 345, 0, 345, 0, 345, 0, 345, 0, 345, - 0, 345, 0, 345, 0, 345, 0, 345, 0, 345, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 346, 0, 346, 346, 0, 346, 0, 0, 346, - 346, 0, 0, 345, 346, 345, 0, 345, 346, 345, - 0, 345, 0, 345, 346, 345, 0, 346, 0, 0, - 0, 0, 0, 0, 346, 0, 0, 346, 0, 346, - 0, 346, 346, 346, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 346, 0, 346, 346, 0, - 346, 0, 0, 346, 0, 346, 0, 346, 346, 346, - 346, 0, 346, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 346, 0, 346, 346, 346, 0, 346, 346, - 346, 346, 0, 0, 346, 0, 346, 346, 346, 346, - 346, 0, 0, 346, 346, 346, 0, 346, 0, 346, - 0, 346, 0, 346, 0, 346, 0, 346, 0, 346, - 0, 346, 0, 346, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 353, 0, 353, 353, 0, - 353, 0, 0, 353, 353, 0, 0, 346, 353, 346, - 0, 346, 353, 346, 0, 346, 0, 346, 353, 346, - 0, 353, 0, 0, 0, 0, 0, 0, 353, 0, - 0, 353, 0, 353, 0, 353, 353, 353, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, - 0, 353, 353, 0, 353, 0, 0, 353, 0, 353, - 0, 353, 353, 353, 353, 0, 353, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 353, 0, 353, 353, - 353, 0, 353, 353, 353, 353, 353, 353, 353, 0, - 353, 353, 353, 353, 353, 0, 0, 353, 353, 353, - 0, 353, 0, 0, 0, 0, 0, 353, 0, 353, - 0, 353, 0, 353, 0, 353, 0, 353, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 352, - 0, 352, 352, 0, 352, 0, 0, 352, 352, 0, - 0, 353, 352, 353, 0, 353, 352, 353, 0, 353, - 0, 353, 352, 353, 0, 352, 0, 0, 0, 0, - 0, 0, 352, 0, 0, 352, 0, 352, 0, 352, - 352, 352, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 352, 0, 352, 352, 0, 352, 0, - 0, 352, 0, 352, 0, 352, 352, 352, 352, 0, - 352, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 352, 0, 352, 352, 352, 0, 352, 352, 352, 352, - 352, 352, 352, 0, 352, 352, 352, 352, 352, 0, - 0, 352, 352, 352, 0, 352, 0, 0, 0, 0, - 0, 352, 0, 352, 0, 352, 0, 352, 0, 352, - 0, 352, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 348, 0, 348, 348, 0, 348, 0, - 0, 348, 348, 0, 0, 352, 348, 352, 0, 352, - 348, 352, 0, 352, 0, 352, 348, 352, 0, 348, - 0, 0, 0, 0, 0, 0, 348, 0, 0, 348, - 0, 348, 0, 348, 348, 348, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 348, 0, 348, - 348, 0, 348, 0, 0, 348, 0, 348, 0, 348, - 348, 348, 348, 0, 348, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 348, 0, 348, 348, 348, 0, - 348, 348, 348, 348, 348, 348, 348, 0, 348, 348, - 348, 348, 348, 0, 0, 348, 348, 348, 0, 348, - 0, 0, 0, 0, 0, 348, 0, 348, 0, 348, - 0, 348, 0, 348, 0, 348, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 349, 0, 349, - 349, 0, 349, 0, 0, 349, 349, 0, 0, 348, - 349, 348, 0, 348, 349, 348, 0, 348, 0, 348, - 349, 348, 0, 349, 0, 0, 0, 0, 0, 0, - 349, 0, 0, 349, 0, 349, 0, 349, 349, 349, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 349, 0, 349, 349, 0, 349, 0, 0, 349, - 0, 349, 0, 349, 349, 349, 349, 0, 349, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 349, 0, - 349, 349, 349, 0, 349, 349, 349, 349, 349, 349, - 349, 0, 349, 349, 349, 349, 349, 0, 0, 349, - 349, 349, 0, 349, 0, 0, 0, 0, 0, 349, - 0, 349, 0, 349, 0, 349, 0, 349, 0, 349, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 350, 0, 350, 350, 0, 350, 0, 0, 350, - 350, 0, 0, 349, 350, 349, 0, 349, 350, 349, - 0, 349, 0, 349, 350, 349, 0, 350, 0, 0, - 0, 0, 0, 0, 350, 0, 0, 350, 0, 350, - 0, 350, 350, 350, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 350, 0, 350, 350, 0, - 350, 0, 0, 350, 0, 350, 0, 350, 350, 350, - 350, 0, 350, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 350, 0, 350, 350, 350, 0, 350, 350, - 350, 350, 350, 350, 350, 0, 350, 350, 350, 350, - 350, 0, 0, 350, 350, 350, 0, 350, 0, 0, - 0, 0, 0, 350, 0, 350, 0, 350, 0, 350, - 0, 350, 0, 350, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 351, 0, 351, 351, 0, - 351, 0, 0, 351, 351, 0, 0, 350, 351, 350, - 0, 350, 351, 350, 0, 350, 0, 350, 351, 350, - 0, 351, 0, 0, 0, 0, 0, 0, 351, 0, - 0, 351, 0, 351, 0, 351, 351, 351, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 351, - 0, 351, 351, 0, 351, 0, 0, 351, 0, 351, - 0, 351, 351, 351, 351, 0, 351, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 351, 0, 351, 351, - 351, 0, 351, 351, 351, 351, 351, 351, 351, 0, - 351, 351, 351, 351, 351, 0, 0, 351, 351, 351, - 0, 351, 0, 0, 0, 0, 0, 351, 0, 351, - 0, 351, 0, 351, 0, 351, 0, 351, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 351, 0, 351, 0, 351, 0, 351, 0, 351, - 0, 351, 0, 351, 502, 502, 502, 502, 502, 0, - 502, 502, 0, 502, 502, 502, 502, 0, 502, 502, - 502, 0, 0, 0, 0, 502, 502, 0, 502, 502, - 502, 502, 502, 0, 0, 502, 0, 0, 0, 502, - 502, 0, 502, 502, 502, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 502, 0, 502, 0, 502, 502, - 0, 502, 0, 502, 502, 502, 502, 502, 502, 502, - 502, 502, 0, 502, 502, 52, 502, 502, 0, 0, - 0, 0, 502, 502, 0, 0, 502, 0, 0, 0, - 0, 502, 502, 502, 502, 502, 0, 0, 53, 502, - 0, 502, 0, 0, 0, 0, 502, 0, 502, 0, - 0, 54, 0, 0, 0, 0, 55, 0, 0, 0, - 0, 56, 0, 57, 58, 59, 60, 0, 0, 0, - 0, 61, 0, 0, 62, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 502, 63, - 502, 0, 502, 0, 502, 0, 502, 0, 502, 0, - 502, 497, 497, 497, 497, 497, 419, 497, 497, 0, - 497, 497, 497, 497, 0, 497, 497, 497, 0, 0, - 0, 0, 497, 0, 0, 497, 497, 497, 497, 497, - 0, 0, 497, 0, 0, 0, 497, 497, 0, 497, - 497, 497, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 497, 0, 497, 0, 497, 497, 0, 497, 0, - 497, 497, 497, 497, 497, 497, 497, 497, 497, 0, - 497, 497, 52, 497, 497, 0, 0, 0, 0, 497, - 497, 0, 0, 497, 0, 0, 0, 0, 497, 497, - 497, 497, 497, 0, 0, 53, 497, 0, 497, 0, - 0, 0, 0, 497, 0, 497, 0, 0, 54, 0, - 0, 0, 0, 55, 0, 0, 0, 0, 56, 0, - 57, 58, 59, 60, 0, 0, 0, 0, 61, 0, - 0, 62, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 497, 63, 497, 0, 497, - 0, 497, 0, 497, 0, 497, 0, 497, 450, 450, - 450, 450, 450, 0, 450, 450, 0, 450, 450, 450, - 450, 0, 450, 450, 0, 0, 0, 0, 0, 450, - 0, 0, 450, 450, 450, 450, 450, 0, 0, 450, - 0, 0, 0, 450, 450, 0, 450, 450, 450, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 450, 0, - 450, 0, 450, 450, 0, 450, 0, 450, 450, 450, - 450, 450, 450, 450, 450, 450, 0, 450, 450, 0, - 450, 450, 0, 0, 0, 0, 450, 450, 0, 0, - 450, 0, 0, 0, 0, 450, 450, 450, 450, 450, - 0, 0, 0, 450, 0, 450, 0, 0, 0, 0, - 450, 0, 450, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 450, 0, 450, 0, 450, 0, 450, 0, - 450, 0, 450, 0, 450, 70, 71, 487, 72, 0, - 0, 73, 488, 0, 489, 490, 75, 0, 0, 491, - 76, 0, 0, 0, 0, 0, 77, 0, 0, 78, - 492, 493, 494, 495, 0, 0, 79, 0, 0, 0, - 496, 80, 0, 81, 82, 83, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 497, 0, 84, 0, 85, - 86, 0, 87, 0, 498, 88, 499, 89, 500, 90, - 91, 92, 501, 0, 94, 502, 0, 503, 504, 0, - 0, 0, 0, 423, 0, 0, 0, 95, 0, 0, - 0, 0, 505, 96, 97, 98, 99, 0, 0, 0, - 100, 0, 101, 0, 0, 0, 0, 102, 0, 103, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 104, - 0, 105, 0, 106, 0, 107, 0, 108, 0, 109, - 0, 506, 458, 458, 458, 458, 0, 0, 458, 458, - 0, 458, 458, 458, 0, 0, 458, 458, 0, 0, - 0, 0, 0, 458, 0, 0, 458, 458, 458, 458, - 458, 0, 0, 458, 0, 0, 0, 458, 458, 0, - 458, 458, 458, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 458, 0, 458, 0, 458, 458, 0, 458, - 0, 458, 458, 458, 458, 458, 458, 458, 458, 458, - 0, 458, 458, 0, 458, 458, 0, 0, 0, 0, - 458, 0, 0, 0, 458, 0, 0, 0, 0, 458, - 458, 458, 458, 458, 0, 0, 0, 458, 0, 458, - 0, 0, 0, 0, 458, 0, 458, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 458, 0, 458, 0, - 458, 0, 458, 0, 458, 0, 458, 0, 458, 70, - 71, 487, 72, 0, 0, 73, 488, 0, 0, 490, - 75, 0, 0, 491, 76, 0, 0, 0, 0, 0, - 77, 0, 0, 78, 492, 493, 494, 495, 0, 0, - 79, 0, 0, 0, 496, 80, 0, 81, 82, 83, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 497, - 0, 84, 0, 85, 86, 0, 87, 0, 498, 88, - 499, 89, 500, 90, 91, 92, 501, 0, 94, 502, - 0, 0, 504, 0, 0, 0, 0, 423, 0, 0, - 0, 95, 0, 0, 0, 0, 505, 96, 97, 98, - 99, 0, 0, 0, 100, 0, 101, 0, 0, 0, - 0, 102, 0, 103, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 354, 354, 0, 354, 0, 0, 354, - 354, 0, 0, 104, 354, 105, 0, 106, 354, 107, - 0, 108, 0, 109, 354, 40, 0, 354, 0, 0, - 0, 0, 0, 0, 354, 0, 0, 0, 0, 354, - 0, 354, 354, 354, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 354, 0, 354, 354, 0, - 354, 0, 0, 354, 0, 354, 0, 354, 354, 354, - 354, 0, 354, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 354, 0, 354, 354, 354, 0, 354, 354, - 354, 354, 354, 354, 354, 0, 0, 0, 354, 354, - 354, 0, 0, 354, 354, 354, 0, 354, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 354, 0, 354, - 0, 354, 0, 354, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 355, 355, 0, - 355, 0, 0, 355, 355, 0, 0, 354, 355, 354, - 0, 354, 355, 354, 0, 354, 0, 354, 355, 354, - 0, 355, 0, 0, 0, 0, 0, 0, 355, 0, - 0, 0, 0, 355, 0, 355, 355, 355, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 355, - 0, 355, 355, 0, 355, 0, 0, 355, 0, 355, - 0, 355, 355, 355, 355, 0, 355, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 355, 0, 355, 355, - 355, 0, 355, 355, 355, 355, 355, 355, 355, 0, - 0, 0, 355, 355, 355, 0, 0, 355, 355, 355, - 0, 355, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 355, 0, 355, 0, 355, 0, 355, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 356, 356, 0, 356, 0, 0, 356, 356, 0, - 0, 355, 356, 355, 0, 355, 356, 355, 0, 355, - 0, 355, 356, 355, 0, 356, 0, 0, 0, 0, - 0, 0, 356, 0, 0, 0, 0, 356, 0, 356, - 356, 356, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 356, 0, 356, 356, 0, 356, 0, - 0, 356, 0, 356, 0, 356, 356, 356, 356, 0, - 356, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 356, 0, 356, 356, 356, 0, 356, 356, 356, 356, - 356, 356, 356, 0, 0, 0, 356, 356, 356, 0, - 0, 356, 356, 356, 0, 356, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 356, 0, 356, 0, 356, - 0, 356, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 357, 357, 0, 357, 0, - 0, 357, 357, 0, 0, 356, 357, 356, 0, 356, - 357, 356, 0, 356, 0, 356, 357, 356, 0, 357, - 0, 0, 0, 0, 0, 0, 357, 0, 0, 0, - 0, 357, 0, 357, 357, 357, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 357, 0, 357, - 357, 0, 357, 0, 0, 357, 0, 357, 0, 357, - 357, 357, 357, 0, 357, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 357, 0, 357, 357, 357, 0, - 357, 357, 357, 357, 357, 357, 357, 0, 0, 0, - 357, 357, 357, 0, 0, 357, 357, 357, 0, 357, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 357, 0, 357, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 358, - 358, 0, 358, 0, 0, 358, 358, 0, 0, 357, - 358, 357, 0, 357, 358, 357, 0, 357, 0, 357, - 358, 357, 0, 358, 0, 0, 0, 0, 0, 0, - 358, 0, 0, 0, 0, 358, 0, 358, 358, 358, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 358, 0, 358, 358, 0, 358, 0, 0, 358, - 0, 358, 0, 358, 358, 358, 358, 0, 358, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 358, 0, - 358, 358, 358, 0, 358, 358, 358, 358, 358, 358, - 358, 0, 0, 0, 358, 358, 358, 0, 0, 358, - 358, 358, 0, 358, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 358, 0, 358, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 359, 359, 0, 359, 0, 0, 359, - 359, 0, 0, 358, 359, 358, 0, 358, 359, 358, - 0, 358, 0, 358, 359, 358, 0, 359, 0, 0, - 0, 0, 0, 0, 359, 0, 0, 0, 0, 359, - 0, 359, 359, 359, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 359, 0, 359, 359, 0, - 359, 0, 0, 359, 0, 359, 0, 359, 359, 359, - 359, 0, 359, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 359, 0, 359, 359, 359, 0, 359, 359, - 359, 359, 359, 359, 359, 0, 0, 0, 0, 359, - 359, 0, 0, 359, 359, 359, 0, 359, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 359, 0, 359, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 361, 361, 0, - 361, 0, 0, 361, 361, 0, 0, 359, 361, 359, - 0, 359, 361, 359, 0, 359, 0, 359, 361, 359, - 0, 361, 0, 0, 0, 0, 0, 0, 361, 0, - 0, 0, 0, 361, 0, 361, 361, 361, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 361, - 0, 361, 361, 0, 361, 0, 0, 361, 0, 361, - 0, 361, 361, 361, 361, 0, 361, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 361, 0, 361, 361, - 361, 0, 361, 361, 361, 361, 361, 361, 361, 0, - 0, 0, 361, 361, 361, 0, 0, 0, 361, 361, - 0, 361, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 361, 0, 361, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 360, 360, 0, 360, 0, 0, 360, 360, 0, - 0, 361, 360, 361, 0, 361, 360, 361, 0, 361, - 0, 361, 360, 361, 0, 360, 0, 0, 0, 0, - 0, 0, 360, 0, 0, 0, 0, 360, 0, 360, - 360, 360, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 360, 0, 360, 360, 0, 360, 0, - 0, 360, 0, 360, 0, 360, 360, 360, 360, 0, - 360, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 360, 0, 360, 360, 360, 0, 360, 360, 360, 360, - 360, 360, 360, 0, 0, 0, 0, 360, 360, 0, - 0, 360, 360, 360, 0, 360, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 360, - 0, 360, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 362, 362, 0, 362, 0, - 0, 362, 362, 0, 0, 360, 362, 360, 0, 360, - 362, 360, 0, 360, 0, 360, 362, 360, 0, 362, - 0, 0, 0, 0, 0, 0, 362, 0, 0, 0, - 0, 362, 0, 362, 362, 362, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 362, 0, 362, - 362, 0, 362, 0, 0, 362, 0, 362, 0, 362, - 362, 362, 362, 0, 362, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 362, 0, 362, 362, 362, 0, - 362, 362, 362, 362, 362, 362, 362, 0, 0, 0, - 362, 362, 362, 0, 0, 0, 362, 362, 0, 362, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 362, 0, 362, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 363, - 363, 0, 363, 0, 0, 363, 363, 0, 0, 362, - 363, 362, 0, 362, 363, 362, 0, 362, 0, 362, - 363, 362, 0, 363, 0, 0, 0, 0, 0, 0, - 363, 0, 0, 0, 0, 363, 0, 363, 363, 363, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 363, 0, 363, 363, 0, 363, 0, 0, 363, - 0, 363, 0, 363, 363, 363, 363, 0, 363, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 363, 0, - 363, 363, 363, 0, 363, 363, 363, 363, 363, 363, - 363, 0, 0, 0, 363, 0, 363, 0, 0, 0, - 363, 363, 0, 363, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 363, 0, 363, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 364, 364, 0, 364, 0, 0, 364, - 364, 0, 0, 363, 364, 363, 0, 363, 364, 363, - 0, 363, 0, 363, 364, 363, 0, 364, 0, 0, - 0, 0, 0, 0, 364, 0, 0, 0, 0, 364, - 0, 364, 364, 364, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 364, 0, 364, 364, 0, - 364, 0, 0, 364, 0, 364, 0, 364, 364, 364, - 364, 0, 364, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 364, 0, 364, 364, 364, 0, 364, 364, - 364, 364, 364, 364, 364, 0, 0, 0, 364, 0, - 364, 0, 0, 0, 364, 364, 0, 364, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 364, 0, 364, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 365, 365, 0, - 365, 0, 0, 365, 365, 0, 0, 364, 365, 364, - 0, 364, 365, 364, 0, 364, 0, 364, 365, 364, - 0, 365, 0, 0, 0, 0, 0, 0, 365, 0, - 0, 0, 0, 365, 0, 365, 365, 365, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 365, - 0, 365, 365, 0, 365, 0, 0, 365, 0, 365, - 0, 365, 365, 365, 365, 0, 365, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 365, 0, 365, 365, - 365, 0, 365, 365, 365, 365, 365, 365, 365, 0, - 0, 0, 365, 0, 365, 0, 0, 0, 365, 365, - 0, 365, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 365, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 366, 366, 0, 366, 0, 0, 366, 366, 0, - 0, 365, 366, 365, 0, 365, 366, 365, 0, 365, - 0, 365, 366, 365, 0, 366, 0, 0, 0, 0, - 0, 0, 366, 0, 0, 0, 0, 366, 0, 366, - 366, 366, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 366, 0, 366, 366, 0, 366, 0, - 0, 366, 0, 366, 0, 366, 366, 366, 366, 0, - 366, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 366, 0, 366, 366, 366, 0, 366, 366, 366, 366, - 366, 366, 366, 0, 0, 0, 366, 0, 366, 0, - 0, 0, 366, 366, 0, 366, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 366, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 367, 367, 0, 367, 0, - 0, 367, 367, 0, 0, 366, 367, 366, 0, 366, - 367, 366, 0, 366, 0, 366, 367, 366, 0, 367, - 0, 0, 0, 0, 0, 0, 367, 0, 0, 0, - 0, 367, 0, 367, 367, 367, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 367, 0, 367, - 367, 0, 367, 0, 0, 367, 0, 367, 0, 367, - 367, 367, 367, 0, 367, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 367, 0, 367, 367, 367, 0, - 367, 367, 367, 367, 367, 367, 367, 0, 0, 0, - 367, 0, 367, 0, 0, 0, 0, 367, 0, 367, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, - 71, 0, 72, 0, 0, 73, 74, 0, 0, 367, - 75, 367, 0, 367, 76, 367, 0, 367, 0, 367, - 77, 367, 0, 78, 0, 0, 0, 0, 0, 0, - 79, 0, 0, 0, 0, 80, 0, 81, 82, 83, - 0, 246, 0, 0, 0, 0, 0, 0, 247, 0, - 0, 84, 0, 85, 86, 0, 87, 0, 0, 88, - 0, 89, 0, 90, 91, 92, 93, 0, 94, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 95, 0, 0, 0, 0, 0, 96, 97, 98, - 99, 0, 0, 0, 100, 0, 101, 0, 0, 0, - 0, 102, 0, 103, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 70, 71, 0, 72, 0, 0, 73, - 74, 0, 0, 104, 75, 105, 0, 106, 76, 107, - 0, 108, 0, 109, 77, 40, 0, 78, 0, 0, - 0, 0, 0, 0, 79, 0, 0, 0, 0, 80, - 0, 81, 82, 83, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 84, 0, 85, 86, 0, - 87, 0, 0, 88, 0, 89, 0, 90, 91, 92, - 93, 0, 94, 0, 0, 0, 0, 0, 0, 0, - 0, 416, 442, 0, 0, 95, 0, 0, 0, 0, - 0, 96, 97, 98, 99, 0, 0, 0, 100, 0, - 101, 0, 0, 0, 0, 102, 0, 103, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 70, 71, 0, - 72, 0, 0, 73, 74, 0, 0, 104, 75, 105, - 0, 106, 76, 107, 0, 108, 0, 109, 77, 40, - 0, 78, 0, 0, 0, 0, 0, 0, 79, 0, - 0, 0, 0, 80, 0, 81, 82, 83, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 84, - 0, 85, 86, 0, 87, 0, 0, 88, 0, 89, - 0, 90, 91, 92, 93, 0, 94, 0, 0, 0, - 0, 0, 0, 0, 0, 416, 554, 0, 0, 95, - 0, 0, 0, 0, 0, 96, 97, 98, 99, 0, - 0, 0, 100, 0, 101, 0, 0, 0, 0, 102, - 0, 103, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 102, 102, 0, 102, 0, 0, 102, 102, 0, - 0, 104, 102, 105, 0, 106, 102, 107, 0, 108, - 0, 109, 102, 40, 0, 102, 0, 0, 0, 0, - 0, 0, 102, 0, 0, 0, 0, 102, 0, 102, - 102, 102, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 102, 0, 102, 102, 0, 102, 0, - 0, 102, 0, 102, 0, 102, 102, 102, 102, 0, - 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 102, 0, 0, 102, 0, 102, 102, - 102, 102, 102, 0, 0, 0, 102, 0, 102, 0, - 0, 0, 0, 102, 0, 102, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 70, 71, 0, 72, 0, - 0, 73, 74, 0, 0, 102, 75, 102, 0, 102, - 76, 102, 0, 102, 0, 102, 77, 102, 0, 78, - 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, - 0, 80, 0, 81, 82, 83, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 84, 0, 85, - 86, 0, 87, 0, 0, 88, 0, 89, 0, 90, - 91, 92, 93, 0, 94, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, - 300, 0, 0, 96, 97, 98, 99, 0, 0, 0, - 100, 0, 101, 0, 0, 0, 0, 102, 0, 103, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, - 71, 0, 72, 0, 0, 73, 74, 0, 0, 104, - 75, 105, 0, 106, 76, 107, 0, 108, 0, 109, - 77, 40, 0, 78, 0, 0, 0, 0, 0, 0, - 79, 0, 0, 0, 0, 80, 0, 81, 82, 83, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 84, 0, 85, 86, 0, 87, 0, 0, 88, - 0, 89, 0, 90, 91, 92, 93, 0, 94, 0, - 0, 0, 0, 0, 0, 0, 0, 416, 0, 0, - 0, 95, 0, 0, 0, 0, 0, 96, 97, 98, - 99, 0, 0, 0, 100, 0, 101, 0, 0, 0, - 0, 102, 0, 103, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 70, 71, 0, 72, 0, 0, 73, - 74, 0, 0, 104, 75, 105, 0, 106, 76, 107, - 0, 108, 0, 109, 77, 40, 0, 78, 0, 0, - 0, 0, 0, 0, 79, 0, 0, 0, 0, 80, - 0, 81, 82, 83, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 84, 0, 85, 86, 0, - 87, 0, 0, 88, 0, 89, 0, 90, 91, 92, - 93, 0, 94, 0, 0, 503, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 95, 0, 0, 0, 0, - 0, 96, 97, 98, 99, 0, 0, 0, 100, 0, - 101, 0, 0, 0, 0, 102, 0, 103, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 437, 437, 0, - 437, 0, 0, 437, 437, 0, 0, 104, 437, 105, - 0, 106, 437, 107, 0, 108, 0, 109, 437, 40, - 0, 437, 0, 0, 0, 0, 0, 0, 437, 0, - 0, 0, 0, 437, 0, 437, 437, 437, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 437, - 0, 437, 437, 0, 437, 0, 0, 437, 0, 437, - 0, 437, 437, 437, 437, 0, 437, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 437, - 0, 0, 0, 0, 437, 437, 437, 437, 437, 0, - 0, 0, 437, 0, 437, 0, 0, 0, 0, 437, - 0, 437, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 70, 71, 0, 72, 0, 0, 73, 74, 0, - 0, 437, 75, 437, 0, 437, 76, 437, 0, 437, - 0, 437, 77, 437, 0, 78, 0, 0, 0, 0, - 0, 0, 79, 0, 0, 0, 0, 80, 0, 81, - 82, 83, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 84, 0, 85, 86, 0, 87, 0, - 0, 88, 0, 89, 0, 90, 91, 92, 93, 0, - 94, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 95, 0, 0, 0, 0, 0, 96, - 97, 98, 99, 0, 0, 0, 100, 0, 101, 0, - 0, 0, 0, 102, 0, 103, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 70, 71, 0, 72, 0, - 0, 73, 74, 0, 0, 104, 75, 105, 0, 106, - 76, 107, 0, 108, 0, 109, 77, 40, 0, 78, - 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, - 0, 80, 0, 81, 82, 83, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 84, 0, 85, - 86, 0, 87, 0, 0, 88, 0, 89, 0, 90, - 91, 92, 93, 0, 94, 0, 71, 503, 72, 0, - 0, 73, 0, 155, 448, 0, 75, 694, 156, 0, - 76, 0, 157, 449, 450, 0, 0, 0, 0, 78, - 0, 0, 0, 0, 451, 0, 79, 158, 0, 0, - 0, 80, 0, 0, 0, 83, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 84, 0, 85, - 0, 0, 87, 159, 0, 0, 0, 0, 0, 0, - 91, 92, 0, 0, 94, 0, 0, 452, 0, 104, - 0, 105, 0, 106, 0, 107, 0, 108, 387, 109, - 387, 40, 0, 387, 0, 387, 387, 0, 387, 0, - 387, 0, 387, 0, 387, 387, 387, 0, 0, 0, - 0, 387, 0, 0, 0, 0, 387, 0, 387, 387, - 0, 0, 0, 387, 0, 0, 0, 387, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 387, - 0, 387, 0, 0, 387, 387, 0, 0, 0, 0, - 0, 0, 387, 387, 0, 386, 387, 386, 0, 387, - 386, 453, 386, 386, 0, 386, 0, 386, 0, 386, - 0, 386, 386, 386, 0, 0, 0, 0, 386, 0, - 0, 0, 0, 386, 0, 386, 386, 0, 0, 0, - 386, 0, 0, 0, 386, 0, 0, 0, 0, 33, - 0, 33, 0, 0, 33, 0, 386, 0, 386, 33, - 0, 386, 386, 33, 0, 0, 33, 0, 0, 386, - 386, 0, 33, 386, 0, 0, 386, 0, 0, 33, - 0, 0, 0, 0, 33, 0, 33, 0, 33, 0, - 0, 0, 0, 387, 0, 0, 0, 0, 0, 0, - 33, 33, 33, 33, 0, 33, 33, 0, 0, 0, - 0, 33, 0, 33, 33, 33, 0, 33, 33, 0, - 33, 0, 0, 0, 33, 0, 0, 147, 0, 0, - 0, 33, 33, 0, 33, 0, 33, 33, 33, 0, - 33, 0, 33, 0, 0, 0, 33, 0, 0, 0, - 0, 0, 33, 0, 33, 33, 0, 33, 0, 0, - 386, 0, 33, 0, 0, 33, 33, 33, 0, 33, - 0, 33, 33, 33, 0, 33, 33, 0, 33, 148, - 33, 33, 0, 33, 0, 33, 33, 0, 33, 0, - 33, 0, 0, 0, 0, 0, 33, 33, 0, 33, - 33, 0, 0, 0, 33, 0, 33, 0, 71, 0, - 72, 33, 0, 73, 110, 33, 0, 33, 75, 33, - 0, 0, 76, 0, 33, 463, 0, 33, 0, 33, - 0, 78, 33, 0, 0, 0, 0, 0, 79, 0, - 33, 33, 0, 80, 33, 0, 0, 83, 0, 0, - 0, 0, 0, 0, 0, 231, 33, 231, 0, 84, - 231, 85, 0, 0, 87, 231, 0, 0, 0, 231, - 0, 0, 91, 92, 0, 0, 94, 0, 231, 464, - 0, 0, 0, 0, 0, 231, 0, 33, 0, 0, - 231, 232, 0, 232, 231, 0, 232, 0, 0, 0, - 0, 232, 0, 0, 0, 232, 231, 0, 231, 0, - 0, 231, 0, 0, 232, 0, 0, 0, 0, 231, - 231, 232, 0, 231, 0, 0, 232, 0, 0, 0, - 232, 33, 231, 0, 0, 0, 0, 0, 0, 0, - 231, 0, 232, 155, 232, 155, 0, 232, 155, 0, - 0, 0, 0, 155, 0, 232, 232, 155, 0, 232, - 155, 252, 0, 40, 0, 118, 155, 118, 232, 0, - 118, 0, 0, 155, 0, 118, 232, 0, 155, 118, - 0, 0, 155, 0, 0, 0, 0, 0, 118, 0, - 0, 0, 0, 0, 155, 118, 155, 252, 0, 155, - 118, 0, 0, 0, 118, 0, 0, 155, 155, 0, - 231, 155, 0, 0, 155, 0, 118, 0, 118, 0, - 0, 118, 0, 0, 0, 0, 0, 0, 0, 118, - 118, 0, 0, 118, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 252, 0, 252, 232, 0, 0, 0, - 0, 0, 252, 252, 0, 252, 252, 252, 252, 252, - 252, 252, 252, 252, 252, 252, 0, 252, 0, 252, - 0, 252, 0, 252, 0, 252, 0, 252, 0, 252, - 0, 252, 0, 252, 0, 252, 0, 252, 0, 252, - 0, 252, 0, 252, 0, 252, 0, 252, 155, 252, - 0, 252, 21, 252, 0, 21, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, - 118, 21, 0, 0, 0, 21, 0, 0, 21, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 21, 21, 0, 0, 0, 21, 21, 0, 0, 0, - 0, 21, 0, 21, 21, 21, 21, 12, 0, 0, - 12, 21, 0, 0, 21, 0, 21, 0, 0, 0, - 0, 12, 0, 0, 0, 0, 12, 0, 0, 21, - 12, 0, 0, 12, 0, 0, 0, 21, 21, 0, - 0, 0, 0, 0, 0, 12, 12, 0, 0, 0, - 12, 12, 0, 0, 0, 0, 12, 0, 12, 12, - 12, 12, 20, 0, 0, 20, 12, 0, 0, 12, - 0, 12, 0, 0, 0, 0, 20, 0, 0, 0, - 0, 20, 0, 0, 12, 20, 0, 0, 20, 0, - 0, 0, 12, 12, 0, 0, 0, 0, 0, 0, - 20, 20, 0, 0, 0, 20, 20, 0, 0, 0, - 0, 20, 0, 20, 20, 20, 20, 23, 0, 0, - 33, 20, 0, 0, 20, 0, 20, 0, 0, 0, - 0, 33, 0, 0, 0, 0, 33, 0, 0, 20, - 33, 0, 20, 33, 0, 0, 0, 0, 20, 0, - 0, 0, 0, 20, 0, 33, 33, 0, 20, 0, - 0, 33, 20, 0, 0, 20, 33, 0, 33, 33, - 33, 33, 0, 0, 0, 0, 33, 20, 20, 33, - 0, 33, 20, 20, 0, 0, 0, 0, 20, 0, - 20, 20, 20, 20, 33, 33, 0, 0, 20, 0, - 0, 20, 23, 20, 0, 0, 33, 0, 0, 33, - 0, 33, 33, 0, 0, 33, 20, 0, 33, 0, - 0, 0, 0, 33, 20, 20, 0, 0, 33, 0, - 33, 33, 33, 0, 0, 33, 33, 0, 0, 0, - 0, 33, 0, 33, 33, 33, 33, 33, 33, 0, - 0, 33, 33, 33, 33, 0, 33, 0, 33, 0, - 33, 33, 33, 33, 22, 0, 0, 33, 33, 33, - 0, 33, 0, 33, 0, 0, 0, 22, 33, 0, - 0, 0, 0, 33, 0, 0, 33, 33, 0, 0, - 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 33, 33, 0, 0, 0, 255, 33, 255, - 440, 255, 440, 33, 440, 33, 33, 33, 33, 255, - 0, 0, 0, 33, 0, 0, 33, 0, 33, 255, - 259, 255, 259, 443, 259, 443, 0, 443, 0, 0, - 0, 33, 259, 0, 0, 0, 0, 0, 0, 255, - 0, 255, 259, 255, 259, 255, 0, 255, 0, 255, - 0, 255, 0, 255, 0, 255, 0, 255, 0, 0, - 0, 0, 259, 0, 259, 0, 259, 0, 259, 0, - 259, 0, 259, 255, 259, 0, 259, 0, 259, 260, - 259, 260, 444, 260, 444, 0, 444, 0, 0, 0, - 299, 260, 299, 447, 299, 447, 259, 447, 0, 0, - 0, 260, 299, 260, 0, 0, 0, 0, 0, 0, - 0, 0, 299, 0, 299, 0, 0, 0, 0, 0, - 0, 260, 0, 260, 0, 260, 0, 260, 0, 260, - 0, 260, 299, 260, 299, 260, 299, 260, 299, 260, - 299, 16, 299, 16, 299, 16, 299, 0, 299, 0, - 299, 0, 0, 16, 0, 260, 0, 0, 0, 0, - 0, 0, 0, 16, 0, 16, 299, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 16, 0, 16, 0, 16, 0, 16, - 0, 16, 0, 16, 0, 16, 0, 16, 0, 16, - 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 16, - }; - protected static short [] yyCheck = { 3, - 235, 24, 322, 267, 326, 519, 491, 281, 1, 13, - 607, 275, 236, 467, 323, 625, 345, 43, 643, 347, - 333, 257, 263, 342, 260, 18, 268, 31, 264, 459, - 266, 24, 343, 269, 27, 271, 272, 343, 274, 313, - 276, 341, 278, 285, 280, 281, 282, 283, 607, 262, - 350, 287, 346, 347, 470, 343, 292, 323, 294, 295, - 296, 620, 564, 299, 300, 301, 343, 303, 364, 95, - 306, 393, 308, 309, 310, 311, 343, 343, 304, 315, - 316, 317, 323, 319, 320, 321, 343, 383, 81, 519, - 419, 419, 328, 329, 596, 304, 332, 323, 334, 335, - 419, 314, 95, 343, 343, 261, 342, 343, 419, 343, - 419, 343, 626, 419, 323, 351, 343, 343, 728, 729, - 536, 347, 96, 97, 98, 99, 100, 101, 102, 103, - 153, 419, 454, 730, 343, 161, 638, 163, 592, 641, - 364, 297, 419, 267, 170, 419, 262, 81, 343, 604, - 161, 275, 419, 419, 361, 419, 343, 183, 184, 346, - 153, 95, 419, 156, 190, 191, 192, 193, 194, 195, - 196, 197, 198, 199, 200, 168, 169, 607, 803, 419, - 419, 454, 419, 419, 343, 419, 337, 419, 381, 644, - 620, 342, 419, 419, 220, 1, 626, 470, 314, 361, - 356, 357, 361, 800, 361, 267, 413, 361, 234, 300, - 419, 370, 18, 275, 361, 208, 209, 373, 342, 375, - 246, 247, 156, 234, 419, 361, 343, 201, 202, 203, - 204, 205, 206, 207, 168, 169, 210, 211, 212, 213, - 214, 215, 216, 217, 218, 219, 355, 221, 733, 734, - 361, 413, 343, 361, 413, 343, 413, 355, 346, 413, - 341, 746, 455, 748, 457, 459, 413, 241, 349, 243, - 347, 591, 298, 350, 208, 209, 385, 413, 387, 325, - 389, 342, 391, 287, 393, 344, 395, 348, 397, 348, - 399, 317, 401, 350, 403, 488, 266, 491, 344, 269, - 352, 353, 413, 326, 341, 413, 271, 500, 501, 81, - 419, 276, 342, 350, 621, 280, 362, 802, 348, 639, - 324, 628, 342, 343, 294, 519, 319, 841, 341, 299, - 295, 347, 345, 326, 347, 348, 329, 350, 823, 343, - 339, 337, 305, 342, 307, 315, 342, 317, 341, 312, - 360, 361, 362, 838, 358, 271, 321, 361, 328, 329, - 276, 343, 332, 556, 280, 347, 370, 360, 503, 419, - 393, 344, 345, 508, 419, 348, 344, 344, 344, 295, - 348, 348, 348, 341, 156, 319, 339, 345, 392, 342, - 416, 384, 396, 386, 341, 329, 168, 169, 345, 829, - 393, 204, 205, 723, 341, 321, 432, 341, 345, 413, - 341, 841, 350, 607, 345, 341, 343, 349, 345, 345, - 347, 343, 257, 345, 344, 347, 360, 420, 348, 452, - 345, 454, 626, 346, 345, 348, 208, 209, 365, 345, - 367, 467, 345, 365, 437, 367, 369, 470, 371, 377, - 384, 379, 386, 206, 207, 448, 449, 347, 343, 452, - 345, 454, 210, 211, 212, 213, 348, 660, 350, 358, - 463, 497, 348, 499, 350, 459, 381, 470, 471, 472, - 363, 348, 486, 350, 359, 459, 420, 343, 343, 345, - 345, 337, 337, 339, 339, 688, 489, 346, 341, 348, - 344, 419, 346, 437, 345, 419, 347, 491, 337, 419, - 339, 214, 215, 346, 448, 449, 346, 491, 419, 419, - 419, 419, 350, 349, 346, 459, 343, 346, 346, 463, - 341, 345, 348, 348, 727, 519, 730, 471, 472, 733, - 734, 349, 349, 344, 349, 519, 739, 349, 348, 346, - 743, 342, 746, 341, 748, 489, 341, 341, 793, 794, - 346, 754, 755, 342, 341, 348, 592, 419, 348, 341, - 348, 342, 459, 355, 350, 301, 342, 342, 345, 304, - 419, 304, 419, 609, 345, 519, 612, 613, 360, 341, - 616, 341, 419, 347, 343, 346, 600, 601, 345, 625, - 355, 347, 628, 345, 491, 350, 800, 350, 802, 459, - 345, 345, 384, 345, 386, 608, 345, 643, 345, 459, - 350, 343, 342, 607, 345, 349, 341, 419, 345, 823, - 343, 350, 519, 607, 350, 829, 346, 355, 831, 345, - 342, 491, 626, 647, 838, 419, 336, 841, 420, 350, - 350, 491, 626, 657, 350, 648, 649, 350, 350, 348, - 653, 419, 346, 349, 344, 437, 459, 346, 694, 519, - 696, 343, 339, 607, 608, 337, 448, 449, 348, 519, - 345, 350, 350, 346, 285, 346, 620, 346, 345, 268, - 268, 463, 626, 346, 344, 346, 344, 346, 491, 471, - 472, 705, 728, 729, 346, 342, 293, 711, 712, 341, - 350, 341, 350, 262, 648, 649, 350, 489, 314, 653, - 607, 459, 346, 346, 345, 345, 519, 342, 344, 346, - 349, 264, 350, 266, 279, 342, 269, 350, 350, 626, - 350, 274, 346, 736, 342, 278, 730, 773, 337, 733, - 734, 346, 346, 491, 287, 346, 730, 607, 346, 733, - 734, 294, 746, 349, 748, 339, 299, 607, 350, 346, - 303, 342, 746, 341, 748, 350, 626, 803, 347, 346, - 341, 519, 315, 355, 317, 344, 626, 320, 346, 341, - 341, 341, 419, 341, 350, 328, 329, 344, 341, 332, - 342, 341, 736, 796, 342, 419, 342, 341, 812, 813, - 814, 350, 314, 385, 607, 387, 800, 389, 802, 391, - 419, 393, 350, 395, 262, 397, 800, 399, 802, 401, - 350, 403, 342, 626, 346, 346, 608, 342, 346, 823, - 223, 287, 4, 730, 31, 829, 733, 734, 15, 823, - 153, 370, 28, 331, 838, 829, 329, 841, 413, 746, - 593, 748, 796, 389, 838, 365, 389, 841, 657, 607, - 601, 396, 600, 727, 712, 711, 648, 649, 293, 812, - 730, 653, 334, 733, 734, 392, 419, 316, 626, 247, - 730, 216, 218, 733, 734, 829, 746, 217, 748, 221, - 219, 65, 806, -1, 829, 800, 746, 841, 748, 623, - 691, 808, -1, 800, 499, 802, 689, 692, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 346, - -1, 348, -1, 350, -1, -1, 823, 730, 355, -1, - 733, 734, 829, -1, 284, -1, -1, -1, -1, -1, - 800, 838, 802, 746, 841, 748, -1, -1, -1, -1, - 800, -1, 802, -1, 736, -1, -1, -1, 385, -1, - 387, -1, 389, 823, 391, -1, 393, -1, 395, 829, - 397, -1, 399, 823, 401, 325, 403, -1, 838, 829, - -1, 841, 730, -1, -1, 733, 734, -1, 838, -1, - -1, 841, -1, -1, -1, -1, -1, 800, 746, 802, - 748, 351, 352, 353, 354, -1, 356, 357, 358, 359, - 360, 361, 362, 363, 796, 365, -1, 367, -1, 369, - 823, 371, -1, 373, -1, 375, 829, 377, -1, 379, - -1, -1, -1, -1, -1, 838, -1, -1, 841, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 800, -1, 802, -1, -1, -1, -1, 257, - -1, -1, 260, -1, 262, -1, 264, -1, 266, -1, - -1, 269, -1, 271, 272, 823, 274, -1, 276, -1, - 278, 829, 280, 281, 282, 283, -1, -1, -1, 287, - 838, -1, -1, 841, 292, -1, 294, 295, 296, -1, - -1, 299, 300, 301, -1, 303, -1, 305, 306, 307, - 308, 309, 310, 311, 312, -1, 314, 315, 316, 317, - -1, 319, 320, 321, -1, -1, -1, -1, -1, -1, - 328, 329, -1, -1, 332, -1, 334, 335, 260, 337, - -1, 339, 264, -1, 266, -1, -1, 269, -1, 271, - 272, -1, 274, 351, 276, -1, 278, -1, 280, 281, - 282, 283, -1, -1, -1, 287, -1, -1, -1, -1, - 292, -1, 294, 295, 296, -1, -1, 299, -1, 301, - -1, 303, -1, -1, 306, -1, 308, 309, 310, 311, - -1, -1, -1, 315, 316, 317, -1, 319, 320, 321, - -1, -1, -1, -1, -1, -1, 328, 329, -1, -1, - 332, -1, 334, 335, -1, -1, -1, -1, -1, 260, - 342, 419, -1, 264, -1, 266, -1, -1, 269, 351, - 271, 272, -1, 274, -1, 276, -1, 278, -1, 280, - 281, 282, 283, -1, -1, -1, 287, -1, -1, -1, - -1, 292, -1, 294, 295, 296, -1, -1, 299, -1, - 301, -1, 303, -1, -1, 306, -1, 308, 309, 310, - 311, -1, -1, -1, 315, 316, 317, -1, 319, 320, - 321, -1, -1, -1, -1, -1, -1, 328, 329, -1, - -1, 332, -1, 334, 335, -1, -1, 419, -1, -1, - 260, 342, -1, -1, 264, -1, 266, -1, -1, 269, - 351, 271, 272, -1, 274, -1, 276, -1, 278, -1, - 280, 281, 282, 283, -1, -1, -1, 287, -1, -1, - -1, -1, 292, -1, 294, 295, 296, -1, -1, 299, - -1, 301, -1, 303, -1, -1, 306, -1, 308, 309, - 310, 311, -1, -1, -1, 315, 316, 317, -1, 319, - 320, 321, -1, -1, -1, -1, -1, -1, 328, 329, - -1, -1, 332, -1, 334, 335, -1, -1, 419, 260, - -1, -1, 342, 264, -1, 266, -1, -1, 269, -1, - 271, 272, -1, 274, -1, 276, -1, 278, -1, 280, - 281, 282, 283, -1, -1, -1, 287, -1, -1, -1, - -1, 292, -1, 294, 295, 296, -1, -1, 299, -1, - 301, -1, 303, -1, -1, 306, -1, 308, 309, 310, - 311, -1, -1, -1, 315, 316, 317, -1, 319, 320, - 321, -1, -1, -1, -1, -1, -1, 328, 329, -1, - -1, 332, -1, 334, 335, -1, -1, -1, -1, 419, - 261, 342, 263, 264, -1, 266, -1, -1, 269, 270, - -1, -1, -1, 274, -1, -1, -1, 278, -1, -1, - -1, -1, -1, 284, -1, -1, 287, -1, -1, -1, - -1, -1, -1, 294, -1, -1, 297, -1, 299, -1, - 301, 302, 303, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 315, -1, 317, 318, -1, 320, - -1, -1, 323, -1, 325, -1, 327, 328, 329, 330, - 346, 332, 348, -1, 350, -1, -1, -1, 419, 355, - 341, 342, -1, 344, 345, 346, 347, 348, 349, 350, - 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, - 361, 362, 363, 364, 365, -1, 367, -1, 369, 385, - 371, 387, 373, 389, 375, 391, 377, 393, 379, 395, - 381, 397, 383, 399, 385, 401, 387, 403, 389, -1, - 391, -1, 393, -1, 395, -1, 397, -1, 399, -1, - 401, -1, 403, -1, -1, -1, 407, -1, 409, -1, - 411, -1, 413, -1, 415, -1, 417, 261, 419, 263, - 264, -1, 266, -1, -1, 269, 270, -1, -1, -1, - 274, -1, -1, -1, 278, -1, -1, -1, -1, -1, - 284, -1, -1, 287, -1, -1, -1, -1, -1, -1, - 294, -1, -1, 297, -1, 299, -1, 301, 302, 303, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 315, -1, 317, 318, -1, 320, -1, -1, 323, - -1, 325, -1, 327, 328, 329, 330, -1, 332, -1, - -1, -1, -1, -1, -1, -1, -1, 341, 342, -1, - 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, - 364, 365, -1, 367, -1, 369, -1, 371, -1, 373, - -1, 375, -1, 377, -1, 379, -1, 381, -1, 383, - -1, 385, -1, 387, -1, 389, -1, 391, -1, 393, - -1, 395, -1, 397, -1, 399, -1, 401, -1, 403, - -1, -1, -1, 407, -1, 409, -1, 411, -1, 413, - -1, 415, -1, 417, 261, 419, 263, 264, -1, 266, - -1, -1, 269, 270, -1, -1, -1, 274, -1, -1, - -1, 278, -1, -1, -1, -1, -1, 284, -1, -1, - 287, -1, -1, -1, -1, -1, -1, 294, -1, -1, - 297, -1, 299, -1, 301, 302, 303, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 315, -1, - 317, 318, -1, 320, -1, -1, 323, -1, 325, -1, - 327, 328, 329, 330, -1, 332, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 342, 343, 344, 345, 346, - 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, - 357, 358, 359, 360, 361, 362, 363, 364, 365, -1, - 367, -1, 369, -1, 371, -1, 373, -1, 375, -1, - 377, -1, 379, -1, 381, -1, 383, -1, 385, -1, - 387, -1, 389, -1, 391, -1, 393, -1, 395, -1, - 397, -1, 399, -1, 401, -1, 403, -1, -1, -1, - 407, -1, 409, -1, 411, -1, 413, -1, 415, -1, - 417, 261, 419, 263, 264, -1, 266, -1, -1, 269, - 270, -1, -1, -1, 274, -1, -1, -1, 278, -1, - -1, -1, -1, -1, 284, -1, -1, 287, -1, -1, - -1, -1, -1, -1, 294, -1, -1, 297, -1, 299, - -1, 301, 302, 303, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 315, -1, 317, 318, -1, - 320, -1, -1, 323, -1, 325, -1, 327, 328, 329, - 330, -1, 332, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 342, 343, 344, 345, 346, -1, 348, 349, - 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, - 360, 361, 362, 363, 364, 365, -1, 367, -1, 369, - -1, 371, -1, 373, -1, 375, -1, 377, -1, 379, - -1, 381, -1, 383, -1, 385, -1, 387, -1, 389, - -1, 391, -1, 393, -1, 395, -1, 397, -1, 399, - -1, 401, -1, 403, -1, -1, -1, 407, -1, 409, - -1, 411, -1, 413, -1, 415, -1, 417, 261, 419, - 263, 264, -1, 266, -1, -1, 269, 270, -1, -1, - -1, 274, -1, -1, -1, 278, -1, -1, -1, -1, - -1, 284, -1, -1, 287, -1, -1, -1, -1, -1, - -1, 294, -1, -1, 297, -1, 299, -1, 301, 302, - 303, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 315, -1, 317, 318, -1, 320, -1, -1, - 323, -1, 325, -1, 327, 328, 329, 330, -1, 332, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 342, - -1, 344, -1, 346, -1, 348, 349, 350, 351, 352, - 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, - 363, 364, -1, -1, -1, -1, 369, -1, 371, -1, - 373, -1, 375, -1, 377, -1, 379, -1, 381, -1, - 383, -1, 385, -1, 387, -1, 389, -1, 391, -1, - 393, -1, 395, -1, 397, -1, 399, -1, 401, -1, - 403, -1, -1, -1, 407, -1, 409, -1, 411, -1, - 413, -1, 415, -1, 417, 261, 419, 263, 264, -1, - 266, -1, -1, 269, 270, -1, -1, -1, 274, -1, - -1, -1, 278, -1, -1, -1, -1, -1, 284, -1, - -1, 287, -1, -1, -1, -1, -1, -1, 294, -1, - -1, 297, -1, 299, -1, 301, 302, 303, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 315, - -1, 317, 318, -1, 320, -1, -1, 323, -1, 325, - -1, 327, 328, 329, 330, -1, 332, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 342, -1, 344, 345, - 346, -1, 348, 349, 350, 351, 352, 353, 354, -1, - 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, - -1, 367, -1, 369, -1, 371, -1, 373, -1, 375, - -1, 377, -1, 379, -1, 381, -1, 383, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 261, - -1, 263, 264, -1, 266, -1, -1, 269, 270, -1, - -1, 407, 274, 409, -1, 411, 278, 413, -1, 415, - -1, 417, 284, 419, -1, 287, -1, -1, -1, -1, - -1, -1, 294, -1, -1, 297, -1, 299, -1, 301, - 302, 303, 304, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 315, -1, 317, 318, -1, 320, -1, - -1, 323, -1, 325, -1, 327, 328, 329, 330, -1, - 332, -1, -1, -1, -1, -1, -1, -1, -1, 341, - 342, 343, 344, 345, 346, -1, 348, 349, 350, 351, - 352, 353, 354, -1, 356, 357, 358, 359, 360, -1, - -1, 363, 364, 365, -1, 367, -1, -1, -1, -1, - -1, 373, -1, 375, -1, 377, -1, 379, -1, 381, - -1, 383, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 261, -1, 263, 264, -1, 266, -1, - -1, 269, 270, -1, -1, 407, 274, 409, -1, 411, - 278, 413, -1, 415, -1, 417, 284, 419, -1, 287, - -1, -1, -1, -1, -1, -1, 294, -1, -1, 297, - -1, 299, -1, 301, 302, 303, 304, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 315, -1, 317, - 318, -1, 320, -1, -1, 323, -1, 325, -1, 327, - 328, 329, 330, -1, 332, -1, -1, -1, -1, -1, - -1, -1, -1, 341, 342, -1, 344, 345, 346, -1, - 348, 349, 350, 351, 352, 353, 354, -1, 356, 357, - 358, 359, 360, -1, -1, 363, 364, 365, -1, 367, - -1, -1, -1, -1, -1, 373, -1, 375, -1, 377, - -1, 379, -1, 381, -1, 383, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 261, -1, 263, - 264, -1, 266, -1, -1, 269, 270, -1, -1, 407, - 274, 409, -1, 411, 278, 413, -1, 415, -1, 417, - 284, 419, -1, 287, -1, -1, -1, -1, -1, -1, - 294, -1, -1, 297, -1, 299, -1, 301, 302, 303, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 315, -1, 317, 318, -1, 320, -1, -1, 323, - -1, 325, -1, 327, 328, 329, 330, -1, 332, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 342, -1, - 344, 345, 346, -1, 348, 349, 350, 351, 352, 353, - 354, -1, 356, 357, 358, 359, -1, -1, -1, 363, - 364, 365, -1, 367, -1, 369, -1, 371, -1, 373, - -1, 375, -1, 377, -1, 379, -1, 381, -1, 383, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 261, -1, 263, 264, -1, 266, -1, -1, 269, - 270, -1, -1, 407, 274, 409, -1, 411, 278, 413, - -1, 415, -1, 417, 284, 419, -1, 287, -1, -1, - -1, -1, -1, -1, 294, -1, -1, 297, -1, 299, - -1, 301, 302, 303, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 315, -1, 317, 318, -1, - 320, -1, -1, 323, -1, 325, -1, 327, 328, 329, - 330, -1, 332, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 342, -1, 344, 345, 346, -1, 348, 349, - 350, 351, 352, 353, 354, -1, 356, 357, 358, 359, - -1, -1, -1, 363, 364, 365, -1, 367, -1, 369, - -1, 371, -1, 373, -1, 375, -1, 377, -1, 379, - -1, 381, -1, 383, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 261, -1, 263, 264, -1, - 266, -1, -1, 269, 270, -1, -1, 407, 274, 409, - -1, 411, 278, 413, -1, 415, -1, 417, 284, 419, - -1, 287, -1, -1, -1, -1, -1, -1, 294, -1, - -1, 297, -1, 299, -1, 301, 302, 303, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 315, - -1, 317, 318, -1, 320, -1, -1, 323, -1, 325, - -1, 327, 328, 329, 330, -1, 332, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 342, -1, 344, 345, - 346, -1, 348, 349, 350, 351, 352, 353, 354, -1, - 356, 357, 358, 359, -1, -1, -1, 363, 364, 365, - -1, 367, -1, 369, -1, 371, -1, 373, -1, 375, - -1, 377, -1, 379, -1, 381, -1, 383, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 261, - -1, 263, 264, -1, 266, -1, -1, 269, 270, -1, - -1, 407, 274, 409, -1, 411, 278, 413, -1, 415, - -1, 417, 284, 419, -1, 287, -1, -1, -1, -1, - -1, -1, 294, -1, -1, 297, -1, 299, -1, 301, - 302, 303, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 315, -1, 317, 318, -1, 320, -1, - -1, 323, -1, 325, -1, 327, 328, 329, 330, -1, - 332, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 342, -1, 344, 345, 346, -1, 348, 349, 350, 351, - -1, -1, 354, -1, 356, 357, 358, 359, 360, -1, - -1, 363, 364, 365, -1, 367, -1, 369, -1, 371, - -1, 373, -1, 375, -1, 377, -1, 379, -1, 381, - -1, 383, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 261, -1, 263, 264, -1, 266, -1, - -1, 269, 270, -1, -1, 407, 274, 409, -1, 411, - 278, 413, -1, 415, -1, 417, 284, 419, -1, 287, - -1, -1, -1, -1, -1, -1, 294, -1, -1, 297, - -1, 299, -1, 301, 302, 303, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 315, -1, 317, - 318, -1, 320, -1, -1, 323, -1, 325, -1, 327, - 328, 329, 330, -1, 332, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 342, -1, 344, 345, 346, -1, - 348, 349, 350, 351, 352, 353, 354, -1, 356, 357, - 358, 359, 360, -1, -1, 363, 364, 365, -1, 367, - -1, -1, -1, -1, -1, 373, -1, 375, -1, 377, - -1, 379, -1, 381, -1, 383, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 261, -1, 263, - 264, -1, 266, -1, -1, 269, 270, -1, -1, 407, - 274, 409, -1, 411, 278, 413, -1, 415, -1, 417, - 284, 419, -1, 287, -1, -1, -1, -1, -1, -1, - 294, -1, -1, 297, -1, 299, -1, 301, 302, 303, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 315, -1, 317, 318, -1, 320, -1, -1, 323, - -1, 325, -1, 327, 328, 329, 330, -1, 332, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 342, -1, - 344, 345, 346, -1, 348, 349, 350, 351, -1, -1, - 354, -1, 356, 357, 358, 359, 360, -1, -1, 363, - 364, 365, -1, 367, -1, 369, -1, 371, -1, 373, - -1, 375, -1, 377, -1, 379, -1, 381, -1, 383, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 261, -1, 263, 264, -1, 266, -1, -1, 269, - 270, -1, -1, 407, 274, 409, -1, 411, 278, 413, - -1, 415, -1, 417, 284, 419, -1, 287, -1, -1, - -1, -1, -1, -1, 294, -1, -1, 297, -1, 299, - -1, 301, 302, 303, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 315, -1, 317, 318, -1, - 320, -1, -1, 323, -1, 325, -1, 327, 328, 329, - 330, -1, 332, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 342, -1, 344, 345, 346, -1, 348, 349, - 350, 351, -1, -1, 354, -1, 356, 357, 358, 359, - 360, -1, -1, 363, 364, 365, -1, 367, -1, 369, - -1, 371, -1, 373, -1, 375, -1, 377, -1, 379, - -1, 381, -1, 383, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 261, -1, 263, 264, -1, - 266, -1, -1, 269, 270, -1, -1, 407, 274, 409, - -1, 411, 278, 413, -1, 415, -1, 417, 284, 419, - -1, 287, -1, -1, -1, -1, -1, -1, 294, -1, - -1, 297, -1, 299, -1, 301, 302, 303, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 315, - -1, 317, 318, -1, 320, -1, -1, 323, -1, 325, - -1, 327, 328, 329, 330, -1, 332, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 342, -1, 344, 345, - 346, -1, 348, 349, 350, 351, 352, 353, 354, -1, - 356, 357, 358, 359, 360, -1, -1, 363, 364, 365, - -1, 367, -1, -1, -1, -1, -1, 373, -1, 375, - -1, 377, -1, 379, -1, 381, -1, 383, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 261, - -1, 263, 264, -1, 266, -1, -1, 269, 270, -1, - -1, 407, 274, 409, -1, 411, 278, 413, -1, 415, - -1, 417, 284, 419, -1, 287, -1, -1, -1, -1, - -1, -1, 294, -1, -1, 297, -1, 299, -1, 301, - 302, 303, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 315, -1, 317, 318, -1, 320, -1, - -1, 323, -1, 325, -1, 327, 328, 329, 330, -1, - 332, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 342, -1, 344, 345, 346, -1, 348, 349, 350, 351, - 352, 353, 354, -1, 356, 357, 358, 359, 360, -1, - -1, 363, 364, 365, -1, 367, -1, -1, -1, -1, - -1, 373, -1, 375, -1, 377, -1, 379, -1, 381, - -1, 383, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 261, -1, 263, 264, -1, 266, -1, - -1, 269, 270, -1, -1, 407, 274, 409, -1, 411, - 278, 413, -1, 415, -1, 417, 284, 419, -1, 287, - -1, -1, -1, -1, -1, -1, 294, -1, -1, 297, - -1, 299, -1, 301, 302, 303, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 315, -1, 317, - 318, -1, 320, -1, -1, 323, -1, 325, -1, 327, - 328, 329, 330, -1, 332, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 342, -1, 344, 345, 346, -1, - 348, 349, 350, 351, 352, 353, 354, -1, 356, 357, - 358, 359, 360, -1, -1, 363, 364, 365, -1, 367, - -1, -1, -1, -1, -1, 373, -1, 375, -1, 377, - -1, 379, -1, 381, -1, 383, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 261, -1, 263, - 264, -1, 266, -1, -1, 269, 270, -1, -1, 407, - 274, 409, -1, 411, 278, 413, -1, 415, -1, 417, - 284, 419, -1, 287, -1, -1, -1, -1, -1, -1, - 294, -1, -1, 297, -1, 299, -1, 301, 302, 303, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 315, -1, 317, 318, -1, 320, -1, -1, 323, - -1, 325, -1, 327, 328, 329, 330, -1, 332, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 342, -1, - 344, 345, 346, -1, 348, 349, 350, 351, 352, 353, - 354, -1, 356, 357, 358, 359, 360, -1, -1, 363, - 364, 365, -1, 367, -1, -1, -1, -1, -1, 373, - -1, 375, -1, 377, -1, 379, -1, 381, -1, 383, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 261, -1, 263, 264, -1, 266, -1, -1, 269, - 270, -1, -1, 407, 274, 409, -1, 411, 278, 413, - -1, 415, -1, 417, 284, 419, -1, 287, -1, -1, - -1, -1, -1, -1, 294, -1, -1, 297, -1, 299, - -1, 301, 302, 303, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 315, -1, 317, 318, -1, - 320, -1, -1, 323, -1, 325, -1, 327, 328, 329, - 330, -1, 332, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 342, -1, 344, 345, 346, -1, 348, 349, - 350, 351, 352, 353, 354, -1, 356, 357, 358, 359, - 360, -1, -1, 363, 364, 365, -1, 367, -1, -1, - -1, -1, -1, 373, -1, 375, -1, 377, -1, 379, - -1, 381, -1, 383, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 261, -1, 263, 264, -1, - 266, -1, -1, 269, 270, -1, -1, 407, 274, 409, - -1, 411, 278, 413, -1, 415, -1, 417, 284, 419, - -1, 287, -1, -1, -1, -1, -1, -1, 294, -1, - -1, 297, -1, 299, -1, 301, 302, 303, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 315, - -1, 317, 318, -1, 320, -1, -1, 323, -1, 325, - -1, 327, 328, 329, 330, -1, 332, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 342, -1, 344, 345, - 346, -1, 348, 349, 350, 351, 352, 353, 354, -1, - 356, 357, 358, 359, 360, -1, -1, 363, 364, 365, - -1, 367, -1, -1, -1, -1, -1, 373, -1, 375, - -1, 377, -1, 379, -1, 381, -1, 383, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 407, -1, 409, -1, 411, -1, 413, -1, 415, - -1, 417, -1, 419, 263, 264, 265, 266, 267, -1, - 269, 270, -1, 272, 273, 274, 275, -1, 277, 278, - 279, -1, -1, -1, -1, 284, 285, -1, 287, 288, - 289, 290, 291, -1, -1, 294, -1, -1, -1, 298, - 299, -1, 301, 302, 303, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 313, -1, 315, -1, 317, 318, - -1, 320, -1, 322, 323, 324, 325, 326, 327, 328, - 329, 330, -1, 332, 333, 260, 335, 336, -1, -1, - -1, -1, 341, 342, -1, -1, 345, -1, -1, -1, - -1, 350, 351, 352, 353, 354, -1, -1, 283, 358, - -1, 360, -1, -1, -1, -1, 365, -1, 367, -1, - -1, 296, -1, -1, -1, -1, 301, -1, -1, -1, - -1, 306, -1, 308, 309, 310, 311, -1, -1, -1, - -1, 316, -1, -1, 319, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 407, 334, - 409, -1, 411, -1, 413, -1, 415, -1, 417, -1, - 419, 263, 264, 265, 266, 267, 351, 269, 270, -1, - 272, 273, 274, 275, -1, 277, 278, 279, -1, -1, - -1, -1, 284, -1, -1, 287, 288, 289, 290, 291, - -1, -1, 294, -1, -1, -1, 298, 299, -1, 301, - 302, 303, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 313, -1, 315, -1, 317, 318, -1, 320, -1, - 322, 323, 324, 325, 326, 327, 328, 329, 330, -1, - 332, 333, 260, 335, 336, -1, -1, -1, -1, 341, - 342, -1, -1, 345, -1, -1, -1, -1, 350, 351, - 352, 353, 354, -1, -1, 283, 358, -1, 360, -1, - -1, -1, -1, 365, -1, 367, -1, -1, 296, -1, - -1, -1, -1, 301, -1, -1, -1, -1, 306, -1, - 308, 309, 310, 311, -1, -1, -1, -1, 316, -1, - -1, 319, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 407, 334, 409, -1, 411, - -1, 413, -1, 415, -1, 417, -1, 419, 263, 264, - 265, 266, 267, -1, 269, 270, -1, 272, 273, 274, - 275, -1, 277, 278, -1, -1, -1, -1, -1, 284, - -1, -1, 287, 288, 289, 290, 291, -1, -1, 294, - -1, -1, -1, 298, 299, -1, 301, 302, 303, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 313, -1, - 315, -1, 317, 318, -1, 320, -1, 322, 323, 324, - 325, 326, 327, 328, 329, 330, -1, 332, 333, -1, - 335, 336, -1, -1, -1, -1, 341, 342, -1, -1, - 345, -1, -1, -1, -1, 350, 351, 352, 353, 354, - -1, -1, -1, 358, -1, 360, -1, -1, -1, -1, - 365, -1, 367, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 407, -1, 409, -1, 411, -1, 413, -1, - 415, -1, 417, -1, 419, 263, 264, 265, 266, -1, - -1, 269, 270, -1, 272, 273, 274, -1, -1, 277, - 278, -1, -1, -1, -1, -1, 284, -1, -1, 287, - 288, 289, 290, 291, -1, -1, 294, -1, -1, -1, - 298, 299, -1, 301, 302, 303, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 313, -1, 315, -1, 317, - 318, -1, 320, -1, 322, 323, 324, 325, 326, 327, - 328, 329, 330, -1, 332, 333, -1, 335, 336, -1, - -1, -1, -1, 341, -1, -1, -1, 345, -1, -1, - -1, -1, 350, 351, 352, 353, 354, -1, -1, -1, - 358, -1, 360, -1, -1, -1, -1, 365, -1, 367, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 407, - -1, 409, -1, 411, -1, 413, -1, 415, -1, 417, - -1, 419, 263, 264, 265, 266, -1, -1, 269, 270, - -1, 272, 273, 274, -1, -1, 277, 278, -1, -1, - -1, -1, -1, 284, -1, -1, 287, 288, 289, 290, - 291, -1, -1, 294, -1, -1, -1, 298, 299, -1, - 301, 302, 303, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 313, -1, 315, -1, 317, 318, -1, 320, - -1, 322, 323, 324, 325, 326, 327, 328, 329, 330, - -1, 332, 333, -1, 335, 336, -1, -1, -1, -1, - 341, -1, -1, -1, 345, -1, -1, -1, -1, 350, - 351, 352, 353, 354, -1, -1, -1, 358, -1, 360, - -1, -1, -1, -1, 365, -1, 367, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 407, -1, 409, -1, - 411, -1, 413, -1, 415, -1, 417, -1, 419, 263, - 264, 265, 266, -1, -1, 269, 270, -1, -1, 273, - 274, -1, -1, 277, 278, -1, -1, -1, -1, -1, - 284, -1, -1, 287, 288, 289, 290, 291, -1, -1, - 294, -1, -1, -1, 298, 299, -1, 301, 302, 303, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 313, - -1, 315, -1, 317, 318, -1, 320, -1, 322, 323, - 324, 325, 326, 327, 328, 329, 330, -1, 332, 333, - -1, -1, 336, -1, -1, -1, -1, 341, -1, -1, - -1, 345, -1, -1, -1, -1, 350, 351, 352, 353, - 354, -1, -1, -1, 358, -1, 360, -1, -1, -1, - -1, 365, -1, 367, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 263, 264, -1, 266, -1, -1, 269, - 270, -1, -1, 407, 274, 409, -1, 411, 278, 413, - -1, 415, -1, 417, 284, 419, -1, 287, -1, -1, - -1, -1, -1, -1, 294, -1, -1, -1, -1, 299, - -1, 301, 302, 303, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 315, -1, 317, 318, -1, - 320, -1, -1, 323, -1, 325, -1, 327, 328, 329, - 330, -1, 332, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 342, -1, 344, 345, 346, -1, 348, 349, - 350, 351, 352, 353, 354, -1, -1, -1, 358, 359, - 360, -1, -1, 363, 364, 365, -1, 367, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 377, -1, 379, - -1, 381, -1, 383, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 263, 264, -1, - 266, -1, -1, 269, 270, -1, -1, 407, 274, 409, - -1, 411, 278, 413, -1, 415, -1, 417, 284, 419, - -1, 287, -1, -1, -1, -1, -1, -1, 294, -1, - -1, -1, -1, 299, -1, 301, 302, 303, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 315, - -1, 317, 318, -1, 320, -1, -1, 323, -1, 325, - -1, 327, 328, 329, 330, -1, 332, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 342, -1, 344, 345, - 346, -1, 348, 349, 350, 351, 352, 353, 354, -1, - -1, -1, 358, 359, 360, -1, -1, 363, 364, 365, - -1, 367, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 377, -1, 379, -1, 381, -1, 383, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 263, 264, -1, 266, -1, -1, 269, 270, -1, - -1, 407, 274, 409, -1, 411, 278, 413, -1, 415, - -1, 417, 284, 419, -1, 287, -1, -1, -1, -1, - -1, -1, 294, -1, -1, -1, -1, 299, -1, 301, - 302, 303, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 315, -1, 317, 318, -1, 320, -1, - -1, 323, -1, 325, -1, 327, 328, 329, 330, -1, - 332, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 342, -1, 344, 345, 346, -1, 348, 349, 350, 351, - 352, 353, 354, -1, -1, -1, 358, 359, 360, -1, - -1, 363, 364, 365, -1, 367, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 377, -1, 379, -1, 381, - -1, 383, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 263, 264, -1, 266, -1, - -1, 269, 270, -1, -1, 407, 274, 409, -1, 411, - 278, 413, -1, 415, -1, 417, 284, 419, -1, 287, - -1, -1, -1, -1, -1, -1, 294, -1, -1, -1, - -1, 299, -1, 301, 302, 303, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 315, -1, 317, - 318, -1, 320, -1, -1, 323, -1, 325, -1, 327, - 328, 329, 330, -1, 332, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 342, -1, 344, 345, 346, -1, - 348, 349, 350, 351, 352, 353, 354, -1, -1, -1, - 358, 359, 360, -1, -1, 363, 364, 365, -1, 367, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 381, -1, 383, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 263, - 264, -1, 266, -1, -1, 269, 270, -1, -1, 407, - 274, 409, -1, 411, 278, 413, -1, 415, -1, 417, - 284, 419, -1, 287, -1, -1, -1, -1, -1, -1, - 294, -1, -1, -1, -1, 299, -1, 301, 302, 303, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 315, -1, 317, 318, -1, 320, -1, -1, 323, - -1, 325, -1, 327, 328, 329, 330, -1, 332, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 342, -1, - 344, 345, 346, -1, 348, 349, 350, 351, 352, 353, - 354, -1, -1, -1, 358, 359, 360, -1, -1, 363, - 364, 365, -1, 367, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 381, -1, 383, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 263, 264, -1, 266, -1, -1, 269, - 270, -1, -1, 407, 274, 409, -1, 411, 278, 413, - -1, 415, -1, 417, 284, 419, -1, 287, -1, -1, - -1, -1, -1, -1, 294, -1, -1, -1, -1, 299, - -1, 301, 302, 303, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 315, -1, 317, 318, -1, - 320, -1, -1, 323, -1, 325, -1, 327, 328, 329, - 330, -1, 332, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 342, -1, 344, 345, 346, -1, 348, 349, - 350, 351, 352, 353, 354, -1, -1, -1, -1, 359, - 360, -1, -1, 363, 364, 365, -1, 367, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 381, -1, 383, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 263, 264, -1, - 266, -1, -1, 269, 270, -1, -1, 407, 274, 409, - -1, 411, 278, 413, -1, 415, -1, 417, 284, 419, - -1, 287, -1, -1, -1, -1, -1, -1, 294, -1, - -1, -1, -1, 299, -1, 301, 302, 303, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 315, - -1, 317, 318, -1, 320, -1, -1, 323, -1, 325, - -1, 327, 328, 329, 330, -1, 332, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 342, -1, 344, 345, - 346, -1, 348, 349, 350, 351, 352, 353, 354, -1, - -1, -1, 358, 359, 360, -1, -1, -1, 364, 365, - -1, 367, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 381, -1, 383, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 263, 264, -1, 266, -1, -1, 269, 270, -1, - -1, 407, 274, 409, -1, 411, 278, 413, -1, 415, - -1, 417, 284, 419, -1, 287, -1, -1, -1, -1, - -1, -1, 294, -1, -1, -1, -1, 299, -1, 301, - 302, 303, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 315, -1, 317, 318, -1, 320, -1, - -1, 323, -1, 325, -1, 327, 328, 329, 330, -1, - 332, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 342, -1, 344, 345, 346, -1, 348, 349, 350, 351, - 352, 353, 354, -1, -1, -1, -1, 359, 360, -1, - -1, 363, 364, 365, -1, 367, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 381, - -1, 383, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 263, 264, -1, 266, -1, - -1, 269, 270, -1, -1, 407, 274, 409, -1, 411, - 278, 413, -1, 415, -1, 417, 284, 419, -1, 287, - -1, -1, -1, -1, -1, -1, 294, -1, -1, -1, - -1, 299, -1, 301, 302, 303, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 315, -1, 317, - 318, -1, 320, -1, -1, 323, -1, 325, -1, 327, - 328, 329, 330, -1, 332, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 342, -1, 344, 345, 346, -1, - 348, 349, 350, 351, 352, 353, 354, -1, -1, -1, - 358, 359, 360, -1, -1, -1, 364, 365, -1, 367, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 381, -1, 383, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 263, - 264, -1, 266, -1, -1, 269, 270, -1, -1, 407, - 274, 409, -1, 411, 278, 413, -1, 415, -1, 417, - 284, 419, -1, 287, -1, -1, -1, -1, -1, -1, - 294, -1, -1, -1, -1, 299, -1, 301, 302, 303, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 315, -1, 317, 318, -1, 320, -1, -1, 323, - -1, 325, -1, 327, 328, 329, 330, -1, 332, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 342, -1, - 344, 345, 346, -1, 348, 349, 350, 351, 352, 353, - 354, -1, -1, -1, 358, -1, 360, -1, -1, -1, - 364, 365, -1, 367, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 381, -1, 383, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 263, 264, -1, 266, -1, -1, 269, - 270, -1, -1, 407, 274, 409, -1, 411, 278, 413, - -1, 415, -1, 417, 284, 419, -1, 287, -1, -1, - -1, -1, -1, -1, 294, -1, -1, -1, -1, 299, - -1, 301, 302, 303, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 315, -1, 317, 318, -1, - 320, -1, -1, 323, -1, 325, -1, 327, 328, 329, - 330, -1, 332, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 342, -1, 344, 345, 346, -1, 348, 349, - 350, 351, 352, 353, 354, -1, -1, -1, 358, -1, - 360, -1, -1, -1, 364, 365, -1, 367, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 381, -1, 383, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 263, 264, -1, - 266, -1, -1, 269, 270, -1, -1, 407, 274, 409, - -1, 411, 278, 413, -1, 415, -1, 417, 284, 419, - -1, 287, -1, -1, -1, -1, -1, -1, 294, -1, - -1, -1, -1, 299, -1, 301, 302, 303, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 315, - -1, 317, 318, -1, 320, -1, -1, 323, -1, 325, - -1, 327, 328, 329, 330, -1, 332, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 342, -1, 344, 345, - 346, -1, 348, 349, 350, 351, 352, 353, 354, -1, - -1, -1, 358, -1, 360, -1, -1, -1, 364, 365, - -1, 367, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 383, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 263, 264, -1, 266, -1, -1, 269, 270, -1, - -1, 407, 274, 409, -1, 411, 278, 413, -1, 415, - -1, 417, 284, 419, -1, 287, -1, -1, -1, -1, - -1, -1, 294, -1, -1, -1, -1, 299, -1, 301, - 302, 303, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 315, -1, 317, 318, -1, 320, -1, - -1, 323, -1, 325, -1, 327, 328, 329, 330, -1, - 332, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 342, -1, 344, 345, 346, -1, 348, 349, 350, 351, - 352, 353, 354, -1, -1, -1, 358, -1, 360, -1, - -1, -1, 364, 365, -1, 367, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 383, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 263, 264, -1, 266, -1, - -1, 269, 270, -1, -1, 407, 274, 409, -1, 411, - 278, 413, -1, 415, -1, 417, 284, 419, -1, 287, - -1, -1, -1, -1, -1, -1, 294, -1, -1, -1, - -1, 299, -1, 301, 302, 303, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 315, -1, 317, - 318, -1, 320, -1, -1, 323, -1, 325, -1, 327, - 328, 329, 330, -1, 332, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 342, -1, 344, 345, 346, -1, - 348, 349, 350, 351, 352, 353, 354, -1, -1, -1, - 358, -1, 360, -1, -1, -1, -1, 365, -1, 367, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 263, - 264, -1, 266, -1, -1, 269, 270, -1, -1, 407, - 274, 409, -1, 411, 278, 413, -1, 415, -1, 417, - 284, 419, -1, 287, -1, -1, -1, -1, -1, -1, - 294, -1, -1, -1, -1, 299, -1, 301, 302, 303, - -1, 305, -1, -1, -1, -1, -1, -1, 312, -1, - -1, 315, -1, 317, 318, -1, 320, -1, -1, 323, - -1, 325, -1, 327, 328, 329, 330, -1, 332, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 345, -1, -1, -1, -1, -1, 351, 352, 353, - 354, -1, -1, -1, 358, -1, 360, -1, -1, -1, - -1, 365, -1, 367, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 263, 264, -1, 266, -1, -1, 269, - 270, -1, -1, 407, 274, 409, -1, 411, 278, 413, - -1, 415, -1, 417, 284, 419, -1, 287, -1, -1, - -1, -1, -1, -1, 294, -1, -1, -1, -1, 299, - -1, 301, 302, 303, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 315, -1, 317, 318, -1, - 320, -1, -1, 323, -1, 325, -1, 327, 328, 329, - 330, -1, 332, -1, -1, -1, -1, -1, -1, -1, - -1, 341, 342, -1, -1, 345, -1, -1, -1, -1, - -1, 351, 352, 353, 354, -1, -1, -1, 358, -1, - 360, -1, -1, -1, -1, 365, -1, 367, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 263, 264, -1, - 266, -1, -1, 269, 270, -1, -1, 407, 274, 409, - -1, 411, 278, 413, -1, 415, -1, 417, 284, 419, - -1, 287, -1, -1, -1, -1, -1, -1, 294, -1, - -1, -1, -1, 299, -1, 301, 302, 303, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 315, - -1, 317, 318, -1, 320, -1, -1, 323, -1, 325, - -1, 327, 328, 329, 330, -1, 332, -1, -1, -1, - -1, -1, -1, -1, -1, 341, 342, -1, -1, 345, - -1, -1, -1, -1, -1, 351, 352, 353, 354, -1, - -1, -1, 358, -1, 360, -1, -1, -1, -1, 365, - -1, 367, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 263, 264, -1, 266, -1, -1, 269, 270, -1, - -1, 407, 274, 409, -1, 411, 278, 413, -1, 415, - -1, 417, 284, 419, -1, 287, -1, -1, -1, -1, - -1, -1, 294, -1, -1, -1, -1, 299, -1, 301, - 302, 303, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 315, -1, 317, 318, -1, 320, -1, - -1, 323, -1, 325, -1, 327, 328, 329, 330, -1, - 332, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 345, -1, -1, 348, -1, 350, 351, - 352, 353, 354, -1, -1, -1, 358, -1, 360, -1, - -1, -1, -1, 365, -1, 367, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 263, 264, -1, 266, -1, - -1, 269, 270, -1, -1, 407, 274, 409, -1, 411, - 278, 413, -1, 415, -1, 417, 284, 419, -1, 287, - -1, -1, -1, -1, -1, -1, 294, -1, -1, -1, - -1, 299, -1, 301, 302, 303, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 315, -1, 317, - 318, -1, 320, -1, -1, 323, -1, 325, -1, 327, - 328, 329, 330, -1, 332, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 345, -1, -1, - 348, -1, -1, 351, 352, 353, 354, -1, -1, -1, - 358, -1, 360, -1, -1, -1, -1, 365, -1, 367, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 263, - 264, -1, 266, -1, -1, 269, 270, -1, -1, 407, - 274, 409, -1, 411, 278, 413, -1, 415, -1, 417, - 284, 419, -1, 287, -1, -1, -1, -1, -1, -1, - 294, -1, -1, -1, -1, 299, -1, 301, 302, 303, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 315, -1, 317, 318, -1, 320, -1, -1, 323, - -1, 325, -1, 327, 328, 329, 330, -1, 332, -1, - -1, -1, -1, -1, -1, -1, -1, 341, -1, -1, - -1, 345, -1, -1, -1, -1, -1, 351, 352, 353, - 354, -1, -1, -1, 358, -1, 360, -1, -1, -1, - -1, 365, -1, 367, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 263, 264, -1, 266, -1, -1, 269, - 270, -1, -1, 407, 274, 409, -1, 411, 278, 413, - -1, 415, -1, 417, 284, 419, -1, 287, -1, -1, - -1, -1, -1, -1, 294, -1, -1, -1, -1, 299, - -1, 301, 302, 303, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 315, -1, 317, 318, -1, - 320, -1, -1, 323, -1, 325, -1, 327, 328, 329, - 330, -1, 332, -1, -1, 335, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 345, -1, -1, -1, -1, - -1, 351, 352, 353, 354, -1, -1, -1, 358, -1, - 360, -1, -1, -1, -1, 365, -1, 367, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 263, 264, -1, - 266, -1, -1, 269, 270, -1, -1, 407, 274, 409, - -1, 411, 278, 413, -1, 415, -1, 417, 284, 419, - -1, 287, -1, -1, -1, -1, -1, -1, 294, -1, - -1, -1, -1, 299, -1, 301, 302, 303, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 315, - -1, 317, 318, -1, 320, -1, -1, 323, -1, 325, - -1, 327, 328, 329, 330, -1, 332, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 345, - -1, -1, -1, -1, 350, 351, 352, 353, 354, -1, - -1, -1, 358, -1, 360, -1, -1, -1, -1, 365, - -1, 367, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 263, 264, -1, 266, -1, -1, 269, 270, -1, - -1, 407, 274, 409, -1, 411, 278, 413, -1, 415, - -1, 417, 284, 419, -1, 287, -1, -1, -1, -1, - -1, -1, 294, -1, -1, -1, -1, 299, -1, 301, - 302, 303, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 315, -1, 317, 318, -1, 320, -1, - -1, 323, -1, 325, -1, 327, 328, 329, 330, -1, - 332, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 345, -1, -1, -1, -1, -1, 351, - 352, 353, 354, -1, -1, -1, 358, -1, 360, -1, - -1, -1, -1, 365, -1, 367, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 263, 264, -1, 266, -1, - -1, 269, 270, -1, -1, 407, 274, 409, -1, 411, - 278, 413, -1, 415, -1, 417, 284, 419, -1, 287, - -1, -1, -1, -1, -1, -1, 294, -1, -1, -1, - -1, 299, -1, 301, 302, 303, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 315, -1, 317, - 318, -1, 320, -1, -1, 323, -1, 325, -1, 327, - 328, 329, 330, -1, 332, -1, 264, 335, 266, -1, - -1, 269, -1, 271, 272, -1, 274, 345, 276, -1, - 278, -1, 280, 281, 282, -1, -1, -1, -1, 287, - -1, -1, -1, -1, 292, -1, 294, 295, -1, -1, - -1, 299, -1, -1, -1, 303, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 315, -1, 317, - -1, -1, 320, 321, -1, -1, -1, -1, -1, -1, - 328, 329, -1, -1, 332, -1, -1, 335, -1, 407, - -1, 409, -1, 411, -1, 413, -1, 415, 264, 417, - 266, 419, -1, 269, -1, 271, 272, -1, 274, -1, - 276, -1, 278, -1, 280, 281, 282, -1, -1, -1, - -1, 287, -1, -1, -1, -1, 292, -1, 294, 295, - -1, -1, -1, 299, -1, -1, -1, 303, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 315, - -1, 317, -1, -1, 320, 321, -1, -1, -1, -1, - -1, -1, 328, 329, -1, 264, 332, 266, -1, 335, - 269, 419, 271, 272, -1, 274, -1, 276, -1, 278, - -1, 280, 281, 282, -1, -1, -1, -1, 287, -1, - -1, -1, -1, 292, -1, 294, 295, -1, -1, -1, - 299, -1, -1, -1, 303, -1, -1, -1, -1, 264, - -1, 266, -1, -1, 269, -1, 315, -1, 317, 274, - -1, 320, 321, 278, -1, -1, 281, -1, -1, 328, - 329, -1, 287, 332, -1, -1, 335, -1, -1, 294, - -1, -1, -1, -1, 299, -1, 301, -1, 303, -1, - -1, -1, -1, 419, -1, -1, -1, -1, -1, -1, - 315, 264, 317, 266, -1, 320, 269, -1, -1, -1, - -1, 274, -1, 328, 329, 278, -1, 332, 281, -1, - 335, -1, -1, -1, 287, -1, -1, 342, -1, -1, - -1, 294, 264, -1, 266, -1, 299, 269, 301, -1, - 303, -1, 274, -1, -1, -1, 278, -1, -1, -1, - -1, -1, 315, -1, 317, 287, -1, 320, -1, -1, - 419, -1, 294, -1, -1, 328, 329, 299, -1, 332, - -1, 303, 335, 305, -1, 307, 264, -1, 266, 342, - 312, 269, -1, 315, -1, 317, 274, -1, 320, -1, - 278, -1, -1, -1, -1, -1, 328, 329, -1, 287, - 332, -1, -1, -1, 419, -1, 294, -1, 264, -1, - 266, 299, -1, 269, 346, 303, -1, 305, 274, 307, - -1, -1, 278, -1, 312, 281, -1, 315, -1, 317, - -1, 287, 320, -1, -1, -1, -1, -1, 294, -1, - 328, 329, -1, 299, 332, -1, -1, 303, -1, -1, - -1, -1, -1, -1, -1, 264, 419, 266, -1, 315, - 269, 317, -1, -1, 320, 274, -1, -1, -1, 278, - -1, -1, 328, 329, -1, -1, 332, -1, 287, 335, - -1, -1, -1, -1, -1, 294, -1, 419, -1, -1, - 299, 264, -1, 266, 303, -1, 269, -1, -1, -1, - -1, 274, -1, -1, -1, 278, 315, -1, 317, -1, - -1, 320, -1, -1, 287, -1, -1, -1, -1, 328, - 329, 294, -1, 332, -1, -1, 299, -1, -1, -1, - 303, 419, 341, -1, -1, -1, -1, -1, -1, -1, - 349, -1, 315, 264, 317, 266, -1, 320, 269, -1, - -1, -1, -1, 274, -1, 328, 329, 278, -1, 332, - 281, 261, -1, 419, -1, 264, 287, 266, 341, -1, - 269, -1, -1, 294, -1, 274, 349, -1, 299, 278, - -1, -1, 303, -1, -1, -1, -1, -1, 287, -1, - -1, -1, -1, -1, 315, 294, 317, 297, -1, 320, - 299, -1, -1, -1, 303, -1, -1, 328, 329, -1, - 419, 332, -1, -1, 335, -1, 315, -1, 317, -1, - -1, 320, -1, -1, -1, -1, -1, -1, -1, 328, - 329, -1, -1, 332, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 343, -1, 345, 419, -1, -1, -1, - -1, -1, 352, 353, -1, 355, 356, 357, 358, 359, - 360, 361, 362, 363, 364, 365, -1, 367, -1, 369, - -1, 371, -1, 373, -1, 375, -1, 377, -1, 379, - -1, 381, -1, 383, -1, 385, -1, 387, -1, 389, - -1, 391, -1, 393, -1, 395, -1, 397, 419, 399, - -1, 401, 257, 403, -1, 260, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 271, -1, -1, -1, - 419, 276, -1, -1, -1, 280, -1, -1, 283, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 295, 296, -1, -1, -1, 300, 301, -1, -1, -1, - -1, 306, -1, 308, 309, 310, 311, 257, -1, -1, - 260, 316, -1, -1, 319, -1, 321, -1, -1, -1, - -1, 271, -1, -1, -1, -1, 276, -1, -1, 334, - 280, -1, -1, 283, -1, -1, -1, 342, 343, -1, - -1, -1, -1, -1, -1, 295, 296, -1, -1, -1, - 300, 301, -1, -1, -1, -1, 306, -1, 308, 309, - 310, 311, 257, -1, -1, 260, 316, -1, -1, 319, - -1, 321, -1, -1, -1, -1, 271, -1, -1, -1, - -1, 276, -1, -1, 334, 280, -1, -1, 283, -1, - -1, -1, 342, 343, -1, -1, -1, -1, -1, -1, - 295, 296, -1, -1, -1, 300, 301, -1, -1, -1, - -1, 306, -1, 308, 309, 310, 311, 257, -1, -1, - 260, 316, -1, -1, 319, -1, 321, -1, -1, -1, - -1, 271, -1, -1, -1, -1, 276, -1, -1, 334, - 280, -1, 260, 283, -1, -1, -1, -1, 343, -1, - -1, -1, -1, 271, -1, 295, 296, -1, 276, -1, - -1, 301, 280, -1, -1, 283, 306, -1, 308, 309, - 310, 311, -1, -1, -1, -1, 316, 295, 296, 319, - -1, 321, 300, 301, -1, -1, -1, -1, 306, -1, - 308, 309, 310, 311, 334, 260, -1, -1, 316, -1, - -1, 319, 342, 321, -1, -1, 271, -1, -1, 257, - -1, 276, 260, -1, -1, 280, 334, -1, 283, -1, - -1, -1, -1, 271, 342, 343, -1, -1, 276, -1, - 295, 296, 280, -1, -1, 283, 301, -1, -1, -1, - -1, 306, -1, 308, 309, 310, 311, 295, 296, -1, - -1, 316, 300, 301, 319, -1, 321, -1, 306, -1, - 308, 309, 310, 311, 257, -1, -1, 260, 316, 334, - -1, 319, -1, 321, -1, -1, -1, 342, 271, -1, - -1, -1, -1, 276, -1, -1, 334, 280, -1, -1, - 283, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 295, 296, -1, -1, -1, 343, 301, 345, - 346, 347, 348, 306, 350, 308, 309, 310, 311, 355, - -1, -1, -1, 316, -1, -1, 319, -1, 321, 365, - 343, 367, 345, 346, 347, 348, -1, 350, -1, -1, - -1, 334, 355, -1, -1, -1, -1, -1, -1, 385, - -1, 387, 365, 389, 367, 391, -1, 393, -1, 395, - -1, 397, -1, 399, -1, 401, -1, 403, -1, -1, - -1, -1, 385, -1, 387, -1, 389, -1, 391, -1, - 393, -1, 395, 419, 397, -1, 399, -1, 401, 343, - 403, 345, 346, 347, 348, -1, 350, -1, -1, -1, - 343, 355, 345, 346, 347, 348, 419, 350, -1, -1, - -1, 365, 355, 367, -1, -1, -1, -1, -1, -1, - -1, -1, 365, -1, 367, -1, -1, -1, -1, -1, - -1, 385, -1, 387, -1, 389, -1, 391, -1, 393, - -1, 395, 385, 397, 387, 399, 389, 401, 391, 403, - 393, 343, 395, 345, 397, 347, 399, -1, 401, -1, - 403, -1, -1, 355, -1, 419, -1, -1, -1, -1, - -1, -1, -1, 365, -1, 367, 419, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 385, -1, 387, -1, 389, -1, 391, - -1, 393, -1, 395, -1, 397, -1, 399, -1, 401, - -1, 403, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 419, - }; - -#line 2535 "cs-parser.jay" -
-
-// <summary>
-// A class used to pass around variable declarations and constants
-// </summary>
-public class VariableDeclaration {
- public string identifier;
- public object expression_or_array_initializer;
-
- public VariableDeclaration (string id, object eoai){
- this.identifier = id;
- this.expression_or_array_initializer = eoai;
- }
-}
-
-// <summary>
-// Given the @class_name name, it creates a fully qualified name
-// based on the containing declaration space
-// </summary>
-string
-MakeName (string class_name)
-{
- string ns = current_namespace.Name;
- string container_name = current_container.Name;
-
- if (container_name == ""){
- if (ns != "")
- return ns + "." + class_name;
- else
- return class_name;
- } else
- return container_name + "." + class_name;
-}
-
-// <summary>
-// Used to report back to the user the result of a declaration
-// in the current declaration space
-// </summary>
-void
-CheckDef (DeclSpace.AdditionResult result, string name)
-{
- if (result == DeclSpace.AdditionResult.Success)
- return;
-
- switch (result){
- case DeclSpace.AdditionResult.NameExists:
- error (102, "The namespace `" + current_container.Name +
- "' already contains a definition for `"+
- name + "'");
- break;
-
-/*
- NEED TO HANDLE THIS IN SEMANTIC ANALYSIS:
-
- case DeclSpace.AdditionResult.MethodDuplicated:
- error (111, "Class `"+current_container.Name+
- "' already defines a member called '" +
- name + "' with the same parameter types");
- break;
-*/
- case DeclSpace.AdditionResult.EnclosingClash:
- error (542, "Member names cannot be the same as their enclosing type");
- break;
-
- case DeclSpace.AdditionResult.NotAConstructor:
- error (1520, "Class, struct, or interface method must have a return type");
- break;
- }
-}
-
-void
-CheckDef (bool result, string name)
-{
- if (result)
- return;
- CheckDef (DeclSpace.AdditionResult.NameExists, name);
-}
-
-Block declare_local_variables (TypeRef typeref, ArrayList variable_declarators)
-{
- Block implicit_block;
- ArrayList inits = null;
-
- //
- // We use the `Used' property to check whether statements
- // have been added to the current block. If so, we need
- // to create another block to contain the new declaration
- // otherwise, as an optimization, we use the same block to
- // add the declaration.
- //
- // FIXME: A further optimization is to check if the statements
- // that were added were added as part of the initialization
- // below. In which case, no other statements have been executed
- // and we might be able to reduce the number of blocks for
- // situations like this:
- //
- // int j = 1; int k = j + 1;
- //
- if (current_block.Used)
- implicit_block = new Block (current_block, true);
- else
- implicit_block = new Block (current_block, true);
-
- foreach (VariableDeclaration decl in variable_declarators){
- if (implicit_block.AddVariable (typeref, decl.identifier)){
- if (decl.expression_or_array_initializer != null){
- if (inits == null)
- inits = new ArrayList ();
- inits.Add (decl);
- }
- } else {
- error (128, "A local variable `" + decl.identifier +
- "' is already defined in this scope");
- }
- }
-
- if (inits == null)
- return implicit_block;
-
- foreach (VariableDeclaration decl in inits){
- if (decl.expression_or_array_initializer is Expression){
- Expression expr = (Expression) decl.expression_or_array_initializer;
- Assign assign;
-
- assign = new Assign (new LocalVariableReference (implicit_block, decl.identifier), expr);
- implicit_block.AddStatement (new StatementExpression (assign));
- } else {
- }
- }
-
- return implicit_block;
-}
-
-void CheckConstant (Expression expr)
-{
- // finishme
-}
-
-void CheckBoolean (Expression expr)
-{
- // finishme
-}
-
-static public void error (int code, string desc)
-{
- Console.WriteLine ("Error CS"+code+": "+desc);
- global_errors++;
-}
-
-void output (string s)
-{
- Console.WriteLine (s);
-}
-
-void note (string s)
-{
- // Used to put annotations
-}
-
-TypeRef type (string type_name)
-{
- return type_references.GetTypeRef (current_container, type_name);
-}
-
-Tokenizer lexer;
-
-public CSharpParser(CIR.Tree tree, string name, System.IO.Stream input)
- : base (tree, name, input)
-{
- current_namespace = new Namespace (null, "");
- current_container = tree.Types;
- current_container.Namespace = current_namespace;
-
- lexer = new Tokenizer (input, name);
- type_references = new TypeRefManager ();
-}
-
-public override int parse ()
-{
- StringBuilder value = new StringBuilder ();
-
- global_errors = 0;
- try {
- if (yacc_verbose_flag)
- yyparse (lexer, new yydebug.yyDebugSimple ());
- else
- yyparse (lexer);
- } catch (Exception e){
- Console.WriteLine ("Fatal error: "+name);
- Console.WriteLine (e);
- Console.WriteLine (lexer.location);
- global_errors++;
- }
-
- return global_errors;
-}
-
-bool yacc_verbose_flag = false;
-
-public bool yacc_verbose {
- set {
- yacc_verbose_flag = value;
- }
-
- get {
- return yacc_verbose_flag;
- }
-}
-
-/* end end end */
-}
-}
-
-#line 5289 "-" -namespace yydebug { - using System; - public interface yyDebug { - void push (int state, Object value); - void lex (int state, int token, string name, Object value); - void shift (int from, int to, int errorFlag); - void pop (int state); - void discard (int state, int token, string name, Object value); - void reduce (int from, int to, int rule, string text, int len); - void shift (int from, int to); - void accept (Object value); - void error (string message); - void reject (); - } - - class yyDebugSimple : yyDebug { - void println (string s){ - Console.WriteLine (s); - } - - public void push (int state, Object value) { - println ("push\tstate "+state+"\tvalue "+value); - } - - public void lex (int state, int token, string name, Object value) { - println("lex\tstate "+state+"\treading "+name+"\tvalue "+value); - } - - public void shift (int from, int to, int errorFlag) { - switch (errorFlag) { - default: // normally - println("shift\tfrom state "+from+" to "+to); - break; - case 0: case 1: case 2: // in error recovery - println("shift\tfrom state "+from+" to "+to - +"\t"+errorFlag+" left to recover"); - break; - case 3: // normally - println("shift\tfrom state "+from+" to "+to+"\ton error"); - break; - } - } - - public void pop (int state) { - println("pop\tstate "+state+"\ton error"); - } - - public void discard (int state, int token, string name, Object value) { - println("discard\tstate "+state+"\ttoken "+name+"\tvalue "+value); - } - - public void reduce (int from, int to, int rule, string text, int len) { - println("reduce\tstate "+from+"\tuncover "+to - +"\trule ("+rule+") "+text); - } - - public void shift (int from, int to) { - println("goto\tfrom state "+from+" to "+to); - } - - public void accept (Object value) { - println("accept\tvalue "+value); - } - - public void error (string message) { - println("error\t"+message); - } - - public void reject () { - println("reject"); - } - - } -} -// %token constants - class Token { - public const int EOF = 257; - public const int NONE = 258; - public const int ERROR = 259; - public const int ABSTRACT = 260; - public const int AS = 261; - public const int ADD = 262; - public const int BASE = 263; - public const int BOOL = 264; - public const int BREAK = 265; - public const int BYTE = 266; - public const int CASE = 267; - public const int CATCH = 268; - public const int CHAR = 269; - public const int CHECKED = 270; - public const int CLASS = 271; - public const int CONST = 272; - public const int CONTINUE = 273; - public const int DECIMAL = 274; - public const int DEFAULT = 275; - public const int DELEGATE = 276; - public const int DO = 277; - public const int DOUBLE = 278; - public const int ELSE = 279; - public const int ENUM = 280; - public const int EVENT = 281; - public const int EXPLICIT = 282; - public const int EXTERN = 283; - public const int FALSE = 284; - public const int FINALLY = 285; - public const int FIXED = 286; - public const int FLOAT = 287; - public const int FOR = 288; - public const int FOREACH = 289; - public const int GOTO = 290; - public const int IF = 291; - public const int IMPLICIT = 292; - public const int IN = 293; - public const int INT = 294; - public const int INTERFACE = 295; - public const int INTERNAL = 296; - public const int IS = 297; - public const int LOCK = 298; - public const int LONG = 299; - public const int NAMESPACE = 300; - public const int NEW = 301; - public const int NULL = 302; - public const int OBJECT = 303; - public const int OPERATOR = 304; - public const int OUT = 305; - public const int OVERRIDE = 306; - public const int PARAMS = 307; - public const int PRIVATE = 308; - public const int PROTECTED = 309; - public const int PUBLIC = 310; - public const int READONLY = 311; - public const int REF = 312; - public const int RETURN = 313; - public const int REMOVE = 314; - public const int SBYTE = 315; - public const int SEALED = 316; - public const int SHORT = 317; - public const int SIZEOF = 318; - public const int STATIC = 319; - public const int STRING = 320; - public const int STRUCT = 321; - public const int SWITCH = 322; - public const int THIS = 323; - public const int THROW = 324; - public const int TRUE = 325; - public const int TRY = 326; - public const int TYPEOF = 327; - public const int UINT = 328; - public const int ULONG = 329; - public const int UNCHECKED = 330; - public const int UNSAFE = 331; - public const int USHORT = 332; - public const int USING = 333; - public const int VIRTUAL = 334; - public const int VOID = 335; - public const int WHILE = 336; - public const int GET = 337; - public const int get = 338; - public const int SET = 339; - public const int set = 340; - public const int OPEN_BRACE = 341; - public const int CLOSE_BRACE = 342; - public const int OPEN_BRACKET = 343; - public const int CLOSE_BRACKET = 344; - public const int OPEN_PARENS = 345; - public const int CLOSE_PARENS = 346; - public const int DOT = 347; - public const int COMMA = 348; - public const int COLON = 349; - public const int SEMICOLON = 350; - public const int TILDE = 351; - public const int PLUS = 352; - public const int MINUS = 353; - public const int BANG = 354; - public const int ASSIGN = 355; - public const int OP_LT = 356; - public const int OP_GT = 357; - public const int BITWISE_AND = 358; - public const int BITWISE_OR = 359; - public const int STAR = 360; - public const int PERCENT = 361; - public const int DIV = 362; - public const int CARRET = 363; - public const int INTERR = 364; - public const int OP_INC = 365; - public const int OP_DEC = 367; - public const int OP_SHIFT_LEFT = 369; - public const int OP_SHIFT_RIGHT = 371; - public const int OP_LE = 373; - public const int OP_GE = 375; - public const int OP_EQ = 377; - public const int OP_NE = 379; - public const int OP_AND = 381; - public const int OP_OR = 383; - public const int OP_MULT_ASSIGN = 385; - public const int OP_DIV_ASSIGN = 387; - public const int OP_MOD_ASSIGN = 389; - public const int OP_ADD_ASSIGN = 391; - public const int OP_SUB_ASSIGN = 393; - public const int OP_SHIFT_LEFT_ASSIGN = 395; - public const int OP_SHIFT_RIGHT_ASSIGN = 397; - public const int OP_AND_ASSIGN = 399; - public const int OP_XOR_ASSIGN = 401; - public const int OP_OR_ASSIGN = 403; - public const int OP_PTR = 405; - public const int LITERAL_INTEGER = 407; - public const int LITERAL_FLOAT = 409; - public const int LITERAL_DOUBLE = 411; - public const int LITERAL_DECIMAL = 413; - public const int LITERAL_CHARACTER = 415; - public const int LITERAL_STRING = 417; - public const int IDENTIFIER = 419; - public const int yyErrorCode = 256; - } - namespace yyParser { - using System; - /** thrown for irrecoverable syntax errors and stack overflow. - */ - public class yyException : System.Exception { - public yyException (string message) : base (message) { - } - } - - /** must be implemented by a scanner object to supply input to the parser. - */ - public interface yyInput { - /** move on to next token. - @return false if positioned beyond tokens. - @throws IOException on input error. - */ - bool advance (); // throws java.io.IOException; - /** classifies current token. - Should not be called if advance() returned false. - @return current %token or single character. - */ - int token (); - /** associated with current token. - Should not be called if advance() returned false. - @return value for token(). - */ - Object value (); - } - } diff --git a/mcs/mcs/cs-parser.jay b/mcs/mcs/cs-parser.jay index 3b792896953..9a87c6b38ec 100755 --- a/mcs/mcs/cs-parser.jay +++ b/mcs/mcs/cs-parser.jay @@ -30,14 +30,13 @@ using System; namespace CSC
{
using System.Collections;
- using Compiler;
using CSC;
using CIR;
/// <summary>
/// The C# Parser
/// </summary>
- public class CSharpParser : Parser {
+ public class CSharpParser {
static int global_errors;
Namespace current_namespace;
@@ -79,6 +78,13 @@ namespace CSC // Used to record all types defined
// </summary>
CIR.Tree tree;
+
+ // Name of the file we are parsing
+ public string name;
+
+ // Input stream to parse from.
+ public System.IO.Stream input;
+
%}
%token EOF
@@ -369,16 +375,7 @@ type_declaration //
opt_attributes
: /* empty */
- | attributes
- ;
-
-attributes
- : attribute_sections
- ;
-
-attribute_sections
- : attribute_section
- | attribute_sections attribute_section
+ | attribute_section opt_attributes
;
attribute_section
@@ -480,7 +477,7 @@ struct_declaration new_struct = new Struct (current_container, full_struct_name, (int) $2);
current_container = new_struct;
current_container.Namespace = current_namespace;
- tree.RecordType (full_class_name, new_struct);
+ tree.RecordType (full_struct_name, new_struct);
}
opt_struct_interfaces
struct_body
@@ -832,7 +829,7 @@ interface_declaration if (current_interface != null)
error (-2, "Internal compiler error: interface inside interface");
current_interface = new_interface;
- tree.RecordType (full_class_name, new_interface);
+ tree.RecordType (full_interface_name, new_interface);
}
opt_interface_base
interface_body
@@ -1522,7 +1519,7 @@ opt_rank_specifier rank_specifiers
: rank_specifier
- | rank_specifiers rank_specifier
+ | rank_specifier rank_specifiers
// finishme
;
@@ -2707,18 +2704,19 @@ TypeRef type (string type_name) Tokenizer lexer;
public CSharpParser(CIR.Tree tree, string name, System.IO.Stream input)
- : base (tree, name, input)
{
current_namespace = new Namespace (null, "");
this.tree = tree;
+ this.name = name;
+ this.input = input;
current_container = tree.Types;
current_container.Namespace = current_namespace;
lexer = new Tokenizer (input, name);
- type_references = tree.TypeRefManager;
+ type_references = new TypeRefManager ();
}
-public override int parse ()
+public int parse ()
{
StringBuilder value = new StringBuilder ();
diff --git a/mcs/mcs/cs-tokenizer.cs b/mcs/mcs/cs-tokenizer.cs index 5cb184e93f7..1d4b500dee8 100755 --- a/mcs/mcs/cs-tokenizer.cs +++ b/mcs/mcs/cs-tokenizer.cs @@ -260,12 +260,12 @@ namespace CSC bool is_identifier_start_character (char c)
{
- return CharacterInfo.IsLetter (c) || c == '_' ;
+ return Char.IsLetter (c) || c == '_' ;
}
bool is_identifier_part_character (char c)
{
- return (CharacterInfo.IsLetter (c) || CharacterInfo.IsDigit (c) || c == '_');
+ return (Char.IsLetter (c) || Char.IsDigit (c) || c == '_');
}
int is_punct (char c, ref bool doread)
@@ -441,7 +441,7 @@ namespace CSC number.Append ((char) c);
while ((d = peekChar ()) != -1){
- if (CharacterInfo.IsDigit ((char)d)){
+ if (Char.IsDigit ((char)d)){
number.Append ((char) d);
getChar ();
seen_digits = true;
@@ -460,7 +460,7 @@ namespace CSC while ((d = peekChar ()) != -1){
char e = Char.ToUpper ((char) d);
- if (CharacterInfo.IsDigit (e) ||
+ if (Char.IsDigit (e) ||
(e >= 'A' && e <= 'F')){
number.Append ((char) e);
getChar ();
@@ -547,8 +547,8 @@ namespace CSC number.Length = 0;
- if (CharacterInfo.IsDigit ((char)c)){
- if (peekChar () == 'x' || peekChar () == 'X'){
+ if (Char.IsDigit ((char)c)){
+ if (c == '0' && peekChar () == 'x' || peekChar () == 'X'){
getChar ();
hex_digits (-1);
val = new System.Int32 ();
@@ -700,7 +700,7 @@ namespace CSC public int xtoken ()
{
int t;
- bool allow_keyword = false;
+ bool allow_keyword_as_ident = false;
bool doread = false;
int c;
@@ -722,34 +722,24 @@ namespace CSC }
ids = id.ToString ();
-
- if (!is_keyword (ids)){
- val = id.ToString ();
- return Token.IDENTIFIER;
- }
-
- if (allow_keyword) {
+
+ if (!is_keyword (ids) || allow_keyword_as_ident) {
val = ids;
return Token.IDENTIFIER;
}
- if (ids == "true")
- return Token.TRUE;
- else if (ids == "false")
- return Token.FALSE;
- else if (ids == "null")
- return Token.NULL;
-
+ // true, false and null are in the hash anyway.
return getKeyword (ids);
+
}
if (c == '.'){
- if (CharacterInfo.IsDigit ((char) peekChar ()))
+ if (Char.IsDigit ((char) peekChar ()))
return is_number (c);
return Token.DOT;
}
- if (CharacterInfo.IsDigit ((char) c))
+ if (Char.IsDigit ((char) c))
return is_number (c);
// Handle double-slash comments.
@@ -874,7 +864,7 @@ namespace CSC }
if (c == '@'){
- allow_keyword = true;
+ allow_keyword_as_ident = true;
continue;
}
diff --git a/mcs/mcs/driver.cs b/mcs/mcs/driver.cs index f4b36acfc59..c796d8b552e 100755 --- a/mcs/mcs/driver.cs +++ b/mcs/mcs/driver.cs @@ -107,16 +107,24 @@ namespace CSC Assembly a;
foreach (string dir in link_paths){
- string full_path = dir + "\\" + assembly;
+ string full_path = dir + "/" + assembly;
try {
- a = Assembly.Load (full_path);
- } catch (FileNotFoundException) {
+ a = Assembly.Load (assembly);
+ } catch (FileNotFoundException f) {
error ("// File not found: " + full_path);
+ error ("Log: " + f.FusionLog);
return 1;
} catch (BadImageFormatException) {
error ("// Bad file format: " + full_path);
return 1;
+ } catch (FileLoadException f){
+ error ("// File Load Exception: " + full_path);
+ error ("Log: " + f.FusionLog);
+ return 1;
+ } catch (ArgumentNullException){
+ error ("// Argument Null exception " + full_path);
+ return 1;
}
context.AddAssembly (a);
@@ -149,8 +157,8 @@ namespace CSC //
// Setup defaults
//
- references.Add ("mscorlib.dll");
- link_paths.Add ("C://WINNT/Microsoft.Net/Framework/v1.0.2204");
+ references.Add ("mscorlib");
+ link_paths.Add ("file:///C:/WINNT/Microsoft.NET/Framework/v1.0.2914");
for (i = 0; i < args.Length; i++){
string arg = args [i];
diff --git a/mcs/mcs/makefile b/mcs/mcs/makefile index 56a8664f1e0..2d3fea9f581 100755 --- a/mcs/mcs/makefile +++ b/mcs/mcs/makefile @@ -1,6 +1,9 @@ +CSC=//c/winnt/microsoft.net/framework/v1.0.2914/csc.exe +CSCFLAGS=/nologo /debug+ /debug:full + VERSION=0.13 -COMMON_SOURCES = cs-parser.cs cs-tokenizer.cs parser.cs errors.cs tree.cs +COMMON_SOURCES = cs-parser.cs cs-tokenizer.cs errors.cs tree.cs COMPILER_SOURCES = \ assign.cs \ @@ -25,27 +28,26 @@ COMPILER_SOURCES = \ TEST_TOKENIZER_SOURCES = test-token.cs $(COMMON_SOURCES) -all: - -rm compiler.exe - csc /target:exe /r:System.dll /debug+ /debug:full /out:compiler.exe $(COMPILER_SOURCES) +all: cs-parser.cs + $(CSC) $(CSCFLAGS) /target:exe /r:System.dll /out:compiler.exe $(COMPILER_SOURCES) + +windows: all + +unix: all opt: - -rm compiler.exe - csc /optimize+ /target:exe /r:System.dll /debug+ /debug:full /out:compiler.exe $(COMPILER_SOURCES) + $(CSC) /optimize+ /target:exe /r:System.dll /out:compiler.exe $(COMPILER_SOURCES) old: test-tokenizer.exe test-tokenizer.exe: $(TEST_TOKENIZER_SOURCES) - csc /target:exe /out:test-tokenizer.exe $(TEST_TOKENIZER_SOURCES) + $(CSC) /target:exe /out:test-tokenizer.exe $(TEST_TOKENIZER_SOURCES) bison: perl -pe 's/\015//' < cs-parser.jay > x.y bison --debug --verbose x.y -parser: - jay -tv cs-parser.jay > cs-parser.cs - -parsernoline: - jay -tv cs-parser.jay | grep -v '^#line' > cs-parser.cs +cs-parser.cs: cs-parser.jay + ../jay/jay -ctv < ../jay/skeleton.cs cs-parser.jay > cs-parser.cs syncunix: rsync -v -a /quack/Barra ~/Barra @@ -81,3 +83,6 @@ try: for i in $(COMPILER_SOURCES); do \ ./compiler -t tree $$i > try-dir/$$i; \ done + +clean: + rm -f compiler.exe cs-parser.cs y.output compiler.pdb *~ .*~ diff --git a/mcs/mcs/parameterCollection.cs b/mcs/mcs/parameterCollection.cs index 77d895c3b4b..86a7c0ce1ae 100755 --- a/mcs/mcs/parameterCollection.cs +++ b/mcs/mcs/parameterCollection.cs @@ -156,5 +156,11 @@ namespace CIR { return parameters.IsSynchronized; } } + + public bool IsFixedSize { + get { + return false; + } + } } } diff --git a/mcs/mcs/parser.cs b/mcs/mcs/parser.cs index 08cca9bb487..7c12cf96c7b 100755 --- a/mcs/mcs/parser.cs +++ b/mcs/mcs/parser.cs @@ -5,7 +5,6 @@ namespace Compiler { abstract public class Parser {
public string name;
public System.IO.Stream input;
- public CIR.Tree tree;
public Parser (CIR.Tree tree, string name, System.IO.Stream stream)
{
diff --git a/mcs/mcs/statementCollection.cs b/mcs/mcs/statementCollection.cs index 475b17b1279..9d235ce6c78 100755 --- a/mcs/mcs/statementCollection.cs +++ b/mcs/mcs/statementCollection.cs @@ -156,5 +156,11 @@ namespace CIR { return statements.IsSynchronized; } } + + public bool IsFixedSize { + get { + return false; + } + } } } diff --git a/mono/.cvsignore b/mono/.cvsignore new file mode 100644 index 00000000000..282522db034 --- /dev/null +++ b/mono/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/mono/Makefile.am b/mono/Makefile.am index 89d68d86d83..dd16095408d 100644 --- a/mono/Makefile.am +++ b/mono/Makefile.am @@ -1 +1 @@ -SUBDIRS = metadata dis
\ No newline at end of file +SUBDIRS = metadata cil dis interpreter diff --git a/mono/cil/.cvsignore b/mono/cil/.cvsignore new file mode 100644 index 00000000000..10dae49ad16 --- /dev/null +++ b/mono/cil/.cvsignore @@ -0,0 +1,3 @@ +Makefile +Makefile.in +opcode.def diff --git a/mono/cil/ChangeLog b/mono/cil/ChangeLog new file mode 100644 index 00000000000..d9869c03c99 --- /dev/null +++ b/mono/cil/ChangeLog @@ -0,0 +1,19 @@ +Wed Jul 11 18:50:12 CEST 2001 Paolo Molaro <lupus@ximian.com> + + * cil-opcodes.xml: change duplicate unused entry. + +Mon Jul 2 15:31:31 CEST 2001 Paolo Molaro <lupus@ximian.com> + + * cil-opcodes.xml: use a more proper XML format (single root tag). + * make-opcodes-def.pl: use XML::Parser, remove debugging print that + broke compilation, corrected opcode byte len. + +2001-07-01 Miguel de Icaza <miguel@ximian.com> + + * cil-opcodes.xml: New file that describes the CIL opcodes in + XML format. + + * make-opcodes-def.pl: Perl script that parses the above file and + generates a Annex V/C.2 compliant opcode.def file. + + diff --git a/mono/cil/Makefile.am b/mono/cil/Makefile.am new file mode 100644 index 00000000000..4fa1bade5f6 --- /dev/null +++ b/mono/cil/Makefile.am @@ -0,0 +1,11 @@ + +opcode.def: make-opcodes-def.pl cil-opcodes.xml + perl make-opcodes-def.pl < $(srcdir)/cil-opcodes.xml > opcode.def + +defdir = $(includedir)/mono/cil +def_DATA = opcode.def + +xmldir = $(share)/mono/cil +xml_DATA = cil-opcodes.xml + +EXTRA_DIST=opcode.def make-opcodes-def.pl make-opcode-def.xsl $(xml_DATA) $(def_DATA)
\ No newline at end of file diff --git a/mono/cil/TODO b/mono/cil/TODO new file mode 100644 index 00000000000..6175693d3f6 --- /dev/null +++ b/mono/cil/TODO @@ -0,0 +1,3 @@ +* Replace make-opcodes-def.pl with XLST process + + We should use an XSLT file to do the conversion there. diff --git a/mono/cil/cil-opcodes.xml b/mono/cil/cil-opcodes.xml new file mode 100644 index 00000000000..dfd5fb106cb --- /dev/null +++ b/mono/cil/cil-opcodes.xml @@ -0,0 +1,297 @@ +<opdesc>
+<opcode name="nop" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0x00" flow="next"/>
+<opcode name="break" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0x01" flow="break"/>
+<opcode name="ldarg.0" input="Pop0" output="Push1" args="InlineNone" o1="0xFF" o2="0x02" flow="next"/>
+<opcode name="ldarg.1" input="Pop0" output="Push1" args="InlineNone" o1="0xFF" o2="0x03" flow="next"/>
+<opcode name="ldarg.2" input="Pop0" output="Push1" args="InlineNone" o1="0xFF" o2="0x04" flow="next"/>
+<opcode name="ldarg.3" input="Pop0" output="Push1" args="InlineNone" o1="0xFF" o2="0x05" flow="next"/>
+<opcode name="ldloc.0" input="Pop0" output="Push1" args="InlineNone" o1="0xFF" o2="0x06" flow="next"/>
+<opcode name="ldloc.1" input="Pop0" output="Push1" args="InlineNone" o1="0xFF" o2="0x07" flow="next"/>
+<opcode name="ldloc.2" input="Pop0" output="Push1" args="InlineNone" o1="0xFF" o2="0x08" flow="next"/>
+<opcode name="ldloc.3" input="Pop0" output="Push1" args="InlineNone" o1="0xFF" o2="0x09" flow="next"/>
+<opcode name="stloc.0" input="Pop1" output="Push0" args="InlineNone" o1="0xFF" o2="0x0A" flow="next"/>
+<opcode name="stloc.1" input="Pop1" output="Push0" args="InlineNone" o1="0xFF" o2="0x0B" flow="next"/>
+<opcode name="stloc.2" input="Pop1" output="Push0" args="InlineNone" o1="0xFF" o2="0x0C" flow="next"/>
+<opcode name="stloc.3" input="Pop1" output="Push0" args="InlineNone" o1="0xFF" o2="0x0D" flow="next"/>
+<opcode name="ldarg.s" input="Pop0" output="Push1" args="ShortInlineVar" o1="0xFF" o2="0x0E" flow="next"/>
+<opcode name="ldarga.s" input="Pop0" output="PushI" args="ShortInlineVar" o1="0xFF" o2="0x0F" flow="next"/>
+<opcode name="starg.s" input="Pop1" output="Push0" args="ShortInlineVar" o1="0xFF" o2="0x10" flow="next"/>
+<opcode name="ldloc.s" input="Pop0" output="Push1" args="ShortInlineVar" o1="0xFF" o2="0x11" flow="next"/>
+<opcode name="ldloca.s" input="Pop0" output="PushI" args="ShortInlineVar" o1="0xFF" o2="0x12" flow="next"/>
+<opcode name="stloc.s" input="Pop1" output="Push0" args="ShortInlineVar" o1="0xFF" o2="0x13" flow="next"/>
+<opcode name="ldnull" input="Pop0" output="PushRef" args="InlineNone" o1="0xFF" o2="0x14" flow="next"/>
+<opcode name="ldc.i4.m1" input="Pop0" output="PushI" args="InlineNone" o1="0xFF" o2="0x15" flow="next"/>
+<opcode name="ldc.i4.0" input="Pop0" output="PushI" args="InlineNone" o1="0xFF" o2="0x16" flow="next"/>
+<opcode name="ldc.i4.1" input="Pop0" output="PushI" args="InlineNone" o1="0xFF" o2="0x17" flow="next"/>
+<opcode name="ldc.i4.2" input="Pop0" output="PushI" args="InlineNone" o1="0xFF" o2="0x18" flow="next"/>
+<opcode name="ldc.i4.3" input="Pop0" output="PushI" args="InlineNone" o1="0xFF" o2="0x19" flow="next"/>
+<opcode name="ldc.i4.4" input="Pop0" output="PushI" args="InlineNone" o1="0xFF" o2="0x1A" flow="next"/>
+<opcode name="ldc.i4.5" input="Pop0" output="PushI" args="InlineNone" o1="0xFF" o2="0x1B" flow="next"/>
+<opcode name="ldc.i4.6" input="Pop0" output="PushI" args="InlineNone" o1="0xFF" o2="0x1C" flow="next"/>
+<opcode name="ldc.i4.7" input="Pop0" output="PushI" args="InlineNone" o1="0xFF" o2="0x1D" flow="next"/>
+<opcode name="ldc.i4.8" input="Pop0" output="PushI" args="InlineNone" o1="0xFF" o2="0x1E" flow="next"/>
+<opcode name="ldc.i4.s" input="Pop0" output="PushI" args="ShortInlineI" o1="0xFF" o2="0x1F" flow="next"/>
+<opcode name="ldc.i4" input="Pop0" output="PushI" args="InlineI" o1="0xFF" o2="0x20" flow="next"/>
+<opcode name="ldc.i8" input="Pop0" output="PushI8" args="InlineI8" o1="0xFF" o2="0x21" flow="next"/>
+<opcode name="ldc.r4" input="Pop0" output="PushR4" args="ShortInlineR" o1="0xFF" o2="0x22" flow="next"/>
+<opcode name="ldc.r8" input="Pop0" output="PushR8" args="InlineR" o1="0xFF" o2="0x23" flow="next"/>
+<opcode name="unused99" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0x24" flow="next"/>
+<opcode name="dup" input="Pop1" output="Push1+Push1" args="InlineNone" o1="0xFF" o2="0x25" flow="next"/>
+<opcode name="pop" input="Pop1" output="Push0" args="InlineNone" o1="0xFF" o2="0x26" flow="next"/>
+<opcode name="jmp" input="Pop0" output="Push0" args="InlineMethod" o1="0xFF" o2="0x27" flow="call"/>
+<opcode name="call" input="VarPop" output="VarPush" args="InlineMethod" o1="0xFF" o2="0x28" flow="call"/>
+<opcode name="calli" input="VarPop" output="VarPush" args="InlineSig" o1="0xFF" o2="0x29" flow="call"/>
+<opcode name="ret" input="VarPop" output="Push0" args="InlineNone" o1="0xFF" o2="0x2A" flow="return"/>
+<opcode name="br.s" input="Pop0" output="Push0" args="ShortInlineBrTarget" o1="0xFF" o2="0x2B" flow="branch"/>
+<opcode name="brfalse.s" input="PopI" output="Push0" args="ShortInlineBrTarget" o1="0xFF" o2="0x2C" flow="cond-branch"/>
+<opcode name="brtrue.s" input="PopI" output="Push0" args="ShortInlineBrTarget" o1="0xFF" o2="0x2D" flow="cond-branch"/>
+<opcode name="beq.s" input="Pop1+Pop1" output="Push0" args="ShortInlineBrTarget" o1="0xFF" o2="0x2E" flow="cond-branch"/>
+<opcode name="bge.s" input="Pop1+Pop1" output="Push0" args="ShortInlineBrTarget" o1="0xFF" o2="0x2F" flow="cond-branch"/>
+<opcode name="bgt.s" input="Pop1+Pop1" output="Push0" args="ShortInlineBrTarget" o1="0xFF" o2="0x30" flow="cond-branch"/>
+<opcode name="ble.s" input="Pop1+Pop1" output="Push0" args="ShortInlineBrTarget" o1="0xFF" o2="0x31" flow="cond-branch"/>
+<opcode name="blt.s" input="Pop1+Pop1" output="Push0" args="ShortInlineBrTarget" o1="0xFF" o2="0x32" flow="cond-branch"/>
+<opcode name="bne.un.s" input="Pop1+Pop1" output="Push0" args="ShortInlineBrTarget" o1="0xFF" o2="0x33" flow="cond-branch"/>
+<opcode name="bge.un.s" input="Pop1+Pop1" output="Push0" args="ShortInlineBrTarget" o1="0xFF" o2="0x34" flow="cond-branch"/>
+<opcode name="bgt.un.s" input="Pop1+Pop1" output="Push0" args="ShortInlineBrTarget" o1="0xFF" o2="0x35" flow="cond-branch"/>
+<opcode name="ble.un.s" input="Pop1+Pop1" output="Push0" args="ShortInlineBrTarget" o1="0xFF" o2="0x36" flow="cond-branch"/>
+<opcode name="blt.un.s" input="Pop1+Pop1" output="Push0" args="ShortInlineBrTarget" o1="0xFF" o2="0x37" flow="cond-branch"/>
+<opcode name="br" input="Pop0" output="Push0" args="InlineBrTarget" o1="0xFF" o2="0x38" flow="branch"/>
+<opcode name="brfalse" input="PopI" output="Push0" args="InlineBrTarget" o1="0xFF" o2="0x39" flow="cond-branch"/>
+<opcode name="brtrue" input="PopI" output="Push0" args="InlineBrTarget" o1="0xFF" o2="0x3A" flow="cond-branch"/>
+<opcode name="beq" input="Pop1+Pop1" output="Push0" args="InlineBrTarget" o1="0xFF" o2="0x3B" flow="cond-branch"/>
+<opcode name="bge" input="Pop1+Pop1" output="Push0" args="InlineBrTarget" o1="0xFF" o2="0x3C" flow="cond-branch"/>
+<opcode name="bgt" input="Pop1+Pop1" output="Push0" args="InlineBrTarget" o1="0xFF" o2="0x3D" flow="cond-branch"/>
+<opcode name="ble" input="Pop1+Pop1" output="Push0" args="InlineBrTarget" o1="0xFF" o2="0x3E" flow="cond-branch"/>
+<opcode name="blt" input="Pop1+Pop1" output="Push0" args="InlineBrTarget" o1="0xFF" o2="0x3F" flow="cond-branch"/>
+<opcode name="bne.un" input="Pop1+Pop1" output="Push0" args="InlineBrTarget" o1="0xFF" o2="0x40" flow="cond-branch"/>
+<opcode name="bge.un" input="Pop1+Pop1" output="Push0" args="InlineBrTarget" o1="0xFF" o2="0x41" flow="cond-branch"/>
+<opcode name="bgt.un" input="Pop1+Pop1" output="Push0" args="InlineBrTarget" o1="0xFF" o2="0x42" flow="cond-branch"/>
+<opcode name="ble.un" input="Pop1+Pop1" output="Push0" args="InlineBrTarget" o1="0xFF" o2="0x43" flow="cond-branch"/>
+<opcode name="blt.un" input="Pop1+Pop1" output="Push0" args="InlineBrTarget" o1="0xFF" o2="0x44" flow="cond-branch"/>
+<opcode name="switch" input="PopI" output="Push0" args="InlineSwitch" o1="0xFF" o2="0x45" flow="cond-branch"/>
+<opcode name="ldind.i1" input="PopI" output="PushI" args="InlineNone" o1="0xFF" o2="0x46" flow="next"/>
+<opcode name="ldind.u1" input="PopI" output="PushI" args="InlineNone" o1="0xFF" o2="0x47" flow="next"/>
+<opcode name="ldind.i2" input="PopI" output="PushI" args="InlineNone" o1="0xFF" o2="0x48" flow="next"/>
+<opcode name="ldind.u2" input="PopI" output="PushI" args="InlineNone" o1="0xFF" o2="0x49" flow="next"/>
+<opcode name="ldind.i4" input="PopI" output="PushI" args="InlineNone" o1="0xFF" o2="0x4A" flow="next"/>
+<opcode name="ldind.u4" input="PopI" output="PushI" args="InlineNone" o1="0xFF" o2="0x4B" flow="next"/>
+<opcode name="ldind.i8" input="PopI" output="PushI8" args="InlineNone" o1="0xFF" o2="0x4C" flow="next"/>
+<opcode name="ldind.i" input="PopI" output="PushI" args="InlineNone" o1="0xFF" o2="0x4D" flow="next"/>
+<opcode name="ldind.r4" input="PopI" output="PushR4" args="InlineNone" o1="0xFF" o2="0x4E" flow="next"/>
+<opcode name="ldind.r8" input="PopI" output="PushR8" args="InlineNone" o1="0xFF" o2="0x4F" flow="next"/>
+<opcode name="ldind.ref" input="PopI" output="PushRef" args="InlineNone" o1="0xFF" o2="0x50" flow="next"/>
+<opcode name="stind.ref" input="PopI+PopI" output="Push0" args="InlineNone" o1="0xFF" o2="0x51" flow="next"/>
+<opcode name="stind.i1" input="PopI+PopI" output="Push0" args="InlineNone" o1="0xFF" o2="0x52" flow="next"/>
+<opcode name="stind.i2" input="PopI+PopI" output="Push0" args="InlineNone" o1="0xFF" o2="0x53" flow="next"/>
+<opcode name="stind.i4" input="PopI+PopI" output="Push0" args="InlineNone" o1="0xFF" o2="0x54" flow="next"/>
+<opcode name="stind.i8" input="PopI+PopI8" output="Push0" args="InlineNone" o1="0xFF" o2="0x55" flow="next"/>
+<opcode name="stind.r4" input="PopI+PopR4" output="Push0" args="InlineNone" o1="0xFF" o2="0x56" flow="next"/>
+<opcode name="stind.r8" input="PopI+PopR8" output="Push0" args="InlineNone" o1="0xFF" o2="0x57" flow="next"/>
+<opcode name="add" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0x58" flow="next"/>
+<opcode name="sub" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0x59" flow="next"/>
+<opcode name="mul" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0x5A" flow="next"/>
+<opcode name="div" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0x5B" flow="next"/>
+<opcode name="div.un" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0x5C" flow="next"/>
+<opcode name="rem" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0x5D" flow="next"/>
+<opcode name="rem.un" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0x5E" flow="next"/>
+<opcode name="and" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0x5F" flow="next"/>
+<opcode name="or" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0x60" flow="next"/>
+<opcode name="xor" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0x61" flow="next"/>
+<opcode name="shl" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0x62" flow="next"/>
+<opcode name="shr" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0x63" flow="next"/>
+<opcode name="shr.un" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0x64" flow="next"/>
+<opcode name="neg" input="Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0x65" flow="next"/>
+<opcode name="not" input="Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0x66" flow="next"/>
+<opcode name="conv.i1" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0x67" flow="next"/>
+<opcode name="conv.i2" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0x68" flow="next"/>
+<opcode name="conv.i4" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0x69" flow="next"/>
+<opcode name="conv.i8" input="Pop1" output="PushI8" args="InlineNone" o1="0xFF" o2="0x6A" flow="next"/>
+<opcode name="conv.r4" input="Pop1" output="PushR4" args="InlineNone" o1="0xFF" o2="0x6B" flow="next"/>
+<opcode name="conv.r8" input="Pop1" output="PushR8" args="InlineNone" o1="0xFF" o2="0x6C" flow="next"/>
+<opcode name="conv.u4" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0x6D" flow="next"/>
+<opcode name="conv.u8" input="Pop1" output="PushI8" args="InlineNone" o1="0xFF" o2="0x6E" flow="next"/>
+<opcode name="callvirt" input="VarPop" output="VarPush" args="InlineMethod" o1="0xFF" o2="0x6F" flow="call"/>
+<opcode name="cpobj" input="PopI+PopI" output="Push0" args="InlineType" o1="0xFF" o2="0x70" flow="next"/>
+<opcode name="ldobj" input="PopI" output="Push1" args="InlineType" o1="0xFF" o2="0x71" flow="next"/>
+<opcode name="ldstr" input="Pop0" output="PushRef" args="InlineString" o1="0xFF" o2="0x72" flow="next"/>
+<opcode name="newobj" input="VarPop" output="PushRef" args="InlineMethod" o1="0xFF" o2="0x73" flow="call"/>
+<opcode name="castclass" input="PopRef" output="PushRef" args="InlineType" o1="0xFF" o2="0x74" flow="next"/>
+<opcode name="isinst" input="PopRef" output="PushI" args="InlineType" o1="0xFF" o2="0x75" flow="next"/>
+<opcode name="conv.r.un" input="Pop1" output="PushR8" args="InlineNone" o1="0xFF" o2="0x76" flow="next"/>
+<opcode name="unused58" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0x77" flow="next"/>
+<opcode name="unused1" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0x78" flow="next"/>
+<opcode name="unbox" input="PopRef" output="PushI" args="InlineType" o1="0xFF" o2="0x79" flow="next"/>
+<opcode name="throw" input="PopRef" output="Push0" args="InlineNone" o1="0xFF" o2="0x7A" flow="throw"/>
+<opcode name="ldfld" input="PopRef" output="Push1" args="InlineField" o1="0xFF" o2="0x7B" flow="next"/>
+<opcode name="ldflda" input="PopRef" output="PushI" args="InlineField" o1="0xFF" o2="0x7C" flow="next"/>
+<opcode name="stfld" input="PopRef+Pop1" output="Push0" args="InlineField" o1="0xFF" o2="0x7D" flow="next"/>
+<opcode name="ldsfld" input="Pop0" output="Push1" args="InlineField" o1="0xFF" o2="0x7E" flow="next"/>
+<opcode name="ldsflda" input="Pop0" output="PushI" args="InlineField" o1="0xFF" o2="0x7F" flow="next"/>
+<opcode name="stsfld" input="Pop1" output="Push0" args="InlineField" o1="0xFF" o2="0x80" flow="next"/>
+<opcode name="stobj" input="PopI+Pop1" output="Push0" args="InlineType" o1="0xFF" o2="0x81" flow="next"/>
+<opcode name="conv.ovf.i1.un" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0x82" flow="next"/>
+<opcode name="conv.ovf.i2.un" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0x83" flow="next"/>
+<opcode name="conv.ovf.i4.un" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0x84" flow="next"/>
+<opcode name="conv.ovf.i8.un" input="Pop1" output="PushI8" args="InlineNone" o1="0xFF" o2="0x85" flow="next"/>
+<opcode name="conv.ovf.u1.un" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0x86" flow="next"/>
+<opcode name="conv.ovf.u2.un" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0x87" flow="next"/>
+<opcode name="conv.ovf.u4.un" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0x88" flow="next"/>
+<opcode name="conv.ovf.u8.un" input="Pop1" output="PushI8" args="InlineNone" o1="0xFF" o2="0x89" flow="next"/>
+<opcode name="conv.ovf.i.un" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0x8A" flow="next"/>
+<opcode name="conv.ovf.u.un" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0x8B" flow="next"/>
+<opcode name="box" input="Pop1" output="PushRef" args="InlineType" o1="0xFF" o2="0x8C" flow="next"/>
+<opcode name="newarr" input="PopI" output="PushRef" args="InlineType" o1="0xFF" o2="0x8D" flow="next"/>
+<opcode name="ldlen" input="PopRef" output="PushI" args="InlineNone" o1="0xFF" o2="0x8E" flow="next"/>
+<opcode name="ldelema" input="PopRef+PopI" output="PushI" args="InlineType" o1="0xFF" o2="0x8F" flow="next"/>
+<opcode name="ldelem.i1" input="PopRef+PopI" output="PushI" args="InlineNone" o1="0xFF" o2="0x90" flow="next"/>
+<opcode name="ldelem.u1" input="PopRef+PopI" output="PushI" args="InlineNone" o1="0xFF" o2="0x91" flow="next"/>
+<opcode name="ldelem.i2" input="PopRef+PopI" output="PushI" args="InlineNone" o1="0xFF" o2="0x92" flow="next"/>
+<opcode name="ldelem.u2" input="PopRef+PopI" output="PushI" args="InlineNone" o1="0xFF" o2="0x93" flow="next"/>
+<opcode name="ldelem.i4" input="PopRef+PopI" output="PushI" args="InlineNone" o1="0xFF" o2="0x94" flow="next"/>
+<opcode name="ldelem.u4" input="PopRef+PopI" output="PushI" args="InlineNone" o1="0xFF" o2="0x95" flow="next"/>
+<opcode name="ldelem.i8" input="PopRef+PopI" output="PushI8" args="InlineNone" o1="0xFF" o2="0x96" flow="next"/>
+<opcode name="ldelem.i" input="PopRef+PopI" output="PushI" args="InlineNone" o1="0xFF" o2="0x97" flow="next"/>
+<opcode name="ldelem.r4" input="PopRef+PopI" output="PushR4" args="InlineNone" o1="0xFF" o2="0x98" flow="next"/>
+<opcode name="ldelem.r8" input="PopRef+PopI" output="PushR8" args="InlineNone" o1="0xFF" o2="0x99" flow="next"/>
+<opcode name="ldelem.ref" input="PopRef+PopI" output="PushRef" args="InlineNone" o1="0xFF" o2="0x9A" flow="next"/>
+<opcode name="stelem.i" input="PopRef+PopI+PopI" output="Push0" args="InlineNone" o1="0xFF" o2="0x9B" flow="next"/>
+<opcode name="stelem.i1" input="PopRef+PopI+PopI" output="Push0" args="InlineNone" o1="0xFF" o2="0x9C" flow="next"/>
+<opcode name="stelem.i2" input="PopRef+PopI+PopI" output="Push0" args="InlineNone" o1="0xFF" o2="0x9D" flow="next"/>
+<opcode name="stelem.i4" input="PopRef+PopI+PopI" output="Push0" args="InlineNone" o1="0xFF" o2="0x9E" flow="next"/>
+<opcode name="stelem.i8" input="PopRef+PopI+PopI8" output="Push0" args="InlineNone" o1="0xFF" o2="0x9F" flow="next"/>
+<opcode name="stelem.r4" input="PopRef+PopI+PopR4" output="Push0" args="InlineNone" o1="0xFF" o2="0xA0" flow="next"/>
+<opcode name="stelem.r8" input="PopRef+PopI+PopR8" output="Push0" args="InlineNone" o1="0xFF" o2="0xA1" flow="next"/>
+<opcode name="stelem.ref" input="PopRef+PopI+PopRef" output="Push0" args="InlineNone" o1="0xFF" o2="0xA2" flow="next"/>
+<opcode name="unused2" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xA3" flow="next"/>
+<opcode name="unused3" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xA4" flow="next"/>
+<opcode name="unused4" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xA5" flow="next"/>
+<opcode name="unused5" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xA6" flow="next"/>
+<opcode name="unused6" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xA7" flow="next"/>
+<opcode name="unused7" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xA8" flow="next"/>
+<opcode name="unused8" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xA9" flow="next"/>
+<opcode name="unused9" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xAA" flow="next"/>
+<opcode name="unused10" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xAB" flow="next"/>
+<opcode name="unused11" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xAC" flow="next"/>
+<opcode name="unused12" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xAD" flow="next"/>
+<opcode name="unused13" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xAE" flow="next"/>
+<opcode name="unused14" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xAF" flow="next"/>
+<opcode name="unused15" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xB0" flow="next"/>
+<opcode name="unused16" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xB1" flow="next"/>
+<opcode name="unused17" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xB2" flow="next"/>
+<opcode name="conv.ovf.i1" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0xB3" flow="next"/>
+<opcode name="conv.ovf.u1" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0xB4" flow="next"/>
+<opcode name="conv.ovf.i2" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0xB5" flow="next"/>
+<opcode name="conv.ovf.u2" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0xB6" flow="next"/>
+<opcode name="conv.ovf.i4" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0xB7" flow="next"/>
+<opcode name="conv.ovf.u4" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0xB8" flow="next"/>
+<opcode name="conv.ovf.i8" input="Pop1" output="PushI8" args="InlineNone" o1="0xFF" o2="0xB9" flow="next"/>
+<opcode name="conv.ovf.u8" input="Pop1" output="PushI8" args="InlineNone" o1="0xFF" o2="0xBA" flow="next"/>
+<opcode name="unused50" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xBB" flow="next"/>
+<opcode name="unused18" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xBC" flow="next"/>
+<opcode name="unused19" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xBD" flow="next"/>
+<opcode name="unused20" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xBE" flow="next"/>
+<opcode name="unused21" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xBF" flow="next"/>
+<opcode name="unused22" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xC0" flow="next"/>
+<opcode name="unused23" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xC1" flow="next"/>
+<opcode name="refanyval" input="Pop1" output="PushI" args="InlineType" o1="0xFF" o2="0xC2" flow="next"/>
+<opcode name="ckfinite" input="Pop1" output="PushR8" args="InlineNone" o1="0xFF" o2="0xC3" flow="next"/>
+<opcode name="unused24" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xC4" flow="next"/>
+<opcode name="unused25" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xC5" flow="next"/>
+<opcode name="mkrefany" input="PopI" output="Push1" args="InlineType" o1="0xFF" o2="0xC6" flow="next"/>
+<opcode name="unused59" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xC7" flow="next"/>
+<opcode name="unused60" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xC8" flow="next"/>
+<opcode name="unused61" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xC9" flow="next"/>
+<opcode name="unused62" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xCA" flow="next"/>
+<opcode name="unused63" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xCB" flow="next"/>
+<opcode name="unused64" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xCC" flow="next"/>
+<opcode name="unused65" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xCD" flow="next"/>
+<opcode name="unused66" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xCE" flow="next"/>
+<opcode name="unused67" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xCF" flow="next"/>
+<opcode name="ldtoken" input="Pop0" output="PushI" args="InlineTok" o1="0xFF" o2="0xD0" flow="next"/>
+<opcode name="conv.u2" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0xD1" flow="next"/>
+<opcode name="conv.u1" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0xD2" flow="next"/>
+<opcode name="conv.i" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0xD3" flow="next"/>
+<opcode name="conv.ovf.i" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0xD4" flow="next"/>
+<opcode name="conv.ovf.u" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0xD5" flow="next"/>
+<opcode name="add.ovf" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0xD6" flow="next"/>
+<opcode name="add.ovf.un" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0xD7" flow="next"/>
+<opcode name="mul.ovf" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0xD8" flow="next"/>
+<opcode name="mul.ovf.un" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0xD9" flow="next"/>
+<opcode name="sub.ovf" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0xDA" flow="next"/>
+<opcode name="sub.ovf.un" input="Pop1+Pop1" output="Push1" args="InlineNone" o1="0xFF" o2="0xDB" flow="next"/>
+<opcode name="endfinally" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xDC" flow="return"/>
+<opcode name="leave" input="Pop0" output="Push0" args="InlineBrTarget" o1="0xFF" o2="0xDD" flow="branch"/>
+<opcode name="leave.s" input="Pop0" output="Push0" args="ShortInlineBrTarget" o1="0xFF" o2="0xDE" flow="branch"/>
+<opcode name="stind.i" input="PopI+PopI" output="Push0" args="InlineNone" o1="0xFF" o2="0xDF" flow="next"/>
+<opcode name="conv.u" input="Pop1" output="PushI" args="InlineNone" o1="0xFF" o2="0xE0" flow="next"/>
+<opcode name="unused26" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xE1" flow="next"/>
+<opcode name="unused27" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xE2" flow="next"/>
+<opcode name="unused28" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xE3" flow="next"/>
+<opcode name="unused29" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xE4" flow="next"/>
+<opcode name="unused30" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xE5" flow="next"/>
+<opcode name="unused31" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xE6" flow="next"/>
+<opcode name="unused32" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xE7" flow="next"/>
+<opcode name="unused33" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xE8" flow="next"/>
+<opcode name="unused34" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xE9" flow="next"/>
+<opcode name="unused35" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xEA" flow="next"/>
+<opcode name="unused36" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xEB" flow="next"/>
+<opcode name="unused37" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xEC" flow="next"/>
+<opcode name="unused38" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xED" flow="next"/>
+<opcode name="unused39" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xEE" flow="next"/>
+<opcode name="unused40" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xEF" flow="next"/>
+<opcode name="unused41" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xF0" flow="next"/>
+<opcode name="unused42" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xF1" flow="next"/>
+<opcode name="unused43" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xF2" flow="next"/>
+<opcode name="unused44" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xF3" flow="next"/>
+<opcode name="unused45" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xF4" flow="next"/>
+<opcode name="unused46" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xF5" flow="next"/>
+<opcode name="unused47" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xF6" flow="next"/>
+<opcode name="unused48" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xF7" flow="next"/>
+<opcode name="prefix7" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xF8" flow="meta"/>
+<opcode name="prefix6" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xF9" flow="meta"/>
+<opcode name="prefix5" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xFA" flow="meta"/>
+<opcode name="prefix4" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xFB" flow="meta"/>
+<opcode name="prefix3" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xFC" flow="meta"/>
+<opcode name="prefix2" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xFD" flow="meta"/>
+<opcode name="prefix1" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xFE" flow="meta"/>
+<opcode name="prefixref" input="Pop0" output="Push0" args="InlineNone" o1="0xFF" o2="0xFF" flow="meta"/>
+<opcode name="arglist" input="Pop0" output="PushI" args="InlineNone" o1="0xFE" o2="0x00" flow="next"/>
+<opcode name="ceq" input="Pop1+Pop1" output="PushI" args="InlineNone" o1="0xFE" o2="0x01" flow="next"/>
+<opcode name="cgt" input="Pop1+Pop1" output="PushI" args="InlineNone" o1="0xFE" o2="0x02" flow="next"/>
+<opcode name="cgt.un" input="Pop1+Pop1" output="PushI" args="InlineNone" o1="0xFE" o2="0x03" flow="next"/>
+<opcode name="clt" input="Pop1+Pop1" output="PushI" args="InlineNone" o1="0xFE" o2="0x04" flow="next"/>
+<opcode name="clt.un" input="Pop1+Pop1" output="PushI" args="InlineNone" o1="0xFE" o2="0x05" flow="next"/>
+<opcode name="ldftn" input="Pop0" output="PushI" args="InlineMethod" o1="0xFE" o2="0x06" flow="next"/>
+<opcode name="ldvirtftn" input="PopRef" output="PushI" args="InlineMethod" o1="0xFE" o2="0x07" flow="next"/>
+<opcode name="unused56" input="Pop0" output="Push0" args="InlineNone" o1="0xFE" o2="0x08" flow="next"/>
+<opcode name="ldarg" input="Pop0" output="Push1" args="InlineVar" o1="0xFE" o2="0x09" flow="next"/>
+<opcode name="ldarga" input="Pop0" output="PushI" args="InlineVar" o1="0xFE" o2="0x0A" flow="next"/>
+<opcode name="starg" input="Pop1" output="Push0" args="InlineVar" o1="0xFE" o2="0x0B" flow="next"/>
+<opcode name="ldloc" input="Pop0" output="Push1" args="InlineVar" o1="0xFE" o2="0x0C" flow="next"/>
+<opcode name="ldloca" input="Pop0" output="PushI" args="InlineVar" o1="0xFE" o2="0x0D" flow="next"/>
+<opcode name="stloc" input="Pop1" output="Push0" args="InlineVar" o1="0xFE" o2="0x0E" flow="next"/>
+<opcode name="localloc" input="PopI" output="PushI" args="InlineNone" o1="0xFE" o2="0x0F" flow="next"/>
+<opcode name="unused57" input="Pop0" output="Push0" args="InlineNone" o1="0xFE" o2="0x10" flow="next"/>
+<opcode name="endfilter" input="PopI" output="Push0" args="InlineNone" o1="0xFE" o2="0x11" flow="return"/>
+<opcode name="unaligned." input="Pop0" output="Push0" args="ShortInlineI" o1="0xFE" o2="0x12" flow="meta"/>
+<opcode name="volatile." input="Pop0" output="Push0" args="InlineNone" o1="0xFE" o2="0x13" flow="meta"/>
+<opcode name="tail." input="Pop0" output="Push0" args="InlineNone" o1="0xFE" o2="0x14" flow="meta"/>
+<opcode name="initobj" input="PopI" output="Push0" args="InlineType" o1="0xFE" o2="0x15" flow="next"/>
+<opcode name="unused68" input="Pop0" output="Push0" args="InlineNone" o1="0xFE" o2="0x16" flow="next"/>
+<opcode name="cpblk" input="PopI+PopI+PopI" output="Push0" args="InlineNone" o1="0xFE" o2="0x17" flow="next"/>
+<opcode name="initblk" input="PopI+PopI+PopI" output="Push0" args="InlineNone" o1="0xFE" o2="0x18" flow="next"/>
+<opcode name="unused69" input="Pop0" output="Push0" args="InlineNone" o1="0xFE" o2="0x19" flow="next"/>
+<opcode name="rethrow" input="Pop0" output="Push0" args="InlineNone" o1="0xFE" o2="0x1A" flow="throw"/>
+<opcode name="unused" input="Pop0" output="Push0" args="InlineNone" o1="0xFE" o2="0x1B" flow="next"/>
+<opcode name="sizeof" input="Pop0" output="PushI" args="InlineType" o1="0xFE" o2="0x1C" flow="next"/>
+<opcode name="refanytype" input="Pop1" output="PushI" args="InlineNone" o1="0xFE" o2="0x1D" flow="next"/>
+<opcode name="unused52" input="Pop0" output="Push0" args="InlineNone" o1="0xFE" o2="0x1E" flow="next"/>
+<opcode name="unused53" input="Pop0" output="Push0" args="InlineNone" o1="0xFE" o2="0x1F" flow="next"/>
+<opcode name="unused54" input="Pop0" output="Push0" args="InlineNone" o1="0xFE" o2="0x20" flow="next"/>
+<opcode name="unused55" input="Pop0" output="Push0" args="InlineNone" o1="0xFE" o2="0x21" flow="next"/>
+<opcode name="unused70" input="Pop0" output="Push0" args="InlineNone" o1="0xFE" o2="0x22" flow="next"/>
+<opcode name="illegal" input="Pop0" output="Push0" args="InlineNone" o1="0x00" o2="0x00" flow="meta"/>
+<opcode name="endmac" input="Pop0" output="Push0" args="InlineNone" o1="0x00" o2="0x00" flow="meta"/>
+
+
+</opdesc>
diff --git a/mono/cil/make-opcode-def.xsl b/mono/cil/make-opcode-def.xsl new file mode 100644 index 00000000000..9ad799f4ba9 --- /dev/null +++ b/mono/cil/make-opcode-def.xsl @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="iso-8859-1"?>
+
+
+<!--
+ | make-opcode-def.xsl: Translates opcodes from the CIL-opcodes.xml into
+ | a spec compliant opcodes.def file
+ | Converted to XSLT from make-opcodes-def.pl
+ |
+ | See: Common Language Infrastructure (CLI) Part 5: Annexes
+ |
+ | Author: Sergey Chaban
+ |
+ | $Id: make-opcode-def.xsl,v 1.1 2001/07/13 01:04:23 miguel Exp $
+ -->
+
+
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+
+
+<xsl:output method="text"/>
+
+
+<xsl:template match="/">
+ <xsl:apply-templates/>
+ <xsl:call-template name="print-trailer"/>
+</xsl:template>
+
+<xsl:template name="to-upper">
+ <xsl:param name="string"/>
+ <xsl:value-of select="translate($string,
+ 'abcdefghijklmnopqrstuvwxyz.-',
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ__')"/>
+</xsl:template>
+
+
+<xsl:template name="get-flow">
+ <xsl:param name="flow" select="@flow"/>
+ <xsl:choose>
+ <xsl:when
+ test="contains('next call return branch meta cond-branch',$flow)">
+ <xsl:call-template name="to-upper">
+ <xsl:with-param name="string" select="$flow"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise><xsl:value-of select="'ERROR'"/></xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<xsl:template match="opdesc/opcode">
+ <xsl:variable name="uname">
+ <xsl:call-template name="to-upper">
+ <xsl:with-param name="string" select="@name"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="o1">
+ <xsl:call-template name="to-upper">
+ <xsl:with-param name="string" select="@o1"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="f">
+ <xsl:call-template name="get-flow"/>
+ </xsl:variable>
+ <xsl:variable name="count"
+ select="number(not(contains($o1,'FF')))+1"/>OPDEF(CEE_<xsl:value-of
+ select="concat($uname,', "',@name,'", ',
+ @input,', ',@output,', ',@args,', X, ',
+ $count,', ',@o1,', ',@o2,', ',$f
+ )"/>)
+</xsl:template>
+
+
+<xsl:template name="print-trailer">
+#ifndef OPALIAS
+#define _MONO_CIL_OPALIAS_DEFINED_
+#define OPALIAS(a,s,r)
+#endif
+
+OPALIAS(CEE_BRNULL, "brnull", CEE_BRFALSE)
+OPALIAS(CEE_BRNULL_S, "brnull.s", CEE_BRFALSE_S)
+OPALIAS(CEE_BRZERO, "brzero", CEE_BRFALSE)
+OPALIAS(CEE_BRZERO_S, "brzero.s", CEE_BRFALSE_S)
+OPALIAS(CEE_BRINST, "brinst", CEE_BRTRUE)
+OPALIAS(CEE_BRINST_S, "brinst.s", CEE_BRTRUE_S)
+OPALIAS(CEE_LDIND_U8, "ldind.u8", CEE_LDIND_I8)
+OPALIAS(CEE_LDELEM_U8, "ldelem.u8", CEE_LDELEM_I8)
+OPALIAS(CEE_LDX_I4_MIX, "ldc.i4.M1", CEE_LDC_I4_M1)
+OPALIAS(CEE_ENDFAULT, "endfault", CEE_ENDFINALLY)
+
+#ifdef _MONO_CIL_OPALIAS_DEFINED_
+#undef OPALIAS
+#undef _MONO_CIL_OPALIAS_DEFINED_
+#endif
+</xsl:template>
+
+
+</xsl:stylesheet>
diff --git a/mono/cil/make-opcodes-def.pl b/mono/cil/make-opcodes-def.pl new file mode 100644 index 00000000000..3114918bb65 --- /dev/null +++ b/mono/cil/make-opcodes-def.pl @@ -0,0 +1,80 @@ +#!/usr/bin/perl +# +# make-opcodes-def.pl: Loads the opcodes from the CIL-opcodes.xml and +# generates a spec compliant opcodes.def file +# +# Author: +# Miguel de Icaza (miguel@ximian.com) +# +# (C) 2001 Ximian, Inc. +# +# We should really be doing this with XSLT, but I know nothing about XSLT +# ;-) +# or maybe just an XML::Parser... - lupus + +use strict; +use XML::Parser; + +my %valid_flow; +# the XML file also includes "throw" +@valid_flow{qw(next call return branch meta cond-branch)} = (); + +open OUTPUT, ">opcode.def" || die "Can not create opcode.def file: $!"; + +my $parser = new XML::Parser (Handlers => {Start => \&handle_opcode}); +$parser->parsefile("cil-opcodes.xml"); +print_trailer(); +close(OUTPUT) || die "Can not close file: $!"; + +sub handle_opcode { + my ($parser, $elem, %attrs) = @_; + my ($name, $input, $output, $args, $o1, $o2, $flow, $uname, $count, $ff); + + return if ($elem ne 'opcode'); + + ($name, $input, $output, $args, $o1, $o2, $flow) = + @attrs{qw(name input output args o1 o2 flow)}; + + $uname = uc $name; + $uname =~ tr/./_/; + if (hex($o1) == 0xff){ + $count = 1; + } else { + $count = 2; + } + + $ff = "ERROR"; + if (exists $valid_flow{$flow}) { + $ff = uc $flow; + $ff =~ tr/-/_/; + } + + print OUTPUT "OPDEF(CEE_$uname, \"$name\", $input, $output, $args, X, $count, $o1, $o2, $ff)\n"; + +} + +sub print_trailer { +print OUTPUT<<EOF; +#ifndef OPALIAS +#define _MONO_CIL_OPALIAS_DEFINED_ +#define OPALIAS(a,s,r) +#endif + +OPALIAS(CEE_BRNULL, "brnull", CEE_BRFALSE) +OPALIAS(CEE_BRNULL_S, "brnull.s", CEE_BRFALSE_S) +OPALIAS(CEE_BRZERO, "brzero", CEE_BRFALSE) +OPALIAS(CEE_BRZERO_S, "brzero.s", CEE_BRFALSE_S) +OPALIAS(CEE_BRINST, "brinst", CEE_BRTRUE) +OPALIAS(CEE_BRINST_S, "brinst.s", CEE_BRTRUE_S) +OPALIAS(CEE_LDIND_U8, "ldind.u8", CEE_LDIND_I8) +OPALIAS(CEE_LDELEM_U8, "ldelem.u8", CEE_LDELEM_I8) +OPALIAS(CEE_LDX_I4_MIX, "ldc.i4.M1", CEE_LDC_I4_M1) +OPALIAS(CEE_ENDFAULT, "endfault", CEE_ENDFINALLY) + +#ifdef _MONO_CIL_OPALIAS_DEFINED_ +#undef OPALIAS +#undef _MONO_CIL_OPALIAS_DEFINED_ +#endif +EOF +} + diff --git a/mono/dis/.cvsignore b/mono/dis/.cvsignore new file mode 100644 index 00000000000..45b45b2bee5 --- /dev/null +++ b/mono/dis/.cvsignore @@ -0,0 +1,5 @@ +Makefile +Makefile.in +.libs +.deps +monodis diff --git a/mono/dis/ChangeLog b/mono/dis/ChangeLog new file mode 100644 index 00000000000..97ce5e3fe73 --- /dev/null +++ b/mono/dis/ChangeLog @@ -0,0 +1,77 @@ +Sun Jul 15 17:29:10 CEST 2001 Paolo Molaro <lupus@ximian.com> + + * get.h,get.c: added some dis_stringify_object() functions: + metadata decoding is now done in libmetadata. Still need to use + them throughhout the code (and move other decode code to + metadata). Fix also field decoding (band-aid until we load + also referenced assemblies). + * dis/main.c: start using the new routines. + +2001-07-13 Miguel de Icaza <miguel@ximian.com> + + * get.c (get_method): GOOD. Implemented this other bad boy. + +2001-07-12 Miguel de Icaza <miguel@ximian.com> + + * get.c (get_token_type): Implement TOKEN_TYPE_TYPE_SPEC. + (get_typespec): Implement. + (get_typedef_or_ref): Use get_typespec. + + * dis-cil.c (dissasemble_cil): Implement InlineField + (dissasemble_cil): Implement InlineTok. + + * get.c (get_token, get_field): Implemented. Worked around lame + tables in the spec. + +Wed Jul 11 18:52:15 CEST 2001 Paolo Molaro <lupus@ximian.com> + + * dis-cil.c: output real name of local var. + * dump.c: output more info about fields (flags and type). Properly decode + Property signatures. Decode also method table. + * main.c: Fix local variable info. Hopefully fix field and property list. + +Mon Jul 9 16:39:41 CEST 2001 Paolo Molaro <lupus@ximian.com> + + * dump.c: write stuff to output, not stderr. Give more info for properties. + * dump.c,dump.h,main.c: implement dump_table_event(), dump_table_file(), + dump_table_moduleref(). + * get.c: first attempt to decode string constants, need to find if and where + this is actually specified. + +Fri Jul 6 19:49:21 CEST 2001 Paolo Molaro <lupus@ximian.com> + + * dump.c,dump.h: implement dump_table_property(). + * main.c: implement local variable info disassembling. + Annotate entrypoint method. Remove memory leak in + parse_method_signature (). + +2001-07-04 Miguel de Icaza <miguel@ximian.com> + + * get.c (get_methodref_signature): Implement. + + * dump.c (dump_table_memberref): Add memberref dumping. + +Tue, 3 Jul 2001 18:32:10 +0200 Paolo Molaro <lupus@ximian.com> + + * main.c: return on failure. + +2001-07-02 Miguel de Icaza <miguel@ximian.com> + + * dis-cil.c (get_encoded_user_string): Return a string from the + #US heap. o + + * get.c (get_blob_encoded_size): Implement 23.1.4 decoding. + +2001-07-01 Miguel de Icaza <miguel@ximian.com> + + * dis-cil.c: New file. CIL opcode dissasembler. + +2001-06-27 Miguel de Icaza <miguel@ximian.com> + + * main.c: Split code. + +2001-06-22 Miguel de Icaza <miguel@ximian.com> + + * main.c: More work on the disassembler and on the understanding + of the metadata file format. + diff --git a/mono/dis/Makefile.am b/mono/dis/Makefile.am index fdb8662c28c..9cb1baad6ad 100644 --- a/mono/dis/Makefile.am +++ b/mono/dis/Makefile.am @@ -3,8 +3,21 @@ INCLUDES = $(GLIB_CFLAGS) -I$(top_srcdir) bin_PROGRAMS = monodis monodis_SOURCES = \ - main.c + get.c \ + get.h \ + dis-cil.c \ + dis-cil.h \ + dump.c \ + dump.h \ + main.c \ + meta.h \ + util.c \ + util.h monodis_LDADD = \ ../metadata/libmetadata.a \ $(GLIB_LIBS) + +man_MANS = monodis.1 + +EXTRA_DIST = $(man_MANS)
\ No newline at end of file diff --git a/mono/dis/TODO b/mono/dis/TODO new file mode 100644 index 00000000000..fb42dc0758a --- /dev/null +++ b/mono/dis/TODO @@ -0,0 +1,5 @@ +* Write test cases + + Write test cases to stress test TypeSpec. This is done by + creating arrays of various dimensions, sizes, and lower + bounds. diff --git a/mono/dis/dis-cil.c b/mono/dis/dis-cil.c new file mode 100644 index 00000000000..8f57ceb067c --- /dev/null +++ b/mono/dis/dis-cil.c @@ -0,0 +1,253 @@ +/* + * dis-cil.c: Disassembles CIL byte codes + * + * Author: + * Miguel de Icaza (miguel@ximian.com) + * + * (C) 2001 Ximian, Inc. + */ +#include <config.h> +#include <glib.h> +#include <stdio.h> +#include <wchar.h> +#include "meta.h" +#include "get.h" +#include "dump.h" +#include "dis-cil.h" + +enum { + InlineBrTarget, + InlineField, + InlineI, + InlineI8, + InlineMethod, + InlineNone, + InlineR, + InlineSig, + InlineString, + InlineSwitch, + InlineTok, + InlineType, + InlineVar, + ShortInlineBrTarget, + ShortInlineI, + ShortInlineR, + ShortInlineVar +}; + +#define OPDEF(a,b,c,d,e,f,g,h,i,j) \ + { b, e, g, h, i }, + +typedef struct { + char *name; + int argument; + + /* + * we are not really using any of the following: + */ + int bytes; + unsigned char o1, o2; +} opcode_t; + +static opcode_t opcodes [300] = { +#include "mono/cil/opcode.def" +}; + +/* + * Strings on the US heap are encoded using UTF-16. Poor man's + * UTF-16 to UTF-8. I know its broken, use libunicode later. + */ +static char * +get_encoded_user_string (const char *ptr) +{ + char *res; + int len, i, j; + + ptr = get_blob_encoded_size (ptr, &len); + res = g_malloc (len + 1); + + /* + * I should really use some kind of libunicode here + */ + for (i = 0, j = 0; i < len; j++, i += 2) + res [j] = ptr [i]; + + res [j] = 0; + + return res; +} + +void +dissasemble_cil (metadata_t *m, const unsigned char *start, int size) +{ + const unsigned char *end = start + size; + const unsigned char *ptr = start; + opcode_t *entry; + + while (ptr < end){ + if (*ptr == 0xfe){ + ptr++; + entry = &opcodes [*ptr + 256]; + } else + entry = &opcodes [*ptr]; + + fprintf (output, "\tIL_%04x: %s ", (int) (ptr - start), entry->name); + ptr++; + switch (entry->argument){ + case InlineBrTarget: { + gint target = *(gint32 *) ptr; + fprintf (output, "IL_%04x", ((int) (ptr - start)) + 4 + target); + ptr += 4; + break; + } + + case InlineField: { + guint32 token = *(guint32 *) ptr; + char *s; + + s = get_field (m, token); + fprintf (output, "%s", s); + g_free (s); + ptr += 4; + break; + } + + case InlineI: { + int value = *(int *) ptr; + + fprintf (output, "%d", value); + ptr += 4; + break; + } + + case InlineI8: { + gint64 top = *(guint64 *) ptr; + + fprintf (output, "%lld", (long long) top); + ptr += 8; + break; + } + + case InlineMethod: { + guint32 token = *(guint32 *) ptr; + char *s; + + s = get_method (m, token); + fprintf (output, "%s", s); + g_free (s); + ptr += 4; + break; + } + + case InlineNone: + break; + + case InlineR: { + double r = *(double *) ptr; + fprintf (output, "%g", r); + ptr += 8; + break; + } + + case InlineSig: { + guint32 token = *(guint32 *) ptr; + fprintf (output, "signature-0x%08x", token); + ptr += 4; + break; + } + + case InlineString: { + guint32 token = *(guint32 *) ptr; + + char *s = get_encoded_user_string ( + mono_metadata_user_string (m, token & 0xffffff)); + + /* + * See section 23.1.4 on the encoding of the #US heap + */ + fprintf (output, "\"%s\"", s); + g_free (s); + ptr += 4; + break; + } + + case InlineSwitch: { + guint32 count = *(guint32 *) ptr; + guint32 i; + + ptr += 4; + fprintf (output, "(\n\t\t\t"); + for (i = 0; i < count; i++){ + fprintf (output, "IL_%x", *(guint32 *) ptr); + ptr += 4; + } + fprintf (output, "\t\t\t)"); + break; + } + + case InlineTok: { + guint32 token = *(guint32 *) ptr; + char *s; + + s = get_token (m, token); + fprintf (output, "%s", s); + g_free (s); + + ptr += 4; + break; + } + + case InlineType: { + guint32 token = *(guint32 *) ptr; + char *s = get_token_type (m, token); + fprintf (output, "%s", s); + g_free (s); + ptr += 4; + break; + } + + case InlineVar: { + gint16 var_idx = *(gint16 *) ptr; + + fprintf (output, "variable-%d\n", var_idx); + ptr += 2; + break; + } + + case ShortInlineBrTarget: { + signed char x = *ptr; + + fprintf (output, "IL_%04x", ptr - start + 1 + x); + ptr++; + break; + } + + case ShortInlineI: { + char x = *ptr; + + fprintf (output, "0x%02x", x); + ptr++; + break; + } + + case ShortInlineR: { + float f = *(float *) ptr; + + fprintf (output, "%g", (double) f); + ptr += 4; + break; + } + + case ShortInlineVar: { + signed char x = *ptr; + + fprintf (output, "V_%d", (int) x); + ptr++; + break; + } + + } + + fprintf (output, "\n"); + } +} diff --git a/mono/dis/dis-cil.h b/mono/dis/dis-cil.h new file mode 100644 index 00000000000..7874d4e7ff1 --- /dev/null +++ b/mono/dis/dis-cil.h @@ -0,0 +1 @@ +void dissasemble_cil (metadata_t *m, const unsigned char *ptr, int size); diff --git a/mono/dis/dump.c b/mono/dis/dump.c new file mode 100644 index 00000000000..bd110dbbc25 --- /dev/null +++ b/mono/dis/dump.c @@ -0,0 +1,370 @@ +/* + * dump.c: Dumping routines for the disassembler. + * + * Author: + * Miguel de Icaza (miguel@ximian.com) + * + * (C) 2001 Ximian, Inc. + */ +#include <config.h> +#include <stdio.h> +#include <string.h> +#include <glib.h> +#include "meta.h" +#include "util.h" +#include "dump.h" +#include "get.h" + +void +dump_table_assembly (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_ASSEMBLY]; + guint32 cols [9]; + const char *ptr; + int len; + + expand (t, 0, cols, CSIZE (cols)); + fprintf (output, "Assembly Table\n"); + + fprintf (output, "Name: %s\n", mono_metadata_string_heap (m, cols [7])); + fprintf (output, "Hash Algoritm: 0x%08x\n", cols [0]); + fprintf (output, "Version: %d.%d.%d.%d\n", cols [1], cols [2], cols [3], cols [4]); + fprintf (output, "Flags: 0x%08x\n", cols [5]); + fprintf (output, "PublicKey: BlobPtr (0x%08x)\n", cols [6]); + + ptr = mono_metadata_blob_heap (m, cols [6]); + ptr = get_encoded_value (ptr, &len); + if (len > 0){ + fprintf (output, "\tDump:"); + hex_dump (ptr, 0, len); + fprintf (output, "\n"); + } else + fprintf (output, "\tZero sized public key\n"); + + fprintf (output, "Culture: %s\n", mono_metadata_string_heap (m, cols [8])); + fprintf (output, "\n"); +} + +void +dump_table_typeref (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_TYPEREF]; + int i; + + fprintf (output, "Typeref Table\n"); + + for (i = 1; i <= t->rows; i++){ + char *s = get_typeref (m, i); + + fprintf (output, "%d: %s\n", i, s); + g_free (s); + } + fprintf (output, "\n"); +} + +void +dump_table_typedef (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_TYPEDEF]; + int i; + + fprintf (output, "Typedef Table\n"); + + for (i = 1; i <= t->rows; i++){ + char *s = get_typedef (m, i); + guint32 cols [6]; + + expand (&m->tables [META_TABLE_TYPEDEF], i - 1, cols, CSIZE (cols)); + + fprintf (output, "%d: %s (flist=%d, mlist=%d)\n", i, s, cols [4], cols [5]); + g_free (s); + } + fprintf (output, "\n"); +} + +void +dump_table_assemblyref (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_ASSEMBLYREF]; + int i; + + fprintf (output, "AssemblyRef Table\n"); + + for (i = 0; i < t->rows; i++){ + const char *ptr; + int len; + guint32 cols [9]; + + expand (t, i, cols, CSIZE (cols)); + fprintf (output, "%d: Version=%d.%d.%d.%d\n\tName=%s\n", i, + cols [0], cols [1], cols [2], cols [3], + mono_metadata_string_heap (m, cols [6])); + ptr = mono_metadata_blob_heap (m, cols [6]); + ptr = get_encoded_value (ptr, &len); + if (len > 0){ + fprintf (output, "\tPublic Key:"); + hex_dump (ptr, 0, len); + fprintf (output, "\n"); + } else + fprintf (output, "\tZero sized public key\n"); + + } + fprintf (output, "\n"); +} + +void +dump_table_param (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_PARAM]; + int i; + + fprintf (output, "Param Table\n"); + + for (i = 0; i < t->rows; i++){ + guint32 cols [3]; + + expand (t, i, cols, CSIZE (cols)); + fprintf (output, "%d: 0x%04x %d %s\n", + i, + cols [0], cols [1], + mono_metadata_string_heap (m, cols [2])); + } + fprintf (output, "\n"); +} + +void +dump_table_field (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_FIELD]; + int i; + + fprintf (output, "Field Table (0..%d)\n", t->rows); + + for (i = 0; i < t->rows; i++){ + guint32 cols [3]; + char *sig, *flags; + + expand (t, i, cols, CSIZE (cols)); + sig = get_field_signature (m, cols [2]); + flags = field_flags (cols [0]); + fprintf (output, "%d: %s %s: %s\n", + i, + sig, + mono_metadata_string_heap (m, cols [1]), + flags); + g_free (sig); + g_free (flags); + } + fprintf (output, "\n"); +} + +void +dump_table_memberref (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_MEMBERREF]; + int i, kind, idx; + char *ks, *x, *xx; + + fprintf (output, "MemberRef Table (0..%d)\n", t->rows); + + for (i = 0; i < t->rows; i++){ + guint32 cols [3]; + + expand (t, i, cols, CSIZE (cols)); + + kind = cols [0] & 7; + idx = cols [0] >> 3; + + x = g_strdup ("UNHANDLED CASE"); + + switch (kind){ + case 0: + ks = "TypeDef"; break; + case 1: + ks = "TypeRef"; + xx = get_typeref (m, idx); + x = g_strconcat (xx, ".", mono_metadata_string_heap (m, cols [1]), NULL); + g_free (xx); + break; + case 2: + ks = "ModuleRef"; break; + case 3: + ks = "MethodDef"; break; + case 4: + ks = "TypeSpec"; break; + default: + g_error ("Unknown tag: %d\n", kind); + } + + fprintf (output, "%d: %s[%d] %s\n\tResolved: %s\n\tSignature: %s\n\t\n", + i, + ks, idx, + mono_metadata_string_heap (m, cols [1]), + x ? x : "", + get_methodref_signature (m, cols [2], NULL)); + + if (x) + g_free (x); + } +} + +void +dump_table_class_layout (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_CLASSLAYOUT]; + int i; + fprintf (output, "ClassLayout Table (0..%d)\n", t->rows); + + for (i = 0; i < t->rows; i++){ + guint32 cols [3]; + + expand (t, i, cols, CSIZE (cols)); + + fprintf (output, "%d: PackingSize=%d ClassSize=%d Parent=%s\n", + i, cols [0], cols [1], get_typedef (m, cols [2])); + } +} + +void +dump_table_constant (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_CONSTANT]; + int i; + fprintf (output, "Constant Table (0..%d)\n", t->rows); + + for (i = 0; i < t->rows; i++){ + guint32 cols [4]; + + expand (t, i, cols, CSIZE (cols)); + + fprintf (output, "%d: Parent=0x%08x %s\n", + i, cols [2], get_constant (m, (ElementTypeEnum) cols [0], cols [3])); + } + +} + +void +dump_table_property (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_PROPERTY]; + int i, j, pcount; + const char *ptr; + char flags[128]; + + fprintf (output, "Property Table (0..%d)\n", t->rows); + + for (i = 0; i < t->rows; i++){ + guint32 cols [3]; + char *type; + int bsize; + + expand (t, i, cols, CSIZE (cols)); + flags [0] = 0; + if (cols [0] & 0x0200) + strcat (flags, "special "); + if (cols [0] & 0x0400) + strcat (flags, "runtime "); + if (cols [0] & 0x1000) + strcat (flags, "hasdefault "); + + ptr = mono_metadata_blob_heap (m, cols [2]); + ptr = get_blob_encoded_size (ptr, &bsize); + /* ECMA claims 0x08 ... */ + if (*ptr != 0x28 && *ptr != 0x08) + g_warning("incorrect signature in propert blob: 0x%x", *ptr); + ptr++; + ptr = get_encoded_value (ptr, &pcount); + ptr = get_type (m, ptr, &type); + fprintf (output, "%d: %s %s (", + i, type, mono_metadata_string_heap (m, cols [1])); + g_free (type); + + for (j = 0; j < pcount; j++){ + ptr = get_param (m, ptr, &type); + fprintf (output, "%s%s", j > 0? ", " : "",type); + g_free (type); + } + fprintf (output, ") %s\n", flags); + } +} + +void +dump_table_event (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_EVENT]; + int i; + fprintf (output, "Event Table (0..%d)\n", t->rows); + + for (i = 0; i < t->rows; i++){ + guint32 cols [3]; + const char *name; + char *type; + + expand (t, i, cols, CSIZE (cols)); + + name = mono_metadata_string_heap (m, cols [1]); + type = get_typedef_or_ref (m, cols [2]); + fprintf (output, "%d: %s %s %s\n", i, type, name, + cols [0] & 0x200 ? "specialname " : ""); + g_free (type); + } + +} + +void +dump_table_file (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_FILE]; + int i; + fprintf (output, "File Table (0..%d)\n", t->rows); + + for (i = 0; i < t->rows; i++){ + guint32 cols [3]; + const char *name; + + expand (t, i, cols, CSIZE (cols)); + + name = mono_metadata_string_heap (m, cols[1]); + fprintf (output, "%d: %s %s\n", i, name, cols[2]&0x1?"nometadata":"containsmetadata"); + } + +} + +void +dump_table_moduleref (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_MODULEREF]; + int i; + fprintf (output, "ModuleRef Table (0..%d)\n", t->rows); + + for (i = 0; i < t->rows; i++){ + guint32 cols [1]; + const char *name; + + expand (t, i, cols, CSIZE (cols)); + + name = mono_metadata_string_heap (m, cols[0]); + fprintf (output, "%d: %s\n", i, name); + } + +} + +void +dump_table_method (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_METHOD]; + int i; + fprintf (output, "Method Table (0..%d)\n", t->rows); + + for (i = 0; i < t->rows; i++){ + guint32 cols [6]; + const char *name; + + expand (t, i, cols, CSIZE (cols)); + + name = mono_metadata_string_heap (m, cols[3]); + fprintf (output, "%d: %s\n", i, name); + } + +} + diff --git a/mono/dis/dump.h b/mono/dis/dump.h new file mode 100644 index 00000000000..8f37c994113 --- /dev/null +++ b/mono/dis/dump.h @@ -0,0 +1,16 @@ +extern FILE *output; + +void dump_table_assembly (metadata_t *m); +void dump_table_assemblyref (metadata_t *m); +void dump_table_class_layout (metadata_t *m); +void dump_table_constant (metadata_t *m); +void dump_table_property (metadata_t *m); +void dump_table_event (metadata_t *m); +void dump_table_file (metadata_t *m); +void dump_table_moduleref (metadata_t *m); +void dump_table_method (metadata_t *m); +void dump_table_field (metadata_t *m); +void dump_table_memberref (metadata_t *m); +void dump_table_param (metadata_t *m); +void dump_table_typedef (metadata_t *m); +void dump_table_typeref (metadata_t *m); diff --git a/mono/dis/get.c b/mono/dis/get.c new file mode 100644 index 00000000000..a71aaeabb03 --- /dev/null +++ b/mono/dis/get.c @@ -0,0 +1,1334 @@ +/* + * get.c: Functions to get stringified values from the metadata tables. + * + * Author: + * Miguel de Icaza (miguel@ximian.com) + * + * (C) 2001 Ximian, Inc. + */ +#include <config.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <glib.h> +#include "meta.h" +#include "util.h" +#include "get.h" + +/** + * expand: + * @t: table to extract information from. + * @idx: index in table. + * @res: array of @res_size cols to store the results in + * + * This decompresses the metadata element @idx in table @t + * into the guint32 @res array that has res_size elements + */ +void +expand (metadata_tableinfo_t *t, int idx, guint32 *res, int res_size) + +{ + guint32 bitfield = t->size_bitfield; + int i, count = meta_table_count (bitfield); + char *data = t->base + idx * t->row_size; + + g_assert (res_size == count); + + for (i = 0; i < count; i++){ + int n = meta_table_size (bitfield, i); + + switch (n){ + case 1: + res [i] = *data; break; + case 2: + res [i] = read16 (data); break; + + case 4: + res [i] = read32 (data); break; + + default: + g_assert_not_reached (); + } + data += n; + } +} + +/** + * get_encoded_value: + * @ptr: pointer to decode from + * @len: result value is stored here. + * + * This routine decompresses 32-bit values as specified in the "Blob and + * Signature" section (22.2) + * + * Returns: updated pointer location + */ +const char * +get_encoded_value (const char *_ptr, guint32 *len) +{ + const unsigned char *ptr = (unsigned char *) _ptr; + unsigned char b = *ptr; + + if ((b & 0x80) == 0){ + *len = b; + return ptr+1; + } else if ((b & 0x40) == 0){ + *len = ((b & 0x3f) << 8 | ptr [1]); + return ptr + 2; + } + *len = ((b & 0x1f) << 24) | + (ptr [1] << 16) | + (ptr [2] << 8) | + ptr [3]; + + return ptr + 4; +} + +char * +get_typedef (metadata_t *m, int idx) +{ + guint32 cols [6]; + + expand (&m->tables [META_TABLE_TYPEDEF], idx - 1, cols, CSIZE (cols)); + + return g_strdup_printf ( + "%s.%s", + mono_metadata_string_heap (m, cols [2]), + mono_metadata_string_heap (m, cols [1])); +} + +char * +get_module (metadata_t *m, int idx) +{ + guint32 cols [5]; + + /* + * There MUST BE only one module in the Module table + */ + g_assert (idx == 1); + + expand (&m->tables [META_TABLE_MODULEREF], idx - 1, cols, CSIZE (cols)); + + return g_strdup (mono_metadata_string_heap (m, cols [6])); +} + +char * +get_assemblyref (metadata_t *m, int idx) +{ + guint32 cols [9]; + + expand (&m->tables [META_TABLE_ASSEMBLYREF], idx - 1, cols, CSIZE (cols)); + + return g_strdup (mono_metadata_string_heap (m, cols [6])); +} + +/* + * + * Returns a string representing the ArrayShape (22.2.16). + */ +static const char * +get_array_shape (metadata_t *m, const char *ptr, char **result) +{ + GString *res = g_string_new ("["); + guint32 rank, num_sizes, num_lo_bounds; + guint32 *sizes = NULL, *lo_bounds = NULL; + int i, r; + char buffer [80]; + + ptr = get_encoded_value (ptr, &rank); + ptr = get_encoded_value (ptr, &num_sizes); + + if (num_sizes > 0) + sizes = g_new (guint32, num_sizes); + + for (i = 0; i < num_sizes; i++) + ptr = get_encoded_value (ptr, &(sizes [i])); + + ptr = get_encoded_value (ptr, &num_lo_bounds); + if (num_lo_bounds > 0) + lo_bounds = g_new (guint32, num_lo_bounds); + + for (i = 0; i < num_lo_bounds; i++) + ptr = get_encoded_value (ptr, &(lo_bounds [i])); + + for (r = 0; r < rank; r++){ + if (r < num_sizes){ + if (r < num_lo_bounds){ + sprintf (buffer, "%d..%d", lo_bounds [r], lo_bounds [r] + sizes [r] - 1); + } else { + sprintf (buffer, "0..%d", sizes [r] - 1); + } + } else + buffer [0] = 0; + + g_string_append (res, buffer); + if ((r + 1) != rank) + g_string_append (res, ", "); + } + g_string_append (res, "]"); + + if (sizes) + g_free (sizes); + + if (lo_bounds) + g_free (lo_bounds); + + *result = res->str; + g_string_free (res, FALSE); + + return ptr; +} + +/** + * get_typespec: + * @m: metadata context + * @blob_idx: index into the blob heap + * + * Returns the stringified representation of a TypeSpec signature (22.2.17) + */ +char * +get_typespec (metadata_t *m, guint32 idx) +{ + guint32 cols [1]; + const char *ptr; + char *s, *result; + GString *res = g_string_new (""); + int len; + + expand (&m->tables [META_TABLE_TYPESPEC], idx-1, cols, CSIZE (cols)); + ptr = mono_metadata_blob_heap (m, cols [0]); + ptr = get_encoded_value (ptr, &len); + + switch (*ptr++){ + case ELEMENT_TYPE_PTR: + ptr = get_custom_mod (m, ptr, &s); + if (s){ + g_string_append (res, s); + g_string_append_c (res, ' '); + g_free (s); + } + + if (*ptr == ELEMENT_TYPE_VOID) + g_string_append (res, "void"); + else { + ptr = get_type (m, ptr, &s); + if (s) + g_string_append (res, s); + } + break; + + case ELEMENT_TYPE_FNPTR: + g_string_append (res, "FNPTR "); + /* + * we assume MethodRefSig, as we do not know + * whether it is a MethodDefSig or a MethodRefSig. + */ + printf ("\n FNPTR:\n"); + + hex_dump (ptr, 0, 40); + break; + + case ELEMENT_TYPE_ARRAY: + ptr = get_type (m, ptr, &s); + g_string_append (res, s); + g_free (s); + g_string_append_c (res, ' '); + ptr = get_array_shape (m, ptr, &s); + g_string_append (res, s); + g_free (s); + break; + + case ELEMENT_TYPE_SZARRAY: + ptr = get_custom_mod (m, ptr, &s); + if (s){ + g_string_append (res, s); + g_string_append_c (res, ' '); + g_free (s); + } + ptr = get_type (m, ptr, &s); + g_string_append (res, s); + g_string_append (res, "[]"); + g_free (s); + } + + result = res->str; + g_string_free (res, FALSE); + + return result; +} + +char * +get_typeref (metadata_t *m, int idx) +{ + guint32 cols [3]; + const char *s, *t; + char *x, *ret; + guint32 rs_idx, table; + + expand (&m->tables [META_TABLE_TYPEREF], idx - 1, cols, CSIZE (cols)); + + t = mono_metadata_string_heap (m, cols [1]); + s = mono_metadata_string_heap (m, cols [2]); + + rs_idx = cols [0] >> 2; + /* + * Two bits in Beta2. + * ECMA spec claims 3 bits + */ + table = cols [0] & 3; + + switch (table){ + case 0: /* Module */ + x = get_module (m, rs_idx); + ret = g_strdup_printf ("TODO:TypeRef-Module [%s] %s.%s", x, s, t); + g_free (x); + break; + + case 1: /* ModuleRef */ + ret = g_strdup_printf ("TODO:TypeRef-ModuleRef (%s.%s)", s, t); + break; + + case 2: /* + * AssemblyRef (ECMA docs claim it is 3, but it looks to + * me like it is 2 (tokens are prefixed with 0x23) + */ + x = get_assemblyref (m, rs_idx); + ret = g_strdup_printf ("[%s] %s.%s", x, s, t); + g_free (x); + break; + + case 4: /* TypeRef */ + ret = g_strdup_printf ("TODO:TypeRef-TypeRef: TYPEREF! (%s.%s)", s, t); + break; + + default: + ret = g_strdup_printf ("Unknown table in TypeRef %d", table); + } + + return ret; +} + +/** + * get_typedef_or_ref: + * @m: metadata context + * @dor_token: def or ref encoded index + * + * Low two bits contain table to lookup from + * high bits contain the index into the def or ref table + * + * Returns: a stringified version of the MethodDef or MethodRef + * at (dor_token >> 2) + */ +char * +get_typedef_or_ref (metadata_t *m, guint32 dor_token) +{ + char *temp = NULL, *s; + int table, idx; + + /* + * low 2 bits contain encoding + */ + table = dor_token & 0x03; + idx = dor_token >> 2; + + switch (table){ + case 0: /* TypeDef */ + temp = get_typedef (m, idx); + s = g_strdup_printf ("%s", temp); + break; + + case 1: /* TypeRef */ + temp = get_typeref (m, idx); + s = g_strdup_printf ("%s", temp); + break; + + case 2: /* TypeSpec */ + s = get_typespec (m, idx); + break; + + default: + g_error ("Unhandled encoding for typedef-or-ref coded index"); + + } + + if (temp) + g_free (temp); + + return s; +} + +/** + * get_encoded_typedef_or_ref: + * @m: metadata context + * @ptr: location to decode from. + * @result: pointer to string where resulting decoded string is stored + * + * result will point to a g_malloc()ed string. + * + * Returns: the new ptr to continue decoding + */ +const char * +get_encoded_typedef_or_ref (metadata_t *m, const char *ptr, char **result) +{ + guint32 token; + + ptr = get_encoded_value (ptr, &token); + + *result = get_typedef_or_ref (m, token); + + return ptr; +} + +/** + * get_custom_mod: + * + * Decodes a CustomMod (22.2.7) + * + * Returns: updated pointer location + */ +const char * +get_custom_mod (metadata_t *m, const char *ptr, char **return_value) +{ + char *s; + + if ((*ptr == ELEMENT_TYPE_CMOD_OPT) || + (*ptr == ELEMENT_TYPE_CMOD_REQD)){ + ptr++; + ptr = get_encoded_typedef_or_ref (m, ptr, &s); + + *return_value = g_strconcat ("CMOD ", s, NULL); + g_free (s); + } else + *return_value = NULL; + return ptr; +} + + +/** + * methoddefref_signature: + * @m: metadata context + * @ptr: location to decode from. + * @result: pointer to string where resulting decoded string is stored + * + * This routine decodes into a string a MethodDef or a MethodRef. + * + * result will point to a g_malloc()ed string. + * + * Returns: the new ptr to continue decoding + */ +static const char * +methoddefref_signature (metadata_t *m, const char *ptr, char **result) +{ + *result = g_strdup ("method-def-or-ref"); + + return ptr; +} + +static map_t element_type_map [] = { + { ELEMENT_TYPE_END , "end" }, + { ELEMENT_TYPE_VOID , "void" }, + { ELEMENT_TYPE_BOOLEAN , "bool" }, + { ELEMENT_TYPE_CHAR , "char" }, + { ELEMENT_TYPE_I1 , "sbyte" }, + { ELEMENT_TYPE_U1 , "byte" }, + { ELEMENT_TYPE_I2 , "int16" }, + { ELEMENT_TYPE_U2 , "uint16" }, + { ELEMENT_TYPE_I4 , "int32" }, + { ELEMENT_TYPE_U4 , "uint32" }, + { ELEMENT_TYPE_I8 , "int64" }, + { ELEMENT_TYPE_U8 , "uint64" }, + { ELEMENT_TYPE_R4 , "float32" }, + { ELEMENT_TYPE_R8 , "float64" }, + { ELEMENT_TYPE_STRING , "string" }, + { ELEMENT_TYPE_TYPEDBYREF , "TypedByRef" }, + { ELEMENT_TYPE_I , "native int" }, + { ELEMENT_TYPE_U , "native unsigned int" }, + { ELEMENT_TYPE_OBJECT , "object" }, + { 0, NULL } +}; + +static map_t call_conv_type_map [] = { + { MONO_CALL_DEFAULT , "default" }, + { MONO_CALL_C , "c" }, + { MONO_CALL_STDCALL , "stdcall" }, + { MONO_CALL_THISCALL , "thiscall" }, + { MONO_CALL_FASTCALL , "fastcall" }, + { MONO_CALL_VARARG , "vararg" }, + { 0, NULL } +}; + +char* +dis_stringify_token (metadata_t *m, guint32 token) +{ + guint idx = token & 0xffffff; + switch (token >> 24) { + case META_TABLE_TYPEDEF: return get_typedef (m, idx); + case META_TABLE_TYPEREF: return get_typeref (m, idx); + case META_TABLE_TYPESPEC: return get_typespec (m, idx); + default: + break; + } + return g_strdup_printf("0x%08x", token); +} + +char* +dis_stringify_array (metadata_t *m, MonoArray *array) +{ + char *type; + GString *s = g_string_new(""); + int i; + + type = dis_stringify_type (m, array->type); + g_string_append (s, type); + g_free (type); + g_string_append_c (s, '['); + for (i = 0; i < array->rank; ++i) { + if (i) + g_string_append_c (s, ','); + if (i < array->numsizes) { + if (i < array->numlobounds && array->lobounds[i] != 0) + g_string_sprintfa (s, "%d..%d", array->lobounds[i], array->sizes[i]); + else + g_string_sprintfa (s, "%d", array->sizes[i]); + } + } + g_string_append_c (s, ']'); + type = s->str; + g_string_free (s, FALSE); + return type; +} + +char* +dis_stringify_modifiers (metadata_t *m, int n, MonoCustomMod *mod) +{ + GString *s = g_string_new(""); + char *result; + int i; + for (i = 0; i < n; ++i) { + char *tok = dis_stringify_token (m, mod[i].token); + g_string_sprintfa (s, "%s %s", mod[i].mod == ELEMENT_TYPE_CMOD_OPT ? "opt": "reqd", tok); + g_free (tok); + } + g_string_append_c (s, ' '); + result = s->str; + g_string_free (s, FALSE); + return result; +} + +char* +dis_stringify_param (metadata_t *m, MonoParam *param) +{ + char *mods = NULL; + char *t; + char *result; + if (param->num_modifiers) + mods = dis_stringify_modifiers (m, param->num_modifiers, param->modifiers); + if (param->typedbyref) + t = g_strdup ("TypedByRef"); + else if (!param->type) + t = g_strdup ("void"); + else + t = dis_stringify_type (m, param->type); + result = g_strjoin (mods ? mods : "", t, NULL); + g_free (t); + g_free (mods); + return result; +} + +char* +dis_stringify_method_signature (metadata_t *m, MonoMethodSignature *method) +{ + return g_strdup ("method-signature"); +} + +char* +dis_stringify_type (metadata_t *m, MonoType *type) +{ + char *bare = NULL; + char *byref = type->byref ? "ref " : ""; + char *result; + + switch (type->type){ + case ELEMENT_TYPE_BOOLEAN: + case ELEMENT_TYPE_CHAR: + case ELEMENT_TYPE_I1: + case ELEMENT_TYPE_U1: + case ELEMENT_TYPE_I2: + case ELEMENT_TYPE_U2: + case ELEMENT_TYPE_I4: + case ELEMENT_TYPE_U4: + case ELEMENT_TYPE_I8: + case ELEMENT_TYPE_U8: + case ELEMENT_TYPE_R4: + case ELEMENT_TYPE_R8: + case ELEMENT_TYPE_I: + case ELEMENT_TYPE_U: + case ELEMENT_TYPE_STRING: + case ELEMENT_TYPE_OBJECT: + case ELEMENT_TYPE_TYPEDBYREF: + bare = g_strdup (map (type->type, element_type_map)); + break; + + case ELEMENT_TYPE_VALUETYPE: + case ELEMENT_TYPE_CLASS: + bare = dis_stringify_token (m, type->data.token); + break; + + case ELEMENT_TYPE_FNPTR: + bare = dis_stringify_method_signature (m, type->data.method); + break; + case ELEMENT_TYPE_PTR: + case ELEMENT_TYPE_SZARRAY: { + char *child_type; + char *mods; + if (type->custom_mod) { + mods = dis_stringify_modifiers (m, type->data.mtype->num_modifiers, type->data.mtype->modifiers); + child_type = dis_stringify_type (m, type->data.mtype->type); + } else { + mods = g_strdup(""); + child_type = dis_stringify_type (m, type->data.type); + } + + bare = g_strdup_printf (type->type == ELEMENT_TYPE_PTR ? "%s*%s" : "%s%s[]", mods, child_type); + g_free (child_type); + g_free (mods); + break; + } + case ELEMENT_TYPE_ARRAY: + bare = dis_stringify_array (m, type->data.array); + break; + default: + g_error ("Do not know how to stringify type 0x%x", type->type); + } + + result = g_strjoin (byref, bare, NULL); + g_free (bare); + return result; +} + +/** + * get_type: + * @m: metadata context + * @ptr: location to decode from. + * @result: pointer to string where resulting decoded string is stored + * + * This routine returs in @result the stringified type pointed by @ptr. + * (22.2.12) + * + * Returns: the new ptr to continue decoding + */ +const char * +get_type (metadata_t *m, const char *ptr, char **result) +{ +#if 0 + char c; + + c = *ptr++; + + switch (c){ + case ELEMENT_TYPE_BOOLEAN: + case ELEMENT_TYPE_CHAR: + case ELEMENT_TYPE_I1: + case ELEMENT_TYPE_U1: + case ELEMENT_TYPE_I2: + case ELEMENT_TYPE_U2: + case ELEMENT_TYPE_I4: + case ELEMENT_TYPE_U4: + case ELEMENT_TYPE_I8: + case ELEMENT_TYPE_U8: + case ELEMENT_TYPE_R4: + case ELEMENT_TYPE_R8: + case ELEMENT_TYPE_I: + case ELEMENT_TYPE_STRING: + case ELEMENT_TYPE_OBJECT: + *result = g_strdup (map (c, element_type_map)); + break; + + case ELEMENT_TYPE_VALUETYPE: + case ELEMENT_TYPE_CLASS: + ptr = get_encoded_typedef_or_ref (m, ptr, result); + break; + + case ELEMENT_TYPE_FNPTR: + ptr = methoddefref_signature (m, ptr, result); + break; + + case ELEMENT_TYPE_SZARRAY: { + char *child_type; + + ptr = get_type (m, ptr, &child_type); + *result = g_strdup_printf ("%s[]", child_type); + g_free (child_type); + break; + } + + case ELEMENT_TYPE_ARRAY: + + *result = g_strdup ("ARRAY:TODO"); + } + + return ptr; +#else + MonoType *type = mono_metadata_parse_type (m, ptr, &ptr); + *result = dis_stringify_type (m, type); + mono_metadata_free_type (type); + return ptr; +#endif +} + +/** + * + * Returns a stringified representation of a FieldSig (22.2.4) + */ +char * +get_field_signature (metadata_t *m, guint32 blob_signature) +{ + char *allocated_modifier_string, *allocated_type_string; + const char *ptr = mono_metadata_blob_heap (m, blob_signature); + const char *base; + char *res; + int len; + + ptr = get_encoded_value (ptr, &len); + base = ptr; + /* FIELD is 0x06 */ + g_assert (*ptr == 0x06); +/* hex_dump (ptr, 0, len); */ + ptr++; len--; + + ptr = get_custom_mod (m, ptr, &allocated_modifier_string); + ptr = get_type (m, ptr, &allocated_type_string); + + res = g_strdup_printf ( + "%s %s", + allocated_modifier_string ? allocated_modifier_string : "", + allocated_type_string); + + if (allocated_modifier_string) + g_free (allocated_modifier_string); + if (allocated_type_string) + g_free (allocated_modifier_string); + + return res; +} + +ElementTypeEnum +get_field_literal_type (metadata_t *m, guint32 blob_signature) +{ + const char *ptr = mono_metadata_blob_heap (m, blob_signature); + int len; + char *allocated_modifier_string; + + ptr = get_encoded_value (ptr, &len); + + /* FIELD is 0x06 */ + g_assert (*ptr == 0x06); + ptr++; len--; + + ptr = get_custom_mod (m, ptr, &allocated_modifier_string); + if (allocated_modifier_string) + g_free (allocated_modifier_string); + + return (ElementTypeEnum) *ptr; + +} + +/** + * decode_literal: + * @m: metadata context + * @token: token to decode + * + * decodes the literal indexed by @token. + */ +char * +decode_literal (metadata_t *m, guint32 token) +{ + return g_strdup ("LITERAL_VALUE"); +} + +/** + * get_ret_type: + * @m: metadata context + * @ptr: location to decode from. + * @result: pointer to string where resulting decoded string is stored + * + * This routine returns in @result the stringified RetType (22.2.11) + * + * Returns: the new ptr to continue decoding. + */ +const char * +get_ret_type (metadata_t *m, const char *ptr, char **ret_type) +{ + GString *str = g_string_new (""); + char *mod = NULL; + char *allocated_type_string; + + ptr = get_custom_mod (m, ptr, &mod); + if (mod){ + g_string_append (str, mod); + g_string_append_c (str, ' '); + g_free (mod); + } + + if (*ptr == ELEMENT_TYPE_TYPEDBYREF){ + /* TODO: what does `typedbyref' mean? */ + g_string_append (str, "/* FIXME: What does this mean? */ typedbyref "); + ptr++; + } else if (*ptr == ELEMENT_TYPE_VOID){ + g_string_append (str, "void"); + ptr++; + } else { + if (*ptr == ELEMENT_TYPE_BYREF){ + g_string_append (str, "[out] "); + ptr++; + } + + ptr = get_type (m, ptr, &allocated_type_string); + g_string_append (str, allocated_type_string); + g_free (allocated_type_string); + } + + *ret_type = str->str; + g_string_free (str, FALSE); + + return ptr; +} + +/** + * get_param: + * @m: metadata context + * @ptr: location to decode from. + * @result: pointer to string where resulting decoded string is stored + * + * This routine returns in @result the stringified Param (22.2.10) + * + * Returns: the new ptr to continue decoding. + */ +const char * +get_param (metadata_t *m, const char *ptr, char **retval) +{ + GString *str = g_string_new (""); + char *allocated_mod_string, *allocated_type_string; + + ptr = get_custom_mod (m, ptr, &allocated_mod_string); + if (allocated_mod_string){ + g_string_append (str, allocated_mod_string); + g_string_append_c (str, ' '); + g_free (allocated_mod_string); + } + + if (*ptr == ELEMENT_TYPE_TYPEDBYREF){ + g_string_append (str, "/*FIXME: what does typedbyref mean? */ typedbyref "); + ptr++; + } else { + if (*ptr == ELEMENT_TYPE_BYREF){ + g_string_append (str, "[out] "); + ptr++; + } + ptr = get_type (m, ptr, &allocated_type_string); + g_string_append (str, allocated_type_string); + g_free (allocated_type_string); + } + + *retval = str->str; + g_string_free (str, FALSE); + return ptr; +} + +static map_t param_map [] = { + { PARAM_ATTRIBUTE_IN, "[in] " }, + { PARAM_ATTRIBUTE_OUT, "[out] " }, + { PARAM_ATTRIBUTE_OPTIONAL, "optional " }, + { PARAM_ATTRIBUTE_HAS_DEFAULT, "hasdefault " }, + { PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL, "fieldmarshal " }, + { 0, NULL } +}; + +char * +param_flags (guint32 f) +{ + return g_strdup (flags (f, param_map)); +} + +static map_t field_access_map [] = { + { FIELD_ATTRIBUTE_COMPILER_CONTROLLED, "compilercontrolled " }, + { FIELD_ATTRIBUTE_PRIVATE, "private " }, + { FIELD_ATTRIBUTE_FAM_AND_ASSEM, "famandassem " }, + { FIELD_ATTRIBUTE_ASSEMBLY, "assembly " }, + { FIELD_ATTRIBUTE_FAMILY, "family " }, + { FIELD_ATTRIBUTE_FAM_OR_ASSEM, "famorassem " }, + { FIELD_ATTRIBUTE_PUBLIC, "public " }, + { 0, NULL } +}; + +static map_t field_flags_map [] = { + { FIELD_ATTRIBUTE_STATIC, "static " }, + { FIELD_ATTRIBUTE_INIT_ONLY, "initonly " }, + { FIELD_ATTRIBUTE_LITERAL, "literal " }, + { FIELD_ATTRIBUTE_NOT_SERIALIZED, "notserialized " }, + { FIELD_ATTRIBUTE_SPECIAL_NAME, "specialname " }, + { FIELD_ATTRIBUTE_PINVOKE_IMPL, "FIXME:pinvokeimpl " }, + { 0, NULL } +}; + +/** + * field_flags: + * + * Returns a stringified version of a Field's flags + */ +char * +field_flags (guint32 f) +{ + static char buffer [1024]; + int access = f & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK; + + buffer [0] = 0; + + strcat (buffer, map (access, field_access_map)); + strcat (buffer, flags (f, field_flags_map)); + return g_strdup (buffer); +} + +/** + * get_blob_encoded_size: + * @ptr: pointer to a blob object + * @size: where we return the size of the object + * + * This decodes a compressed size as described by 23.1.4 + * + * Returns: the position to start decoding a blob or user string object + * from. + */ +const char * +get_blob_encoded_size (const char *xptr, int *size) +{ + const unsigned char *ptr = xptr; + + if ((*ptr & 0x80) == 0){ + *size = ptr [0] & 0x7f; + ptr++; + } else if ((*ptr & 0x40) == 0){ + *size = ((ptr [0] & 0x3f) << 8) + ptr [1]; + ptr += 2; + } else { + *size = ((ptr [0] & 0x1f) << 24) + + (ptr [1] << 16) + + (ptr [2] << 8) + + ptr [3]; + ptr += 4; + } + + return (char *) ptr; +} + +/** + * Returns a stringifed representation of a MethodRefSig (22.2.2) + */ +char * +get_methodref_signature (metadata_t *m, guint32 blob_signature, const char *fancy_name) +{ + GString *res = g_string_new (""); + const char *ptr = mono_metadata_blob_heap (m, blob_signature); + char *allocated_ret_type, *s; + gboolean seen_vararg = 0; + int param_count, signature_len; + int i; + + ptr = get_encoded_value (ptr, &signature_len); + + if (*ptr & 0x20){ + if (*ptr & 0x40) + g_string_append (res, "explicit-this "); + else + g_string_append (res, "instance "); /* has-this */ + } + + if (*ptr & 0x05) + seen_vararg = 1; + + ptr++; + ptr = get_encoded_value (ptr, ¶m_count); + ptr = get_ret_type (m, ptr, &allocated_ret_type); + + g_string_append (res, allocated_ret_type); + + if (fancy_name){ + g_string_append_c (res, ' '); + g_string_append (res, fancy_name); + } + + g_string_append (res, " ("); + + /* + * param_count describes parameters *before* and *after* + * the vararg sentinel + */ + for (i = 0; i < param_count; i++){ + char *param = NULL; + + /* + * If ptr is a SENTINEL + */ + if (*ptr == 0x41){ + g_string_append (res, " varargs "); + continue; + } + + ptr = get_param (m, ptr, ¶m); + g_string_append (res, param); + if (i+1 != param_count) + g_string_append (res, ", "); + g_free (param); + } + g_string_append (res, ")"); + + /* + * cleanup and return + */ + g_free (allocated_ret_type); + s = res->str; + g_string_free (res, FALSE); + return s; +} + +/* + * We use this to pass context information to the typedef locator + */ +typedef struct { + int idx; /* The field index that we are trying to locate */ + metadata_t *m; /* the metadata context */ + metadata_tableinfo_t *t; /* pointer to the typedef table */ + guint32 result; +} locator_t; + +static int +typedef_locator (const void *a, const void *b) +{ + locator_t *loc = (locator_t *) a; + char *bb = (char *) b; + int typedef_index = (bb - loc->t->base) / loc->t->row_size; + guint32 cols [6], cols_next [6]; + + expand (loc->t, typedef_index, cols, CSIZE (cols)); + + if (loc->idx < cols [4]) + return -1; + + /* + * Need to check that the next row is valid. + */ + if (typedef_index + 1 < loc->t->rows) { + expand (loc->t, typedef_index + 1, cols_next, CSIZE (cols_next)); + if (loc->idx >= cols_next [4]) + return 1; + + if (cols [4] == cols_next [4]) + return 1; + } + + loc->result = typedef_index; + + return 0; +} + +/** + * get_field: + * @m: metadata context + * @token: a FIELD_DEF token + * + * This routine has to locate the TypeDef that "owns" this Field. + * Since there is no backpointer in the Field table, we have to scan + * the TypeDef table and locate the actual "owner" of the field + */ +char * +get_field (metadata_t *m, guint32 token) +{ + int idx = mono_metadata_token_index (token); + metadata_tableinfo_t *tdef = &m->tables [META_TABLE_TYPEDEF]; + guint32 cols [3]; + char *sig, *res, *type; + locator_t loc; + + /* + * We can get here also with a MenberRef token (for a field + * defined in another module/assembly, just like in get_method () + */ + if (mono_metadata_token_code (token) == TOKEN_TYPE_MEMBER_REF) { + return g_strdup_printf ("fieldref-0x%08x", token); + } + g_assert (mono_metadata_token_code (token) == TOKEN_TYPE_FIELD_DEF); + + expand (&m->tables [META_TABLE_FIELD], idx - 1, cols, CSIZE (cols)); + sig = get_field_signature (m, cols [2]); + + /* + * To locate the actual "container" for this field, we have to scan + * the TypeDef table. LAME! + */ + loc.idx = idx; + loc.m = m; + loc.t = tdef; + + if (!bsearch (&loc, tdef->base, tdef->rows, tdef->row_size, typedef_locator)) + g_assert_not_reached (); + + /* loc_result is 0..1, needs to be mapped to table index (that is +1) */ + type = get_typedef (m, loc.result + 1); + res = g_strdup_printf ("%s %s.%s", + sig, type, + mono_metadata_string_heap (m, cols [1])); + g_free (type); + g_free (sig); + + return res; +} + +static char * +get_memberref_parent (metadata_t *m, guint32 mrp_token) +{ + /* + * mrp_index is a MemberRefParent coded index + */ + guint32 table = mrp_token & 7; + guint32 idx = mrp_token >> 3; + + switch (table){ + case 0: /* TypeDef */ + return get_typedef (m, idx); + + case 1: /* TypeRef */ + return get_typeref (m, idx); + + case 2: /* ModuleRef */ + return g_strdup_printf ("TODO:MemberRefParent-ModuleRef"); + + case 3: /* MethodDef */ + return g_strdup ("TODO:MethodDef"); + + case 4: /* TypeSpec */ + return get_typespec (m, idx); + } + g_assert_not_reached (); + return NULL; +} + +/** + * get_method: + * @m: metadata context + * @token: a METHOD_DEF or MEMBER_REF token + * + * This routine has to locate the TypeDef that "owns" this Field. + * Since there is no backpointer in the Field table, we have to scan + * the TypeDef table and locate the actual "owner" of the field + */ +char * +get_method (metadata_t *m, guint32 token) +{ + int idx = mono_metadata_token_index (token); + guint32 member_cols [3]; + char *res, *class, *fancy_name; + + switch (mono_metadata_token_code (token)){ + case TOKEN_TYPE_METHOD_DEF: + return g_strdup_printf ("TODO:MethodDef call [%x]", token); + + case TOKEN_TYPE_MEMBER_REF: { + char *sig; + + expand (&m->tables [META_TABLE_MEMBERREF], idx - 1, member_cols, CSIZE (member_cols)); + class = get_memberref_parent (m, member_cols [0]); + fancy_name = g_strconcat (class, "::", + mono_metadata_string_heap (m, member_cols [1]), + NULL); + + sig = get_methodref_signature ( + m, member_cols [2], fancy_name); + res = g_strdup_printf ("%s", sig); + g_free (sig); + + return res; + } + + default: + g_assert_not_reached (); + } + g_assert_not_reached (); + return NULL; +} + +/** + * get_constant: + * @m: metadata context + * @blob_index: index into the blob where the constant is stored + * + * Returns: An allocated value representing a stringified version of the + * constant. + */ +char * +get_constant (metadata_t *m, ElementTypeEnum t, guint32 blob_index) +{ + const char *ptr = mono_metadata_blob_heap (m, blob_index); + int len; + + ptr = get_encoded_value (ptr, &len); + + switch (t){ + case ELEMENT_TYPE_BOOLEAN: + return g_strdup_printf ("%s", *ptr ? "true" : "false"); + + case ELEMENT_TYPE_CHAR: + return g_strdup_printf ("%c", *ptr); + + case ELEMENT_TYPE_U1: + return g_strdup_printf ("0x%02x", (int) (*ptr)); + break; + + case ELEMENT_TYPE_I2: + return g_strdup_printf ("%d", (int) (*(gint16 *) ptr)); + + case ELEMENT_TYPE_I4: + return g_strdup_printf ("%d", *(gint32 *) ptr); + + case ELEMENT_TYPE_I8: + /* + * FIXME: This is not endian portable, does only + * matter for debugging, but still. + */ + return g_strdup_printf ("0x%08x%08x", *(guint32 *) ptr, *(guint32 *) (ptr + 4)); + + case ELEMENT_TYPE_U8: + return g_strdup_printf ("0x%08x%08x", *(guint32 *) ptr, *(guint32 *) (ptr + 4)); + case ELEMENT_TYPE_R4: + return g_strdup_printf ("%g", (double) (* (float *) ptr)); + + case ELEMENT_TYPE_R8: + return g_strdup_printf ("%g", * (double *) ptr); + + case ELEMENT_TYPE_STRING: { + int len, i, j, e; + char *res; + e = len = 0; + for (i = 0; !ptr [i+1]; i += 2){ + len++; + switch (ptr [i]) { + case '"': + case '\\': + case '\n': /* add more */ + e++; + } + } + res = g_malloc (len + e + 3); + j = 1; + res [0] = '"'; + + for (i = 0; i < len; i += 2){ + switch(ptr[i]) { + case '"': + res[j++] = '\\'; + res[j++] = '"'; + case '\\': + res[j++] = '\\'; + res[j++] = '\\'; + case '\n': + res[j++] = '\\'; + res[j++] = 'n'; + break; + default: + res[j++] = isprint (ptr [i]) ? ptr [i] : '.'; + break; + } + } + res[j++] = '"'; + res[j] = 0; + return res; + } + + case ELEMENT_TYPE_CLASS: + return g_strdup ("CLASS CONSTANT. MUST BE ZERO"); + + /* + * These are non CLS compliant: + */ + case ELEMENT_TYPE_I1: + return g_strdup_printf ("%d", (int) *ptr); + + case ELEMENT_TYPE_U2: + return g_strdup_printf ("0x%04x", (unsigned int) (*(guint16 *) ptr)); + + case ELEMENT_TYPE_U4: + return g_strdup_printf ("0x%04x", (unsigned int) (*(guint32 *) ptr)); + + default: + g_error ("Unknown ELEMENT_TYPE (%d) on constant at Blob index (0x%08x)\n", + (int) *ptr, blob_index); + return g_strdup_printf ("Unknown"); + } + +} + +/** + * get_token: + * @m: metadata context + * @token: token that we want to decode. + * + * Returns: An allocated value representing a stringified version of the + * constant. + */ +char * +get_token (metadata_t *m, guint32 token) +{ + switch (mono_metadata_token_code (token)){ + case TOKEN_TYPE_FIELD_DEF: + return (get_field (m, token)); + + default: + g_error ("Do not know how to decode tokens of type 0x%08x", token); + } + + g_assert_not_reached (); + return g_strdup ("ERROR"); +} + +/** + * get_token_type: + * @m: metadata context + * @token: the token can belong to any of the following tables: + * TOKEN_TYPE_TYPE_REF, TOKEN_TYPE_TYPE_DEF, TOKEN_TYPE_TYPE_SPEC + * + * Returns: a stringified version of the MethodDef or MethodRef or TypeSpecn + * at (token & 0xffffff) + */ +char * +get_token_type (metadata_t *m, guint32 token) +{ + char *temp = NULL, *s; + int idx; + + idx = mono_metadata_token_index (token); + + switch (mono_metadata_token_code (token)){ + case TOKEN_TYPE_TYPE_DEF: + temp = get_typedef (m, idx); + s = g_strdup_printf ("%s", temp); + break; + + case TOKEN_TYPE_TYPE_REF: + temp = get_typeref (m, idx); + s = g_strdup_printf ("%s", temp); + break; + + case TOKEN_TYPE_TYPE_SPEC: + s = get_typespec (m, idx); + break; + + default: + g_error ("Unhandled encoding for typedef-or-ref coded index"); + + } + + if (temp) + g_free (temp); + + return s; +} diff --git a/mono/dis/get.h b/mono/dis/get.h new file mode 100644 index 00000000000..b67b5510720 --- /dev/null +++ b/mono/dis/get.h @@ -0,0 +1,56 @@ + +/* + * These return allocated strings + */ +char *get_typedef (metadata_t *m, int idx); +char *get_module (metadata_t *m, int idx); +char *get_assemblyref (metadata_t *m, int idx); +char *get_typeref (metadata_t *m, int idx); +char *get_typedef_or_ref (metadata_t *m, guint32 dor_token); +char *get_field_signature (metadata_t *m, guint32 blob_signature); +char *decode_literal (metadata_t *m, guint32 token); +char *get_field (metadata_t *m, guint32 token); +char *param_flags (guint32 f); +char *field_flags (guint32 f); +char *get_methodref_signature (metadata_t *m, guint32 blob_signature, const char *fancy); +char *get_constant (metadata_t *m, ElementTypeEnum t, guint32 blob_index); +char *get_token (metadata_t *m, guint32 token); +char *get_token_type (metadata_t *m, guint32 token); +char *get_typespec (metadata_t *m, guint32 blob_idx); +char *get_method (metadata_t *m, guint32 token); + + +char *dis_stringify_type (metadata_t *m, MonoType *type); +char *dis_stringify_token (metadata_t *m, guint32 token); +char *dis_stringify_array (metadata_t *m, MonoArray *array); +char *dis_stringify_modifiers (metadata_t *m, int n, MonoCustomMod *mod); +char *dis_stringify_param (metadata_t *m, MonoParam *param); +char *dis_stringify_method_signature (metadata_t *m, MonoMethodSignature *method); + +/* + * These functions are used during the decoding of streams in the + * metadata heaps (a simple parsing). + * + * They return the `next' location to continue parsing from (ptr is + * the starting location). + * + * Results are returning in the pointer argument. + */ +const char *get_encoded_typedef_or_ref (metadata_t *m, const char *ptr, + char **result); +const char *get_encoded_value (const char *_ptr, + guint32 *len); +const char *get_custom_mod (metadata_t *m, const char *ptr, + char **return_value); +const char *get_type (metadata_t *m, const char *ptr, + char **result); +const char *get_ret_type (metadata_t *m, const char *ptr, + char **ret_type); +const char *get_param (metadata_t *m, const char *ptr, + char **retval); +const char *get_blob_encoded_size (const char *ptr, int *size); + +void expand (metadata_tableinfo_t *t, int idx, guint32 *res, int res_size); + + +ElementTypeEnum get_field_literal_type (metadata_t *m, guint32 blob_signature); diff --git a/mono/dis/main.c b/mono/dis/main.c index 49f9027c1e2..659e4883e7c 100644 --- a/mono/dis/main.c +++ b/mono/dis/main.c @@ -1,22 +1,34 @@ /* - * dis.c: Sample disassembler + * main.c: Sample disassembler * * Author: * Miguel de Icaza (miguel@ximian.com) * * (C) 2001 Ximian, Inc. + * + * TODO: + * Investigate how interface inheritance works and how it should be dumped. + * Structs are not being labeled as `valuetype' classes + * + * How are fields with literals mapped to constants? */ #include <config.h> #include <stdio.h> +#include <string.h> #include <glib.h> -#include <mono/metadata/assembly.h> -#include <mono/metadata/cil-coff.h> +#include "meta.h" +#include "util.h" +#include "dump.h" +#include "get.h" +#include "dis-cil.h" FILE *output; /* True if you want to get a dump of the header data */ gboolean dump_header_data_p = FALSE; +int dump_table = -1; + static void dump_header_data (MonoAssembly *ass) { @@ -29,26 +41,595 @@ dump_header_data (MonoAssembly *ass) } static void +dis_directive_assembly (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_ASSEMBLY]; + guint32 cols [9]; + + if (t->base == NULL) + return; + + expand (t, 0, cols, CSIZE (cols)); + + fprintf (output, + ".assembly %s\n" + "{\n" + " .hash algorithm 0x%08x\n" + " .ver %d.%d.%d.%d" + "%s %s" + "%s" + "\n" + "}\n", + mono_metadata_string_heap (m, cols [7]), + cols [0], + cols [1], cols [2], cols [3], cols [4], + cols [8] ? "\n .locale" : "", + cols [8] ? mono_metadata_string_heap (m, cols [8]) : "", + cols [6] ? "\n .publickey" : "" + ); +} + +static void +dis_directive_assemblyref (metadata_t *m) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_ASSEMBLYREF]; + guint32 cols [9]; + int i; + + if (t->base == NULL) + return; + + for (i = 0; i < t->rows; i++){ + expand (t, i, cols, CSIZE (cols)); + + fprintf (output, + ".assembly extern %s\n" + "{\n" + " .ver %d.%d.%d.%d\n" + "}\n", + mono_metadata_string_heap (m, cols [6]), + cols [0], cols [1], cols [2], cols [3] + ); + } +} + +static map_t visibility_map [] = { + { TYPE_ATTRIBUTE_NOT_PUBLIC, "private " }, + { TYPE_ATTRIBUTE_PUBLIC, "public " }, + { TYPE_ATTRIBUTE_NESTED_PUBLIC, "nested-public " }, + { TYPE_ATTRIBUTE_NESTED_PRIVATE, "nested-private " }, + { TYPE_ATTRIBUTE_NESTED_FAMILY, "family " }, + { TYPE_ATTRIBUTE_NESTED_ASSEMBLY, "nested-assembly" }, + { TYPE_ATTRIBUTE_NESTED_FAM_AND_ASSEM, "nested-fam-and-assembly" }, + { TYPE_ATTRIBUTE_NESTED_FAM_OR_ASSEM, "nested-fam-or-assembly" }, + { 0, NULL } +}; + +static map_t layout_map [] = { + { TYPE_ATTRIBUTE_AUTO_LAYOUT, "auto " }, + { TYPE_ATTRIBUTE_SEQUENTIAL_LAYOUT, "sequential " }, + { TYPE_ATTRIBUTE_EXPLICIT_LAYOUT, "explicit " }, + { 0, NULL } +}; + +static map_t format_map [] = { + { TYPE_ATTRIBUTE_ANSI_CLASS, "ansi " }, + { TYPE_ATTRIBUTE_UNICODE_CLASS, "unicode " }, + { TYPE_ATTRIBUTE_AUTO_CLASS, "auto " }, + { 0, NULL } +}; + +static char * +typedef_flags (guint32 flags) +{ + static char buffer [1024]; + int visibility = flags & TYPE_ATTRIBUTE_VISIBILITY_MASK; + int layout = flags & TYPE_ATTRIBUTE_LAYOUT_MASK; + int format = flags & TYPE_ATTRIBUTE_STRING_FORMAT_MASK; + + buffer [0] = 0; + + strcat (buffer, map (visibility, visibility_map)); + strcat (buffer, map (layout, layout_map)); + strcat (buffer, map (format, format_map)); + + if (flags & TYPE_ATTRIBUTE_ABSTRACT) + strcat (buffer, "abstract "); + if (flags & TYPE_ATTRIBUTE_SEALED) + strcat (buffer, "sealed "); + if (flags & TYPE_ATTRIBUTE_SPECIAL_NAME) + strcat (buffer, "special-name "); + if (flags & TYPE_ATTRIBUTE_IMPORT) + strcat (buffer, "import "); + if (flags & TYPE_ATTRIBUTE_SERIALIZABLE) + strcat (buffer, "serializable "); + if (flags & TYPE_ATTRIBUTE_BEFORE_FIELD_INIT) + strcat (buffer, "beforefieldinit "); + + return buffer; +} + +/** + * dis_field_list: + * @m: metadata context + * @start: starting index into the Field Table. + * @end: ending index into Field table. + * + * This routine displays all the decoded fields from @start to @end + */ +static void +dis_field_list (metadata_t *m, guint32 start, guint32 end) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_FIELD]; + guint32 cols [3]; + int i; + + if (end > t->rows + 1) { + g_warning ("ERROR index out of range in fields"); + end = t->rows; + } + + for (i = start; i < end; i++){ + char *sig, *flags; + + expand (t, i, cols, CSIZE (cols)); + sig = get_field_signature (m, cols [2]); + flags = field_flags (cols [0]); + + if (cols [0] & FIELD_ATTRIBUTE_LITERAL){ + ElementTypeEnum type; + char *lit; + + type = get_field_literal_type (m, cols [2]); + lit = g_strdup ("FIXME:Do-not-know-how-to-get-this-from-the-constants-table"); + /* get_constant (m, type, cols [2]); */ + + fprintf (output, " .field %s %s %s = ", + flags, sig, + mono_metadata_string_heap (m, cols [1])); + fprintf (output, "%s\n", lit); + g_free (lit); + } else + fprintf (output, " .field %s %s %s\n", + flags, sig, + mono_metadata_string_heap (m, cols [1])); + g_free (flags); + g_free (sig); + } +} + +static map_t method_access_map [] = { + { METHOD_ATTRIBUTE_COMPILER_CONTROLLED, "compilercontrolled " }, + { METHOD_ATTRIBUTE_PRIVATE, "private" }, + { METHOD_ATTRIBUTE_FAM_AND_ASSEM, "famandassem" }, + { METHOD_ATTRIBUTE_ASSEM, "assembly " }, + { METHOD_ATTRIBUTE_FAMILY, "family " }, + { METHOD_ATTRIBUTE_FAM_OR_ASSEM, "famorassem " }, + { METHOD_ATTRIBUTE_PUBLIC, "public " }, + { 0, NULL } +}; + +static map_t method_flags_map [] = { + { METHOD_ATTRIBUTE_STATIC, "static " }, + { METHOD_ATTRIBUTE_FINAL, "final " }, + { METHOD_ATTRIBUTE_VIRTUAL, "virtual " }, + { METHOD_ATTRIBUTE_HIDE_BY_SIG, "hidebysig " }, + { METHOD_ATTRIBUTE_VTABLE_LAYOUT_MASK, "newslot " }, + { METHOD_ATTRIBUTE_ABSTRACT, "abstract " }, + { METHOD_ATTRIBUTE_SPECIAL_NAME, "specialname " }, + { METHOD_ATTRIBUTE_RT_SPECIAL_NAME, "rtspecialname " }, + { METHOD_ATTRIBUTE_PINVOKE_IMPL, "pinvokeimpl " }, + { METHOD_ATTRIBUTE_UNMANAGED_EXPORT, "export " }, + { METHOD_ATTRIBUTE_HAS_SECURITY, "hassecurity" }, + { METHOD_ATTRIBUTE_REQUIRE_SEC_OBJECT, "requiresecobj" }, + { 0, NULL } +}; + +/** + * method_flags: + * + * Returns a stringified version of the Method's flags + */ +static char * +method_flags (guint32 f) +{ + GString *str = g_string_new (""); + int access = f & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK; + char *s; + + g_string_append (str, map (access, method_access_map)); + g_string_append (str, flags (f, method_flags_map)); + + s = str->str; + g_string_free (str, FALSE); + + return s; +} + +static map_t method_impl_map [] = { + { METHOD_IMPL_ATTRIBUTE_IL, "cil " }, + { METHOD_IMPL_ATTRIBUTE_NATIVE, "native " }, + { METHOD_IMPL_ATTRIBUTE_OPTIL, "optil " }, + { METHOD_IMPL_ATTRIBUTE_RUNTIME, "runtime " }, + { 0, NULL } +}; + +static map_t managed_type_map [] = { + { METHOD_IMPL_ATTRIBUTE_UNMANAGED, "unmanaged " }, + { METHOD_IMPL_ATTRIBUTE_MANAGED, "managed " }, + { 0, NULL } +}; + +static map_t managed_impl_flags [] = { + { METHOD_IMPL_ATTRIBUTE_FORWARD_REF, "fwdref " }, + { METHOD_IMPL_ATTRIBUTE_PRESERVE_SIG, "preservesig " }, + { METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL, "internalcall " }, + { METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED, "synchronized " }, + { METHOD_IMPL_ATTRIBUTE_NOINLINING, "noinline " }, + { 0, NULL } +}; + +static char * +method_impl_flags (guint32 f) +{ + GString *str = g_string_new (""); + char *s; + int code_type = f & METHOD_IMPL_ATTRIBUTE_CODE_TYPE_MASK; + int managed_type = f & METHOD_IMPL_ATTRIBUTE_MANAGED_MASK; + + g_string_append (str, map (code_type, method_impl_map)); + g_string_append (str, map (managed_type, managed_type_map)); + g_string_append (str, flags (f, managed_impl_flags)); + + s = str->str; + g_string_free (str, FALSE); + return s; +} + +static void +dis_locals (metadata_t *m, guint32 token) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_STANDALONESIG]; + const char *ptr; + guint32 cols[1]; + int len=0, i, bsize; + + expand (t, (token&0xffffff)-1, cols, CSIZE(cols)); + ptr = mono_metadata_blob_heap (m, cols[0]); + ptr = get_blob_encoded_size (ptr, &bsize); + if (*ptr != 0x07) + g_warning("wrong signature for locals blob"); + ptr++; + ptr = get_encoded_value (ptr, &len); + fprintf(output, "\t.locals ( // %d\n", len); + for (i=0; i < len; ++i) { + int val; + char * desc = NULL; + const char *p = ptr; + MonoType *type; + ptr = get_encoded_value (ptr, &val); + if (val == ELEMENT_TYPE_PINNED) { + fprintf(output, "//pinned\n"); + p = ptr; + ptr = get_encoded_value (ptr, &val); + } + if (val == ELEMENT_TYPE_BYREF) { + fprintf(output, "// byref\n"); + p = ptr; + } + type = mono_metadata_parse_type (m, p, &ptr); + desc = dis_stringify_type (m, type); + mono_metadata_free_type (type); + fprintf(output, "\t\t%s\tV_%d\n", desc, i); + g_free(desc); + } + fprintf(output, "\t)\n"); +} + +static void +dis_code (metadata_t *m, cli_image_info_t *ii, guint32 rva) +{ + MonoMetaMethodHeader *mh; + const char *ptr = cli_rva_map (ii, rva); + char *loc; + + if (rva == 0) + return; + + mh = mono_metadata_parse_mh (m, ptr); + loc = mono_metadata_locate_token (m, ii->cli_cli_header.ch_entry_point); + if (rva == read32(loc)) + fprintf (output, "\t.entrypoint\n"); + fprintf (output, "\t.maxstack %d\n", mh->max_stack); + fprintf (output, "\t// Code size=%d (0x%x)\n", mh->code_size, mh->code_size); + printf ("\t// Values Code Size=%d/0x%x\n\t// LocalTok=%x\n\n", + mh->code_size, mh->code_size, mh->local_var_sig_tok); + if (mh->local_var_sig_tok) + dis_locals (m, mh->local_var_sig_tok); + dissasemble_cil (m, mh->code, mh->code_size); + +/* + hex_dump (mh->code, 0, mh->code_size); + printf ("\nAfter the code\n"); + hex_dump (mh->code + mh->code_size, 0, 64); +*/ + mono_metadata_free_mh (mh); +} + +typedef struct { + char flags; + char *ret_type; + int param_count; + char **param; +} MethodSignature; + +/** + * parse_method_signature: + * @m: metadata context + * @blob_signature: pointer to the signature in the Blob heap + * + * 22.2.1: MethodDefSig. + * + * Returns the parsed information in the MethodSignature structure + * needs to be deallocated with free_method_signature(). + */ +static MethodSignature * +parse_method_signature (metadata_t *m, guint32 blob_signature) +{ + const char *ptr = mono_metadata_blob_heap (m, blob_signature); + MethodSignature *ms = g_new0 (MethodSignature, 1); + int i, len; + + ptr = get_encoded_value (ptr, &len); + fprintf (output, " // SIG: "); + hex_dump (ptr, 0, -len); + fprintf (output, "\n"); + + ms->flags = *ptr++; + + ptr = get_encoded_value (ptr, &ms->param_count); + ptr = get_ret_type (m, ptr, &ms->ret_type); + ms->param = g_new (char *, ms->param_count); + + for (i = 0; i < ms->param_count; i++) + ptr = get_param (m, ptr, &(ms->param [i])); + + return ms; +} + +static void +free_method_signature (MethodSignature *ms) +{ + int i; + + for (i = 0; i < ms->param_count; i++) + g_free (ms->param [i]); + g_free (ms->param); + g_free (ms->ret_type); + g_free (ms); +} + +/** + * dis_method_list: + * @m: metadata context + * @start: starting index into the Method Table. + * @end: ending index into Method table. + * + * This routine displays the methods in the Method Table from @start to @end + */ +static void +dis_method_list (metadata_t *m, cli_image_info_t *ii, guint32 start, guint32 end) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_METHOD]; + metadata_tableinfo_t *p = &m->tables [META_TABLE_PARAM]; + guint32 cols [6]; + guint32 cols_next [6]; + guint32 param_cols [3]; + int i; + + if (end > t->rows){ + fprintf (output, "ERROR index out of range in methods"); + /*exit (1);*/ + end = t->rows; + } + + for (i = start; i < end; i++){ + MethodSignature *ms; + char *flags, *impl_flags; + + expand (t, i, cols, CSIZE (cols)); + expand (t, i + 1, cols_next, CSIZE (cols_next)); + + flags = method_flags (cols [2]); + impl_flags = method_impl_flags (cols [1]); + + ms = parse_method_signature (m, cols [4]); + + fprintf (output, + " .method %s\n", + flags); + fprintf (output, + " %s %s", + ms->ret_type, + mono_metadata_string_heap (m, cols [3])); + if (ms->param_count > 0){ + int i; + + fprintf (output, "(\n"); + for (i = 0; i < ms->param_count; i++){ + char *pf; + + expand (p, i, param_cols, CSIZE (param_cols)); + pf = param_flags (param_cols [0]); + fprintf ( + output, "\t\t%s %s %s%s", pf, ms->param [i], + mono_metadata_string_heap (m, param_cols [2]), + (i+1 == ms->param_count) ? ")" : ",\n"); + + g_free (pf); + } + + } + fprintf (output, " %s\n", impl_flags); + g_free (flags); + g_free (impl_flags); + + fprintf (output, " {\n"); + fprintf (output, " // Method begins at RVA 0x%x\n", cols [0]); + dis_code (m, ii, cols [0]); + fprintf (output, " }\n\n"); + free_method_signature (ms); + } +} + +/** + * dis_type: + * @m: metadata context + * @n: index of type to disassemble + * + * Disassembles the type whose index in the TypeDef table is @n. + */ +static void +dis_type (metadata_t *m, cli_image_info_t *ii, int n) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_TYPEDEF]; + guint32 cols [6]; + guint32 cols_next [6]; + const char *name; + gboolean next_is_valid, last; + + expand (t, n, cols, CSIZE (cols)); + + if (t->rows > n+1){ + expand (t, n + 1, cols_next, CSIZE (cols_next)); + next_is_valid = 1; + } else + next_is_valid = 0; + + fprintf (output, ".namespace %s\n{\n", mono_metadata_string_heap (m, cols [2])); + name = mono_metadata_string_heap (m, cols [1]); + + if ((cols [0] & TYPE_ATTRIBUTE_CLASS_SEMANTIC_MASK) == TYPE_ATTRIBUTE_CLASS){ + char *base = get_typedef_or_ref (m, cols [3]); + fprintf (output, " .class %s%s\n", typedef_flags (cols [0]), name); + fprintf (output, " \textends %s\n", base); + g_free (base); + } else + fprintf (output, " .class interface %s%s\n", typedef_flags (cols [0]), name); + + fprintf (output, " {\n"); + + /* + * The value in the table is always valid, we know we have fields + * if the value stored is different than the next record. + */ + + if (next_is_valid) + last = cols_next [4] - 1; + else + last = m->tables [META_TABLE_FIELD].rows; + + /*if (cols [4] != cols_next [4] && cols_next [4] != 0) + dis_field_list (m, cols [4] - 1, last);*/ + if (cols[4] && cols[4] <= m->tables [META_TABLE_FIELD].rows) + dis_field_list (m, cols [4] - 1, last); + /*fprintf (output, "cols[4] -> %d cols_next[4] -> %d last -> %d rows -> %d\n", cols[4], cols_next[4], last, m->tables [META_TABLE_FIELD].rows);*/ + fprintf (output, "\n"); + + if (next_is_valid) + last = cols_next [5] - 1; + else + last = m->tables [META_TABLE_METHOD].rows; + + /*if (cols [4] != cols_next [5] && cols_next [5] != 0) + dis_method_list (m, ii, cols [5] - 1, last);*/ + /*fprintf (output, "method(%d): cols[5] -> %d cols_next[5] -> %d last -> %d rows -> %d\n", next_is_valid, cols[5], cols_next[5], last, m->tables [META_TABLE_METHOD].rows);*/ + if (cols [5] < m->tables [META_TABLE_METHOD].rows) + dis_method_list (m, ii, cols [5]-1, last); + + fprintf (output, " }\n}\n\n"); +} + +/** + * dis_types: + * @m: metadata context + * + * disassembles all types in the @m context + */ +static void +dis_types (metadata_t *m, cli_image_info_t *ii) +{ + metadata_tableinfo_t *t = &m->tables [META_TABLE_TYPEDEF]; + int i; + + for (i = 1; i < t->rows; i++) + dis_type (m, ii, i); +} + +struct { + char *name; + int table; + void (*dumper) (metadata_t *m); +} table_list [] = { + { "--assembly", META_TABLE_ASSEMBLY, dump_table_assembly }, + { "--assemblyref", META_TABLE_ASSEMBLYREF, dump_table_assemblyref }, + { "--fields", META_TABLE_FIELD, dump_table_field }, + { "--memberref", META_TABLE_MEMBERREF, dump_table_memberref }, + { "--param", META_TABLE_PARAM, dump_table_param }, + { "--typedef", META_TABLE_TYPEDEF, dump_table_typedef }, + { "--typeref", META_TABLE_TYPEREF, dump_table_typeref }, + { "--classlayout", META_TABLE_CLASSLAYOUT, dump_table_class_layout }, + { "--constant", META_TABLE_CONSTANT, dump_table_constant }, + { "--property", META_TABLE_PROPERTY, dump_table_property }, + { "--event", META_TABLE_EVENT, dump_table_event }, + { "--file", META_TABLE_FILE, dump_table_file }, + { "--moduleref", META_TABLE_MODULEREF, dump_table_moduleref }, + { "--method", META_TABLE_METHOD, dump_table_method }, + { NULL, -1 } +}; + +/** + * disassemble_file: + * @file: file containing CIL code. + * + * Disassembles the @file file. + */ +static void disassemble_file (const char *file) { enum MonoAssemblyOpenStatus status; MonoAssembly *ass; + cli_image_info_t *ii; + metadata_t *m; + + fprintf (output, "// Disassembling %s\n", file); ass = mono_assembly_open (file, &status); if (ass == NULL){ fprintf (stderr, "Error while trying to process %s\n", file); - + return; } - dump_header_data (ass); - + ii = ass->image_info; + m = &ii->cli_metadata; + + if (dump_table != -1){ + (*table_list [dump_table].dumper) (m); + } else { + dump_header_data (ass); + + dis_directive_assemblyref (m); + dis_directive_assembly (m); + dis_types (m, ii); + } + mono_assembly_close (ass); } static void usage (void) { - fprintf (stderr, "Usage is: monodis file1 ..\n"); + fprintf (stderr, "Usage is: monodis [--typeref][--typedef][--assemblyref][--param][--fields][--memberref] file ..\n"); exit (1); } @@ -56,7 +637,7 @@ int main (int argc, char *argv []) { GList *input_files = NULL, *l; - int i; + int i, j; output = stdout; for (i = 1; i < argc; i++){ @@ -65,6 +646,11 @@ main (int argc, char *argv []) usage (); else if (argv [i][1] == 'd') dump_header_data_p = TRUE; + else if (strcmp (argv [i], "--help") == 0) + usage (); + for (j = 0; table_list [j].name != NULL; j++) + if (strcmp (argv [i], table_list [j].name) == 0) + dump_table = j; } else input_files = g_list_append (input_files, argv [i]); } @@ -74,4 +660,6 @@ main (int argc, char *argv []) for (l = input_files; l; l = l->next) disassemble_file (l->data); + + return 0; } diff --git a/mono/dis/meta.h b/mono/dis/meta.h new file mode 100644 index 00000000000..8d8629d921d --- /dev/null +++ b/mono/dis/meta.h @@ -0,0 +1,10 @@ +#include <mono/metadata/assembly.h> +#include <mono/metadata/cil-coff.h> +#include <mono/metadata/endian.h> +#include <mono/metadata/typeattr.h> +#include <mono/metadata/fieldattr.h> +#include <mono/metadata/methodattr.h> +#include <mono/metadata/eltype.h> +#include <mono/metadata/blobsig.h> +#include <mono/metadata/paramattr.h> +#include <mono/metadata/tokentype.h> diff --git a/mono/dis/monodis.1 b/mono/dis/monodis.1 new file mode 100644 index 00000000000..7880d8d4aa2 --- /dev/null +++ b/mono/dis/monodis.1 @@ -0,0 +1,41 @@ +.\" +.\" monodis manual page. +.\" (C) Ximian, Inc. +.\" Author: +.\" Miguel de Icaza (miguel@gnu.org) +.\" +.TH Mono "Mono 1.0" +.SH NAME +monodis \- CIL image content dumper and disassembler. +.SH SYNOPSIS +.PP +.B monodis +[\-hd] [\-\-help] +[\-\-typeref] +[\-\-typedefl] +[\-\-assemblyref] +[FILES...] +.SH DESCRIPTION +The \fImonodis\fP program is used to dump the contents a CIL image +(contained in .EXE files that contain extended PE/COFF CIL code). +.SH OPTIONS +The following Generic options are supported: +.TP +.I "--help", "-h" +Displays usage instructions. +.TP +.I "--typeref" +Dumps the contents of the typeref table. +.TP +.I "--typedef" +Dumps the contents of the typedef table. +.TP +.I "--assemblyref" +Dumps the contents of the assemblyref table. +.PP +If no flags are specified the program dumps the content of the image +in a format that can be used to rountrip the code. +.SH AUTHOR +gnome-config was written by Miguel de Icaza +.SH SEE ALSO +.BR pedump(1), diff --git a/mono/dis/push-pop.h b/mono/dis/push-pop.h new file mode 100644 index 00000000000..f74252e4327 --- /dev/null +++ b/mono/dis/push-pop.h @@ -0,0 +1,265 @@ +/* Poping */ +/* 1 bit */ +#define Pop0 1 +/* 2 bits */ +#define Pop1 2 +/* 3 bits */ +#define PopI 8 +/* 1 bit */ +#define PopI8 64 +/* 1 bit */ +#define Pop8 128 +/* 1 bit */ +#define PopR4 256 +/* 1 bit */ +#define PopR8 512 +/* 1 bit */ +#define PopRef 1024 +/* 1 bit */ +#define VarPop 2048 + +/* Pushing */ +#define Push0 1 +#define PushI 2 +#define PushI8 4 +#define PushR4 8 +#define PushR8 16 +#define PushRef 32 +#define VarPush 64 +#define Push1 128 + +/* + * dis-cil.c: Disassembles CIL byte codes + * + * Author: + * Miguel de Icaza (miguel@ximian.com) + * + * (C) 2001 Ximian, Inc. + */ +#include <config.h> +#include <glib.h> +#include <stdio.h> +#include "meta.h" +#include "dump.h" +#include "dis-cil.h" + +/* Poping */ +/* 1 bit */ +#define Pop0 1 +/* 2 bits */ +#define Pop1 2 +/* 3 bits */ +#define PopI 8 +/* 1 bit */ +#define PopI8 64 +/* 1 bit */ +#define Pop8 128 +/* 1 bit */ +#define PopR4 256 +/* 1 bit */ +#define PopR8 512 +/* 1 bit */ +#define PopRef 1024 +/* 1 bit */ +#define VarPop 2048 + +/* Pushing */ +#define Push0 1 +#define PushI 2 +#define PushI8 4 +#define PushR4 8 +#define PushR8 16 +#define PushRef 32 +#define VarPush 64 +#define Push1 128 + +enum { + InlineBrTarget, + InlineField, + InlineI, + InlineI8, + InlineMethod, + InlineNone, + InlineR, + InlineSig, + InlineString, + InlineSwitch, + InlineTok, + InlineType, + InlineVar, + ShortInlineBrTarget, + ShortInlineI, + ShortInlineR, + ShortInlineVar +}; + +#define OPDEF(a,b,c,d,e,f,g,h,i,j) \ + { b, c, d, e, g, h, i }, + +typedef struct { + char *name; + int pop, push; + int argument; + int bytes; + unsigned char o1, o2; +} opcode_t; + +static opcode_t opcodes [300] = { +#include "mono/cil/opcode.def" +}; + +void +dissasemble_cil (metadata_t *m, const unsigned char *start, int size) +{ + const unsigned char *end = start + size; + const unsigned char *ptr = start; + opcode_t *entry; + + while (ptr < end){ + if (*ptr == 0xfe){ + ptr++; + entry = &opcodes [*ptr + 256]; + } else + entry = &opcodes [*ptr]; + + ptr++; + + fprintf (output, "\tIL_%04x: %s ", ptr - start, entry->name); + switch (entry->argument){ + case InlineBrTarget: { + gint target = *(gint32 *) ptr; + fprintf (output, "IL_%04x", ptr + 4 + target); + ptr += 4; + break; + } + + case InlineField: { + token = *(guint32 *) ptr; + fprintf (output, "fieldref-0x%08x", token); + ptr += 4; + break; + } + + case InlineI: { + int value = *(int *) ptr; + + fprintf (output, "%d", value); + ptr += 4; + break; + } + + case InlineI8: { + gint64 top = *(guint64 *) value; + + fprintf (output, "%ld", top); + ptr += 8; + break; + } + + case InlineMethod: { + token = *(guint32 *) ptr; + fprintf (output, "method-0x%08x", token); + ptr += 4; + break; + } + + case InlineNone: + break; + + case InlineR: { + double r = *(double *) ptr; + fprintf (output, "%g", r); + ptr += 8; + break; + } + + case InlineSig: { + guint32 token = *(guint32 *) ptr; + fprintf (output, "signature-0x%08x", token); + ptr += 4; + break; + } + + case InlineString: { + guint32 token = *(guint32 *) ptr; + + fprintf (output, "string-%0x08x", token); + ptr += 4; + break; + } + + case InlineSwitch: { + guint32 count = *(guint32 *) ptr; + guint32 i; + + ptr += 4; + fprintf (output, "(\n\t\t\t"); + for (i = 0; i < count; i++){ + fprintf (output, "IL_%x", *(guint32 *) ptr); + ptr += 4; + } + fprintf (output, "\t\t\t)"); + break; + } + + case InlineTok: { + guint32 token = *(guint32 *) ptr; + + fprintf (output, "TOKEN_%08x", token); + ptr += 4; + break; + } + + case InlineType: { + guint32 token = *(guint32 *) ptr; + + fprintf (output, "Type-%08x", token); + ptr += 4; + break; + } + + case InlineVar: { + gint16 var_idx = *(gint16 *) ptr; + + fprintf (output, "variable-%d\n", var_idx); + ptr += 2; + break; + } + + case ShortInlineBrTarget: { + signed char x = *ptr; + + fprintf (output, "IL_%04x", ptr - start + 1 + x); + ptr++: + break; + } + + case ShortInlineI: { + char x = *ptr; + + fprintf (output, "0x%02x", x); + ptr++; + break; + } + + case ShortInlineR: { + float f = *(float *) ptr; + + fprintf (output, "%g", (double) f); + ptr += 4; + break; + } + + case ShortInlineVar: { + signed char x = *ptr; + + fprintf (output, "Varidx-%d", (int) x); + ptr++; + break; + }m + + } + + fprintf (output, "\n"); + } +} diff --git a/mono/dis/util.c b/mono/dis/util.c new file mode 100644 index 00000000000..2debbbf1eff --- /dev/null +++ b/mono/dis/util.c @@ -0,0 +1,82 @@ +/* + * util.c: Assorted utilities for the dissasembler + * + * Author: + * Miguel de Icaza (miguel@ximian.com) + * + * (C) 2001 Ximian, Inc (http://www.ximian.com) + */ +#include <config.h> +#include <glib.h> +#include <string.h> +#include <stdio.h> +#include "util.h" + +/** + * map: + * @code: code to lookup in table + * @table: table to decode code + * + * Warning: returns static buffer. + */ +const char * +map (guint32 code, map_t *table) +{ + int i; + + for (i = 0; table [i].str != NULL; i++) + if (table [i].code == code) + return table [i].str; + g_assert_not_reached (); + return ""; +} + +/** + * flags: + * @code: bitfield + * @table: table to decode bitfield + * + * Warning: returns static buffer. + */ +const char * +flags (guint32 code, map_t *table) +{ + static char buffer [1024]; + int i; + + buffer [0] = 0; + + for (i = 0; table [i].str != NULL; i++) + if (table [i].code & code) + strcat (buffer, table [i].str); + + return buffer; +} + +/** + * hex_dump: + * @buffer: pointer to buffer to dump + * @base: numbering base to use + * @count: number of bytes to dump + */ +void +hex_dump (const char *buffer, int base, int count) +{ + int show_header = 1; + int i; + + if (count < 0){ + count = -count; + show_header = 0; + } + + for (i = 0; i < count; i++){ + if (show_header) + if ((i % 16) == 0) + printf ("\n0x%08x: ", (unsigned char) base + i); + + printf ("%02x ", (unsigned char) (buffer [i])); + } + fflush (stdout); +} + diff --git a/mono/dis/util.h b/mono/dis/util.h new file mode 100644 index 00000000000..c6647c7d2ec --- /dev/null +++ b/mono/dis/util.h @@ -0,0 +1,11 @@ + +typedef struct { + int code; + char *str; +} map_t; + +const char *map (guint32 code, map_t *table); +const char *flags (guint32 code, map_t *table); +void hex_dump (const char *buffer, int base, int count); + +#define CSIZE(x) (sizeof (x) / 4) diff --git a/mono/interpreter/.cvsignore b/mono/interpreter/.cvsignore new file mode 100644 index 00000000000..aac5927f938 --- /dev/null +++ b/mono/interpreter/.cvsignore @@ -0,0 +1,6 @@ +Makefile +Makefile.in +mono-int +*.o +.libs +.deps diff --git a/mono/interpreter/ChangeLog b/mono/interpreter/ChangeLog new file mode 100644 index 00000000000..ab99b841ef1 --- /dev/null +++ b/mono/interpreter/ChangeLog @@ -0,0 +1,8 @@ + +Sun Jul 15 17:50:23 CEST 2001 Paolo Molaro <lupus@ximian.com> + + * Started changelog. + * interp.c: use new mono_get_method () function to get the complete + info on a method invocation: we support now method invocation with + multiple (or zero) simple arguments and with or without a return value. + Implement also a couple more opcodes. diff --git a/mono/interpreter/Makefile.am b/mono/interpreter/Makefile.am new file mode 100644 index 00000000000..d75aaac3a2e --- /dev/null +++ b/mono/interpreter/Makefile.am @@ -0,0 +1,12 @@ +INCLUDES = $(GLIB_CFLAGS) -I$(top_srcdir) + +bin_PROGRAMS = mono-int + +mono_int_SOURCES = \ + interp.c \ + interp.h + +mono_int_LDADD = \ + ../metadata/libmetadata.a \ + $(GLIB_LIBS) + diff --git a/mono/interpreter/interp.c b/mono/interpreter/interp.c new file mode 100644 index 00000000000..a7d0f67906c --- /dev/null +++ b/mono/interpreter/interp.c @@ -0,0 +1,915 @@ +/* + * PLEASE NOTE: This is a research prototype. + * + * + * interp.c: Interpreter for CIL byte codes + * + * Author: + * Paolo Molaro (lupus@ximian.com) + * + * (C) 2001 Ximian, Inc. + */ +#include <config.h> +#include <stdio.h> +#include <string.h> +#include <glib.h> +#include <alloca.h> + +#include "interp.h" +/* trim excessive headers */ +#include <mono/metadata/assembly.h> +#include <mono/metadata/cil-coff.h> +#include <mono/metadata/endian.h> +#include <mono/metadata/typeattr.h> +#include <mono/metadata/fieldattr.h> +#include <mono/metadata/methodattr.h> +#include <mono/metadata/eltype.h> +#include <mono/metadata/blobsig.h> +#include <mono/metadata/paramattr.h> + +#define OPDEF(a,b,c,d,e,f,g,h,i,j) \ + a = i, + +enum { +#include "mono/cil/opcode.def" + LAST = 0xff +}; +#undef OPDEF + +/* this needs to be metadata,token indexed, not only token */ +static GHashTable * method_cache = 0; + +/* FIXME: check in configure */ +typedef gint32 nati_t; + +#define GET_NATI(sp) ((guint32)(sp).data.i) + +static int count = 0; + +/* + * Attempt at using the goto label construct of GNU GCC: + * it turns out this does give some benefit: 5-15% speedup. + * Don't look at these macros, it hurts... + */ +#define GOTO_LABEL +#ifdef GOTO_LABEL +#define SWITCH(a) goto *goto_map [(a)]; +#define BREAK SWITCH(*ip) +#define CASE(l) l ## _LABEL: +#define SUB_SWITCH \ + CEE_PREFIX1_LABEL: \ + CEE_ARGLIST_LABEL: \ + CEE_CEQ_LABEL: \ + CEE_CGT_LABEL: \ + CEE_CGT_UN_LABEL: \ + CEE_CLT_LABEL: \ + CEE_CLT_UN_LABEL: \ + CEE_LDFTN_LABEL: \ + CEE_LDVIRTFTN_LABEL: \ + CEE_UNUSED56_LABEL: \ + CEE_LDARG_LABEL: \ + CEE_LDARGA_LABEL: \ + CEE_STARG_LABEL: \ + CEE_LDLOC_LABEL: \ + CEE_LDLOCA_LABEL: \ + CEE_STLOC_LABEL: \ + CEE_LOCALLOC_LABEL: \ + CEE_UNUSED57_LABEL: \ + CEE_ENDFILTER_LABEL: \ + CEE_UNALIGNED__LABEL: \ + CEE_VOLATILE__LABEL: \ + CEE_TAIL__LABEL: \ + CEE_INITOBJ_LABEL: \ + CEE_UNUSED68_LABEL: \ + CEE_CPBLK_LABEL: \ + CEE_INITBLK_LABEL: \ + CEE_UNUSED69_LABEL: \ + CEE_RETHROW_LABEL: \ + CEE_UNUSED_LABEL: \ + CEE_SIZEOF_LABEL: \ + CEE_REFANYTYPE_LABEL: \ + CEE_UNUSED52_LABEL: \ + CEE_UNUSED53_LABEL: \ + CEE_UNUSED54_LABEL: \ + CEE_UNUSED55_LABEL: \ + CEE_UNUSED70_LABEL: +#else +#define SWITCH(a) switch(a) +#define BREAK break +#define CASE(l) case l: +#define SUB_SWITCH case 0xFE: +#endif + +/* + * Need to optimize ALU ops when natural int == int32 + * + * Need to design how exceptions are supposed to work... + * + * IDEA: if we maintain a stack of ip, sp to be checked + * in the return opcode, we could inline simple methods that don't + * use the stack or local variables.... + * + * The {,.S} versions of many opcodes can/should be merged to reduce code + * duplication. + * + * -fomit-frame-pointer gives about 2% speedup. + */ +void +ves_exec_method (cli_image_info_t *iinfo, MonoMethod *mh, stackval *args) +{ + /* + * with alloca we get the expected huge performance gain + * stackval *stack = g_new0(stackval, mh->max_stack); + */ + stackval *stack = alloca (sizeof (stackval) * mh->header->max_stack); + register const unsigned char *ip = mh->header->code; + register stackval *sp = stack; + /* FIXME: remove this hack */ + static int fake_field = 42; + stackval *locals; + +#ifdef GOTO_LABEL + const static void * const goto_map [] = { +#define OPDEF(a,b,c,d,e,f,g,h,i,j) \ + && a ## _LABEL, +#include "mono/cil/opcode.def" +#undef OPDEF + &&START + }; +#endif + + if (mh->header->num_locals) + locals = alloca (sizeof (stackval) * mh->header->num_locals); + + /* + * using while (ip < end) may result in a 15% performance drop, + * but it may be useful for debug + */ + while (1) { + /*count++;*/ +#ifdef GOTO_LABEL + START: +#endif + /*g_print ("0x%04x %02x\n", ip-(unsigned char*)mh->header->code, *ip); + if (sp > stack) + printf ("\t[%d] %d 0x%08x %0.5f\n", sp-stack, sp[-1].type, sp[-1].data.i, sp[-1].data.f); + */ + SWITCH (*ip) { + CASE (CEE_NOP) + ++ip; + BREAK; + CASE (CEE_BREAK) + ++ip; + G_BREAKPOINT (); /* this is not portable... */ + BREAK; + CASE (CEE_LDARG_0) + CASE (CEE_LDARG_1) + CASE (CEE_LDARG_2) + CASE (CEE_LDARG_3) + *sp = args [(*ip)-CEE_LDARG_0]; + ++sp; + ++ip; + BREAK; + CASE (CEE_LDLOC_0) + CASE (CEE_LDLOC_1) + CASE (CEE_LDLOC_2) + CASE (CEE_LDLOC_3) + *sp = locals [(*ip)-CEE_LDLOC_0]; + ++ip; + ++sp; + BREAK; + CASE (CEE_STLOC_0) + CASE (CEE_STLOC_1) + CASE (CEE_STLOC_2) + CASE (CEE_STLOC_3) + --sp; + locals [(*ip)-CEE_STLOC_0] = *sp; + ++ip; + BREAK; + CASE (CEE_LDARG_S) + ++ip; + *sp = args [*ip]; + ++sp; + ++ip; + BREAK; + CASE (CEE_LDARGA_S) + ++ip; + sp->type = VAL_TP; + sp->data.p = &(args [*ip]); + ++sp; + ++ip; + BREAK; + CASE (CEE_STARG_S) g_assert_not_reached(); BREAK; + CASE (CEE_LDLOC_S) + ++ip; + *sp = locals [*ip]; + ++sp; + ++ip; + BREAK; + CASE (CEE_LDLOCA_S) g_assert_not_reached(); BREAK; + CASE (CEE_STLOC_S) + ++ip; + --sp; + locals [*ip] = *sp; + ++ip; + BREAK; + CASE (CEE_LDNULL) + ++ip; + sp->type = VAL_OBJ; + sp->data.p = NULL; + ++sp; + BREAK; + CASE (CEE_LDC_I4_M1) + ++ip; + sp->type = VAL_I32; + sp->data.i = -1; + ++sp; + BREAK; + CASE (CEE_LDC_I4_0) + CASE (CEE_LDC_I4_1) + CASE (CEE_LDC_I4_2) + CASE (CEE_LDC_I4_3) + CASE (CEE_LDC_I4_4) + CASE (CEE_LDC_I4_5) + CASE (CEE_LDC_I4_6) + CASE (CEE_LDC_I4_7) + CASE (CEE_LDC_I4_8) + sp->type = VAL_I32; + sp->data.i = (*ip) - CEE_LDC_I4_0; + ++sp; + ++ip; + BREAK; + CASE (CEE_LDC_I4_S) + ++ip; + sp->type = VAL_I32; + sp->data.i = *ip; /* FIXME: signed? */ + ++ip; + ++sp; + BREAK; + CASE (CEE_LDC_I4) + ++ip; + sp->type = VAL_I32; + sp->data.i = read32 (ip); + ip += 4; + ++sp; + BREAK; + CASE (CEE_LDC_I8) + ++ip; + sp->type = VAL_I64; + sp->data.i = read64 (ip); + ip += 8; + ++sp; + BREAK; + CASE (CEE_LDC_R4) + ++ip; + sp->type = VAL_DOUBLE; + /* FIXME: ENOENDIAN */ + sp->data.f = *(float*)(ip); + ip += sizeof (float); + ++sp; + BREAK; + CASE (CEE_LDC_R8) + ++ip; + sp->type = VAL_DOUBLE; + /* FIXME: ENOENDIAN */ + sp->data.f = *(double*) (ip); + ip += sizeof (double); + ++sp; + BREAK; + CASE (CEE_UNUSED99) g_assert_not_reached (); BREAK; + CASE (CEE_DUP) + *sp = sp [-1]; + ++sp; + ++ip; + BREAK; + CASE (CEE_POP) + ++ip; + --sp; + BREAK; + CASE (CEE_JMP) g_assert_not_reached(); BREAK; + CASE (CEE_CALL) { + MonoMethod *cmh; + guint32 token; + + ++ip; + token = read32 (ip); + ip += 4; + if (!(cmh = g_hash_table_lookup (method_cache, GINT_TO_POINTER (token)))) { + cmh = mono_get_method (iinfo, token); + g_hash_table_insert (method_cache, GINT_TO_POINTER (token), cmh); + } + + /* decrement by the actual number of args */ + sp -= cmh->signature->param_count; + g_assert (cmh->signature->call_convention == MONO_CALL_DEFAULT); + + /* we need to truncate according to the type of args ... */ + ves_exec_method (iinfo, cmh, sp); + + /* need to handle typedbyref ... */ + if (cmh->signature->ret->type) + sp++; + BREAK; + } + CASE (CEE_CALLI) g_assert_not_reached(); BREAK; + CASE (CEE_RET) + --sp; + *args = *sp; + if (sp != stack) + g_warning ("more values on stack: %d", sp-stack); + + /*if (sp->type == VAL_DOUBLE) + g_print("%.9f\n", sp->data.f);*/ + /*g_free (stack);*/ + return; + CASE (CEE_BR_S) + ++ip; + ip += (signed char) *ip; + ++ip; + BREAK; + CASE (CEE_BRFALSE_S) { + int result; + ++ip; + --sp; + switch (sp->type) { + case VAL_I32: result = sp->data.i == 0; break; + case VAL_I64: result = sp->data.l == 0; break; + case VAL_DOUBLE: result = sp->data.f ? 0: 1; break; + default: result = sp->data.p == NULL; break; + } + if (result) + ip += (signed char)*ip; + ++ip; + BREAK; + } + CASE (CEE_BRTRUE_S) { + int result; + ++ip; + --sp; + switch (sp->type) { + case VAL_I32: result = sp->data.i != 0; break; + case VAL_I64: result = sp->data.l != 0; break; + case VAL_DOUBLE: result = sp->data.f ? 1 : 0; break; + default: result = sp->data.p != NULL; break; + } + if (result) + ip += (signed char)*ip; + ++ip; + BREAK; + } + CASE (CEE_BEQ_S) { + int result; + ++ip; + sp -= 2; + if (sp->type == VAL_I32) + result = sp [0].data.i == GET_NATI (sp [1]); + else if (sp->type == VAL_I64) + result = sp [0].data.l == sp [1].data.l; + else if (sp->type == VAL_DOUBLE) + result = sp [0].data.f == sp [1].data.f; + else + result = GET_NATI (sp [0]) == GET_NATI (sp [1]); + if (result) + ip += (signed char)*ip; + ++ip; + BREAK; + } + CASE (CEE_BGE_S) { + int result; + ++ip; + sp -= 2; + if (sp->type == VAL_I32) + result = sp [0].data.i >= GET_NATI (sp [1]); + else if (sp->type == VAL_I64) + result = sp [0].data.l >= sp [1].data.l; + else if (sp->type == VAL_DOUBLE) + result = sp [0].data.f >= sp [1].data.f; + else + result = GET_NATI (sp [0]) >= GET_NATI (sp [1]); + if (result) + ip += (signed char)*ip; + ++ip; + BREAK; + } + CASE (CEE_BGT_S) { + int result; + ++ip; + sp -= 2; + if (sp->type == VAL_I32) + result = sp [0].data.i > GET_NATI (sp [1]); + else if (sp->type == VAL_I64) + result = sp [0].data.l > sp [1].data.l; + else if (sp->type == VAL_DOUBLE) + result = sp [0].data.f > sp [1].data.f; + else + result = GET_NATI (sp [0]) > GET_NATI (sp [1]); + if (result) + ip += (signed char)*ip; + ++ip; + BREAK; + } + CASE (CEE_BLT_S) { + int result; + ++ip; + sp -= 2; + if (sp->type == VAL_I32) + result = sp[0].data.i < GET_NATI(sp[1]); + else if (sp->type == VAL_I64) + result = sp[0].data.l < sp[1].data.l; + else if (sp->type == VAL_DOUBLE) + result = sp[0].data.f < sp[1].data.f; + else + result = GET_NATI(sp[0]) < GET_NATI(sp[1]); + if (result) + ip += (signed char)*ip; + ++ip; + BREAK; + } + CASE (CEE_BLE_S) { + int result; + ++ip; + sp -= 2; + + if (sp->type == VAL_I32) + result = sp [0].data.i <= GET_NATI (sp [1]); + else if (sp->type == VAL_I64) + result = sp [0].data.l <= sp [1].data.l; + else if (sp->type == VAL_DOUBLE) + result = sp [0].data.f <= sp [1].data.f; + else { + /* + * FIXME: here and in other places GET_NATI on the left side + * _will_ be wrong when we change the macro to work on 64 buts + * systems. + */ + result = GET_NATI (sp [0]) <= GET_NATI (sp [1]); + } + if (result) + ip += (signed char)*ip; + ++ip; + BREAK; + } + CASE (CEE_BNE_UN_S) g_assert_not_reached(); BREAK; + CASE (CEE_BGE_UN_S) g_assert_not_reached(); BREAK; + CASE (CEE_BGT_UN_S) g_assert_not_reached(); BREAK; + CASE (CEE_BLE_UN_S) g_assert_not_reached(); BREAK; + CASE (CEE_BLT_UN_S) g_assert_not_reached(); BREAK; + CASE (CEE_BR) g_assert_not_reached(); BREAK; + CASE (CEE_BRFALSE) g_assert_not_reached(); BREAK; + CASE (CEE_BRTRUE) g_assert_not_reached(); BREAK; + CASE (CEE_BEQ) g_assert_not_reached(); BREAK; + CASE (CEE_BGE) g_assert_not_reached(); BREAK; + CASE (CEE_BGT) g_assert_not_reached(); BREAK; + CASE (CEE_BLE) g_assert_not_reached(); BREAK; + CASE (CEE_BLT) g_assert_not_reached(); BREAK; + CASE (CEE_BNE_UN) g_assert_not_reached(); BREAK; + CASE (CEE_BGE_UN) g_assert_not_reached(); BREAK; + CASE (CEE_BGT_UN) g_assert_not_reached(); BREAK; + CASE (CEE_BLE_UN) g_assert_not_reached(); BREAK; + CASE (CEE_BLT_UN) g_assert_not_reached(); BREAK; + CASE (CEE_SWITCH) g_assert_not_reached(); BREAK; + CASE (CEE_LDIND_I1) g_assert_not_reached(); BREAK; + CASE (CEE_LDIND_U1) g_assert_not_reached(); BREAK; + CASE (CEE_LDIND_I2) g_assert_not_reached(); BREAK; + CASE (CEE_LDIND_U2) g_assert_not_reached(); BREAK; + CASE (CEE_LDIND_I4) g_assert_not_reached(); BREAK; + CASE (CEE_LDIND_U4) g_assert_not_reached(); BREAK; + CASE (CEE_LDIND_I8) g_assert_not_reached(); BREAK; + CASE (CEE_LDIND_I) g_assert_not_reached(); BREAK; + CASE (CEE_LDIND_R4) g_assert_not_reached(); BREAK; + CASE (CEE_LDIND_R8) g_assert_not_reached(); BREAK; + CASE (CEE_LDIND_REF) g_assert_not_reached(); BREAK; + CASE (CEE_STIND_REF) g_assert_not_reached(); BREAK; + CASE (CEE_STIND_I1) g_assert_not_reached(); BREAK; + CASE (CEE_STIND_I2) g_assert_not_reached(); BREAK; + CASE (CEE_STIND_I4) g_assert_not_reached(); BREAK; + CASE (CEE_STIND_I8) g_assert_not_reached(); BREAK; + CASE (CEE_STIND_R4) g_assert_not_reached(); BREAK; + CASE (CEE_STIND_R8) g_assert_not_reached(); BREAK; + CASE (CEE_ADD) + ++ip; + --sp; + /* should probably consider the pointers as unsigned */ + if (sp->type == VAL_I32) + sp [-1].data.i += GET_NATI (sp [0]); + else if (sp->type == VAL_I64) + sp [-1].data.l += sp [0].data.l; + else if (sp->type == VAL_DOUBLE) + sp [-1].data.f += sp [0].data.f; + else + (char*)sp [-1].data.p += GET_NATI (sp [0]); + BREAK; + CASE (CEE_SUB) + ++ip; + --sp; + /* should probably consider the pointers as unsigned */ + if (sp->type == VAL_I32) + sp [-1].data.i -= GET_NATI (sp [0]); + else if (sp->type == VAL_I64) + sp [-1].data.l -= sp [0].data.l; + else if (sp->type == VAL_DOUBLE) + sp [-1].data.f -= sp [0].data.f; + else + (char*)sp [-1].data.p -= GET_NATI (sp [0]); + BREAK; + CASE (CEE_MUL) + ++ip; + --sp; + if (sp->type == VAL_I32) + sp [-1].data.i *= GET_NATI (sp [0]); + else if (sp->type == VAL_I64) + sp [-1].data.l *= sp [0].data.l; + else if (sp->type == VAL_DOUBLE) + sp [-1].data.f *= sp [0].data.f; + BREAK; + CASE (CEE_DIV) + ++ip; + --sp; + if (sp->type == VAL_I32) + sp [-1].data.i /= GET_NATI (sp [0]); + else if (sp->type == VAL_I64) + sp [-1].data.l /= sp [0].data.l; + else if (sp->type == VAL_DOUBLE) + sp [-1].data.f /= sp [0].data.f; + BREAK; + CASE (CEE_DIV_UN) + ++ip; + --sp; + if (sp->type == VAL_I32) + (guint32)sp [-1].data.i /= (guint32)GET_NATI (sp [0]); + else if (sp->type == VAL_I64) + (guint64)sp [-1].data.l /= (guint64)sp [0].data.l; + else if (sp->type == VAL_NATI) + (gulong)sp [-1].data.p /= (gulong)sp [0].data.p; + BREAK; + CASE (CEE_REM) + ++ip; + --sp; + if (sp->type == VAL_I32) + sp [-1].data.i %= GET_NATI (sp [0]); + else if (sp->type == VAL_I64) + sp [-1].data.l %= sp [0].data.l; + else if (sp->type == VAL_DOUBLE) + /* FIXME: what do we actually fo here? */ + sp [-1].data.f = 0; + else + GET_NATI (sp [-1]) %= GET_NATI (sp [0]); + BREAK; + CASE (CEE_REM_UN) g_assert_not_reached(); BREAK; + CASE (CEE_AND) + ++ip; + --sp; + if (sp->type == VAL_I32) + sp [-1].data.i &= GET_NATI (sp [0]); + else if (sp->type == VAL_I64) + sp [-1].data.l &= sp [0].data.l; + else + GET_NATI (sp [-1]) &= GET_NATI (sp [0]); + BREAK; + CASE (CEE_OR) + ++ip; + --sp; + if (sp->type == VAL_I32) + sp [-1].data.i |= GET_NATI (sp [0]); + else if (sp->type == VAL_I64) + sp [-1].data.l |= sp [0].data.l; + else + GET_NATI (sp [-1]) |= GET_NATI (sp [0]); + BREAK; + CASE (CEE_XOR) + ++ip; + --sp; + if (sp->type == VAL_I32) + sp [-1].data.i ^= GET_NATI (sp [0]); + else if (sp->type == VAL_I64) + sp [-1].data.l ^= sp [0].data.l; + else + GET_NATI (sp [-1]) ^= GET_NATI (sp [0]); + BREAK; + CASE (CEE_SHL) + ++ip; + --sp; + if (sp->type == VAL_I32) + sp [-1].data.i <<= GET_NATI (sp [0]); + else if (sp->type == VAL_I64) + sp [-1].data.l <<= GET_NATI (sp [0]); + else + GET_NATI (sp [-1]) <<= GET_NATI (sp [0]); + BREAK; + CASE (CEE_SHR) + ++ip; + --sp; + if (sp->type == VAL_I32) + sp [-1].data.i >>= GET_NATI (sp [0]); + else if (sp->type == VAL_I64) + sp [-1].data.l >>= GET_NATI (sp [0]); + else + GET_NATI (sp [-1]) >>= GET_NATI (sp [0]); + BREAK; + CASE (CEE_SHR_UN) g_assert_not_reached(); BREAK; + CASE (CEE_NEG) + ++ip; + if (sp->type == VAL_I32) + sp->data.i = - sp->data.i; + else if (sp->type == VAL_I64) + sp->data.l = - sp->data.l; + else if (sp->type == VAL_DOUBLE) + sp->data.f = - sp->data.f; + else if (sp->type == VAL_NATI) + sp->data.p = (gpointer)(- (nati_t)sp->data.p); + BREAK; + CASE (CEE_NOT) + ++ip; + if (sp->type == VAL_I32) + sp->data.i = ~ sp->data.i; + else if (sp->type == VAL_I64) + sp->data.l = ~ sp->data.l; + else if (sp->type == VAL_NATI) + sp->data.p = (gpointer)(~ (nati_t)sp->data.p); + BREAK; + CASE (CEE_CONV_I1) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_I2) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_I4) + ++ip; + /* FIXME: handle other cases. what about sign? */ + if (sp [-1].type == VAL_DOUBLE) { + sp [-1].data.i = (gint32)sp [-1].data.f; + sp [-1].type = VAL_I32; + } else { + g_assert_not_reached(); + } + BREAK; + CASE (CEE_CONV_I8) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_R4) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_R8) + ++ip; + /* FIXME: handle other cases. what about sign? */ + if (sp [-1].type == VAL_I32) { + sp [-1].data.f = (double)sp [-1].data.i; + sp [-1].type = VAL_DOUBLE; + } else { + g_assert_not_reached(); + } + BREAK; + CASE (CEE_CONV_U4) + ++ip; + /* FIXME: handle other cases. what about sign? */ + if (sp [-1].type == VAL_DOUBLE) { + sp [-1].data.i = (guint32)sp [-1].data.f; + sp [-1].type = VAL_I32; + } else { + g_assert_not_reached(); + } + BREAK; + CASE (CEE_CONV_U8) g_assert_not_reached(); BREAK; + CASE (CEE_CALLVIRT) g_assert_not_reached(); BREAK; + CASE (CEE_CPOBJ) g_assert_not_reached(); BREAK; + CASE (CEE_LDOBJ) g_assert_not_reached(); BREAK; + CASE (CEE_LDSTR) g_assert_not_reached(); BREAK; + CASE (CEE_NEWOBJ) g_assert_not_reached(); BREAK; + CASE (CEE_CASTCLASS) g_assert_not_reached(); BREAK; + CASE (CEE_ISINST) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_R_UN) g_assert_not_reached(); BREAK; + CASE (CEE_UNUSED58) g_assert_not_reached(); BREAK; + CASE (CEE_UNUSED1) g_assert_not_reached(); BREAK; + CASE (CEE_UNBOX) g_assert_not_reached(); BREAK; + CASE (CEE_THROW) g_assert_not_reached(); BREAK; + CASE (CEE_LDFLD) g_assert_not_reached(); BREAK; + CASE (CEE_LDFLDA) g_assert_not_reached(); BREAK; + CASE (CEE_STFLD) g_assert_not_reached(); BREAK; + CASE (CEE_LDSFLD) + /* FIXME: get the real field here */ + ip += 5; + sp->type = VAL_I32; + sp->data.i = fake_field; + ++sp; + BREAK; + CASE (CEE_LDSFLDA) g_assert_not_reached(); BREAK; + CASE (CEE_STSFLD) + /* FIXME: get the real field here */ + ip += 5; + --sp; + fake_field = sp->data.i; + BREAK; + CASE (CEE_STOBJ) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_I1_UN) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_I2_UN) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_I4_UN) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_I8_UN) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_U1_UN) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_U2_UN) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_U4_UN) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_U8_UN) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_I_UN) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_U_UN) g_assert_not_reached(); BREAK; + CASE (CEE_BOX) g_assert_not_reached(); BREAK; + CASE (CEE_NEWARR) g_assert_not_reached(); BREAK; + CASE (CEE_LDLEN) g_assert_not_reached(); BREAK; + CASE (CEE_LDELEMA) g_assert_not_reached(); BREAK; + CASE (CEE_LDELEM_I1) g_assert_not_reached(); BREAK; + CASE (CEE_LDELEM_U1) g_assert_not_reached(); BREAK; + CASE (CEE_LDELEM_I2) g_assert_not_reached(); BREAK; + CASE (CEE_LDELEM_U2) g_assert_not_reached(); BREAK; + CASE (CEE_LDELEM_I4) g_assert_not_reached(); BREAK; + CASE (CEE_LDELEM_U4) g_assert_not_reached(); BREAK; + CASE (CEE_LDELEM_I8) g_assert_not_reached(); BREAK; + CASE (CEE_LDELEM_I) g_assert_not_reached(); BREAK; + CASE (CEE_LDELEM_R4) g_assert_not_reached(); BREAK; + CASE (CEE_LDELEM_R8) g_assert_not_reached(); BREAK; + CASE (CEE_LDELEM_REF) g_assert_not_reached(); BREAK; + CASE (CEE_STELEM_I) g_assert_not_reached(); BREAK; + CASE (CEE_STELEM_I1) g_assert_not_reached(); BREAK; + CASE (CEE_STELEM_I2) g_assert_not_reached(); BREAK; + CASE (CEE_STELEM_I4) g_assert_not_reached(); BREAK; + CASE (CEE_STELEM_I8) g_assert_not_reached(); BREAK; + CASE (CEE_STELEM_R4) g_assert_not_reached(); BREAK; + CASE (CEE_STELEM_R8) g_assert_not_reached(); BREAK; + CASE (CEE_STELEM_REF) g_assert_not_reached(); BREAK; + CASE (CEE_UNUSED2) + CASE (CEE_UNUSED3) + CASE (CEE_UNUSED4) + CASE (CEE_UNUSED5) + CASE (CEE_UNUSED6) + CASE (CEE_UNUSED7) + CASE (CEE_UNUSED8) + CASE (CEE_UNUSED9) + CASE (CEE_UNUSED10) + CASE (CEE_UNUSED11) + CASE (CEE_UNUSED12) + CASE (CEE_UNUSED13) + CASE (CEE_UNUSED14) + CASE (CEE_UNUSED15) + CASE (CEE_UNUSED16) + CASE (CEE_UNUSED17) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_I1) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_U1) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_I2) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_U2) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_I4) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_U4) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_I8) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_U8) g_assert_not_reached(); BREAK; + CASE (CEE_UNUSED50) + CASE (CEE_UNUSED18) + CASE (CEE_UNUSED19) + CASE (CEE_UNUSED20) + CASE (CEE_UNUSED21) + CASE (CEE_UNUSED22) + CASE (CEE_UNUSED23) g_assert_not_reached(); BREAK; + CASE (CEE_REFANYVAL) g_assert_not_reached(); BREAK; + CASE (CEE_CKFINITE) g_assert_not_reached(); BREAK; + CASE (CEE_UNUSED24) g_assert_not_reached(); BREAK; + CASE (CEE_UNUSED25) g_assert_not_reached(); BREAK; + CASE (CEE_MKREFANY) g_assert_not_reached(); BREAK; + CASE (CEE_UNUSED59) + CASE (CEE_UNUSED60) + CASE (CEE_UNUSED61) + CASE (CEE_UNUSED62) + CASE (CEE_UNUSED63) + CASE (CEE_UNUSED64) + CASE (CEE_UNUSED65) + CASE (CEE_UNUSED66) + CASE (CEE_UNUSED67) g_assert_not_reached(); BREAK; + CASE (CEE_LDTOKEN) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_U2) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_U1) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_I) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_I) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_OVF_U) g_assert_not_reached(); BREAK; + CASE (CEE_ADD_OVF) g_assert_not_reached(); BREAK; + CASE (CEE_ADD_OVF_UN) g_assert_not_reached(); BREAK; + CASE (CEE_MUL_OVF) g_assert_not_reached(); BREAK; + CASE (CEE_MUL_OVF_UN) g_assert_not_reached(); BREAK; + CASE (CEE_SUB_OVF) g_assert_not_reached(); BREAK; + CASE (CEE_SUB_OVF_UN) g_assert_not_reached(); BREAK; + CASE (CEE_ENDFINALLY) g_assert_not_reached(); BREAK; + CASE (CEE_LEAVE) g_assert_not_reached(); BREAK; + CASE (CEE_LEAVE_S) g_assert_not_reached(); BREAK; + CASE (CEE_STIND_I) g_assert_not_reached(); BREAK; + CASE (CEE_CONV_U) g_assert_not_reached(); BREAK; + CASE (CEE_UNUSED26) + CASE (CEE_UNUSED27) + CASE (CEE_UNUSED28) + CASE (CEE_UNUSED29) + CASE (CEE_UNUSED30) + CASE (CEE_UNUSED31) + CASE (CEE_UNUSED32) + CASE (CEE_UNUSED33) + CASE (CEE_UNUSED34) + CASE (CEE_UNUSED35) + CASE (CEE_UNUSED36) + CASE (CEE_UNUSED37) + CASE (CEE_UNUSED38) + CASE (CEE_UNUSED39) + CASE (CEE_UNUSED40) + CASE (CEE_UNUSED41) + CASE (CEE_UNUSED42) + CASE (CEE_UNUSED43) + CASE (CEE_UNUSED44) + CASE (CEE_UNUSED45) + CASE (CEE_UNUSED46) + CASE (CEE_UNUSED47) + CASE (CEE_UNUSED48) g_assert_not_reached(); BREAK; + CASE (CEE_PREFIX7) g_assert_not_reached(); BREAK; + CASE (CEE_PREFIX6) g_assert_not_reached(); BREAK; + CASE (CEE_PREFIX5) g_assert_not_reached(); BREAK; + CASE (CEE_PREFIX4) g_assert_not_reached(); BREAK; + CASE (CEE_PREFIX3) g_assert_not_reached(); BREAK; + CASE (CEE_PREFIX2) g_assert_not_reached(); BREAK; + CASE (CEE_PREFIXREF) g_assert_not_reached(); BREAK; + SUB_SWITCH + ++ip; + switch (*ip) { + case CEE_ARGLIST: g_assert_not_reached(); break; + case CEE_CEQ: g_assert_not_reached(); break; + case CEE_CGT: g_assert_not_reached(); break; + case CEE_CGT_UN: g_assert_not_reached(); break; + case CEE_CLT: g_assert_not_reached(); break; + case CEE_CLT_UN: g_assert_not_reached(); break; + case CEE_LDFTN: g_assert_not_reached(); break; + case CEE_LDVIRTFTN: g_assert_not_reached(); break; + case CEE_UNUSED56: g_assert_not_reached(); break; + case CEE_LDARG: g_assert_not_reached(); break; + case CEE_LDARGA: g_assert_not_reached(); break; + case CEE_STARG: g_assert_not_reached(); break; + case CEE_LDLOC: g_assert_not_reached(); break; + case CEE_LDLOCA: g_assert_not_reached(); break; + case CEE_STLOC: g_assert_not_reached(); break; + case CEE_LOCALLOC: g_assert_not_reached(); break; + case CEE_UNUSED57: g_assert_not_reached(); break; + case CEE_ENDFILTER: g_assert_not_reached(); break; + case CEE_UNALIGNED_: g_assert_not_reached(); break; + case CEE_VOLATILE_: g_assert_not_reached(); break; + case CEE_TAIL_: g_assert_not_reached(); break; + case CEE_INITOBJ: g_assert_not_reached(); break; + case CEE_UNUSED68: g_assert_not_reached(); break; + case CEE_CPBLK: g_assert_not_reached(); break; + case CEE_INITBLK: g_assert_not_reached(); break; + case CEE_UNUSED69: g_assert_not_reached(); break; + case CEE_RETHROW: g_assert_not_reached(); break; + case CEE_UNUSED: g_assert_not_reached(); break; + case CEE_SIZEOF: g_assert_not_reached(); break; + case CEE_REFANYTYPE: g_assert_not_reached(); break; + case CEE_UNUSED52: + case CEE_UNUSED53: + case CEE_UNUSED54: + case CEE_UNUSED55: + case CEE_UNUSED70: + default: +#ifdef GOTO_LABEL + CEE_ILLEGAL_LABEL: + CEE_ENDMAC_LABEL: +#endif + g_error ("Unimplemented opcode: 0xFE %02x at 0x%x\n", *ip, ip-(unsigned char*)mh->header->code); + } + continue; +#ifndef GOTO_LABEL + default: + g_error ("Unimplemented opcode: %x at 0x%x\n", *ip, ip-(unsigned char*)mh->header->code); +#endif + } + } + + g_assert_not_reached(); +} + +static int +ves_exec (cli_image_info_t *iinfo) +{ + stackval result; + MonoMethod *mh; + + /* we need to exec the class and object constructors... */ + method_cache = g_hash_table_new (g_direct_hash, g_direct_equal); + + mh = mono_get_method (iinfo, iinfo->cli_cli_header.ch_entry_point); + ves_exec_method (iinfo, mh, &result); + fprintf (stderr, "result: %d\n", result.data.i); + mono_free_method (mh); + + return 0; +} + +int +main (int argc, char *argv []) +{ + cli_image_info_t *iinfo; + MonoAssembly *assembly; + int retval = 0; + char *file = argv [1]; + + assembly = mono_assembly_open (file, NULL); + if (!assembly){ + fprintf (stderr, "Can not open assembly %s\n", file); + exit (1); + } + iinfo = assembly->image_info; + retval = ves_exec (iinfo); + mono_assembly_close (assembly); + printf("count: %d\n", count); + + return retval; +} + + + diff --git a/mono/interpreter/interp.h b/mono/interpreter/interp.h new file mode 100644 index 00000000000..584e058ba51 --- /dev/null +++ b/mono/interpreter/interp.h @@ -0,0 +1,24 @@ + +#include <glib.h> + +enum { + VAL_I32, + VAL_I64, + VAL_DOUBLE, + VAL_NATI, + VAL_MP, + VAL_TP, + VAL_OBJ +}; + +typedef struct { + union { + gint32 i; + gint64 l; + double f; + /* native size integer and pointer types */ + gpointer p; + } data; + int type; +} stackval; + diff --git a/mono/metadata/.cvsignore b/mono/metadata/.cvsignore new file mode 100644 index 00000000000..896769d89cf --- /dev/null +++ b/mono/metadata/.cvsignore @@ -0,0 +1,5 @@ +Makefile +Makefile.in +pedump +.libs +.deps diff --git a/mono/metadata/ChangeLog b/mono/metadata/ChangeLog new file mode 100644 index 00000000000..1a9a72a7b20 --- /dev/null +++ b/mono/metadata/ChangeLog @@ -0,0 +1,86 @@ +Sun Jul 15 19:39:06 CEST 2001 Paolo Molaro <lupus@ximian.com> + + * metadata.c, metadata.h: decode local vars in method header + parse function. Change callers accordingly. + +Sun Jul 15 17:40:47 CEST 2001 Paolo Molaro <lupus@ximian.com> + + * metadata.h, cil-coff.h: protect against multiple inclusion. + Added some new structures to hold information decoded from metadata: + MonoType, MonoParam, MonoArray, MonoMethod, MonoMethodSignature + and relevant decoding/free functions. + * metadata.c: implement decoding functions. Add warning for out of bounds + index in mono_metadata_locate(). Implement mono_get_method () to retreive + all the info about a method signature and invocation. Remove check on + uninitialized local var in parse_mh() and fix memory leak. + +2001-07-12 Miguel de Icaza <miguel@ximian.com> + + * metadata.h: More macros. + + * tokentype.h: New file. + +Fri Jul 6 11:30:53 CEST 2001 Paolo Molaro <lupus@ximian.com> + + * assembly.c: added a consistency check and initialize + some structures with g_new0(). + * metadata.c: fixed a couple more bugs in table size computation + and add other checks for out-of bound access to metadata. + +Thu Jul 5 22:34:21 CEST 2001 Paolo Molaro <lupus@ximian.com> + + * metatada.c: fix bugs computing table sizes. Spew a + warning when index in string heap is out of bounds. + +2001-07-04 Miguel de Icaza <miguel@ximian.com> + + * metadata.h: Add a couple of macros to manipulate tokens. + +Tue Jul 3 18:33:32 CEST 2001 Paolo Molaro <lupus@ximian.com> + + * assembly.c: g_free(ii->cli_sections) (and avoid double free of + cli_section_tables). + +2001-07-01 Miguel de Icaza <miguel@ximian.com> + + * metadata.c (mono_metadata_user_string): New function, provides + access to the UserString heap. + +2001-06-27 Miguel de Icaza <miguel@ximian.com> + + * metadata.c: Add inline documentation. + +2001-06-26 Miguel de Icaza <miguel@ximian.com> + + * propertyattr.h, paramattr.h, methodsem.h, methodattr.h: New + files. + +2001-06-22 Miguel de Icaza <miguel@ximian.com> + + * typeattr.h: New file, TypeAttribute flags. + +2001-06-21 Miguel de Icaza <miguel@ximian.com> + + * mono/metadata/assembly.c (mono_assembly_ensure_section_idx, + mono_assembly_ensure_section): Section loading code. + (load_section_tables): Load the sections. + + * mono/metadata/metadata.c (mono_metadata_locate_token, + mono_metadata_locate): Functions to locate the information + definition given a token or a table and an index. + (mono_metadata_compute_table_bases): New. + (compute_size): New function to compute the sizes of the various + tables. + + * mono/metadata/metadata.h: Finish listing the different index + types. + + * mono/metadata/pedump.c: Improve to dump new information. + +2001-06-19 Miguel de Icaza <miguel@ximian.com> + + * mono/metadata/metadata.c: Entered all the tables matching + Beta2. + + * mono/metadata/assembly.c (load_metadata_ptrs): Fix for Beta2 + diff --git a/mono/metadata/Makefile.am b/mono/metadata/Makefile.am index 505141d5abc..2966a60a0b0 100644 --- a/mono/metadata/Makefile.am +++ b/mono/metadata/Makefile.am @@ -5,13 +5,28 @@ lib_LIBRARIES = libmetadata.a INCLUDES = $(GLIB_CFLAGS) -I$(top_srcdir) libmetadata_a_SOURCES = \ - assembly.h \ assembly.c \ - cil-coff.h \ metadata.c \ + rawbuffer.c + +libmetadataincludedir = $(includedir)/mono/metadata + +libmetadatainclude_HEADERS = \ + assembly.h \ + blobsig.h \ + cil-coff.h \ + eltype.h \ + endian.h \ + fieldattr.h \ metadata.h \ - rawbuffer.c \ - rawbuffer.h + methodattr.h \ + methodheader.h \ + methodsem.h \ + paramattr.h \ + propertyattr.h \ + rawbuffer.h \ + tokentype.h \ + typeattr.h pedump_SOURCES = \ pedump.c $(libmetadata_a_SOURCES) diff --git a/mono/metadata/TODO b/mono/metadata/TODO new file mode 100644 index 00000000000..7c7da2c7aef --- /dev/null +++ b/mono/metadata/TODO @@ -0,0 +1,5 @@ + +* Rename assembly.c to module.c + + * Rename all symbols called `assembly' to module, because that is + what they actually are.
\ No newline at end of file diff --git a/mono/metadata/assembly.c b/mono/metadata/assembly.c index 6d6b2602d7f..ec5e16c57c9 100644 --- a/mono/metadata/assembly.c +++ b/mono/metadata/assembly.c @@ -8,7 +8,7 @@ * (C) 2001 Ximian, Inc. http://www.ximian.com * * TODO: - * Do byteswaps for big-endian systems on the various headers. + * Implement big-endian versions of the reading routines. */ #include <config.h> #include <stdio.h> @@ -18,22 +18,15 @@ #include "assembly.h" #include "cil-coff.h" #include "rawbuffer.h" +#include "endian.h" #define INVALID_ADDRESS 0xffffffff -/* FIXME: implement big endian versions */ -#define le64_to_cpu(x) (x) -#define le32_to_cpu(x) (x) -#define le16_to_cpu(x) (x) -#define read32(x) le32_to_cpu (*((guint32 *) (x))) -#define read16(x) le16_to_cpu (*((guint16 *) (x))) -#define read64(x) le64_to_cpu (*((guint64 *) (x))) - -static guint32 -coff_map (dotnet_image_info_t *iinfo, guint32 addr) +guint32 +cli_rva_image_map (cli_image_info_t *iinfo, guint32 addr) { - const int top = iinfo->dn_section_count; - section_table_t *tables = iinfo->dn_section_tables; + const int top = iinfo->cli_section_count; + section_table_t *tables = iinfo->cli_section_tables; int i; for (i = 0; i < top; i++){ @@ -46,17 +39,97 @@ coff_map (dotnet_image_info_t *iinfo, guint32 addr) return INVALID_ADDRESS; } -static int -load_section_tables (MonoAssembly *assembly, dotnet_image_info_t *iinfo) +char * +cli_rva_map (cli_image_info_t *iinfo, guint32 addr) { - const int top = iinfo->dn_header.coff.coff_sections; + const int top = iinfo->cli_section_count; + section_table_t *tables = iinfo->cli_section_tables; int i; + + for (i = 0; i < top; i++){ + if ((addr >= tables->st_virtual_address) && + (addr < tables->st_virtual_address + tables->st_raw_data_size)){ + return iinfo->cli_sections [i] + + (addr - tables->st_virtual_address); + } + tables++; + } + return NULL; +} + +/** + * mono_assembly_ensure_section_idx: + * @assembly: The image we are operating on + * @section: section number that we will load/map into memory + * + * This routine makes sure that we have an in-memory copy of + * an image section (.text, .rsrc, .data). + * + * Returns: TRUE on success + */ +int +mono_assembly_ensure_section_idx (MonoAssembly *assembly, int section) +{ + cli_image_info_t *iinfo = assembly->image_info; + section_table_t *sect; + gboolean writable; + + g_return_val_if_fail (section < iinfo->cli_section_count, FALSE); - iinfo->dn_section_count = top; - iinfo->dn_section_tables = g_new (section_table_t, top); + if (iinfo->cli_sections [section] != NULL) + return TRUE; + sect = &iinfo->cli_section_tables [section]; + + writable = sect->st_flags & SECT_FLAGS_MEM_WRITE; + + iinfo->cli_sections [section] = raw_buffer_load ( + fileno (assembly->f), writable, + sect->st_raw_data_ptr, sect->st_raw_data_size); + + if (iinfo->cli_sections [section] == NULL) + return FALSE; + + return TRUE; +} + +/** + * mono_assembly_ensure_section: + * @assembly: The image we are operating on + * @section: section name that we will load/map into memory + * + * This routine makes sure that we have an in-memory copy of + * an image section (.text, .rsrc, .data). + * + * Returns: TRUE on success + */ +int +mono_assembly_ensure_section (MonoAssembly *assembly, const char *section) +{ + cli_image_info_t *ii = assembly->image_info; + int i; + + for (i = 0; i < ii->cli_section_count; i++){ + if (strncmp (ii->cli_section_tables [i].st_name, section, 8) != 0) + continue; + + return mono_assembly_ensure_section_idx (assembly, i); + } + return FALSE; +} + +static int +load_section_tables (MonoAssembly *assembly, cli_image_info_t *iinfo) +{ + const int top = iinfo->cli_header.coff.coff_sections; + int i; + + iinfo->cli_section_count = top; + iinfo->cli_section_tables = g_new0 (section_table_t, top); + iinfo->cli_sections = g_new0 (void *, top); + for (i = 0; i < top; i++){ - section_table_t *t = &iinfo->dn_section_tables [i]; + section_table_t *t = &iinfo->cli_section_tables [i]; if (fread (t, sizeof (section_table_t), 1, assembly->f) != 1) return FALSE; @@ -71,36 +144,40 @@ load_section_tables (MonoAssembly *assembly, dotnet_image_info_t *iinfo) t->st_line_count = le16_to_cpu (t->st_line_count); } + for (i = 0; i < top; i++) + if (!mono_assembly_ensure_section_idx (assembly, i)) + return FALSE; + return TRUE; } static gboolean -load_cli_header (MonoAssembly *assembly, dotnet_image_info_t *iinfo) +load_cli_header (MonoAssembly *assembly, cli_image_info_t *iinfo) { guint32 offset; int n; - offset = coff_map (iinfo, iinfo->dn_header.datadir.pe_cli_header.rva); + offset = cli_rva_image_map (iinfo, iinfo->cli_header.datadir.pe_cli_header.rva); if (offset == INVALID_ADDRESS) return FALSE; if (fseek (assembly->f, offset, 0) != 0) return FALSE; - if ((n = fread (&iinfo->dn_cli_header, sizeof (cli_header_t), 1, assembly->f)) != 1) + if ((n = fread (&iinfo->cli_cli_header, sizeof (cli_header_t), 1, assembly->f)) != 1) return FALSE; /* Catch new uses of the fields that are supposed to be zero */ - if ((iinfo->dn_cli_header.ch_eeinfo_table.rva != 0) || - (iinfo->dn_cli_header.ch_helper_table.rva != 0) || - (iinfo->dn_cli_header.ch_dynamic_info.rva != 0) || - (iinfo->dn_cli_header.ch_delay_load_info.rva != 0) || - (iinfo->dn_cli_header.ch_module_image.rva != 0) || - (iinfo->dn_cli_header.ch_external_fixups.rva != 0) || - (iinfo->dn_cli_header.ch_ridmap.rva != 0) || - (iinfo->dn_cli_header.ch_debug_map.rva != 0) || - (iinfo->dn_cli_header.ch_ip_map.rva != 0)){ + if ((iinfo->cli_cli_header.ch_eeinfo_table.rva != 0) || + (iinfo->cli_cli_header.ch_helper_table.rva != 0) || + (iinfo->cli_cli_header.ch_dynamic_info.rva != 0) || + (iinfo->cli_cli_header.ch_delay_load_info.rva != 0) || + (iinfo->cli_cli_header.ch_module_image.rva != 0) || + (iinfo->cli_cli_header.ch_external_fixups.rva != 0) || + (iinfo->cli_cli_header.ch_ridmap.rva != 0) || + (iinfo->cli_cli_header.ch_debug_map.rva != 0) || + (iinfo->cli_cli_header.ch_ip_map.rva != 0)){ g_message ("Some fields in the CLI header which should have been zero are not zero"); } @@ -108,16 +185,16 @@ load_cli_header (MonoAssembly *assembly, dotnet_image_info_t *iinfo) } static gboolean -load_metadata_ptrs (MonoAssembly *assembly, dotnet_image_info_t *iinfo) +load_metadata_ptrs (MonoAssembly *assembly, cli_image_info_t *iinfo) { - metadata_t *metadata = &iinfo->dn_metadata; + metadata_t *metadata = &iinfo->cli_metadata; guint32 offset, size; - guint16 records; + guint16 streams; int i; char *ptr; - offset = coff_map (iinfo, iinfo->dn_cli_header.ch_metadata.rva); - size = iinfo->dn_cli_header.ch_metadata.size; + offset = cli_rva_image_map (iinfo, iinfo->cli_cli_header.ch_metadata.rva); + size = iinfo->cli_cli_header.ch_metadata.size; metadata->raw_metadata = raw_buffer_load (fileno (assembly->f), FALSE, offset, size); if (metadata->raw_metadata == NULL) @@ -125,25 +202,25 @@ load_metadata_ptrs (MonoAssembly *assembly, dotnet_image_info_t *iinfo) ptr = metadata->raw_metadata; - /* - * Handle Beta 1 and ECMA versions of the metadata root - */ - if (strncmp (ptr, "COM+", 4) == 0){ - ptr += 10; - } else if (strncmp (ptr, "BSJB", 4) == 0){ + if (strncmp (ptr, "BSJB", 4) == 0){ guint32 version_string_len; - ptr += 8; + ptr += 12; version_string_len = read32 (ptr); + ptr += 4; ptr += version_string_len; if (((guint32) ptr) % 4) ptr += 4 - (((guint32) ptr) %4); - } + } else + return FALSE; - records = read16 (ptr); + /* skip over flags */ + ptr += 2; + + streams = read16 (ptr); ptr += 2; - for (i = 0; i < records; i++){ + for (i = 0; i < streams; i++){ if (strncmp (ptr + 8, "#~", 3) == 0){ metadata->heap_tables.sh_offset = read32 (ptr); metadata->heap_tables.sh_size = read32 (ptr + 4); @@ -173,6 +250,9 @@ load_metadata_ptrs (MonoAssembly *assembly, dotnet_image_info_t *iinfo) return TRUE; } +/* + * Load representation of logical metadata tables, from the "#~" stream + */ static gboolean load_tables (MonoAssembly *assembly, metadata_t *meta) { @@ -180,47 +260,70 @@ load_tables (MonoAssembly *assembly, metadata_t *meta) guint32 *rows; guint64 valid_mask; int valid = 0, table; + int heap_sizes; + + heap_sizes = heap_tables [6]; + meta->idx_string_wide = ((heap_sizes & 0x01) == 1); + meta->idx_guid_wide = ((heap_sizes & 0x02) == 2); + meta->idx_blob_wide = ((heap_sizes & 0x04) == 4); valid_mask = read64 (heap_tables + 8); rows = (guint32 *) (heap_tables + 24); for (table = 0; table < 64; table++){ if ((valid_mask & ((guint64) 1 << table)) == 0){ - meta->rows [table] = 0; + meta->tables [table].rows = 0; continue; } - meta->rows [table] = *rows; + if (table > 0x2b) { + g_warning("bits in valid must be zero above 0x2b (II - 23.1.6)"); + } + meta->tables [table].rows = read32 (rows); rows++; valid++; } + meta->tables_base = (heap_tables + 24) + (4 * valid); + + /* They must be the same */ + g_assert ((void *) meta->tables_base == (void *) rows); + + mono_metadata_compute_table_bases (meta); return TRUE; } static gboolean -load_metadata (MonoAssembly *assembly, dotnet_image_info_t *iinfo) +load_metadata (MonoAssembly *assembly, cli_image_info_t *iinfo) { if (!load_metadata_ptrs (assembly, iinfo)) return FALSE; - return load_tables (assembly, &iinfo->dn_metadata); + return load_tables (assembly, &iinfo->cli_metadata); } +/** + * mono_assembly_open: + * @fname: filename that points to the module we want to open + * @status: An error condition is returned in this field + * + * Retuns: An open assembly of type %MonoAssembly or NULL on error. + * if NULL, then check the value of @status for details on the error + */ MonoAssembly * mono_assembly_open (const char *fname, enum MonoAssemblyOpenStatus *status) { - dotnet_image_info_t *iinfo; + cli_image_info_t *iinfo; dotnet_header_t *header; msdos_header_t msdos; MonoAssembly *assembly; int n; - assembly = g_new (MonoAssembly, 1); + assembly = g_new0 (MonoAssembly, 1); assembly->f = fopen (fname, "r"); - iinfo = g_new (dotnet_image_info_t, 1); + iinfo = g_new0 (cli_image_info_t, 1); assembly->image_info = iinfo; - header = &iinfo->dn_header; + header = &iinfo->cli_header; if (assembly->f == NULL){ if (status) @@ -265,6 +368,13 @@ invalid_image: return NULL; } +/** + * mono_assembly_close: + * @assembly: The image file we wish to close + * + * Closes an image file, deallocates all memory consumed and + * unmaps all possible sections of the file + */ void mono_assembly_close (MonoAssembly *assembly) { @@ -274,26 +384,39 @@ mono_assembly_close (MonoAssembly *assembly) fclose (assembly->f); if (assembly->image_info){ - dotnet_image_info_t *ii = assembly->image_info; + cli_image_info_t *ii = assembly->image_info; + int i; - if (ii->dn_metadata.raw_metadata != NULL) - raw_buffer_free (ii->dn_metadata.raw_metadata); + if (ii->cli_metadata.raw_metadata != NULL) + raw_buffer_free (ii->cli_metadata.raw_metadata); - if (ii->dn_section_tables) - g_free (ii->dn_section_tables); - + for (i = 0; i < ii->cli_section_count; i++){ + if (!ii->cli_sections [i]) + continue; + raw_buffer_free (ii->cli_sections [i]); + } + if (ii->cli_section_tables) + g_free (ii->cli_section_tables); + if (ii->cli_sections) + g_free (ii->cli_sections); g_free (assembly->image_info); } g_free (assembly); } +/** + * mono_assembly_strerror: + * @status: an code indicating the result from a recent operation + * + * Returns: a string describing the error + */ const char * mono_assembly_strerror (enum MonoAssemblyOpenStatus status) { switch (status){ case MONO_ASSEMBLY_OK: - return "succes"; + return "success"; case MONO_ASSEMBLY_ERROR_ERRNO: return strerror (errno); case MONO_ASSEMBLY_IMAGE_INVALID: @@ -301,3 +424,4 @@ mono_assembly_strerror (enum MonoAssemblyOpenStatus status) } return "Internal error"; } + diff --git a/mono/metadata/assembly.h b/mono/metadata/assembly.h index dcec354f007..bcb592eec89 100644 --- a/mono/metadata/assembly.h +++ b/mono/metadata/assembly.h @@ -12,9 +12,15 @@ enum MonoAssemblyOpenStatus { MONO_ASSEMBLY_IMAGE_INVALID }; -MonoAssembly *mono_assembly_open (const char *fname, enum MonoAssemblyOpenStatus *status); -void mono_assembly_close (MonoAssembly *assembly); - +MonoAssembly *mono_assembly_open (const char *fname, + enum MonoAssemblyOpenStatus *status); +void mono_assembly_close (MonoAssembly *assembly); const char *mono_assembly_strerror (enum MonoAssemblyOpenStatus status); + + +int mono_assembly_ensure_section (MonoAssembly *assembly, + const char *section); +int mono_assembly_ensure_section_idx (MonoAssembly *assembly, + int section); #endif diff --git a/mono/metadata/blobsig.h b/mono/metadata/blobsig.h new file mode 100644 index 00000000000..a6d01b810c1 --- /dev/null +++ b/mono/metadata/blobsig.h @@ -0,0 +1,8 @@ +#ifndef _MONO_METADATA_BLOB_SIG_H_ +#define _MONO_METADATA_BLOB_SIG_H_ + +#define SIGNATURE_HAS_THIS 0x20 +#define SIGNATURE_EXPLICIT_THIS 0x40 +#define SIGNATURE_VARARG 0x05 + +#endif diff --git a/mono/metadata/cil-coff.h b/mono/metadata/cil-coff.h index ee4f001e2b0..7d14cadc8f1 100644 --- a/mono/metadata/cil-coff.h +++ b/mono/metadata/cil-coff.h @@ -1,3 +1,7 @@ + +#ifndef __MONO_CIL_COFF_H__ +#define __MONO_CIL_COFF_H__ + #include <mono/metadata/metadata.h> /* A metadata token */ @@ -110,6 +114,7 @@ typedef struct { #define SECT_FLAGS_MEM_READ 0x40000000 #define SECT_FLAGS_MEM_WRITE 0x80000000 guint32 st_flags; + } section_table_t; typedef struct { @@ -144,13 +149,27 @@ typedef struct { /* This is not an on-disk structure */ typedef struct { - dotnet_header_t dn_header; - int dn_section_count; - section_table_t *dn_section_tables; - cli_header_t dn_cli_header; + dotnet_header_t cli_header; + int cli_section_count; + section_table_t *cli_section_tables; + void **cli_sections; + cli_header_t cli_cli_header; + + metadata_t cli_metadata; +} cli_image_info_t; + +typedef struct { + MonoMetaMethodHeader *header; + MonoMethodSignature *signature; + guint32 name; /* index in string heap */ + /* add flags, info from param table ... */ +} MonoMethod; - metadata_t dn_metadata; -} dotnet_image_info_t; +guint32 cli_rva_image_map (cli_image_info_t *iinfo, guint32 rva); +char *cli_rva_map (cli_image_info_t *iinfo, guint32 rva); +MonoMethod *mono_get_method (cli_image_info_t *iinfo, guint32 token); +void mono_free_method (MonoMethod *method); +#endif /* __MONO_CIL_COFF_H__ */ diff --git a/mono/metadata/eltype.h b/mono/metadata/eltype.h new file mode 100644 index 00000000000..f7cb5c796a6 --- /dev/null +++ b/mono/metadata/eltype.h @@ -0,0 +1,43 @@ +#ifndef _MONO_METADATA_ELTYPE_H_ +#define _MONO_METADATA_ELTYPE_H_ + +/* + * Encoding for type signatures used in the Metadata + */ +typedef enum { + ELEMENT_TYPE_END = 0x00, /* End of List */ + ELEMENT_TYPE_VOID = 0x01, + ELEMENT_TYPE_BOOLEAN = 0x02, + ELEMENT_TYPE_CHAR = 0x03, + ELEMENT_TYPE_I1 = 0x04, + ELEMENT_TYPE_U1 = 0x05, + ELEMENT_TYPE_I2 = 0x06, + ELEMENT_TYPE_U2 = 0x07, + ELEMENT_TYPE_I4 = 0x08, + ELEMENT_TYPE_U4 = 0x09, + ELEMENT_TYPE_I8 = 0x0a, + ELEMENT_TYPE_U8 = 0x0b, + ELEMENT_TYPE_R4 = 0x0c, + ELEMENT_TYPE_R8 = 0x0d, + ELEMENT_TYPE_STRING = 0x0e, + ELEMENT_TYPE_PTR = 0x0f, /* arg: <type> token */ + ELEMENT_TYPE_BYREF = 0x10, /* arg: <type> token */ + ELEMENT_TYPE_VALUETYPE = 0x11, /* arg: <type> token */ + ELEMENT_TYPE_CLASS = 0x12, /* arg: <type> token */ + ELEMENT_TYPE_ARRAY = 0x14, /* type, rank, boundsCount, bound1, loCount, lo1 */ + ELEMENT_TYPE_TYPEDBYREF = 0x15, + ELEMENT_TYPE_I = 0x18, + ELEMENT_TYPE_U = 0x19, + ELEMENT_TYPE_FNPTR = 0x1b, /* arg: full method signature */ + ELEMENT_TYPE_OBJECT = 0x1c, + ELEMENT_TYPE_SZARRAY = 0x1d, /* 0-based one-dim-array */ + ELEMENT_TYPE_CMOD_REQD = 0x1f, /* arg: typedef or typeref token */ + ELEMENT_TYPE_CMOD_OPT = 0x20, /* optional arg: typedef or typref token */ + ELEMENT_TYPE_INTERNAL = 0x21, /* CLR internal type */ + + ELEMENT_TYPE_MODIFIER = 0x40, /* Or with the following types */ + ELEMENT_TYPE_SENTINEL = 0x41, /* Sentinel for varargs method signature */ + ELEMENT_TYPE_PINNED = 0x45, /* Local var that points to pinned object */ +} ElementTypeEnum; + +#endif /* _MONO_METADATA_ELTYPE_H_ */ diff --git a/mono/metadata/endian.h b/mono/metadata/endian.h new file mode 100644 index 00000000000..8da0e4126e0 --- /dev/null +++ b/mono/metadata/endian.h @@ -0,0 +1,13 @@ +#ifndef _MONO_METADATA_ENDIAN_H_ +#define _MONO_METADATA_ENDIAN_H_ 1 + +/* FIXME: implement big endian versions */ + +#define le64_to_cpu(x) (x) +#define le32_to_cpu(x) (x) +#define le16_to_cpu(x) (x) +#define read32(x) le32_to_cpu (*((guint32 *) (x))) +#define read16(x) le16_to_cpu (*((guint16 *) (x))) +#define read64(x) le64_to_cpu (*((guint64 *) (x))) + +#endif /* _MONO_METADATA_ENDIAN_H_ */ diff --git a/mono/metadata/fieldattr.h b/mono/metadata/fieldattr.h new file mode 100644 index 00000000000..8b2e50e3680 --- /dev/null +++ b/mono/metadata/fieldattr.h @@ -0,0 +1,34 @@ +#ifndef _MONO_METADATA_FIELDATTR_H_ +#define _MONO_METADATA_FIELDATTR_H_ +/* + * Flags for bitmasks in the metadata tables + */ + +/* + * Field Attributes (21.1.5). + */ + +#define FIELD_ATTRIBUTE_FIELD_ACCESS_MASK 0x0007 +#define FIELD_ATTRIBUTE_COMPILER_CONTROLLED 0x0000 +#define FIELD_ATTRIBUTE_PRIVATE 0x0001 +#define FIELD_ATTRIBUTE_FAM_AND_ASSEM 0x0002 +#define FIELD_ATTRIBUTE_ASSEMBLY 0x0003 +#define FIELD_ATTRIBUTE_FAMILY 0x0004 +#define FIELD_ATTRIBUTE_FAM_OR_ASSEM 0x0005 +#define FIELD_ATTRIBUTE_PUBLIC 0x0006 + +#define FIELD_ATTRIBUTE_STATIC 0x0010 +#define FIELD_ATTRIBUTE_INIT_ONLY 0x0020 +#define FIELD_ATTRIBUTE_LITERAL 0x0040 +#define FIELD_ATTRIBUTE_NOT_SERIALIZED 0x0080 +#define FIELD_ATTRIBUTE_SPECIAL_NAME 0x0200 +#define FIELD_ATTRIBUTE_PINVOKE_IMPL 0x2000 + +/* For runtime use only */ +#define FIELD_ATTRIBUTE_RESERVED_MASK 0x9500 +#define FIELD_ATTRIBUTE_RT_SPECIAL_NAME 0x0400 +#define FIELD_ATTRIBUTE_HAS_FIELD_MARSHAL 0x1000 +#define FIELD_ATTRIBUTE_HAS_DEFAULT 0x8000 +#define FIELD_ATTRIBUTE_HAS_FIELD_RVA 0x0100 + +#endif diff --git a/mono/metadata/metadata.c b/mono/metadata/metadata.c index 02db6e5c04b..650ad7ba446 100644 --- a/mono/metadata/metadata.c +++ b/mono/metadata/metadata.c @@ -8,6 +8,1305 @@ */ #include <config.h> +#include <stdio.h> #include <glib.h> #include "metadata.h" +#include "methodheader.h" +#include "endian.h" +#include "cil-coff.h" +/* + * Encoding of the "description" argument: + * + * identifier [CODE ARG] + * + * If CODE is ':', then a lookup on table ARG is performed + * If CODE is '=', then a lookup in the aliased-table ARG is performed + * If CODE is '#', then this encodes a flag, ARG is the flag name. + * + * Aliased table for example is `CustomAttributeType' which depending on the + * information might refer to different tables. + */ + +static MonoMetaTable AssemblySchema [] = { + { MONO_MT_UINT32, "HashId" }, + { MONO_MT_UINT16, "Major" }, + { MONO_MT_UINT16, "Minor" }, + { MONO_MT_UINT16, "BuildNumber" }, + { MONO_MT_UINT16, "RevisionNumber" }, + { MONO_MT_UINT32, "Flags" }, + { MONO_MT_BLOB_IDX, "PublicKey" }, + { MONO_MT_STRING_IDX, "Name" }, + { MONO_MT_STRING_IDX, "Culture" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable AssemblyOSSchema [] = { + { MONO_MT_UINT32, "OSPlatformID" }, + { MONO_MT_UINT32, "OSMajor" }, + { MONO_MT_UINT32, "OSMinor" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable AssemblyProcessorSchema [] = { + { MONO_MT_UINT32, "Processor" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable AssemblyRefSchema [] = { + { MONO_MT_UINT16, "Major" }, + { MONO_MT_UINT16, "Minor" }, + { MONO_MT_UINT16, "Build" }, + { MONO_MT_UINT16, "Revision" }, + { MONO_MT_UINT32, "Flags" }, + { MONO_MT_BLOB_IDX, "PublicKeyOrToken" }, + { MONO_MT_STRING_IDX, "Name" }, + { MONO_MT_STRING_IDX, "Culture" }, + { MONO_MT_BLOB_IDX, "HashValue" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable AssemblyRefOSSchema [] = { + { MONO_MT_UINT32, "OSPlatformID" }, + { MONO_MT_UINT32, "OSMajorVersion" }, + { MONO_MT_UINT32, "OSMinorVersion" }, + { MONO_MT_TABLE_IDX, "AssemblyRef:AssemblyRef" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable AssemblyRefProcessorSchema [] = { + { MONO_MT_UINT32, "Processor" }, + { MONO_MT_TABLE_IDX, "AssemblyRef:AssemblyRef" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable ClassLayoutSchema [] = { + { MONO_MT_UINT16, "PackingSize" }, + { MONO_MT_UINT32, "ClassSize" }, + { MONO_MT_TABLE_IDX, "Parent:TypeDef" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable ConstantSchema [] = { + { MONO_MT_UINT8, "Type" }, + { MONO_MT_UINT8, "PaddingZero" }, + { MONO_MT_CONST_IDX, "Parent" }, + { MONO_MT_BLOB_IDX, "Value" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable CustomAttributeSchema [] = { + { MONO_MT_HASCAT_IDX, "Parent" }, + { MONO_MT_CAT_IDX, "Type" }, + { MONO_MT_BLOB_IDX, "Value" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable DeclSecuritySchema [] = { + { MONO_MT_UINT16, "Action" }, + { MONO_MT_HASDEC_IDX, "Parent" }, + { MONO_MT_BLOB_IDX, "PermissionSet" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable EventMapSchema [] = { + { MONO_MT_TABLE_IDX, "Parent:TypeDef" }, + { MONO_MT_TABLE_IDX, "EventList:Event" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable EventSchema [] = { + { MONO_MT_UINT16, "EventFlags#EventAttribute" }, + { MONO_MT_STRING_IDX, "Name" }, + { MONO_MT_TABLE_IDX, "EventType" }, /* TypeDef or TypeRef */ + { MONO_MT_END, NULL } +}; + +static MonoMetaTable ExportedTypeSchema [] = { + { MONO_MT_UINT32, "Flags" }, + { MONO_MT_TABLE_IDX, "TypeDefId" }, + { MONO_MT_STRING_IDX, "TypeName" }, + { MONO_MT_STRING_IDX, "TypeNameSpace" }, + { MONO_MT_IMPL_IDX, "Implementation" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable FieldSchema [] = { + { MONO_MT_UINT16, "Flags" }, + { MONO_MT_STRING_IDX, "Name" }, + { MONO_MT_BLOB_IDX, "Signature" }, + { MONO_MT_END, NULL } +}; +static MonoMetaTable FieldLayoutSchema [] = { + { MONO_MT_UINT32, "Offset" }, + { MONO_MT_TABLE_IDX, "Field:Field" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable FieldMarshalSchema [] = { + { MONO_MT_HFM_IDX, "Parent" }, + { MONO_MT_BLOB_IDX, "NativeType" }, + { MONO_MT_END, NULL } +}; +static MonoMetaTable FieldRVASchema [] = { + { MONO_MT_UINT32, "RVA" }, + { MONO_MT_TABLE_IDX, "Field:Field" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable FileSchema [] = { + { MONO_MT_UINT32, "Flags" }, + { MONO_MT_STRING_IDX, "Name" }, + { MONO_MT_BLOB_IDX, "Value" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable ImplMapSchema [] = { + { MONO_MT_UINT16, "MappingFlag" }, + { MONO_MT_MF_IDX, "MemberForwarded" }, + { MONO_MT_STRING_IDX, "ImportName" }, + { MONO_MT_TABLE_IDX, "ImportScope:ModuleRef" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable InterfaceImplSchema [] = { + { MONO_MT_TABLE_IDX, "Class:TypeDef" }, + { MONO_MT_TDOR_IDX, "Interface=TypeDefOrRef" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable ManifestResourceSchema [] = { + { MONO_MT_UINT32, "Offset" }, + { MONO_MT_UINT32, "Flags" }, + { MONO_MT_STRING_IDX, "Name" }, + { MONO_MT_IMPL_IDX, "Implementation" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable MemberRefSchema [] = { + { MONO_MT_MRP_IDX, "Class" }, + { MONO_MT_STRING_IDX, "Name" }, + { MONO_MT_BLOB_IDX, "Signature" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable MethodSchema [] = { + { MONO_MT_UINT32, "RVA" }, + { MONO_MT_UINT16, "ImplFlags#MethodImplAttributes" }, + { MONO_MT_UINT16, "Flags#MethodAttribute" }, + { MONO_MT_STRING_IDX, "Name" }, + { MONO_MT_BLOB_IDX, "Signature" }, + { MONO_MT_TABLE_IDX, "ParamList:Param" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable MethodImplSchema [] = { + { MONO_MT_TABLE_IDX, "Class:TypeDef" }, + { MONO_MT_MDOR_IDX, "MethodBody" }, + { MONO_MT_MDOR_IDX, "MethodDeclaration" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable MethodSemanticsSchema [] = { + { MONO_MT_UINT16, "MethodSemantic" }, + { MONO_MT_TABLE_IDX, "Method:Method" }, + { MONO_MT_HS_IDX, "Association" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable ModuleSchema [] = { + { MONO_MT_UINT16, "Generation" }, + { MONO_MT_STRING_IDX, "Name" }, + { MONO_MT_GUID_IDX, "MVID" }, + { MONO_MT_GUID_IDX, "EncID" }, + { MONO_MT_GUID_IDX, "EncBaseID" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable ModuleRefSchema [] = { + { MONO_MT_STRING_IDX, "Name" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable NestedClassSchema [] = { + { MONO_MT_TABLE_IDX, "NestedClass:TypeDef" }, + { MONO_MT_TABLE_IDX, "EnclosingClass:TypeDef" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable ParamSchema [] = { + { MONO_MT_UINT16, "Flags" }, + { MONO_MT_UINT16, "Sequence" }, + { MONO_MT_STRING_IDX, "Name" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable PropertySchema [] = { + { MONO_MT_UINT16, "Flags" }, + { MONO_MT_STRING_IDX, "Name" }, + { MONO_MT_BLOB_IDX, "Type" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable PropertyMapSchema [] = { + { MONO_MT_TABLE_IDX, "Parent:TypeDef" }, + { MONO_MT_TABLE_IDX, "PropertyList:Property" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable StandaloneSigSchema [] = { + { MONO_MT_BLOB_IDX, "Signature" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable TypeDefSchema [] = { + { MONO_MT_UINT32, "Flags" }, + { MONO_MT_STRING_IDX, "Name" }, + { MONO_MT_STRING_IDX, "Namespace" }, + { MONO_MT_TDOR_IDX, "Extends" }, + { MONO_MT_TABLE_IDX, "FieldList:Field" }, + { MONO_MT_TABLE_IDX, "MethodList:Method" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable TypeRefSchema [] = { + { MONO_MT_RS_IDX, "ResolutionScope=ResolutionScope" }, + { MONO_MT_STRING_IDX, "Name" }, + { MONO_MT_STRING_IDX, "Namespace" }, + { MONO_MT_END, NULL } +}; + +static MonoMetaTable TypeSpecSchema [] = { + { MONO_MT_BLOB_IDX, "Signature" }, + { MONO_MT_END, NULL } +}; + +static struct { + MonoMetaTable *table; + const char *name; +} tables [] = { + /* 0 */ { ModuleSchema, "Module" }, + /* 1 */ { TypeRefSchema, "TypeRef" }, + /* 2 */ { TypeDefSchema, "TypeDef" }, + /* 3 */ { NULL, NULL }, + /* 4 */ { FieldSchema, "Field" }, + /* 5 */ { NULL, NULL }, + /* 6 */ { MethodSchema, "Method" }, + /* 7 */ { NULL, NULL }, + /* 8 */ { ParamSchema, "Param" }, + /* 9 */ { InterfaceImplSchema, "InterfaceImpl" }, + /* A */ { MemberRefSchema, "MemberRef" }, + /* B */ { ConstantSchema, "Constant" }, + /* C */ { CustomAttributeSchema, "CustomAttribute" }, + /* D */ { FieldMarshalSchema, "FieldMarshal" }, + /* E */ { DeclSecuritySchema, "DeclSecurity" }, + /* F */ { ClassLayoutSchema, "ClassLayout" }, + /* 10 */ { FieldLayoutSchema, "FieldLayout" }, + /* 11 */ { StandaloneSigSchema, "StandaloneSig" }, + /* 12 */ { EventMapSchema, "EventMap" }, + /* 13 */ { NULL, NULL }, + /* 14 */ { EventSchema, "Event" }, + /* 15 */ { PropertyMapSchema, "PropertyMap" }, + /* 16 */ { NULL, NULL }, + /* 17 */ { PropertySchema, "PropertyTable" }, + /* 18 */ { MethodSemanticsSchema, "MethodSemantics" }, + /* 19 */ { MethodImplSchema, "MethodImpl" }, + /* 1A */ { ModuleRefSchema, "ModuleRef" }, + /* 1B */ { TypeSpecSchema, "TypeSpec" }, + /* 1C */ { ImplMapSchema, "ImplMap" }, + /* 1D */ { FieldRVASchema, "FieldRVA" }, + /* 1E */ { NULL, NULL }, + /* 1F */ { NULL, NULL }, + /* 20 */ { AssemblySchema, "Assembly" }, + /* 21 */ { AssemblyProcessorSchema, "AssemblyProcessor" }, + /* 22 */ { AssemblyOSSchema, "AssemblyOS" }, + /* 23 */ { AssemblyRefSchema, "AssemblyRef" }, + /* 24 */ { AssemblyRefProcessorSchema, "AssemblyRefProcessor" }, + /* 25 */ { AssemblyRefOSSchema, "AssemblyRefOS" }, + /* 26 */ { FileSchema, "File" }, + /* 27 */ { ExportedTypeSchema, "ExportedType" }, + /* 28 */ { ManifestResourceSchema, "ManifestResource" }, + /* 29 */ { NestedClassSchema, "NestedClass" }, + /* 2A */ { NULL, NULL }, + /* 2B */ { NULL, NULL }, +}; + +/** + * mono_meta_table_name: + * @table: table index + * + * Returns the name for the @table index + */ +const char * +mono_meta_table_name (int table) +{ + if ((table < 0) || (table > 0x29)) + return ""; + + return tables [table].name; +} + +/* The guy who wrote the spec for this should not be allowed near a + * computer again. + +If e is a coded token(see clause 23.1.7) that points into table ti out of n possible tables t0, .. tn-1, +then it is stored as e << (log n) & tag{ t0, .. tn-1}[ ti] using 2 bytes if the maximum number of +rows of tables t0, ..tn-1, is less than 2^16 - (log n), and using 4 bytes otherwise. The family of +finite maps tag{ t0, ..tn-1} is defined below. Note that to decode a physical row, you need the +inverse of this mapping. + + */ +#define rtsize(s,b) (((s) < (1 << (b)) ? 2 : 4)) +#define idx_size(tableidx) (meta->tables [(tableidx)].rows < 65536 ? 2 : 4) + +/* Reference: Partition II - 23.2.6 */ +static int +compute_size (metadata_t *meta, MonoMetaTable *table, int tableindex, guint32 *result_bitfield) +{ + guint32 bitfield = 0; + int size = 0, field_size; + int i, n, code; + int shift = 0; + + for (i = 0; (code = table [i].code) != MONO_MT_END; i++){ + switch (code){ + case MONO_MT_UINT32: + field_size = 4; break; + + case MONO_MT_UINT16: + field_size = 2; break; + + case MONO_MT_UINT8: + field_size = 1; break; + + case MONO_MT_BLOB_IDX: + field_size = meta->idx_blob_wide ? 4 : 2; break; + + case MONO_MT_STRING_IDX: + field_size = meta->idx_string_wide ? 4 : 2; break; + + case MONO_MT_GUID_IDX: + field_size = meta->idx_guid_wide ? 4 : 2; break; + + case MONO_MT_TABLE_IDX: + /* Uhm, a table index can point to other tables besides the current one + * so, it's not correct to use the rowcount of the current table to + * get the size for this column - lupus + */ + switch (tableindex) { + case META_TABLE_ASSEMBLYREFOS: + g_assert (i == 3); + field_size = idx_size (META_TABLE_ASSEMBLYREF); break; + case META_TABLE_ASSEMBLYPROCESSOR: + g_assert (i == 1); + field_size = idx_size (META_TABLE_ASSEMBLYREF); break; + case META_TABLE_CLASSLAYOUT: + g_assert (i == 2); + field_size = idx_size (META_TABLE_TYPEDEF); break; + case META_TABLE_EVENTMAP: + g_assert (i == 0 || i == 1); + field_size = i ? idx_size (META_TABLE_EVENT): + idx_size(META_TABLE_TYPEDEF); + break; + case META_TABLE_EVENT: + g_assert (i == 2); + field_size = MAX (idx_size (META_TABLE_TYPEDEF), idx_size(META_TABLE_TYPEREF)); + field_size = MAX (field_size, idx_size(META_TABLE_TYPESPEC)); + break; + case META_TABLE_EXPORTEDTYPE: + g_assert (i == 1); + field_size = idx_size (META_TABLE_TYPEDEF); break; + case META_TABLE_FIELDLAYOUT: + g_assert (i == 1); + field_size = idx_size (META_TABLE_FIELD); break; + case META_TABLE_FIELDRVA: + g_assert (i == 1); + field_size = idx_size (META_TABLE_FIELD); break; + case META_TABLE_IMPLMAP: + g_assert (i == 3); + field_size = idx_size (META_TABLE_MODULEREF); break; + case META_TABLE_INTERFACEIMPL: + g_assert (i == 0); + field_size = idx_size (META_TABLE_TYPEDEF); break; + case META_TABLE_METHOD: + g_assert (i == 5); + field_size = idx_size (META_TABLE_PARAM); break; + case META_TABLE_METHODIMPL: + g_assert (i == 0); + field_size = idx_size (META_TABLE_TYPEDEF); break; + case META_TABLE_METHODSEMANTICS: + g_assert (i == 1); + field_size = idx_size (META_TABLE_METHOD); break; + case META_TABLE_NESTEDCLASS: + g_assert (i == 0 || i == 1); + field_size = idx_size (META_TABLE_TYPEDEF); break; + case META_TABLE_PROPERTYMAP: + g_assert (i == 0 || i == 1); + field_size = i ? idx_size (META_TABLE_PROPERTY): + idx_size(META_TABLE_TYPEDEF); + break; + case META_TABLE_TYPEDEF: + g_assert (i == 4 || i == 5); + field_size = i == 4 ? idx_size (META_TABLE_FIELD): + idx_size(META_TABLE_METHOD); + break; + default: + g_assert_not_reached (); + } + if (field_size != idx_size (tableindex)) + g_warning ("size changed (%d to %d)", idx_size (tableindex), field_size); + + break; + + /* + * HasConstant: ParamDef, FieldDef, Property + */ + case MONO_MT_CONST_IDX: + n = MAX (meta->tables [META_TABLE_PARAM].rows, + meta->tables [META_TABLE_FIELD].rows); + n = MAX (n, meta->tables [META_TABLE_PROPERTY].rows); + + /* 2 bits to encode tag */ + field_size = rtsize (n, 16-2); + break; + + /* + * HasCustomAttribute: points to any table but + * itself. + */ + case MONO_MT_HASCAT_IDX: + /* + * We believe that since the signature and + * permission are indexing the Blob heap, + * we should consider the blob size first + */ + /* I'm not a believer - lupus + if (meta->idx_blob_wide){ + field_size = 4; + break; + }*/ + + n = MAX (meta->tables [META_TABLE_METHOD].rows, + meta->tables [META_TABLE_FIELD].rows); + n = MAX (n, meta->tables [META_TABLE_TYPEREF].rows); + n = MAX (n, meta->tables [META_TABLE_TYPEDEF].rows); + n = MAX (n, meta->tables [META_TABLE_PARAM].rows); + n = MAX (n, meta->tables [META_TABLE_INTERFACEIMPL].rows); + n = MAX (n, meta->tables [META_TABLE_MEMBERREF].rows); + n = MAX (n, meta->tables [META_TABLE_MODULE].rows); + /* Permission seems to be a blob heap pointer */ + n = MAX (n, meta->tables [META_TABLE_PROPERTY].rows); + n = MAX (n, meta->tables [META_TABLE_EVENT].rows); + /* Signature seems to be a blob heap pointer */ + n = MAX (n, meta->tables [META_TABLE_MODULEREF].rows); + n = MAX (n, meta->tables [META_TABLE_TYPESPEC].rows); + n = MAX (n, meta->tables [META_TABLE_ASSEMBLY].rows); + n = MAX (n, meta->tables [META_TABLE_ASSEMBLYREF].rows); + n = MAX (n, meta->tables [META_TABLE_FILE].rows); + n = MAX (n, meta->tables [META_TABLE_EXPORTEDTYPE].rows); + n = MAX (n, meta->tables [META_TABLE_MANIFESTRESOURCE].rows); + + /* 5 bits to encode */ + field_size = rtsize (n, 16-5); + break; + + /* + * CustomAttributeType: TypeDef, TypeRef, MethodDef, + * MemberRef and String. + */ + case MONO_MT_CAT_IDX: + /* String is a heap, if it is wide, we know the size */ + /* See above, nope. + if (meta->idx_string_wide){ + field_size = 4; + break; + }*/ + + n = MAX (meta->tables [META_TABLE_TYPEREF].rows, + meta->tables [META_TABLE_TYPEDEF].rows); + n = MAX (n, meta->tables [META_TABLE_METHOD].rows); + n = MAX (n, meta->tables [META_TABLE_MEMBERREF].rows); + + /* 3 bits to encode */ + field_size = rtsize (n, 16-3); + break; + + /* + * HasDeclSecurity: Typedef, MethodDef, Assembly + */ + case MONO_MT_HASDEC_IDX: + n = MAX (meta->tables [META_TABLE_TYPEDEF].rows, + meta->tables [META_TABLE_METHOD].rows); + n = MAX (n, meta->tables [META_TABLE_ASSEMBLY].rows); + + /* 2 bits to encode */ + field_size = rtsize (n, 16-2); + break; + + /* + * Implementation: File, AssemblyRef, ExportedType + */ + case MONO_MT_IMPL_IDX: + n = MAX (meta->tables [META_TABLE_FILE].rows, + meta->tables [META_TABLE_ASSEMBLYREF].rows); + n = MAX (n, meta->tables [META_TABLE_EXPORTEDTYPE].rows); + + /* 2 bits to encode tag */ + field_size = rtsize (n, 16-2); + break; + + /* + * HasFieldMarshall: FieldDef, ParamDef + */ + case MONO_MT_HFM_IDX: + n = MAX (meta->tables [META_TABLE_FIELD].rows, + meta->tables [META_TABLE_PARAM].rows); + + /* 1 bit used to encode tag */ + field_size = rtsize (n, 16-1); + break; + + /* + * MemberForwarded: FieldDef, MethodDef + */ + case MONO_MT_MF_IDX: + n = MAX (meta->tables [META_TABLE_FIELD].rows, + meta->tables [META_TABLE_METHOD].rows); + + /* 1 bit used to encode tag */ + field_size = rtsize (n, 16-1); + break; + + /* + * TypeDefOrRef: TypeDef, ParamDef, TypeSpec + */ + case MONO_MT_TDOR_IDX: + n = MAX (meta->tables [META_TABLE_TYPEDEF].rows, + meta->tables [META_TABLE_PARAM].rows); + n = MAX (n, meta->tables [META_TABLE_TYPESPEC].rows); + + /* 2 bits to encode */ + field_size = rtsize (n, 16-2); + break; + + /* + * MemberRefParent: TypeDef, TypeRef, ModuleDef, ModuleRef, TypeSpec + */ + case MONO_MT_MRP_IDX: + n = MAX (meta->tables [META_TABLE_TYPEDEF].rows, + meta->tables [META_TABLE_TYPEREF].rows); + n = MAX (n, meta->tables [META_TABLE_MODULE].rows); + n = MAX (n, meta->tables [META_TABLE_MODULEREF].rows); + n = MAX (n, meta->tables [META_TABLE_TYPESPEC].rows); + + /* 3 bits to encode */ + field_size = rtsize (n, 16 - 3); + break; + + case MONO_MT_MDOR_IDX: + + /* + * MethodDefOrRef: MethodDef, MemberRef + */ + case MONO_MT_HS_IDX: + n = MAX (meta->tables [META_TABLE_METHOD].rows, + meta->tables [META_TABLE_MEMBERREF].rows); + + /* 1 bit used to encode tag */ + field_size = rtsize (n, 16-1); + break; + + /* + * ResolutionScope: Module, ModuleRef, AssemblyRef, TypeRef + */ + case MONO_MT_RS_IDX: + n = MAX (meta->tables [META_TABLE_MODULE].rows, + meta->tables [META_TABLE_MODULEREF].rows); + n = MAX (n, meta->tables [META_TABLE_ASSEMBLYREF].rows); + n = MAX (n, meta->tables [META_TABLE_TYPEREF].rows); + + /* 2 bits used to encode tag (ECMA spec claims 3) */ + field_size = rtsize (n, 16 - 2); + break; + } + + /* + * encode field size as follows (we just need to + * distinguish them). + * + * 4 -> 3 + * 2 -> 1 + * 1 -> 0 + */ + bitfield |= (field_size-1) << shift; + shift += 2; + size += field_size; + /*g_print ("table %02x field %d size %d\n", tableindex, i, field_size);*/ + } + + *result_bitfield = (i << 24) | bitfield; + return size; +} + +/** + * mono_metadata_compute_table_bases: + * @meta: metadata context to compute table values + * + * Computes the table bases for the metadata structure. + * This is an internal function used by the image loader code. + */ +void +mono_metadata_compute_table_bases (metadata_t *meta) +{ + int i; + char *base = meta->tables_base; + + for (i = 0; i < 64; i++){ + if (meta->tables [i].rows == 0) + continue; + + meta->tables [i].row_size = compute_size ( + meta, tables [i].table, i, + &meta->tables [i].size_bitfield); + meta->tables [i].base = base; + base += meta->tables [i].rows * meta->tables [i].row_size; + } +} + +/** + * mono_metadata_locate: + * @meta: metadata context + * @table: table code. + * @idx: index of element to retrieve from @table. + * + * Returns a pointer to the @idx element in the metadata table + * whose code is @table. + */ +char * +mono_metadata_locate (metadata_t *meta, int table, int idx) +{ + /* idx == 0 refers always to NULL */ + g_return_val_if_fail (idx > 0 && idx <= meta->tables [table].rows, ""); + + return meta->tables [table].base + (meta->tables [table].row_size * (idx - 1)); +} + +char * +mono_metadata_locate_token (metadata_t *meta, guint32 token) +{ + return mono_metadata_locate (meta, token >> 24, token & 0xffffff); +} + +/** + * mono_metadata_get_table: + * @table: table to retrieve + * + * Returns the MonoMetaTable structure for table @table + */ +MonoMetaTable * +mono_metadata_get_table (MetaTableEnum table) +{ + int x = (int) table; + + g_return_val_if_fail ((x > 0) && (x <= META_TABLE_LAST), NULL); + + return tables [table].table; +} + +/** + * mono_metadata_string_heap: + * @meta: metadata context + * @index: index into the string heap. + * + * Returns: an in-memory pointer to the @index in the string heap. + */ +const char * +mono_metadata_string_heap (metadata_t *meta, guint32 index) +{ + g_return_val_if_fail (index < meta->heap_strings.sh_size, ""); + return meta->raw_metadata + meta->heap_strings.sh_offset + index; +} + +const char * +mono_metadata_user_string (metadata_t *meta, guint32 index) +{ + g_return_val_if_fail (index < meta->heap_us.sh_size, ""); + return meta->raw_metadata + meta->heap_us.sh_offset + index; +} + +/** + * mono_metadata_blob_heap: + * @meta: metadata context + * @index: index into the blob. + * + * Returns: an in-memory pointer to the @index in the Blob heap. + */ +const char * +mono_metadata_blob_heap (metadata_t *meta, guint32 index) +{ + g_return_val_if_fail (index < meta->heap_blob.sh_size, ""); + return meta->raw_metadata + meta->heap_blob.sh_offset + index; +} + +static const char * +dword_align (const char *ptr) +{ + return (const char *) (((guint32) (ptr + 3)) & ~3); +} + +static MonoMetaExceptionHandler * +parse_exception_handler (const char *ptr, gboolean is_fat) +{ + MonoMetaExceptionHandler *eh = g_new0 (MonoMetaExceptionHandler, 1); + int size; + + eh->kind = (MonoMetaExceptionEnum) *ptr; + ptr++; + if (is_fat) + size = (ptr [0] << 16) | (ptr [1] << 8) | ptr [2]; + else + size = (unsigned char) ptr [0]; + + /* + * It must be aligned + */ + ptr += 4; + g_assert ((((guint32) ptr) & 3) == 0); + + if (is_fat){ + printf ("Records: %d (%d)\n", size / 12, size); + + } else { + printf ("Records: %d (%d)\n", size / 12, size); + + } + + return eh; +} + +/* cut and paste from expand: remove that one later */ +void +mono_metadata_decode_row (metadata_tableinfo_t *t, int idx, guint32 *res, int res_size) +{ + guint32 bitfield = t->size_bitfield; + int i, count = meta_table_count (bitfield); + char *data = t->base + idx * t->row_size; + + g_assert (res_size == count); + + for (i = 0; i < count; i++){ + int n = meta_table_size (bitfield, i); + + switch (n){ + case 1: + res [i] = *data; break; + case 2: + res [i] = read16 (data); break; + + case 4: + res [i] = read32 (data); break; + + default: + g_assert_not_reached (); + } + data += n; + } +} + +const char * +mono_metadata_decode_blob_size (const char *xptr, int *size) +{ + const unsigned char *ptr = xptr; + + if ((*ptr & 0x80) == 0){ + *size = ptr [0] & 0x7f; + ptr++; + } else if ((*ptr & 0x40) == 0){ + *size = ((ptr [0] & 0x3f) << 8) + ptr [1]; + ptr += 2; + } else { + *size = ((ptr [0] & 0x1f) << 24) + + (ptr [1] << 16) + + (ptr [2] << 8) + + ptr [3]; + ptr += 4; + } + + return (char *) ptr; +} + +/* cut and paste from get_encode_val */ +const char * +mono_metadata_decode_value (const char *_ptr, guint32 *len) +{ + const unsigned char *ptr = (unsigned char *) _ptr; + unsigned char b = *ptr; + + if ((b & 0x80) == 0){ + *len = b; + return ptr+1; + } else if ((b & 0x40) == 0){ + *len = ((b & 0x3f) << 8 | ptr [1]); + return ptr + 2; + } + *len = ((b & 0x1f) << 24) | + (ptr [1] << 16) | + (ptr [2] << 8) | + ptr [3]; + + return ptr + 4; +} + +guint32 +mono_metadata_parse_typedef_or_ref (metadata_t *m, const char *ptr, const char **rptr) +{ + guint32 token; + guint table; + ptr = mono_metadata_decode_value (ptr, &token); + switch (table & 0x03) { + case 0: table = META_TABLE_TYPEDEF; break; + case 1: table = META_TABLE_TYPEREF; break; + case 2: table = META_TABLE_TYPESPEC; break; + default: g_error ("Unhandled encoding for typedef-or-ref coded index"); + } + if (rptr) + *rptr = ptr; + return (token >> 2) | table << 24; +} + +int +mono_metadata_parse_custom_mod (metadata_t *m, MonoCustomMod *dest, const char *ptr, const char **rptr) +{ + MonoCustomMod local; + if ((*ptr == ELEMENT_TYPE_CMOD_OPT) || + (*ptr == ELEMENT_TYPE_CMOD_REQD)) { + if (!dest) + dest = &local; + dest->mod = *ptr++; + dest->token = mono_metadata_parse_typedef_or_ref (m, ptr, &ptr); + return TRUE; + } + return FALSE; +} + +MonoArray * +mono_metadata_parse_array (metadata_t *m, const char *ptr, const char **rptr) +{ + int i; + MonoArray *array = g_new0(MonoArray, 1); + + array->type = mono_metadata_parse_type (m, ptr, &ptr); + ptr = mono_metadata_decode_value (ptr, &array->rank); + + ptr = mono_metadata_decode_value (ptr, &array->numsizes); + if (array->numsizes) + array->sizes = g_new0(int, array->numsizes); + for (i = 0; i < array->numsizes; ++i) + ptr = mono_metadata_decode_value (ptr, &(array->sizes[i])); + + ptr = mono_metadata_decode_value (ptr, &array->numlobounds); + if (array->numlobounds) + array->lobounds = g_new0(int, array->numlobounds); + for (i = 0; i < array->numlobounds; ++i) + ptr = mono_metadata_decode_value (ptr, &(array->lobounds[i])); + + if (rptr) + *rptr = ptr; + return array; +} + +void +mono_metadata_free_array (MonoArray *array) +{ + mono_metadata_free_type (array->type); + g_free (array->sizes); + g_free (array->lobounds); + g_free (array); +} + +MonoParam * +mono_metadata_parse_param (metadata_t *m, int rettype, const char *ptr, const char **rptr) +{ + const char *tmp_ptr = ptr; + MonoParam *param; + int count = 0; + int byref = 0; + + /* count the modifiers */ + while (mono_metadata_parse_custom_mod (m, NULL, tmp_ptr, &tmp_ptr)) + count++; + param = g_malloc0(sizeof(MonoParam)+(count-1)*sizeof(MonoCustomMod)); + param->num_modifiers = count; + /* save them this time */ + count = 0; + while (mono_metadata_parse_custom_mod (m, &(param->modifiers[count]), ptr, &ptr)) + count++; + switch (*ptr) { + case ELEMENT_TYPE_TYPEDBYREF: + param->typedbyref = 1; + ptr++; + break; + case ELEMENT_TYPE_VOID: + if (!rettype) + g_error ("void not allowed in param"); + ptr++; + break; + case ELEMENT_TYPE_BYREF: + byref = 1; + ptr++; + /* follow through */ + default: + param->type = mono_metadata_parse_type (m, ptr, &ptr); + param->type->byref = byref; + break; + } + if (rptr) + *rptr = ptr; + return param; +} + +void +mono_metadata_free_param (MonoParam *param) +{ + if (param->type) + mono_metadata_free_type (param->type); + g_free (param); +} + +MonoMethodSignature * +mono_metadata_parse_method_signature (metadata_t *m, int def, const char *ptr, const char **rptr) +{ + MonoMethodSignature *method = g_new0(MonoMethodSignature, 1); + int i; + + if (*ptr & 0x20) + method->hasthis = 1; + if (*ptr & 0x40) + method->explicit_this = 1; + method->call_convention = *ptr & 0x0F; + ptr++; + ptr = mono_metadata_decode_value (ptr, &method->param_count); + method->ret = mono_metadata_parse_param (m, 1, ptr, &ptr); + + method->params = g_new0(MonoParam*, method->param_count); + method->sentinelpos = -1; + for (i = 0; i < method->param_count; ++i) { + if (*ptr == ELEMENT_TYPE_SENTINEL) { + if (method->call_convention != MONO_CALL_VARARG || def) + g_error ("found sentinel for methoddef or no vararg method"); + method->sentinelpos = i; + ptr++; + } + method->params[i] = mono_metadata_parse_param (m, 0, ptr, &ptr); + } + + if (rptr) + *rptr = ptr; + return method; +} + +void +mono_metadata_free_method_signature (MonoMethodSignature *method) +{ + int i; + mono_metadata_free_param (method->ret); + for (i = 0; i < method->param_count; ++i) + mono_metadata_free_param (method->params[i]); + + g_free (method->params); + g_free (method); +} + +/* II 22.2.12 */ +MonoType * +mono_metadata_parse_type (metadata_t *m, const char *ptr, const char **rptr) +{ + /* should probably be allocated in a memchunk */ + MonoType *type = g_new0(MonoType, 1); + int val; + + ptr = mono_metadata_decode_value (ptr, &val); + type->type = val; + + switch (type->type){ + case ELEMENT_TYPE_BOOLEAN: + case ELEMENT_TYPE_CHAR: + case ELEMENT_TYPE_I1: + case ELEMENT_TYPE_U1: + case ELEMENT_TYPE_I2: + case ELEMENT_TYPE_U2: + case ELEMENT_TYPE_I4: + case ELEMENT_TYPE_U4: + case ELEMENT_TYPE_I8: + case ELEMENT_TYPE_U8: + case ELEMENT_TYPE_R4: + case ELEMENT_TYPE_R8: + case ELEMENT_TYPE_I: + case ELEMENT_TYPE_U: + case ELEMENT_TYPE_STRING: + case ELEMENT_TYPE_OBJECT: + break; + case ELEMENT_TYPE_VALUETYPE: + case ELEMENT_TYPE_CLASS: + type->data.token = mono_metadata_parse_typedef_or_ref (m, ptr, &ptr); + break; + case ELEMENT_TYPE_SZARRAY: + case ELEMENT_TYPE_PTR: + if (mono_metadata_parse_custom_mod (m, NULL, ptr, NULL)) { + const char *tmp_ptr = ptr; + MonoModifiedType *mtype; + int count = 0; + + type->custom_mod = 1; + /* count the modifiers */ + while (mono_metadata_parse_custom_mod (m, NULL, tmp_ptr, &tmp_ptr)) + count++; + type->data.mtype = mtype = g_malloc0(sizeof(MonoModifiedType)+(count-1)*sizeof(MonoCustomMod)); + mtype->num_modifiers = count; + count = 0; + /* save them this time */ + while (mono_metadata_parse_custom_mod (m, &(mtype->modifiers[count]), ptr, &ptr)) + count++; + /* FIXME: mono_metadata_decode_value ... */ + if (*ptr == ELEMENT_TYPE_VOID) { + mtype->type = NULL; + ptr++; + } else { + mtype->type = mono_metadata_parse_type (m, ptr, &ptr); + } + } else { + /* FIXME: mono_metadata_decode_value ... */ + if (*ptr == ELEMENT_TYPE_VOID) { + type->data.type = NULL; + ptr++; + } else { + type->data.type = mono_metadata_parse_type (m, ptr, &ptr); + } + } + break; + case ELEMENT_TYPE_FNPTR: + type->data.method = mono_metadata_parse_method_signature (m, 0, ptr, &ptr); + break; + case ELEMENT_TYPE_ARRAY: + type->data.array = mono_metadata_parse_array (m, ptr, &ptr); + break; + default: + g_error ("type 0x%02x not handled in mono_metadata_parse_type", type->type); + } + + if (rptr) + *rptr = ptr; + return type; +} + +void +mono_metadata_free_type (MonoType *type) +{ + switch (type->type){ + case ELEMENT_TYPE_SZARRAY: + case ELEMENT_TYPE_PTR: + if (!type->custom_mod) + mono_metadata_free_type (type->data.type); + else { + mono_metadata_free_type (type->data.mtype->type); + g_free (type->data.mtype); + } + break; + case ELEMENT_TYPE_FNPTR: + mono_metadata_free_method_signature (type->data.method); + break; + case ELEMENT_TYPE_ARRAY: + mono_metadata_free_array (type->data.array); + break; + } + g_free (type); +} + +MonoMethod * +mono_get_method (cli_image_info_t *iinfo, guint32 token) +{ + MonoMethod *result = g_new0 (MonoMethod, 1); + int table = mono_metadata_token_table (token); + int index = mono_metadata_token_index (token); + metadata_tableinfo_t *tables = iinfo->cli_metadata.tables; + const char *loc; + const char *sig = NULL; + int size; + guint32 cols[6]; + + /* + * We need a context with cli_image_info_t for this module and the assemblies + * loaded later to support method refs... + */ + if (table != META_TABLE_METHOD) { + g_assert (table == META_TABLE_MEMBERREF); + mono_metadata_decode_row (&tables [table], index, cols, 3); + g_assert ((cols [0] & 0x07) != 3); + table = META_TABLE_METHOD; + index = cols [0] >> 3; + sig = mono_metadata_blob_heap (&iinfo->cli_metadata, cols [2]); + result->name = cols [1]; + } + + mono_metadata_decode_row (&tables [table], index - 1, cols, 6); + result->name = cols [3]; + /* if this is a methodref from another module/assembly, this fails */ + loc = cli_rva_map (iinfo, cols [0]); + g_assert (loc); + result->header = mono_metadata_parse_mh (&iinfo->cli_metadata, loc); + if (!sig) /* already taken from the methodref */ + sig = mono_metadata_blob_heap (&iinfo->cli_metadata, cols [4]); + sig = mono_metadata_decode_blob_size (sig, &size); + result->signature = mono_metadata_parse_method_signature (&iinfo->cli_metadata, 0, sig, NULL); + + return result; +} + +void +mono_free_method (MonoMethod *method) +{ + mono_metadata_free_method_signature (method->signature); + mono_metadata_free_mh (method->header); + g_free (method); +} + +/** + * @mh: The Method header + * @ptr: Points to the beginning of the Section Data (25.3) + */ +static void +parse_section_data (MonoMetaMethodHeader *mh, const char *ptr) +{ +#if 0 + while ((*ptr) & METHOD_HEADER_SECTION_MORE_SECTS){ + /* align on 32-bit boundary */ + /* FIXME: not 64-bit clean code */ + ptr = dword_align (ptr); + + sect_data_flags = *ptr; + ptr++; + + if (sect_data_flags & METHOD_HEADER_SECTION_MORE_SECTS){ + g_error ("Can not deal with more sections"); + } + + if (sect_data_flags & METHOD_HEADER_SECTION_FAT_FORMAT){ + sect_data_len = + } else { + sect_data_len = ptr [0]; + ptr++; + } + + if (!(sect_data_flags & METHOD_HEADER_SECTION_EHTABLE)) + return mh; + + ptr = dword_align (ptr); + } +#endif +} + +MonoMetaMethodHeader * +mono_metadata_parse_mh (metadata_t *m, const char *ptr) +{ + MonoMetaMethodHeader *mh; + unsigned char flags = *(unsigned char *) ptr; + unsigned char format = flags & METHOD_HEADER_FORMAT_MASK; + guint16 fat_flags; + int hsize; + + g_return_val_if_fail (ptr != NULL, NULL); + + mh = g_new0 (MonoMetaMethodHeader, 1); + switch (format){ + case METHOD_HEADER_TINY_FORMAT: + ptr++; + mh->max_stack = 8; + mh->local_var_sig_tok = 0; + mh->code_size = flags >> 2; + mh->code = ptr; + break; + + case METHOD_HEADER_TINY_FORMAT1: + ptr++; + mh->max_stack = 8; + mh->local_var_sig_tok = 0; + mh->code_size = flags >> 3; + mh->code = ptr; + break; + + case METHOD_HEADER_FAT_FORMAT: + fat_flags = read16 (ptr); + ptr += 2; + hsize = (fat_flags >> 12) & 0xf; + mh->max_stack = *(guint16 *) ptr; + ptr += 2; + mh->code_size = *(guint32 *) ptr; + ptr += 4; + mh->local_var_sig_tok = *(guint32 *) ptr; + ptr += 4; + + if (fat_flags & METHOD_HEADER_INIT_LOCALS) + mh->init_locals = 1; + else + mh->init_locals = 0; + + mh->code = ptr; + + if (!(fat_flags & METHOD_HEADER_MORE_SECTS)) + break; + + /* + * There are more sections + */ + ptr = mh->code + mh->code_size; + + parse_section_data (mh, ptr); + break; + + default: + g_free (mh); + return NULL; + } + + if (mh->local_var_sig_tok) { + metadata_tableinfo_t *t = &m->tables [META_TABLE_STANDALONESIG]; + const char *ptr; + guint32 cols[1]; + int len=0, i, bsize; + + mono_metadata_decode_row (t, (mh->local_var_sig_tok & 0xffffff)-1, cols, 1); + ptr = mono_metadata_blob_heap (m, cols [0]); + ptr = mono_metadata_decode_blob_size (ptr, &bsize); + if (*ptr != 0x07) + g_warning ("wrong signature for locals blob"); + ptr++; + ptr = mono_metadata_decode_value (ptr, &len); + mh->num_locals = len; + mh->locals = g_new (MonoType*, len); + for (i = 0; i < len; ++i) { + int val; + const char *p = ptr; + ptr = mono_metadata_decode_blob_size (ptr, &val); + /* FIXME: store pinned/byref values */ + if (val == ELEMENT_TYPE_PINNED) { + p = ptr; + ptr = mono_metadata_decode_blob_size (ptr, &val); + } + if (val == ELEMENT_TYPE_BYREF) { + p = ptr; + } + mh->locals [i] = mono_metadata_parse_type (m, p, &ptr); + } + } + return mh; +} + +void +mono_metadata_free_mh (MonoMetaMethodHeader *mh) +{ + int i; + for (i = 0; i < mh->num_locals; ++i) + mono_metadata_free_type (mh->locals[i]); + g_free (mh->locals); + g_free (mh); +} diff --git a/mono/metadata/metadata.h b/mono/metadata/metadata.h index 6e34877013f..e42fcc517d0 100644 --- a/mono/metadata/metadata.h +++ b/mono/metadata/metadata.h @@ -1,18 +1,344 @@ +#ifndef __MONO_METADATA_H__ +#define __MONO_METADATA_H__ + +#include <glib.h> + +#include "eltype.h" + typedef struct { - guint32 sh_offset; - guint32 sh_size; + guint32 sh_offset; + guint32 sh_size; } stream_header_t; +typedef enum { + META_TABLE_MODULE, + META_TABLE_TYPEREF, + META_TABLE_TYPEDEF, + META_TABLE_UNUSED1, + META_TABLE_FIELD, + META_TABLE_UNUSED2, + META_TABLE_METHOD, + META_TABLE_UNUSED3, + META_TABLE_PARAM, + META_TABLE_INTERFACEIMPL, + META_TABLE_MEMBERREF, + META_TABLE_CONSTANT, + META_TABLE_CUSTOMATTRIBUTE, + META_TABLE_FIELDMARSHAL, + META_TABLE_DECLSECURITY, + META_TABLE_CLASSLAYOUT, + META_TABLE_FIELDLAYOUT, + META_TABLE_STANDALONESIG, + META_TABLE_EVENTMAP, + META_TABLE_UNUSED4, + META_TABLE_EVENT, + META_TABLE_PROPERTYMAP, + META_TABLE_UNUSED5, + META_TABLE_PROPERTY, + META_TABLE_METHODSEMANTICS, + META_TABLE_METHODIMPL, + META_TABLE_MODULEREF, + META_TABLE_TYPESPEC, + META_TABLE_IMPLMAP, + META_TABLE_FIELDRVA, + META_TABLE_UNUSED6, + META_TABLE_UNUSED7, + META_TABLE_ASSEMBLY, + META_TABLE_ASSEMBLYPROCESSOR, + META_TABLE_ASSEMBLYOS, + META_TABLE_ASSEMBLYREF, + META_TABLE_ASSEMBLYREFPROCESSOR, + META_TABLE_ASSEMBLYREFOS, + META_TABLE_FILE, + META_TABLE_EXPORTEDTYPE, + META_TABLE_MANIFESTRESOURCE, + META_TABLE_NESTEDCLASS, + +#define META_TABLE_LAST META_TABLE_NESTEDCLASS +} MetaTableEnum; + typedef struct { - char *raw_metadata; + guint32 rows, row_size; + char *base; + + /* + * Tables contain up to 9 rows and the possible sizes of the + * fields in the documentation are 1, 2 and 4 bytes. So we + * can encode in 2 bits the size. + * + * A 32 bit value can encode the resulting size + * + * The top eight bits encode the number of columns in the table. + * we only need 4, but 8 is aligned no shift required. + */ + guint32 size_bitfield; +} metadata_tableinfo_t; - stream_header_t heap_strings; - stream_header_t heap_us; - stream_header_t heap_blob; - stream_header_t heap_guid; - stream_header_t heap_tables; +/* + * This macro is used to extract the size of the table encoded in + * the size_bitfield of metadata_tableinfo_t. + */ +#define meta_table_size(bitfield,table) ((((bitfield) >> ((table)*2)) & 0x3) + 1) +#define meta_table_count(bitfield) ((bitfield) >> 24) + +typedef struct { + char *raw_metadata; + + gboolean idx_string_wide, idx_guid_wide, idx_blob_wide; + + stream_header_t heap_strings; + stream_header_t heap_us; + stream_header_t heap_blob; + stream_header_t heap_guid; + stream_header_t heap_tables; + + char *tables_base; - guint32 rows [64]; + metadata_tableinfo_t tables [64]; } metadata_t; +/* + * This enumeration is used to describe the data types in the metadata + * tables + */ +enum { + MONO_MT_END, + + /* Sized elements */ + MONO_MT_UINT32, + MONO_MT_UINT16, + MONO_MT_UINT8, + + /* Index into Blob heap */ + MONO_MT_BLOB_IDX, + + /* Index into String heap */ + MONO_MT_STRING_IDX, + + /* GUID index */ + MONO_MT_GUID_IDX, + + /* Pointer into a table */ + MONO_MT_TABLE_IDX, + + /* HasConstant:Parent pointer (Param, Field or Property) */ + MONO_MT_CONST_IDX, + + /* HasCustomAttribute index. Indexes any table except CustomAttribute */ + MONO_MT_HASCAT_IDX, + + /* CustomAttributeType encoded index */ + MONO_MT_CAT_IDX, + + /* HasDeclSecurity index: TypeDef Method or Assembly */ + MONO_MT_HASDEC_IDX, + + /* Implementation coded index: File, Export AssemblyRef */ + MONO_MT_IMPL_IDX, + + /* HasFieldMarshal coded index: Field or Param table */ + MONO_MT_HFM_IDX, + + /* MemberForwardedIndex: Field or Method */ + MONO_MT_MF_IDX, + + /* TypeDefOrRef coded index: typedef, typeref, typespec */ + MONO_MT_TDOR_IDX, + + /* MemberRefParent coded index: typeref, moduleref, method, memberref, typesepc, typedef */ + MONO_MT_MRP_IDX, + + /* MethodDefOrRef coded index: Method or Member Ref table */ + MONO_MT_MDOR_IDX, + + /* HasSemantic coded index: Event or Property */ + MONO_MT_HS_IDX, + + /* ResolutionScope coded index: Module, ModuleRef, AssemblytRef, TypeRef */ + MONO_MT_RS_IDX +}; + +typedef struct { + int code; + char *def; +} MonoMetaTable; + +const char *mono_meta_table_name (int table); + +/* Internal functions */ +void mono_metadata_compute_table_bases (metadata_t *meta); + +MonoMetaTable *mono_metadata_get_table (MetaTableEnum table); + +/* + * + */ +char *mono_metadata_locate (metadata_t *meta, int table, int idx); +char *mono_metadata_locate_token (metadata_t *meta, guint32 token); + +const char *mono_metadata_string_heap (metadata_t *meta, guint32 index); +const char *mono_metadata_blob_heap (metadata_t *meta, guint32 index); +const char *mono_metadata_user_string (metadata_t *meta, guint32 index); + +const char *mono_metadata_decode_value (const char *ptr, + guint32 *len); +const char *mono_metadata_decode_blob_size (const char *xptr, + int *size); +void mono_metadata_decode_row (metadata_tableinfo_t *t, + int idx, + guint32 *res, + int res_size); + +typedef enum { + MONO_META_EXCEPTION_CLAUSE_NONE, + MONO_META_EXCEPTION_CLAUSE_FILTER, + MONO_META_EXCEPTION_CLAUSE_FINALLY, + MONO_META_EXCEPTION_CLAUSE_FAULT +} MonoMetaExceptionEnum; + +typedef enum { + MONO_CALL_DEFAULT, + MONO_CALL_C, + MONO_CALL_STDCALL, + MONO_CALL_THISCALL, + MONO_CALL_FASTCALL, + MONO_CALL_VARARG +} MonoCallConvention; + +typedef struct { + MonoMetaExceptionEnum kind; + int n_clauses; + void **clauses; +} MonoMetaExceptionHandler; + +typedef struct _MonoType MonoType; +typedef struct _MonoArray MonoArray; +typedef struct _MonoMethodSignature MonoMethodSignature; + +typedef struct { + guchar mod; + guint32 token; +} MonoCustomMod; + +typedef struct { + MonoType *type; + int num_modifiers; + MonoCustomMod modifiers[1]; /* this may grow */ +} MonoModifiedType; + +struct _MonoArray { + MonoType *type; + int rank; + int numsizes; + int numlobounds; + int *sizes; + int *lobounds; +}; + +struct _MonoType { + guchar type; /* ElementTypeEnum */ + guchar custom_mod; /* for PTR and SZARRAY: use data.mtype instead of data.type */ + guchar byref; /* when included in a MonoRetType */ + guchar constraint; /* valid when included in a local var signature */ + union { + guint32 token; /* for VALUETYPE and CLASS */ + MonoType *type; + MonoModifiedType *mtype; + MonoArray *array; /* for ARRAY */ + MonoMethodSignature *method; + } data; +}; + +typedef struct { + /* maybe use a union here: saves 4 bytes */ + MonoType *type; /* NULL for VOID */ + short param_attrs; /* 22.1.11 */ + char typedbyref; + int num_modifiers; + MonoCustomMod modifiers[1]; /* this may grow */ +} MonoRetType; + +/* MonoRetType is used also for params */ +typedef MonoRetType MonoParam; + +struct _MonoMethodSignature { + char hasthis; + char explicit_this; + char call_convention; + int param_count; + int sentinelpos; + MonoRetType *ret; + MonoParam **params; +}; + +typedef struct { + guint32 code_size; + const char *code; + short max_stack; + guint32 local_var_sig_tok; + + /* if local_var_sig_tok != 0, then the following apply: */ + unsigned int init_locals : 1; + int num_locals; + MonoType **locals; + + GList *exception_handler_list; +} MonoMetaMethodHeader; + +guint32 mono_metadata_parse_typedef_or_ref (metadata_t *m, + const char *ptr, + const char **rptr); +int mono_metadata_parse_custom_mod (metadata_t *m, + MonoCustomMod *dest, + const char *ptr, + const char **rptr); +MonoArray *mono_metadata_parse_array (metadata_t *m, + const char *ptr, + const char **rptr); +void mono_metadata_free_array (MonoArray *array); +MonoParam *mono_metadata_parse_param (metadata_t *m, + int rettype, + const char *ptr, + const char **rptr); +void mono_metadata_free_param (MonoParam *param); +MonoType *mono_metadata_parse_type (metadata_t *m, + const char *ptr, + const char **rptr); +void mono_metadata_free_type (MonoType *type); + +MonoMethodSignature *mono_metadata_parse_method_signature (metadata_t *m, + int def, + const char *ptr, + const char **rptr); +void mono_metadata_free_method_signature (MonoMethodSignature *method); + +MonoMetaMethodHeader *mono_metadata_parse_mh (metadata_t *m, const char *ptr); +void mono_metadata_free_mh (MonoMetaMethodHeader *mh); + +/* + * Makes a token based on a table and an index + */ +#define mono_metadata_make_token(table,idx) (((table) << 24)| idx) + +/* + * Returns the table index that this token encodes. + */ +#define mono_metadata_token_table(token) ((token) >> 24) + +/* + * Returns the index that a token refers to + */ +#define mono_metadata_token_index(token) ((token & 0xffffff)) + + +#define mono_metadata_token_code(token) ((token & 0xff000000)) + +/* + * FIXME: put all of the table codes here + */ +enum { + TOKEN_TABLE_XXX = 0 +} MonoMetadataTableCodes; + +#endif /* __MONO_METADATA_H__ */ diff --git a/mono/metadata/methodattr.h b/mono/metadata/methodattr.h new file mode 100644 index 00000000000..dc3da757ded --- /dev/null +++ b/mono/metadata/methodattr.h @@ -0,0 +1,57 @@ +#ifndef _MONO_METADATA_METHODATTR_H_ +#define _MONO_METADATA_METHODATTR_H_ + +/* + * Method Attributes (22.1.9) + */ + +#define METHOD_IMPL_ATTRIBUTE_CODE_TYPE_MASK 0x0003 +#define METHOD_IMPL_ATTRIBUTE_IL 0x0000 +#define METHOD_IMPL_ATTRIBUTE_NATIVE 0x0001 +#define METHOD_IMPL_ATTRIBUTE_OPTIL 0x0002 +#define METHOD_IMPL_ATTRIBUTE_RUNTIME 0x0003 + +#define METHOD_IMPL_ATTRIBUTE_MANAGED_MASK 0x0004 +#define METHOD_IMPL_ATTRIBUTE_UNMANAGED 0x0004 +#define METHOD_IMPL_ATTRIBUTE_MANAGED 0x0000 + +#define METHOD_IMPL_ATTRIBUTE_FORWARD_REF 0x0010 +#define METHOD_IMPL_ATTRIBUTE_PRESERVE_SIG 0x0080 +#define METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL 0x1000 +#define METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED 0x0020 +#define METHOD_IMPL_ATTRIBUTE_NOINLINING 0x0008 +#define METHOD_IMPL_ATTRIBUTE_MAX_METHOD_IMPL_VAL 0xffff + +#define METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK 0x0007 +#define METHOD_ATTRIBUTE_COMPILER_CONTROLLED 0x0000 +#define METHOD_ATTRIBUTE_PRIVATE 0x0001 +#define METHOD_ATTRIBUTE_FAM_AND_ASSEM 0x0002 +#define METHOD_ATTRIBUTE_ASSEM 0x0003 +#define METHOD_ATTRIBUTE_FAMILY 0x0004 +#define METHOD_ATTRIBUTE_FAM_OR_ASSEM 0x0005 +#define METHOD_ATTRIBUTE_PUBLIC 0x0006 + +#define METHOD_ATTRIBUTE_STATIC 0x0010 +#define METHOD_ATTRIBUTE_FINAL 0x0020 +#define METHOD_ATTRIBUTE_VIRTUAL 0x0040 +#define METHOD_ATTRIBUTE_HIDE_BY_SIG 0x0080 + +#define METHOD_ATTRIBUTE_VTABLE_LAYOUT_MASK 0x0100 +#define METHOD_ATTRIBUTE_REUSE_SLOT 0x0000 +#define METHOD_ATTRIBUTE_NEW_SLOT 0x0100 + +#define METHOD_ATTRIBUTE_ABSTRACT 0x0400 +#define METHOD_ATTRIBUTE_SPECIAL_NAME 0x0800 + +#define METHOD_ATTRIBUTE_PINVOKE_IMPL 0x2000 +#define METHOD_ATTRIBUTE_UNMANAGED_EXPORT 0x0008 + +/* + * For runtime use only + */ +#define METHOD_ATTRIBUTE_RESERVED_MASK 0xd000 +#define METHOD_ATTRIBUTE_RT_SPECIAL_NAME 0x1000 +#define METHOD_ATTRIBUTE_HAS_SECURITY 0x4000 +#define METHOD_ATTRIBUTE_REQUIRE_SEC_OBJECT 0x8000 + +#endif diff --git a/mono/metadata/methodheader.h b/mono/metadata/methodheader.h new file mode 100644 index 00000000000..9993a29132b --- /dev/null +++ b/mono/metadata/methodheader.h @@ -0,0 +1,29 @@ +#ifndef _MONO_METADATA_METHOD_HEADER_H_ +#define _MONO_METADATA_METHOD_HEADER_H_ + +/* + * 25.2.1: Method header type values + */ +#define METHOD_HEADER_FORMAT_MASK 7 +#define METHOD_HEADER_TINY_FORMAT 2 +#define METHOD_HEADER_TINY_FORMAT1 6 +#define METHOD_HEADER_FAT_FORMAT 3 + +/* + * 25.2.3.1: Flags for method headers + */ +#define METHOD_HEADER_INIT_LOCALS 0x10 +#define METHOD_HEADER_MORE_SECTS 0x08 + +/* + * For section data (25.3) + */ +#define METHOD_HEADER_SECTION_RESERVED 0 +#define METHOD_HEADER_SECTION_EHTABLE 1 +#define METHOD_HEADER_SECTION_OPTIL_TABLE 2 +#define METHOD_HEADER_SECTION_FAT_FORMAT 0x40 +#define METHOD_HEADER_SECTION_MORE_SECTS 0x80 + +#endif /* _MONO_METADATA_METHOD_HEADER_H_ */ + + diff --git a/mono/metadata/methodsem.h b/mono/metadata/methodsem.h new file mode 100644 index 00000000000..ffd6f2803aa --- /dev/null +++ b/mono/metadata/methodsem.h @@ -0,0 +1,15 @@ +#ifndef _MONO_METADATA_METHODSEM_H_ +#define _MONO_METADATA_METHODSEM_H_ + +/* + * Method Semantics ([MethodSemanticAttributes]) 22.1.10 + */ + +#define METHOD_SEMANTIC_SETTER 0x0001 +#define METHOD_SEMANTIC_GETTER 0x0002 +#define METHOD_SEMANTIC_OTHER 0x0004 +#define METHOD_SEMANTIC_ADD_ON 0x0008 +#define METHOD_SEMANTIC_REMOVE_ON 0x0010 +#define METHOD_SEMANTIC_FIRE 0x0020 + +#endif diff --git a/mono/metadata/mono-endian.h b/mono/metadata/mono-endian.h new file mode 100644 index 00000000000..8da0e4126e0 --- /dev/null +++ b/mono/metadata/mono-endian.h @@ -0,0 +1,13 @@ +#ifndef _MONO_METADATA_ENDIAN_H_ +#define _MONO_METADATA_ENDIAN_H_ 1 + +/* FIXME: implement big endian versions */ + +#define le64_to_cpu(x) (x) +#define le32_to_cpu(x) (x) +#define le16_to_cpu(x) (x) +#define read32(x) le32_to_cpu (*((guint32 *) (x))) +#define read16(x) le16_to_cpu (*((guint16 *) (x))) +#define read64(x) le64_to_cpu (*((guint64 *) (x))) + +#endif /* _MONO_METADATA_ENDIAN_H_ */ diff --git a/mono/metadata/paramattr.h b/mono/metadata/paramattr.h new file mode 100644 index 00000000000..f6ff9ba1c5f --- /dev/null +++ b/mono/metadata/paramattr.h @@ -0,0 +1,12 @@ +#ifndef _MONO_METADATA_PARAMATTR_H_ +#define _MONO_METADATA_PARAMATTR_H_ + +#define PARAM_ATTRIBUTE_IN 0x0001 +#define PARAM_ATTRIBUTE_OUT 0x0002 +#define PARAM_ATTRIBUTE_OPTIONAL 0x0004 +#define PARAM_ATTRIBUTE_RESERVED_MASK 0xf000 +#define PARAM_ATTRIBUTE_HAS_DEFAULT 0x1000 +#define PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL 0x2000 +#define PARAM_ATTRIBUTE_UNUSED 0xcfe0 + +#endif diff --git a/mono/metadata/pedump.c b/mono/metadata/pedump.c index 7a716cf3ea7..3415dee7039 100644 --- a/mono/metadata/pedump.c +++ b/mono/metadata/pedump.c @@ -8,10 +8,14 @@ */ #include <config.h> #include <stdio.h> +#include <string.h> #include "assembly.h" #include <glib.h> #include "cil-coff.h" +gboolean dump_data = TRUE; +gboolean dump_tables = FALSE; + static void hex_dump (char *buffer, int base, int count) { @@ -166,13 +170,13 @@ dump_section_table (section_table_t *st) } static void -dump_sections (dotnet_image_info_t *iinfo) +dump_sections (cli_image_info_t *iinfo) { - const int top = iinfo->dn_header.coff.coff_sections; + const int top = iinfo->cli_header.coff.coff_sections; int i; for (i = 0; i < top; i++) - dump_section_table (&iinfo->dn_section_tables [i]); + dump_section_table (&iinfo->cli_section_tables [i]); } static void @@ -195,7 +199,7 @@ dump_cli_header (cli_header_t *ch) } static void -dsh (char *label, dotnet_image_info_t *iinfo, stream_header_t *sh) +dsh (char *label, cli_image_info_t *iinfo, stream_header_t *sh) { printf ("%s: 0x%08x - 0x%08x [%d == 0x%08x]\n", label, @@ -204,9 +208,9 @@ dsh (char *label, dotnet_image_info_t *iinfo, stream_header_t *sh) } static void -dump_metadata_ptrs (dotnet_image_info_t *iinfo) +dump_metadata_ptrs (cli_image_info_t *iinfo) { - metadata_t *meta = &iinfo->dn_metadata; + metadata_t *meta = &iinfo->cli_metadata; printf ("\nMetadata pointers:\n"); dsh ("\tTables (#~)", iinfo, &meta->heap_tables); @@ -216,70 +220,67 @@ dump_metadata_ptrs (dotnet_image_info_t *iinfo) dsh ("\t GUID", iinfo, &meta->heap_guid); } -static const char * -table_to_string (int table) +static void +dump_table (metadata_t *meta, int table) { - char *map_table_to_string [] = { - /* 0 */ "Module", "TypeRef", "TypeDef", "FieldPtr", - /* 4 */ "FieldDef", "MethodPtr", "MethodDef", "ParamPtr", - /* 8 */ "ParamDef", "InterfaceImpl", "MemberRef", "FieldInit", - /* 12 */ "CustomAttr", "MarshalDef", "Permission", "LayoutDef", - /* 16 */ "FieldOffset", "Signature", "EventAssoc", "EventPtr", - /* 20 */ "Event", "PropertyAssoc", "PropertyPtr", "Property", - /* 24 */ "MethodAssoc", "MethodImpl", "ModuleRef", "TypeSpec", - /* 28 */ "PInvoke", "Data", "EncLog", "EncAssoc", - /* 32 */ "Assembly", "ProcessorDef", "OSDef", "AssemblyRef", - /* 36 */ "ProcessorRef", "OSRef", "File", "ComType", - /* 40 */ "ManifestResource", "ExeLocation", "42", "43", - /* 44 */ "44", "45", "NestedClass", "47" - /* 48 */ "48", "49", "50", "51", - /* 52 */ "52", "53", "54", "55" - /* 56 */ "56", "57", "58", "59" - /* 60 */ "60", "61", "62", "63" - }; - if (table < 0 || table > 63) - return "Unknown table name"; - - return map_table_to_string [table]; } static void -dump_metadata (dotnet_image_info_t *iinfo) +dump_metadata (cli_image_info_t *iinfo) { - metadata_t *meta = &iinfo->dn_metadata; + metadata_t *meta = &iinfo->cli_metadata; int table; dump_metadata_ptrs (iinfo); printf ("Rows:\n"); for (table = 0; table < 64; table++){ - if (meta->rows [table] == 0) + if (meta->tables [table].rows == 0) continue; - printf ("Table %s (%d): %d rows\n", table_to_string (table), table, meta->rows [table]); + printf ("Table %s: %d records (%d bytes, at %p)\n", + mono_meta_table_name (table), + meta->tables [table].rows, + meta->tables [table].row_size, + meta->tables [table].base + ); + if (dump_tables) + dump_table (meta, table); } } static void -dump_dotnet_iinfo (dotnet_image_info_t *iinfo) +dump_methoddef (cli_image_info_t *iinfo, guint32 token) { - dump_dotnet_header (&iinfo->dn_header); + char *loc; + + loc = mono_metadata_locate_token (&iinfo->cli_metadata, token); + + printf ("RVA for Entry Point: 0x%08x\n", (*(guint32 *)loc)); +} + +static void +dump_dotnet_iinfo (cli_image_info_t *iinfo) +{ + dump_dotnet_header (&iinfo->cli_header); dump_sections (iinfo); - dump_cli_header (&iinfo->dn_cli_header); + dump_cli_header (&iinfo->cli_cli_header); dump_metadata (iinfo); + + dump_methoddef (iinfo, iinfo->cli_cli_header.ch_entry_point); } static void usage (void) { - printf ("Usage is: pedump [-m] file.exe\n"); + printf ("Usage is: pedump [--tables] file.exe\n"); exit (1); } int main (int argc, char *argv []) { - dotnet_image_info_t *iinfo; + cli_image_info_t *iinfo; MonoAssembly *assembly; char *file = NULL; int i; @@ -290,18 +291,25 @@ main (int argc, char *argv []) continue; } - if (argv [i][1] == 'h') + if (strcmp (argv [i], "--help") == 0) usage (); + if (strcmp (argv [i], "--tables") == 0) + dump_tables = 1; } if (!file) usage (); assembly = mono_assembly_open (file, NULL); + if (!assembly){ + fprintf (stderr, "Can not open assembly %s\n", file); + exit (1); + } iinfo = assembly->image_info; - dump_dotnet_iinfo (iinfo); - + if (dump_data) + dump_dotnet_iinfo (iinfo); + mono_assembly_close (assembly); return 0; diff --git a/mono/metadata/propertyattr.h b/mono/metadata/propertyattr.h new file mode 100644 index 00000000000..5bb912d8663 --- /dev/null +++ b/mono/metadata/propertyattr.h @@ -0,0 +1,10 @@ +#ifndef _MONO_METADATA_PROPERTYATTR_H_ +#define _MONO_METADATA_PROPERTYATTR_H_ + +#define PROPERTY_ATTRIBUTE_SPECIAL_NAME 0x0200 +#define PROPERTY_ATTRIBUTE_RESERVED_MASK 0xf400 +#define PROPERTY_ATTRIBUTE_RT_SPECIAL_NAME 0x0400 +#define PROPERTY_ATTRIBUTE_HAS_DEFAULT 0x1000 +#define PROPERTY_ATTRIBUTE_UNUSED 0xe9ff + +#endif diff --git a/mono/metadata/tokentype.h b/mono/metadata/tokentype.h new file mode 100644 index 00000000000..06c75faecb0 --- /dev/null +++ b/mono/metadata/tokentype.h @@ -0,0 +1,39 @@ +#ifndef _MONO_METADATA_TOKENTYPE_H_ +#define _MONO_METADATA_TOKENTYPE_H_ + +/* + * These tokens match the table ID except for the last + * three (string, name and base type which are special) + */ + +typedef enum { + TOKEN_TYPE_MODULE = 0x00000000, + TOKEN_TYPE_TYPE_REF = 0x01000000, + TOKEN_TYPE_TYPE_DEF = 0x02000000, + TOKEN_TYPE_FIELD_DEF = 0x04000000, + TOKEN_TYPE_METHOD_DEF = 0x06000000, + TOKEN_TYPE_PARAM_DEF = 0x08000000, + TOKEN_TYPE_INTERFACE_IMPL = 0x09000000, + TOKEN_TYPE_MEMBER_REF = 0x0a000000, + TOKEN_TYPE_CUSTOM_ATTRIBUTE = 0x0c000000, + TOKEN_TYPE_PERMISSION = 0x0e000000, + TOKEN_TYPE_SIGNATURE = 0x11000000, + TOKEN_TYPE_EVENT = 0x14000000, + TOKEN_TYPE_PROPERTY = 0x17000000, + TOKEN_TYPE_MODULE_REF = 0x1a000000, + TOKEN_TYPE_TYPE_SPEC = 0x1b000000, + TOKEN_TYPE_ASSEMBLY = 0x20000000, + TOKEN_TYPE_ASSEMBLY_REF = 0x23000000, + TOKEN_TYPE_FILE = 0x26000000, + TOKEN_TYPE_EXPORTED_TYPE = 0x27000000, + TOKEN_TYPE_MANIFEST_RESOURCE = 0x28000000, + + /* + * These do not match metadata tables directly + */ + TOKEN_TYPE_STRING = 0x70000000, + TOKEN_TYPE_NAME = 0x71000000, + TOKEN_TYPE_BASE_TYPE = 0x72000000 +} TokenType; + +#endif /* _MONO_METADATA_TOKENTYPE_H_ */ diff --git a/mono/metadata/typeattr.h b/mono/metadata/typeattr.h new file mode 100644 index 00000000000..63b6481cea8 --- /dev/null +++ b/mono/metadata/typeattr.h @@ -0,0 +1,47 @@ +#ifndef _MONO_METADATA_BITMASK_H_ +#define _MONO_METADATA_BITMASK_H_ +/* + * Flags for bitmasks in the metadata tables + */ + +/* + * Type Attributes (21.1.13). + */ +#define TYPE_ATTRIBUTE_VISIBILITY_MASK 0x00000007 +#define TYPE_ATTRIBUTE_NOT_PUBLIC 0x00000000 +#define TYPE_ATTRIBUTE_PUBLIC 0x00000001 +#define TYPE_ATTRIBUTE_NESTED_PUBLIC 0x00000002 +#define TYPE_ATTRIBUTE_NESTED_PRIVATE 0x00000003 +#define TYPE_ATTRIBUTE_NESTED_FAMILY 0x00000004 +#define TYPE_ATTRIBUTE_NESTED_ASSEMBLY 0x00000005 +#define TYPE_ATTRIBUTE_NESTED_FAM_AND_ASSEM 0x00000006 +#define TYPE_ATTRIBUTE_NESTED_FAM_OR_ASSEM 0x00000007 + +#define TYPE_ATTRIBUTE_LAYOUT_MASK 0x00000018 +#define TYPE_ATTRIBUTE_AUTO_LAYOUT 0x00000000 +#define TYPE_ATTRIBUTE_SEQUENTIAL_LAYOUT 0x00000008 +#define TYPE_ATTRIBUTE_EXPLICIT_LAYOUT 0x00000010 + +#define TYPE_ATTRIBUTE_CLASS_SEMANTIC_MASK 0x00000020 +#define TYPE_ATTRIBUTE_CLASS 0x00000000 +#define TYPE_ATTRIBUTE_INTERFACE 0x00000020 + +#define TYPE_ATTRIBUTE_ABSTRACT 0x00000080 +#define TYPE_ATTRIBUTE_SEALED 0x00000100 +#define TYPE_ATTRIBUTE_SPECIAL_NAME 0x00000400 + +#define TYPE_ATTRIBUTE_IMPORT 0x00001000 +#define TYPE_ATTRIBUTE_SERIALIZABLE 0x00002000 + +#define TYPE_ATTRIBUTE_STRING_FORMAT_MASK 0x00030000 +#define TYPE_ATTRIBUTE_ANSI_CLASS 0x00000000 +#define TYPE_ATTRIBUTE_UNICODE_CLASS 0x00010000 +#define TYPE_ATTRIBUTE_AUTO_CLASS 0x00020000 + +#define TYPE_ATTRIBUTE_BEFORE_FIELD_INIT 0x00100000 + +#define TYPE_ATTRIBUTE_RESERVED_MASK 0x00040800 +#define TYPE_ATTRIBUTE_RT_SPECIAL_NAME 0x00000800 +#define TYPE_ATTRIBUTE_HAS_SECURITY 0x00040000 + +#endif diff --git a/notes/cil b/notes/cil new file mode 100644 index 00000000000..458aca543ba --- /dev/null +++ b/notes/cil @@ -0,0 +1,13 @@ +Random collection of notes + + * What is the point of having the InlineVar argument to + opcodes be a signed integer instead of unsigned? + + +Storage + + The CIL metadata is a very compressed file format, even the + sizes of blobs and strings are recorded in a compressed form. + Still, all strings are encoded using 16-bit chars, instead of the + more efficient UTF-8. + diff --git a/status/compare-assembly.cs b/status/compare-assembly.cs new file mode 100755 index 00000000000..263bcb163f3 --- /dev/null +++ b/status/compare-assembly.cs @@ -0,0 +1,231 @@ +/* +Tool #1: + + compare file1.dll file2.dll annotations.xml + + file1.dll: This is an assembly created by Microsoft. + + file2.dll: This is a Mono assembly (currently we have none + that build). + + annotations.xml: contains comments about a class: + + <class name="System.Object"> + <maintainer> + <email>miguel@ximian.com</email> + <name>Miguel de Icaza</name> + </maintainer> + <status test-suite="no" percent="XX"> + </class> + + That would generate an XML file with all the classes that are + implemented in the second library. If there is nothing for a + given class, it should generate an emtpy group: + + <class name="System.Object"> + </class> + +Tool #2: + + Using a Perl script that can grok XML, generate HTML pages + that we can put on the web site: + + Per assembly status. + Per maintainer status. + Per Percent status. + +*/ +namespace Mapper +{ + using System; + using System.Collections; + using System.Reflection; + + /// <summary> + /// Summary description for Class1. + /// </summary> + public class Mapper + { + Assembly a; + Hashtable nshash = new Hashtable(); + int indent = 0; + + public Mapper(string name) + { + a = Assembly.LoadFrom (name); + } + + void o (string s) + { + Console.WriteLine (s.PadLeft (s.Length + indent, ' ')); + } + + void DumpMember (MemberInfo mi) + { + string kind; + string more=""; + + switch (mi.MemberType) + { + case MemberTypes.Field: + kind = "field"; + break; + case MemberTypes.Method: + if (((MethodInfo)mi).IsSpecialName) { + return; + } + kind = "method"; + more = " signature='" + mi.ToString() +"'"; + break; + case MemberTypes.Event: + kind = "event"; + break; + case MemberTypes.Property: + kind = "property"; + break; + default: + kind = "***UNKOWN***"; + break; + } + + o ("<" + kind + " name='" + mi.Name + "'" + more + "/>"); + } + + void DumpType (Type t) + { + string kind, name, attrs = ""; + + name = t.Name; + + if (t.IsClass) { + kind = "class"; + } else if (t.IsInterface) { + kind = "interface"; + } else if (t.IsValueType) { + kind = "valueType"; + } else if (t.IsEnum) { + kind = "enum"; + } else return; + + if (t.IsAbstract) { + attrs += "abstract='true'"; + } else if (t.IsSealed) { + attrs += "sealed='true'"; + } else if (t.IsCOMObject) { + attrs += "comobject='true'"; + } + + o ("<" + kind + " name='" + name + (attrs == "" ? "'" : "' ") + attrs + ">"); + + indent += 4; + + /*o ("<maintainer></maintainer>"); + o ("<description></description>");*/ + + foreach (Type type in t.GetNestedTypes ()) + { + DumpType(type); + } + + foreach (FieldInfo field in t.GetFields ()) + { + DumpMember (field); + } + + foreach (MethodInfo method in t.GetMethods ()) + { + DumpMember (method); + } + + indent -= 4; + + o ("</" + kind + ">"); + } + + void LoadTypeList (Type [] types) + { + foreach (Type t in types) + { + ArrayList list = (ArrayList) nshash [t.Namespace]; + if (list == null) + { + list = new ArrayList (); + nshash.Add (t.Namespace, list); + } + list.Add (t); + } + } + + void DumpTypeList (Type [] types) + { + LoadTypeList (types); + + foreach (string ns in nshash.Keys) + { + o ("<namespace " + "name='" + ns + "'>"); + + indent += 4; + + foreach (Type t in (ArrayList) nshash [ns]) + { + DumpType (t); + } + + indent -= 4; + + o ("</namespace>"); + } + } + + public void Map () + { + string name; + Type [] types; + Module [] modules; + + name = a.GetName ().Name; + types = a.GetExportedTypes (); + modules = a.GetModules (); + + o ("<assembly name='" + name + "'>"); + + indent += 4; + + /*o ("<maintainer></maintainer>"); + o ("<description></description>");*/ + + DumpTypeList (types); + + indent -= 4; + + o ("</assembly>"); + } + + public static int Main(string[] args) + { + Mapper m; + string basedir = "c:\\WINDOWS\\Microsoft.NET\\Framework\\v1.0.2914\\"; + + if (args.Length > 0) { + foreach (string s in args){ + try { + m = new Mapper (basedir + s); + m.Map (); + } catch (Exception e) { + Console.WriteLine("Error: "+e.ToString()); + } + } + } else { + try { + m = new Mapper (basedir + "mscorlib.dll"); + m.Map (); + } catch (Exception e) { + Console.WriteLine("Error: "+e.ToString()); + } + } + + return 0; + } + } +} + diff --git a/status/maintainers.xml b/status/maintainers.xml new file mode 100755 index 00000000000..eb22b9fddc8 --- /dev/null +++ b/status/maintainers.xml @@ -0,0 +1,61 @@ +<maintainers> + <person email="miguel@ximian.com" name="Miguel de Icaza"> + <class name="System.Object"/> + <assembly name="mscorlib"/> + </person> + <person email="fejj@ximian.com" name="Jeffrey Stedfast"> + <class name="System.String" date="Jul-15-2001"/> + </person> + <person email="jbarn@httcb.net" name="John Barnette"> + <class name="System.Collections.Hashtable" date="Jul-15-2001"/> + </person> + <person email="iain@ximian.com" name="Iain"> + <class name="System.Collections.Queue"/> + </person> + <person email="bob@thestuff.net" name="Bob Smith"> + <class name="System.Math"/> + </person> + <person email="joe@ximian.com" name="Joe Shaw"> + <class name="System.Array"/> + </person> + <person email="marcins@zipworld.com.au" name="Marcin Szczepanski"> + <class name="System.StringBuilder" date="Jul-15-2001"/> + <class name="System.IO.TextReader" date="Jul-15-2001"/> + <class name="System.IO.StringReader" date="Jul-15-2001"/> + <class name="System.IO.TextWriter" date="Jul-15-2001"/> + <class name="System.IO.StringWriter" date="Jul-15-2001"/> + </person> + <person email="rooneg@electricjellyfish.net" name="Garrett Rooney"> + <class name="System.Collections.Stack" date="Jul-15-2001"/> + </person> + <person email="angryjohn69@nc.rr.com" name="John R. Hicks"> + <class name="System.Diagnostics.Switch" date="Jul-15-2001"/> + <class name="System.Diagnostics.BooleanSwitch" date="Jul-15-2001"/> + <class name="System.Diagnostics.TraceSwitch" date="Jul-15-2001"/> + <class name="System.Diagnostics.ConditionalAttribute" date="Jul-15-2001"/> + <class name="System.Diagnostics.Debug" date="Jul-15-2001"/> + <class name="System.Diagnostics.DiagnosticsConfigurationHandler" date="Jul-15-2001"/> + <class name="System.Diagnostics.StackFrame" date="Jul-15-2001"/> + <class name="System.Diagnostics.StackTrace" date="Jul-15-2001"/> + <class name="System.Diagnostics.Trace" date="Jul-15-2001"/> + <class name="System.Diagnostics.TraceListener" date="Jul-15-2001"/> + </person> + <person email="czw@home.se" name="Jens Backman"> + <class name="System.IO.BinaryReader" date="Jul-15-2001"/> + <class name="System.IO.BinaryWriter" date="Jul-15-2001"/> + <class name="System.IO.FileStream" date="Jul-15-2001"/> + <class name="System.IO.Stream" date="Jul-15-2001"/> + </person> + <person email="jason@injektilo.org" name="Jason Diamon"> + <class name="System.XML.XmlReader" date="Jul-15-2001"/> + </person> +</maintainers> + + + + + + + + + diff --git a/status/makefile b/status/makefile new file mode 100644 index 00000000000..c8ac5515468 --- /dev/null +++ b/status/makefile @@ -0,0 +1,3 @@ +push: + perl mono-stats + scp *.html *.xml www@www:/web/cvsmodules/mono/class-status
\ No newline at end of file diff --git a/status/mono-stats b/status/mono-stats new file mode 100755 index 00000000000..64a2947df09 --- /dev/null +++ b/status/mono-stats @@ -0,0 +1,289 @@ +#!/usr/bin/perl -w + +use strict; +use XML::Parser; +#use Data::Dumper; + +# command line arguments: shell globs for the files containing the info +# for the ms assemblyes and mono's +my $msglob = shift || 'ms*.xml'; +my $monoglob = shift || 'mono*.xml'; +# maintainers file +my $mfile = 'maintainers.xml'; +my $curfile; + +# positions in array refs +use constant MNAME => 0; +use constant MASSEMBLY => 1; +use constant MCLASS => 2; + +use constant MAINTAINER => 0; +use constant PERCENT => 1; +use constant HASH => 2; +# we store all the data in some global hash tables +# $email => [$name, \%assembly, \%class] +my %maintainer; + +# $name => [$maintainer, $percent, \%classes]; +my %assembly; + +# $name => [$maintainer, $percent, \%methods] +my %class; + +# my parsing state machine +my @status; +# current maintainer, class and assembly pointers +my ($curm, $curc, $cura); +my $mono = 0; +my $namespace = ''; +my %status_action = ( + MAINTAINERS => sub { + my ($elem, %attrs) = @_; + malformed ($mfile, $elem, 'maintainers', \@status); + push @status, 'DUDE'; + }, + DUDE => sub { + my ($elem, %attrs) = @_; + malformed ($mfile, $elem, 'person', \@status); + foreach(qw(email name)) {die "$_ not included in person\n" unless defined $attrs{$_}} + $curm = $maintainer{$attrs{email}} = [$attrs{name}, {}, {}]; + push @status, 'DUDE_CONTENT'; + }, + DUDE_CONTENT => sub { + my ($elem, %attrs) = @_; + malformed ($mfile, $elem, 'class|assembly', \@status); + if ($elem eq 'class') { + $curm->[MCLASS]->{$attrs{name}} = ''; + } elsif ($elem eq 'assembly') { + $curm->[MASSEMBLY]->{$attrs{name}} = ''; + } + push @status, 'DUDE_CONTENT'; + }, + ASSEMBLY => sub { + my ($elem, %attrs) = @_; + malformed ($curfile, $elem, 'assembly', \@status); + $namespace = ''; + $cura = $assembly{$attrs{name}} = ['', 0, {}]; + push @status, 'NAMESPACE'; + }, + NAMESPACE => sub { + my ($elem, %attrs) = @_; + malformed ($curfile, $elem, 'namespace', \@status); + $namespace = $attrs{name}; + push @status, 'CLASS'; + }, + CLASS => sub { + my ($elem, %attrs) = @_; + malformed ($curfile, $elem, 'class|valueType|interface', \@status); + if ($elem eq 'class') { + my $name = $namespace ? $namespace.".".$attrs{name} : $attrs{name}; + if ($mono) { + warn "mono implements non exisistent class $name\n" + if (!exists $class{$name}); + $curc = $class{$name}; + } else { + $curc = $class{$name} = ['', 0, {}]; + } + $cura->[HASH]->{$name} = $mono; + push @status, 'METHOD'; + } else { + push @status, 'METHOD'; + } + }, + METHOD => sub { + my ($elem, %attrs) = @_; + malformed ($curfile, $elem, 'method|field|valueType', \@status); + if ($elem eq 'method') { + my $name = $attrs{signature}; + if ($mono) { + warn "mono implements non exisistent method $name\n" + if (!exists $curc->[HASH]->{$name}); + } + $curc->[HASH]->{$name} = $mono; + push @status, 'METHOD'; + } else { + push @status, 'METHOD'; + } + }, +); + + +my $parser = new XML::Parser (Handlers => {Start => \&handle_tag, End => \&end_tag}); + +# parse the maintainers info +if ($mfile) { + @status = 'MAINTAINERS'; + $parser->parsefile($mfile); + #print Dumper(\%maintainer); +} + +foreach (glob($msglob)) { + $curfile = $_; + @status = 'ASSEMBLY'; + $mono = 0; + $parser->parsefile($_); +} + +foreach (glob($monoglob)) { + $curfile = $_; + @status = 'ASSEMBLY'; + $mono = 1; + $parser->parsefile($_); +} + +create_stats(); +create_html(); +#print Dumper(\%assembly); +#print Dumper(\%class); +exit(0); + +sub malformed { + my ($file, $elem, $match, $data) = @_; + unless ($elem =~ /^$match$/) { + $data = Dumper($data) if defined $data; + die "file $file malformed ($elem instead of $match) $data\n" + } +} + +sub handle_tag { + my $parser = shift @_; + my $status = $status[-1]; + die "status $status unknown" unless exists $status_action{$status}; + $status_action{$status}->(@_); +} + +sub end_tag { + my $last = pop @status; + # print STDERR "done with $last\n"; +} + +sub assign_maintainer { + my ($m, $from, $to, $type) = @_; + foreach (keys %$from) { + if (!exists $to->{$_}) { + warn "$m maintains unknown $type $_\n"; + # fixup to avoid warnings + $to->{$_}->[MAINTAINER] = $m; + $to->{$_}->[PERCENT] = 0; + $to->{$_}->[HASH] = {}; + } else { + warn "$to->{$_}->[MAINTAINER] already maintains $_ (now $m)\n" if $to->{$_}->[MAINTAINER]; + $to->{$_}->[MAINTAINER] = $m; + } + } +} + +sub completeness { + my $hash = shift @_; + my $total = keys %$hash; + my $done = 0; + map {$done += $_} values %$hash; + return 0 unless $total; + return int($done*100/$total); +} + +sub create_stats { + # set maintainer field in assembly and class hashes + foreach my $m (sort keys %maintainer) { + assign_maintainer ($m, $maintainer{$m}->[MASSEMBLY], \%assembly, 'assembly'); + assign_maintainer ($m, $maintainer{$m}->[MCLASS], \%class, 'class'); + } + # assign completeness percent + foreach my $ass (values %assembly) { + $ass->[PERCENT] = completeness ($ass->[HASH]); + } + foreach my $class (values %class) { + $class->[PERCENT] = completeness ($class->[HASH]); + } +} + +sub html_header { + my ($title) = @_; +return <<"EOF"; +<html><head><title>$title</title></head><body bgcolor="#ffffff"> +<h1 ALIGN=center>$title</H1> +EOF + +} + +sub unimplemented ($) { + my ($c) = @_; + my $id = $c; + $id =~ tr/./-/; + return "<A HREF='per-unimplemented.html#$id'>$c</A>"; +} + +sub create_html { + + open(F, ">per-assembly.html") || die "Cannot open file: $!"; + print F html_header("Mono - per-assembly stats"); + print F "<TABLE BORDER=1><TR><TH>Assembly<TH>Maintainer<TH>Completion\n"; + foreach my $ass (sort keys %assembly) { + print F "\t<TR><TD>", join('<TD>', $ass, $assembly{$ass}->[MAINTAINER], $assembly{$ass}->[PERCENT]), "\n"; + } + print F "</TABLE>\n"; + print F "</body></html>\n"; + close(F); + + # per maintainer info + open(F, ">per-maintainer.html") || die "Cannot open file: $!"; + print F html_header("Mono - per-maintainer stats"); + print F "<TABLE BORDER=1><TR><TH>Maintainer<TH>Class<TH>Completion\n"; + foreach my $m (sort keys %maintainer) { + my @classes = sort keys %{$maintainer{$m}->[MCLASS]}; + my $count = @classes; + foreach my $c (@classes) { + my $start = $count?"\t<TR><TD ROWSPAN=$count>$m<TD>":"\t<TR><TD>"; + $count = 0; + print F $start, join('<TD>', $c, $class{$c}->[PERCENT]), "\n"; + } + } + my @unmantained = sort grep {!$class{$_}->[MAINTAINER]} keys %class; + my $count = @unmantained; + foreach my $c (@unmantained) { + my $start = $count?"\t<TR><TD ROWSPAN=$count>Unmantained<TD>":"\t<TR><TD>"; + $count = 0; + print F $start, join('<TD>', $c, $class{$c}->[PERCENT]), "\n"; + } + print F "</TABLE>\n"; + print F "</body></html>\n"; + close(F); + + # per-completion info + open(F, ">per-completion.html") || die "Cannot open file: $!"; + print F html_header("Mono - per-completion stats"); + print F "<TABLE BORDER=1><TR><TH>Completion<TH>Class<TH>Maintainer\n"; + foreach my $c (sort {$class{$b}->[PERCENT] <=> $class{$a}->[PERCENT]} keys %class) { + print F "\t<TR><TD>", join('<TD>', $class{$c}->[PERCENT], unimplemented($c), $class{$c}->[MAINTAINER]), "\n"; + } + print F "</TABLE>\n"; + print F "</body></html>\n"; + close(F); + + # unimplemented methods + # FIXME: this can create a very big file, split on assembly name + # and fix also the unimplemented() sub + open(F, ">per-unimplemented.html") || die "Cannot open file: $!"; + print F html_header("Mono - unimplemented methods stats"); + print F "<TABLE BORDER=1><TR><TH>Class<TH>Method\n"; + foreach my $c (sort grep {$class{$_}->[PERCENT] != 100} keys %class) { + my @methods = sort grep {!$class{$c}->[HASH]->{$_}} keys %{$class{$c}->[HASH]}; + my $count = @methods; + my $aname = ''; + if ($count) { + my $id = $c; + $id =~ tr/./-/; + $aname = "<A NAME='$id'></A>"; + } + foreach my $m (@methods) { + my $start = $count?"\t<TR><TD ROWSPAN=$count>$aname$c<TD>":"\t<TR><TD>"; + $count = 0; + print F $start, join('<TD>', $m), "\n"; + } + } + print F "</TABLE>\n"; + print F "</body></html>\n"; + close(F); + +} + diff --git a/web/.cvsignore b/web/.cvsignore new file mode 100644 index 00000000000..79a25824094 --- /dev/null +++ b/web/.cvsignore @@ -0,0 +1,3 @@ +Makefile.in +Makefile +all-docs diff --git a/web/Makefile.am b/web/Makefile.am new file mode 100644 index 00000000000..dd2e2d85e2c --- /dev/null +++ b/web/Makefile.am @@ -0,0 +1,19 @@ +WEB_FILES= \ + c-sharp class-library contact contributing documentation download \ + faq gcc-frontend ideas index passport rationale resources \ + roadmap runtime status team testing thanks tools + +OTHERS= pending resources-pending todo + +EXTRA_DIST = $(WEB_FILES) README $(OTHERS) + +all-docs: $(WEB_FILES) + cat rationale roadmap c-sharp tools class-library \ + runtime documentation download faq contributing \ + resources status > all-docs + +webit: + (cd web; make && make push) + +push-notes: + scp release-notes/mono* www@www:/web/cvsmodules/mono/archive diff --git a/web/README b/web/README new file mode 100644 index 00000000000..333d133943f --- /dev/null +++ b/web/README @@ -0,0 +1,17 @@ +To edit the website appearance: + +cd doc/web +edit template.html.in +make + +To edit website content: + +cd doc (this directory) +edit files carefully +cd web +make + +To publish changes: + +cd web +make push diff --git a/web/c-sharp b/web/c-sharp new file mode 100644 index 00000000000..c37fe559200 --- /dev/null +++ b/web/c-sharp @@ -0,0 +1,151 @@ +* MCS: The Ximian C# compiler + + MCS began as an experiment to learn the features of C# by + writing a large C# program. MCS is currently able to parse C# + programs and create an internal tree representation of the + program. MCS can parse itself. + + Work is progressing quickly on various fronts in the C# + compiler. Recently I started using the System.Reflection API + to load system type definitions and avoid self-population of + types in the compiler and dropped my internal Type + representation in favor of using the CLI's System.Type. + +** Phases of the compiler + + The compiler has a number of phases: + + <ul> + * Lexical analyzer: hand-coded lexical analyzer that + provides tokens to the parser. + + * The Parser: the parser is implemented using Jay (A + Berkeley Yacc port to Java, that I ported to C#). + The parser does minimal work and syntax checking, + and only constructs a parsed tree. + + Each language element gets its own class. The code + convention is to use an uppercase name for the + language element. So a C# class and its associated + information is kept in a "Class" class, a "struct" + in a "Struct" class and so on. Statements derive + from the "Statement" class, and Expressions from the + Expr class. + + * Parent class resolution: before the actual code + generation, we need to resolve the parents and + interfaces for interface, classe and struct + definitions. + + * Semantic analysis: since C# can not resolve in a + top-down pass what identifiers actually mean, we + have to postpone this decision until the above steps + are finished. + + * Code generation: nothing done so far, but I do not + expect this to be hard, as I will just use + System.Reflection.Emit to generate the code. + + </ul> + +<a name="tasks"> +** Current pending tasks + + Simple tasks: + + <ul> + * Array declarations are currently being ignored, + + * PInvoke declarations are not supported. + + * Pre-processing is not supported. + + * Attribute declarations and passing currently ignored. + + * Compiler does not pass around line/col information from tokenizer for error reporting. + + * Jay does not work correctly with `error' + productions, making parser errors hard to point. It + would be best to port the Bison-To-Java compiler to + become Bison-to-C# compiler (bjepson@oreilly.com + might have more information) + </ul> + + Critical tasks: + + <ul> + * Resolve "base" classes and "base" interfaces for + classes, structs and interfaces. + + Once this is done, we can actually do the semantic + analysis, because otherwise we do not know who our + parents are. + </ul> + + Interesting tasks: + + <ul> + * Finishing the JB port from Java to C#. If you are + interested in working on this, please contact Brian + Jepson (bjepson at oreilly d-o-t com). + + More on JB at: <a href="http://www.cs.colorado.edu/~dennis/software/jb.html"> + http://www.cs.colorado.edu/~dennis/software/jb.html</a> + + JB will allow us to move from the Berkeley Yacc + based Jay to a Bison-based compiler (better error + reporting and recovery). + </ul> + +** Questions and Answers + +Q: Why not write a C# front-end for GCC? + +A: I wanted to learn about C#, and this was an exercise in this + task. The resulting compiler is highly object-oriented, which has + lead to a very nice, easy to follow and simple implementation of + the compiler. + + I found that the design of this compiler is very similar to + Guavac's implementation. + + Targeting the CIL/MSIL byte codes would require to re-architecting + GCC, as GCC is mostly designed to be used for register machines. + + The GCC Java engine that generates Java byte codes cheats: it does + not use the GCC backend; it has a special backend just for Java, so + you can not really generate Java bytecodes from the other languages + supported by GCC. + +Q: If your C# compiler is written in C#, how do you plan on getting + this working on a non-Microsoft environment. + + We will do this through an implementation of the CLI Virtual + Execution System for Unix (our JIT engine). + +Q: Do you use Bison? + +A: No, currently I am using Jay which is a port of Berkeley Yacc to + Java that I later ported to C#. This means that error recovery is + not as nice as I would like to, and for some reason error + productions are not being caught. + + In the future I want to port one of the Bison/Java ports to C# for + the parser. + +Q: How do I compile it? + +A: Compiling MCS currently requires you to run my port of <a + href="http://primates.ximian.com/~miguel/code/jay.cs.tar.gz">Jay to + C#</a> on a Unix system to generate the parser, and then you need + to use Microsoft's .NET csc.exe compiler to compile the compiler. + + You only need to compile the compiler compiler (C code), the + samples are Java samples that I did not port, and you do not need + them. + + It might be simple to port Jay.cs to Windows, but I have not tried + this. + +You might also want to look at the <a href="faq.html#gcc">GCC</a> +section on the main FAQ diff --git a/web/class-library b/web/class-library new file mode 100644 index 00000000000..a2ce00d655b --- /dev/null +++ b/web/class-library @@ -0,0 +1,174 @@ +* The Class Library + + The Class Library should be compatible with Microsoft's .NET + implementation. + + Please see the <a href="class-status.html">Class Status</a> + page for a status of who is working on which classes. + + We will write as much code as possible in C#. We may need to + interface with code written in C to gain access to the + functionality of libraries like libart, Gtk+, and libc. + +** Contributing + + We welcome contributions to the the Class Library. To get + started, check the status page for information about which + APIs are being worked on, and how to get in touch with + individual maintainers. + + If you want to work on a class, first check the <a + href="download.html">Classes Distribution</a> to see if it is + not implemented yet, if not, check the <a + href="class-status.html">Class Status</a> to see if someone is + already working on it, and maybe contact them. + + If nobody is working on it, mail <a + href="mailto:mono-list@ximian.com">mono-list@ximian.com</a> + with the class you want to implement and CC <a + href="mailto:miguel@ximian.com">miguel@ximian.com</a> + +** Layout + + The Class Library resides in the `mcs' module in the directoy + `class'. + + Each directory in the directory represents the assembly where + the code belongs to, and inside each directory we divide the + code based on the namespace they implement. + + There are two cases when we should consider portability: when + we are dealing with a couple of classes only that differ from + system to system (Consider System.Net and System.IO for Win32 + and Unix). In those cases we will just place the files for + example on <t>corlib/System/System.IO/Unix-Console.cs</t> and + <t>corlib/System/System.IO/Win32-Console.cs</t>. + + For classes that might differ more (for example, the + implementation of Windows.Forms), we might have different + directories altogether: <t>System.Windows.Forms/Win32</t>, + <t>System.Windows.Forms/Gtk+</t> and + <t>System.Windows.Forms/Cocoa</t>. + +** Using existing components from GNOME. + + Our current plan is to implement the GUI tools on top of + Gtk+. The only obstacle here is that applications from Windows + might expect to be able to pull the HWND property from the + widgets and use PInvoke to call Windows functions. + +** Class Library and Win32 dependencies. + + There are a few spots where the Win32 foundation is exposed to + the class library (for example, the HDC and HWND properties in + the GDI+). Casual inspection suggests that these can be + safely mapped to Gdk's GC and GdkWindow pointers without + breaking anything. + + The only drawback is that support for PInvoke of Win32 code + won't be available. An alternate solution would be to use + portions of Wine, or even to use Wine as our toolkit. + +*** Initial GDI+ and WinForms implementation + + The initial implementation will use Gtk+ as the underlying + toolkit. Since GTK+ has already been ported to many windowing + systems other than X (including frame buffer, Win32, and BeOS) + its use should cover most applications for most users. + +*** Database access + + We will implement ADO.NET functionality by reusing <a + href="http://www.gnome-db.org">GNOME-DB</a>. This is an ideal + choice, since GNOME-DB was implemented precisely to provide an + ADO-like system for GNOME. + +*** Component Integration + + We will provide a new namespace to use GNOME specific features + as well as a namespace to host Bonobo interfaces and classes + in Mono. + +** Licensing + + The class library will be licensed under the terms of the GNU + LGPL. Some people have pointed out that the plain LGPL is + troublesome for embedded use of the Mono class libraries. So + we are considering to use the GPL with a special exception + (like the <a + href="http://www.gnu.org/software/classpath/classpath.html">GNU + Classpath</a> project did. + + The exception to the GPL would be: + + <i>The library is distributed under the terms of the GNU General + Public License with the following exception: + + If you link this library against your own program, then you do not + need to release the source code for that program. However, any + changes that you make to the library itself, or to any native + methods upon which the library relies, must be re-distributed in + accordance with the terms of the GPL.</i> + + If you are going to contribute, please keep in mind that we + might require you to agree that Ximian might adjust the + license to enable the use of the class libraries on embedded + systems or to develop proprietary applications using Mono. + + We suggest that you assign the copyright of your work to the + GNOME Foundation or the Free Software Foundation to simplify + defending the code in case it is used inappropiately. + +** Class Library testing + + We need to write regression tests that will verify + the correctness of the class library, compiler, and JIT + engine. + +** Coding conventions + + Please follow the conventions on the ECMA specification (On + the Annex Partition) for your coding your libraries. + + Use 8 space tabs for writing your code (hopefully we can keep + this consistent). If you are modifying someone else's code, try + to keep the coding style similar. + + For a rationale on 8 space tabs, read Linus Torvald's Coding + Style guidelines in the Linux kernel source for a rationale. + +*** Missing implementation bits + + If you implement a class and you are missing implementation bits, + please put in the code the word "TODO" and a description of what + is missing to be implemented. + +*** Tagging buggy code + + If there is a bug in your implementation tag the problem by using + the word "FIXME" in the code, together with a description of the + problem. + + Do not use XXX or obscure descriptions, because otherwise people + will not be able to understand what you mean. + +*** Tagging Lame specs + + Sometimes the specification will be lame (consider Version.ToString (fieldCount) + where there is no way of knowing how many fields are available, making the API + not only stupid, but leading to unreliable code). + + In those cases, use the keyword "LAMESPEC". + +** FAQ + +Frequently asked questions about the class library: + +Q: I am writing a new class that overrides one of the system classes, + and I am getting a 1595 warning from the compiler. Should we use a + different namespace? + +A: There is a quick solution to the problem, you can pass the command + line argument /nowarn:1595 and this will effectively let you use + your implementation of the code, while overriding the ones from the + system assemblies.
\ No newline at end of file diff --git a/web/class-status b/web/class-status new file mode 100644 index 00000000000..5e26c2d1e63 --- /dev/null +++ b/web/class-status @@ -0,0 +1,27 @@ +* Status of the various pieces of the class library + + You can browse the status of the class library and see who has + registered to work on what parts of the system. These list + work-in-progress components currently. + + <ul> + * Per <a href="class-status/per-assembly.html">Assembly</a> + + * Per <a href="class-status/per-completion.html">Completion</a> + + * Per <a href="class-status/per-maintainer.html">Maintainer</a> + + * Per <a href="class-status/per-unimplemented.html">Unimplemented</a> + </ul> + + A better mechanism will soon be in place, I just did this + really quickly, as we already got one duplicated implementation. + + You can also download the XML <a + href="class-status/maintainers.xml">maintainers</a> file that + contains the actual maintainers list. + + I am sure we can generate better reports, if you are + interested in contributing, let <a + href="mailto:miguel@ximian.com">me</a> know. + diff --git a/web/contact b/web/contact new file mode 100644 index 00000000000..f5e1b98c115 --- /dev/null +++ b/web/contact @@ -0,0 +1,16 @@ +* Contacting the Mono team. + + You can contact the Mono Team by sending e-mail to `<a + href="mailto:mono-hackers@ximian.com">mailto:mono-hackers@ximian.com</a>'. + + You can contact the general forum of discussion by sending + e-mail to <a href="mailto:mono-list@ximian.com">mono-list@ximian.com</a> + + You can contact me (Miguel de Icaza) by sending e-mail to <a + href="mailto:miguel@ximian.com">miguel@ximian.com</a>. My web + page is <a + href="http://primates.ximian.com/~miguel">http://primates.ximian.com/~miguel"</a> + + You can also <a + href="http://www.ximian.com/about/contact.php3">reach Ximian.</a> + diff --git a/web/contributing b/web/contributing new file mode 100644 index 00000000000..7e64a96ab21 --- /dev/null +++ b/web/contributing @@ -0,0 +1,53 @@ +* Contributing to the Mono project + + There are many ways in which you can help in the Mono project: + + <ul> + * <b>Programmers:</b> You can work on a free + implementation of the <a + href="class-library.html">class libraries</a>, the + <a href="runtime.html">runtime engine</a>, <a + href="tools.html">the tools</a>, the <a + href="testing.html">testing framework</a> + + * <b>Writers:</b> You can help us with writing <a + href="documentation.html">documentation</a>. + </ul> + + Those are just broad things that need to be worked on, but + something that would help tremendously would be to help with + small duties in the project that need to be addressed. + +** Small tasks + + A few smaller tasks are here, dropped in no particular order: + <ul> + * <b>MCS compilation process:</b> Currently MCS does + not build with a single `make' command. This should + be fixed (this being part of the `Joel Test' that + software has to pass). + + * <b>Mono/doc and web site:</b> They need to be + packaged up in the official `distribution' + + * <b>Enthusiasts: </b> + </ul> + +* Special note + + If you have looked at Microsoft's implementation of .NET or + their shared source code, you may not be able to contribute + to Mono. Details will follow when we know more about this. + + In general be careful when you are implementing free software + and you have access to proprietary code. We need to make sure + that we are not using someone else's copyrighted code + accidentally. + + Please do not use the <b>ildasm</b> program to disassemble + proprietary code when you are planning to reimplement a class + for Mono. If you have done this, we might not be able to use + your code. + + Please stick to published documentation for implementing any + classes. diff --git a/web/documentation b/web/documentation new file mode 100644 index 00000000000..166e0e8ccfe --- /dev/null +++ b/web/documentation @@ -0,0 +1,50 @@ +* Documentation + + Although most of the concepts from Microsoft.NET can + be applied to the completed Mono platform, we do need to + have a complete set of free documentation written specifically + for Mono. + + The documentation license we have chosen is the GNU Free + Documentation License (FDL), the standard for most documents + in the free software world. + + We need documentation on a number of topics: + + <ul> + + * The development tools (compilers, assembler tools, + language reference, design time features). + + * Frequently Asked Question compilations. + + * HOWTO documents. + + * The Class Libraries + + * Tutorials on Mono and the specifics of running it. + + * A guide to Mono as compared to the Microsoft.NET + Framework SDK + + </ul> + +** Class Library documentation + + When contributing to the Class Library effort, please use the + inline XML documentation tags to document your classes so we + can automatically generate the documentation from the class + libraries. + + If you provide examples, please do not embed them into the + source code, as that will make the source code harder to read + and maintain. Instead, put examples for your code into a + subdirectory of the class libraries. Make your sample + code a full standalone application that people can compile. + Ideally the Mono documentation browser will let you edit, modify + and run the sample programs. + + + + + diff --git a/web/download b/web/download new file mode 100644 index 00000000000..27a82064593 --- /dev/null +++ b/web/download @@ -0,0 +1,52 @@ +* Software Availability + + The Virtual Execution System is available in package `mono'. + Currently this contains a metadata library and the + disassembler. Please reffer to our <a + href="runtime.html">Runtime</a> description for more details + on this part of the project. + + The code for the C# compiler as well as the language error + test suite and the class library are in the `mcs' package, we + will move this later into `mono' itself. + + The mcs compiler requires the `jay' parser generator, this is + available in module `jay'. + +** Sources + + Currently we will be providing CVS snapshots every day, until + we make the first tarball release. + + <ul> + <a name="july-15"> + <b>July 15th, 2001</b> + <ul> + * <a href="archive/mcs-15-Jul-2001.tar.gz">mcs-15-Jul-2001.tar.gz</a>: CVS snapshot. + * <a href="archive/mono-0.4.tar.gz">mono-0.4.tar.gz</a>: Packaged Source Code. + * <a href="archive/mono-0.4">Release Notes</a> + </ul> + + <a name="july-14"> + <b>July 14th, 2001</b> + <ul> + * <a href="archive/jay.cs.tar.gz">archive/jay.cs.tar.gz</a>: Sources to Jay. + * <a href="archive/mcs-12-Jul-2001.tar.gz">mcs-12-Jul-2001.tar.gz</a>: CVS snapshot. + * <a href="archive/mono-0.3.tar.gz">mono-0.3.tar.gz</a>: Packaged Source Code. + </ul> + + <a name="july-8"> + <b>July 8th, 2001</b> + + <ul> + * <a href="archive/jay.cs.tar.gz">archive/jay.cs.tar.gz</a>: Sources. + * <a href="archive/mcs-08-Jul-2001.tar.gz">mcs-08-Jul-2001.tar.gz</a>: CVS Snapshot + * <a href="archive/mono-08-Jul-2001.tar.gz">mono-08-Jul-2001.tar.gz</a>: CVS Snapshot + </ul> + </ul> + +** CVS + + We are trying to figure out where to put our CVS repository. + We are debating between the GNOME CVS or SourceForge. Watch + this spot. diff --git a/web/faq b/web/faq new file mode 100644 index 00000000000..8f9f8f199f4 --- /dev/null +++ b/web/faq @@ -0,0 +1,609 @@ +** Basics + +Q: Is Mono the same as Microsoft's .NET initiative? + +A: It is not. + + .NET is a company-wide initiative at Microsoft that + encompasses many different areas. The .NET development framework, + Passport, Biztalk, new server products, and anything that is + remotely connected to .NET gets the ".NET-stamping" treatment. + Some components of Microsoft's .NET initiative have been announced + and some others are in the works. + + Mono is a project to implement several technologies developed by + Microsoft that have now been submitted to the ECMA Standards Body. + +Q: What technologies are included in Mono? + +A: Mono contains a number of components useful for building new + software: + + <ul> + * A Common Language Infrastructure (CLI) virtual + machine that contains a class loader, Just-in-time + compiler, and a garbage collecting runtime. + + * A class library that can work with any language + which works on the CLR. + + * A compiler for the C# language. In the future we + might work on other compilers that target the Common + Language Runtime. + + Windows has compilers that target the + virtual machine from + <a href="http://msdn.microsoft.com/net/thirdparty/default.asp#lang">a + number of languages:</a> Managed C++, Java Script, + Eiffel, Component Pascal, APL, Cobol, Oberon, Perl, + Python, Scheme, Smalltalk, Standard ML, Haskell, + Mercury and Oberon. + </ul> + + The CLR and the Common Type System (CTS) enables applications and + libraries to be written in a number of languages. Classes and + methods created in one language can be used from a different + language. + + This means for example that if you define a class to do algebraic + manipulation in C#, that class can be reused from any other + language that supports the CLI. You could create a class in C#, + subclass it in C++ and instantiate it in an Eiffel program. + + A single object system, threading system, class libraries, and + garbage collection system can be shared across all these languages. + +Q: Where can I find the specification for these technologies? + +A: You can find the work-in-progress documentation from the T3G ECMA + group here: + + <a href="http://www.dotnetexperts.com">http://www.dotnetexperts.com</a> + +Q: Will you implement the .NET Framework SDK class libraries? + +A: Yes, we will be implementing the APIs of the .NET Framework SDK + class libraries. + +Q: What does Mono stand for? + +A: Mono is the word for `Monkey' in Spanish. We like monkeys. + +Q: When will you ship it? + +A: We do not know when the code will be shipped. The more + contributions we get to the project, the sooner it will ship. + + A rough estimate is that we might be able to run our C# compiler on + Linux by the end of the year. That means running the Windows + Executable generated by a Microsoft .NET compiler on the Linux + platform. + + We expect that doing GUI applications will require more work on the + class libraries. That could take another six months. + +Q: How can I contribute? + +A: Check the <a href="contributing.html">contributing</a> section. + +Q: You guys should innovate instead of copying. + +A: In this particular case, we see a clear advantage in the platform + and we are interested in using the features of the CLI on open source systems. + + We have decided that we should spend our limited resources towards + implementing an existing specification instead of designing and + implementing our own. + + Designing and implementing our own would be possible, but it doesn't make + sense to do that just because the specification comes from a + proprietary vendor. + +** Ximian + +Q: Why is Ximian working on .NET? + +A: We are interested in providing the best tools for programmers to + develop applications for Free Operating Systems. + + For more information, read the project <a + href="rationale.html">rationale</a> page. + +Q: Will Ximian be able to take on a project of this size? + +A: Ximian will not be able to taken on the whole project on its own. + Mono will be a free software/open source community project, that is + the only way we can hope to implement something of this size. You + can <a href="contributing.html">contribute</a> to this effort. + +Q: What pieces will Ximian be working on? + +A: We will focus on building a development and execution + environment. + + The idea is to get Mono to a state of that would allow + third parties to actually be able to use it real-world development. + +Q: Why does Ximian even care? + +A: We like the features that the CLI and its related technologies + bring to the table. An exciting addition to the developer toolkit. + The goal of Mono is to bring this technology to non-Windows + platforms (although we hope Mono will also run on Windows, for + debugging and comparative purposes). + + +** Licensing + +Q: Will I be able to write proprietary applications that run with + Mono? + +A: Yes. We will make sure that the licensing will allow developers to + create proprietary applications. + +Q: What license is Mono on? + +A: The C# Compiler is released under the terms of the GPL. The class + libraries will be under the LGPL or the GPL with a special + exception. The runtime libraries are under the LGPL. + + Here is the exception for the class libraries: + + The library is distributed under the terms of the GNU General + Public License with the following exception: + + If you link this library against your own program, then you do not + need to release the source code for that program. However, any + changes that you make to the library itself, or to any native + methods upon which the library relies, must be re-distributed in + accordance with the terms of the GPL. + + This is similar in spirit to <a + href="http://www.gnu.org/software/classpath/classpath.html">GNU + Classpath.</a> + +Q: Will you accept code under the XXX License? + +A: If the XXX License is compatible with the license we use in that + specific piece of code, then yes. If you want to use the BSD license, make + sure you use the BSD license without the advertisement clause (The + `Ousterhout License'). + +** Mono and .NET + +Q: If applications use Mono, does that mean that I have to pay a service fee? + +A: No. Mono is not related to Microsoft's initiative of + software-as-a-service. + +Q: If you implement .NET, will I depend on Microsoft Passport to run my software? + +A: No. The .NET Framework is a runtime infrastructure and collection + of class libraries. Passport may be required to access certain web + services written for that framework, but only if the programmer + chooses Passport as the authentication mechanism. + +Q: Is .NET just a bunch of marketing slogans? + +A: Although the `.NET initiative' is still quite nebulous, The .NET Framework + has been available for some time. Mono is not an implementation of the .NET + initiative, just the development framework. + +Q: What is a 100% .NET application? + +A: A `100% .NET application' is one that only uses the APIs defined + under the System namespace and does not use PInvoke. These + applications would in theory run unmodified on Windows, Linux, + HP-UX, Solaris, MacOS X and others. + +Q: But Microsoft will release a port of the real thing under the + `Shared Source' license, why bother with anything else? + +A: The Shared Source implementation will not be usable for commercial + purposes. We are working towards an implementation that will grant + a number of rights to recipients: use for any purpose, + redistribution, modification, and redistribution of modifications. + + This is what we call <a + href="http://www.gnu.org/philosophy/free-sw.html">Free Software</a> + +** Passport + +Q: Is this a free implementation of Passport? + +A: No. Passport is part of Microsoft's Hailstorm initiative. Mono + is just a runtime, a compiler and a set of class libraries. + +Q: Will the System.Web.Security.PassportIdentity class, mean + that my software will depend on Passport? + +A: No. That just means that applications might use that API to + contact a Passport site. + + As long as your application does not use Passport, you will not + need Passport. + + It might even be possible to implement that class with + a set of dummy functions, or use an alternate Passport implementation. + + We do not know at this time whether the Passport protocol is + documented and whether we will be able to talk to + passport.com + +Q: What is your opinion? + +A: You can read my personal <a href="passport.html">opinion on + passport</a>. + +** Mono and Windows + +Q: Will Mono allow me to run Microsoft Office on Linux? + +A: No, it will not. Microsoft Office is a Windows application. To + run Windows applications on Intel Unix systems refer to <a + href="http://www.winehq.com">the Wine Project</a> + +** GNOME + +Q: How is this related to GNOME? + +A: In a number of ways: + + * Mono will use existing + components that have been developed for GNOME when it makes + sense. For example on X systems, we will use Gtk+ and + Libart to implement Winforms and the Drawing2D API. + + For database access, we will use LibGDA (not really + depending on GNOME, but related to). + + * This project was born out of the need of providing improved + tools for the GNOME community. + + * We would like to add support to our CLR implementation to + deal with GObjects (in GNOME 1.x, they are called + GtkObjects), and allow Mono developers to provide GObjects + or use and extend existing GObjects. + +Q: Has the GNOME Foundation or the GNOME team adopted Mono? + +A: Mono is too new to be adopted by those groups. We hope that the + tools that we will provide will be adopted by free software + programmers including the GNOME Foundation members and the GNOME + project generally. + +Q: Should GNOME programmers switch over to Mono? + +A: Mono will not be ready even within the next six months, and a + complete implementation is probably one year away. + + We encourage GNOME developers to continue using the existing tools, + libraries and components. Improvements made to GNOME will have an + impact on Mono, as they will provide the "backend" for various + classes. + +Q: Will Mono include compatibility with Bonobo components? + +A: Yes, we will provide a set of classes for implementing and using + Bonobo components from within Mono. + +** Mono and the Web + +Q: Is Mono a way of running Java applets? + +A: No. + +** Web Services + +Q: Is Mono just a new way of writing Web Services? + +A: No. + +Q: If this implements the SDK classes, will I be able to write and + execute .NET Web Services with this? + +A: Yes, you will. + + When the project is finished, you will be able to use the same + technologies that are available through the .NET Framework SDK on + Windows to write Web Services. + +Q: What about Soup? + +A: Soup is a library for GNOME applications to create SOAP server and + SOAP clients. You can browse the source code for soup using <a + href="http://cvs.gnome.org/bonsai">GNOME's Bonsai</a> + +Q: Can I use CORBA? + +A: Yes. The CLI contains enough information about a class that + exposing it to other RPC systems (like CORBA) is really simple, and + does not even require support from an object. + + We will be implementing CORBA interoperation as an extension to the + Mono classes so that we can integrate with Bonobo, just like + Microsoft provides COM interoperation classes and support + mechanisms. + +Q: Can I serialize my objects to other things other than XML? + +A: Yes, although the serializing tools have not yet been planned, and +you would probably have to implement them yourself. + +** Development Tools + +Q: Will it be possible to use the CLI features without using bytecodes + or the JIT? + +A: Yes. The CLI engine will be made available as a shared library. + The garbage collection engine, the threading abstraction, the + object system, the dynamic type code system and the JIT will be + available for C developers to integreate with their applications if + they wish to do so. + +Q: Will you have new development tools? + +A: Hopefully Free Software enthusiasts will contribute tools to + improve the developer environment. These tools could be developed + initially using Microsoft implementation of the CLI and then + executed later with Mono. + +** Mono and Java + +Q: What about using Java? After all there are many languages that + target the Java VM. + +A: You can get very good tools for doing Java development on free + systems right now. <a href="http://www.redhat.com">Red Hat</a> has + contributed a <a href="http://gcc.gnu.org">GCC</a> <a + href="http://gcc.gnu.org/java">frontend for Java</a> that can take + Java sources or Java byte codes and generate native executables; <a + href="http://www.transvirtual.com">Transvirtual</a> has implemented + <a href="http://www.kaffe.org">Kaffe</a> a JIT engine for Java; + Intel also has a Java VM called <a + href="http://www.intel.com/research/mrl/orp">ORP</a>. + + The JVM is not designed to be a general purpose virtual machine. + The Common Intermediate Language (CIL), on the other hand, is + designed to be a target for a + wide variety of programming languages, and has a set of rules + designed to be optimal for JITers. + + +Q: What kind of rules make the Common Intermediate Language useful for + JITers? + +A: The main rule is that the stack in the CLI is not a general purpose + stack. You are not allowed to use it for other purposes than + computing values and passing arguments to functions or return + values. + + At any given call or return instruction, the types on the stack + have to be the same independently of the flow of execution of your + code. + +Q: I heard that the CIL is ideal for JITing and not efficient for + interpreters, is this the case? + +A: The CIL is better suited to be JITed than JVM byte codes, but you + can interpret them as trivially as you can interpret JVM byte + codes. + +** Extending Mono + +Q: Would you allow other classes other than those in the + specification? + +A: Yes. The Microsoft class collection is very big, but it is by no + means complete. It would be nice to have a port of `Camel' (the + Mail API used by Evolution inspired by Java Mail) for Mono + applications. + + You might also want to look into implementing CORBA for Mono. Not + only because it would be useful, but because it sounds like a fun + thing to do, given the fact that the CLI is such a type rich + system. + + For more information on extending Mono, see our <a + href="ideas.html">ideas</a> page. + +** Mono and portability + +Q: Will Mono only work on Linux? + +A: Currently, we are doing our work on Linux-based systems and + Windows. We do not expect many Linux-isms in the code, so it + should be easy to port Mono to other UNIX variants. + +Q: What about Mono on non X-based systems? + +A: Our main intention at Ximian is to be able to develop GNOME + applications with Mono, but if you are interested in providing a + port of the Winform classes to other platforms (frame buffer or + MacOS X for example), we would gladly integrate them, as long + they are under a Free Software License. + +** Reusing existing Code + +Q: What projects will you reuse or build upon? + +A: We want to get Mono in the hands of programmers soon. We are + interested in reusing existing open source software. + +Q: What about Intel's research JIT framework, ORP? + +A: At this time, we are investigating whether we can use elements of + ORP for Mono. ORP is a research JIT engine that has a clear + defined API that splits the JIT from the GC system and the actual + byte code implementation. It is a research product. + +Q: What about using GNU Lightning? + +A: We are also researching <a + href="http://www.gnu.org/software/lightning/lightning.html">GNU + Lightning</a>. + +** Ximian and Microsoft + +Q: Didn't Miguel de Icaza say that `Unix Sucks'? + +A: Yes, he did, as a catch phrase in his opening remark on the Ottawa + Linux Symposium. His talk focused on various ways to improve Unix. + + There is a paper describing some ways to improve Unix at: + + <a href="http://primates.ximian.com/~miguel/bongo-bong.html"> + http://primates.ximian.com/~miguel/bongo-bong.html</a> + +Q: Didn't Ximian's Miguel work for Microsoft? + +A: Actually, Nat Friedman (Ximian's co-founder) did work as an + intern for Microsoft for one summer but Miguel did not. + +Q: Did Nat and Miguel meet at Microsoft? + +A: They met online on the Linux IRC network; They met in person for + the first time in 1997. + +** Mono and Microsoft + +Q: How can you expect Mono to compete with Microsoft, wont this + require an effort too large? + +A: You are right. Mono will never become a reality without the help + of other contributors. Ximian is a small company that can not + finish Mono alone. We will be working with members of the + community to deliver the product. + +Q: Is Microsoft and Corel involved in the Mono implementation? + +A: No, they are not. + +Q: Are you writing Mono from the ECMA specs? + +A: yes, we are writing them from the ECMA specs and the published + materials in print about .NET + +** Acronyms + +Q: What is the difference between CLR (Common Language Runtime) and + CLI (Common Language Infrastructure)? + +A: CLI is the specification of an execution system. The Microsoft + implementation of this specification is named CLR. + + Unless we come up with our own acronym, we could just call ours + also CLR, just because it would do exactly the same thing the + Microsoft implementation does. + +<a name="gcc"> +** Mono and GCC + +Q: Should someone work on a GCC front-end to C#? + +A: I would love if someone does, and we would love to help anyone that + takes on that task, but we do not have the time or expertise to + build a C# compiler with the GCC engine. I find it a lot more fun + personally to work on C# on a C# compiler, which has an intrinsic + beauty. + +Q: Should someone make a GCC backend that will generate CIL images? + +A: I would love to see a backend to GCC that generates CIL images. It + would provide a ton of free compilers that would generate CIL + code. This is something that people would want to look into + anyways for Windows interoperation in the future. + +Q: What about making a front-end to GCC that takes CIL images and + generates native code? + +A: I would love to see this, specially since GCC supports this same + feature for Java Byte Codes. You could use the metadata library + from Mono to read the byte codes (ie, this would be your + "front-end") and generate the trees that get passed to the + optimizer. + + Ideally our implementation of the CLI will be available as a shared + library that could be linked with your application as its runtime + support. + +Q: But would this work around the GPL in the GCC compiler and allow + people to work on non-free front-ends? + +A: People can already do this by targeting the JVM byte codes (there + are about 130 compilers for various languages that target the JVM). + +Q: Why are you writing a JIT engine instead of a front-end to GCC? + +A: The JIT engine and runtime engine will be able to execute CIL + executables generated on Windows. + +** Mono and GNU + +Q: Is Mono part of the GNU project? + +A: Mono is a Ximian project, that is also part of the GNU project. + +** Mono and Portability + +Q: Will Mono work on other variants of Unix? + +A: Yes. We do not expect to add any gratuitous incompatibilities. + +Q: Will Mono run on Windows? + +A: Hopefully yes. Currently some parts of Mono only run on Windows + (the C# compiler is a .NET executable) and other parts have only + been compiled on Linux, but work on Windows with Cygwin. + +Q: Will Mono depend on GNOME? + +A: It will depend only if you are using a particular assembly (for + example, for doing GUI applications). If you are just interested + in Mono for implementing a `Hello World Enterprise P2P Web + Service', you will not need any GNOME component. + +** Performance + +Q: How fast will be Mono? + +A: We can not predict the future, but a conservative estimate is that + it would be at least `as fast as other JIT engines'. + + Now, wishfully thinking I hope that we will ship various JITs with + Mono just like Microsoft has done. A fast JITer when maximum + performance is not needed, but fast load times are important; And + an optimizing JITer that would be slower at generating code but + produce more optimal output. + + The CIL has some advantages over the Java byte code: it is really + an intermediate representation and there are a number of + restrictions on how you can emit CIL code that simplify creating + better JIT engines. + + For example, on the CIL the stack is not really an abstraction + available for the code generator to use at will: it is just a way + of creating a postfix representation of the parsed tree. At any + given call point or return point, the contents of the stack are + expected to contain the same object types independently of how the + instructions was reached. + +** Assorted questions + +Q: You say that the CLI allows multiple languages to execute on the + same environment. Isn't this the purpose of CORBA? + +A: CORBA can be used for this purpose, but think of CORBA mostly as a + inter-process (local machine or remote machine) communication + system. + + Think of the CLI to be targeted to interoperation of languages in + the same process, and CORBA as being a nifty addition for + out-of-process. + + Sure, we have used CORBA for in-proc components, but the lack of an + ABI for in-proc components does not translate into a good framework + for in-proc systems + + + diff --git a/web/gcc-frontend b/web/gcc-frontend new file mode 100644 index 00000000000..2b15346db69 --- /dev/null +++ b/web/gcc-frontend @@ -0,0 +1,9 @@ +* The GCC front-end + + The GCC front-end will accept input in a binary file with + codes in the Common Intermediate Language (CIL), and generate + native code. + + This will allow pre-compilation and full optimization to take + place before a program is executed. + diff --git a/web/ideas b/web/ideas new file mode 100644 index 00000000000..acc584d95cf --- /dev/null +++ b/web/ideas @@ -0,0 +1,40 @@ +* Ideas + + Here are a few ideas of tools, classes and projects that you + could start. More are forthcoming. + +<a name="classes"> +** Classes + + <ul> + * Implement a JXTA protocol implementation: + <a href="http://www.jxta.org">http://www.jxta.org</a> + + * Implement a Mail API, similar to Camel or JavaMail (Camel has + significant architecture features that are required on a real + mailer). + + You can check the current C + <a href="http://cvs.gnome.org/bonsai/rview.cgi?dir=evolution%2Fcamel"> + Camel implementation</a>. + + * Interfacing to Multimedia systems. You might want + to look into the Quicktime API. I know <a + href="mailto:vladimir@ximian.com">Vladimir</a> has + researched the problem before + </ul> + +<a name="projects"> +** Projects + + <ul> + * Implement an xmlStorageSystem for the CLI: + <a href="http://www.soapware.org/xmlStorageSystem"> + http://www.soapware.org/xmlStorageSystem</a> + + * Build a CORBA interoperability engine for the CLR. + You do not need to do all of the work, just talking + the protocol will get us a long way (<a + href="http://www.omg.org">The OMG site</a> has the CORBA specs). + + </ul> diff --git a/web/index b/web/index new file mode 100644 index 00000000000..db1035e01bf --- /dev/null +++ b/web/index @@ -0,0 +1,45 @@ +** Jul 15, 2001 + + Another release of Mono is out, check the <a + href="archive/mono-0.4">Mono 0.4 Release Notes</a>. Get it <a + href="download.html#july-15">here</a>. + +** Jul 14, 2001 + + A <a + href="http://mail.ximian.com/archives/public/mono-list/2001-July/000399.html">new + release</a> of the + runtime, compiler and classes has been made. Get it <a href="download.html#july-14">here</a> + +** Jul 12, 2001 + + I keep getting questions about my opinion on Passport, even when + Mono has <b>nothing</b> to do with it. I finally <a + href="passport.html">wrote something.</a> + +** Jul 9, 2001 + + Today <a href="http://www.ximian.com">Ximian</a> announced the + launch of the Mono + project, an effort to create a free software + (sometimes called open source) implementation of the .NET + Development Framework. + + If you have questions about the + project, please read our list of <a + href="faq.html">Frequently Asked Questions</a>. + + You might also want to <a href="download.html">Download the + source</a> for our work so far. + + You might want to <a + href="resources.html#mailing">subscribe</a> to our mono-list + and mono-announce-list + + You can contact the team at: <a + href="mailto:mono-list@ximian.com">mono-list@ximian.com</a> + +** O'Reilly + + Brian posted a story on <a + href="http://www.oreillynet.com/dotnet">O'Reilly Network .NET</a> diff --git a/web/passport b/web/passport new file mode 100644 index 00000000000..facf3ee01b0 --- /dev/null +++ b/web/passport @@ -0,0 +1,231 @@ +* Microsoft Hailstorm and Passport + + Microsoft Passport is a centralized database hosted by + Microsoft that enhances the consumer experience with the Web + by providing a single logon system that they can use across a + number of participant web sites. + + As you might know by now from our extensive <a + href="faq.html">FAQ</a>, the Mono project has nothing to do + with Microsoft Hailstorm or <a + href="http://www.passport.com">Microsoft Passport.</a> + + Still a lot of people have asked us our opinion on them. + +** Passport + + Passport is important not because of it being breaktrough + technologically speaking, but because the company is in a + position to drive most people toward being suscribers of it. + + At the time of this writing passport is required to use the + free mail service <a href="http://www.hotmail.com">Hotmail</a> + to get customized support for the <a + href="http://www.msn.com">MSN portal</a>, <a + href="http://msdn.microsoft.com">Microsoft Developers + Network</a> and according to the original announcement from + Microsoft <a href="http://www.americanexpress.com">American + Express</a> and <a href="http://www.ebay.com">EBay</a> will be + adopting it. + + There is already a <a + href="http://www.passport.com/Directory/Default.asp?PPDir=C&lc=1033">Large + list</a> of participating sites. + + There are many current users of it and Microsoft will be + driving more users towards Passport as it <a + href="http://news.cnet.com/news/0-1003-200-6343275.html">integrates + it</a> in their upcoming release of Windows. + + Microsoft has also <a + href="http://www.passport.com/Business/JoinPassportNetwork.asp?lc=1033">developed + a toolkit</a> to enable current web merchants to integrate + their services with passport. + + To the end user, there is a clear benefit: they only have to + log into a single network and not remember multiple passwords + across sites on the internet. Companies that adopt passport + will have a competition advantage over those that dont. + Microsoft lists a list of <a + href="http://www.passport.com/Business/Default.asp?lc=1033">benefits</a> + to companies. + + +** The problems of Passport + + There are a number of concerns that different groups have over + Passport. Sometimes I have some, sometimes I do not. But + overall, consumers and businesses can have better solutions. + + <ul> + * <b>Single Point of Failure:</b> As more services and + components depend on remote servers, functionality can + grind to a halt if there is a failure on the + centralized Passport system. + + Such a failure was predicted, and we recently <a + href="http://news.cnet.com/news/0-1005-200-6473003.html">witnessed</a> + got a lot of people worried. + + The outgage lasted for seven days. Think what this + could do to your business. + + * <b>Trust:</b> Not everyone trusts Microsoft to keep + their information confidential. Concerns are not only + at the corporate level policy, but also the fact that + the source code for Microsoft products is not + available, means that trojans or worms could be built + into the products by malicious engineers. This is not + unheard of, as the <a + href="http://slashdot.org/articles/00/04/14/0619206.shtml">Microsoft + Internet Server</a> had a trojan horse built into that + allowed anyone that knew about this to control any + server running IIS. + + * <b>Security:</b> With a centralized system like + Passport, imagine the repercussions of a malicious + hacker gaining access to the Passport database. + Personal information and credit card information about + almost everyone using a computer could be stored there. + + Hackers have already <a + href="http://slashdot.org/articles/00/10/27/1147248.shtml">broken + into Microsoft</a> in the past. And the company was + unable to figure out for how long their systems had been hacked. + </ul> + + Microsoft might or might not realize this. The idea behind + Passport is indeed a good one (I can start to get rid of my + file that keeps track of the 30 logins and passwords or so + that I use across the various services on the net myself). + +** Alternatives to Microsoft Passport + + An alternative to Microsoft Passport needs to take the above + problems into consideration. Any solution of the form `We + will just have a competing offering' will not work. + + The system thus has to be: + + <ul> + * <b>Distributed:</b> The entire authentication + system should not create an internet `blackout' in the + case of failure. + + * <b>Allow for multiple registrars:</b> Users should + be able to choose a registrar (their banks, local + phone company, service provider, Swiss bank, or any + other entity they trust. + + * <b>Mandate good security measures:</b> As a + principle, only Open Source software should be used + for servers in the registrar, and they should conform + to a standard set of tools and software that can be + examined by third parties. + </ul> + + An implementation of this protocol could use the DNS or a + DNS-like setup to distribute the information of users with the + possibility of replicating and caching public information + about the user. + + For instant messaging (another pieces of the Hailstorm bit), + you want to use a non-centralized system like Sun's <a + href="http://www.jxta.org">JXTA</a>. Some people mailed me to + mention Jabber as a messaging platform. + + It could also just use the user e-mail address as the `key' to + choose the registrar (msn.com, hotmail.com -> passport.com; + aol.com -> aol.passport.com; you get the idea). + + The <a + href="http://www.soapware.org/xmlStorageSystem">xmlStorage</a> + idea from <a href="http://www.scripting.com">Dave Winer</a> + could be used to store the information. + + A toolkit for various popular web servers could be provided, + authenticated and should be open sourced (for those of you who + think that a binary program would give more security and would + prevent people from tampering: you are wrong. You can always + use a proxy system that "behaves" like the binary, and passes + information back and forth from the real program, and snoops + in-transit information). + + Good cryptographers need to be involved in this problem to + figure out the details and the possible insecure pieces of a + proposal like this. + +** Implementation: In short + + To keep it short: <b>DNS, JXTA, xmlStorage.</b> + + +** Deploying it + + The implementation of such a system should be a pretty + straightforward tasks once security cryptographers have + designed such a beast. + + The major problems are: + + <ul> + * <b>People might just not care:</b> In a poll to US + citizens a couple of decades ago, it was found that + most people did not care about the rights they were + given by the Bill of Rights, which lead to a number of + laws to be passed in the US that eliminated most of + the rights people had. + + * <b>The industry will move way too slow:</b> + Microsoft's implementation is out in the open now: it + is being deployed, and soon it will be insinuated to + many, many users. The industry needs to get together + soon if they care about this issue. + + By the time the industry reacts, it might be too + late. + </ul> + +** Passport and Mono + + The .NET class libraries includes a Passport class that + applications might use to authenticate with Passport. Since + we do not have information at this point on the exact protocol + of Passport, it is not even feasible to implement it. + + If at some point the information is disclosed, it could be + implemented. + + If a competing system to Passport existed, we could probably + hide all the authentication information to use a number of + different passport-like systems. + + If a user does not want to use Passport at all, he could + always turn it off (or completely remove the class from the + library). After all, this is free software. + + Currently, we are too far from the point where this is a real + issue. + +** Disclaimer + + This is just a group of personal thoughts of mine that I have + placed here because I get asked this question a lot lately. + The views of this page are not a statement from my employer + (Ximian, Inc). + + This is not part of Mono. We are not trying to deal with this + problem. + + Nat Friedman (Ximian's co-founder) has his own ideas on how a + competing system to Passport could be designed, but I will let + <a href="http://www.nat.org/gym">him</a> post his own story. + +** Other Alternatives + + Some people have pointed out <a + href="http://www.xns.org">XNS</a> + +Send comments to me: Miguel de Icaza (<a + href="mailto:miguel@ximian.com">miguel@ximian.com</a>) + diff --git a/web/pending b/web/pending new file mode 100644 index 00000000000..e243a10dedf --- /dev/null +++ b/web/pending @@ -0,0 +1,14 @@ +** Microsoft and GNU and Linux. + +Q: Does this mean that Microsoft is better than Linux? + +A: Many of us are working on <a + href="http://www.gnu.org/philosophy/free-sw.html">free software<a> + and want to have an <a href="http://www.opensource.org">open + source</a> environment that we can change, modify, improve, learn + from, and share with others. Some of us also think that this will + lead on the long run to better software: more efficient, faster, + more robust and more. + + We are willing to take good ideas from any source they come from. + diff --git a/web/rationale b/web/rationale new file mode 100644 index 00000000000..1027d292286 --- /dev/null +++ b/web/rationale @@ -0,0 +1,173 @@ + +* The Mono Project + +** Background. + + The GNOME project goal was to bring missing technologies to + Unix and make it competitive in the current market place for + desktop applications. We also realized early on that language + independence was important, and that is why GNOME APIs were + coded using a standard that allowed the APIs to be easily + wrapped for other languages. Our APIs are available to most + programming languages on Unix (Perl, Python, Scheme, C++, + Objective-C, Ada). + + Later on we decided to use better methods for encapsulating + our APIs, and we started to use CORBA to define interfaces to + components. We complemented it with policy and a set of + standard GNOME interfaces for easily creating reusable, + language independent components, controls and compound + documents. This technology is known as <a + href="http://www.ximian.com/tech/bonobo.php3">Bonobo</a>. + Interfaces to Bonobo exist for C, Perl, Python, and + Java. + + CORBA is good when you define coarse interfaces, and most + Bonobo interfaces are coarse. The only problem is that + Bonobo/CORBA interfaces are not good for small interfaces. + For example, an XML parsing Bonobo/CORBA component would be + inefficient compared to a C API. + +** Another explanation + + I recently explained our motivations to Dave Winer, and he posted + it <a + href="http://scriptingnews.userland.com/stories/storyReader$1275">here</a> + +** Microsoft's .NET + + The Microsoft .NET initiative is confusing because it is a + company wide effort that ranges from development tools to end + user applications. .NET is a branding formative that + has been applied to: + + <ul> + * The .NET development platform, a new platform for + writing software. + + * Web services. + + * Microsoft Server Applications. + + * New tools that use the new development platform. + + * Hailstorm, the Passport centralized single-signon + system that is being integrated into Windows XP. + + </ul> + + Mono is an implementation of the .NET development platform. + +** The Common Language Infrastructure platform. + + Microsoft has created a new development platform. The + highlights of this new development platform are: + + <ul> + * A runtime environment that provides garbage + collection, threading and a virtual machine + specification (The Virtual Execution System, VES) + + * A comprehensive class library. + + * A new language, C#. Very similar to Java, C# + allows programmers to use all the features available + on the .NET runtime. + + * A language specification that compilers can + follow if they want to generate classes and code + that can interoperate with other programming + languages (The Common Language Specification: CLS) + </ul> + + The Common Language Infrastructure platform is similar to the + goals we had in GNOME of giving language independence to + programmers. It is more mature, documented, larger in scope, + and has a consistent design. + + Any API that is written using a CLS provider language can be + used by any language that is a CLS consumer. Compilers + generate code in a format called Common Intermediate Language + (CIL) which is an intermediate representation of a compiled + program and is easy to compile to native code or compiled + using Just-in-Time (JIT) engines. The restrictions placed by + the runtime on the CIL byte codes ensures that it is possible + to do a good job at optimizing the code in a JIT compiler. + + There is not really a lot of innovation in this platform: we + have seen all of these concepts before, and we are all + familiar with how these things work. + + What makes the Common Language Infrastructure development + platform interesting is that it is a good mix of technologies + that have been nicely integrated. + + The .NET development platform is essentially a new foundation + for program development that gives Microsoft a room to grow + for the coming years. + +** ECMA standards. + + Microsoft has submitted the + specifications of C#, the runtime, the metadata and the + other various bits of the .NET development platform to the + <a href="http://www.ecma.ch">ECMA</a> for standarization. + + You can get a copy of the specifications submitted to ECMA + from: <a href="http://www.dotnetexperts.com/ecma">http://www.dotnetexperts.com/ecma</a> + +** Mono: an Open Source Common Language Infrastructure implementation. + + Ximian has begun work on Mono, a project that aims to bring + the Common Language Infrastructure platform to free systems. + + When the GNU project was launched, they picked the best + operating system that was available out there, and they + began to clone it: Unix. + + The .NET development platform is a very rich, powerful, and + well designed platform that would help improve the free + software development platform. Just like the GNU project + began to clone Unix sixteen years ago, we will be cloning the + .NET development platform because it is a great platform to + build on. + +** What makes up Mono? + + There are various pieces that will make up Mono: + + <ul> + * A C# compiler. + + * The Virtual Execution System: that will have the + Just-in-Time compiler, garbage collector, loader, + threading engine. + + A byte code interpreter will be provided for quickly + porting Mono to new systems and debugging the JIT + purposes, but it is not intended to be the ideal + execution environment. + + * An implemenation of the .NET class library. + + * Visual development tools. + + * A CIL GCC frontend. + </ul> + +** Why use GNOME components? + + GNOME is an umbrella project that consists of infrastructural + components (GUI toolkit, XML libraries, CORBA implementation, + printing architecture, imaging system), a desktop environment, + and productivity applications. + + The GNOME infrastructural components can be used to quickly + implement various pieces of the class libraries without reinventing + the wheel, and since all those components are licensed under + the terms of the GNU LGPL it is a perfect fit. + + Libart will be used to implement the Drawing.2D API; Gtk+ and + the GNOME libraries will be used to implement the WinForms + API and of course Glib and libxml will be used in various + places.
\ No newline at end of file diff --git a/web/release-notes/mono-0.3 b/web/release-notes/mono-0.3 new file mode 100644 index 00000000000..4976037b957 --- /dev/null +++ b/web/release-notes/mono-0.3 @@ -0,0 +1,46 @@ +To: mono-list@ximian.com, mono-announce-list@ximian.com +Subject: July 12 snapshots. +FCC: ~/Mail/outbox.txt +X-Windows: Sometimes you fill a vacuum and it still sucks. +--text follows this line-- + +Hey! + + July 12 snapshots of class libraries, the compiler and the mono +runtime are available. + +New on this release: + + * Runtime (module: mono) + + The beginning of a simple interpreter that Paolo started + workign on (can run really simple .NET programs). + + Disassembler copes with more elements of the binary format and + more tokens are decoded. Paolo is working now on moving some + of these to the metadata library. + + More tables are dumped. + + * Class libraries (module: mcs/class) + + Many new more classes are in from Joe, Vladimir, Jeff, Sean + and yours truly. + + Sean fixed the build process, and it is now possible to + compile with a single command the assemblies. We will be + revisiting this mechanism in the future to compile per-OS + assemblies (ie, Unix, Windows, MacOS, etc). + + * Compiler (module mcs/mcs) + + Not much done this week, just a few fixes here and there, and + more work to make it easy to compiler. + + * Documentation (module: mono/doc) + + All the changes to the web site are there for your browsing + pleasure. We still need to integrate the status system in + there. + +Miguel. diff --git a/web/release-notes/mono-0.4 b/web/release-notes/mono-0.4 new file mode 100644 index 00000000000..1d7e1cea5f1 --- /dev/null +++ b/web/release-notes/mono-0.4 @@ -0,0 +1,43 @@ +To: mono-list@ximian.com +Subject: Sunday snapshot available. +Gcc: mail.2001-07 +--text follows this line-- + +Hey guys, + + I promise I will not be doing these so often once we have the CVS +server up. In the meantime: + + * MCS + + Sean got the classes to compile in a single go. You + will need CygWin (www.cygwin.org) to compile though + (GNU make and stuff is required). + + System.Xml.XmlReader contribution from Jason + (WOOHHOO!!). It also contains a nice test-suite for + his functions, and in his new code bit, his + implementation is faster than Microsoft's + + We now ship `jay' as part of the distribution to allow + you to compile the compiler with the same `make' + command. Small fixes to the parser as well were + introduced. + + * Mono 0.4 + + Paolo's interpreter supports call instructions and has + the test suite program that he posted about. + + + All documentation ships now in the mono-0.4.tar.gz + +Notes: + + As usual, MCS is targeted to be compiled on a Windows machine + (you will need Cygwin). + + Mono is targeted to be compiled on a Unix machine or a Windows + machine running Cygwin. + +Miguel.
\ No newline at end of file diff --git a/web/resources b/web/resources new file mode 100644 index 00000000000..7ef28be7c12 --- /dev/null +++ b/web/resources @@ -0,0 +1,109 @@ + +* Resources + + There are a number of resources available for those of you who + want to contribute to the Mono project. Here are a few links. + + If you want to send suggestions for links, address them to <a + mailto="web-mono@ximian.com">web-mono@ximian.com</a>. + +** ECMA Documentation. + + You can get the documentation for the ECMA specs from a number of sites: + <ul> + * <a href="http://msdn.microsoft.com/net/ecma">At MSDN</a> + * <a href="http://www.dotnetexperts.com">Dot Net Experts</a> + * <a href="http://developer.intel.com/software/idap/ecma">Intel</a> + * <a href="http://lightning.csse.monash.edu.au/.net/CLI">Monash University</a> + </ul> + + These contain specifications for the assembler, the metadata, + byte codes supported by the CLI virtual machine, the C# + language and the core class libraries. + + For details on the .NET class libraries, you can + visit the Microsoft's Developer Network: + + <ul> + * <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/cpref_start.asp">.NET Framework Class Library</a> + </ul> + + You can also get this information if you install the Beta2 + release of the .NET Framework. + +<a name="mailing"> +** Mailing Lists + + There are a number of mailing lists for Mono + + <ul> + + * <b><a + href="http://mail.ximian.com/mailman/listinfo/mono-list">mono-list:</a></b> + The general Mono discussion list. + * <b><a + href="http://mail.ximian.com/mailman/listinfo/mono-announce-list">mono-announce-list:</a></b> + Announcements of Mono developments. + * <b><a + href="http://mail.ximian.com/mailman/listinfo/mono-docs-list">mono-docs-list:</a></b> + Discussion on the documentation of Mono. + * <b><a + href="http://discuss.develop.com/dotnet.html">Dotnet mailing + list at Develop.com:</a></b> The guys at Develop Mentor run + this general purpose mailing list. + </ul> + +** Discussion Groups. + + <ul> + + * <a href="http://www.oreillynet.com">O'Reilly + Network</a> has a <a + href="http://www.oreillynet.com/dotnet">section devoted to + .NET</a> + * <a + href="http://msdn.microsoft.com/newsgroups">MSDN</a> also + lists various newsgroups related to .NET</ul> + </ul> + +** Other .NET related projects + + There are a number of related projects to Mono: + + <ul> + * <a + href="http://www.icsharpcode.net/OpenSource/SD/default.asp">Sharp + Develop:</a> an IDE for the C# language written in C#. + + * <a + href="http://www.southern-storm.com.au/portable_net.html">Portable.NET:</a> + + * <a href="http://nunit.sourceforge.net">NUnit:</a> A + testing framework for .NET classes. + + * <a href="http://www.kaffe.org">Kaffe:</a> A popular + Free Software JIT engine for Java. + + * <a href="http://www.intel.com/research/mrl/orp">ORP:</a> A research +JIT/VM/GC system from Intel. + </ul> + +** GNOME Documentation + + Documnetation on GNOME, and the GNOME APIs is available from + the <a href="http://developer.gnome.org">developer</a> site at + GNOME: + + <ul> + * <a href="http://developer.gnome.org/doc/API/">GNOME + API documentation</a> + + * <a href="http://developer.gnome.org/doc/books">GNOME + Online books</a> + + * <A + href="http://developer.gnome.org/arch/">Architecture Overview</a> + </ul> + + +
\ No newline at end of file diff --git a/web/resources-pending b/web/resources-pending new file mode 100644 index 00000000000..fd9b9073d64 --- /dev/null +++ b/web/resources-pending @@ -0,0 +1,30 @@ +** MacOS Documentation + +** Assembly Language Manuals online + Intel + MIPS + SPARC + +** Microsoft + msdn.microsoft.com/net + Research.microsoft.com + +** Related Technologies + + <ul> + + * The CLI allows people to create Web Services using the SOAP + protocol. SOAP is based on XML, XML schemas an the HTTP + protocol. + <ul> + * XML specification. + * XML Namespaces. + * XML Schemas. + * SOAP Specification. + </ul> + </ul> + +** Compiler Information + GCC + GCC Sample front-end tutorial + diff --git a/web/roadmap b/web/roadmap new file mode 100644 index 00000000000..6cdfa1366a8 --- /dev/null +++ b/web/roadmap @@ -0,0 +1,12 @@ +* Roadmap + + We are working on the following three projects at Ximian: + + The C# Compiler (mcs/mcs) + + A .NET compatible Class Library (mcs/class) + + The JIT/interpreter (mono) + + +
\ No newline at end of file diff --git a/web/runtime b/web/runtime new file mode 100644 index 00000000000..82bc0a74fa8 --- /dev/null +++ b/web/runtime @@ -0,0 +1,133 @@ + The MonoNet runtime + + The MonoNet runtime will implement the JIT engine (and a byte + code interpreter for quickly porting to new systems), the + class loader, the garbage collector, threading system and + metadata access libraries. + + Currently the runtime contains the beginning of an image + loader and metadata access entry points. Since Beta2 has been + now released, it is possible to resume work using the ECMA + specs and testing with Beta2-generated executables. + + The runtime core will be implemented in C, in a library + "libMonoVES.so". + +** Executing MSIL/CIL images + + The code will load an executable and map the references to + external assemblies to our own version of the assemblies on + GNU/Linux. + + Our roadmap looks like this, this has been updated as of + <b>Jul 15, 2001</b>: + + <ul> + + * Milestone 1: Fully read and parse all CIL byte-codes + and metadata tokens (ie, a disassembler). + + * Milestone 2: Complete an interpreter for CIL byte + codes. This interpreter can be used temporarly to + run CIL byte code on a system where no JIT is + available. + + * Milestone 3: Define an <i>lburg</i> instruction + selector for the JITer for Intel. Although slower + at JITing than a streaming JITer, it generates + better code. The same grammar can later be used for + the stream jitter. + + * Milestone 4: Implement JITer. + + * Milestone 5: Port of the JITer to non IA32 systems. + </ul> + + A setup similar to the Kaffe JIT engine can be used to + layout the code to support non-IA32 architectures. Our work + will be focused on getting a IA32 version running first. + + The JIT engine should work on Linux and Win32, although you + will need to install the CygWin32 development tools to get a + Unix-like compilation environment. + +** JIT Engine (<b>updated, Jul 14th, 2001</b>) + + We will be using a code-generator generator approach for our + JITer. Given the properties of CIL byte codes, we can take + full advantage of a real instruction selector for our code + generator. + + There are a couple of books that deal with this technique: "A + Retargetable C Compiler" and "Advanced Compiler Design and + Implementation" are good references. You can also get a + technical description of <a + href="http://research.microsoft.com/copyright/accept.asp?path=http://www.research.microsoft.com/~drh/pubs/iburg.pdf&pub=ACM">lbrug</a> + + Previously we had looked at a number of JIT engines and tools, + but they would not take full advantage of the CIL properties: + + <ul> + * <a + href="http://www.intel.com/research/mrl/orp/">ORP</a> + + * <a + href="http://www.gnu.org/software/lightning/">GNU + Lightning</a> + + * href="http://www.eecs.harvard.edu/~nr/toolkit/">NJ Machine + Toolkit</a>.). + + * VCODE. + </ul> + +** Garbage Collection + + We have decided to implement a generational tracing garbage + collector, which is very similar to the one being used by + .NET. For an introduction to the garbage collection system + used by Microsoft's CLR implementation, you can read this book + on <a + href="http://www.amazon.com/exec/obidos/ASIN/0471941484/o/qid=992556433/sr=2-1/ref=aps_sr_b_1_1/103-5866388-0492603">Garbage + Collection.</a> + + Although using a conservative garbage collector like Bohem's + would work, all the type information is available at runtime, + so we can actually implement a better collector than a + conservative collector. + + <ul> + * Garbage collection list and FAQ:<br> + <a href="http://www.iecc.com/gclist/">http://www.iecc.com/gclist/</a> + + * The Microsoft .NET Garbage Collection Implementation:<br> + <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI.asp</a> + <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI.asp</a> + </ul> + +** Useful links + + Paolo Molaro found a few interesting links: + + <ul> + + * On compilation of stack-based languages:<br> + <a href="http://www.complang.tuwien.ac.at/projects/rafts.html"> + http://www.complang.tuwien.ac.at/projects/rafts.html</a> + + * A paper on fast JIT compilation of a stack-based language:<br> + <a href="http://www.research.microsoft.com/~cwfraser/pldi99codegen.pdf"> + http://www.research.microsoft.com/~cwfraser/pldi99codegen.pdf</a> + + * Vmgen generates much of the code for efficient virtual machine (VM) + interpreters from simple descriptions of the VM instructions:<br> + <a href="http://www.complang.tuwien.ac.at/anton/vmgen/"> + http://www.complang.tuwien.ac.at/anton/vmgen</a> + </ul> + +** PInvoke + + PInvoke will be supported, and will be used to wrap Unix API + calls, these in turn are required for reusing some of the + GNOME libraries that will reduce the work we have to do to + deliver a complete class library. diff --git a/web/status b/web/status new file mode 100644 index 00000000000..274fb3a24f6 --- /dev/null +++ b/web/status @@ -0,0 +1,44 @@ +* Project Status + + + Pieces of Mono that have been implemented: + + <ul> + * C# compiler: The C# parser can now generate parse + trees. Next up: semantic analysis, compiler lever optimizations + and code generation. + + * Metadata library: Can currently parse and load + information from .NET modules (executables and DLL + files). It has a few bugs outstanding (table + dimension computation is incorrect). + + Parsing of Exception tables is missing. + + It lacks Token to (Table, Index) mapping, but this + should be trivial to write. + + * Disassembler: Can disassemble .NET modules. Still + lacking exception handling as well as useful debugging + tools (hex dumping, token dumping). + + * Class Libraries: Only a few classes have been + implemented. + </ul> + + Tasks on the critical path: + + <ul> + * Method and Field resolution. + + * Bytecode interpreter: Not implemented yet. + + * Simple JIT: Not implemented yet. + + * Garbage collection engine. + </ul> + + + + + diff --git a/web/team b/web/team new file mode 100644 index 00000000000..eff7bc9d3d5 --- /dev/null +++ b/web/team @@ -0,0 +1,2 @@ +* The MonoNet Team + diff --git a/web/testing b/web/testing new file mode 100644 index 00000000000..febabf6550e --- /dev/null +++ b/web/testing @@ -0,0 +1,21 @@ +* Testing + + All classes in Mono libraries should have comprehensive unit test + suites to go with them. Unit testing is a software engineering + methodology that makes it easier to build correct code. Every + method in every class should have a set of tests to verify + that they work correctly. Mono also needs a testing framework + to make it easy to write and run lots of tests. + + Try <a href="http://nunit.sourceforge.net">NUnit</a> + + Why do unit testing? It becomes simple to run automated tests + for the whole library. Unit tests are a safety net - you can + change part of the code and verify that you haven't broken + anything. Ideally, tests are written before the actual library + code itself. And every time a bug is discovered, a test should + be written to demonstrate the bug and its fix. Then, if + you ever reintroduce the bug, you will know immediately. For + more info, read <a + href="http://nunit.sourceforge.net/doc/testinfected/testing.html"> + JUnit Test Infected: Programmers Love Writing Tests</a>. diff --git a/web/thanks b/web/thanks new file mode 100644 index 00000000000..5f2df36f9cd --- /dev/null +++ b/web/thanks @@ -0,0 +1,6 @@ +* Thanks + + We would like to thank Tim O'Reilly, Brian Jepson and Nathan + Torkington for their help. + + Dave Winer for provided interesting comments and a to read. diff --git a/web/todo b/web/todo new file mode 100644 index 00000000000..abae8cdfb40 --- /dev/null +++ b/web/todo @@ -0,0 +1 @@ +Discuss with write new JIT
\ No newline at end of file diff --git a/web/tools b/web/tools new file mode 100644 index 00000000000..1a7065d58aa --- /dev/null +++ b/web/tools @@ -0,0 +1,25 @@ +* Tools + + We need a number of tools to make people productive using a + Mono-based solution. Some of these tools can be developed on + Windows before Mono is fully finished. + +** Debugger + + We will need a debugging API to debug CLI applications and + then a debugger component that can be used in an IDE + environment. + +** Integrated Development Environment + + There is already a project to create a C# development + environment (SharpDevelop). People could work with the + SharpDevelop hackers to produce a unified development environment. + +** Help Browser + + We need a good help browser that can be used to browse all the + Mono documentation. + + + diff --git a/web/web/.cvsignore b/web/web/.cvsignore new file mode 100644 index 00000000000..a023a6f9c7c --- /dev/null +++ b/web/web/.cvsignore @@ -0,0 +1,2 @@ +*.src +*.html diff --git a/web/web/commands b/web/web/commands new file mode 100644 index 00000000000..4184a72fecb --- /dev/null +++ b/web/web/commands @@ -0,0 +1,17 @@ +0,Home,index.html,index.src +1,FAQ,faq.html,faq.src +0,Mono,rationale.html,rationale.src +1,Runtime,runtime.html,runtime.src +1,Classes,class-library.html,class-library.src +2,Class Status,class-status.html,class-status.src +1,C# Compiler,c-sharp.html,c-sharp.src +1,Status,status.html,status.src +0,Contributing,contributing.html,contributing.src +1,Documentation,documentation.html,documentation.src +1,Test Suite,testing.html,testing.src +1,Tools,tools.html,tools.src +0,Download,download.html,download.src +0,Resources,resources.html,resources.src +1,Ideas,ideas.html,ideas.src +1,Passport,passport.html,passport.src +0,Contact,contact.html,contact.src diff --git a/web/web/htmlify b/web/web/htmlify new file mode 100644 index 00000000000..d0e163eaab5 --- /dev/null +++ b/web/web/htmlify @@ -0,0 +1,24 @@ +#!/usr/bin/perl +$q = 1; + +while (<>){ + chop; + if (/^\* (.*)$/){ + print "<h1>$1</h1>\n"; + } elsif (/^\*\* (.*)$/) { + print "<h2>$1</h2>\n"; + } elsif (/^\*\*\* (.*)$/) { + print "<h3>$1</h3>\n"; + } elsif (/^$/) { + print "<p>\n"; + } elsif (/^\t\t\* (.*)$/) { + print "<li>$1\n"; + } elsif (/^Q: (.*)$/){ + print "<p><a name=\"q$q\"><b>Question $q:</b> $1\n"; + $q++; + } elsif (/^A: (.*)$/){ + print "$1\n"; + } else { + print "$_\n"; + } +} diff --git a/web/web/images/bgsquares.gif b/web/web/images/bgsquares.gif Binary files differnew file mode 100644 index 00000000000..864bcd44038 --- /dev/null +++ b/web/web/images/bgsquares.gif diff --git a/web/web/images/bgsquares.png b/web/web/images/bgsquares.png Binary files differnew file mode 100644 index 00000000000..54de2ad1e6d --- /dev/null +++ b/web/web/images/bgsquares.png diff --git a/web/web/images/bgsquares.xcf.gz b/web/web/images/bgsquares.xcf.gz Binary files differnew file mode 100644 index 00000000000..200b5805615 --- /dev/null +++ b/web/web/images/bgsquares.xcf.gz diff --git a/web/web/images/mono.gif b/web/web/images/mono.gif Binary files differnew file mode 100644 index 00000000000..5ce7a218ac7 --- /dev/null +++ b/web/web/images/mono.gif diff --git a/web/web/images/mono.png b/web/web/images/mono.png Binary files differnew file mode 100644 index 00000000000..a19e38acedd --- /dev/null +++ b/web/web/images/mono.png diff --git a/web/web/images/pixel.gif b/web/web/images/pixel.gif Binary files differnew file mode 100644 index 00000000000..a4f37d7e02e --- /dev/null +++ b/web/web/images/pixel.gif diff --git a/web/web/images/pixel.png b/web/web/images/pixel.png Binary files differnew file mode 100644 index 00000000000..d8f33a2a3e4 --- /dev/null +++ b/web/web/images/pixel.png diff --git a/web/web/makefile b/web/web/makefile new file mode 100644 index 00000000000..1e549a40c3a --- /dev/null +++ b/web/web/makefile @@ -0,0 +1,39 @@ +SOURCES= \ + ../contributing \ + ../class-library \ + ../class-status \ + ../contact \ + ../c-sharp \ + ../documentation \ + ../download \ + ../faq \ + ../gcc-frontend \ + ../index \ + ../ideas \ + ../passport \ + ../rationale \ + ../resources \ + ../roadmap \ + ../runtime \ + ../status \ + ../testing \ + ../tools + +all: + -mkdir site + for i in $(SOURCES); do \ + perl htmlify $$i > `basename $$i`.src; \ + done; + + perl process.pl commands template.html.in . + +clean: + for i in $(SOURCES); do \ + rm -f `basename $$i`.src `basename $$i`.html; \ + done; + +push: + scp *.html www@www.ximian.com:/web/cvsmodules/mono + +push2: + scp *.html primates:public_html/xxx diff --git a/web/web/process.pl b/web/web/process.pl new file mode 100755 index 00000000000..157ae9bb08f --- /dev/null +++ b/web/web/process.pl @@ -0,0 +1,73 @@ +#!/usr/bin/perl +# +# Author: +# Sean MacIsaac +# + +use strict; + +my $full_expand = 1; +my @template; +my $n; + +if ($#ARGV != 2) { + print "process.pl command_file template_file directory_prefix\n"; + exit (); +} + +my $menu = ""; + +open COMMANDS, $ARGV[0] || die "Can not open $ARGV[0]"; +while (<COMMANDS>) { + chop; + my @command = split /,/; + if ($command[0] != -1) { + $menu .= "\t\t"; + if ($command[0] == 0){ + $menu .= "<tr><td valign=\"top\" class=\"navi\"><a class=\"navi\""; + } else { + $menu .= "<tr><td valign=\"top\" class=\"subnavi\">  <a class=\"subnavi\""; + } + $menu .= "HREF=\"$command[2]\">$command[1]</A></td></tr>\n\n"; + } +} +close COMMANDS; + +open TEMPLATE, $ARGV[1] || die "Can not open $ARGV[1]"; +while (<TEMPLATE>) { + push @template, $_; +} +close TEMPLATE; + +open COMMANDS, $ARGV[0] || die "Can not open $ARGV[0]"; +while (<COMMANDS>) { + chop; + my @command = split /,/; + + $n = $ARGV[2] . "/" . $command[2]; + open OUTPUT, ">" . $n || die "Can not create $n"; + + my $content = ""; + open INPUT, $command[3] || die "Can not open $command[3]"; + while (<INPUT>) { + $content .= $_; + } + close INPUT; + + my $line; + my $temp; + my $tit; + my $title; + + $tit = $command[1]; + foreach $line (@template) { + $temp = $line; + $title = "$tit / Mono"; + $temp =~ s/#TITLE#/$title/; + $temp =~ s/#CONTENT#/$content/; + $temp =~ s/#MENU#/$menu/; + print OUTPUT $temp; + } + + close OUTPUT; +} diff --git a/web/web/template.html.in b/web/web/template.html.in new file mode 100644 index 00000000000..7b3e5986494 --- /dev/null +++ b/web/web/template.html.in @@ -0,0 +1,78 @@ +<html> +<head> +<title>#TITLE#</title> +<style type="text/css"> +<!-- + body { font-family: "trebuchet ms", lucida, verdana, helvetica; + background-image: url("images/bgsquares.gif"); + background-attachment: fixed; } + body, td, table { font-family: "trebuchet ms", lucida, verdana, helvetica; + font-size: 12px; } + + .navi { font-size: 14px; background: #444444; } + .subnavi { font-size: 12px; } + .footnote { font-size: 10px; color: #aaaaaa; } + + a.navi { color: #ffffff; text-decoration: none; font-weight: bold; } + a.navi:visited { color: #cccccc; } + a.navi:hover { color: #ee9900; text-decoration: underline; } + + a.subnavi { color: #ffffff; text-decoration: none; font-weight: bold; } + a.subnavi:visited { color: #cccccc; } + a.subnavi:hover { color: #ee9900; text-decoration: underline; } + +// --> +</style> +</head> +<body bgcolor="#555555" text="#000000"> + +<table cellpadding="0" cellspacing="0" border="0" width="100%"> + <tr> + <td><img src="images/pixel.gif"></td><!-- left border --> + <td colspan="4"> + <a href="/"><img src="images/mono.gif" border="0"></a></td> + <td><img src="images/pixel.gif"></td><!-- right border --> + </tr> + <tr> + <td><img src="images/pixel.gif" width="1" height="1"></td> + <td colspan="3" bgcolor="black"><img src="images/pixel.gif" height="2"></td> + <td bgcolor="black"><img src="images/pixel.gif" width="1"></td> + <td><img src="images/pixel.gif"></td> + </tr> + <tr> + <td width="100"><img src="images/pixel.gif"></td> + <td valign="top"> + <table cellpadding="2" valign="top" cellspacing="0" border="0"> + #MENU# + </table> + </td> + <td bgcolor="black" width="1"><img src="images/pixel.gif" width="1"></td> + <td bgcolor="white"> + <table cellpadding="16"> + <tr><td> + #CONTENT# + </td></tr> + </table> + </td> + <td bgcolor="black"><img src="images/pixel.gif" width="1"></td> + <td width="100"><img src="images/pixel.gif"></td> + </tr> + <tr> + <td colspan="2"> + <img src="images/pixel.gif"></td> + <td colspan="2" bgcolor="black"><img src="images/pixel.gif" height="1"></td> + <td bgcolor="black"><img src="images/pixel.gif" width="1"></td> + <td><img src="images/pixel.gif"></td> + </tr> + + <td colspan="2"></td> + <td colspan="2" align="center"> + <a class="footnote" href="mailto: webmaster@go-mono.com">webmaster@go-mono.com</a> + </td> + <td colspan="2"></td> + </tr> +</tr> +</table> + +</body> +</html> |