Hi Thomas,
On Sat, Feb 17, 2007 at 06:12:19PM +0100, Thomas PFEIFFER wrote:
> Thanks a lot David, METAAS is a very promising project and can be
> such useful !
Thanks :)
> Just a request, if I read corerctly the documentation, would it be
> possible to get the source block code of a method from a ASMEthod
> instance?
I need to add some example code to the docs, but yes, this is doable
with the new features added in this release...
ASMethod is a StatementContainer, which means you can do something like,
ASMethod meth = ...get a method from somewhere...
List content = meth.getStatementList();
for (Iterator i=content.iterator(); i.hasNext(); ) {
Statement stmt = (Statement)i.next();
if (stmt instanceof ExpressionStatement) {
ExpressionStatement exprStmt = (ExpressionStatement)stmt;
...do something with exprStmt...
} else if (stmt instanceof ForInStatement) {
ForInStatement forInStmt = (ForInStatement)stmt;
...do something with forInStmt...
} else ...etc...
...
}
}
Several of the subtypes of Statement also implement StatementContainer,
so you also explore the children of (for example) an IfStatement, using
code just like the above example.
(Note that the API still only allows appending of new statements to the
end of a code block; there are no insert or delete functions for complex
manipulation of existing code, yet.)
This API is quite new, so please let me know of any problems.
thanks!
dave
--
http://david.holroyd.me.uk/
_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org