This week was fairly scattered, I ended up doing a little bit all
over. Work was mostly bug fixing, or in some cases just bashing up
against regressions all over. We never have quite enough testing or
quite enough time to look at little problems as they crop up. And of
course the test suite doesn’t include big things like Eclipse 3 that
stress many things at once.
I added a renaming feature to GDirect this week. Now it is pretty
easy to control the mapping of a Java method name to the underlying
native function name. There is an interface for renaming, and a
couple useful built-in renamers. So, for instance, now you can have a
Java-style method name like “setFocusOnClick” and have it call the C
Currently I’m thinking of wrapping object-oriented C APIs (e.g.,
gtk) by having these classes derive from a Pointer class that supplies
the implicit “this”. There are several plausible approaches, but this
one is simple and fairly easy to understand.
I had taken a small hiatus from gcjx, but I’ve been working on it
more lately. Mostly I’m working on lowering to the GCC tree
representation. Really that is largely there and I’m really doing
some cleanup work and writing some of the needed glue — building all
the right decls, hooking in to gcc’s command line processing, stuff
like that. None of this stuff compiles.
I’m planning to relicense gcjx to the LGPL. This will let me do
things like use it from ant via dlopen(). I’ll have to rewrite a few
little bits that come from the old gcj. The tree-lowering code will
remain GPL, since it links directly into gcc.
Once I get it actually able to compile a java program to trees
without crashing, I think I’ll try to get it into the gcc repository
on a branch. Currently I’m thinking most of gcjx would go in a new
top-level directory (like libcpp), with just the tree-lowering and
glue code in the gcc directory.
Writing a GCC front end
Once you understand trees (there are some intro manuals
around, a couple nice examples
– hint: don’t read gcj or g++, and as a last resort tree.def),
you might be wondering how to hook your front end to GCC. This part
was intimidating me a bit; I was afraid I’d have to dig through gcj to
figure it out.
I started doing this, but a simpler way is to read langhooks.h.
This provides a decent, though imperfect, overview of what a front is
either required to do or can easily override. It doesn’t mention
build_common_tree_nodes, and I’m sure other
stuff I have yet to figure out, but it is still pretty helpful.