首页 | 本学科首页   官方微博 | 高级检索  
     

CCodeExtractor:一种针对C程序自动化的函数提取方法
引用本文:张其良,张昱,周坤. CCodeExtractor:一种针对C程序自动化的函数提取方法[J]. 计算机科学, 2017, 44(4): 16-20, 29
作者姓名:张其良  张昱  周坤
作者单位:中国科学技术大学计算机科学与技术学院 合肥230026,中国科学技术大学计算机科学与技术学院 合肥230026,中国科学技术大学计算机科学与技术学院 合肥230026
基金项目:本文受国家863高技术研究发展计划项目基金(2012AA010901),国家自然科学基金(61170018)资助
摘    要:随着程序规模和复杂性的增加,代码重构在改善软件质量、性能以及提高软件的扩展性和维护性等方面至关重要。目前的Eclipse中,C源代码重构工具的函数提取只能处理一些简单的代码,且处理过程需要人工参与,不能自动化处理。为此,提出一种C源代码级别自动化的函数提取方法(CCodeExtractor),它通过指定提取条件,在保证语义一致的前提下,将符合条件的代码片段自动分离成一个单独的函数,并将其放到新文件中,而原代码片段替换成了一个函数调用。为了验证CCodeExtractor的有效性,结合循环分析和优化在实际应用中的广泛应用,在LLVM上实现了一个提取循环的工具,将程序中满足条件的for循环封装成单独的函数。在实验中,使用该工具对6个不同规模的程序进行了测试并且对比了变换前后程序运行的结果。实验结果表明,CCodeExtractor代码提取方法在保证程序语义不变的前提下,适用于不同规模的程序。

关 键 词:C程序重构  程序变换  程序理解  代码提取  循环分析  LLVM
收稿时间:2015-11-30
修稿时间:2016-02-26

CCodeExtractor:Automatic Approach of Function Extraction for C Programs
ZHANG Qi-liang,ZHANG Yu and ZHOU Kun. CCodeExtractor:Automatic Approach of Function Extraction for C Programs[J]. Computer Science, 2017, 44(4): 16-20, 29
Authors:ZHANG Qi-liang  ZHANG Yu  ZHOU Kun
Affiliation:School of Computer Science and Technology,University of Science and Technology of China,Hefei 230026,China,School of Computer Science and Technology,University of Science and Technology of China,Hefei 230026,China and School of Computer Science and Technology,University of Science and Technology of China,Hefei 230026,China
Abstract:As program complexity increases,code refactoring plays an important role in improving quality and perfor-mance of software,and is also essential for improving the maintainability and extensibility of programs.Current code extraction approach for C code in Eclipse,can only deal with some simple code,and cannot refactor the code automatically.In this paper,we proposed a code extraction approach for C code,CCodeExtractor.It can extract the C code fragments that meet the specified conditions into new functions,and replace the fragments with these new functions calls automatically.The refactored code has the same program semantics as the original code.In order to verify the validity of CCodeExtractor,we implemented it in LLVM to extract some for statements in C programs into new functions since loop ana-lysis and optimization has been widely explored in recent years.Our experiments evaluated CCodeExtractor using six actual applications of different size,and compared the outcomes of the original and transformed programs.Experimental results show that CCodeExtractor can provide correct source-level transformation for programs of different size.
Keywords:C program refactoring  Program transformation  Program comprehension  Code extraction  Loop analysis  LLVM
点击此处可从《计算机科学》下载全文
设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号