Function Inlining as a Language Parametric Refactoring

Master Thesis (2022)
Author(s)

L.A. van der Gugten (TU Delft - Electrical Engineering, Mathematics and Computer Science)

Contributor(s)

L. Miljak – Mentor (TU Delft - Programming Languages)

C.B. Bach – Graduation committee member (TU Delft - Programming Languages)

A. Van Deursen – Graduation committee member (TU Delft - Software Technology)

Faculty
Electrical Engineering, Mathematics and Computer Science
Copyright
© 2022 Loek van der Gugten
More Info
expand_more
Publication Year
2022
Language
English
Copyright
© 2022 Loek van der Gugten
Graduation Date
22-06-2022
Awarding Institution
Delft University of Technology
Project
['Programming and Validating Software Restructurings (NWO MasCot project)']
Programme
['Computer Science']
Faculty
Electrical Engineering, Mathematics and Computer Science
Reuse Rights

Other than for strictly personal use, it is not permitted to download, forward or distribute the text or part of it, without the consent of the author(s) and/or copyright holder(s), unless the work is under an open content license such as Creative Commons.

Abstract

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 cannot 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.

Files

Final_version.pdf
(pdf | 0.699 Mb)
License info not available