Re: Software Architecture/Design
James Milne <[email protected]> Wed, 16 Jun 2010 14:50:46 +0100
| Newsgroups | gmane.games.devel.sweng |
|---|---|
| Message-ID | <[email protected]> |
On 16 Jun 2010, at 14:40, James Milne wrote: > On 16 Jun 2010, at 13:58, Alen Ladavac wrote: >> James wrote at 6/16/2010: >>> I think this is becoming feasible with compilers like LLVM. GCC also has a plugin API now, which would give one the opportunity to insert a data emitter at the appropriate point in the compilation pipeline. >> >>> This data could then probably be linked into your final executable as an extra section, and read at runtime. Thus making it useful for GC (no more bugs introduced by forgetting to mark references), serialisation, runtime introspection, signals/slots systems, etc. >> >> Note that plain C++ declarations will be inadequate for most tasks like serialization, networking etc. You need extra tags to mark data that is not serialized, or various ways to relink and otherwise interpret some data differently. > > Certainly, I agree. > > It would be good if more compilers had support for arbitrary annotations along with an interface for emitting them. The trouble is that most compilers consider their code generator and debug info emitter as the only consumers of the code. Thus there is no infrastructure for user-defined annotations because there is nothing that could access them anyway > > This is changing though. > > One cool example of a GCC plugin is the DeHydra plugin written by the Mozilla guys to do static analysis: > > <https://developer.mozilla.org/en/Dehydra> > > It allows you to write JavaScript fragments which are executed by the GCC plugin at various points in the compilation process. One of the examples here shows it looking for user attributes on type declarations: > > <https://developer.mozilla.org/En/Dehydra/Using_Dehydra> > > One could imagine how this could be used to expose various pieces of metadata on types and fields which could be written into your own type database. The GCC 4.5 Plugin API docs describe how to register custom attributes. See section 23.6 of the GCC internals docs: <http://gcc.gnu.org/onlinedocs/gccint/Plugins.html> I'm not aware of whether LLVM/Clang provides an equivalent way to dynamically extend the compiler through a plugin. This would certainly be preferably to having to mod the compiler directly. James _______________________________________________ Sweng-Gamedev mailing list [email protected] http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnightryder.com