| 1 | = Inline macro substitution = |
| 2 | |
| 3 | The inline macro substitution refactoring step substitutes a selected macro application with the corresponding macro body and takes care of necessary compensations. |
| 4 | |
| 5 | Inline macro application {{{?Add(A,A)}}}: |
| 6 | |
| 7 | {{{ |
| 8 | -module(inlmac). |
| 9 | -define(Add(A,B),A+B). |
| 10 | |
| 11 | double(A)-> ?Add(A,A). |
| 12 | }}} |
| 13 | |
| 14 | Macro inlined: |
| 15 | |
| 16 | {{{ |
| 17 | -module(inlmac). |
| 18 | -define(Add(A,B),A+B). |
| 19 | |
| 20 | double(A)->A+A. |
| 21 | }}} |
| 22 | |
| 23 | == Side conditions == |
| 24 | |
| 25 | * The selected macro must not contain stringification or another macro in its definition. |
| 26 | |
| 27 | * The selection must not be inside a macro definition. |
| 28 | |
| 29 | * If the selection is not specify a macro usage the transformation starts an interaction to let the user specify one. It gives a list with the possible macro usages. |
| 30 | |
| 31 | == Transformation steps and compensations == |
| 32 | |
| 33 | 1. All the side conditions must met. |
| 34 | |
| 35 | 2. The following must be gathered that are necessary to fully finish the transformation: |
| 36 | * Edges to be deleted: those between ‘subst’ and both its children and the macro definition; ones connecting all intermediate ‘token’ nodes with ‘subst’, the containing expression and the original lexical tokens; and the one between the ‘subst’ node and its arguments. |
| 37 | * Nodes to be deleted: those lexical children of the ‘subst’ nodes parameter child which do not participate in the final solution (commas), children of the ‘subst’ node, the ‘subst’ node itself and the intermediate ‘token’ nodes. |
| 38 | * Edges to be rewired: those edges that originally connected a nonshared lexical node created specifically for the given substitution. |
| 39 | * Nodes to be created: those nodes which must be cloned from the macro definition because they are shared between all usages. |