With the enrichment of software resources,people began to study the reuse method of software code.There have been many forms of code reuse methods in history.In recent years,some people have proposed code reuse methods for reusing code relating to a specified function,and the code relating to a function is called an organ,the reuse of the code is called software transplantation.Some people have studied methods for automated software transplantation.Firstly,this paper analyzes the development of current automated software transplantation,and analyzes the problems and challenges in this field.To solve the problem of extracting organ,this paper proposes a method based on abstract syntax tree(AST)and program slicing technology.This method combines the advantage of abstract syntax tree and program slicing technology,can analyze the control dependence graph and data dependence graph of program,and finally extract organ comprehensively and accurately.This method includes three steps:(1)building program's AST;(2)transforming the AST and getting code in control dependence with organ;(3)slicing the program and getting code in data dependence with organ.Through the research on organ extraction methods in automated software transplantation,this paper proposes the framework of our method,and designs and implements the organ extraction system based on the framework.This paper conducts an experimental study on four open source software,and transplants four functions using our method,the experiment results reveals that our method has practical usage in automated software transplantation.Effective organ extraction method is vital to automated software transplantation,extracting organ comprehensively and accurately means that the software transplantation process is completed more than half.This paper studies the method of extracting organ,and proposes the method based on AST and program slicing.This method can extract organ comprehensively and accurately,and contributes to the research of organ extraction in automated software transplantation. |