Need some advice on hacking egcs...
Dream Machine
dream@quiknet.com
Sat Jan 3 15:14:00 GMT 1998
Hi All!
I'm currently working on a C++Builder-like tool for X/Linux (hey,
Borland hasn't expressed an interest in it, so what the hell. :-), for
which I would like to use egcs as the backend. Actually, what I'm
shooting for is source-level compatibility...
There are two basic things that are needed to implement this: A Visual
Component Library, which is essentially a set of C++ wrapper classes
for the Xlib and UNIX C functions, and several "extensions" that
Borland has made to the C++ language.
Re-creating the VCL under X is proving to be relatively simple. I was
planning to use a preprocessor of my own design to implement the
extensions to the language, but the deeper I get into the project, the
more I realize that I need to make these changes to the compiler
itself.
To illustrate, let's look at one of borland's extensions, namely the
"__property" access specifier(or storage class?). This specifier can
be applied to any data member and causes a private method to be called
whenever the data member is accessed:
class Foo {
private:
int FVal; // Holds the real value of Val
int GetVal() { return FVal };
int &SetVal(int NewValue) { FVal = NewValue; return &FVal};
public:
__property int Val = {read=GetVal, write=SetVal};
};
main()
{
Foo F;
int x;
x = F.Val; // Actually calls GetVal();
F.Val = 2; // Actually calls SetVal(2);
};
I thought of simply replacing each assignment and each reference to the
data values with the appropriate call, and that works fine for simple
data values, but when you throw more complex references into the
mix(like pointers, arrays of pointers, etc.), the words "nervous
breakdown" start to have real meaning. :(
Then I started to go through all of the various permutations of
overloaded assignment operators and reference methods(?), and eventually
came to the conclusion that there isn't any easy way to implement these
extensions in a preprocessor, without hacking the compiler itself (where
they should be anyway, from a design perspective). That way, all of the
pointer dereferencing is taken care of beforehand.
Since I'm a complete newcomer to the GCC/egcs code, I was hoping there
was either someone willing to give me a push in the right direction, or
someone interested in collaborating on the project as a whole.
Is there a document that describes in general how egcs works, i.e. what
data structures hold what, the basics of the tree structures, etc?
Eric
More information about the Gcc
mailing list