Hi Günter, Sean, have a look at Jejak (https://github.com/ThierryGoubier/Jejak), it does exactly what you describe: take a method, scan the ast, rewrite some of the nodes (i.e. inject new ast nodes), recompile the method... uninstall the modified method. Ask me if you have any question about it. (Now, there is the MetaLink framework in Pharo5 which is interesting as well). Regards, Thierry Le 08/09/2015 03:02, Sean P. DeNigris a écrit :
From Günter Khyo:
Günter Khyo wrote
Hello!
I want to replace particular nodes of an AST (such as Assignments or Self sends) with my own nodes. Is there an easy (high-level) way to do this without being familiar with the entire compiler infrastructure?
The problem I am having is that AST nodes maintain internal state such as parent links and, in the case of RBVariables, links to scopes and bindings. There might be many other dependencies I am missing and missing one of them can trigger exceptions with stack traces buried deep in the IR Code-Generator and visitor calls.
For example, if I want to replace an assignment such as
Morph>>position: aPoint
"box := self fullBounds."
with something like
"self assignAndNotifiyDependents: self fullBounds to: 'box'"
Btw: I know there is a rewrite tool, but I want to do it programmatically.
Thanks!
----- Cheers, Sean -- View this message in context: http://forum.world.st/Modifying-the-AST-of-a-method-tp4848709.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.