Function Inlining as a Language Parametric Refactoring

Loek van der Gugten


Date: Wed, June 22, 2022
Time: 12:00
Room: LB 01.010 Snijderszaal (building 36) / Loek's Zoom Room
Note: This is a MSc thesis defense


Refactorings are program transformations that preserve the observable behavior of the program. The refactoring function inlining replaces a function call with the contents of the referenced function definition. To preserve the behavior, properties such as reference relations must be retained and language constructs like ‘return’ statements must be replaced. Implementing a behavior preserving refactoring is a time-consuming and error-prone task. In the past, such refactorings have only been implemented for one language at a time, thus they can not be reused in other languages.

This thesis presents a language parametric function inlining algorithm that can be applied to any language. The algorithm performs function inlining and checks the transformed program for static semantics errors and changes to reference relations that would cause a change to the behavior of the program, fixing them where possible. The required language parameters are an AST parser, a static semantics analyzer that can derive reference relations, and a set of language-specific functions that can perform language-specific tasks, for example identifying return statements. An implementation of the algorithm is provided in the language workbench Spoofax using the transformation language Stratego. It can be applied to all languages with an SDF3 defined grammar and a Statix semantics analyzer. The implementation is tested on C++, WebDSL and Tiger using unit tests.


Previous: |
Next: |