Computer Engineering and Applications ›› 2018, Vol. 54 ›› Issue (6): 30-36.DOI: 10.3778/j.issn.1002-8331.1610-0151

Previous Articles     Next Articles

Research and application of refactoring algorithm of branch statements

ZHAO Huiqun, SUN Yu   

  1. College of Computer Science, North China University of Technology, Beijing 100144, China
  • Online:2018-03-15 Published:2018-04-03


赵会群,孙  雨   

  1. 北方工业大学 计算机学院,北京 100144

Abstract: Due to the multiple nested of conditional branch statements, logic structure of the code is not clear and the code is difficult to read, the efficiency of dividing basic block is reduced when generating basic path set. On this basis, a method is proposed for automatic code refactoring. It uses bottom-up analysis and reduction, following compiler syntax analysis method, can realize automatic adjustment to the nested if-else conditional statement, and is more clearer to the structure of code, the code will be more suitable for the tool of generating basic path set. This method improves the efficiency of the tool of generating basic path set. For the tool of generating basic path set based on the model algebraic, it improves the algorithm of generating model algebraic expressions, and can generate basic path set accurately. Finally, through the comparison of the experiment, it verifies the effectiveness of the refactoring and the improved algorithm.

Key words: multiple nested, automated refactoring, bottom-up analysis, reduction, model algebraic expression

摘要: 由于条件分支语句的多重嵌套,导致代码的逻辑结构不清晰,可读性差,降低了生成基本路径集时划分基本块的效率。据此,提出一种代码自动化重构方法,该方法运用编译原理中语法分析的自下而上分析方法和归约思想,能够对嵌套的if-else条件语句实现自动化调整,实现代码结构的清晰化,更适用于生成基本路径集的工具,该方法提高了生成基本路径集的效率。而对于基于模型代数的基本路径集生成工具,改进了生成模型代数表达式的算法,并且能够准确地生成基本路径集。最后通过实验对案例进行对比,验证了重构方法及改进算法的有效性。

关键词: 多重嵌套, 自动化重构, 自下而上分析, 归约, 模型代数表达式