Download presentation
Presentation is loading. Please wait.
Published byJoanna Shelton Modified over 9 years ago
1
CS 614: Theory and Construction of Compilers Lecture 10 Fall 2003 Department of Computer Science University of Alabama Joel Jones
2
Lecture 10©2003 Joel Jones2 Overview Requirements for a refactoring tool Don Roberts and John Brant in Refactoring: Improving the Design of Existing Code by Martin Fowler Architecture of the smalltalk refactoring browser Don Roberts, Practical Analysis for Refactoring, University of Illinois, Department of Computer Science Ph.D. dissertation.
3
Lecture 10©2003 Joel Jones3 Technical Criteria for a Refactoring Tool Program database Must be able to search all of the code for a program Parse trees Refactorings are source-to-source translations, so parse tree must be fairly complete Accuracy Refactoring shouldn’t change behavior
4
Lecture 10©2003 Joel Jones4 Practical Criteria for a Refactoring Tool Speed Must be fast enough for programmer to use it Undo Allows more experimentation Is source code control system enough? Integrated with tools Otherwise, programmers won’t use it
5
Lecture 10©2003 Joel Jones5 The Transformation Framework Refactorings—base class, implements preconditions and performRefactoring Conditions—analyses that are shared by all refactorings Parser—preserves non-semantic information, recognizes pattern variables, uses Builder pattern
6
Lecture 10©2003 Joel Jones6 The Transformation Framework (cont.) Tree rewriter—performs matches (input: AST with potential named pattern variables and standard AST) and rewrites (input: two pattern ASTs with shared patterns variables and standard AST), uses Visitor pattern Formatter—uses Visitor over ASTs and BRFormatter class to produce source code following formatting guidelines Change objects—represent low-level changes to code, uses Command pattern to support undo
7
Lecture 10©2003 Joel Jones7 Reading Next Class Muchnick, chapter 4 through and including section 4.6
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.