[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is this a sane idea?
G'day Brett!
On Tue, 24 Oct 2000, Brett Morgan wrote:
> I am, for various reasons, not all of which are classifiable sane :-),
> thinking about writing java code that generates classfiles, then loads
> those classes and runs them. (In passing, I am attempting to do some
> Genetic Algorithm stuff, and writing an interpreter on top of another
> interpreter sounded kind of silly.)
Well, I don't see any insanity yet. ;)
> So, first off, is programatically creating a grimple IR, and then
> using soot to create a class file from this IR, a sane approach to
> writing a mini-compiler? Is there some demo code some where of doing
> something like this somewhere?
We know how to parse three-address Jimple code. This is pretty
straightforward. However, this only allows you simple expressions, not
compound ones.
Grimp is the soot IR that contains aggregated expressions. Once you have
grimp, you can go to classfiles easily enough.
So you have two choices, one of which is saner than the other.
(1) [less sane] Write a grimp parser: at the moment we have a Jimple
parser, which handles three-address code. It would take some effort to
build a Grimp parser from this. I don't know how hard this would be.
(2) [more sane] Build your grimp directly. So, your Java program
generating code would create the Grimp objects on the fly. The skeleton
for this would be the createclass tutorial (mail me if you don't know
where that is), but you would need to add a lot more code, of course,
using a different IR.
I'd be happy to answer any further questions you may have.
pat