This is actually very interesting, and I was also looking to achieve something similar. However, I chose to do the things differently.<div><br><div>As C++ is statically typed, why bother with dynamic reflection, while you can achieve a more efficient, cleaner static reflection?</div>

<div>I rather thought of kind of preprocess phase that would add traits on classes containing their members, methods, etc... The reflection would be implemented by using these generated traits. We then could add a post reflection processed target that would simply prints the traits, thus allowing to have a standard C++ code buildable with any compiler.</div>

<div><br></div><div>struct Foo</div><div>{</div><div>  void f();</div><div>  int a;</div><div>};<br><br></div><div>The generated traits may look like (very roughly):</div><div><br></div><div>reflect_trait<Foo>::attribute::count</div>

<div>reflect_trait<Foo>::attribute<1>::type</div><div>reflect_trait<Foo>::attribute<1>::name</div><div>reflect_trait<Foo>::method<1>::type</div><div>reflect_trait<Foo>::method<1>::signature</div>

<div>reflect_trait<Foo>::method<1>::name</div><div>reflect_trait<Foo>::method<1>::param::count</div><div>etc..</div><div><br></div><div>Just my 2 cents</div><div><br><div class="gmail_quote">On Mon, Dec 13, 2010 at 2:49 PM, Russell Harmon <span dir="ltr"><<a href="mailto:russ@eatnumber1.com">russ@eatnumber1.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I'm looking to possibly add support for reflection to clang & llvm.<br>
I'm thinking it would work something like the following:<br>
<br>
- clang inserts reflection information into the compiled bitcode<br>
  - does debugging symbols provide enough information already?<br>
  - should this be a new symbol table, or an extension of the debugging symbols?<br>
- I write a c library which using the symbols from the compiled<br>
binary, allows you to do reflection<br>
  - A typeof() or similar builtin will be necessary<br>
- I'll need to eventually modify llvm's optimizer somehow so that it<br>
doesn't break the reflection information<br>
<br>
Thoughts?<br>
This is going to be my introduction to the llvm & clang code base, so<br>
any advice on where to start?<br>
<font color="#888888"><br>
-Russell Harmon<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Aurélien Vallée<br>+33 6 47 41 70 37<br>
</div></div>