高级检索
    边奕心 王甜甜 苏小红 马培军. 一种语义保持的C克隆代码无定型过程提取方法[J]. 计算机研究与发展, 2013, 50(7): 1534-1541.
    引用本文: 边奕心 王甜甜 苏小红 马培军. 一种语义保持的C克隆代码无定型过程提取方法[J]. 计算机研究与发展, 2013, 50(7): 1534-1541.
    Bian Yixin, Wang Tiantian, Su Xiaohong, and Ma Peijun. A Semantics-Preserving Amorphous Procedure Extraction Method for C Clone Code[J]. Journal of Computer Research and Development, 2013, 50(7): 1534-1541.
    Citation: Bian Yixin, Wang Tiantian, Su Xiaohong, and Ma Peijun. A Semantics-Preserving Amorphous Procedure Extraction Method for C Clone Code[J]. Journal of Computer Research and Development, 2013, 50(7): 1534-1541.

    一种语义保持的C克隆代码无定型过程提取方法

    A Semantics-Preserving Amorphous Procedure Extraction Method for C Clone Code

    • 摘要: 克隆代码又被称为重复代码,是一种代码坏味.针对传统的保持语法结构不变的过程提取方法提取克隆代码时存在的对某些克隆代码无法直接提取的问题,提出一种新的语义保持的克隆代码无定型过程提取方法.该方法结合程序依赖图和抽象语法树对程序进行语义分析,取消了传统的保持语法结构不变的过程提取算法对语句结构一致性的约束,保留了语义一致性约束,从而解决了传统方法不易处理的连续但不能直接提取的克隆代码提取问题,降低了对未标记语句提升的需求,并且不需要对跳转语句进行特殊处理.实验结果表明该方法可以提取传统的保持语法结构不变的过程提取方法不能提取的克隆代码,提高了克隆代码过程提取的准确性和适用性.

       

      Abstract: Cloned code, also known as duplicated code, is among the bad “code smells”. Procedure extraction can be used to remove clones and make a software system more maintainable. When clone code is extracted out to form procedures, there are some disadvantages that some clone code fragments cannot be extracted directly with the previous syntax-preserving procedure extraction algorithm. To solve these problems, this paper proposes a new semantics-preserving amorphous procedure extraction algorithm. This approach analyzes the program semantic information with program dependence graph and abstract syntax tree. Its characteristic is not syntax-preserving but semantics-preserving, so it can deal with continuous clone code which can not be extracted directly by the traditional method and reduce the need for promoting the unmarked statements, and it need not handle existing jumps that cannot be addressed with the traditional procedure extraction method. The experimental results show that the method can extract the code clones which can't be extracted by the traditional method. It improves the accuracy and adaptability of procedure extraction. We conclude that the proposed algorithm can be a useful contribution to the toolboxes of software managers and developers in the future, which could help them improve code structure and reduce software maintenance and project costs.

       

    /

    返回文章
    返回