Hostname: page-component-586b7cd67f-tf8b9 Total loading time: 0 Render date: 2024-11-29T00:12:24.486Z Has data issue: false hasContentIssue false

Semantic code browsing*

Published online by Cambridge University Press:  14 October 2016

ISABEL GARCÍA-CONTRERAS
Affiliation:
IMDEA Software Institute (e-mails: [email protected], [email protected], [email protected])
JOSÉ F. MORALES
Affiliation:
IMDEA Software Institute (e-mails: [email protected], [email protected], [email protected])
MANUEL V. HERMENEGILDO
Affiliation:
IMDEA Software Institute (e-mails: [email protected], [email protected], [email protected]) School of Computer Science, Technical University of Madrid (UPM) (e-mail: [email protected])

Abstract

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.

Type
Regular Papers
Copyright
Copyright © Cambridge University Press 2016 

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Footnotes

*

This research has received funding from the EU FP7 agreement no 318337, ENTRA, Spanish MINECO TIN2012-39391 StrongSoft and TIN2015-67522-C3-1-R TRACES projects, and the Madrid M141047003 N-GREENS program.

References

Bruynooghe, M. 1991. A practical framework for the abstract interpretation of Logic Programs. Journal of Logic Programming 10, 91124.Google Scholar
Cabeza, D. and Hermenegildo, M. 2000. A new module system for Prolog. In International Conference CL 2000, LNAI, vol. 1861. Springer-Verlag, 131148.Google Scholar
Cousot, P. and Cousot, R. 1977. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In Proc. of POPL'77. ACM Press, 238252.CrossRefGoogle Scholar
Gallagher, J. and de Waal, D. 1994. Fast and precise regular approximations of logic programs. In Proc. of ICLP'94. MIT Press, 599613.Google Scholar
Hermenegildo, M., Puebla, G., Bueno, F. and Lopez-Garcia, P. 2005. Integrated program debugging, verification, and optimization using abstract interpretation (and the ciao system preprocessor). Science of Computer Programming 58, 1–2 (October), 115140.CrossRefGoogle Scholar
Hermenegildo, M. V., Bueno, F., Carro, M., López, P., Mera, E., Morales, J. and Puebla, G. 2012. An overview of ciao and its design philosophy. Theory and Practice of Logic Programming 12, 1–2, 219252. http://arxiv.org/abs/1102.5497.CrossRefGoogle Scholar
Maarek, Y. S., Berry, D. M. and Kaiser, G. E. 1991. An information retrieval approach for automatically constructing software libraries. Software Engineering, IEEE Transactions on 17, 8, 800813.Google Scholar
McMillan, C., Hariri, N., Poshyvanyk, D., Cleland-Huang, J. and Mobasher, B. 2012. Recommending source code for use in rapid software prototypes. In Proceedings of the 34th International Conference on Software Engineering. IEEE Press, 848858.Google Scholar
Mitchell, N. 2008. Hoogle overview. The Monad.Reader 12 (November), 2735.Google Scholar
Muthukumar, K. and Hermenegildo, M. 1991. Combined determination of sharing and freeness of program variables through abstract interpretation. In International Conference on Logic Programming (ICLP 1991). MIT Press, 4963.Google Scholar
Muthukumar, K. and Hermenegildo, M. 1992. Compile-time derivation of variable dependency using abstract interpretation. Journal of Logic Programming 13, 2/3 (July), 315347.Google Scholar
Puebla, G., Bueno, F. and Hermenegildo, M. 2000a. An assertion language for constraint logic programs. In Analysis and Visualization Tools for Constraint Programming. Number 1870 in LNCS. Springer-Verlag, 2361.CrossRefGoogle Scholar
Puebla, G., Bueno, F. and Hermenegildo, M. 2000b. Combined static and dynamic assertion-based debugging of constraint logic programs. In Logic-based Program Synthesis and Transformation (LOPSTR'99), Number 1817 in LNCS. Springer-Verlag, 273292.CrossRefGoogle Scholar
Puebla, G., Correas, J., Hermenegildo, M., Bueno, F., García de la Banda, M., Marriott, K. and Stuckey, P. J. 2004. A generic framework for context-sensitive analysis of modular programs. In Program Development in Computational Logic, Number 3049 in LNCS. Springer-Verlag, 234261.Google Scholar
Puebla, G. and Hermenegildo, M. 1999. Abstract multiple specialization and its application to program parallelization. J. of Logic Programming. Special Issue on Synthesis, Transformation and Analysis of Logic Programs 41, 2&3 (November), 279316.Google Scholar
Reiss, S. P. 2009. Semantics-based code search. In Proceedings of the 31st International Conference on Software Engineering. IEEE Computer Society, 243253.Google Scholar
Rollins, E. J. and Wing, J. M. 1991. Specifications as Search Keys for Software Libraries. In Proceedings of the Eighth International Conference on Logic Programming. MIT Press, 173187.Google Scholar
Stulova, N., Morales, J. F. and Hermenegildo, M. V. 2014. Assertion-based debugging of higher-order (C)LP programs. In 16th Int'l. ACM SIGPLAN Symposium on Principles and Practice of Declarative Programming (PPDP'14). ACM Press.Google Scholar
Vaucheret, C. and Bueno, F. 2002. More precise yet efficient type inference for logic programs. In SAS'02. Number 2477 in LNCS. Springer, 102116.Google Scholar
Supplementary material: PDF

García-Contreras supplementary material

Online Appendix

Download García-Contreras supplementary material(PDF)
PDF 421.3 KB