Our website uses cookies to enhance your browsing experience.
Accept
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam

>
>
How VivaCore library appeared

How VivaCore library appeared

Aug 10 2008
Author:

The article describes the main preconditions and stages of development of open VivaCore library intended for code analysis and creation of metaprogramming systems. VivaCore project is a development of OpenC++ library in which support of C and C++ language peculiarities specific for Visual Studio 2005/2008 is implemented.

Introduction

This article is intended for software developers who use or plan to use VivaCore library in their developments. The article touches upon the history of creating VivaCore library and relating peculiarities of the library's implementation.

VivaCore library is a project with open program code built on the basis of an older library OpenC++ (OpenCxx). VivaCore library is implemented in C++ and meant to be used in VisualStudio 2005/2008 environment.

VivaCore library was created and continues to develop thanks to OOO "Program Verification Systems". VivaCore code analysis library has a State Computer program certificate N 2008610480.

You can use VivaCore library free. The only license limitation concerning it is the necessity to mention that your project has been developed on the basis of OpenC++ library and its development VivaCore.

The library is used to develop projects in which analysis of source code of C and C++ programs is performed. Such an example is systems of language syntax extension, code editing and coloring systems, static analyzers, systems of building documentation on the code. To learn more about the library and possible ways to use it see article "The essence of the code analysis library VivaCore" [1].

VivaCore library as part of Viva64 product

Creation of VivaCore has never been planned purposely but it appeared in an absolutely natural way while working on Viva64 project. Viva64 product is a specialized tool for testing source code of C/C++ programs to establish if they are compatible with 64-bit platforms [2]. Viva64 is a typical static code analyzer meant to help programmers while developing 64-bit applications.

Of course, an essential part of Viva64 project is the system of parsing source code of programs for further analysis. OpenC++ (OpenCxx) was used as a library for code parsing. On the initial stage of Viva64 product's development its inner structure was as shown on Picture 1.

a0027_VivaCore_history/image1.png

Picture 1. How we imagined Viva64 project's structure to look.

As seen from the picture there was the code of Viva64 project which used functionality of OpenC++ library inside it.

But it became clear already at early stages of implementation that OpenC++ library doesn't implement the whole necessary functionality, contains some disappointing errors and doesn't support fully key words used in Visual C++ compiler. This was the stimulus to develop new functionality and improve OpenC++ library.

Let's give some examples of improvements. C language support was implemented (OpenC++ works only with C++ code) as well as calculation of values of literal constants. Specific key words __noop, __if_exists, __ptr32 became supported too. And so on.

As the result of these changes, large code has been written which related to a code analysis library in its meaning, but it was implemented in Viva64's code. Because of it Viva64's architecture looked as shown on Picture 2.

a0027_VivaCore_history/image2.png

Picture 2. Implementation of functionality relating to C/C++ code parsing in Viva64.

It became evident that some functionality relating to code parsing should be enclosed into a separate module. Thus VivaCore library appeared. Although its code was still inside Viva64 project, it was separated logically. Viva64's structure became as shown on Picture 3.

a0027_VivaCore_history/image3.png

Picture 3. A decision is made to enclose functionality relating to C/C++ code parsing into a separate library VivaCore.

The new architecture where code parsing functionality was enclosed into a separate subsystem VivaCore was convenient for us. But we decided to go further.

VivaCore library's independent life

We decided to provide other developers with an opportunity to use new abilities implemented within the framework of VivaCore. It turned out to be too difficult a task to update OpenC++ library up to the necessary level. That's why we decided simply to make VivaCore library a separate project (Picture 4) and put it on OOO "Program Verification Systems" site. You can download source code of VivaCore library here.

a0027_VivaCore_history/image4.png

Picture 4. Viva64's new structure.

Now VivaCore library can be used not only within the framework of OOO "Program Verification Systems" projects such as Viva64, VivaMP, but in projects of third-party developers as well (Picture 5).

a0027_VivaCore_history/image5.png

Picture 5. Open library VivaCore for developing projects dealing with source C/C++ code.

Besides VivaCore library itself developers can download a demo program VivaVisualCode [3]. It shows some abilities of VivaCore library by an example of graphic representation of a parse tree. An example of such a tree is shown on Picture 6.

a0027_VivaCore_history/image6.png

Picture 6. Parse tree for expression "const bool is64bitInt = sizeof(int) == 8;".

Peculiarities of the library relating to the history of its development

As VivaCore library has been developed as part of Viva64 project it was reflected in some peculiarities of its implementation. These peculiarities are:

  • Accurate diagnosis of syntax errors in program text was sacrificed to the ability of processing as much code as possible. In case of parsing of code with the purpose to perform its static analysis or some other processing (for example, coloring) it is more important to process as much text as possible ignoring errors met. To detect syntax errors a compiler is used. VivaCore library supposes that the code is correct. If it is not, it tries to ignore an incorrect section and starts parsing at the next correct construction. It is useful if the code is incomplete or contains new unknown key words or too complex constructions based on generic classes. However, nothing prevents the user from inserting corresponding processors of incorrect input data.
  • Garbage Collector mechanism is not implemented in OpenC++. VivaCore library has the same problem. As the result, while working VivaCore is constantly allocating memory without returning it. It is not critically for Viva64 analyzer because it is launched for each file separately. If a developer needs to work with the library for a long time, he will have to implement the missing functionality.
  • The library is optimized for working on 64-bit systems.
  • There is no integral documentation. However, it is absent in OpenC++ as well. That's why developers must be ready to spend some time on mastering it. Contact us if you have any questions. We'll try to help you.
  • The library contains some functions which don't take part in the very code parsing but are necessary for Viva64 and VivaMP projects.

Conclusion

I hope this article will help you to decide whether you should use VivaCore library in your projects. If you are not sure - write. We'll try to provide you with additional information and answer your questions.

References

Popular related articles


Comments (0)

Next comments next comments
close comment form