Summary: | 碩士 === 國立東華大學 === 資訊工程學系 === 100 === This thesis investigates in the effect of code motion transformation on the quality of code clones. In large scale computer programs, a considerable fraction of the source code is duplicate code, call as clones. When the clones are extracted into procedure calls, the non-duplicate statements in the code clones induce a considerable overhead. If we can reduce the overhead when the code clone is extracted into procedure calls, the quality of code clone can be enhanced. The semantics-preserving procedure extraction technique and the PDG-based clone detection allow difference in the detected clones. Komondoor and Hor-witz proposed the semantics-preserving procedure extraction technique, this technique not only can detect discontinuous clones but also can enhance the quality of code clones. The PDG-based clone detection also can detect dis-continuous clones, but PDG-based clone detection cannot detect contiguous clones. Higo and Kusumoto proposed their methods to enhance the PDG-based clone detection in 2009. In this thesis, we use the local independence transformation, the statement distribution of control structures, and code motion to enhance the quality of code clones. Yung and Lai developed “lo-cal independence transformation” to enhance the quality of code clones if the non-duplicate statement can be transformation into a new statement which can be moved out of the clone. However, there is a problem, when the non-duplicate statement is in loop, moving the statement out of the clone by local independence transformation may change the semantics of program. For this reason, Yung and I develop “statement distribution of control structures” to enhance the quality of code clones if the non-duplicate statement is in control structure(control structure means if , for , or while structure). Furthermore, we combine “local independence transformation” and “statement distribution of control structures” for enhancing more quality of code clones. We take some experiments to observe the effects: the effect of local independence transfor-mation, the effect of statement distribution of control structures, and the effect of combining local independence transformation and statement distribution of control structures. We compare these effects with K.H.(Komondoor and Hor-witz).
|