[cfe-dev] ObjC AST cleanup...
Daniel Dunbar
daniel at zuster.org
Thu Dec 18 18:05:37 PST 2008
Hi Steve,
Sorry for the late review...
This sounds great Steve, this would simplify some code in the IRgen
for Objective-C as well.
One simple question, would it be better to call ObjCClassImplDecl
ObjCInterfaceImplDecl? The code is inconsistent with using "class" and
"interface" and I think we should clean this up.
Somewhat more complicated, how does this all relate to the current set
of Objective-C container objects we have right now?
Here is a brief taxonomy of the Objective-C container objects:
Currently there are five:
(1) ObjCInterfaceDecl
(2) ObjCCategoryDecl
(3) ObjCProtocolDecl
(4) ObjCImplementationDecl
(5) ObjCCategoryImplDecl
These container objects all act as containers for class and instance
methods with associated accessors (instmeth_*, classmeth_*).
ObjCCategoryImplDecl and ObjCImplementationDecl use a SmallVector for
the method arrays, the others just use a pointer to an array.
ObjCCategoryImplDecl and ObjCImplementationDecl don't have property
lists (classprop_*), the other three do.
My main question is could we make something even higher than an
ObjCImplDecl which implemented the "method container" abstraction? It
looks to me like this would be straightforward and would simplify the
code a lot.
Beyond that, it may also be worth having a common class for
implementing the "property container" abstraction.
This would yield the following hierarchy:
ObjCContainerDecl
\--> ObjCPropertyContainerDecl (FIXME: this is a horrible name)
\-->---> ObjCCategoryDecl
\-->---> ObjCInterfaceDecl
\-->---> ObjCProtocolDecl
\--> ObjCImplDecl
\-->---> ObjCCategoryImplDecl
\-->---> ObjCClassImplDecl
For simplicities sake, if we went this route it might make sense to
just merge ObjCPropertyContainerDecl into ObjCContainerDecl (even
though ObjCImplDecl wouldn't actually use the property list). We don't
expect to actually have many implementations in any given translation
unit so I think the simplicity in the class hierarchy might be a good
tradeoff for a little extra memory usage.
What do you think?
- Daniel
On Tue, Dec 2, 2008 at 11:41 AM, steve naroff <snaroff at apple.com> wrote:
> To folks that work with the ObjC AST's,
>
> I've recently written some annoying code that needs to deal
> (generically) with method definitions (attached to a class or category).
>
> As a result, I'd like to consider adding a new base class
> ObjCImplDecl, that will contain the methods and properties for a class
> or category.
>
> Here is the new class hierarchy I'm considering:
>
> class ObjCImplDecl : NamedDecl // new
> class ObjCClassImplDecl : ObjCImplDecl // previously
> 'ObjCImplementationDecl : NamedDecl'
> class ObjCCategoryImplDecl : ObjCImplDecl // previously
> 'ObjCCategoryImplDecl : NamedDecl'
>
> This will result in (a) less code, simplified classes. (b) allow us to
> operate on method definitions more generically. (c) Improved naming
> (ObjCImplementationDecl->ObjCClassImplDecl).
>
> Since changes to the AST's can effect everyone, I wanted to get some
> buy-in before I make this change.
>
> Anyone see any problems with this?
>
> Thanks,
>
> snaroff
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
More information about the cfe-dev
mailing list