Cool. Per class customizable code rewriting. Great for extendable frameworks. Thierry Le 28 févr. 2015 16:18, "Marcus Denker" <marcus.denker@inria.fr> a écrit :
A simple AST-transformer plugin architecture for Opal...
-> subclass OCCompilerASTPlugin -> implement #transform e.g.
transform | rule | rule := RBParseTreeRewriter replaceLiteral: 42 with: 'meaning of life'. rule executeTree: ast. ^ast
The plugin can be activated *per class hierarchy* by overriding #compiler
compiler "the example plugin is active for this class" ^super compiler addPlugin: ASTPluginMeaningOfLife.
or of course for a single compilation:
(Smalltalk compiler addPlugin: ASTPluginMeaningOfLife) evaluate: '42'
For review here:
https://pharo.fogbugz.com/f/cases/15019/Compiler-AST-transformation-Plugins
Marcus