ABSTRACT
Refactorings are behaviour-preserving program transformations, typically for improving the structure of existing code. A few of these transformations have been mechanised in interactive development environments. Many more refactorings have been proposed, and it would be desirable for programmers to script their own refactorings. Implementing such source-to-source transformations, however, is quite complex: even the most sophisticated development environments contain significant bugs in their refactoring tools.We present a domain-specific language for refactoring, named JunGL. It manipulates a graph representation of the program: all information about the program, including ASTs for its compilation units, variable binding, control flow and so on is represented in a uniform graph format. The language is a hybrid of a functional language (in the style of ML) and a logic query language (akin to Datalog). JunGL furthermore has a notion of demand-driven evaluation for constructing computed information in the graph, such as control flow edges. Borrowing from earlier work on the specification of compiler optimisations, JunGL uses so-called `path queries' to express dataflow properties.We motivate the design of JunGL via a number of non-trivial refactorings, and describe its implementation on the.NET platform.
References
- Andrew W. Appel. Modern Compiler Implementation in uppercaseML. Cambridge University Press, 1998.]] Google Scholar
Digital Library
- Uwe Assmann. OPTIMIX --- a tool for rewriting and optimizing programs. In H. Ehrig, G. Engels, H. J. Kreowski, and G. Rozenberg, editors, Handbook of Graph Grammars and Computing by Graph Transformation. Volume 2: Applications, Languages and Tools, pages 307--318. World Scientific, 1998.]] Google Scholar
Digital Library
- Ittai Balaban, Frank Tip, and Robert Fuhrer. Refactoring support for class library migration. In Proceedings of the 20th ACM conference on Object-Oriented Programming, Systems, Languages and Applications, pages 265--279, 2005.]] Google Scholar
Digital Library
- Peter Buneman, Mary Fernandez, and Dan Suciu. UnQL: A query language and algebra for semistructured data based on structural recursion. VLDB Journal, 9(1):76--110, 2000.]] Google Scholar
Digital Library
- Alan Donovan, Adam Kiezun, Matthew S. Tschantz, and Michael D. Ernst. Converting java programs to use generic libraries. In Proceedings of the 19th ACM conference on Object-Oriented Programming, Systems, Languages and Applications, pages 15--34, 2004.]] Google Scholar
Digital Library
- Stephen J. Drape, Oege de Moor, and Ganesh Sittampalam. Transforming the.NET intermediate language using path logic programming. In Principles and Practice of Declarative Programming, pages 133--144, 2002.]] Google Scholar
Digital Library
- Torbjörn Ekman and Görel Hedin. Rewritable reference attributed grammars. In Martin Odersky, editor, European Conference on Object-Oriented Programming, pages 144--169, 2004.]]Google Scholar
- Dawson R. Engler. Interface compilation: Steps toward compiling program interfaces as languages. IEEE Transactions on Software Engineering, 25(3):387--400, 1999.]] Google Scholar
Digital Library
- Ran Ettinger and Mathieu Verbaere. Untangling: a slice extraction refactoring. In Gail C. Murphy and Karl J. Lieberherr, editors, em Aspect-Oriented Software Development, pages 93--101, 2004.]] Google Scholar
Digital Library
- Ran Ettinger and Mathieu Verbaere. Refactoring bugs in Eclipse, IntelliJ IDEA and Visual Studio. http://progtools.comlab.ox.ac.uk/projects/refactoring/bugreports, 2005.]]Google Scholar
- Martin Fowler. Refactoring: Improving the Design of Existing Code. Addison Wesley, 1999.]] Google Scholar
Digital Library
- Martin Fowler. Refactoring home page. http://www.refactoring.com, 2005.]]Google Scholar
- Sam Z. Guyer and Calvin Lin. An annotation language for optimizing software libraries. In Second conference on Domain-Specific Languages, pages 39--52. USENIX, 1999.]] Google Scholar
Digital Library
- Elnar Hajiyev, Mathieu Verbaere, Oege de Moor, and Kris de Volder. Codequest with datalog. In OOPSLA Companion, 2005.]]Google Scholar
- Susan Horwitz and Thomas Reps. The use of program dependence graphs in software engineering. In International Conference on Software Engineering, pages 392--411, 1992.]] Google Scholar
Digital Library
- Neil D. Jones and Alan Mycroft. Stepwise development of operational and denotational semantics for prolog. In Symposium on Logic Programming, pages 281--288, 1984.]]Google Scholar
- Joshua Kerievsky. Refactoring to Patterns. Addison Wesley, 2005.]] Google Scholar
Digital Library
- Marion Klein, Jens Knoop, Dirk Koschützki, and Bernhard Steffen. DFA & OPT-METAFrame: a toolkit for program analysis and optimization. In Tools and Algorithms for the Construction and Analysis of Systems, volume 1055 of Lecture Notes in Computer Science, pages 418--421. Springer, 1996.]] Google Scholar
Digital Library
- David Lacey, Neil D. Jones, Eric Van Wyk, and Carl Christian Frederiksen. Proving correctness of compiler optimizations by temporal logic. In Proceedings of the 29th ACM symposium on Principles of Programming Languages, pages 283--294, 2002.]] Google Scholar
Digital Library
- David Lacey and Oege de Moor. Imperative program transformation by rewriting. In R. Wilhelm, editor, Proceedings of the 10th International Conference on Compiler Construction, volume 2027 of Lecture Notes in Computer Science, pages 52--68. Springer Verlag, 2001.]] Google Scholar
Digital Library
- Sorin Lerner, Todd Millstein, and Craig Chambers. Automatically proving the correctness of compiler optimizations. In Programming Language Design and Implementation, pages 220--231, 2003.]] Google Scholar
Digital Library
- Sorin Lerner, Todd Millstein, Erika Rice, and Craig Chambers. Automated soundness proofs for dataflow and analyses via local rules. In Proceedings of the 32nd ACM symposium on Principles of Programming Languages, pages 364--377, 2005.]] Google Scholar
Digital Library
- Ondrej Lhotak and Laurie Hendren. Jedd: A BDD-based relational extension of java. In Programming Language Design and Implementation, pages 158--169, 2004.]] Google Scholar
Digital Library
- Yanhong Annie Liu and Scott D. Stoller. Querying complex graphs. In P. Van Hentenryck, editor, Proceedings of the 8th International Symposium on Practical Aspects of Declarative Languages, pages 16--30, 2006.]] Google Scholar
Digital Library
- Michael Martin, Benjamin Livshits, and Monica S. Lam. Finding application errors and security flaws using PQL: a program query language. In Proceedings of the 20th ACM conference on Object-Oriented Programming, Systems, Languages and Applications, pages 365--383, 2005.]] Google Scholar
Digital Library
- Tom Mens, Serge Demeyer, and Dirk Janssens. Formalising behaviour preserving program transformations. In Graph Transformation, volume 2505 of Lecture Notes in Computer Science, pages 286--301, 2002.]] Google Scholar
Digital Library
- Tom Mens, Gabriele Taentzer, and Olga Runge. Detecting structural refactoring conflicts using critical pair analysis. Electronic Notes in Theoretical Computer Science, 127(3):113--128, 2005.]]Google Scholar
Digital Library
- Oege de Moor, David Lacey, and Eric Van Wyk. Universal regular path queries. Higher-order and symbolic computation, 16(1-2):15--35, 2003.]] Google Scholar
Digital Library
- Karina Olmos and Eelco Visser. Strategies for source-to-source constant propagation. In B. Gramlich and S. Lucas, editors, Workshop on Reduction Strategies in Rewriting and Programming, volume 70 of Electronic Notes in Theoretical Computer Science. Elsevier Science Publishers, May 2002.]]Google Scholar
Cross Ref
- William F. Opdyke. Refactoring Object-Oriented Frameworks. PhD thesis, University of Illinois at Urbana-Champaign, 1992.]] Google Scholar
Digital Library
- Donald F. Roberts. Practical Analysis for Refactoring. PhD thesis, University of Illinois at Urbana-Champaign, 1999.]] Google Scholar
Digital Library
- J. Alan Robinson and Ernest E. Sibert. LOGLISP: Motivation, design and implementation. In K. L. Clark and S. A. Tänlund, editors, Logic Programming, pages 299--313. Academic Press, 1982.]]Google Scholar
- Peter Sestoft and Henrik I. Hansen. C# Precisely. MIT Press, 2004.]] Google Scholar
Digital Library
- Ganesh Sittampalam, Oege de Moor, and Ken Friis Larsen. Incremental execution of transformation specifications. In Proceedings of the 31st ACM symposium on Principles of Programming Languages, pages 26--38, 2004.]] Google Scholar
Digital Library
- Don Syme. F# home page. http://research.microsoft.com/projects/ilx/fsharp.aspx, 2005.]]Google Scholar
- Frank Tip, Adam Kiezun, and Dirk Bäumer. Refactoring for generalization using type constraints. In Proceedings of the 18th ACM conference on Object-Oriented Programming, Systems, Languages and Applications, pages 13--26, 2003.]] Google Scholar
Digital Library
- Eelco Visser. Meta-programming with concrete object syntax. In Generative programming and component engineering, pages 299--315, 2002.]] Google Scholar
Digital Library
- Daniel von Dincklage and Amer Diwan. Converting java classes to use generics. In Proceedings of the 19th ACM conference on Object-Oriented Programming, Systems, Languages and Applications, pages 1--14, 2004.]] Google Scholar
Digital Library
- Mark Weiser. Program slicing. IEEE Transactions on Software Engineering, 10:352--357, 1984.]]Google Scholar
Digital Library
- Deborah Whitfield and Mary Lou Soffa. An approach for exploring code-improving transformations. ACM Transactions on Programming Languages and Systems, 19(6):1053--1084, 1997.]] Google Scholar
Digital Library
Index Terms
JunGL: a scripting language for refactoring





Comments