Code Search Method Based on the Reachability Analysis of Petri Nets
-
摘要: 复用已有高质量源代码可提高软件开发效率及软件质量.当前,基于用户提供的输入输出对的匹配判断是代码语义搜索的主要方法之一,但该方法难以刻画完整代码行为,且仅能处理单输入类型.提出一种针对多种形式类型匹配的代码语义搜索方法.首先将代码集内各个代码片段中数据对象个数及类型的加工过程转换为Petri网模型;其次根据用户查询中蕴含的数据类型及个数、输出数据类型等约束来构造Petri网初始标识和目标标识;然后在Petri网中通过可达图及诱发网分析判断是否存在相应的可达路径,从而获得代码匹配依据.分析及实验表明,该方法能有效实现多种形式的输入输出类型匹配的代码搜索,且相对于传统类型匹配方法,能明显提高搜索准确度和效率.Abstract: Reusing existing high-quality source codes can improve efficiency of software development and quality of software. At present, code search based on inputoutput queries provided by users is one of the main approaches in the field of code semantic search, but existing approaches are difficult to describe the complete behavior of codes and can only handle a single input type. This paper proposes a code semantic search approach based on the reachability analysis of Petri Nets for matching multiple forms of type. First, the semantic processes of code snippets consisting of the number of data objects and types of data objects in the code corpus are converted into improved Petri Net models. Second, the initial marking and target marking of Petri Net models are constructed according to the number of data objects and types of data objects contained in users’ queries. Matching code snippets is obtained by the analysis of reachable paths in reachability graphs and induced networks of Petri Nets. Analysis and experimental results show that this approach contributes to seeking out desired code snippets by queries that possess multiple forms of inputoutput types provided by users, and compared with traditional approaches, it can significantly improve accuracy and efficiency of code search.
-
Keywords:
- code reuse /
- semantic search /
- matching type /
- Petri Net model /
- reachability analysis
-
-
期刊类型引用(2)
1. 邵子豪,霍如,王志浩,倪东,谢人超. 基于区块链的移动群智感知数据处理研究综述. 浙江大学学报(工学版). 2024(06): 1091-1106 . 百度学术
2. 赵贺贺,高鹏飞,张健明. 英式逆拍卖可以提高第三支柱养老保险市场效率吗?. 长沙民政职业技术学院学报. 2023(01): 74-80 . 百度学术
其他类型引用(1)
计量
- 文章访问数: 330
- HTML全文浏览量: 6
- PDF下载量: 257
- 被引次数: 3