[Mono-list] About CSC and MCS
He HongFu
hfhe@stryon.com
Wed, 5 Nov 2003 8:34:48 +0000
Hi all:
=09
=09There is just a suggestion about optimizing the MCS.
=09
=09AFAIK, now the working flow of the current MCS as following:=
firstly use CSharpParser to parse all source file,building type=
tree, member token table, parsing all statement and expression=
then resolving the type tree, finally defining the types,=
emiting IL codes. Maybe I'm wrong about that.
=09And I get the working flow of CSC(Microsoft) when I parsing it.=
The flow as following:
=09CSC compiles all files with four phases:
=09
=09Phase 1. Handle preprocessor directives, build type tree for=
all files, and parse these type's member lexically and=
syntactically. I think the work of this phase is building a=
symbol table.
=09Phase 2. Semantically parse the members of all defined type,=
including type resolving. We can get type information from the=
symbol table built above
=09
=09Phase 3. Semantically parse the members of all defined type,=
such as method overload, Main entry defined, etc.
=09
=09Phase 4. Lexicallly, syntactically, Semantically parse the=
member body such as method, property, sevolve statements
expressions, I don't know whether .
=09
=09If errors occur in the one of the file in some phase, all file=
will do util the same phase work was finished.
=09
=09I have thought about the implementation of CSC for long time.=
Why it did as that? As well known, the author of the CSC is=
Anders Hejlsberg which is one of the best excellent programmer=
of compiler. I just get some tiny reasons. I think the primary=
advantage is that compiling multiple file and error handling.=
First, the work flow of CSC can save obvious memory usage When=
compiling multiple files. Second, if we have error in a file in=
some phase, we can stop the following phase work after parsing=
all files in the phase, and exit the compiler. And preprocessor=
directive can be proprocessing without any overloads.
Of course, the changes of MCS makes more overloads, and the=
structure of CSC maybe not as many advantages as I thought. I
hope Mono hacker can cosider it carefully. Or if want to optimize=
MCS, we can make a branch just for experiment.
Regardings!
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1He HongFu
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1hfhe@stryon.com
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A12003-11-04
______________________________________________