This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: objc data structures
- From: Ziemowit Laski <zlaski at apple dot com>
- To: Geoffrey Keating <geoffk at apple dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 7 Oct 2004 12:03:41 -0700
- Subject: Re: objc data structures
- References: <F9407864-17ED-11D9-9787-0030657EA24A@apple.com> <A3D525C0-17F2-11D9-8D5E-000393673036@apple.com> <0D90E9FB-17F6-11D9-9787-0030657EA24A@apple.com> <D8E368A8-17F8-11D9-8D5E-000393673036@apple.com> <8A136761-1880-11D9-B3C4-0030657EA24A@apple.com> <E7B019D2-188B-11D9-90DD-000393673036@apple.com> <B91A3931-188E-11D9-B3C4-0030657EA24A@apple.com>
- What is actually being stored in these fields?
For now, just protocol annotations (e.g., 'NSObject <NCCopying,
NSArchiving> *').
So, it's one tree pointer?
That's all I need, since I can store them as a TREE_LIST (or some
other structure if need be).
OK. If you could have whatever data structure you wanted, would it
still be a tree pointer?
Hmm... TREE_LISTs are quite sufficient for this task, but we could also
use a different data structure if you think that would make more sense.
- How often is it used?
Very often. Protocols are used very heavily in AppKit and
Foundation, for example.
No, I mean "how often is it used in a compilation". As in, is it
used every time a field is referenced?
Protocols attach to types, not fields. Protocols are used in type
comparisons and when dispatching ObjC messages (so that the proper
method signature may be selected), but are not needed for things such
as codegen.
OK. So the data would be used each time a type is compared or when an
objc message is dispatched to an object.
Yes.
- Is it ever necessary to have this information as well as the
information that C or C++ stores in the lang_specific field?
No idea.
Could you please find out? This information is essential to the
design.
How do you suggest I do that? You're asking me to establish
constraints on the use of a local data structure by other front-ends.
Is it necessary in the current compilers, to which you have source?
Even if the "current compilers" were set in stone, I still fail to see
how you'd compute this predicate.
More generally, given what the current compilers have in the lang_type
structures, is it necessary to have both that data and the data that
objc needs?
Or, to phrase it another way, could we just decide that lang_type can
be a union that can point to either the data that objc needs or the
data that the C or C++ frontend needs?
You're asking me
(1) the exact conditions under which C or C++ might decide to store
lang_specific information in a type node; and
(2) the exact conditions under which ObjC/ObjC++ needs to store
lang_specific information (for now, protocols) in a type node; and
(3) whether (1) and (2) are guaranteed to be mutually exclusive.
The only one of these I could even _begin_ to answer is (2). Unless
you can present a methodology for computing (1), as well as ensuring
that _no_ future patch to the C or C++ front-ends alters (1) in ways
that violates (3), I posit that the C/C++ and ObjC/ObjC++ lang_specific
information must be treated as orthogonal.
--Zem