arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1608.02565cs.PL
收藏

语义代码浏览

Semantic Code Browsing

Isabel Garcia-Contreras, Jose F. Morales, Manuel V. Hermenegildo

摘要:

程序员目前可以访问数量非常多的代码存储库和不断增长的库。然而,在所有这些代码中进行搜索变得越来越困难,这一事实阻碍了随后的重用潜力。大多数代码搜索引擎都是基于语法技术的,比如签名匹配或关键字提取。但是,这些技术是不准确的(因为它们基本上依赖于文档),同时也不能提供非常有表现力的代码查询语言。我们提出了一种新的方法,专注于查询自动获得的代码本身的语义特征。使用静态分析技术对程序单元进行预处理,基于抽象解释,获得安全的语义近似。一种新的,基于断言的代码查询语言被用来表达所需的部分规范的代码的语义特征。通过将这些部分规范与程序元素的推断语义进行比较来找到相关代码。我们的方法是全自动的,不依赖于用户注释或文档。它比签名匹配更强大和灵活,因为它是抽象域和属性的参数,并且不需要类型定义。此外,它的原因与属性之间的关系,如蕴涵和抽象,而不仅仅是平等。它对语法代码差异的适应性也更强。我们描述的方法和报告的Ciao系统内的原型实现。正在考虑接受TPLP。

英文摘要:

Programmers currently enjoy access to a very high number of code repositories and libraries of ever increasing size. The ensuing potential for reuse is however hampered by the fact that searching within all this code becomes an increasingly difficult task. Most code search engines are based on syntactic techniques such as signature matching or keyword extraction. However, these techniques are inaccurate (because they basically rely on documentation) and at the same time do not offer very expressive code query languages. We propose a novel approach that focuses on querying for semantic characteristics of code obtained automatically from the code itself. Program units are pre-processed using static analysis techniques, based on abstract interpretation, obtaining safe semantic approximations. A novel, assertion-based code query language is used to express desired semantic characteristics of the code as partial specifications. Relevant code is found by comparing such partial specifications with the inferred semantics for program elements. Our approach is fully automatic and does not rely on user annotations or documentation. It is more powerful and flexible than signature matching because it is parametric on the abstract domain and properties, and does not require type definitions. Also, it reasons with relations between properties, such as implication and abstraction, rather than just equality. It is also more resilient to syntactic code differences. We describe the approach and report on a prototype implementation within the Ciao system. Under consideration for acceptance in TPLP.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑