期刊文献+

基于AST的克隆序列与克隆类识别 被引量:2

Detection of clone sequences and classes using AST
下载PDF
导出
摘要 为了减少代码冗余,改善程序结构,提出一种新的基于抽象语法的代码克隆识别方法,归纳出常见的代码克隆形式并给出相应的重构技术.用二叉树表示源程序的抽象语法(BAST),逐条判断各语句BAST子树的同构性,识别出相似的语句序列作为克隆序列;根据子树同构识别一元克隆类,然后通过克隆类的连接操作,逐步识别二元及任意元数的克隆类.实验分析了多个开源软件,识别出了其中的克隆序列以及克隆类,从中归纳出4种常见的代码克隆,其基本特征分别为:相同的程序点访问同类对象的不同属性、部分变量名不同、针对不同的数据类型实施相同的操作、修改克隆区域外定义的变量,并对这4种代码有效地实施了重构. In order to reduce code redundancy and improve program structure, a novel approach based on abstract syntax is presented to detect clone code, and several kinds of code clones that occur frequently in programs are outlined. Corresponding refactoring techniques are also presented. Abstract syntax of the analyzed program is represented as binary tree (BAST). Isomorphism of sub- BAST is judged statement by statement. Similar statement sequences are detected as clone sequences. 1 -tuple clone classes are detected according to isomorphism of sub-BAST. By the join operation of clone classes 2-tuple and other clone classes can be achieved stage by stage. The experi- ment analyzes several open source projects, and clone sequences and classes are detected. Four kinds of code clones are induced from the detection result which have the following characters respectively : accessing different properties of the same class's objects at the same program point, modifying some variable names, applying the same operation to different types, modifying variables defined outside the clone area. All the four kinds of clone codes are refactored successfully.
出处 《东南大学学报(自然科学版)》 EI CAS CSCD 北大核心 2008年第2期228-232,共5页 Journal of Southeast University:Natural Science Edition
基金 国家杰出青年科学基金资助项目(60425206) 国家自然科学基金资助项目(60503020) 江苏省自然科学基金资助项目(BK2006094) 江苏省高技术研究资助项目(BG2005032).
关键词 代码克隆 克隆识别 克隆类 软件维护 code clone clone detection clone class software maintenance
  • 相关文献

参考文献15

  • 1Fowler M. Refactoring : improving the design of existing code [M]. New York: Addison Wesley, 1999.
  • 2Kamiya T, Kusumoto S, Inoue K. CCFinder: a multilinguistic token-based code clone detection system for large scale source code [J]. IEEE Transaction on Software Lngineering, 2002,28 ( 7 ) : 654 - 670.
  • 3Mann Z A. Three public enemies: cut, copy, and paste [J]. IEEE Computer, 2006, 39(7) : 31 -35.
  • 4Baxter I D, Yahin A, Moura L, et al. Clone detection using abstract syntax trees [C ]//IEEE International Conference on Software Maintenance. Bethesda, USA, 1998 : 368 - 377.
  • 5Bellon S. Detection of software clones [EB/OL ]. (2004-10-1) [ 2007-09-21 ]. http ://www. bauhaus-stuttga rt. de/clones/.
  • 6Krinke J. Identifying similar code with program dependence graphs [C]//The 8th Working Conference on Reverse Engineering. Stuttgart, Germany, 2001: 301- 309.
  • 7Komondoor R V. Automated duplicated-code detection and procedure extraction[ D ]. USA: University of Wisconsin-Madison, 2003.
  • 8Monden A, Nakae D, Kamiya T, et al. Software quality analysis by code clones in industrial legacy software [C ]//The 8th IEEE International Software Metrics Symposium. Ottawa, Canada, 2002 : 87 - 94.
  • 9Greenan K. Method-level code clone detection on transformed abstract syntax trees using sequence matching algorithms [R]. Santa Cruz: University of California, 2005 : 1 - 17.
  • 10Tairas R, Gray J. Phoenix-based clone detection using suffix trees [C]//The 44th Annual Southeast Regional Conference. Melbourne, Florida, USA, 2006: 679-684.

同被引文献8

引证文献2

二级引证文献4

相关作者

内容加载中请稍等...

相关机构

内容加载中请稍等...

相关主题

内容加载中请稍等...

浏览历史

内容加载中请稍等...
;
使用帮助 返回顶部