RE: RE: [abc-users] Using abc for instrumentation

From: Young G <lhasariverside@yahoo.com>
Date: Mon May 29 2006 - 22:13:19 BST

Hi Eric,

> I know it's very tedious indeed. Sorry about that - but that's how
> compilers work unfortunately. However, if you insert pure java code AST
> nodes only (i.e. no AspectJ AST nodes), then polyglot (which is part of
> abc) actually does have a means of generating an AST from a plaintext
> statement or expression. Look at the class polyglot.ext.jl.qq.QQ
> ("QuasiQuoter") please. You might want to download the polyglot source
> code from our website for reference. You can instantiate a QQ object
> with your abc extensioninfo and then you can invoke methods like "Stmt
> QQ.parseStmt(String)" etc. Note that this might be relatively slow,
> since polyglot actually has to parse the string it gives you, which is
> much more expensive than inserting the AST nodes directly. But for a
> prototype that should be fine.
>
I think QQ is exactly what I'm looking for. It will save me a lot time.
Thanks!

> > Well, another workaround to the tediousness of constructing AST nodes
> > for inserted statements is rewriting source files while instrumenting.
>
> I am not sure what you mean. You mean by sort of textual find/replace?
> That would be very error prone and I don't think you can or even want to
> do that within a compiler.
>
> > Can you please advice me of if and how we can instruct abc to start
> > over the compilation process from my extension?
>
> Again, I don't really see what you mean here. But I think you should
> find the abovementioned hint helpful.
>
What I want to do is,
1. to insert a new pass into abc to inject instrumentation code (plain
statements) into original source files;
2. to abort abc's current compilation;
3. to instruct abc to start over a new compilation to compile the modified
source files into bytecode.
And what I'd like to know is how to abort and re-start abc's compilation
from an intermediate pass. If I still don't make myself clear, please
ignore it :) Your QQ hint will nicely solve my problem anyway.

I really appreciate your help,

Young

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Received on Mon May 29 22:13:25 2006

This archive was generated by hypermail 2.1.8 : Mon May 29 2006 - 23:50:07 BST